final Map<String, Object> attributes = nifiFlowEntity.getAttributes(); final NiFiFlow nifiFlow = new NiFiFlow(rootProcessGroupId); nifiFlow.setExEntity(nifiFlowEntity);
public String getQualifiedName(Object obj) { Map<String, Object> attributes = null; if (obj instanceof AtlasObjectId) { attributes = ((AtlasObjectId) obj).getUniqueAttributes(); } else if (obj instanceof Map) { attributes = (Map) ((Map) obj).get(AtlasObjectId.KEY_UNIQUE_ATTRIBUTES); } else if (obj instanceof AtlasEntity) { attributes = ((AtlasEntity) obj).getAttributes(); } else if (obj instanceof AtlasEntityWithExtInfo) { attributes = ((AtlasEntityWithExtInfo) obj).getEntity().getAttributes(); } Object ret = attributes != null ? attributes.get(ATTRIBUTE_QUALIFIED_NAME) : null; return ret != null ? ret.toString() : null; }
@Override public ExportImportAuditEntry from(AtlasEntity entity) { return from(entity.getGuid(), entity.getAttributes()); }
private static void compactAttributes(AtlasEntity entity) { if (entity != null) { Map<String, Object> relationshipAttributes = entity.getRelationshipAttributes(); Map<String, Object> attributes = entity.getAttributes(); if (MapUtils.isNotEmpty(relationshipAttributes) && MapUtils.isNotEmpty(attributes)) { for (String attrName : relationshipAttributes.keySet()) { if (attributes.containsKey(attrName)) { entity.removeAttribute(attrName); } } } } }
private static void compactAttributes(AtlasEntity entity) { if (entity != null) { Map<String, Object> relationshipAttributes = entity.getRelationshipAttributes(); Map<String, Object> attributes = entity.getAttributes(); if (MapUtils.isNotEmpty(relationshipAttributes) && MapUtils.isNotEmpty(attributes)) { for (String attrName : relationshipAttributes.keySet()) { if (attributes.containsKey(attrName)) { entity.removeAttribute(attrName); } } } } }
private Map<String, Object> pruneEntityAttributesForAudit(AtlasEntity entity) { Map<String, Object> ret = null; Map<String, Object> entityAttributes = entity.getAttributes(); List<String> excludeAttributes = auditRepository.getAuditExcludeAttributes(entity.getTypeName()); AtlasEntityType entityType = typeRegistry.getEntityTypeByName(entity.getTypeName()); if (CollectionUtils.isNotEmpty(excludeAttributes) && MapUtils.isNotEmpty(entityAttributes) && entityType != null) { for (AtlasAttribute attribute : entityType.getAllAttributes().values()) { String attrName = attribute.getName(); Object attrValue = entityAttributes.get(attrName); if (excludeAttributes.contains(attrName)) { if (ret == null) { ret = new HashMap<>(); } ret.put(attrName, attrValue); entityAttributes.remove(attrName); } } } return ret; }
private Map<String, Object> pruneEntityAttributesForAudit(AtlasEntity entity) { Map<String, Object> ret = null; Map<String, Object> entityAttributes = entity.getAttributes(); List<String> excludeAttributes = auditRepository.getAuditExcludeAttributes(entity.getTypeName()); AtlasEntityType entityType = typeRegistry.getEntityTypeByName(entity.getTypeName()); if (CollectionUtils.isNotEmpty(excludeAttributes) && MapUtils.isNotEmpty(entityAttributes) && entityType != null) { for (AtlasAttribute attribute : entityType.getAllAttributes().values()) { String attrName = attribute.getName(); Object attrValue = entityAttributes.get(attrName); if (excludeAttributes.contains(attrName)) { if (ret == null) { ret = new HashMap<>(); } ret.put(attrName, attrValue); entityAttributes.remove(attrName); } } } return ret; }
public AtlasEntityHeader(AtlasEntity entity) { super(entity.getTypeName(), entity.getAttributes()); setGuid(entity.getGuid()); setClassifications(entity.getClassifications()); if (CollectionUtils.isNotEmpty(entity.getClassifications())) { this.classificationNames = new ArrayList<>(entity.getClassifications().size()); for (AtlasClassification classification : entity.getClassifications()) { this.classificationNames.add(classification.getTypeName()); } } }
private void map(AtlasEntity entity, AtlasEntityExtInfo entityExtInfo, StringBuilder sb, Set<String> processedGuids) throws AtlasBaseException { if (entity == null || processedGuids.contains(entity.getGuid())) { return; } processedGuids.add(entity.getGuid()); sb.append(entity.getTypeName()).append(FULL_TEXT_DELIMITER); Set<String> excludeAttributes = getExcludeAttributesForIndexText(entity.getTypeName()); mapAttributes(entity.getAttributes(), entityExtInfo, sb, processedGuids, excludeAttributes); List<AtlasClassification> classifications = entity.getClassifications(); if (CollectionUtils.isNotEmpty(classifications)) { for (AtlasClassification classification : classifications) { sb.append(classification.getTypeName()).append(FULL_TEXT_DELIMITER); Set<String> excludeClassificationAttributes = getExcludeAttributesForIndexText(classification.getTypeName()); mapAttributes(classification.getAttributes(), entityExtInfo, sb, processedGuids, excludeClassificationAttributes); } } }
if (MapUtils.isNotEmpty(entity.getAttributes())) { for (Map.Entry<String, Object> entry : entity.getAttributes().entrySet()) { if (entry.getValue() instanceof AtlasObjectId) { ret.put(entry.getKey(), new LinkedHashMap<String, Object>(){{
private void removeAttribute(AtlasEntityWithExtInfo entity, String attributeName) { Object attributeValue = entity.getEntity().getAttribute(attributeName); entity.getEntity().getAttributes().remove(attributeName); if (attributeValue instanceof AtlasObjectId) { AtlasObjectId objectId = (AtlasObjectId) attributeValue; entity.removeReferredEntity(objectId.getGuid()); } else if (attributeValue instanceof Collection) { for (Object item : (Collection) attributeValue) if (item instanceof AtlasObjectId) { AtlasObjectId objectId = (AtlasObjectId) item; entity.removeReferredEntity(objectId.getGuid()); } } }
@Test public void testDefaultValueForPrimitiveTypes() throws Exception { init(); EntityMutationResponse response = entityStore.createOrUpdate(new AtlasEntityStream(primitiveEntity), false); List<AtlasEntityHeader> entitiesCreatedResponse = response.getEntitiesByOperation(EntityOperation.CREATE); List<AtlasEntityHeader> entitiesCreatedwithdefault = response.getMutatedEntities().get(EntityOperation.CREATE); AtlasEntity entityCreated = getEntityFromStore(entitiesCreatedResponse.get(0)); Map attributesMap = entityCreated.getAttributes(); String description = (String) attributesMap.get("description"); String check = (String) attributesMap.get("check"); String sourceCode = (String) attributesMap.get("sourcecode"); float diskUsage = (float) attributesMap.get("diskUsage"); boolean isstoreUse = (boolean) attributesMap.get("isstoreUse"); int cost = (int) attributesMap.get("Cost"); assertEquals(description,"test"); assertEquals(check,"check"); //defaultValue assertEquals(diskUsage,70.5f); assertEquals(isstoreUse,true); assertEquals(sourceCode,"Hello World"); assertEquals(cost,30); }
@Test public void testDefaultValueForPrimitiveTypes() throws Exception { init(); EntityMutationResponse response = entityStore.createOrUpdate(new AtlasEntityStream(primitiveEntity), false); List<AtlasEntityHeader> entitiesCreatedResponse = response.getEntitiesByOperation(EntityOperation.CREATE); List<AtlasEntityHeader> entitiesCreatedwithdefault = response.getMutatedEntities().get(EntityOperation.CREATE); AtlasEntity entityCreated = getEntityFromStore(entitiesCreatedResponse.get(0)); Map attributesMap = entityCreated.getAttributes(); String description = (String) attributesMap.get("description"); String check = (String) attributesMap.get("check"); String sourceCode = (String) attributesMap.get("sourcecode"); float diskUsage = (float) attributesMap.get("diskUsage"); boolean isstoreUse = (boolean) attributesMap.get("isstoreUse"); int cost = (int) attributesMap.get("Cost"); assertEquals(description,"test"); assertEquals(check,"check"); //defaultValue assertEquals(diskUsage,70.5f); assertEquals(isstoreUse,true); assertEquals(sourceCode,"Hello World"); assertEquals(cost,30); }
fromV2ToV1(entityType, entity.getAttributes(), context));
final Map<String, Object> attributes = nifiFlowEntity.getAttributes(); final NiFiFlow nifiFlow = new NiFiFlow(rootProcessGroupId); nifiFlow.setExEntity(nifiFlowEntity);
fromV2ToV1(entityType, entity.getAttributes(), context), new AtlasSystemAttributes(entity.getCreatedBy(), entity.getUpdatedBy(), entity.getCreateTime(), entity.getUpdateTime()));
entity.getTypeName(), entity.getGuid(), auditSize, auditMaxSize); Map<String, Object> attrValues = entity.getAttributes(); Map<String, Object> relAttrValues = entity.getRelationshipAttributes();
entity.getTypeName(), entity.getGuid(), auditSize, auditMaxSize); Map<String, Object> attrValues = entity.getAttributes(); Map<String, Object> relAttrValues = entity.getRelationshipAttributes();
vertex = AtlasGraphUtilsV2.findByUniqueAttributes(entityType, entity.getAttributes()); } else if (!isAssignedGuid) { // for local-guids, entity must be in the stream throw new AtlasBaseException(AtlasErrorCode.REFERENCED_ENTITY_NOT_FOUND, guid);
vertex = AtlasGraphUtilsV2.findByUniqueAttributes(entityType, entity.getAttributes()); } else if (!isAssignedGuid) { // for local-guids, entity must be in the stream throw new AtlasBaseException(AtlasErrorCode.REFERENCED_ENTITY_NOT_FOUND, guid);