@Test public void testAddRelationshipDef() { OMRSArchiveBuilder oMRSArchiveBuilder = getOMRSArchiveBuilder(); EntityDef entityDefA = new EntityDef(TypeDefCategory.ENTITY_DEF,"1111","EntityDefA",1L,"1"); oMRSArchiveBuilder.addEntityDef(entityDefA); EntityDef entityDefB = new EntityDef(TypeDefCategory.ENTITY_DEF,"2222","EntityDefB",1L,"1"); oMRSArchiveBuilder.addEntityDef(entityDefB); assertNotNull(oMRSArchiveBuilder); List<TypeDefAttribute> propertyList1 = new ArrayList<>(); TypeDefAttribute attr1 = new TypeDefAttribute(); attr1.setAttributeName("abc"); propertyList1.add(attr1); entityDefA.setPropertiesDefinition(propertyList1); List<TypeDefAttribute> propertyList2 = new ArrayList<>(); TypeDefAttribute attr2 = new TypeDefAttribute(); attr2.setAttributeName("abc2"); propertyList2.add(attr2); entityDefB.setPropertiesDefinition(propertyList2); RelationshipDef relationshipDef = new RelationshipDef(TypeDefCategory.RELATIONSHIP_DEF, "3333", "EntityDef1", 1L, "1"); RelationshipEndDef endDef1 = new RelationshipEndDef(); endDef1.setAttributeName("aaaa"); TypeDefLink entityTypeA = new TypeDefLink(); entityTypeA.setGUID("1111"); entityTypeA.setName("EntityDefA"); endDef1.setEntityType(entityTypeA); relationshipDef.setEndDef1(endDef1); RelationshipEndDef endDef2 = new RelationshipEndDef(); endDef2.setAttributeName("bbbb"); TypeDefLink entityTypeB= new TypeDefLink(); entityTypeB.setGUID("2222"); entityTypeB.setName("EntityDefB"); endDef2.setEntityType(entityTypeB); relationshipDef.setEndDef2(endDef2); List<TypeDefAttribute> propertyList3 = new ArrayList<>(); TypeDefAttribute attr3 = new TypeDefAttribute(); attr3.setAttributeName("abc3"); propertyList3.add(attr3); relationshipDef.setPropertiesDefinition(propertyList3); oMRSArchiveBuilder.addRelationshipDef(relationshipDef); }
public void addRelationshipDef(RelationshipDef relationshipDef) { final String methodName = "addRelationshipDef"; if (relationshipDef != null) { log.debug("Adding RelationshipDef: " + relationshipDef.toString()); this.checkForBlanksInTypeName(relationshipDef.getName()); RelationshipDef duplicateElement = relationshipDefMap.put(relationshipDef.getName(), relationshipDef); if (duplicateElement != null) { throw new OMRSLogicErrorException(OMRSErrorCode.DUPLICATE_TYPE_IN_ARCHIVE.getMessageDefinition(relationshipDef.getName(), TypeDefCategory.RELATIONSHIP_DEF.getName(), duplicateElement.toString(), relationshipDef.toString()), this.getClass().getName(), methodName); } Object duplicateGUID = guidMap.put(relationshipDef.getGUID(), relationshipDef); if (duplicateGUID != null) { throw new OMRSLogicErrorException(OMRSErrorCode.DUPLICATE_GUID_IN_ARCHIVE.getMessageDefinition(relationshipDef.getGUID(), duplicateGUID.toString(), relationshipDef.toString()), this.getClass().getName(), methodName); } Object duplicateName = nameMap.put(relationshipDef.getName(), relationshipDef); if (duplicateName != null) { throw new OMRSLogicErrorException(OMRSErrorCode.DUPLICATE_TYPENAME_IN_ARCHIVE.getMessageDefinition(relationshipDef.getName(), duplicateName.toString(), relationshipDef.toString()), this.getClass().getName(), methodName); } this.checkRelationshipDefDuplicateAttributes(relationshipDef); if (relationshipDef.getPropertiesDefinition() != null) { Set<String> attributeSet = new HashSet<>(); for (TypeDefAttribute typeDefAttr : relationshipDef.getPropertiesDefinition()) { String duplicateAttributeName = typeDefAttr.getAttributeName(); if (attributeSet.contains(duplicateAttributeName)) { throw new OMRSLogicErrorException(OMRSErrorCode.DUPLICATE_RELATIONSHIP_ATTR_IN_ARCHIVE.getMessageDefinition(duplicateAttributeName, relationshipDef.getName()), this.getClass().getName(), methodName); } attributeSet.add(duplicateAttributeName); } } relationshipDefList.add(relationshipDef); } }
OMRSArchiveBuilder { public void addRelationshipDef(RelationshipDef relationshipDef) { final String methodName = "addRelationshipDef"; if (relationshipDef != null) { log.debug("Adding RelationshipDef: " + relationshipDef.toString()); this.checkForBlanksInTypeName(relationshipDef.getName()); RelationshipDef duplicateElement = relationshipDefMap.put(relationshipDef.getName(), relationshipDef); if (duplicateElement != null) { throw new OMRSLogicErrorException(OMRSErrorCode.DUPLICATE_TYPE_IN_ARCHIVE.getMessageDefinition(relationshipDef.getName(), TypeDefCategory.RELATIONSHIP_DEF.getName(), duplicateElement.toString(), relationshipDef.toString()), this.getClass().getName(), methodName); } Object duplicateGUID = guidMap.put(relationshipDef.getGUID(), relationshipDef); if (duplicateGUID != null) { throw new OMRSLogicErrorException(OMRSErrorCode.DUPLICATE_GUID_IN_ARCHIVE.getMessageDefinition(relationshipDef.getGUID(), duplicateGUID.toString(), relationshipDef.toString()), this.getClass().getName(), methodName); } Object duplicateName = nameMap.put(relationshipDef.getName(), relationshipDef); if (duplicateName != null) { throw new OMRSLogicErrorException(OMRSErrorCode.DUPLICATE_TYPENAME_IN_ARCHIVE.getMessageDefinition(relationshipDef.getName(), duplicateName.toString(), relationshipDef.toString()), this.getClass().getName(), methodName); } this.checkRelationshipDefDuplicateAttributes(relationshipDef); if (relationshipDef.getPropertiesDefinition() != null) { Set<String> attributeSet = new HashSet<>(); for (TypeDefAttribute typeDefAttr : relationshipDef.getPropertiesDefinition()) { String duplicateAttributeName = typeDefAttr.getAttributeName(); if (attributeSet.contains(duplicateAttributeName)) { throw new OMRSLogicErrorException(OMRSErrorCode.DUPLICATE_RELATIONSHIP_ATTR_IN_ARCHIVE.getMessageDefinition(duplicateAttributeName, relationshipDef.getName()), this.getClass().getName(), methodName); } attributeSet.add(duplicateAttributeName); } } relationshipDefList.add(relationshipDef); } } }
OMRSArchiveBuilder { public void addRelationshipDef(RelationshipDef relationshipDef) { final String methodName = "addRelationshipDef"; if (relationshipDef != null) { log.debug("Adding RelationshipDef: " + relationshipDef.toString()); this.checkForBlanksInTypeName(relationshipDef.getName()); RelationshipDef duplicateElement = relationshipDefMap.put(relationshipDef.getName(), relationshipDef); if (duplicateElement != null) { throw new OMRSLogicErrorException(OMRSErrorCode.DUPLICATE_TYPE_IN_ARCHIVE.getMessageDefinition(relationshipDef.getName(), TypeDefCategory.RELATIONSHIP_DEF.getName(), duplicateElement.toString(), relationshipDef.toString()), this.getClass().getName(), methodName); } Object duplicateGUID = guidMap.put(relationshipDef.getGUID(), relationshipDef); if (duplicateGUID != null) { throw new OMRSLogicErrorException(OMRSErrorCode.DUPLICATE_GUID_IN_ARCHIVE.getMessageDefinition(relationshipDef.getGUID(), duplicateGUID.toString(), relationshipDef.toString()), this.getClass().getName(), methodName); } Object duplicateName = nameMap.put(relationshipDef.getName(), relationshipDef); if (duplicateName != null) { throw new OMRSLogicErrorException(OMRSErrorCode.DUPLICATE_TYPENAME_IN_ARCHIVE.getMessageDefinition(relationshipDef.getName(), duplicateName.toString(), relationshipDef.toString()), this.getClass().getName(), methodName); } this.checkRelationshipDefDuplicateAttributes(relationshipDef); if (relationshipDef.getPropertiesDefinition() != null) { Set<String> attributeSet = new HashSet<>(); for (TypeDefAttribute typeDefAttr : relationshipDef.getPropertiesDefinition()) { String duplicateAttributeName = typeDefAttr.getAttributeName(); if (attributeSet.contains(duplicateAttributeName)) { throw new OMRSLogicErrorException(OMRSErrorCode.DUPLICATE_RELATIONSHIP_ATTR_IN_ARCHIVE.getMessageDefinition(duplicateAttributeName, relationshipDef.getName()), this.getClass().getName(), methodName); } attributeSet.add(duplicateAttributeName); } } relationshipDefList.add(relationshipDef); } } OMRSArchiveBuilder(String                     archiveGUID,
                              String                     archiveName,
                              String                     archiveDescription,
                              OpenMetadataArchiveType    archiveType,
                              String                     originatorName,
                              Date                       creationDate,
                              List<OpenMetadataArchive>  dependsOnArchives);  OMRSArchiveBuilder(String                     archiveGUID,
                              String                     archiveName,
                              String                     archiveDescription,
                              OpenMetadataArchiveType    archiveType,
                              String                     originatorName,
                              String                     originatorLicense,
                              Date                       creationDate,
                              List<OpenMetadataArchive>  dependsOnArchives);  OMRSArchiveBuilder(String                     archiveGUID,
                              String                     archiveName,
                              String                     archiveDescription,
                              OpenMetadataArchiveType    archiveType,
                              String                     archiveVersion,
                              String                     originatorName,
                              String                     originatorLicense,
                              Date                       creationDate,
                              List<OpenMetadataArchive>  dependsOnArchives); }
