Java Code Examples for org.apache.atlas.model.instance.AtlasEntity#setCustomAttributes()
The following examples show how to use
org.apache.atlas.model.instance.AtlasEntity#setCustomAttributes() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AtlasEntityStoreV2Test.java From atlas with Apache License 2.0 | 6 votes |
@Test (dependsOnMethods = "testCreate") public void addCustomAttributesToEntity() throws AtlasBaseException { AtlasEntity tblEntity = getEntityFromStore(tblEntityGuid); Map<String, String> customAttributes = new HashMap<>(); customAttributes.put("key1", "val1"); customAttributes.put("key2", "val2"); customAttributes.put("key3", "val3"); customAttributes.put("key4", "val4"); customAttributes.put("key5", "val5"); tblEntity.setCustomAttributes(customAttributes); entityStore.createOrUpdate(new AtlasEntityStream(tblEntity), false); tblEntity = getEntityFromStore(tblEntityGuid); assertEquals(customAttributes, tblEntity.getCustomAttributes()); }
Example 2
Source File: AtlasEntityStoreV2Test.java From atlas with Apache License 2.0 | 6 votes |
@Test (dependsOnMethods = "addCustomAttributesToEntity") public void updateCustomAttributesToEntity() throws AtlasBaseException { AtlasEntity tblEntity = getEntityFromStore(tblEntityGuid); // update custom attributes, remove key3, key4 and key5 Map<String, String> customAttributes = new HashMap<>(); customAttributes.put("key1", "val1"); customAttributes.put("key2", "val2"); tblEntity.setCustomAttributes(customAttributes); entityStore.createOrUpdate(new AtlasEntityStream(tblEntity), false); tblEntity = getEntityFromStore(tblEntityGuid); assertEquals(customAttributes, tblEntity.getCustomAttributes()); }
Example 3
Source File: AtlasEntityStoreV2Test.java From atlas with Apache License 2.0 | 6 votes |
@Test (dependsOnMethods = "addInvalidKeysToEntityCustomAttributes") public void addInvalidValuesToEntityCustomAttributes() throws AtlasBaseException { AtlasEntity tblEntity = getEntityFromStore(tblEntityGuid); // value length is greater than 500 Map<String, String> invalidCustomAttributes = new HashMap<>(); invalidCustomAttributes.put("key1", randomAlphanumeric(500)); invalidCustomAttributes.put("key2", randomAlphanumeric(501)); tblEntity.setCustomAttributes(invalidCustomAttributes); try { entityStore.createOrUpdate(new AtlasEntityStream(tblEntity), false); } catch (AtlasBaseException ex) { assertEquals(ex.getAtlasErrorCode(), INVALID_CUSTOM_ATTRIBUTE_VALUE); } }
Example 4
Source File: EntityGraphRetriever.java From atlas with Apache License 2.0 | 5 votes |
private AtlasEntity mapSystemAttributes(AtlasVertex entityVertex, AtlasEntity entity) { if (LOG.isDebugEnabled()) { LOG.debug("Mapping system attributes for type {}", entity.getTypeName()); } entity.setGuid(getGuid(entityVertex)); entity.setTypeName(getTypeName(entityVertex)); entity.setStatus(GraphHelper.getStatus(entityVertex)); entity.setVersion(GraphHelper.getVersion(entityVertex)); entity.setCreatedBy(GraphHelper.getCreatedByAsString(entityVertex)); entity.setUpdatedBy(GraphHelper.getModifiedByAsString(entityVertex)); entity.setCreateTime(new Date(GraphHelper.getCreatedTime(entityVertex))); entity.setUpdateTime(new Date(GraphHelper.getModifiedTime(entityVertex))); entity.setHomeId(GraphHelper.getHomeId(entityVertex)); entity.setIsProxy(GraphHelper.isProxy(entityVertex)); entity.setIsIncomplete(isEntityIncomplete(entityVertex)); entity.setProvenanceType(GraphHelper.getProvenanceType(entityVertex)); entity.setCustomAttributes(getCustomAttributes(entityVertex)); entity.setLabels(getLabels(entityVertex)); return entity; }
Example 5
Source File: AtlasEntityStoreV2Test.java From atlas with Apache License 2.0 | 5 votes |
@Test (dependsOnMethods = "updateCustomAttributesToEntity") public void deleteCustomAttributesToEntity() throws AtlasBaseException { AtlasEntity tblEntity = getEntityFromStore(tblEntityGuid); Map<String, String> emptyCustomAttributes = new HashMap<>(); // remove all custom attributes tblEntity.setCustomAttributes(emptyCustomAttributes); entityStore.createOrUpdate(new AtlasEntityStream(tblEntity), false); tblEntity = getEntityFromStore(tblEntityGuid); assertEquals(emptyCustomAttributes, tblEntity.getCustomAttributes()); }
Example 6
Source File: AtlasEntityStoreV2Test.java From atlas with Apache License 2.0 | 4 votes |
@Test (dependsOnMethods = "deleteCustomAttributesToEntity") public void nullCustomAttributesToEntity() throws AtlasBaseException { AtlasEntity tblEntity = getEntityFromStore(tblEntityGuid); Map<String, String> customAttributes = new HashMap<>(); customAttributes.put("key1", "val1"); customAttributes.put("key2", "val2"); tblEntity.setCustomAttributes(customAttributes); entityStore.createOrUpdate(new AtlasEntityStream(tblEntity), false); // assign custom attributes to null tblEntity.setCustomAttributes(null); entityStore.createOrUpdate(new AtlasEntityStream(tblEntity), false); tblEntity = getEntityFromStore(tblEntityGuid); assertEquals(customAttributes, tblEntity.getCustomAttributes()); }
Example 7
Source File: TestEntitiesREST.java From atlas with Apache License 2.0 | 3 votes |
@Test public void testCustomAttributesSearch() throws Exception { AtlasEntity dbWithCustomAttr = new AtlasEntity(dbEntity); Map customAttr = new HashMap<String, String>() {{ put("key1", "value1"); }}; dbWithCustomAttr.setCustomAttributes(customAttr); AtlasEntitiesWithExtInfo atlasEntitiesWithExtInfo = new AtlasEntitiesWithExtInfo(dbWithCustomAttr); EntityMutationResponse response = entityREST.createOrUpdate(atlasEntitiesWithExtInfo); Assert.assertNotNull(response.getUpdatedEntitiesByTypeName(DATABASE_TYPE)); searchParameters = new SearchParameters(); searchParameters.setTypeName("_ALL_ENTITY_TYPES"); SearchParameters.FilterCriteria filter = new SearchParameters.FilterCriteria(); filter.setAttributeName(CUSTOM_ATTRIBUTES_PROPERTY_KEY); filter.setOperator(SearchParameters.Operator.CONTAINS); filter.setAttributeValue("key1=value1"); searchParameters.setEntityFilters(filter); AtlasSearchResult res = discoveryREST.searchWithParameters(searchParameters); Assert.assertNotNull(res.getEntities()); Assert.assertEquals(res.getEntities().size(), 1); }