Search in sources :

Example 1 with AtlasBusinessMetadataDef

use of org.apache.atlas.model.typedef.AtlasBusinessMetadataDef in project atlas by apache.

the class TypeDefExample method createBusinessMetadataDefs.

private List<AtlasBusinessMetadataDef> createBusinessMetadataDefs() {
    String description = "description";
    Map<String, String> options = new HashMap<>();
    options.put("maxStrLength", "20");
    options.put("applicableEntityTypes", "[\"" + SampleAppConstants.DATABASE_TYPE + "\",\"" + SampleAppConstants.TABLE_TYPE + "\"]");
    AtlasBusinessMetadataDef bmWithAllTypes = createBusinessMetadataDef(SampleAppConstants.BUSINESS_METADATA_TYPE, description, "1.0", createOptionalAttrDef(ATTR_ATTR1, ATLAS_TYPE_BOOLEAN, options, description), createOptionalAttrDef(ATTR_ATTR2, ATLAS_TYPE_BYTE, options, description), createOptionalAttrDef(ATTR_ATTR8, ATLAS_TYPE_STRING, options, description));
    AtlasBusinessMetadataDef bmWithAllTypesMV = createBusinessMetadataDef(SampleAppConstants.BUSINESS_METADATA_TYPE_MV, description, "1.0", createOptionalAttrDef(ATTR_ATTR11, "array<boolean>", options, description), createOptionalAttrDef(ATTR_ATTR18, "array<string>", options, description));
    return Arrays.asList(bmWithAllTypes, bmWithAllTypesMV);
}
Also used : HashMap(java.util.HashMap) AtlasBusinessMetadataDef(org.apache.atlas.model.typedef.AtlasBusinessMetadataDef)

Example 2 with AtlasBusinessMetadataDef

use of org.apache.atlas.model.typedef.AtlasBusinessMetadataDef in project atlas by apache.

the class TypeDefExample method createTypeDefinitions.

public void createTypeDefinitions() throws Exception {
    AtlasEntityDef databaseDef = createDatabaseDef();
    AtlasEntityDef tableDef = createTableDef();
    AtlasEntityDef columnDef = createColumnDef();
    AtlasEntityDef processDef = createProcessDef();
    AtlasStructDef serDeDef = createSerDeDef();
    AtlasEnumDef tableTypeDef = createTableTypeEnumDef();
    List<AtlasClassificationDef> classificationDefs = createClassificationDefs();
    List<AtlasBusinessMetadataDef> businessMetadataDef = createBusinessMetadataDefs();
    List<AtlasRelationshipDef> relationshipDefs = createAtlasRelationshipDef();
    AtlasTypesDef typesDef = new AtlasTypesDef(Collections.singletonList(tableTypeDef), Collections.singletonList(serDeDef), classificationDefs, Arrays.asList(databaseDef, tableDef, columnDef, processDef), relationshipDefs, businessMetadataDef);
    this.typesDef = batchCreateTypes(typesDef);
}
Also used : AtlasStructDef(org.apache.atlas.model.typedef.AtlasStructDef) AtlasClassificationDef(org.apache.atlas.model.typedef.AtlasClassificationDef) AtlasEntityDef(org.apache.atlas.model.typedef.AtlasEntityDef) AtlasRelationshipDef(org.apache.atlas.model.typedef.AtlasRelationshipDef) AtlasBusinessMetadataDef(org.apache.atlas.model.typedef.AtlasBusinessMetadataDef) AtlasEnumDef(org.apache.atlas.model.typedef.AtlasEnumDef) AtlasTypesDef(org.apache.atlas.model.typedef.AtlasTypesDef)

Example 3 with AtlasBusinessMetadataDef

use of org.apache.atlas.model.typedef.AtlasBusinessMetadataDef in project atlas by apache.

the class ExportService method processTypesDef.

