private void visitRelationships(AtlasEntityType entityType, AtlasEntity entity, List<String> visitedAttributes) throws AtlasBaseException { for (AtlasAttribute attribute : entityType.getRelationshipAttributes().values()) { AtlasType attrType = attribute.getAttributeType(); String attrName = attribute.getName(); Object attrVal = entity.getRelationshipAttribute(attrName); if (entity.hasRelationshipAttribute(attrName)) { visitAttribute(attrType, attrVal); visitedAttributes.add(attrName); } } }
@Override public void resolveReferencesPhase3(AtlasTypeRegistry typeRegistry) throws AtlasBaseException { for (AtlasAttributeDef attributeDef : getStructDef().getAttributeDefs()) { String attributeName = attributeDef.getName(); AtlasType attributeType = typeRegistry.getType(attributeDef.getTypeName()); AtlasEntityType attributeEntityType = getReferencedEntityType(attributeType); // validate if RelationshipDefs is defined for all entityDefs if (attributeEntityType != null && !hasRelationshipAttribute(attributeName)) { LOG.warn("No RelationshipDef defined between {} and {} on attribute: {}.{}", getTypeName(), attributeEntityType.getTypeName(), getTypeName(), attributeName); } } for (String superTypeName : allSuperTypes) { AtlasEntityType superType = typeRegistry.getEntityTypeByName(superTypeName); Map<String, AtlasAttribute> superTypeRelationshipAttributes = superType.getRelationshipAttributes(); if (MapUtils.isNotEmpty(superTypeRelationshipAttributes)) { relationshipAttributes.putAll(superTypeRelationshipAttributes); } Map<String, List<AtlasRelationshipType>> superTypeRelationshipAttributesType = superType.getRelationshipAttributesType(); if (MapUtils.isNotEmpty(superTypeRelationshipAttributesType)) { relationshipAttributesType.putAll(superTypeRelationshipAttributesType); } } allSubTypes = Collections.unmodifiableSet(allSubTypes); typeAndAllSubTypes = Collections.unmodifiableSet(typeAndAllSubTypes); typeAndAllSubTypesQryStr = ""; // will be computed on next access relationshipAttributes = Collections.unmodifiableMap(relationshipAttributes); relationshipAttributesType = Collections.unmodifiableMap(relationshipAttributesType); }
private void visitRelationships(AtlasEntityType entityType, AtlasEntity entity, List<String> visitedAttributes) throws AtlasBaseException { for (AtlasAttribute attribute : entityType.getRelationshipAttributes().values()) { AtlasType attrType = attribute.getAttributeType(); String attrName = attribute.getName(); Object attrVal = entity.getRelationshipAttribute(attrName); if (entity.hasRelationshipAttribute(attrName)) { visitAttribute(attrType, attrVal); visitedAttributes.add(attrName); } } }
Map<String, AtlasAttribute> superTypeRelationshipAttributes = superType.getRelationshipAttributes();
private Map<String, AtlasAttribute> getRelationAttrsForType(String typeName) { return typeRegistry.getEntityTypeByName(typeName).getRelationshipAttributes(); }
private Map<String, AtlasAttribute> getRelationAttrsForType(String typeName) { return typeRegistry.getEntityTypeByName(typeName).getRelationshipAttributes(); }
private void mapRelationshipAttributes(AtlasVertex entityVertex, AtlasEntity entity) throws AtlasBaseException { AtlasEntityType entityType = typeRegistry.getEntityTypeByName(entity.getTypeName()); if (entityType == null) { throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_INVALID, entity.getTypeName()); } for (AtlasAttribute attribute : entityType.getRelationshipAttributes().values()) { Object attrValue = mapVertexToRelationshipAttribute(entityVertex, entityType, attribute); entity.setRelationshipAttribute(attribute.getName(), attrValue); } }
private void mapRelationshipAttributes(AtlasVertex entityVertex, AtlasEntity entity) throws AtlasBaseException { AtlasEntityType entityType = typeRegistry.getEntityTypeByName(entity.getTypeName()); if (entityType == null) { throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_INVALID, entity.getTypeName()); } for (AtlasAttribute attribute : entityType.getRelationshipAttributes().values()) { Object attrValue = mapVertexToRelationshipAttribute(entityVertex, entityType, attribute); entity.setRelationshipAttribute(attribute.getName(), attrValue); } }
private void mapRelationshipAttributes(AtlasEntity entity, AtlasVertex vertex, EntityOperation op, EntityMutationContext context) throws AtlasBaseException { if (LOG.isDebugEnabled()) { LOG.debug("==> mapRelationshipAttributes({}, {})", op, entity.getTypeName()); } if (MapUtils.isNotEmpty(entity.getRelationshipAttributes())) { AtlasEntityType entityType = getEntityType(entity.getTypeName()); if (op.equals(CREATE)) { for (AtlasAttribute attribute : entityType.getRelationshipAttributes().values()) { Object attrValue = entity.getRelationshipAttribute(attribute.getName()); mapAttribute(attribute, attrValue, vertex, op, context); } } else if (op.equals(UPDATE)) { // relationship attributes mapping for (AtlasAttribute attribute : entityType.getRelationshipAttributes().values()) { if (attribute != null && entity.hasRelationshipAttribute(attribute.getName())) { Object attrValue = entity.getRelationshipAttribute(attribute.getName()); mapAttribute(attribute, attrValue, vertex, op, context); } } } updateModificationMetadata(vertex); } if (LOG.isDebugEnabled()) { LOG.debug("<== mapRelationshipAttributes({}, {})", op, entity.getTypeName()); } }
private void mapRelationshipAttributes(AtlasEntity entity, AtlasVertex vertex, EntityOperation op, EntityMutationContext context) throws AtlasBaseException { if (LOG.isDebugEnabled()) { LOG.debug("==> mapRelationshipAttributes({}, {})", op, entity.getTypeName()); } if (MapUtils.isNotEmpty(entity.getRelationshipAttributes())) { MetricRecorder metric = RequestContext.get().startMetricRecord("mapRelationshipAttributes"); AtlasEntityType entityType = getEntityType(entity.getTypeName()); if (op.equals(CREATE)) { for (AtlasAttribute attribute : entityType.getRelationshipAttributes().values()) { Object attrValue = entity.getRelationshipAttribute(attribute.getName()); mapAttribute(attribute, attrValue, vertex, op, context); } } else if (op.equals(UPDATE)) { // relationship attributes mapping for (AtlasAttribute attribute : entityType.getRelationshipAttributes().values()) { if (attribute != null && entity.hasRelationshipAttribute(attribute.getName())) { Object attrValue = entity.getRelationshipAttribute(attribute.getName()); mapAttribute(attribute, attrValue, vertex, op, context); } } } updateModificationMetadata(vertex); RequestContext.get().endMetricRecord(metric); } if (LOG.isDebugEnabled()) { LOG.debug("<== mapRelationshipAttributes({}, {})", op, entity.getTypeName()); } }