use of org.apache.atlas.model.legacy.EntityResult in project incubator-atlas by apache.
the class AtlasClient method updateEntities.
protected EntityResult updateEntities(JSONArray entities) throws AtlasServiceException {
LOG.debug("Updating entities: {}", entities);
JSONObject response = callAPIWithBody(API.UPDATE_ENTITY, entities.toString());
EntityResult results = extractEntityResult(response);
LOG.debug("Update entities returned results: {}", results);
return results;
}
use of org.apache.atlas.model.legacy.EntityResult in project incubator-atlas by apache.
the class AtlasClient method deleteEntities.
/**
* Delete the specified entities from the repository
*
* @param guids guids of entities to delete
* @return List of entity ids updated/deleted
* @throws AtlasServiceException
*/
public EntityResult deleteEntities(final String... guids) throws AtlasServiceException {
LOG.debug("Deleting entities: {}", guids);
JSONObject jsonResponse = callAPIWithRetries(API.DELETE_ENTITIES, null, new ResourceCreator() {
@Override
public WebResource createResource() {
API api = API.DELETE_ENTITIES;
WebResource resource = getResource(api);
for (String guid : guids) {
resource = resource.queryParam(GUID.toLowerCase(), guid);
}
return resource;
}
});
EntityResult results = extractEntityResult(jsonResponse);
LOG.debug("Delete entities returned results: {}", results);
return results;
}
use of org.apache.atlas.model.legacy.EntityResult in project incubator-atlas by apache.
the class GraphBackedMetadataRepository method deleteEntities.
@Override
@GraphTransaction
public EntityResult deleteEntities(List<String> guids) throws RepositoryException {
if (guids == null || guids.size() == 0) {
throw new IllegalArgumentException("guids must be non-null and non-empty");
}
// Retrieve vertices for requested guids.
Map<String, AtlasVertex> vertices = graphHelper.getVerticesForGUIDs(guids);
Collection<AtlasVertex> deletionCandidates = vertices.values();
if (LOG.isDebugEnabled()) {
for (String guid : guids) {
if (!vertices.containsKey(guid)) {
// Entity does not exist - treat as non-error, since the caller
// wanted to delete the entity and it's already gone.
LOG.debug("Deletion request ignored for non-existent entity with guid " + guid);
}
}
}
if (deletionCandidates.isEmpty()) {
LOG.info("No deletion candidate entities were found for guids %s", guids);
return new EntityResult(Collections.<String>emptyList(), Collections.<String>emptyList(), Collections.<String>emptyList());
}
try {
deleteHandler.deleteEntities(deletionCandidates);
} catch (AtlasException e) {
throw new RepositoryException(e);
}
RequestContext requestContext = RequestContext.get();
return createEntityResultFromContext(requestContext);
}
use of org.apache.atlas.model.legacy.EntityResult 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.legacy.EntityResult in project incubator-atlas by apache.
the class DefaultMetadataService method deleteGuids.
private EntityResult deleteGuids(List<String> deleteCandidateGuids) throws AtlasException {
EntityResult entityResult = repository.deleteEntities(deleteCandidateGuids);
onEntitiesAddedUpdated(entityResult);
return entityResult;
}
Aggregations