congrats Icon
New! Announcing our next generation AI code completions
Read here
Tabnine Logo
AtlasRelationshipType
Code IndexAdd Tabnine to your IDE (free)

How to use
AtlasRelationshipType
in
org.apache.atlas.type

Best Java code snippets using org.apache.atlas.type.AtlasRelationshipType (Showing top 20 results out of 315)

origin: apache/atlas

private String getRelationshipEdgeLabel(String typeName, String relationshipTypeName) {
  AtlasRelationshipType relationshipType = typeRegistry.getRelationshipTypeByName(relationshipTypeName);
  AtlasRelationshipDef  relationshipDef  = relationshipType.getRelationshipDef();
  AtlasEntityType       end1Type         = relationshipType.getEnd1Type();
  AtlasEntityType       end2Type         = relationshipType.getEnd2Type();
  Set<String>           vertexTypes      = getTypeAndAllSuperTypes(typeName);
  AtlasAttribute        attribute        = null;
  if (vertexTypes.contains(end1Type.getTypeName())) {
    String attributeName = relationshipDef.getEndDef1().getName();
    attribute = (attributeName != null) ? end1Type.getAttribute(attributeName) : null;
  } else if (vertexTypes.contains(end2Type.getTypeName())) {
    String attributeName = relationshipDef.getEndDef2().getName();
    attribute = (attributeName != null) ? end2Type.getAttribute(attributeName) : null;
  }
  return (attribute != null) ? attribute.getRelationshipEdgeLabel() : null;
}
origin: apache/atlas

public static Map<String, TypeInfo> get(AtlasTypeRegistry typeRegistry) {
  Map<String, TypeInfo> ret = new HashMap<>();
  for (AtlasRelationshipType relType : typeRegistry.getAllRelationshipTypes()) {
    AtlasRelationshipDef relDef      = relType.getRelationshipDef();
    String               relTypeName = relType.getTypeName();
    add(ret, getKey(relDef.getEndDef1()), relTypeName, relDef.getPropagateTags());
    add(ret, getKey(relDef.getEndDef2()), relTypeName, getEnd2PropagateTag(relDef.getPropagateTags()));
  }
  return ret;
}
origin: apache/incubator-atlas

/**
 * Validate the fields in the the RelationshipType are consistent with respect to themselves.
 * @param type
 * @throws AtlasBaseException
 */
private boolean validateAtlasRelationshipType(AtlasRelationshipType type) {
  boolean isValid = false;
  try {
    validateAtlasRelationshipDef(type.getRelationshipDef());
    isValid = true;
  } catch (AtlasBaseException abe) {
    LOG.error("Validation error for AtlasRelationshipType", abe);
  }
  return isValid;
}
origin: apache/atlas

private void addRelationshipType(AtlasRelationshipType relationshipType, ExportService.ExportContext context) {
  if (!context.relationshipTypes.contains(relationshipType.getTypeName())) {
    context.relationshipTypes.add(relationshipType.getTypeName());
    addAttributeTypes(relationshipType, context);
    addEntityType(relationshipType.getEnd1Type(), context);
    addEntityType(relationshipType.getEnd2Type(), context);
  }
}
origin: apache/incubator-atlas

@Override
public void resolveReferencesPhase2(AtlasTypeRegistry typeRegistry) throws AtlasBaseException {
  super.resolveReferencesPhase2(typeRegistry);
  AtlasRelationshipEndDef endDef1           = relationshipDef.getEndDef1();
  AtlasRelationshipEndDef endDef2           = relationshipDef.getEndDef2();
  String                  relationshipLabel = null;
  // if legacyLabel is not specified at both ends, use relationshipDef name as relationship label.
  // if legacyLabel is specified in any one end, use it as the relationship label for both ends (legacy case).
  // if legacyLabel is specified at both ends use the respective end's legacyLabel as relationship label (legacy case).
  if (!endDef1.getIsLegacyAttribute() && !endDef2.getIsLegacyAttribute()) {
    relationshipLabel = relationshipDef.getRelationshipLabel();
  } else if (endDef1.getIsLegacyAttribute() && !endDef2.getIsLegacyAttribute()) {
    relationshipLabel = getLegacyEdgeLabel(end1Type, endDef1.getName());
  } else if (!endDef1.getIsLegacyAttribute() && endDef2.getIsLegacyAttribute()) {
    relationshipLabel = getLegacyEdgeLabel(end2Type, endDef2.getName());
  }
  addRelationshipAttributeToEndType(endDef1, end1Type, end2Type.getTypeName(), typeRegistry, relationshipLabel);
  addRelationshipAttributeToEndType(endDef2, end2Type, end1Type.getTypeName(), typeRegistry, relationshipLabel);
  // add relationship edge direction information
  addRelationshipEdgeDirection();
}
origin: org.apache.atlas/atlas-repository

