Skip to content

Commit

Permalink
Merge branch 'master' into issue2388
Browse files Browse the repository at this point in the history
  • Loading branch information
planetf1 committed Jan 13, 2020
2 parents e48bd02 + 73525c4 commit 8564518
Show file tree
Hide file tree
Showing 6 changed files with 1,114 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public enum ConformanceSuiteAuditCode

TEST_CASE_COMPLETED_SUCCESSFULLY("CONFORMANCE-SUITE-0014",
OMRSAuditLogRecordSeverity.INFO,
"The Open Metadata Conformance Test Case {0} has complete with {1} successful assertions, {2} unsuccessful assertions, {3} unexpected exceptions and {4} discovered properties. The message on completion was: {5}",
"The Open Metadata Conformance Test Case {0} has completed with {1} successful assertions, {2} unsuccessful assertions, {3} unexpected exceptions and {4} discovered properties. The message on completion was: {5}",
"The Open Metadata Conformance Test Case has completed running its tests. Retrieve the report to find out more details.",
"No action is required. This is part of the normal operation of the service."),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.OMRSMetadataCollection;
import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.MatchCriteria;
import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.EntityDetail;
import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.EntityProxy;
import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.InstanceProperties;
import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.InstancePropertyValue;
import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.InstanceProvenanceType;
Expand Down Expand Up @@ -422,6 +423,55 @@ protected InstanceProperties getAllPropertiesForInstance(String userId, TypeDef

}


/**
* Return only the unique properties for the properties defined in the TypeDef and all of its supertypes.
*
* @param userId calling user
* @param typeDef the definition of the type
* @return properties for an instance of this type
* @throws Exception problem manipulating types
*/
protected InstanceProperties getAllUniquePropertiesForInstance(String userId, TypeDef typeDef) throws Exception
{
InstanceProperties properties = null;

// Recursively gather all the TypeDefAttributes for the supertype hierarchy...
List<TypeDefAttribute> allTypeDefAttributes = getPropertiesForTypeDef(userId, typeDef);

if (allTypeDefAttributes != null)
{
Map<String, InstancePropertyValue> propertyMap = new HashMap<>();


for (TypeDefAttribute typeDefAttribute : allTypeDefAttributes)
{
String attributeName = typeDefAttribute.getAttributeName();
AttributeTypeDef attributeType = typeDefAttribute.getAttributeType();
AttributeTypeDefCategory category = attributeType.getCategory();

if (typeDefAttribute.isUnique()) {
switch (category) {
case PRIMITIVE:
PrimitiveDef primitiveDef = (PrimitiveDef) attributeType;
propertyMap.put(attributeName, this.getPrimitivePropertyValue(attributeName, primitiveDef));
break;
}
}
}

if (! propertyMap.isEmpty())
{
properties = new InstanceProperties();
properties.setInstanceProperties(propertyMap);
}
}

return properties;

}


/**
* Return instance properties for only the mandatory properties defined in the TypeDef and all of its supertypes.
*
Expand Down Expand Up @@ -582,6 +632,41 @@ public EntityDetail addEntityToRepository(String userId,
return metadataCollection.addEntity(userId, entityDef.getGUID(), properties, null, null );
}

/**
* Adds an entity proxy of the requested type to the repository.
*
* @param userId userId for the new entity
* @param metadataCollection metadata connection to access the repository
* @param entityDef type of entity to create
* @return string - entity proxy's GUID
* @throws Exception error in create
*/
public String addEntityProxyToRepository(String userId,
OMRSMetadataCollection metadataCollection,
EntityDef entityDef,
String homeMetadataCollectionId) throws Exception
{
/*
* Supply all unique properties for the instance, including those inherited from supertypes, since they may be mandatory.
*/
InstanceProperties uniqueProperties = this.getAllUniquePropertiesForInstance(userId, entityDef);

OMRSRepositoryHelper repositoryHelper = cohortRepositoryConnector.getRepositoryHelper();

EntityProxy entityProxy = repositoryHelper.getNewEntityProxy(cohortRepositoryConnector.getRepositoryName(),
homeMetadataCollectionId,
InstanceProvenanceType.LOCAL_COHORT,
userId,
entityDef.getName(),
uniqueProperties,
null);


metadataCollection.addEntityProxy(userId, entityProxy);

return entityProxy.getGUID();

}



Expand Down
Loading

0 comments on commit 8564518

Please sign in to comment.