use of org.apache.atlas.typesystem.ITypedReferenceableInstance in project incubator-atlas by apache.
the class ReverseReferenceUpdateSoftDeleteTest method assertTestOneToManyReference.
@Override
void assertTestOneToManyReference(Object object, ITypedReferenceableInstance referencingInstance) throws Exception {
// Verify reference was not disconnected if soft deletes are enabled.
Assert.assertTrue(object instanceof List);
List<ITypedReferenceableInstance> refValues = (List<ITypedReferenceableInstance>) object;
Assert.assertEquals(refValues.size(), 2);
// Verify that one of the reference edges is marked DELETED.
AtlasVertex vertexForGUID = GraphHelper.getInstance().getVertexForGUID(referencingInstance.getId()._getId());
String edgeLabel = GraphHelper.getEdgeLabel(typeB, typeB.fieldMapping.fields.get("manyA"));
Iterator<AtlasEdge> outGoingEdgesByLabel = GraphHelper.getInstance().getOutGoingEdgesByLabel(vertexForGUID, edgeLabel);
boolean found = false;
while (outGoingEdgesByLabel.hasNext()) {
AtlasEdge edge = outGoingEdgesByLabel.next();
String edgeState = edge.getProperty(Constants.STATE_PROPERTY_KEY, String.class);
if (edgeState.equals(Id.EntityState.DELETED.name())) {
found = true;
break;
}
}
Assert.assertTrue(found, "One edge for label " + edgeLabel + " should be marked " + Id.EntityState.DELETED.name());
}
use of org.apache.atlas.typesystem.ITypedReferenceableInstance in project incubator-atlas by apache.
the class ReverseReferenceUpdateSoftDeleteTest method assertTestOneToOneReference.
@Override
void assertTestOneToOneReference(Object actual, ITypedReferenceableInstance expectedValue, ITypedReferenceableInstance referencingInstance) throws Exception {
// Verify reference was not disconnected if soft deletes are enabled.
Assert.assertNotNull(actual);
Assert.assertTrue(actual instanceof ITypedReferenceableInstance);
ITypedReferenceableInstance referenceValue = (ITypedReferenceableInstance) actual;
Assert.assertEquals(referenceValue.getId()._getId(), expectedValue.getId()._getId());
//Verify reference edge was marked as DELETED.
AtlasVertex vertexForGUID = GraphHelper.getInstance().getVertexForGUID(referencingInstance.getId()._getId());
String edgeLabel = GraphHelper.getEdgeLabel(typeB, typeB.fieldMapping.fields.get("a"));
AtlasEdge edgeForLabel = GraphHelper.getInstance().getEdgeForLabel(vertexForGUID, edgeLabel);
String edgeState = edgeForLabel.getProperty(Constants.STATE_PROPERTY_KEY, String.class);
Assert.assertEquals(edgeState, Id.EntityState.DELETED.name());
}
use of org.apache.atlas.typesystem.ITypedReferenceableInstance in project incubator-atlas by apache.
the class VertexLookupContext method addInstance.
/**
* Adds an instance to be loaded.
*
*/
public void addInstance(IReferenceableInstance instance) throws AtlasException {
ClassType classType = typeSystem.getDataType(ClassType.class, instance.getTypeName());
ITypedReferenceableInstance newInstance = classType.convert(instance, Multiplicity.REQUIRED);
findReferencedInstancesToPreLoad(newInstance);
Id id = instance.getId();
if (mapper.lookupVertex(id) == null) {
if (id.isAssigned()) {
guidsToLookup.add(id);
} else {
addToClassMap(classType, instance);
}
}
}
use of org.apache.atlas.typesystem.ITypedReferenceableInstance in project incubator-atlas by apache.
the class ReplaceIdWithInstance method processNode.
@Override
public void processNode(ObjectGraphWalker.Node nd) throws AtlasException {
if (nd.attributeName != null) {
if (nd.aInfo.isComposite && nd.value != null) {
if (nd.aInfo.dataType().getTypeCategory() == DataTypes.TypeCategory.CLASS) {
if (nd.value instanceof Id) {
Id id = (Id) nd.value;
ITypedReferenceableInstance r = getInstance(id);
nd.instance.set(nd.attributeName, r);
}
} else if (nd.aInfo.dataType().getTypeCategory() == DataTypes.TypeCategory.ARRAY) {
DataTypes.ArrayType aT = (DataTypes.ArrayType) nd.aInfo.dataType();
nd.instance.set(nd.attributeName, convertToInstances((ImmutableCollection) nd.value, nd.aInfo.multiplicity, aT));
} else if (nd.aInfo.dataType().getTypeCategory() == DataTypes.TypeCategory.MAP) {
DataTypes.MapType mT = (DataTypes.MapType) nd.aInfo.dataType();
nd.instance.set(nd.attributeName, convertToInstances((ImmutableMap) nd.value, nd.aInfo.multiplicity, mT));
}
}
}
}
use of org.apache.atlas.typesystem.ITypedReferenceableInstance in project incubator-atlas by apache.
the class TypedInstanceToGraphMapper method addFullTextProperty.
private void addFullTextProperty(List<ITypedReferenceableInstance> instances, FullTextMapper fulltextMapper) throws AtlasException {
if (!AtlasRepositoryConfiguration.isFullTextSearchEnabled()) {
return;
}
for (ITypedReferenceableInstance typedInstance : instances) {
// Traverse
AtlasVertex instanceVertex = getClassVertex(typedInstance);
String fullText = fulltextMapper.mapRecursive(instanceVertex, true);
GraphHelper.setProperty(instanceVertex, Constants.ENTITY_TEXT_PROPERTY_KEY, fullText);
}
}
Aggregations