private void storeRelationshipType(Relationship relationship) { String type = relationship.getClass().getName(); Map<String, FileRelationship> storedRelationships = this.fileDataSource.getRelationships().get(type); if (storedRelationships == null) { storedRelationships = new ConcurrentHashMap<String, FileRelationship>(); this.fileDataSource.getRelationships().put(type, storedRelationships); } storedRelationships.put(relationship.getId(), new FileRelationship(relationship)); this.fileDataSource.flushRelationships(); }
@Override protected void removeFromRelationships(IdentityContext context, IdentityType identityType) { Map<String, Map<String, FileRelationship>> relationships = this.fileDataSource.getRelationships(); for (Map<String, FileRelationship> relationshipsType : relationships.values()) { for (FileRelationship fileRelationship : new HashMap<String, FileRelationship>(relationshipsType).values()) { if (fileRelationship.hasIdentityType(identityType)) { relationshipsType.remove(fileRelationship.getId()); } } } this.fileDataSource.flushRelationships(); }
FileRelationship storedRelationship = partitionRelationships.get(id); if (storedRelationship != null && typeToSearch.isAssignableFrom(storedRelationship.getEntry().getClass())) { result.add((T) cloneAttributedType(context, storedRelationship.getEntry())); return result; boolean match = query.getParameters().isEmpty(); if (typeToSearch.isInstance(storedRelationship.getEntry())) { for (Entry<QueryParameter, Object[]> entry : query.getParameters().entrySet()) { QueryParameter queryParameter = entry.getKey(); IdentityType identityType = (IdentityType) object; if (storedRelationship.hasIdentityType(identityType)) { valuesMathCount--; String identityTypeId = storedRelationship.getIdentityTypeId(identityTypeParameter.getName()); Serializable value = property.getValue(storedRelationship.getEntry()); loadAttributes(context, storedRelationship.getEntry()); match = matchAttribute(storedRelationship.getEntry(), attributeParameter.getName(), values); T relationship = (T) cloneAttributedType(context, storedRelationship.getEntry()); reference.addIdentityTypeReference(property.getName(), storedRelationship.getIdentityTypeId (property.getName()));
@Override protected void doPopulateProperties(Map<String, Serializable> properties) throws Exception { super.doPopulateProperties(properties); List<Property<IdentityType>> relationshipIdentityTypes = PropertyQueries .<IdentityType> createQuery(getEntry().getClass()) .addCriteria(new TypedPropertyCriteria(IdentityType.class, MatchOption.SUB_TYPE)).getResultList(); for (Property<IdentityType> annotatedProperty : relationshipIdentityTypes) { IdentityType identityType = annotatedProperty.getValue(getEntry()); if (identityType != null) { this.identityTypeIds.put(IdentityTypeUtil.formatId(identityType), annotatedProperty.getName()); } } }
@Override public void removeAttributedType(IdentityContext context, AttributedType attributedType) { if (IdentityType.class.isInstance(attributedType)) { IdentityType identityType = (IdentityType) attributedType; Partition partition = identityType.getPartition(); FilePartition filePartition = resolve(partition.getClass(), partition.getName()); Map<String, FileIdentityType> identityTypes = filePartition.getIdentityTypes().get(attributedType.getClass().getName()); if (identityTypes != null) { identityTypes.remove(identityType.getId()); } this.fileDataSource.flushAttributedTypes(filePartition); } else if (Relationship.class.isInstance(attributedType)) { Map<String, FileRelationship> fileRelationships = this.fileDataSource.getRelationships() .get(attributedType.getClass().getName()); for (FileRelationship fileRelationship : new HashMap<String, FileRelationship>(fileRelationships).values()) { if (fileRelationship.getId().equals(attributedType.getId())) { fileRelationships.remove(fileRelationship.getId()); } } this.fileDataSource.flushRelationships(); } else { this.fileDataSource.getAttributedTypes().remove(attributedType.getId()); this.fileDataSource.flushAttributedTypes(); } }
FileRelationship storedRelationship = partitionRelationships.get(id); if (storedRelationship != null && typeToSearch.isAssignableFrom(storedRelationship.getEntry().getClass())) { result.add((T) cloneAttributedType(context, storedRelationship.getEntry())); return result; boolean match = query.getParameters().isEmpty(); if (typeToSearch.isInstance(storedRelationship.getEntry())) { for (Entry<QueryParameter, Object[]> entry : query.getParameters().entrySet()) { QueryParameter queryParameter = entry.getKey(); IdentityType identityType = (IdentityType) object; if (storedRelationship.hasIdentityType(identityType)) { valuesMathCount--; String identityTypeId = storedRelationship.getIdentityTypeId(identityTypeParameter.getName()); Serializable value = property.getValue(storedRelationship.getEntry()); loadAttributes(context, storedRelationship.getEntry()); match = matchAttribute(storedRelationship.getEntry(), attributeParameter.getName(), values); T relationship = (T) cloneAttributedType(context, storedRelationship.getEntry()); reference.addIdentityTypeReference(property.getName(), storedRelationship.getIdentityTypeId (property.getName()));
@Override protected void doPopulateProperties(Map<String, Serializable> properties) throws Exception { super.doPopulateProperties(properties); List<Property<IdentityType>> relationshipIdentityTypes = PropertyQueries .<IdentityType> createQuery(getEntry().getClass()) .addCriteria(new TypedPropertyCriteria(IdentityType.class, MatchOption.SUB_TYPE)).getResultList(); for (Property<IdentityType> annotatedProperty : relationshipIdentityTypes) { IdentityType identityType = annotatedProperty.getValue(getEntry()); if (identityType != null) { this.identityTypeIds.put(IdentityTypeUtil.formatId(identityType), annotatedProperty.getName()); } } }
@Override public void removeAttributedType(IdentityContext context, AttributedType attributedType) { if (IdentityType.class.isInstance(attributedType)) { IdentityType identityType = (IdentityType) attributedType; Partition partition = identityType.getPartition(); FilePartition filePartition = resolve(partition.getClass(), partition.getName()); Map<String, FileIdentityType> identityTypes = filePartition.getIdentityTypes().get(attributedType.getClass().getName()); if (identityTypes != null) { identityTypes.remove(identityType.getId()); } this.fileDataSource.flushAttributedTypes(filePartition); } else if (Relationship.class.isInstance(attributedType)) { Map<String, FileRelationship> fileRelationships = this.fileDataSource.getRelationships() .get(attributedType.getClass().getName()); for (FileRelationship fileRelationship : new HashMap<String, FileRelationship>(fileRelationships).values()) { if (fileRelationship.getId().equals(attributedType.getId())) { fileRelationships.remove(fileRelationship.getId()); } } this.fileDataSource.flushRelationships(); } else { this.fileDataSource.getAttributedTypes().remove(attributedType.getId()); this.fileDataSource.flushAttributedTypes(); } }
@Override protected void removeFromRelationships(IdentityContext context, IdentityType identityType) { Map<String, Map<String, FileRelationship>> relationships = this.fileDataSource.getRelationships(); for (Map<String, FileRelationship> relationshipsType : relationships.values()) { for (FileRelationship fileRelationship : new HashMap<String, FileRelationship>(relationshipsType).values()) { if (fileRelationship.hasIdentityType(identityType)) { relationshipsType.remove(fileRelationship.getId()); } } } this.fileDataSource.flushRelationships(); }
private void storeRelationshipType(Relationship relationship) { String type = relationship.getClass().getName(); Map<String, FileRelationship> storedRelationships = this.fileDataSource.getRelationships().get(type); if (storedRelationships == null) { storedRelationships = new ConcurrentHashMap<String, FileRelationship>(); this.fileDataSource.getRelationships().put(type, storedRelationships); } storedRelationships.put(relationship.getId(), new FileRelationship(relationship)); this.fileDataSource.flushRelationships(); }