private void processTypesDef(ExportContext context) {
    AtlasTypesDef typesDef = context.result.getData().getTypesDef();
    for (String entityType : context.entityTypes) {
        AtlasEntityDef entityDef = typeRegistry.getEntityDefByName(entityType);
        typesDef.getEntityDefs().add(entityDef);
    }
    for (String classificationType : context.classificationTypes) {
        AtlasClassificationDef classificationDef = typeRegistry.getClassificationDefByName(classificationType);
        typesDef.getClassificationDefs().add(classificationDef);
    }
    for (String structType : context.structTypes) {
        AtlasStructDef structDef = typeRegistry.getStructDefByName(structType);
        typesDef.getStructDefs().add(structDef);
    }
    for (String enumType : context.enumTypes) {
        AtlasEnumDef enumDef = typeRegistry.getEnumDefByName(enumType);
        typesDef.getEnumDefs().add(enumDef);
    }
    for (String relationshipType : context.relationshipTypes) {
        AtlasRelationshipDef relationshipDef = typeRegistry.getRelationshipDefByName(relationshipType);
        typesDef.getRelationshipDefs().add(relationshipDef);
    }
    for (String bm : context.businessMetadataTypes) {
        AtlasBusinessMetadataDef bmDef = typeRegistry.getBusinessMetadataDefByName(bm);
        typesDef.getBusinessMetadataDefs().add(bmDef);
    }
}
Also used : AtlasClassificationDef(org.apache.atlas.model.typedef.AtlasClassificationDef) AtlasStructDef(org.apache.atlas.model.typedef.AtlasStructDef) AtlasEntityDef(org.apache.atlas.model.typedef.AtlasEntityDef) AtlasRelationshipDef(org.apache.atlas.model.typedef.AtlasRelationshipDef) AtlasBusinessMetadataDef(org.apache.atlas.model.typedef.AtlasBusinessMetadataDef) AtlasEnumDef(org.apache.atlas.model.typedef.AtlasEnumDef) AtlasTypesDef(org.apache.atlas.model.typedef.AtlasTypesDef)

Example 4 with AtlasBusinessMetadataDef

use of org.apache.atlas.model.typedef.AtlasBusinessMetadataDef in project atlas by apache.

the class TestUtilsV2 method defineBusinessMetadataTypes.

public static AtlasTypesDef defineBusinessMetadataTypes() {
    String _description = "_description";
    Map<String, String> options = new HashMap<>();
    options.put("maxStrLength", "20");
    AtlasBusinessMetadataDef bmNoApplicableTypes = createBusinessMetadataDef("bmNoApplicableTypes", _description, "1.0", createOptionalAttrDef("attr0", "string", options, _description));
    AtlasBusinessMetadataDef bmNoAttributes = createBusinessMetadataDef("bmNoAttributes", _description, "1.0", null);
    options.put("applicableEntityTypes", "[\"" + DATABASE_TYPE + "\",\"" + TABLE_TYPE + "\"]");
    AtlasBusinessMetadataDef bmWithAllTypes = createBusinessMetadataDef("bmWithAllTypes", _description, "1.0", createOptionalAttrDef("attr1", AtlasBusinessMetadataDef.ATLAS_TYPE_BOOLEAN, options, _description), createOptionalAttrDef("attr2", AtlasBusinessMetadataDef.ATLAS_TYPE_BYTE, options, _description), createOptionalAttrDef("attr3", AtlasBusinessMetadataDef.ATLAS_TYPE_SHORT, options, _description), createOptionalAttrDef("attr4", AtlasBusinessMetadataDef.ATLAS_TYPE_INT, options, _description), createOptionalAttrDef("attr5", AtlasBusinessMetadataDef.ATLAS_TYPE_LONG, options, _description), createOptionalAttrDef("attr6", AtlasBusinessMetadataDef.ATLAS_TYPE_FLOAT, options, _description), createOptionalAttrDef("attr7", AtlasBusinessMetadataDef.ATLAS_TYPE_DOUBLE, options, _description), createOptionalAttrDef("attr8", AtlasBusinessMetadataDef.ATLAS_TYPE_STRING, options, _description), createOptionalAttrDef("attr9", AtlasBusinessMetadataDef.ATLAS_TYPE_DATE, options, _description), createOptionalAttrDef("attr10", "ENUM_1", options, _description));
    AtlasBusinessMetadataDef bmWithAllTypesMV = createBusinessMetadataDef("bmWithAllTypesMV", _description, "1.0", createOptionalAttrDef("attr11", "array<boolean>", options, _description), createOptionalAttrDef("attr12", "array<byte>", options, _description), createOptionalAttrDef("attr13", "array<short>", options, _description), createOptionalAttrDef("attr14", "array<int>", options, _description), createOptionalAttrDef("attr15", "array<long>", options, _description), createOptionalAttrDef("attr16", "array<float>", options, _description), createOptionalAttrDef("attr17", "array<double>", options, _description), createOptionalAttrDef("attr18", "array<string>", options, _description), createOptionalAttrDef("attr19", "array<date>", options, _description), createOptionalAttrDef("attr20", "array<ENUM_1>", options, _description));
    options.put("applicableEntityTypes", "[\"" + SUPER_TYPE_NAME + "\"]");
    AtlasBusinessMetadataDef bmWithSuperType = createBusinessMetadataDef("bmWithSuperType", _description, "1.0", createOptionalAttrDef("attrSuperBoolean", AtlasBusinessMetadataDef.ATLAS_TYPE_BOOLEAN, options, _description), createOptionalAttrDef("attrSuperString", AtlasBusinessMetadataDef.ATLAS_TYPE_STRING, options, _description));
    AtlasTypesDef ret = AtlasTypeUtil.getTypesDef(new ArrayList<>(), new ArrayList<>(), new ArrayList<>(), new ArrayList<>(), new ArrayList<>(), Arrays.asList(bmNoApplicableTypes, bmNoAttributes, bmWithAllTypes, bmWithAllTypesMV, bmWithSuperType));
    populateSystemAttributes(ret);
    return ret;
}
Also used : HashMap(java.util.HashMap) AtlasBusinessMetadataDef(org.apache.atlas.model.typedef.AtlasBusinessMetadataDef) AtlasTypesDef(org.apache.atlas.model.typedef.AtlasTypesDef)

