Search in sources :

Example 1 with AtlasConstraintDef

use of org.apache.atlas.model.typedef.AtlasStructDef.AtlasConstraintDef in project incubator-atlas by apache.

the class TestAtlasEntityType method createColumnEntityDefWithInvalidInverseAttributeType.

private AtlasEntityDef createColumnEntityDefWithInvalidInverseAttributeType() {
    AtlasEntityDef column = new AtlasEntityDef(TYPE_COLUMN);
    AtlasAttributeDef attrTable = new AtlasAttributeDef(ATTR_TABLE, TYPE_TABLE);
    Map<String, Object> params = new HashMap<>();
    params.put(AtlasConstraintDef.CONSTRAINT_PARAM_ATTRIBUTE, ATTR_NAME);
    attrTable.addConstraint(new AtlasConstraintDef(AtlasConstraintDef.CONSTRAINT_TYPE_INVERSE_REF, params));
    column.addAttribute(attrTable);
    return column;
}
Also used : AtlasEntityDef(org.apache.atlas.model.typedef.AtlasEntityDef) HashMap(java.util.HashMap) AtlasAttributeDef(org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef) AtlasConstraintDef(org.apache.atlas.model.typedef.AtlasStructDef.AtlasConstraintDef)

Example 2 with AtlasConstraintDef

use of org.apache.atlas.model.typedef.AtlasStructDef.AtlasConstraintDef in project incubator-atlas by apache.

the class TestAtlasEntityType method createColumnEntityDef.

private AtlasEntityDef createColumnEntityDef() {
    AtlasEntityDef column = new AtlasEntityDef(TYPE_COLUMN);
    AtlasAttributeDef attrTable = new AtlasAttributeDef(ATTR_TABLE, TYPE_TABLE);
    Map<String, Object> params = new HashMap<>();
    params.put(AtlasConstraintDef.CONSTRAINT_PARAM_ATTRIBUTE, ATTR_COLUMNS);
    attrTable.addConstraint(new AtlasConstraintDef(AtlasConstraintDef.CONSTRAINT_TYPE_INVERSE_REF, params));
    column.addAttribute(attrTable);
    return column;
}
Also used : AtlasEntityDef(org.apache.atlas.model.typedef.AtlasEntityDef) HashMap(java.util.HashMap) AtlasAttributeDef(org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef) AtlasConstraintDef(org.apache.atlas.model.typedef.AtlasStructDef.AtlasConstraintDef)

Example 3 with AtlasConstraintDef

use of org.apache.atlas.model.typedef.AtlasStructDef.AtlasConstraintDef in project incubator-atlas by apache.

the class TestAtlasEntityType method createColumnEntityDefWithNonExistingInverseAttribute.

private AtlasEntityDef createColumnEntityDefWithNonExistingInverseAttribute() {
    AtlasEntityDef column = new AtlasEntityDef(TYPE_COLUMN);
    AtlasAttributeDef attrTable = new AtlasAttributeDef(ATTR_TABLE, TYPE_TABLE);
    Map<String, Object> params = new HashMap<>();
    params.put(AtlasConstraintDef.CONSTRAINT_PARAM_ATTRIBUTE, "non-existing:" + ATTR_COLUMNS);
    attrTable.addConstraint(new AtlasConstraintDef(AtlasConstraintDef.CONSTRAINT_TYPE_INVERSE_REF, params));
    column.addAttribute(attrTable);
    return column;
}
Also used : AtlasEntityDef(org.apache.atlas.model.typedef.AtlasEntityDef) HashMap(java.util.HashMap) AtlasAttributeDef(org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef) AtlasConstraintDef(org.apache.atlas.model.typedef.AtlasStructDef.AtlasConstraintDef)

Example 4 with AtlasConstraintDef

use of org.apache.atlas.model.typedef.AtlasStructDef.AtlasConstraintDef in project incubator-atlas by apache.

