/** * 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); }
@Override public String toString() { return AtlasType.toV1Json(this); }
private String getCollectionElementType(AtlasType elemType) { if(elemType.getTypeCategory() == TypeCategory.OBJECT_ID_TYPE) { return ((AtlasBuiltInTypes.AtlasObjectIdType)elemType).getObjectType(); } else { return elemType.getTypeName(); } }
public boolean validateValue(Object obj, String objName, List<String> messages) { boolean ret = isValidValue(obj); if (!ret) { messages.add(objName + "=" + obj + ": invalid value for type " + getTypeName()); } return ret; }
@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"); }
public static EntityResult fromString(String json) { return AtlasType.fromV1Json(json, EntityResult.class); } }
public AtlasMapType(AtlasType keyType, AtlasType valueType) { super(AtlasBaseTypeDef.getMapTypeName(keyType.getTypeName(), valueType.getTypeName()), TypeCategory.MAP); this.keyTypeName = keyType.getTypeName(); this.valueTypeName = valueType.getTypeName(); this.keyType = keyType; this.valueType = valueType; }
private boolean isTraitType(AtlasType t) { return (t != null && t.getTypeCategory() == TypeCategory.CLASSIFICATION); }
protected AtlasTypesDef getTypesDefFromFile(String s) { File f = new File(getFilePath(s)); try { return AtlasType.fromJson(FileUtils.readFileToString(f), AtlasTypesDef.class); } catch (IOException e) { throw new SkipException("getTypesDefFromFile: " + s, e); } }
private void mapAttribute(AtlasAttribute attribute, Object attrValue, AtlasVertex vertex, EntityOperation op, EntityMutationContext context) throws AtlasBaseException { if (attrValue == null) { AtlasAttributeDef attributeDef = attribute.getAttributeDef(); AtlasType attrType = attribute.getAttributeType(); if (attrType.getTypeCategory() == TypeCategory.PRIMITIVE) { if (attributeDef.getDefaultValue() != null) { attrValue = attrType.createDefaultValue(attributeDef.getDefaultValue()); } else { if (attribute.getAttributeDef().getIsOptional()) { attrValue = attrType.createOptionalDefaultValue(); } else { attrValue = attrType.createDefaultValue(); } } } } AttributeMutationContext ctx = new AttributeMutationContext(op, vertex, attribute, attrValue); mapToVertexByTypeCategory(ctx, context); }
} else { for (Object key : map1.keySet()) { if (!valueType.areEqualValues(map1.get(key), map2.get(key))) { ret = false;
@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"); }
@Override EntityAuditEvent extractElement(ObjectNode element) { return AtlasType.fromV1Json(element.toString(), EntityAuditEvent.class); } });
public AtlasMapType(AtlasType keyType, AtlasType valueType) { super(AtlasBaseTypeDef.getMapTypeName(keyType.getTypeName(), valueType.getTypeName()), TypeCategory.MAP); this.keyTypeName = keyType.getTypeName(); this.valueTypeName = valueType.getTypeName(); this.keyType = keyType; this.valueType = valueType; }
private boolean isTraitType(AtlasType t) { return (t != null && t.getTypeCategory() == TypeCategory.CLASSIFICATION); }
private void mapAttribute(AtlasAttribute attribute, Object attrValue, AtlasVertex vertex, EntityOperation op, EntityMutationContext context) throws AtlasBaseException { if (attrValue == null) { AtlasAttributeDef attributeDef = attribute.getAttributeDef(); AtlasType attrType = attribute.getAttributeType(); if (attrType.getTypeCategory() == TypeCategory.PRIMITIVE) { if (attributeDef.getDefaultValue() != null) { attrValue = attrType.createDefaultValue(attributeDef.getDefaultValue()); } else { if (attribute.getAttributeDef().getIsOptional()) { attrValue = attrType.createOptionalDefaultValue(); } else { attrValue = attrType.createDefaultValue(); } } } } AttributeMutationContext ctx = new AttributeMutationContext(op, vertex, attribute, attrValue); mapToVertexByTypeCategory(ctx, context); }
Object newValue = newEntity.getAttribute(attrName); if (!attrType.areEqualValues(currEntity.getAttribute(attrName), newEntity.getAttribute(attrName))) { ret = true;
@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"); }
/** * 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); }
@Override public String toString() { return AtlasType.toV1Json(this); }