@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(); }
@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(); }
@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 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(); } }