public AtlasRelationshipDef getRelationshipDef(AtlasVertex entityVertex, AtlasEntityType entityType, String attributeName) {
  List<AtlasRelationshipType> relationshipTypes = entityType.getRelationshipAttributeType(attributeName);
  AtlasRelationshipDef        ret               = null;
  if (relationshipTypes.size() > 1) {
    Iterator<AtlasEdge> iter = entityVertex.getEdges(AtlasEdgeDirection.IN).iterator();
    while (iter.hasNext() && ret == null) {
      String edgeTypeName = AtlasGraphUtilsV2.getTypeName(iter.next());
      for (AtlasRelationshipType relationType : relationshipTypes) {
        AtlasRelationshipDef relationshipDef = relationType.getRelationshipDef();
        if (StringUtils.equals(edgeTypeName, relationshipDef.getName())) {
          ret = relationshipDef;
          break;
        }
      }
    }
    if (ret == null) {
      ret = relationshipTypes.get(0).getRelationshipDef();
    }
  } else {
    //relationshipTypes will have at least one relationshipDef
    ret = relationshipTypes.get(0).getRelationshipDef();
  }
  return ret;
}
origin: org.apache.atlas/atlas-intg

@Override
void resolveReferences(AtlasTypeRegistry typeRegistry) throws AtlasBaseException {
  super.resolveReferences(typeRegistry);
  if (relationshipDef == null) {
    throw new AtlasBaseException(AtlasErrorCode.INVALID_VALUE, "relationshipDef is null");
  }
  String end1TypeName = relationshipDef.getEndDef1() != null ? relationshipDef.getEndDef1().getType() : null;
  String end2TypeName = relationshipDef.getEndDef2() != null ? relationshipDef.getEndDef2().getType() : null;
  AtlasType type1 = typeRegistry.getType(end1TypeName);
  AtlasType type2 = typeRegistry.getType(end2TypeName);
  if (type1 instanceof AtlasEntityType) {
    end1Type = (AtlasEntityType) type1;
  } else {
    throw new AtlasBaseException(AtlasErrorCode.RELATIONSHIPDEF_INVALID_END_TYPE, getTypeName(), end1TypeName);
  }
  if (type2 instanceof AtlasEntityType) {
    end2Type = (AtlasEntityType) type2;
  } else {
    throw new AtlasBaseException(AtlasErrorCode.RELATIONSHIPDEF_INVALID_END_TYPE, getTypeName(), end2TypeName);
  }
  validateAtlasRelationshipDef(relationshipDef);
}
origin: org.apache.atlas/atlas-repository

private AtlasRelationship defineTermAssignment(String termGuid, AtlasRelatedObjectId relatedObjectId) {
  AtlasRelationshipType relationshipType = typeRegistry.getRelationshipTypeByName(TERM_ASSIGNMENT);
  AtlasStruct           defaultAttrs     = relationshipType.createDefaultValue();
  AtlasObjectId     end1         = new AtlasObjectId(termGuid);
  AtlasRelationship relationship = new AtlasRelationship(TERM_ASSIGNMENT, end1, relatedObjectId, defaultAttrs.getAttributes());
  updateRelationshipAttributes(relationship, relatedObjectId);
  return relationship;
}
origin: org.apache.atlas/atlas-intg

