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 AtlasGlossaryHeader constructGlossaryId(AtlasRelatedObjectId relatedObjectId) { AtlasGlossaryHeader ret = new AtlasGlossaryHeader(); ret.setGlossaryGuid(relatedObjectId.getGuid()); ret.setRelationGuid(relatedObjectId.getRelationshipGuid()); return ret; }
public AtlasRelatedObjectId(String guid, String typeName, AtlasEntity.Status entityStatus, Map<String, Object> uniqueAttributes, String displayText, String relationshipGuid, AtlasRelationship.Status relationshipStatus, AtlasStruct relationshipAttributes) { super(guid, typeName, uniqueAttributes); setEntityStatus(entityStatus); setRelationshipGuid(relationshipGuid); setRelationshipStatus(relationshipStatus); setDisplayText(displayText); setRelationshipAttributes(relationshipAttributes); }
protected AtlasRelatedObjectId glossaryIdToRelatedObjectId(AtlasGlossaryHeader glossaryId) { AtlasRelatedObjectId ret = new AtlasRelatedObjectId(); ret.setGuid(glossaryId.getGlossaryGuid()); ret.setRelationshipGuid(glossaryId.getRelationGuid()); return ret; }
EntityMutationResponse response = entityStore.createOrUpdate(new AtlasEntityStream(assetEntity), false); AtlasEntityHeader firstEntityCreated = response.getFirstEntityCreated(); relatedObjectId = new AtlasRelatedObjectId(); relatedObjectId.setGuid(firstEntityCreated.getGuid()); relatedObjectId.setTypeName(firstEntityCreated.getTypeName()); assertNotNull(relatedObjectId); } catch (AtlasBaseException e) { assertNotNull(assignedEntities); assertEquals(assignedEntities.size(), 1); String relationshipGuid = assignedEntities.get(0).getRelationshipGuid(); assertNotNull(relationshipGuid); relatedObjectId.setRelationshipGuid(relationshipGuid); } catch (AtlasBaseException e) { fail("Term fetch should've succeeded",e); entityStore.deleteById(relatedObjectId.getGuid()); } catch (AtlasBaseException e) { fail("Entity delete should've succeeded");
protected AtlasRelatedCategoryHeader constructRelatedCategoryId(AtlasRelatedObjectId relatedObjectId) { AtlasRelatedCategoryHeader ret = new AtlasRelatedCategoryHeader(); ret.setCategoryGuid(relatedObjectId.getGuid()); ret.setRelationGuid(relatedObjectId.getRelationshipGuid()); AtlasStruct relationshipAttributes = relatedObjectId.getRelationshipAttributes(); if (relationshipAttributes != null) { ret.setDescription((String) relationshipAttributes.getAttribute("description")); } return ret; }
protected static AtlasObjectId toAtlasObjectId(Object object) { if (object instanceof AtlasRelatedObjectId) { AtlasRelatedObjectId relatedObjectId = (AtlasRelatedObjectId) object; return new AtlasObjectId(relatedObjectId.getGuid(), relatedObjectId.getTypeName(), relatedObjectId.getUniqueAttributes()); } return null; }
private List<Referenceable> toReferenceables(List<AtlasRelatedObjectId> entityIds) throws AtlasBaseException { List<Referenceable> ret = new ArrayList<>(); if (CollectionUtils.isNotEmpty(entityIds)) { for (AtlasRelatedObjectId relatedObjectId : entityIds) { String entityGuid = relatedObjectId.getGuid(); ret.add(toReferenceable(entityGuid)); } } return ret; }
private AtlasRelatedObjectId mapVertexToRelatedObjectId(AtlasVertex entityVertex, AtlasEdge edge) throws AtlasBaseException { AtlasRelatedObjectId ret = null; if (GraphHelper.elementExists(edge)) { AtlasVertex referenceVertex = edge.getInVertex(); if (StringUtils.equals(getIdFromVertex(referenceVertex), getIdFromVertex(entityVertex))) { referenceVertex = edge.getOutVertex(); } if (referenceVertex != null) { String entityTypeName = getTypeName(referenceVertex); String entityGuid = getGuid(referenceVertex); AtlasEntity.Status entityStatus = GraphHelper.getStatus(referenceVertex); AtlasRelationship relationship = mapEdgeToAtlasRelationship(edge); ret = new AtlasRelatedObjectId(entityGuid, entityTypeName, entityStatus, relationship.getGuid(), relationship.getStatus(), new AtlasStruct(relationship.getTypeName(), relationship.getAttributes())); Object displayText = getDisplayText(referenceVertex, entityTypeName); if (displayText != null) { ret.setDisplayText(displayText.toString()); } } } return ret; }
private boolean isRelationshipGuidSame(AtlasRelatedObjectId storeObject, AtlasRelatedObjectId relatedObjectId) { return StringUtils.equals(relatedObjectId.getRelationshipGuid(), storeObject.getRelationshipGuid()); }
private void updateRelationshipAttributes(AtlasRelationship relationship, AtlasRelatedObjectId relatedObjectId) { AtlasStruct relationshipAttributes = relatedObjectId.getRelationshipAttributes(); if (Objects.nonNull(relationshipAttributes)) { for (Map.Entry<String, Object> attrEntry : relationshipAttributes.getAttributes().entrySet()) { relationship.setAttribute(attrEntry.getKey(), attrEntry.getValue()); } } }
@GraphTransaction public List<AtlasRelatedObjectId> getAssignedEntities(final String termGuid, int offset, int limit, SortOrder sortOrder) throws AtlasBaseException { if (Objects.isNull(termGuid)) { throw new AtlasBaseException(AtlasErrorCode.BAD_REQUEST, "termGuid is null/empty"); } AtlasGlossaryTerm glossaryTerm = dataAccess.load(getAtlasGlossaryTermSkeleton(termGuid)); Set<AtlasRelatedObjectId> assignedEntities = glossaryTerm.getAssignedEntities(); List<AtlasRelatedObjectId> ret; if (CollectionUtils.isNotEmpty(assignedEntities)) { ret = new ArrayList<>(assignedEntities); if (sortOrder != null) { ret.sort((o1, o2) -> sortOrder == SortOrder.ASCENDING ? o1.getDisplayText().compareTo(o2.getDisplayText()) : o2.getDisplayText().compareTo(o1.getDisplayText())); } ret = new PaginationHelper<>(assignedEntities, offset, limit).getPaginatedList(); } else { ret = Collections.emptyList(); } return ret; }
EntityMutationResponse response = entityStore.createOrUpdate(new AtlasEntityStream(assetEntity), false); AtlasEntityHeader firstEntityCreated = response.getFirstEntityCreated(); relatedObjectId = new AtlasRelatedObjectId(); relatedObjectId.setGuid(firstEntityCreated.getGuid()); relatedObjectId.setTypeName(firstEntityCreated.getTypeName()); assertNotNull(relatedObjectId); } catch (AtlasBaseException e) { assertNotNull(assignedEntities); assertEquals(assignedEntities.size(), 1); String relationshipGuid = assignedEntities.get(0).getRelationshipGuid(); assertNotNull(relationshipGuid); relatedObjectId.setRelationshipGuid(relationshipGuid); } catch (AtlasBaseException e) { fail("Term fetch should've succeeded",e); entityStore.deleteById(relatedObjectId.getGuid()); } catch (AtlasBaseException e) { fail("Entity delete should've succeeded");
protected AtlasRelatedCategoryHeader constructRelatedCategoryId(AtlasRelatedObjectId relatedObjectId) { AtlasRelatedCategoryHeader ret = new AtlasRelatedCategoryHeader(); ret.setCategoryGuid(relatedObjectId.getGuid()); ret.setRelationGuid(relatedObjectId.getRelationshipGuid()); AtlasStruct relationshipAttributes = relatedObjectId.getRelationshipAttributes(); if (relationshipAttributes != null) { ret.setDescription((String) relationshipAttributes.getAttribute("description")); } return ret; }
protected AtlasRelatedObjectId glossaryIdToRelatedObjectId(AtlasGlossaryHeader glossaryId) { AtlasRelatedObjectId ret = new AtlasRelatedObjectId(); ret.setGuid(glossaryId.getGlossaryGuid()); ret.setRelationshipGuid(glossaryId.getRelationGuid()); return ret; }
protected static AtlasObjectId toAtlasObjectId(Object object) { if (object instanceof AtlasRelatedObjectId) { AtlasRelatedObjectId relatedObjectId = (AtlasRelatedObjectId) object; return new AtlasObjectId(relatedObjectId.getGuid(), relatedObjectId.getTypeName(), relatedObjectId.getUniqueAttributes()); } return null; }
private List<Referenceable> toReferenceables(List<AtlasRelatedObjectId> entityIds) throws AtlasBaseException { List<Referenceable> ret = new ArrayList<>(); if (CollectionUtils.isNotEmpty(entityIds)) { for (AtlasRelatedObjectId relatedObjectId : entityIds) { String entityGuid = relatedObjectId.getGuid(); ret.add(toReferenceable(entityGuid)); } } return ret; }
private AtlasRelatedObjectId mapVertexToRelatedObjectId(AtlasVertex entityVertex, AtlasEdge edge) throws AtlasBaseException { AtlasRelatedObjectId ret = null; if (GraphHelper.elementExists(edge)) { AtlasVertex referenceVertex = edge.getInVertex(); if (StringUtils.equals(getIdFromVertex(referenceVertex), getIdFromVertex(entityVertex))) { referenceVertex = edge.getOutVertex(); } if (referenceVertex != null) { String entityTypeName = getTypeName(referenceVertex); String entityGuid = getGuid(referenceVertex); AtlasEntity.Status entityStatus = GraphHelper.getStatus(referenceVertex); AtlasRelationship relationship = mapEdgeToAtlasRelationship(edge); ret = new AtlasRelatedObjectId(entityGuid, entityTypeName, entityStatus, relationship.getGuid(), relationship.getStatus(), new AtlasStruct(relationship.getTypeName(), relationship.getAttributes())); Object displayText = getDisplayText(referenceVertex, entityTypeName); if (displayText != null) { ret.setDisplayText(displayText.toString()); } } } return ret; }
private boolean isRelationshipGuidSame(AtlasRelatedObjectId storeObject, AtlasRelatedObjectId relatedObjectId) { return StringUtils.equals(relatedObjectId.getRelationshipGuid(), storeObject.getRelationshipGuid()); }
private void updateRelationshipAttributes(AtlasRelationship relationship, AtlasRelatedObjectId relatedObjectId) { AtlasStruct relationshipAttributes = relatedObjectId.getRelationshipAttributes(); if (Objects.nonNull(relationshipAttributes)) { for (Map.Entry<String, Object> attrEntry : relationshipAttributes.getAttributes().entrySet()) { relationship.setAttribute(attrEntry.getKey(), attrEntry.getValue()); } } }