public AtlasStruct(String typeName, String attrName, Object attrValue) { setTypeName(typeName); setAttribute(attrName, attrValue); }
public AtlasStruct(String typeName, String attrName, Object attrValue) { setTypeName(typeName); setAttribute(attrName, attrValue); }
protected AtlasRelatedObjectId termIdToRelatedObjectId(AtlasRelatedTermHeader relatedTermId) { AtlasRelatedObjectId ret = new AtlasRelatedObjectId(); ret.setGuid(relatedTermId.getTermGuid()); ret.setRelationshipGuid(relatedTermId.getRelationGuid()); AtlasStruct relationshipAttributes = new AtlasStruct(); relationshipAttributes.setAttribute("description", relatedTermId.getDescription()); relationshipAttributes.setAttribute("expression", relatedTermId.getExpression()); relationshipAttributes.setAttribute("source", relatedTermId.getSource()); relationshipAttributes.setAttribute("steward", relatedTermId.getSteward()); relationshipAttributes.setAttribute("status", relatedTermId.getStatus().name()); ret.setRelationshipAttributes(relationshipAttributes); return ret; }
protected AtlasRelatedObjectId termIdToRelatedObjectId(AtlasRelatedTermHeader relatedTermId) { AtlasRelatedObjectId ret = new AtlasRelatedObjectId(); ret.setGuid(relatedTermId.getTermGuid()); ret.setRelationshipGuid(relatedTermId.getRelationGuid()); AtlasStruct relationshipAttributes = new AtlasStruct(); relationshipAttributes.setAttribute("description", relatedTermId.getDescription()); relationshipAttributes.setAttribute("expression", relatedTermId.getExpression()); relationshipAttributes.setAttribute("source", relatedTermId.getSource()); relationshipAttributes.setAttribute("steward", relatedTermId.getSteward()); relationshipAttributes.setAttribute("status", relatedTermId.getStatus().name()); ret.setRelationshipAttributes(relationshipAttributes); return ret; }
public void normalizeAttributeValues(AtlasStruct obj) { if (obj != null) { for (AtlasAttributeDef attributeDef : structDef.getAttributeDefs()) { String attributeName = attributeDef.getName(); if (obj.hasAttribute(attributeName)) { Object attributeValue = getNormalizedValue(obj.getAttribute(attributeName), attributeDef); obj.setAttribute(attributeName, attributeValue); } else if (!attributeDef.getIsOptional()) { obj.setAttribute(attributeName, createDefaultValue(attributeDef)); } } } }
public void normalizeAttributeValues(AtlasStruct obj) { if (obj != null) { for (AtlasAttributeDef attributeDef : structDef.getAttributeDefs()) { String attributeName = attributeDef.getName(); if (obj.hasAttribute(attributeName)) { Object attributeValue = getNormalizedValue(obj.getAttribute(attributeName), attributeDef); obj.setAttribute(attributeName, attributeValue); } else if (!attributeDef.getIsOptional()) { obj.setAttribute(attributeName, createDefaultValue(attributeDef)); } } } }
private void normalizeRelationshipAttributeValues(AtlasStruct obj) { if (obj != null && obj instanceof AtlasEntity) { AtlasEntity entityObj = (AtlasEntity) obj; for (AtlasAttribute attribute : relationshipAttributes.values()) { String attributeName = attribute.getName(); AtlasAttributeDef attributeDef = attribute.getAttributeDef(); if (((AtlasEntity) obj).hasRelationshipAttribute(attributeName)) { Object attributeValue = getNormalizedValue(entityObj.getAttribute(attributeName), attributeDef); obj.setAttribute(attributeName, attributeValue); } } } }
public void normalizeAttributeValuesForUpdate(AtlasStruct obj) { if (obj != null) { for (AtlasAttributeDef attributeDef : structDef.getAttributeDefs()) { String attributeName = attributeDef.getName(); if (obj.hasAttribute(attributeName)) { Object attributeValue = getNormalizedValueForUpdate(obj.getAttribute(attributeName), attributeDef); obj.setAttribute(attributeName, attributeValue); } } } }
public void normalizeAttributeValuesForUpdate(AtlasStruct obj) { if (obj != null) { for (AtlasAttributeDef attributeDef : structDef.getAttributeDefs()) { String attributeName = attributeDef.getName(); if (obj.hasAttribute(attributeName)) { Object attributeValue = getNormalizedValueForUpdate(obj.getAttribute(attributeName), attributeDef); obj.setAttribute(attributeName, attributeValue); } } } }
private void mapAttributes(AtlasVertex entityVertex, AtlasStruct struct, AtlasEntityExtInfo entityExtInfo, boolean isMinExtInfo) throws AtlasBaseException { AtlasType objType = typeRegistry.getType(struct.getTypeName()); if (!(objType instanceof AtlasStructType)) { throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_INVALID, struct.getTypeName()); } AtlasStructType structType = (AtlasStructType) objType; for (AtlasAttribute attribute : structType.getAllAttributes().values()) { Object attrValue = mapVertexToAttribute(entityVertex, attribute, entityExtInfo, isMinExtInfo); struct.setAttribute(attribute.getName(), attrValue); } }
private void mapAttributes(AtlasVertex entityVertex, AtlasStruct struct, AtlasEntityExtInfo entityExtInfo, boolean isMinExtInfo) throws AtlasBaseException { AtlasType objType = typeRegistry.getType(struct.getTypeName()); if (!(objType instanceof AtlasStructType)) { throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_INVALID, struct.getTypeName()); } AtlasStructType structType = (AtlasStructType) objType; for (AtlasAttribute attribute : structType.getAllAttributes().values()) { Object attrValue = mapVertexToAttribute(entityVertex, attribute, entityExtInfo, isMinExtInfo); struct.setAttribute(attribute.getName(), attrValue); } }
protected AtlasRelatedObjectId relatedCategoryIdToRelatedObjectId(AtlasRelatedCategoryHeader relatedCategoryId) { AtlasRelatedObjectId ret = new AtlasRelatedObjectId(); ret.setGuid(relatedCategoryId.getCategoryGuid()); ret.setRelationshipGuid(relatedCategoryId.getRelationGuid()); AtlasStruct relationshipAttributes = new AtlasStruct(); relationshipAttributes.setAttribute("description", relatedCategoryId.getDescription()); ret.setRelationshipAttributes(relationshipAttributes); return ret; }
protected AtlasRelatedObjectId relatedCategoryIdToRelatedObjectId(AtlasRelatedCategoryHeader relatedCategoryId) { AtlasRelatedObjectId ret = new AtlasRelatedObjectId(); ret.setGuid(relatedCategoryId.getCategoryGuid()); ret.setRelationshipGuid(relatedCategoryId.getRelationGuid()); AtlasStruct relationshipAttributes = new AtlasStruct(); relationshipAttributes.setAttribute("description", relatedCategoryId.getDescription()); ret.setRelationshipAttributes(relationshipAttributes); return ret; }
SerDeInfo sdSerDeInfo = sd.getSerdeInfo(); serdeInfo.setAttribute(ATTRIBUTE_NAME, sdSerDeInfo.getName()); serdeInfo.setAttribute(ATTRIBUTE_SERIALIZATION_LIB, sdSerDeInfo.getSerializationLib()); serdeInfo.setAttribute(ATTRIBUTE_PARAMETERS, sdSerDeInfo.getParameters()); AtlasStruct sortcol = new AtlasStruct(HIVE_TYPE_ORDER); sortcol.setAttribute("col", sdSortCol.getCol()); sortcol.setAttribute("order", sdSortCol.getOrder());
@Test(dependsOnMethods = "testCreate") public void testStructs() throws Exception { AtlasEntity databaseEntity = dbEntity.getEntity(); AtlasEntity tableEntity = new AtlasEntity(tblEntity.getEntity()); AtlasEntitiesWithExtInfo entitiesInfo = new AtlasEntitiesWithExtInfo(tableEntity); AtlasStruct serdeInstance = new AtlasStruct(TestUtilsV2.SERDE_TYPE, TestUtilsV2.NAME, "serde1Name"); serdeInstance.setAttribute("serde", "test"); serdeInstance.setAttribute("description", "testDesc"); tableEntity.setAttribute("serde1", serdeInstance); tableEntity.setAttribute("database", new AtlasObjectId(databaseEntity.getTypeName(), TestUtilsV2.NAME, databaseEntity.getAttribute(TestUtilsV2.NAME))); init(); EntityMutationResponse response = entityStore.createOrUpdate(new AtlasEntityStream(entitiesInfo), false); AtlasEntityHeader updatedTable = response.getFirstUpdatedEntityByTypeName(TABLE_TYPE); validateEntity(entitiesInfo, getEntityFromStore(updatedTable)); //update struct attribute serdeInstance.setAttribute("serde", "testUpdated"); init(); response = entityStore.createOrUpdate(new AtlasEntityStream(entitiesInfo), false); updatedTable = response.getFirstUpdatedEntityByTypeName(TABLE_TYPE); validateEntity(entitiesInfo, getEntityFromStore(updatedTable)); //set to null tableEntity.setAttribute("description", null); init(); response = entityStore.createOrUpdate(new AtlasEntityStream(entitiesInfo), false); updatedTable = response.getFirstUpdatedEntityByTypeName(TABLE_TYPE); Assert.assertNull(updatedTable.getAttribute("description")); validateEntity(entitiesInfo, getEntityFromStore(updatedTable)); }
@Test(dependsOnMethods = "testCreate") public void testStructs() throws Exception { AtlasEntity databaseEntity = dbEntity.getEntity(); AtlasEntity tableEntity = new AtlasEntity(tblEntity.getEntity()); AtlasEntitiesWithExtInfo entitiesInfo = new AtlasEntitiesWithExtInfo(tableEntity); AtlasStruct serdeInstance = new AtlasStruct(TestUtilsV2.SERDE_TYPE, TestUtilsV2.NAME, "serde1Name"); serdeInstance.setAttribute("serde", "test"); serdeInstance.setAttribute("description", "testDesc"); tableEntity.setAttribute("serde1", serdeInstance); tableEntity.setAttribute("database", new AtlasObjectId(databaseEntity.getTypeName(), TestUtilsV2.NAME, databaseEntity.getAttribute(TestUtilsV2.NAME))); init(); EntityMutationResponse response = entityStore.createOrUpdate(new AtlasEntityStream(entitiesInfo), false); AtlasEntityHeader updatedTable = response.getFirstUpdatedEntityByTypeName(TABLE_TYPE); validateEntity(entitiesInfo, getEntityFromStore(updatedTable)); //update struct attribute serdeInstance.setAttribute("serde", "testUpdated"); init(); response = entityStore.createOrUpdate(new AtlasEntityStream(entitiesInfo), false); updatedTable = response.getFirstUpdatedEntityByTypeName(TABLE_TYPE); validateEntity(entitiesInfo, getEntityFromStore(updatedTable)); //set to null tableEntity.setAttribute("description", null); init(); response = entityStore.createOrUpdate(new AtlasEntityStream(entitiesInfo), false); updatedTable = response.getFirstUpdatedEntityByTypeName(TABLE_TYPE); Assert.assertNull(updatedTable.getAttribute("description")); validateEntity(entitiesInfo, getEntityFromStore(updatedTable)); }
structList.get(0).setAttribute(NAME, "structArray11-edit"); complexEntity.setAttribute("listOfStructs", structList); response = entityStore.createOrUpdate(new AtlasEntityStream(complexEntitiesInfo), false);
structList.get(0).setAttribute(NAME, "structArray11-edit"); complexEntity.setAttribute("listOfStructs", structList); response = entityStore.createOrUpdate(new AtlasEntityStream(complexEntitiesInfo), false);
partitions.get(0).setAttribute(TestUtilsV2.NAME, "part4"); response = entityStore.createOrUpdate(new AtlasEntityStream(entitiesInfo), false); updatedTable = response.getFirstUpdatedEntityByTypeName(TABLE_TYPE);
structMap.get("key11").setAttribute("name", "structMap11-edit"); complexEntity.setAttribute("mapOfStructs", structMap);