use of org.apache.atlas.typesystem.persistence.Id 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.persistence.Id in project incubator-atlas by apache.
the class TypedInstanceToGraphMapper method createGuidMapping.
public GuidMapping createGuidMapping() {
Map<String, String> mapping = new HashMap<>(idToVertexMap.size());
for (Map.Entry<Id, AtlasVertex> entry : idToVertexMap.entrySet()) {
Id id = entry.getKey();
if (id.isUnassigned()) {
AtlasVertex classVertex = entry.getValue();
mapping.put(id._getId(), GraphHelper.getGuid(classVertex));
}
}
return new GuidMapping(mapping);
}
use of org.apache.atlas.typesystem.persistence.Id 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.persistence.Id in project incubator-atlas by apache.
the class TypedInstanceToGraphMapper method getId.
private Id getId(ITypedReferenceableInstance typedReference) throws EntityNotFoundException {
if (typedReference == null) {
throw new IllegalArgumentException("typedReference must be non-null");
}
Id id = typedReference instanceof Id ? (Id) typedReference : typedReference.getId();
if (id.isUnassigned()) {
AtlasVertex classVertex = idToVertexMap.get(id);
String guid = GraphHelper.getGuid(classVertex);
id = new Id(guid, 0, typedReference.getTypeName());
}
return id;
}
use of org.apache.atlas.typesystem.persistence.Id in project incubator-atlas by apache.
the class EntityLineageServiceTest method createTable.
private void createTable(String tableName, int numCols, boolean createLineage) throws Exception {
String dbId = getEntityId(DATABASE_TYPE, "name", "Sales");
Id salesDB = new Id(dbId, 0, DATABASE_TYPE);
//Create the entity again and schema should return the new schema
List<Referenceable> columns = new ArrayStack();
for (int i = 0; i < numCols; i++) {
columns.add(column("col" + random(), "int", "column descr"));
}
Referenceable sd = storageDescriptor("hdfs://host:8000/apps/warehouse/sales", "TextInputFormat", "TextOutputFormat", true, ImmutableList.of(column("time_id", "int", "time id")));
Id table = table(tableName, "test table", salesDB, sd, "fetl", "External", columns);
if (createLineage) {
Id inTable = table("table" + random(), "test table", salesDB, sd, "fetl", "External", columns);
Id outTable = table("table" + random(), "test table", salesDB, sd, "fetl", "External", columns);
loadProcess("process" + random(), "hive query for monthly summary", "Tim ETL", ImmutableList.of(inTable), ImmutableList.of(table), "create table as select ", "plan", "id", "graph", "ETL");
loadProcess("process" + random(), "hive query for monthly summary", "Tim ETL", ImmutableList.of(table), ImmutableList.of(outTable), "create table as select ", "plan", "id", "graph", "ETL");
}
}
Aggregations