OMRSArchiveBuilder { public void addRelationshipDef(RelationshipDef relationshipDef) { final String methodName = "addRelationshipDef"; if (relationshipDef != null) { log.debug("Adding RelationshipDef: " + relationshipDef.toString()); this.checkForBlanksInTypeName(relationshipDef.getName()); RelationshipDef duplicateElement = relationshipDefMap.put(relationshipDef.getName(), relationshipDef); if (duplicateElement != null) { throw new OMRSLogicErrorException(OMRSErrorCode.DUPLICATE_TYPE_IN_ARCHIVE.getMessageDefinition(relationshipDef.getName(), TypeDefCategory.RELATIONSHIP_DEF.getName(), duplicateElement.toString(), relationshipDef.toString()), this.getClass().getName(), methodName); } Object duplicateGUID = guidMap.put(relationshipDef.getGUID(), relationshipDef); if (duplicateGUID != null) { throw new OMRSLogicErrorException(OMRSErrorCode.DUPLICATE_GUID_IN_ARCHIVE.getMessageDefinition(relationshipDef.getGUID(), duplicateGUID.toString(), relationshipDef.toString()), this.getClass().getName(), methodName); } Object duplicateName = nameMap.put(relationshipDef.getName(), relationshipDef); if (duplicateName != null) { throw new OMRSLogicErrorException(OMRSErrorCode.DUPLICATE_TYPENAME_IN_ARCHIVE.getMessageDefinition(relationshipDef.getName(), duplicateName.toString(), relationshipDef.toString()), this.getClass().getName(), methodName); } this.checkRelationshipDefDuplicateAttributes(relationshipDef); if (relationshipDef.getPropertiesDefinition() != null) { Set<String> attributeSet = new HashSet<>(); for (TypeDefAttribute typeDefAttr : relationshipDef.getPropertiesDefinition()) { String duplicateAttributeName = typeDefAttr.getAttributeName(); if (attributeSet.contains(duplicateAttributeName)) { throw new OMRSLogicErrorException(OMRSErrorCode.DUPLICATE_RELATIONSHIP_ATTR_IN_ARCHIVE.getMessageDefinition(duplicateAttributeName, relationshipDef.getName()), this.getClass().getName(), methodName); } attributeSet.add(duplicateAttributeName); } } relationshipDefList.add(relationshipDef); } } OMRSArchiveBuilder(String                     archiveGUID,
                              String                     archiveName,
                              String                     archiveDescription,
                              OpenMetadataArchiveType    archiveType,
                              String                     originatorName,
                              Date                       creationDate,
                              List<OpenMetadataArchive>  dependsOnArchives);  OMRSArchiveBuilder(String                     archiveGUID,
                              String                     archiveName,
                              String                     archiveDescription,
                              OpenMetadataArchiveType    archiveType,
                              String                     originatorName,
                              String                     originatorLicense,
                              Date                       creationDate,
                              List<OpenMetadataArchive>  dependsOnArchives);  OMRSArchiveBuilder(String                     archiveGUID,
                              String                     archiveName,
                              String                     archiveDescription,
                              OpenMetadataArchiveType    archiveType,
                              String                     archiveVersion,
                              String                     originatorName,
                              String                     originatorLicense,
                              Date                       creationDate,
                              List<OpenMetadataArchive>  dependsOnArchives); void addPrimitiveDef(PrimitiveDef   primitiveDef); PrimitiveDef getPrimitiveDef(String   primitiveDefName); void addCollectionDef(CollectionDef  collectionDef); void addEnumDef(EnumDef    enumDef); void addClassificationDef(ClassificationDef   classificationDef); void addEntityDef(EntityDef    entityDef); EntityDef getEntityDef(String   entityDefName); void addRelationshipDef(RelationshipDef   relationshipDef); TypeDefPatch getPatchForType(String  typeName); void addTypeDefPatch(TypeDefPatch  typeDefPatch); TypeDef getTypeDefByName(String  typeName); void addEntity(EntityDetail   entity); EntityDetail getEntity(String   guid); void addRelationship(Relationship  relationship); Relationship getRelationship(String   guid); void addClassification(ClassificationEntityExtension classification); OpenMetadataArchive getOpenMetadataArchive(); void logBadArchiveContent(String   methodName); }
