@Test public void testAddClassificationDefSameAttr() { OMRSArchiveBuilder oMRSArchiveBuilder = getOMRSArchiveBuilder(); ClassificationDef classificationDef = new ClassificationDef(TypeDefCategory.CLASSIFICATION_DEF,"1111","EntityDefA",1L,"1"); List<TypeDefAttribute> propertyList1 = new ArrayList<>(); TypeDefAttribute attr1 = new TypeDefAttribute(); attr1.setAttributeName("abc"); propertyList1.add(attr1); TypeDefAttribute attr2 = new TypeDefAttribute(); attr2.setAttributeName("abc"); propertyList1.add(attr2); classificationDef.setPropertiesDefinition(propertyList1); try { oMRSArchiveBuilder.addClassificationDef(classificationDef); assertTrue(false); } catch (OMRSLogicErrorException e) { assertTrue(e.getMessage().contains("OMRS-ARCHIVE-BUILDER-400-011")); } }
public void addClassificationDef(ClassificationDef classificationDef) { final String methodName = "addClassificationDef"; if (classificationDef != null) { log.debug("Adding ClassificationDef: " + classificationDef.toString()); this.checkForBlanksInTypeName(classificationDef.getName()); ClassificationDef duplicateElement = classificationDefMap.put(classificationDef.getName(), classificationDef); if (duplicateElement != null) { throw new OMRSLogicErrorException(OMRSErrorCode.DUPLICATE_TYPE_IN_ARCHIVE.getMessageDefinition(classificationDef.getName(), TypeDefCategory.CLASSIFICATION_DEF.getName(), duplicateElement.toString(), classificationDef.toString()), this.getClass().getName(), methodName); } Object duplicateGUID = guidMap.put(classificationDef.getGUID(), classificationDef); if (duplicateGUID != null) { throw new OMRSLogicErrorException(OMRSErrorCode.DUPLICATE_GUID_IN_ARCHIVE.getMessageDefinition(classificationDef.getGUID(), duplicateGUID.toString(), classificationDef.toString()), this.getClass().getName(), methodName); } Object duplicateName = nameMap.put(classificationDef.getName(), classificationDef); if (duplicateName != null) { throw new OMRSLogicErrorException(OMRSErrorCode.DUPLICATE_TYPENAME_IN_ARCHIVE.getMessageDefinition(classificationDef.getName(), duplicateName.toString(), classificationDef.toString()), this.getClass().getName(), methodName); } if (classificationDef.getPropertiesDefinition() != null) { Set<String> attributeSet = new HashSet<>(); for (TypeDefAttribute typeDefAttr :classificationDef.getPropertiesDefinition()) { String duplicateAttributeName = typeDefAttr.getAttributeName(); if (attributeSet.contains(duplicateAttributeName)) { throw new OMRSLogicErrorException(OMRSErrorCode.DUPLICATE_CLASSIFICATION_ATTR_IN_ARCHIVE.getMessageDefinition(duplicateAttributeName, classificationDef.getName()), this.getClass().getName(), methodName); } attributeSet.add(duplicateAttributeName); } } classificationDefList.add(classificationDef); } }
OMRSArchiveBuilder { public void addClassificationDef(ClassificationDef classificationDef) { final String methodName = "addClassificationDef"; if (classificationDef != null) { log.debug("Adding ClassificationDef: " + classificationDef.toString()); this.checkForBlanksInTypeName(classificationDef.getName()); ClassificationDef duplicateElement = classificationDefMap.put(classificationDef.getName(), classificationDef); if (duplicateElement != null) { throw new OMRSLogicErrorException(OMRSErrorCode.DUPLICATE_TYPE_IN_ARCHIVE.getMessageDefinition(classificationDef.getName(), TypeDefCategory.CLASSIFICATION_DEF.getName(), duplicateElement.toString(), classificationDef.toString()), this.getClass().getName(), methodName); } Object duplicateGUID = guidMap.put(classificationDef.getGUID(), classificationDef); if (duplicateGUID != null) { throw new OMRSLogicErrorException(OMRSErrorCode.DUPLICATE_GUID_IN_ARCHIVE.getMessageDefinition(classificationDef.getGUID(), duplicateGUID.toString(), classificationDef.toString()), this.getClass().getName(), methodName); } Object duplicateName = nameMap.put(classificationDef.getName(), classificationDef); if (duplicateName != null) { throw new OMRSLogicErrorException(OMRSErrorCode.DUPLICATE_TYPENAME_IN_ARCHIVE.getMessageDefinition(classificationDef.getName(), duplicateName.toString(), classificationDef.toString()), this.getClass().getName(), methodName); } if (classificationDef.getPropertiesDefinition() != null) { Set<String> attributeSet = new HashSet<>(); for (TypeDefAttribute typeDefAttr :classificationDef.getPropertiesDefinition()) { String duplicateAttributeName = typeDefAttr.getAttributeName(); if (attributeSet.contains(duplicateAttributeName)) { throw new OMRSLogicErrorException(OMRSErrorCode.DUPLICATE_CLASSIFICATION_ATTR_IN_ARCHIVE.getMessageDefinition(duplicateAttributeName, classificationDef.getName()), this.getClass().getName(), methodName); } attributeSet.add(duplicateAttributeName); } } classificationDefList.add(classificationDef); } } }
OMRSArchiveBuilder { public void addClassificationDef(ClassificationDef classificationDef) { final String methodName = "addClassificationDef"; if (classificationDef != null) { log.debug("Adding ClassificationDef: " + classificationDef.toString()); this.checkForBlanksInTypeName(classificationDef.getName()); ClassificationDef duplicateElement = classificationDefMap.put(classificationDef.getName(), classificationDef); if (duplicateElement != null) { throw new OMRSLogicErrorException(OMRSErrorCode.DUPLICATE_TYPE_IN_ARCHIVE.getMessageDefinition(classificationDef.getName(), TypeDefCategory.CLASSIFICATION_DEF.getName(), duplicateElement.toString(), classificationDef.toString()), this.getClass().getName(), methodName); } Object duplicateGUID = guidMap.put(classificationDef.getGUID(), classificationDef); if (duplicateGUID != null) { throw new OMRSLogicErrorException(OMRSErrorCode.DUPLICATE_GUID_IN_ARCHIVE.getMessageDefinition(classificationDef.getGUID(), duplicateGUID.toString(), classificationDef.toString()), this.getClass().getName(), methodName); } Object duplicateName = nameMap.put(classificationDef.getName(), classificationDef); if (duplicateName != null) { throw new OMRSLogicErrorException(OMRSErrorCode.DUPLICATE_TYPENAME_IN_ARCHIVE.getMessageDefinition(classificationDef.getName(), duplicateName.toString(), classificationDef.toString()), this.getClass().getName(), methodName); } if (classificationDef.getPropertiesDefinition() != null) { Set<String> attributeSet = new HashSet<>(); for (TypeDefAttribute typeDefAttr :classificationDef.getPropertiesDefinition()) { String duplicateAttributeName = typeDefAttr.getAttributeName(); if (attributeSet.contains(duplicateAttributeName)) { throw new OMRSLogicErrorException(OMRSErrorCode.DUPLICATE_CLASSIFICATION_ATTR_IN_ARCHIVE.getMessageDefinition(duplicateAttributeName, classificationDef.getName()), this.getClass().getName(), methodName); } attributeSet.add(duplicateAttributeName); } } classificationDefList.add(classificationDef); } } 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 addClassificationDef(ClassificationDef classificationDef) { final String methodName = "addClassificationDef"; if (classificationDef != null) { log.debug("Adding ClassificationDef: " + classificationDef.toString()); this.checkForBlanksInTypeName(classificationDef.getName()); ClassificationDef duplicateElement = classificationDefMap.put(classificationDef.getName(), classificationDef); if (duplicateElement != null) { throw new OMRSLogicErrorException(OMRSErrorCode.DUPLICATE_TYPE_IN_ARCHIVE.getMessageDefinition(classificationDef.getName(), TypeDefCategory.CLASSIFICATION_DEF.getName(), duplicateElement.toString(), classificationDef.toString()), this.getClass().getName(), methodName); } Object duplicateGUID = guidMap.put(classificationDef.getGUID(), classificationDef); if (duplicateGUID != null) { throw new OMRSLogicErrorException(OMRSErrorCode.DUPLICATE_GUID_IN_ARCHIVE.getMessageDefinition(classificationDef.getGUID(), duplicateGUID.toString(), classificationDef.toString()), this.getClass().getName(), methodName); } Object duplicateName = nameMap.put(classificationDef.getName(), classificationDef); if (duplicateName != null) { throw new OMRSLogicErrorException(OMRSErrorCode.DUPLICATE_TYPENAME_IN_ARCHIVE.getMessageDefinition(classificationDef.getName(), duplicateName.toString(), classificationDef.toString()), this.getClass().getName(), methodName); } if (classificationDef.getPropertiesDefinition() != null) { Set<String> attributeSet = new HashSet<>(); for (TypeDefAttribute typeDefAttr :classificationDef.getPropertiesDefinition()) { String duplicateAttributeName = typeDefAttr.getAttributeName(); if (attributeSet.contains(duplicateAttributeName)) { throw new OMRSLogicErrorException(OMRSErrorCode.DUPLICATE_CLASSIFICATION_ATTR_IN_ARCHIVE.getMessageDefinition(duplicateAttributeName, classificationDef.getName()), this.getClass().getName(), methodName); } attributeSet.add(duplicateAttributeName); } } classificationDefList.add(classificationDef); } } 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 addClassificationDef(ClassificationDef classificationDef) { final String methodName = "addClassificationDef"; if (classificationDef != null) { log.debug("Adding ClassificationDef: " + classificationDef.toString()); this.checkForBlanksInTypeName(classificationDef.getName()); ClassificationDef duplicateElement = classificationDefMap.put(classificationDef.getName(), classificationDef); if (duplicateElement != null) { throw new OMRSLogicErrorException(OMRSErrorCode.DUPLICATE_TYPE_IN_ARCHIVE.getMessageDefinition(classificationDef.getName(), TypeDefCategory.CLASSIFICATION_DEF.getName(), duplicateElement.toString(), classificationDef.toString()), this.getClass().getName(), methodName); } Object duplicateGUID = guidMap.put(classificationDef.getGUID(), classificationDef); if (duplicateGUID != null) { throw new OMRSLogicErrorException(OMRSErrorCode.DUPLICATE_GUID_IN_ARCHIVE.getMessageDefinition(classificationDef.getGUID(), duplicateGUID.toString(), classificationDef.toString()), this.getClass().getName(), methodName); } Object duplicateName = nameMap.put(classificationDef.getName(), classificationDef); if (duplicateName != null) { throw new OMRSLogicErrorException(OMRSErrorCode.DUPLICATE_TYPENAME_IN_ARCHIVE.getMessageDefinition(classificationDef.getName(), duplicateName.toString(), classificationDef.toString()), this.getClass().getName(), methodName); } if (classificationDef.getPropertiesDefinition() != null) { Set<String> attributeSet = new HashSet<>(); for (TypeDefAttribute typeDefAttr :classificationDef.getPropertiesDefinition()) { String duplicateAttributeName = typeDefAttr.getAttributeName(); if (attributeSet.contains(duplicateAttributeName)) { throw new OMRSLogicErrorException(OMRSErrorCode.DUPLICATE_CLASSIFICATION_ATTR_IN_ARCHIVE.getMessageDefinition(duplicateAttributeName, classificationDef.getName()), this.getClass().getName(), methodName); } attributeSet.add(duplicateAttributeName); } } classificationDefList.add(classificationDef); } } 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);  }