AtlasRelationshipDef relationshipDef1 = new AtlasRelationshipDef("emptyRelationshipDef", "desc 1", "version1",
    AtlasRelationshipDef.RelationshipCategory.ASSOCIATION, AtlasRelationshipDef.PropagateTags.ONE_TO_TWO, ep_single, ep_SET);
AtlasRelationshipType.validateAtlasRelationshipDef(relationshipDef1);
AtlasRelationshipDef relationshipDef2 = new AtlasRelationshipDef("emptyRelationshipDef", "desc 1", "version1",
    AtlasRelationshipDef.RelationshipCategory.COMPOSITION, AtlasRelationshipDef.PropagateTags.ONE_TO_TWO, ep_SET_container, ep_single);
AtlasRelationshipType.validateAtlasRelationshipDef(relationshipDef2);
AtlasRelationshipDef relationshipDef3 = new AtlasRelationshipDef("emptyRelationshipDef", "desc 1", "version1",
    AtlasRelationshipDef.RelationshipCategory.AGGREGATION, AtlasRelationshipDef.PropagateTags.ONE_TO_TWO, ep_SET_container, ep_single);
AtlasRelationshipType.validateAtlasRelationshipDef(relationshipDef3);
  AtlasRelationshipType.validateAtlasRelationshipDef(relationshipDef);
  fail("This call is expected to fail");
} catch (AtlasBaseException abe) {
  AtlasRelationshipDef relationshipDef = new AtlasRelationshipDef("emptyRelationshipDef", "desc 1", "version1",
      AtlasRelationshipDef.RelationshipCategory.COMPOSITION, AtlasRelationshipDef.PropagateTags.ONE_TO_TWO, ep_single, ep_single_container);
  AtlasRelationshipType.validateAtlasRelationshipDef(relationshipDef);
  fail("This call is expected to fail");
} catch (AtlasBaseException abe) {
  AtlasRelationshipDef relationshipDef = new AtlasRelationshipDef("emptyRelationshipDef", "desc 1", "version1",
      AtlasRelationshipDef.RelationshipCategory.AGGREGATION, AtlasRelationshipDef.PropagateTags.ONE_TO_TWO, ep_single, ep_single_container);
  AtlasRelationshipType.validateAtlasRelationshipDef(relationshipDef);
  fail("This call is expected to fail");
} catch (AtlasBaseException abe) {
  AtlasRelationshipDef relationshipDef = new AtlasRelationshipDef("emptyRelationshipDef", "desc 1", "version1",
      AtlasRelationshipDef.RelationshipCategory.COMPOSITION, AtlasRelationshipDef.PropagateTags.ONE_TO_TWO, ep_SET_container, ep_SET);
  AtlasRelationshipType.validateAtlasRelationshipDef(relationshipDef);
origin: org.apache.atlas/atlas-intg

AtlasRelationshipDef relationshipDef = (AtlasRelationshipDef) typeDef;
registryData.relationshipDefs.addType(relationshipDef, new AtlasRelationshipType(relationshipDef));
origin: apache/atlas

private PropagateTags getRelationshipTagPropagation(AtlasVertex fromVertex, AtlasVertex toVertex, AtlasRelationship relationship) {
  AtlasRelationshipType   relationshipType = typeRegistry.getRelationshipTypeByName(relationship.getTypeName());
  AtlasRelationshipEndDef endDef1          = relationshipType.getRelationshipDef().getEndDef1();
  AtlasRelationshipEndDef endDef2          = relationshipType.getRelationshipDef().getEndDef2();
  Set<String>             fromVertexTypes  = getTypeAndAllSuperTypes(getTypeName(fromVertex));
  Set<String>             toVertexTypes    = getTypeAndAllSuperTypes(getTypeName(toVertex));
  PropagateTags           ret              = relationshipType.getRelationshipDef().getPropagateTags();
  // relationshipDef is defined as end1 (hive_db) and end2 (hive_table) and tagPropagation = ONE_TO_TWO
  // relationship edge exists from [hive_table --> hive_db]
  // swap the tagPropagation property for such cases.
  if (fromVertexTypes.contains(endDef2.getType()) && toVertexTypes.contains(endDef1.getType())) {
    if (ret == ONE_TO_TWO) {
      ret = TWO_TO_ONE;
    } else if (ret == TWO_TO_ONE) {
      ret = ONE_TO_TWO;
    }
  }
  return ret;
}
origin: apache/incubator-atlas

@Override
public void resolveReferences(AtlasTypeRegistry typeRegistry) throws AtlasBaseException {
  super.resolveReferences(typeRegistry);
  if (relationshipDef == null) {
    throw new AtlasBaseException(AtlasErrorCode.INVALID_VALUE, "relationshipDef is null");
  }
  String end1TypeName = relationshipDef.getEndDef1() != null ? relationshipDef.getEndDef1().getType() : null;
  String end2TypeName = relationshipDef.getEndDef2() != null ? relationshipDef.getEndDef2().getType() : null;
  AtlasType type1 = typeRegistry.getType(end1TypeName);
  AtlasType type2 = typeRegistry.getType(end2TypeName);
  if (type1 instanceof AtlasEntityType) {
    end1Type = (AtlasEntityType) type1;
  } else {
    throw new AtlasBaseException(AtlasErrorCode.RELATIONSHIPDEF_INVALID_END_TYPE, getTypeName(), end1TypeName);
  }
  if (type2 instanceof AtlasEntityType) {
    end2Type = (AtlasEntityType) type2;
  } else {
    throw new AtlasBaseException(AtlasErrorCode.RELATIONSHIPDEF_INVALID_END_TYPE, getTypeName(), end2TypeName);
  }
  validateAtlasRelationshipDef(this.relationshipDef);
}
origin: org.apache.atlas/atlas-intg

@Override
void resolveReferencesPhase2(AtlasTypeRegistry typeRegistry) throws AtlasBaseException {
  super.resolveReferencesPhase2(typeRegistry);
  AtlasRelationshipEndDef endDef1           = relationshipDef.getEndDef1();
  AtlasRelationshipEndDef endDef2           = relationshipDef.getEndDef2();
  String                  relationshipLabel = null;
  // if legacyLabel is not specified at both ends, use relationshipDef name as relationship label.
  // if legacyLabel is specified in any one end, use it as the relationship label for both ends (legacy case).
  // if legacyLabel is specified at both ends use the respective end's legacyLabel as relationship label (legacy case).
  if (!endDef1.getIsLegacyAttribute() && !endDef2.getIsLegacyAttribute()) {
    relationshipLabel = relationshipDef.getRelationshipLabel();
  } else if (endDef1.getIsLegacyAttribute() && !endDef2.getIsLegacyAttribute()) {
    relationshipLabel = getLegacyEdgeLabel(end1Type, endDef1.getName());
  } else if (!endDef1.getIsLegacyAttribute() && endDef2.getIsLegacyAttribute()) {
    relationshipLabel = getLegacyEdgeLabel(end2Type, endDef2.getName());
  }
  addRelationshipAttributeToEndType(endDef1, end1Type, end2Type.getTypeName(), typeRegistry, relationshipLabel);
  addRelationshipAttributeToEndType(endDef2, end2Type, end1Type.getTypeName(), typeRegistry, relationshipLabel);
  // add relationship edge direction information
  addRelationshipEdgeDirection();
}
origin: apache/atlas

private AtlasRelationship defineTermAssignment(String termGuid, AtlasRelatedObjectId relatedObjectId) {
  AtlasRelationshipType relationshipType = typeRegistry.getRelationshipTypeByName(TERM_ASSIGNMENT);
  AtlasStruct           defaultAttrs     = relationshipType.createDefaultValue();
  AtlasObjectId     end1         = new AtlasObjectId(termGuid);
  AtlasRelationship relationship = new AtlasRelationship(TERM_ASSIGNMENT, end1, relatedObjectId, defaultAttrs.getAttributes());
  updateRelationshipAttributes(relationship, relatedObjectId);
  return relationship;
}
origin: apache/incubator-atlas

AtlasRelationshipDef relationshipDef1 = new AtlasRelationshipDef("emptyRelationshipDef", "desc 1", "version1",
    AtlasRelationshipDef.RelationshipCategory.ASSOCIATION, AtlasRelationshipDef.PropagateTags.ONE_TO_TWO, ep_single, ep_SET);
AtlasRelationshipType.validateAtlasRelationshipDef(relationshipDef1);
AtlasRelationshipDef relationshipDef2 = new AtlasRelationshipDef("emptyRelationshipDef", "desc 1", "version1",
    AtlasRelationshipDef.RelationshipCategory.COMPOSITION, AtlasRelationshipDef.PropagateTags.ONE_TO_TWO, ep_SET_container, ep_single);
AtlasRelationshipType.validateAtlasRelationshipDef(relationshipDef2);
AtlasRelationshipDef relationshipDef3 = new AtlasRelationshipDef("emptyRelationshipDef", "desc 1", "version1",
    AtlasRelationshipDef.RelationshipCategory.AGGREGATION, AtlasRelationshipDef.PropagateTags.ONE_TO_TWO, ep_SET_container, ep_single);
AtlasRelationshipType.validateAtlasRelationshipDef(relationshipDef3);
  AtlasRelationshipType.validateAtlasRelationshipDef(relationshipDef);
  fail("This call is expected to fail");
} catch (AtlasBaseException abe) {
  AtlasRelationshipDef relationshipDef = new AtlasRelationshipDef("emptyRelationshipDef", "desc 1", "version1",
      AtlasRelationshipDef.RelationshipCategory.COMPOSITION, AtlasRelationshipDef.PropagateTags.ONE_TO_TWO, ep_single, ep_single_container);
  AtlasRelationshipType.validateAtlasRelationshipDef(relationshipDef);
  fail("This call is expected to fail");
} catch (AtlasBaseException abe) {
  AtlasRelationshipDef relationshipDef = new AtlasRelationshipDef("emptyRelationshipDef", "desc 1", "version1",
      AtlasRelationshipDef.RelationshipCategory.AGGREGATION, AtlasRelationshipDef.PropagateTags.ONE_TO_TWO, ep_single, ep_single_container);
  AtlasRelationshipType.validateAtlasRelationshipDef(relationshipDef);
  fail("This call is expected to fail");
} catch (AtlasBaseException abe) {
  AtlasRelationshipDef relationshipDef = new AtlasRelationshipDef("emptyRelationshipDef", "desc 1", "version1",
      AtlasRelationshipDef.RelationshipCategory.COMPOSITION, AtlasRelationshipDef.PropagateTags.ONE_TO_TWO, ep_SET_container, ep_SET);
  AtlasRelationshipType.validateAtlasRelationshipDef(relationshipDef);
origin: apache/incubator-atlas

AtlasRelationshipDef relationshipDef = (AtlasRelationshipDef) typeDef;
registryData.relationshipDefs.addType(relationshipDef, new AtlasRelationshipType(relationshipDef));
origin: org.apache.atlas/atlas-repository

  private String getRelationshipEdgeLabel(String typeName, String relationshipTypeName) {
    AtlasRelationshipType relationshipType = typeRegistry.getRelationshipTypeByName(relationshipTypeName);
    AtlasRelationshipDef  relationshipDef  = relationshipType.getRelationshipDef();
    AtlasEntityType       end1Type         = relationshipType.getEnd1Type();
    AtlasEntityType       end2Type         = relationshipType.getEnd2Type();
    Set<String>           vertexTypes      = getTypeAndAllSuperTypes(typeName);
    AtlasAttribute        attribute        = null;

    if (vertexTypes.contains(end1Type.getTypeName())) {
      String attributeName = relationshipDef.getEndDef1().getName();

      attribute = (attributeName != null) ? end1Type.getAttribute(attributeName) : null;
    } else if (vertexTypes.contains(end2Type.getTypeName())) {
      String attributeName = relationshipDef.getEndDef2().getName();

      attribute = (attributeName != null) ? end2Type.getAttribute(attributeName) : null;
    }

    return (attribute != null) ? attribute.getRelationshipEdgeLabel() : null;
  }
}
origin: org.apache.atlas/atlas-repository

