public static EntityResult fromString(String json) { return AtlasType.fromV1Json(json, EntityResult.class); } }
@JsonIgnore public void setEntityDefinition(String entityDefinition) { this.entityDefinition = AtlasType.fromV1Json(entityDefinition, Referenceable.class); }
@Override EntityAuditEvent extractElement(ObjectNode element) { return AtlasType.fromV1Json(element.toString(), EntityAuditEvent.class); } });
@JsonIgnore public void setEntityDefinition(String entityDefinition) { this.entityDefinition = AtlasType.fromV1Json(entityDefinition, Referenceable.class); }
@Override EntityAuditEvent extractElement(ObjectNode element) { return AtlasType.fromV1Json(element.toString(), EntityAuditEvent.class); } });
@JsonIgnore public static EntityAuditEvent fromString(String eventString) { return AtlasType.fromV1Json(eventString, EntityAuditEvent.class); } }
@JsonIgnore public static EntityAuditEvent fromString(String eventString) { return AtlasType.fromV1Json(eventString, EntityAuditEvent.class); } }
/** * Get an entity given the entity id * @param guid entity id * @return result object * @throws AtlasServiceException */ public Referenceable getEntity(String guid) throws AtlasServiceException { ObjectNode jsonResponse = callAPIWithBodyAndParams(API_V1.GET_ENTITY, null, guid); String entityInstanceDefinition = AtlasType.toJson(jsonResponse.get(AtlasClient.DEFINITION)); return AtlasType.fromV1Json(entityInstanceDefinition, Referenceable.class); }
/** * Get trait definition for a given entity and traitname * @param guid GUID of the entity * @param traitName * @return trait definition * @throws AtlasServiceException */ public Struct getTraitDefinition(final String guid, final String traitName) throws AtlasServiceException { ObjectNode jsonResponse = callAPIWithBodyAndParams(API_V1.GET_TRAIT_DEFINITION, null, guid, TRAIT_DEFINITIONS, traitName); return AtlasType.fromV1Json(AtlasType.toJson(jsonResponse.get(AtlasClient.RESULTS)), Struct.class); }
public TypesDef getType(String typeName) throws AtlasServiceException { ObjectNode response = callAPIWithBodyAndParams(API_V1.GET_TYPE, null, typeName); String typeJson = AtlasType.toJson(response.get(DEFINITION)); return AtlasType.fromV1Json(typeJson, TypesDef.class); }
/** * Get an entity given the entity id * @param guid entity id * @return result object * @throws AtlasServiceException */ public Referenceable getEntity(String guid) throws AtlasServiceException { ObjectNode jsonResponse = callAPIWithBodyAndParams(API_V1.GET_ENTITY, null, guid); String entityInstanceDefinition = AtlasType.toJson(jsonResponse.get(AtlasClient.DEFINITION)); return AtlasType.fromV1Json(entityInstanceDefinition, Referenceable.class); }
public TypesDef getType(String typeName) throws AtlasServiceException { ObjectNode response = callAPIWithBodyAndParams(API_V1.GET_TYPE, null, typeName); String typeJson = AtlasType.toJson(response.get(DEFINITION)); return AtlasType.fromV1Json(typeJson, TypesDef.class); }
/** * Get trait definition for a given entity and traitname * @param guid GUID of the entity * @param traitName * @return trait definition * @throws AtlasServiceException */ public Struct getTraitDefinition(final String guid, final String traitName) throws AtlasServiceException { ObjectNode jsonResponse = callAPIWithBodyAndParams(API_V1.GET_TRAIT_DEFINITION, null, guid, TRAIT_DEFINITIONS, traitName); return AtlasType.fromV1Json(AtlasType.toJson(jsonResponse.get(AtlasClient.RESULTS)), Struct.class); }
/** * Get all trait definitions for an entity * @param guid GUID of the entity * @return List<String> trait definitions of the traits associated to the entity * @throws AtlasServiceException */ public List<Struct> listTraitDefinitions(final String guid) throws AtlasServiceException { ObjectNode jsonResponse = callAPIWithBodyAndParams(API_V1.GET_ALL_TRAIT_DEFINITIONS, null, guid, TRAIT_DEFINITIONS); List<ObjectNode> traitDefList = extractResults(jsonResponse, AtlasClient.RESULTS, new ExtractOperation<ObjectNode, ObjectNode>()); ArrayList<Struct> traitStructList = new ArrayList<>(); for (ObjectNode traitDef : traitDefList) { Struct traitStruct = AtlasType.fromV1Json(traitDef.toString(), Struct.class); traitStructList.add(traitStruct); } return traitStructList; }
/** * Get all trait definitions for an entity * @param guid GUID of the entity * @return List<String> trait definitions of the traits associated to the entity * @throws AtlasServiceException */ public List<Struct> listTraitDefinitions(final String guid) throws AtlasServiceException { ObjectNode jsonResponse = callAPIWithBodyAndParams(API_V1.GET_ALL_TRAIT_DEFINITIONS, null, guid, TRAIT_DEFINITIONS); List<ObjectNode> traitDefList = extractResults(jsonResponse, AtlasClient.RESULTS, new ExtractOperation<ObjectNode, ObjectNode>()); ArrayList<Struct> traitStructList = new ArrayList<>(); for (ObjectNode traitDef : traitDefList) { Struct traitStruct = AtlasType.fromV1Json(traitDef.toString(), Struct.class); traitStructList.add(traitStruct); } return traitStructList; }
/** * Get an entity given the entity id * @param entityType entity type name * @param attribute qualified name of the entity * @param value * @return result object * @throws AtlasServiceException */ public Referenceable getEntity(final String entityType, final String attribute, final String value) throws AtlasServiceException { final API api = API_V1.GET_ENTITY; ObjectNode jsonResponse = callAPIWithRetries(api, null, new ResourceCreator() { @Override public WebResource createResource() { WebResource resource = getResource(api); resource = resource.queryParam(TYPE, entityType); resource = resource.queryParam(ATTRIBUTE_NAME, attribute); resource = resource.queryParam(ATTRIBUTE_VALUE, value); return resource; } }); String entityInstanceDefinition = AtlasType.toJson(jsonResponse.get(AtlasClient.DEFINITION)); return AtlasType.fromV1Json(entityInstanceDefinition, Referenceable.class); }
/** * Get an entity given the entity id * @param entityType entity type name * @param attribute qualified name of the entity * @param value * @return result object * @throws AtlasServiceException */ public Referenceable getEntity(final String entityType, final String attribute, final String value) throws AtlasServiceException { final API api = API_V1.GET_ENTITY; ObjectNode jsonResponse = callAPIWithRetries(api, null, new ResourceCreator() { @Override public WebResource createResource() { WebResource resource = getResource(api); resource = resource.queryParam(TYPE, entityType); resource = resource.queryParam(ATTRIBUTE_NAME, attribute); resource = resource.queryParam(ATTRIBUTE_VALUE, value); return resource; } }); String entityInstanceDefinition = AtlasType.toJson(jsonResponse.get(AtlasClient.DEFINITION)); return AtlasType.fromV1Json(entityInstanceDefinition, Referenceable.class); }
private String getEntityDefinition(Result result) throws AtlasBaseException { String ret = getResultString(result, COLUMN_DEFINITION); if (getAuditType(result) != ENTITY_AUDIT_V2) { Referenceable referenceable = AtlasType.fromV1Json(ret, Referenceable.class); AtlasEntity entity = toAtlasEntity(referenceable); ret = AtlasType.toJson(entity); } return ret; }
private String getV2Details(Result result) throws AtlasBaseException { String ret = null; String v1DetailsWithPrefix = getResultString(result, COLUMN_DETAIL); if (StringUtils.isNotEmpty(v1DetailsWithPrefix)) { EntityAuditAction v1AuditAction = EntityAuditAction.fromString(getResultString(result, COLUMN_ACTION)); if (v1AuditAction == TERM_ADD || v1AuditAction == TERM_DELETE) { // for terms audit v1 and v2 structure is same ret = v1DetailsWithPrefix; } else { String v1AuditPrefix = EntityAuditListener.getV1AuditPrefix(v1AuditAction); String[] split = v1DetailsWithPrefix.split(v1AuditPrefix); if (ArrayUtils.isNotEmpty(split) && split.length == 2) { String v1AuditDetails = split[1]; Referenceable referenceable = AtlasType.fromV1Json(v1AuditDetails, Referenceable.class); String v2Json = (referenceable != null) ? toV2Json(referenceable, v1AuditAction) : v1AuditDetails; if (v2Json != null) { ret = getV2AuditPrefix(v1AuditAction) + v2Json; } } else { ret = v1DetailsWithPrefix; } } } return ret; }
public AtlasEntitiesWithExtInfo toAtlasEntities(String[] jsonEntities) throws AtlasBaseException, AtlasException { Referenceable[] referenceables = new Referenceable[jsonEntities.length]; for (int i = 0; i < jsonEntities.length; i++) { referenceables[i] = AtlasType.fromV1Json(jsonEntities[i], Referenceable.class); } AtlasEntityFormatConverter converter = (AtlasEntityFormatConverter) instanceFormatters.getConverter(TypeCategory.ENTITY); ConverterContext context = new ConverterContext(); for (Referenceable referenceable : referenceables) { AtlasEntityType entityType = typeRegistry.getEntityTypeByName(referenceable.getTypeName()); if (entityType == null) { throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_INVALID, TypeCategory.ENTITY.name(), referenceable.getTypeName()); } AtlasEntity entity = converter.fromV1ToV2(referenceable, entityType, context); context.addEntity(entity); } AtlasEntitiesWithExtInfo ret = context.getEntities(); return ret; }