the class TypedefsJerseyResourceIT method createHiveTypesV2.

private AtlasTypesDef createHiveTypesV2() throws Exception {
    AtlasTypesDef atlasTypesDef = new AtlasTypesDef();
    AtlasEntityDef databaseTypeDefinition = createClassTypeDef("database", ImmutableSet.<String>of(), AtlasTypeUtil.createUniqueRequiredAttrDef("name", "string"), AtlasTypeUtil.createRequiredAttrDef("description", "string"));
    atlasTypesDef.getEntityDefs().add(databaseTypeDefinition);
    AtlasEntityDef tableTypeDefinition = createClassTypeDef("table", ImmutableSet.<String>of(), AtlasTypeUtil.createUniqueRequiredAttrDef("name", "string"), AtlasTypeUtil.createRequiredAttrDef("description", "string"), AtlasTypeUtil.createOptionalAttrDef("columnNames", DataTypes.arrayTypeName("string")), AtlasTypeUtil.createOptionalAttrDef("created", "date"), AtlasTypeUtil.createOptionalAttrDef("parameters", DataTypes.mapTypeName("string", "string")), AtlasTypeUtil.createRequiredAttrDef("type", "string"), new AtlasAttributeDef("database", "database", false, Cardinality.SINGLE, 1, 1, true, true, Collections.<AtlasConstraintDef>emptyList()));
    atlasTypesDef.getEntityDefs().add(tableTypeDefinition);
    AtlasClassificationDef fetlTypeDefinition = AtlasTypeUtil.createTraitTypeDef("fetl", ImmutableSet.<String>of(), AtlasTypeUtil.createRequiredAttrDef("level", "int"));
    atlasTypesDef.getClassificationDefs().add(fetlTypeDefinition);
    return atlasTypesDef;
}
Also used : AtlasClassificationDef(org.apache.atlas.model.typedef.AtlasClassificationDef) AtlasEntityDef(org.apache.atlas.model.typedef.AtlasEntityDef) AtlasAttributeDef(org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef) AtlasConstraintDef(org.apache.atlas.model.typedef.AtlasStructDef.AtlasConstraintDef) AtlasTypesDef(org.apache.atlas.model.typedef.AtlasTypesDef)

Example 5 with AtlasConstraintDef

use of org.apache.atlas.model.typedef.AtlasStructDef.AtlasConstraintDef in project incubator-atlas by apache.

the class AtlasTypeUtil method createRequiredAttrDefWithConstraint.

public static AtlasAttributeDef createRequiredAttrDefWithConstraint(String name, String typeName, String type, Map param) {
    AtlasAttributeDef ret = AtlasTypeUtil.createRequiredAttrDef(name, typeName);
    ret.addConstraint(new AtlasConstraintDef(type, param));
    return ret;
}
Also used : AtlasAttributeDef(org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef) AtlasConstraintDef(org.apache.atlas.model.typedef.AtlasStructDef.AtlasConstraintDef)

Aggregations

AtlasConstraintDef (org.apache.atlas.model.typedef.AtlasStructDef.AtlasConstraintDef)20 AtlasAttributeDef (org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef)19 AtlasEntityDef (org.apache.atlas.model.typedef.AtlasEntityDef)14 HashMap (java.util.HashMap)10 AtlasTypesDef (org.apache.atlas.model.typedef.AtlasTypesDef)6 AtlasClassificationDef (org.apache.atlas.model.typedef.AtlasClassificationDef)5 AtlasEnumDef (org.apache.atlas.model.typedef.AtlasEnumDef)5 AtlasStructDef (org.apache.atlas.model.typedef.AtlasStructDef)5 ArrayList (java.util.ArrayList)4 AtlasEnumElementDef (org.apache.atlas.model.typedef.AtlasEnumDef.AtlasEnumElementDef)4 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 Map (java.util.Map)1 Multiplicity (org.apache.atlas.typesystem.types.Multiplicity)1