private PropagateTags getRelationshipTagPropagation(AtlasVertex fromVertex, AtlasVertex toVertex, AtlasRelationship relationship) {
  AtlasRelationshipType   relationshipType = typeRegistry.getRelationshipTypeByName(relationship.getTypeName());
  AtlasRelationshipEndDef endDef1          = relationshipType.getRelationshipDef().getEndDef1();
  AtlasRelationshipEndDef endDef2          = relationshipType.getRelationshipDef().getEndDef2();
  Set<String>             fromVertexTypes  = getTypeAndAllSuperTypes(getTypeName(fromVertex));
  Set<String>             toVertexTypes    = getTypeAndAllSuperTypes(getTypeName(toVertex));
  PropagateTags           ret              = relationshipType.getRelationshipDef().getPropagateTags();
  // relationshipDef is defined as end1 (hive_db) and end2 (hive_table) and tagPropagation = ONE_TO_TWO
  // relationship edge exists from [hive_table --> hive_db]
  // swap the tagPropagation property for such cases.
  if (fromVertexTypes.contains(endDef2.getType()) && toVertexTypes.contains(endDef1.getType())) {
    if (ret == ONE_TO_TWO) {
      ret = TWO_TO_ONE;
    } else if (ret == TWO_TO_ONE) {
      ret = ONE_TO_TWO;
    }
  }
  return ret;
}
origin: apache/atlas

