/** * 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; }
public ERCAuditTrail auditTrailForObject(EOEditingContext ec, EOEnterpriseObject eo) { EOKeyGlobalID gid = null; if (eo instanceof ERXGenericRecord) { gid = ((ERXGenericRecord) eo).permanentGlobalID(); } else { throw new IllegalArgumentException("Can't handle non ERXGenericRecord"); } ERCAuditTrail trail = (ERCAuditTrail) ERXEOControlUtilities.objectWithQualifier(ec, ENTITY_NAME, ERXQ.equals(Key.GID, ERXKeyGlobalID.globalIDForGID(gid))); if (trail == null) { trail = (ERCAuditTrail) EOQualifier.filteredArrayWithQualifier(ec.insertedObjects(), ERXQ.equals("entityName", ENTITY_NAME).and(ERXQ.equals(Key.GID + ".globalID", gid))).lastObject(); } return trail; }
@SuppressWarnings("unchecked") public NSArray<EOEnterpriseObject> destinationObjectsWithQualifier(EOQualifier qual) { NSArray<EOEnterpriseObject> result = null; NSArray<EOSortOrdering> orderings = null; if (!ERXStringUtilities.stringIsNullOrEmpty(sortKey())) { orderings = ERXS.ascs(sortKey()); } if (extraQualifier() != null) { qual = ERXQ.and(qual, extraQualifier()); } if (useFetch() && ERXStringUtilities.stringIsNullOrEmpty(restrictedChoiceKey())) { if(restrictingFetchSpecificationName() != null) { qual = ERXQ.and(qual, restrictingFetchSpec().qualifier()); } EOFetchSpecification fetchSpec = new EOFetchSpecification(destinationEntityName(), qual, orderings); if (!ERXStringUtilities.stringIsNullOrEmpty((String) d2wContext() .valueForKey(Keys.fetchLimit))) { fetchSpec.setFetchLimit(Integer.valueOf((String) d2wContext() .valueForKey(Keys.fetchLimit))); } fetchSpec.setIsDeep(true); EOEditingContext ec = ERXEC.newEditingContext(); result = ec.objectsWithFetchSpecification(fetchSpec); } else { result = ERXQ.filtered(allItems(), qual); } return result; }
String destinationAttribute = toJoinRelationship.destinationAttributes().get(0).name(); ERXFetchSpecification fs = new ERXFetchSpecification(joinEntity.name(), ERXQ.equals(destinationAttribute, row.valueForKey(sourceAttribute)), null); NSArray<NSMutableDictionary<String, Object>> fetchedObjects = joinStore.fetch(joinEntity.attributesToFetch(), EOEntity destEntity = relationship.destinationEntity(); fs = new ERXFetchSpecification(destEntity.name(), ERXQ.in(destinationAttribute, destValues), null); EREntityStore destinationStore = context._entityStoreForEntity(destEntity); fetchedObjects = destinationStore.fetch(destEntity.attributesToFetch(), fs, false, destEntity, context);
EOQualifier additionalTagCountQualifier = additionalTagCountQualifier(); if (additionalTagCountQualifier != null || additionalQualifier != null) { combinedAdditionalQualifier = ERXQ.and(additionalQualifier, additionalTagCountQualifier);
NSArray<EOKeyValueQualifier> keyValueQualifiers = ERXQ.extractKeyValueQualifiers(qualifier); for (EOKeyValueQualifier keyValueQualifier : keyValueQualifiers) { String qualifierKey = keyValueQualifier.key(); if (mergeRelationship != null) { mergeRelationships.add(mergeRelationship); qualifier = ERXQ.replaceQualifierWithQualifier(qualifier, keyValueQualifier, ERXQ.has(qualifierKey, new NSArray(keyValueQualifier.value()))); } else if (qualifierKey.equals(entity.primaryKeyAttributeNames().get(0)) && keyValueQualifier.selector().name().equals("doesContain") && !(keyValueQualifier.value() instanceof NSArray)) { qualifier= ERXQ.replaceQualifierWithQualifier(qualifier, keyValueQualifier, ERXQ.is(qualifierKey, keyValueQualifier.value()));
/** * Will fetch related rows for the given row relationship. The * context will be used to access the needed entity store. * * @param entity * the current entity * @param row * the currently selected row * @param relationship * the relationship * @param context * the memory adaptor context * @return array of rows from related entity store */ protected NSArray<NSMutableDictionary<String, Object>> fetchRelatedRows(EOEntity entity, NSDictionary<String, Object> row, EORelationship relationship, ERMemoryAdaptorContext context) { EOEntity destEntity = relationship.destinationEntity(); EREntityStore destStore = context._entityStoreForEntity(destEntity); String sourceAttribute = relationship.sourceAttributes().get(0).name(); String destinationAttribute = relationship.destinationAttributes().get(0).name(); ERXFetchSpecification fs = new ERXFetchSpecification(destEntity.name(), ERXQ.equals(destinationAttribute, row.valueForKey(sourceAttribute)), null); return destStore.fetch(destEntity.attributesToFetch(), fs, false, destEntity, context); }
qualifier = ERXQ.and(qualifier, additionalQualifier);
/** * Action called when the user makes a selection from the AjaxAutoComplete */ public WOActionResults selectObject() { // log.debug("selectobject called: " + item); EOQualifier qual = ERXQ.equals(keyWhenRelationship(), searchValue()); NSArray<EOEnterpriseObject> objs = destinationObjectsWithQualifier(qual); if (objs != null && objs.count() > 0) { EOEnterpriseObject localEO = ERXEOControlUtilities.localInstanceOfObject(object().editingContext(), objs.objectAtIndex(0)); object().addObjectToBothSidesOfRelationshipWithKey(localEO, propertyKey()); } else { EOEnterpriseObject existingObj = (EOEnterpriseObject)object().valueForKey(propertyKey()); if (existingObj != null) { object().removeObjectFromBothSidesOfRelationshipWithKey(existingObj, propertyKey()); } } // support for ERMDAjaxNotificationCenter if (ERXValueUtilities.booleanValueWithDefault(d2wContext().valueForKey("shouldObserve"), false)) { NSNotificationCenter.defaultCenter().postNotification( ERMDAjaxNotificationCenter.PropertyChangedNotification, parent().valueForKeyPath("d2wContext")); } // NSLog.out.appendln("Select Object Called: " + object().valueForKey(propertyKey()) + " " + searchValue()); return null; }
/** * 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); } }
/** * 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; }
/** * 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); } }
/** * 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(); }