use of org.apache.atlas.typesystem.persistence.AtlasSystemAttributes in project incubator-atlas by apache.
the class GraphBackedMetadataRepositoryTest method testGetEntityDefinitionForDepartment.
@Test(dependsOnMethods = "testSubmitEntity")
public void testGetEntityDefinitionForDepartment() throws Exception {
ITypedReferenceableInstance entity = repositoryService.getEntityDefinition(guid);
Assert.assertNotNull(entity);
// entity state should be active by default
Assert.assertEquals(entity.getId().getState(), Id.EntityState.ACTIVE);
// System attributes created time and modified time should not be null
AtlasSystemAttributes systemAttributes = entity.getSystemAttributes();
Assert.assertNotNull(systemAttributes.createdTime);
Assert.assertNotNull(systemAttributes.modifiedTime);
}
use of org.apache.atlas.typesystem.persistence.AtlasSystemAttributes in project incubator-atlas by apache.
the class GraphToTypedInstanceMapper method mapGraphToTypedInstance.
public ITypedReferenceableInstance mapGraphToTypedInstance(String guid, AtlasVertex instanceVertex) throws AtlasException {
if (LOG.isDebugEnabled()) {
// place to add a check to see if there are any places that were missed.
if (RequestContext.get().getInstanceV1(guid) != null) {
LOG.warn("Looking up previously cached guid at: ", new Exception());
}
LOG.debug("Mapping graph root vertex {} to typed instance for guid {}", instanceVertex, guid);
}
String typeName = GraphHelper.getSingleValuedProperty(instanceVertex, Constants.ENTITY_TYPE_PROPERTY_KEY, String.class);
List<String> traits = GraphHelper.getTraitNames(instanceVertex);
String state = GraphHelper.getStateAsString(instanceVertex);
String createdBy = GraphHelper.getCreatedByAsString(instanceVertex);
String modifiedBy = GraphHelper.getModifiedByAsString(instanceVertex);
Date createdTime = new Date(GraphHelper.getCreatedTime(instanceVertex));
Date modifiedTime = new Date(GraphHelper.getModifiedTime(instanceVertex));
AtlasSystemAttributes systemAttributes = new AtlasSystemAttributes(createdBy, modifiedBy, createdTime, modifiedTime);
if (LOG.isDebugEnabled()) {
LOG.debug("Found createdBy : {} modifiedBy : {} createdTime: {} modifedTime: {}", createdBy, modifiedBy, createdTime, modifiedTime);
}
Id id = new Id(guid, Integer.parseInt(String.valueOf(GraphHelper.getProperty(instanceVertex, Constants.VERSION_PROPERTY_KEY))), typeName, state);
if (LOG.isDebugEnabled()) {
LOG.debug("Created id {} for instance type {}", id, typeName);
}
ClassType classType = typeSystem.getDataType(ClassType.class, typeName);
ITypedReferenceableInstance typedInstance = classType.createInstance(id, systemAttributes, traits.toArray(new String[traits.size()]));
mapVertexToInstance(instanceVertex, typedInstance, classType.fieldMapping().fields);
mapVertexToInstanceTraits(instanceVertex, typedInstance, traits);
RequestContext.get().cache(typedInstance);
return typedInstance;
}
Aggregations