private AtlasRelationship defineCategoryAnchorRelation(String glossaryGuid, String categoryGuid) {
  AtlasRelationshipType relationshipType = typeRegistry.getRelationshipTypeByName(CATEGORY_ANCHOR);
  AtlasStruct           defaultAttrs     = relationshipType.createDefaultValue();
  return new AtlasRelationship(CATEGORY_ANCHOR, new AtlasObjectId(glossaryGuid), new AtlasObjectId(categoryGuid), defaultAttrs.getAttributes());
}
origin: apache/incubator-atlas

registryData.relationshipDefs.addType(relationshipDef, new AtlasRelationshipType(relationshipDef));
org.apache.atlas.typeAtlasRelationshipType

Javadoc

class that implements behaviour of an relationship-type.

Most used methods

  • getRelationshipDef
  • getTypeName
  • validateAtlasRelationshipDef
    Throw an exception so we can junit easily. This method assumes that the 2 ends are not null.
  • <init>
  • addRelationshipAttributeToEndType
  • addRelationshipEdgeDirection
  • createDefaultValue
  • getAllAttributes
  • getEnd1Type
  • getEnd2Type
  • getLegacyEdgeLabel
  • getNormalizedValue
  • getLegacyEdgeLabel,
  • getNormalizedValue,
  • getRelationshipFromValue,
  • hasLegacyAttributeEnd,
  • resolveReferences,
  • validateAtlasRelationshipType,
  • validateRelationship,
  • validateValue

Popular in Java

  • Reading from database using SQL prepared statement
  • startActivity (Activity)
  • getSystemService (Context)
  • onRequestPermissionsResult (Fragment)
  • Color (java.awt)
    The Color class is used to encapsulate colors in the default sRGB color space or colors in arbitrary
  • Charset (java.nio.charset)
    A charset is a named mapping between Unicode characters and byte sequences. Every Charset can decode
  • Collections (java.util)
    This class consists exclusively of static methods that operate on or return collections. It contains
  • Iterator (java.util)
    An iterator over a sequence of objects, such as a collection.If a collection has been changed since
  • Manifest (java.util.jar)
    The Manifest class is used to obtain attribute information for a JarFile and its entries.
  • Option (scala)
  • Top plugins for WebStorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now