Example 5 with AtlasBusinessMetadataDef

use of org.apache.atlas.model.typedef.AtlasBusinessMetadataDef in project atlas by apache.

the class AtlasBusinessMetadataDefStoreV2 method getByName.

@Override
public AtlasBusinessMetadataDef getByName(String name) throws AtlasBaseException {
    if (LOG.isDebugEnabled()) {
        LOG.debug("==> AtlasBusinessMetadataDefStoreV2.getByName({})", name);
    }
    AtlasVertex vertex = typeDefStore.findTypeVertexByNameAndCategory(name, DataTypes.TypeCategory.BUSINESS_METADATA);
    if (vertex == null) {
        throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_NOT_FOUND, name);
    }
    vertex.getProperty(Constants.TYPE_CATEGORY_PROPERTY_KEY, String.class);
    AtlasBusinessMetadataDef ret = toBusinessMetadataDef(vertex);
    if (LOG.isDebugEnabled()) {
        LOG.debug("<== AtlasBusinessMetadataDefStoreV2.getByName({}): {}", name, ret);
    }
    return ret;
}
Also used : AtlasBaseException(org.apache.atlas.exception.AtlasBaseException) AtlasVertex(org.apache.atlas.repository.graphdb.AtlasVertex) AtlasBusinessMetadataDef(org.apache.atlas.model.typedef.AtlasBusinessMetadataDef)

Aggregations

AtlasBusinessMetadataDef (org.apache.atlas.model.typedef.AtlasBusinessMetadataDef)38 AtlasBaseException (org.apache.atlas.exception.AtlasBaseException)14 AtlasTypesDef (org.apache.atlas.model.typedef.AtlasTypesDef)14 AtlasStructDef (org.apache.atlas.model.typedef.AtlasStructDef)13 Test (org.testng.annotations.Test)9 AtlasClassificationDef (org.apache.atlas.model.typedef.AtlasClassificationDef)7 AtlasEntityDef (org.apache.atlas.model.typedef.AtlasEntityDef)7 AtlasVertex (org.apache.atlas.repository.graphdb.AtlasVertex)7 AtlasEnumDef (org.apache.atlas.model.typedef.AtlasEnumDef)6 AtlasRelationshipDef (org.apache.atlas.model.typedef.AtlasRelationshipDef)6 AtlasTypeAccessRequest (org.apache.atlas.authorize.AtlasTypeAccessRequest)4 HashMap (java.util.HashMap)3 GET (javax.ws.rs.GET)2 Path (javax.ws.rs.Path)2 Timed (org.apache.atlas.annotation.Timed)2 AtlasAttributeDef (org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef)2 AtlasBusinessMetadataType (org.apache.atlas.type.AtlasBusinessMetadataType)2 AtlasStructType (org.apache.atlas.type.AtlasStructType)2 AtlasType (org.apache.atlas.type.AtlasType)2 Set (java.util.Set)1