/** * Implementation of the * {@link er.directtoweb.assignments.ERDComputingAssignmentInterface}. * * @return empty array. */ @Override public NSArray<String> dependentKeys(String keyPath) { return new NSArray<String>(ERD2WPage.Keys.propertyKey, ERMDAjaxNotificationCenter.PROPERTY_DEPENDENCIES.key()); }
/** * Returns an array of all of the available tags in the system that start with * the given string. * * @param startsWith the prefix to lookup * @param editingContext the editing context to fetch into * @return an array of matching tags */ @SuppressWarnings("unchecked") public NSArray<String> fetchTagsLike(EOEditingContext editingContext, String startsWith) { NSArray<ERTag> erTags = ERTag.fetchERTags(editingContext, ERTag.NAME.likeInsensitive(startsWith + "*"), null); NSArray<String> tags = (NSArray<String>) erTags.valueForKey(ERTag.NAME_KEY); return tags; }
public String id() { if (id == null) { id = ERXWOContext.safeIdentifierName(context(), true); AJAX_NOTIFICATION_CENTER_ID.takeValueInObject(id, d2wContext()); } return id; }
/** * This method returns a simple count of the number of distinct objects which match the tags provided. * * @param editingContext the editing context to fetch into * @param tags the tags to search (String to tokenize, NSArray<String>, etc) * @param inclusion find matches for ANY tags or ALL tags provided * @return the count of distinct objects for the given tags */ public int countUniqueTaggedWith(EOEditingContext editingContext, ERTag.Inclusion inclusion, Object tags) { NSArray<String> tagNames = splitTagNames(tags); if (tagNames.count() == 0) { throw new IllegalArgumentException("No tags were passed in."); } EOQualifier qualifier = new ERXKey<ERTag>(_tagsRelationship.name()).append(ERTag.NAME).in(tagNames); EOFetchSpecification fetchSpec = new EOFetchSpecification(_entity.name(), qualifier, null); fetchSpec.setUsesDistinct(true); ERXSQLHelper sqlHelper = ERXSQLHelper.newSQLHelper(_entity.model()); EOSQLExpression sqlExpression = sqlHelper.sqlExpressionForFetchSpecification(editingContext, fetchSpec, 0, -1); sqlHelper.addGroupByClauseToExpression(editingContext, fetchSpec, sqlExpression); if (inclusion == ERTag.Inclusion.ALL) { sqlHelper.addHavingCountClauseToExpression(EOQualifier.QualifierOperatorEqual, tagNames.count(), sqlExpression); } int count = sqlHelper.rowCountForFetchSpecification(editingContext, fetchSpec); return count; }
public NSDictionary<String, NSArray<String>> propertyDependencies(D2WContext context) { NSDictionary<String, NSArray<String>> propertyDependencies = PROPERTY_DEPENDENCIES .valueInObject(context); return propertyDependencies; }
/** * Checks to see if this object has been tagged with any of the given tags. * * @param tags the tags to add (String to tokenize, NSArray<String>, etc) * @return true if this eo is tagged with any of the given tag names, false otherwise */ public boolean isTaggedWithAny(Object tags) { NSArray<String> tagNames = _entity.splitTagNames(tags); return ERXQ.filtered(tags(), ERTag.NAME.in(tagNames)).count() > 0; }
/** * Checks to see if this object has been tagged with the given tag name. * * @param tagName the tag name to check * @return true if this eo is tagged with the given tag name, false otherwise */ public boolean isTaggedWith(String tagName) { return ERXQ.filtered(tags(), ERTag.NAME.is(tagName)).count() > 0; }
/** * Checks whether the current property is declared as to be observed via the * propertyDependencies key. * * @return true if the current property key is to be observed */ public Object shouldObserve(D2WContext context) { boolean shouldObserve = false; NSDictionary<String, NSArray<String>> propertyDependencies = ERMDAjaxNotificationCenter.PROPERTY_DEPENDENCIES .valueInObject(context); if (propertyDependencies != null && propertyDependencies.containsKey(context.propertyKey())) { shouldObserve = true; } return shouldObserve; }
/** * This method removes tags from the target object, by parsing the tags parameter * into Tag object instances and removing them from the tag collection of the object if they exist. * * @param tags the tags to remove (String to tokenize, NSArray<String>, etc) */ public void removeTags(Object tags) { NSArray<ERTag> erTags = tags(); NSArray<ERTag> matchingTags = ERXQ.filtered(erTags, ERTag.NAME.in(_entity.splitTagNames(tags))); for (ERTag tag : matchingTags) { removeTag(tag); } }
/** * This method removes tags from the target object, by looking up the corresponding * Tag object instances and removing them from the tag collection of the object if they exist. * * @param tagName the tag to remove (String to tokenize, NSArray<String>, etc) */ public void removeTagNamed(String tagName) { NSArray<ERTag> erTags = tags(); NSArray<ERTag> matchingTags = ERXQ.filtered(erTags, ERTag.NAME.is(tagName)); for (ERTag tag : matchingTags) { removeTag(tag); } }
EOQualifier tagNameQualifier = new ERXKey<ERTag>(_tagsRelationship.name()).append(ERTag.NAME).in(tagNames); EOFetchSpecification fetchSpec = new EOFetchSpecification(_entity.name(), tagNameQualifier, null); EOSQLExpression sqlExpression = sqlHelper.sqlExpressionForFetchSpecification(editingContext, fetchSpec, 0, -1, fetchAttributes); tagsFetchAttributes.addObject(countAttribute); EOQualifier idQualifier = new ERXKey<Object>("id").in(itemPrimaryKeys); EOFetchSpecification tagsFetchSpec = new EOFetchSpecification(_entity.name(), idQualifier, null); EOSQLExpression tagsSqlExpression = sqlHelper.sqlExpressionForFetchSpecification(editingContext, tagsFetchSpec, 0, -1, tagsFetchAttributes);
/** * @param context * The d2wContext of the changed property level component * @return a list of property keys to be updated */ @SuppressWarnings("unchecked") public NSArray<String> propertyChanged(D2WContext context) { String prop = context.propertyKey(); NSArray<String> dependants = NSArray.EmptyArray; NSDictionary<String, NSArray<String>> propertyDependencies = PROPERTY_DEPENDENCIES .valueInObject(context); if (propertyDependencies.containsKey(prop)) { dependants = (NSArray<String>) propertyDependencies.valueForKey(prop); } return dependants; }
/** * Checks to see if this object has been tagged with all the given tags. * * @param tags the tags to add (String to tokenize, NSArray<String>, etc) * @return true if this eo is tagged with all of the given tag names, false otherwise */ public boolean isTaggedWithAll(Object tags) { NSArray<String> tagNames = _entity.splitTagNames(tags); return ERXQ.filtered(tags(), ERTag.NAME.in(tagNames)).count() == tagNames.count(); }
NSArray<ERTag> tags = (NSArray<ERTag>) ERXEOControlUtilities.objectsWithQualifier(editingContext, _tagEntity.name(), ERTag.NAME.is(tagName), null, true, true, true, true); ERTag tag; if (tags.count() == 0) {
/** * Checks whether the current property is declared dependent via the * propertyDependencies key. * * @return true if the current property is dependent */ public Object isDependent(D2WContext context) { boolean isDependent = false; NSDictionary<String, NSArray<String>> propertyDependencies = ERMDAjaxNotificationCenter.PROPERTY_DEPENDENCIES .valueInObject(context); if (propertyDependencies != null) { if (ERXArrayUtilities.flatten(propertyDependencies.allValues()).contains( context.propertyKey())) { isDependent = true; } } return isDependent; }
public void propertyChanged(NSNotification n) { log.debug("Property changed for property key: {}", PROPERTY_KEY.valueInObject(n.object())); NSArray<String> updateProps = propertyChanged((D2WContext) n.object()); if (updateProps != null && updateProps.count() > 0) { refreshRelationships(updateProps); // collect the corresponding update container IDs NSMutableArray<String> attributeLineUCs = new NSMutableArray<String>(); D2WContext c = (D2WContext) n.object(); String pageConfiguration = (String) c.valueForKey("pageConfiguration"); for (String aPropertyName : updateProps) { String lineUC = pageConfiguration; lineUC = lineUC.concat(ERXStringUtilities.capitalize(aPropertyName)); lineUC = lineUC.concat("LineUC"); attributeLineUCs.addObject(lineUC); } ERXArrayUtilities.addObjectsFromArrayWithoutDuplicates(updateContainerIDs, attributeLineUCs); // force update of notification center UC AjaxUpdateContainer.safeUpdateContainerWithID(id, context()); log.debug("Container ids to be updated: {}", updateContainerIDs.componentsJoinedByString(", ")); } }