OMRSArchiveBuilder { public void addRelationshipDef(RelationshipDef relationshipDef) { final String methodName = "addRelationshipDef"; if (relationshipDef != null) { log.debug("Adding RelationshipDef: " + relationshipDef.toString()); this.checkForBlanksInTypeName(relationshipDef.getName()); RelationshipDef duplicateElement = relationshipDefMap.put(relationshipDef.getName(), relationshipDef); if (duplicateElement != null) { throw new OMRSLogicErrorException(OMRSErrorCode.DUPLICATE_TYPE_IN_ARCHIVE.getMessageDefinition(relationshipDef.getName(), TypeDefCategory.RELATIONSHIP_DEF.getName(), duplicateElement.toString(), relationshipDef.toString()), this.getClass().getName(), methodName); } Object duplicateGUID = guidMap.put(relationshipDef.getGUID(), relationshipDef); if (duplicateGUID != null) { throw new OMRSLogicErrorException(OMRSErrorCode.DUPLICATE_GUID_IN_ARCHIVE.getMessageDefinition(relationshipDef.getGUID(), duplicateGUID.toString(), relationshipDef.toString()), this.getClass().getName(), methodName); } Object duplicateName = nameMap.put(relationshipDef.getName(), relationshipDef); if (duplicateName != null) { throw new OMRSLogicErrorException(OMRSErrorCode.DUPLICATE_TYPENAME_IN_ARCHIVE.getMessageDefinition(relationshipDef.getName(), duplicateName.toString(), relationshipDef.toString()), this.getClass().getName(), methodName); } this.checkRelationshipDefDuplicateAttributes(relationshipDef); if (relationshipDef.getPropertiesDefinition() != null) { Set<String> attributeSet = new HashSet<>(); for (TypeDefAttribute typeDefAttr : relationshipDef.getPropertiesDefinition()) { String duplicateAttributeName = typeDefAttr.getAttributeName(); if (attributeSet.contains(duplicateAttributeName)) { throw new OMRSLogicErrorException(OMRSErrorCode.DUPLICATE_RELATIONSHIP_ATTR_IN_ARCHIVE.getMessageDefinition(duplicateAttributeName, relationshipDef.getName()), this.getClass().getName(), methodName); } attributeSet.add(duplicateAttributeName); } } relationshipDefList.add(relationshipDef); } } OMRSArchiveBuilder(String                     archiveGUID,
                              String                     archiveName,
                              String                     archiveDescription,
                              OpenMetadataArchiveType    archiveType,
                              String                     originatorName,
                              Date                       creationDate,
                              List<OpenMetadataArchive>  dependsOnArchives);  OMRSArchiveBuilder(String                     archiveGUID,
                              String                     archiveName,
                              String                     archiveDescription,
                              OpenMetadataArchiveType    archiveType,
                              String                     originatorName,
                              String                     originatorLicense,
                              Date                       creationDate,
                              List<OpenMetadataArchive>  dependsOnArchives);  OMRSArchiveBuilder(String                     archiveGUID,
                              String                     archiveName,
                              String                     archiveDescription,
                              OpenMetadataArchiveType    archiveType,
                              String                     archiveVersion,
                              String                     originatorName,
                              String                     originatorLicense,
                              Date                       creationDate,
                              List<OpenMetadataArchive>  dependsOnArchives); void addPrimitiveDef(PrimitiveDef   primitiveDef); PrimitiveDef getPrimitiveDef(String   primitiveDefName); void addCollectionDef(CollectionDef  collectionDef); void addEnumDef(EnumDef    enumDef); void addClassificationDef(ClassificationDef   classificationDef); void addEntityDef(EntityDef    entityDef); EntityDef getEntityDef(String   entityDefName); void addRelationshipDef(RelationshipDef   relationshipDef); TypeDefPatch getPatchForType(String  typeName); void addTypeDefPatch(TypeDefPatch  typeDefPatch); TypeDef getTypeDefByName(String  typeName); void addEntity(EntityDetail   entity); EntityDetail getEntity(String   guid); void addRelationship(Relationship  relationship); Relationship getRelationship(String   guid); void addClassification(ClassificationEntityExtension classification); OpenMetadataArchive getOpenMetadataArchive(); void logBadArchiveContent(String   methodName);  }