use of org.apache.atlas.typesystem.ITypedReferenceableInstance in project incubator-atlas by apache.
the class ReplaceIdWithInstance method getInstance.
ITypedReferenceableInstance getInstance(Id id) throws AtlasException {
ITypedReferenceableInstance r = idToInstanceMap.get(id);
if (r == null) {
r = repository.get(id);
idToInstanceMap.put(id, r);
walker.addRoot(r);
}
return r;
}
use of org.apache.atlas.typesystem.ITypedReferenceableInstance in project incubator-atlas by apache.
the class ReplaceIdWithInstance method convertToInstances.
ImmutableMap<?, ?> convertToInstances(ImmutableMap val, Multiplicity m, DataTypes.MapType mapType) throws AtlasException {
if (val == null || (mapType.getKeyType().getTypeCategory() != DataTypes.TypeCategory.CLASS && mapType.getValueType().getTypeCategory() != DataTypes.TypeCategory.CLASS)) {
return val;
}
ImmutableMap.Builder b = ImmutableMap.builder();
for (Map.Entry elem : (Iterable<Map.Entry>) val.entrySet()) {
Object oldKey = elem.getKey();
Object oldValue = elem.getValue();
Object newKey = oldKey;
Object newValue = oldValue;
if (oldKey instanceof Id) {
Id id = (Id) elem;
ITypedReferenceableInstance r = getInstance(id);
}
if (oldValue instanceof Id) {
Id id = (Id) elem;
ITypedReferenceableInstance r = getInstance(id);
}
b.put(newKey, newValue);
}
return b.build();
}
use of org.apache.atlas.typesystem.ITypedReferenceableInstance in project incubator-atlas by apache.
the class SoftDeleteHandlerV1Test method assertProcessForTestDeleteReference.
@Override
protected void assertProcessForTestDeleteReference(final AtlasEntityHeader processInstance) throws Exception {
//
ITypedReferenceableInstance process = metadataService.getEntityDefinition(processInstance.getGuid());
List<ITypedReferenceableInstance> outputs = (List<ITypedReferenceableInstance>) process.get(AtlasClient.PROCESS_ATTRIBUTE_OUTPUTS);
List<ITypedReferenceableInstance> expectedOutputs = (List<ITypedReferenceableInstance>) process.get(AtlasClient.PROCESS_ATTRIBUTE_OUTPUTS);
assertEquals(outputs.size(), expectedOutputs.size());
}
use of org.apache.atlas.typesystem.ITypedReferenceableInstance in project incubator-atlas by apache.
the class SoftDeleteHandlerV1Test method assertTestUpdateEntity_MultiplicityOneNonCompositeReference.
@Override
protected void assertTestUpdateEntity_MultiplicityOneNonCompositeReference(final String janeGuid) throws Exception {
// Verify Jane's subordinates reference cardinality is still 2.
ITypedReferenceableInstance jane = metadataService.getEntityDefinition(janeGuid);
List<ITypedReferenceableInstance> subordinates = (List<ITypedReferenceableInstance>) jane.get("subordinates");
Assert.assertEquals(subordinates.size(), 2);
}
use of org.apache.atlas.typesystem.ITypedReferenceableInstance in project incubator-atlas by apache.
the class HardDeleteHandlerV1Test method assertMaxForTestDisconnectBidirectionalReferences.
@Override
protected void assertMaxForTestDisconnectBidirectionalReferences(Map<String, String> nameGuidMap) throws Exception {
// Verify that the Department.employees reference to the deleted employee
// was disconnected.
ITypedReferenceableInstance hrDept = metadataService.getEntityDefinition(nameGuidMap.get("hr"));
List<ITypedReferenceableInstance> employees = (List<ITypedReferenceableInstance>) hrDept.get("employees");
Assert.assertEquals(employees.size(), 3);
String maxGuid = nameGuidMap.get("Max");
for (ITypedReferenceableInstance employee : employees) {
Assert.assertNotEquals(employee.getId()._getId(), maxGuid);
}
// Verify that the Manager.subordinates reference to the deleted employee
// Max was disconnected.
ITypedReferenceableInstance jane = metadataService.getEntityDefinition(nameGuidMap.get("Jane"));
List<ITypedReferenceableInstance> subordinates = (List<ITypedReferenceableInstance>) jane.get("subordinates");
assertEquals(subordinates.size(), 1);
// Verify that max's Person.mentor unidirectional reference to john was disconnected.
ITypedReferenceableInstance john = metadataService.getEntityDefinition(nameGuidMap.get("John"));
assertNull(john.get("mentor"));
}
Aggregations