use of org.apache.atlas.typesystem.ITypedReferenceableInstance in project incubator-atlas by apache.
the class TypedInstanceToGraphMapper method addOrUpdateAttributesAndTraits.
private List<String> addOrUpdateAttributesAndTraits(Operation operation, List<ITypedReferenceableInstance> instances) throws AtlasException {
List<String> guids = new ArrayList<>();
for (ITypedReferenceableInstance instance : instances) {
try {
//new vertex, set all the properties
String guid = addOrUpdateAttributesAndTraits(operation, instance);
guids.add(guid);
} catch (AtlasSchemaViolationException e) {
throw new EntityExistsException(instance, e);
}
}
return guids;
}
use of org.apache.atlas.typesystem.ITypedReferenceableInstance in project incubator-atlas by apache.
the class TypedInstanceToGraphMapper method addToEntityCache.
private void addToEntityCache(RequestContext context, ITypedReferenceableInstance instance) throws EntityNotFoundException {
Id instanceId = instance.getId();
if (instanceId.isUnassigned()) {
if (instance instanceof ReferenceableInstance) {
//When the id is unassigned, we can only cache the instance of it is
//an instance of ReferenceableInstance, since replaceWithNewId is not
//currently in the ITypedReferenceableInstance interface.
Id id = getId(instance);
((ReferenceableInstance) instance).replaceWithNewId(id);
context.cache(instance);
}
} else {
context.cache(instance);
}
}
use of org.apache.atlas.typesystem.ITypedReferenceableInstance in project incubator-atlas by apache.
the class GraphBackedDiscoveryServiceTest method setUp.
@Override
@BeforeClass
public void setUp() throws Exception {
super.setUp();
repositoryService = TestUtils.addTransactionWrapper(repositoryService);
final TypeSystem typeSystem = TypeSystem.getInstance();
Collection<String> oldTypeNames = new HashSet<>();
oldTypeNames.addAll(typeSystem.getTypeNames());
TestUtils.defineDeptEmployeeTypes(typeSystem);
addIndexesForNewTypes(oldTypeNames, typeSystem);
ITypedReferenceableInstance hrDept = TestUtils.createDeptEg1(typeSystem);
repositoryService.createEntities(hrDept);
ITypedReferenceableInstance jane = repositoryService.getEntityDefinition("Manager", "name", "Jane");
Id janeGuid = jane.getId();
ClassType personType = typeSystem.getDataType(ClassType.class, "Person");
ITypedReferenceableInstance instance = personType.createInstance(janeGuid);
instance.set("orgLevel", "L1");
repositoryService.updatePartial(instance);
}
use of org.apache.atlas.typesystem.ITypedReferenceableInstance in project incubator-atlas by apache.
the class SoftDeleteHandlerV1Test method assertTableForTestDeleteReference.
@Override
protected void assertTableForTestDeleteReference(final String tableId) throws Exception {
ITypedReferenceableInstance table = metadataService.getEntityDefinition(tableId);
assertNotNull(table.get(NAME));
assertNotNull(table.get("description"));
assertNotNull(table.get("type"));
assertNotNull(table.get("tableType"));
assertNotNull(table.get("created"));
Id dbId = (Id) table.get("database");
assertNotNull(dbId);
ITypedReferenceableInstance db = metadataService.getEntityDefinition(dbId.getId()._getId());
assertNotNull(db);
assertEquals(db.getId().getState(), Id.EntityState.ACTIVE);
}
use of org.apache.atlas.typesystem.ITypedReferenceableInstance in project incubator-atlas by apache.
the class FullTextMapper method mapRecursive.
public String mapRecursive(AtlasVertex instanceVertex, boolean followReferences) throws AtlasException {
String guid = GraphHelper.getGuid(instanceVertex);
ITypedReferenceableInstance typedReference;
RequestContext context = RequestContext.get();
typedReference = context.getInstanceV1(guid);
if (typedReference != null) {
if (LOG.isDebugEnabled()) {
LOG.debug("Cache hit: guid = {}, entityId = {}", guid, typedReference.getId()._getId());
}
} else {
typedReference = graphToTypedInstanceMapper.mapGraphToTypedInstance(guid, instanceVertex);
context.cache(typedReference);
if (LOG.isDebugEnabled()) {
LOG.debug("Cache miss: guid = {}, entityId = {}", guid, typedReference.getId().getId());
}
}
String fullText = forInstance(typedReference, followReferences);
StringBuilder fullTextBuilder = new StringBuilder(typedReference.getTypeName()).append(FULL_TEXT_DELIMITER).append(fullText);
List<String> traits = typedReference.getTraits();
for (String traitName : traits) {
String traitText = forInstance((ITypedInstance) typedReference.getTrait(traitName), false);
fullTextBuilder.append(FULL_TEXT_DELIMITER).append(traitName).append(FULL_TEXT_DELIMITER).append(traitText);
}
return fullTextBuilder.toString();
}
Aggregations