private void validateAndNormalize(AtlasRelationship relationship) throws AtlasBaseException { List<String> messages = new ArrayList<>(); if (! AtlasTypeUtil.isValidGuid(relationship.getGuid())) { throw new AtlasBaseException(AtlasErrorCode.RELATIONSHIP_GUID_NOT_FOUND, relationship.getGuid()); } AtlasRelationshipType type = typeRegistry.getRelationshipTypeByName(relationship.getTypeName()); if (type == null) { throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_INVALID, TypeCategory.RELATIONSHIP.name(), relationship.getTypeName()); } type.validateValue(relationship, relationship.getTypeName(), messages); if (!messages.isEmpty()) { throw new AtlasBaseException(AtlasErrorCode.RELATIONSHIP_CRUD_INVALID_PARAMS, messages); } type.getNormalizedValue(relationship); }
private void validateAndNormalize(AtlasRelationship relationship) throws AtlasBaseException { List<String> messages = new ArrayList<>(); if (! AtlasTypeUtil.isValidGuid(relationship.getGuid())) { throw new AtlasBaseException(AtlasErrorCode.RELATIONSHIP_GUID_NOT_FOUND, relationship.getGuid()); } AtlasRelationshipType type = typeRegistry.getRelationshipTypeByName(relationship.getTypeName()); if (type == null) { throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_INVALID, TypeCategory.RELATIONSHIP.name(), relationship.getTypeName()); } type.validateValue(relationship, relationship.getTypeName(), messages); if (!messages.isEmpty()) { throw new AtlasBaseException(AtlasErrorCode.RELATIONSHIP_CRUD_INVALID_PARAMS, messages); } type.getNormalizedValue(relationship); }
@Override public boolean areEqualValues(Object val1, Object val2) { final boolean ret; if (val1 == null) { ret = val2 == null; } else if (val2 == null) { ret = false; } else { AtlasRelationship rel1 = getRelationshipFromValue(val1); if (rel1 == null) { ret = false; } else { AtlasRelationship rel2 = getRelationshipFromValue(val2); if (rel2 == null) { ret = false; } else if (!super.areEqualValues(rel1, rel2)) { ret = false; } else { ret = Objects.equals(rel1.getGuid(), rel2.getGuid()) && Objects.equals(rel1.getEnd1(), rel2.getEnd1()) && Objects.equals(rel1.getEnd2(), rel2.getEnd2()) && Objects.equals(rel1.getLabel(), rel2.getLabel()) && Objects.equals(rel1.getPropagateTags(), rel2.getPropagateTags()) && Objects.equals(rel1.getStatus(), rel2.getStatus()); } } } return ret; }
public AtlasRelationshipHeader(AtlasRelationship relationship) { this(relationship.getTypeName(), relationship.getGuid(), relationship.getEnd1(), relationship.getEnd2()); setLabel(relationship.getLabel()); switch (relationship.getStatus()) { case ACTIVE: setStatus(AtlasEntity.Status.ACTIVE); break; case DELETED: setStatus(AtlasEntity.Status.DELETED); break; } }
} else { relationshipStore.deleteById(parentRelationship.getGuid(), true); createRelationship(defineCategoryHierarchyLink(newParent, storeObject.getGuid()));
} else { relationshipStore.deleteById(parentRelationship.getGuid(), true); createRelationship(defineCategoryHierarchyLink(newParent, storeObject.getGuid()));
private AtlasEdge createRelationshipEdge(AtlasVertex fromVertex, AtlasVertex toVertex, AtlasRelationship relationship) throws RepositoryException, AtlasBaseException { String relationshipLabel = getRelationshipEdgeLabel(fromVertex, toVertex, relationship.getTypeName()); PropagateTags tagPropagation = getRelationshipTagPropagation(fromVertex, toVertex, relationship); AtlasEdge ret = graphHelper.getOrCreateEdge(fromVertex, toVertex, relationshipLabel); if (LOG.isDebugEnabled()) { LOG.debug("Created relationship edge from [{}] --> [{}] using edge label: [{}]", getTypeName(fromVertex), getTypeName(toVertex), relationshipLabel); } // map additional properties to relationship edge if (ret != null) { // Accept a valid (assigned) guid from the supplied relationship, or generate one. String relationshipGuid = relationship.getGuid(); final String guid = AtlasTypeUtil.isAssignedGuid(relationshipGuid) ? relationshipGuid : UUID.randomUUID().toString(); AtlasGraphUtilsV2.setEncodedProperty(ret, ENTITY_TYPE_PROPERTY_KEY, relationship.getTypeName()); AtlasGraphUtilsV2.setEncodedProperty(ret, RELATIONSHIP_GUID_PROPERTY_KEY, guid); AtlasGraphUtilsV2.setEncodedProperty(ret, VERSION_PROPERTY_KEY, getRelationshipVersion(relationship)); AtlasGraphUtilsV2.setEncodedProperty(ret, RELATIONSHIPTYPE_TAG_PROPAGATION_KEY, tagPropagation.name()); // blocked propagated classifications handleBlockedClassifications(ret, relationship.getBlockedPropagatedClassifications()); // propagate tags deleteHandler.addTagPropagation(ret, tagPropagation); } 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 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; }
String guid = relationship.getGuid();
String guid = relationship.getGuid();
String relationshipGuid = relationship.getGuid(); PropagateTags tagPropagation = getRelationshipTagPropagation(end1Vertex, end2Vertex, relationship); final String guid = AtlasTypeUtil.isAssignedGuid(relationshipGuid) ? relationshipGuid : UUID.randomUUID().toString();