use of org.apache.atlas.model.instance.GuidMapping 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.model.instance.GuidMapping in project incubator-atlas by apache.
the class GraphBackedMetadataRepository method createEntities.
@Override
@GraphTransaction
public CreateUpdateEntitiesResult createEntities(ITypedReferenceableInstance... entities) throws RepositoryException, EntityExistsException {
if (LOG.isDebugEnabled()) {
LOG.debug("adding entities={}", entities);
}
try {
TypedInstanceToGraphMapper instanceToGraphMapper = new TypedInstanceToGraphMapper(graphToInstanceMapper, deleteHandler);
instanceToGraphMapper.mapTypedInstanceToGraph(TypedInstanceToGraphMapper.Operation.CREATE, entities);
List<String> createdGuids = RequestContext.get().getCreatedEntityIds();
CreateUpdateEntitiesResult result = new CreateUpdateEntitiesResult();
EntityResult entityResult = new EntityResult(createdGuids, null, null);
GuidMapping mapping = instanceToGraphMapper.createGuidMapping();
result.setEntityResult(entityResult);
result.setGuidMapping(mapping);
return result;
} catch (EntityExistsException e) {
throw e;
} catch (AtlasException e) {
throw new RepositoryException(e);
}
}
use of org.apache.atlas.model.instance.GuidMapping in project incubator-atlas by apache.
the class EntityResource method getResponse.
private JSONObject getResponse(CreateUpdateEntitiesResult result) throws AtlasException, JSONException {
JSONObject response = new JSONObject();
EntityResult entityResult = result.getEntityResult();
GuidMapping mapping = result.getGuidMapping();
response.put(AtlasClient.REQUEST_ID, Servlets.getRequestId());
if (entityResult != null) {
response.put(AtlasClient.ENTITIES, new JSONObject(entityResult.toString()).get(AtlasClient.ENTITIES));
String sampleEntityId = getSample(result.getEntityResult());
if (sampleEntityId != null) {
String entityDefinition = metadataService.getEntityDefinitionJson(sampleEntityId);
response.put(AtlasClient.DEFINITION, new JSONObject(entityDefinition));
}
}
if (mapping != null) {
response.put(AtlasClient.GUID_ASSIGNMENTS, new JSONObject(AtlasType.toJson(mapping)).get(AtlasClient.GUID_ASSIGNMENTS));
}
return response;
}
Aggregations