@JsonIgnore public String getEntityDefinitionString() { if (entity != null) { return AtlasType.toJson(entity); } return null; }
/** * Bulk update API for all types, changes detected in the type definitions would be persisted * * @param typesDef A composite object that captures all type definition changes * @return A composite object with lists of type definitions that were updated */ public AtlasTypesDef updateAtlasTypeDefs(final AtlasTypesDef typesDef) throws AtlasServiceException { return callAPI(API_V2.UPDATE_ALL_TYPE_DEFS, AtlasTypesDef.class, AtlasType.toJson(typesDef)); }
/** * Bulk create APIs for all atlas type definitions, only new definitions will be created. * Any changes to the existing definitions will be discarded * * @param typesDef A composite wrapper object with corresponding lists of the type definition * @return A composite wrapper object with lists of type definitions that were successfully * created */ public AtlasTypesDef createAtlasTypeDefs(final AtlasTypesDef typesDef) throws AtlasServiceException { return callAPI(API_V2.CREATE_ALL_TYPE_DEFS, AtlasTypesDef.class, AtlasType.toJson(typesDef)); }
/** * Bulk update API for all types, changes detected in the type definitions would be persisted * * @param typesDef A composite object that captures all type definition changes * @return A composite object with lists of type definitions that were updated */ public AtlasTypesDef updateAtlasTypeDefs(final AtlasTypesDef typesDef) throws AtlasServiceException { return callAPI(API_V2.UPDATE_ALL_TYPE_DEFS, AtlasTypesDef.class, AtlasType.toJson(typesDef)); }
private String toV2Json(Referenceable referenceable, EntityAuditAction action) throws AtlasBaseException { String ret; if (action == TAG_ADD || action == TAG_UPDATE || action == TAG_DELETE) { AtlasClassification classification = instanceConverter.toAtlasClassification(referenceable); ret = AtlasType.toJson(classification); } else { AtlasEntity entity = toAtlasEntity(referenceable); ret = AtlasType.toJson(entity); } return ret; }
/** * 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 AtlasImportResult importData(AtlasImportRequest request, String absoluteFilePath) throws AtlasServiceException { FileDataBodyPart filePart = new FileDataBodyPart("data", new File(absoluteFilePath)); MultiPart multipartEntity = new FormDataMultiPart() .field("request", AtlasType.toJson(request), MediaType.APPLICATION_JSON_TYPE) .bodyPart(filePart); return callAPI(IMPORT, AtlasImportResult.class, multipartEntity); }
@Test public void testEntityDefSerDeEmpty() { AtlasEntityDef entityDef = new AtlasEntityDef("emptyEntityDef"); String jsonString = AtlasType.toJson(entityDef); AtlasEntityDef entityDef2 = AtlasType.fromJson(jsonString, AtlasEntityDef.class); assertEquals(entityDef2, entityDef, "Incorrect serialization/deserialization of AtlasEntityDef"); }
@Test public void testClassificationDefSerDeWithSuperTypes() { AtlasClassificationDef classificationDef = ModelTestUtil.getClassificationDefWithSuperTypes(); String jsonString = AtlasType.toJson(classificationDef); AtlasClassificationDef classificationDef2 = AtlasType.fromJson(jsonString, AtlasClassificationDef.class); assertEquals(classificationDef2, classificationDef, "Incorrect serialization/deserialization of AtlasClassificationDef with superTypes"); }
@Test public void testClassificationDefSerDe() { AtlasClassificationDef classificationDef = ModelTestUtil.getClassificationDef(); String jsonString = AtlasType.toJson(classificationDef); AtlasClassificationDef classificationDef2 = AtlasType.fromJson(jsonString, AtlasClassificationDef.class); assertEquals(classificationDef2, classificationDef, "Incorrect serialization/deserialization of AtlasClassificationDef"); }
@Test public void testStructDefSerDe() { AtlasStructDef structDef = ModelTestUtil.getStructDef(); String jsonString = AtlasType.toJson(structDef); AtlasStructDef structDef2 = AtlasType.fromJson(jsonString, AtlasStructDef.class); assertEquals(structDef2, structDef, "Incorrect serialization/deserialization of AtlasStructDef"); }
@Test public void testStructDefSerDe() { AtlasStructDef structDef = ModelTestUtil.getStructDef(); String jsonString = AtlasType.toJson(structDef); AtlasStructDef structDef2 = AtlasType.fromJson(jsonString, AtlasStructDef.class); assertEquals(structDef2, structDef, "Incorrect serialization/deserialization of AtlasStructDef"); }
@Test public void testClassificationDefSerDeEmpty() { AtlasClassificationDef classificationDef = new AtlasClassificationDef("emptyClassificationDef"); String jsonString = AtlasType.toJson(classificationDef); AtlasClassificationDef classificationDef2 = AtlasType.fromJson(jsonString, AtlasClassificationDef.class); assertEquals(classificationDef2, classificationDef, "Incorrect serialization/deserialization of AtlasClassificationDef"); }
@Test public void testClassificationDefSerDeWithSuperTypes() { AtlasClassificationDef classificationDef = ModelTestUtil.getClassificationDefWithSuperTypes(); String jsonString = AtlasType.toJson(classificationDef); AtlasClassificationDef classificationDef2 = AtlasType.fromJson(jsonString, AtlasClassificationDef.class); assertEquals(classificationDef2, classificationDef, "Incorrect serialization/deserialization of AtlasClassificationDef with superTypes"); }
@Test public void testEntityDefSerDe() { AtlasEntityDef entityDef = ModelTestUtil.getEntityDef(); String jsonString = AtlasType.toJson(entityDef); AtlasEntityDef entityDef2 = AtlasType.fromJson(jsonString, AtlasEntityDef.class); assertEquals(entityDef2, entityDef, "Incorrect serialization/deserialization of AtlasEntityDef"); }
@Test public void testEntityDefSerDeWithSuperTypes() { AtlasEntityDef entityDef = ModelTestUtil.getEntityDefWithSuperTypes(); String jsonString = AtlasType.toJson(entityDef); AtlasEntityDef entityDef2 = AtlasType.fromJson(jsonString, AtlasEntityDef.class); assertEquals(entityDef2, entityDef, "Incorrect serialization/deserialization of AtlasEntityDef with superTypes"); }
@JsonIgnore public String toAuditString() { AtlasGlossaryTerm t = new AtlasGlossaryTerm(); t.setGuid(this.getGuid()); t.setName(this.getName()); t.setQualifiedName(this.getQualifiedName()); return AtlasType.toJson(t); }
@Test public void testEntitySerDe() throws AtlasBaseException { AtlasEntityDef entityDef = ModelTestUtil.getEntityDef(); AtlasTypeRegistry typeRegistry = ModelTestUtil.getTypesRegistry(); AtlasEntityType entityType = typeRegistry.getEntityTypeByName(entityDef.getName()); assertNotNull(entityType); AtlasEntity ent1 = entityType.createDefaultValue(); String jsonString = AtlasType.toJson(ent1); AtlasEntity ent2 = AtlasType.fromJson(jsonString, AtlasEntity.class); entityType.normalizeAttributeValues(ent2); assertEquals(ent2, ent1, "Incorrect serialization/deserialization of AtlasEntity"); }
@Test public void testClassificationSerDe() throws AtlasBaseException { AtlasClassificationDef classificationDef = ModelTestUtil.getClassificationDef(); AtlasTypeRegistry typeRegistry = ModelTestUtil.getTypesRegistry(); AtlasClassificationType classificationType = typeRegistry.getClassificationTypeByName(classificationDef.getName()); assertNotNull(classificationType); AtlasClassification ent1 = ModelTestUtil.newClassification(classificationDef, typeRegistry); String jsonString = AtlasType.toJson(ent1); AtlasClassification ent2 = AtlasType.fromJson(jsonString, AtlasClassification.class); classificationType.normalizeAttributeValues(ent2); assertEquals(ent2, ent1, "Incorrect serialization/deserialization of AtlasClassification"); }