Java Code Examples for org.apache.atlas.model.typedef.AtlasBaseTypeDef#getArrayTypeName()

The following examples show how to use org.apache.atlas.model.typedef.AtlasBaseTypeDef#getArrayTypeName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestAtlasEntityType.java    From atlas with Apache License 2.0 6 votes vote down vote up
private AtlasEntityDef createTableEntityDefWithOptions() {
    AtlasEntityDef    table       = new AtlasEntityDef(TYPE_TABLE);
    AtlasAttributeDef attrName    = new AtlasAttributeDef(ATTR_NAME, AtlasBaseTypeDef.ATLAS_TYPE_STRING);
    AtlasAttributeDef attrColumns = new AtlasAttributeDef(ATTR_COLUMNS, AtlasBaseTypeDef.getArrayTypeName(TYPE_COLUMN));
    AtlasAttributeDef attrOwner   = new AtlasAttributeDef(ATTR_OWNER, AtlasBaseTypeDef.ATLAS_TYPE_STRING);

    attrColumns.addConstraint(new AtlasConstraintDef(AtlasConstraintDef.CONSTRAINT_TYPE_OWNED_REF));

    table.addAttribute(attrName);
    table.addAttribute(attrColumns);
    table.addAttribute(attrOwner);

    Map<String,String> options = new HashMap<>();
    String             key     = "dynAttribute:" + ATTR_OWNER;
    String             value   = "{" + ATTR_NAME + "}";

    options.put(key,value);

    table.setOptions(options);

    return table;
}
 
Example 2
Source File: AtlasArrayType.java    From atlas with Apache License 2.0 5 votes vote down vote up
public AtlasArrayType(AtlasType elementType, int minCount, int maxCount, Cardinality cardinality) {
    super(AtlasBaseTypeDef.getArrayTypeName(elementType.getTypeName()), TypeCategory.ARRAY, SERVICE_TYPE_ATLAS_CORE);

    this.elementTypeName = elementType.getTypeName();
    this.minCount        = minCount;
    this.maxCount        = maxCount;
    this.cardinality     = cardinality;
    this.elementType     = elementType;
}
 
Example 3
Source File: AtlasArrayType.java    From atlas with Apache License 2.0 5 votes vote down vote up
public AtlasArrayType(String elementTypeName, int minCount, int maxCount, Cardinality cardinality, AtlasTypeRegistry typeRegistry)
    throws  AtlasBaseException {
    super(AtlasBaseTypeDef.getArrayTypeName(elementTypeName), TypeCategory.ARRAY, SERVICE_TYPE_ATLAS_CORE);

    this.elementTypeName = elementTypeName;
    this.minCount        = minCount;
    this.maxCount        = maxCount;
    this.cardinality     = cardinality;

    this.resolveReferences(typeRegistry);
}
 
Example 4
Source File: TestAtlasEntityType.java    From atlas with Apache License 2.0 5 votes vote down vote up
private AtlasEntityDef createTableEntityDef() {
    AtlasEntityDef    table       = new AtlasEntityDef(TYPE_TABLE);
    AtlasAttributeDef attrName    = new AtlasAttributeDef(ATTR_NAME, AtlasBaseTypeDef.ATLAS_TYPE_STRING);
    AtlasAttributeDef attrColumns = new AtlasAttributeDef(ATTR_COLUMNS,
                                                          AtlasBaseTypeDef.getArrayTypeName(TYPE_COLUMN));

    attrColumns.addConstraint(new AtlasConstraintDef(AtlasConstraintDef.CONSTRAINT_TYPE_OWNED_REF));

    table.addAttribute(attrName);
    table.addAttribute(attrColumns);

    return table;
}
 
Example 5
Source File: AtlasArrayType.java    From incubator-atlas with Apache License 2.0 5 votes vote down vote up
public AtlasArrayType(AtlasType elementType, int minCount, int maxCount) {
    super(AtlasBaseTypeDef.getArrayTypeName(elementType.getTypeName()), TypeCategory.ARRAY);

    this.elementTypeName = elementType.getTypeName();
    this.minCount        = minCount;
    this.maxCount        = maxCount;
    this.elementType     = elementType;
}
 
Example 6
Source File: AtlasArrayType.java    From incubator-atlas with Apache License 2.0 5 votes vote down vote up
public AtlasArrayType(String elementTypeName, int minCount, int maxCount) {
    super(AtlasBaseTypeDef.getArrayTypeName(elementTypeName), TypeCategory.ARRAY);

    this.elementTypeName = elementTypeName;
    this.minCount        = minCount;
    this.maxCount        = maxCount;
    this.elementType     = null;
}
 
Example 7
Source File: AtlasArrayType.java    From incubator-atlas with Apache License 2.0 5 votes vote down vote up
public AtlasArrayType(String elementTypeName, int minCount, int maxCount, AtlasTypeRegistry typeRegistry)
    throws  AtlasBaseException {
    super(AtlasBaseTypeDef.getArrayTypeName(elementTypeName), TypeCategory.ARRAY);

    this.elementTypeName = elementTypeName;
    this.minCount        = minCount;
    this.maxCount        = maxCount;

    this.resolveReferences(typeRegistry);
}
 
Example 8
Source File: AtlasRelationshipType.java    From incubator-atlas with Apache License 2.0 5 votes vote down vote up
private void addRelationshipAttributeToEndType(AtlasRelationshipEndDef endDef, AtlasEntityType entityType, String attrTypeName,
                                               AtlasTypeRegistry typeRegistry, String relationshipLabel) throws AtlasBaseException {

    String attrName = (endDef != null) ? endDef.getName() : null;

    if (StringUtils.isEmpty(attrName)) {
        return;
    }

    AtlasAttribute attribute = entityType.getAttribute(attrName);

    // if relationshipLabel is null, then legacyLabel is mentioned at both ends,
    // use the respective end's legacyLabel as relationshipLabel
    if (relationshipLabel == null) {
        relationshipLabel = getLegacyEdgeLabel(entityType, attrName);
    }

    if (attribute == null) { //attr doesn't exist in type - is a new relationship attribute

        if (endDef.getCardinality() == Cardinality.SET) {
            attrTypeName = AtlasBaseTypeDef.getArrayTypeName(attrTypeName);
        }

        attribute = new AtlasAttribute(entityType, new AtlasAttributeDef(attrName, attrTypeName),
                                       typeRegistry.getType(attrTypeName), relationshipLabel);

    } else {
        // attribute already exists (legacy attribute which is also a relationship attribute)
        // add relationshipLabel information to existing attribute
        attribute.setRelationshipEdgeLabel(relationshipLabel);
    }

    entityType.addRelationshipAttribute(attrName, attribute);

    entityType.addRelationshipAttributeType(attrName, this);
}
 
Example 9
Source File: TestAtlasEntityType.java    From incubator-atlas with Apache License 2.0 5 votes vote down vote up
private AtlasEntityDef createTableEntityDef() {
    AtlasEntityDef    table       = new AtlasEntityDef(TYPE_TABLE);
    AtlasAttributeDef attrName    = new AtlasAttributeDef(ATTR_NAME, AtlasBaseTypeDef.ATLAS_TYPE_STRING);
    AtlasAttributeDef attrColumns = new AtlasAttributeDef(ATTR_COLUMNS,
                                                          AtlasBaseTypeDef.getArrayTypeName(TYPE_COLUMN));

    attrColumns.addConstraint(new AtlasConstraintDef(AtlasConstraintDef.CONSTRAINT_TYPE_OWNED_REF));

    table.addAttribute(attrName);
    table.addAttribute(attrColumns);

    return table;
}