use of org.apache.atlas.type.AtlasType in project atlas by apache.
the class AtlasEntityGraphDiscoveryV1 method visitRelationships.
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);
}
}
}
use of org.apache.atlas.type.AtlasType in project atlas by apache.
the class AtlasEntityGraphDiscoveryV1 method visitStruct.
void visitStruct(AtlasStructType structType, AtlasStruct struct) throws AtlasBaseException {
for (AtlasAttribute attribute : structType.getAllAttributes().values()) {
AtlasType attrType = attribute.getAttributeType();
Object attrVal = struct.getAttribute(attribute.getName());
visitAttribute(attrType, attrVal);
}
}
use of org.apache.atlas.type.AtlasType in project atlas by apache.
the class AtlasEntityGraphDiscoveryV1 method visitEntity.
void visitEntity(AtlasEntityType entityType, AtlasEntity entity) throws AtlasBaseException {
List<String> visitedAttributes = new ArrayList<>();
// visit relationship attributes
if (!(this.discoveryContext.getEntityStream() instanceof EntityImportStream)) {
visitRelationships(entityType, entity, visitedAttributes);
}
// visit struct attributes
for (AtlasAttribute attribute : entityType.getAllAttributes().values()) {
AtlasType attrType = attribute.getAttributeType();
String attrName = attribute.getName();
Object attrVal = entity.getAttribute(attrName);
if (entity.hasAttribute(attrName) && !visitedAttributes.contains(attrName)) {
visitAttribute(attrType, attrVal);
}
}
}
use of org.apache.atlas.type.AtlasType in project atlas by apache.
the class AtlasRelationshipDefStoreV1 method updateByGuid.
@Override
public AtlasRelationshipDef updateByGuid(String guid, AtlasRelationshipDef relationshipDef) throws AtlasBaseException {
if (LOG.isDebugEnabled()) {
LOG.debug("==> AtlasRelationshipDefStoreV1.updateByGuid({})", guid);
}
AtlasRelationshipDef existingDef = typeRegistry.getRelationshipDefByGuid(guid);
AtlasAuthorizationUtils.verifyAccess(new AtlasTypeAccessRequest(AtlasPrivilege.TYPE_UPDATE, existingDef), "update relationship-Def ", (existingDef != null ? existingDef.getName() : guid));
validateType(relationshipDef);
AtlasType type = typeRegistry.getTypeByGuid(guid);
if (type.getTypeCategory() != org.apache.atlas.model.TypeCategory.RELATIONSHIP) {
throw new AtlasBaseException(AtlasErrorCode.TYPE_MATCH_FAILED, relationshipDef.getName(), TypeCategory.RELATIONSHIP.name());
}
AtlasVertex vertex = typeDefStore.findTypeVertexByGuidAndCategory(guid, TypeCategory.RELATIONSHIP);
if (vertex == null) {
throw new AtlasBaseException(AtlasErrorCode.TYPE_GUID_NOT_FOUND, guid);
}
preUpdateCheck(relationshipDef, (AtlasRelationshipType) type, vertex);
// updates should not effect the edges between the types as we do not allow updates that change the endpoints.
AtlasRelationshipDef ret = toRelationshipDef(vertex);
if (LOG.isDebugEnabled()) {
LOG.debug("<== AtlasRelationshipDefStoreV1.updateByGuid({}): {}", guid, ret);
}
return ret;
}
use of org.apache.atlas.type.AtlasType in project atlas by apache.
the class AtlasEntityDefStoreV1 method updateByName.
@Override
public AtlasEntityDef updateByName(String name, AtlasEntityDef entityDef) throws AtlasBaseException {
if (LOG.isDebugEnabled()) {
LOG.debug("==> AtlasEntityDefStoreV1.updateByName({}, {})", name, entityDef);
}
AtlasEntityDef existingDef = typeRegistry.getEntityDefByName(name);
AtlasAuthorizationUtils.verifyAccess(new AtlasTypeAccessRequest(AtlasPrivilege.TYPE_UPDATE, existingDef), "update entity-def ", name);
validateType(entityDef);
AtlasType type = typeRegistry.getType(entityDef.getName());
if (type.getTypeCategory() != org.apache.atlas.model.TypeCategory.ENTITY) {
throw new AtlasBaseException(AtlasErrorCode.TYPE_MATCH_FAILED, entityDef.getName(), TypeCategory.CLASS.name());
}
AtlasVertex vertex = typeDefStore.findTypeVertexByNameAndCategory(name, TypeCategory.CLASS);
if (vertex == null) {
throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_NOT_FOUND, name);
}
updateVertexPreUpdate(entityDef, (AtlasEntityType) type, vertex);
updateVertexAddReferences(entityDef, vertex);
AtlasEntityDef ret = toEntityDef(vertex);
if (LOG.isDebugEnabled()) {
LOG.debug("<== AtlasEntityDefStoreV1.updateByName({}, {}): {}", name, entityDef, ret);
}
return ret;
}
Aggregations