org.apache.http.annotation.Experimental#org.apache.atlas.model.typedef.AtlasTypesDef源码实例Demo

下面列出了org.apache.http.annotation.Experimental#org.apache.atlas.model.typedef.AtlasTypesDef 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: atlas   文件: TypesREST.java
/**
 * Bulk create APIs for all atlas type definitions, only new definitions will be created.
 * Any changes to the existing definitions will be discarded
 * @param typesDef A composite wrapper object with corresponding lists of the type definition
 * @return A composite wrapper object with lists of type definitions that were successfully
 * created
 * @throws Exception
 * @HTTP 200 On successful update of requested type definitions
 * @HTTP 400 On validation failure for any type definitions
 */
@POST
@Path("/typedefs")
public AtlasTypesDef createAtlasTypeDefs(final AtlasTypesDef typesDef) throws AtlasBaseException {
    AtlasPerfTracer perf = null;

    try {
        if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
            perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "TypesREST.createAtlasTypeDefs(" +
                                                           AtlasTypeUtil.toDebugString(typesDef) + ")");
        }

        return typeDefStore.createTypesDef(typesDef);
    } finally {
        AtlasPerfTracer.log(perf);
    }
}
 
源代码2 项目: atlas   文件: TypesREST.java
/**
 * Bulk delete API for all types
 * @param typesDef A composite object that captures all types to be deleted
 * @throws Exception
 * @HTTP 204 On successful deletion of the requested type definitions
 * @HTTP 400 On validation failure for any type definitions
 */
@DELETE
@Path("/typedefs")
@Experimental
public void deleteAtlasTypeDefs(final AtlasTypesDef typesDef) throws AtlasBaseException {
    AtlasPerfTracer perf = null;

    try {
        if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
            perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "TypesREST.deleteAtlasTypeDefs(" +
                                                           AtlasTypeUtil.toDebugString(typesDef) + ")");
        }



        typeDefStore.deleteTypesDef(typesDef);
    } finally {
        AtlasPerfTracer.log(perf);
    }
}
 
源代码3 项目: atlas   文件: TestUtilsV2.java
public static AtlasTypesDef simpleTypeUpdated(){
    AtlasEntityDef superTypeDefinition =
            createClassTypeDef("h_type", Collections.<String>emptySet(),
                    createOptionalAttrDef("attr", "string"));

    AtlasEntityDef newSuperTypeDefinition =
            createClassTypeDef("new_h_type", Collections.<String>emptySet(),
                    createOptionalAttrDef("attr", "string"));

    AtlasStructDef structTypeDefinition = new AtlasStructDef("s_type", "structType", "1.0",
            Arrays.asList(createRequiredAttrDef("name", "string")));

    AtlasClassificationDef traitTypeDefinition =
            AtlasTypeUtil.createTraitTypeDef("t_type", "traitType", Collections.<String>emptySet());

    AtlasEnumDef enumTypeDefinition = new AtlasEnumDef("e_type", "enumType",
            Arrays.asList(new AtlasEnumElementDef("ONE", "Element Description", 1)));
    AtlasTypesDef ret = AtlasTypeUtil.getTypesDef(Collections.singletonList(enumTypeDefinition), Collections.singletonList(structTypeDefinition),
            Collections.singletonList(traitTypeDefinition), Arrays.asList(superTypeDefinition, newSuperTypeDefinition));

    populateSystemAttributes(ret);

    return ret;
}
 
源代码4 项目: atlas   文件: EntityV2JerseyResourceIT.java
@Test(dependsOnMethods = "testSubmitEntity")
public void testGetTraitDefinitionForEntity() throws Exception{
    traitName = "PII_Trait" + randomString();
    AtlasClassificationDef piiTrait =
            AtlasTypeUtil.createTraitTypeDef(traitName, Collections.<String>emptySet());
    AtlasTypesDef typesDef = new AtlasTypesDef();
    typesDef.getClassificationDefs().add(piiTrait);
    createType(typesDef);

    AtlasClassificationDef classificationByName = atlasClientV2.getClassificationDefByName(traitName);
    assertNotNull(classificationByName);

    AtlasEntity hiveTable = createHiveTable();
    assertEquals(hiveTable.getClassifications().size(), 7);

    AtlasClassification piiClassification = new AtlasClassification(piiTrait.getName());

    atlasClientV2.addClassifications(hiveTable.getGuid(), Lists.newArrayList(piiClassification));

    AtlasClassifications classifications = atlasClientV2.getClassifications(hiveTable.getGuid());
    assertNotNull(classifications);
    assertTrue(classifications.getList().size() > 0);
    assertEquals(classifications.getList().size(), 8);
}
 
源代码5 项目: incubator-atlas   文件: AtlasTypeRegistry.java
public void addTypes(AtlasTypesDef typesDef) throws AtlasBaseException {
    if (LOG.isDebugEnabled()) {
        LOG.debug("==> AtlasTypeRegistry.addTypes({})", typesDef);
    }

    if (typesDef != null) {
        addTypesWithNoRefResolve(typesDef.getEnumDefs());
        addTypesWithNoRefResolve(typesDef.getStructDefs());
        addTypesWithNoRefResolve(typesDef.getClassificationDefs());
        addTypesWithNoRefResolve(typesDef.getEntityDefs());
        addTypesWithNoRefResolve(typesDef.getRelationshipDefs());

        resolveReferences();
    }

    if (LOG.isDebugEnabled()) {
        LOG.debug("<== AtlasTypeRegistry.addTypes({})", typesDef);
    }
}
 
源代码6 项目: atlas   文件: EntityV2JerseyResourceIT.java
@Test(dependsOnMethods = "testSubmitEntity")
public void testDeleteExistentTraitNonExistentForEntity() throws Exception {

    final String guid = createHiveTable().getGuid();
    final String traitName = "PII_Trait" + randomString();
    AtlasClassificationDef piiTrait = AtlasTypeUtil
            .createTraitTypeDef(traitName, Collections.<String>emptySet(),
                    AtlasTypeUtil.createRequiredAttrDef("type", "string"));
    AtlasTypesDef typesDef = new AtlasTypesDef();
    typesDef.getClassificationDefs().add(piiTrait);
    createType(typesDef);

    try {
        atlasClientV2.deleteClassification(guid, traitName);
        fail("Deletion should've failed for non-existent trait association");
    } catch (AtlasServiceException ex) {
        Assert.assertNotNull(ex.getStatus());
        assertEquals(ex.getStatus(), ClientResponse.Status.BAD_REQUEST);
    }
}
 
源代码7 项目: atlas   文件: EntityV2JerseyResourceIT.java
@Test
public void testUTF8() throws Exception {
    String classType = randomString();
    String attrName = randomUTF8();
    String attrValue = randomUTF8();

    AtlasEntityDef classTypeDef = AtlasTypeUtil
            .createClassTypeDef(classType, Collections.<String>emptySet(),
                    AtlasTypeUtil.createUniqueRequiredAttrDef(attrName, "string"));
    AtlasTypesDef atlasTypesDef = new AtlasTypesDef();
    atlasTypesDef.getEntityDefs().add(classTypeDef);
    createType(atlasTypesDef);

    AtlasEntity instance = new AtlasEntity(classType);
    instance.setAttribute(attrName, attrValue);
    AtlasEntityHeader entity = createEntity(instance);
    assertNotNull(entity);
    assertNotNull(entity.getGuid());

    AtlasEntity entityByGuid = getEntityByGuid(entity.getGuid());
    assertEquals(entityByGuid.getAttribute(attrName), attrValue);
}
 
源代码8 项目: atlas   文件: TypedefsJerseyResourceIT.java
@Test
public void testDuplicateCreate() throws Exception {
    AtlasEntityDef type = createClassTypeDef(randomString(),
            Collections.<String>emptySet(), AtlasTypeUtil.createUniqueRequiredAttrDef("name", "string"));
    AtlasTypesDef typesDef = new AtlasTypesDef();
    typesDef.getEntityDefs().add(type);

    AtlasTypesDef created = clientV2.createAtlasTypeDefs(typesDef);
    assertNotNull(created);

    try {
        created = clientV2.createAtlasTypeDefs(typesDef);
        fail("Expected 409");
    } catch (AtlasServiceException e) {
        assertEquals(e.getStatus().getStatusCode(), Response.Status.CONFLICT.getStatusCode());
    }
}
 
@BeforeClass
public void setUp() throws Exception {
    new GraphBackedSearchIndexer(typeRegistry);

    // create employee relationship types
    AtlasTypesDef employeeTypes = getDepartmentEmployeeTypes();
    typeDefStore.createTypesDef(employeeTypes);

    AtlasEntitiesWithExtInfo employeeInstances = getDepartmentEmployeeInstances();
    EntityMutationResponse response = entityStore.createOrUpdate(new AtlasEntityStream(employeeInstances), false);

    for (AtlasEntityHeader entityHeader : response.getCreatedEntities()) {
        employeeNameIdMap.put((String) entityHeader.getAttribute(NAME), getAtlasObjectId(entityHeader));
    }

    init();
    AtlasTypesDef testTypes = getInverseReferenceTestTypes();
    typeDefStore.createTypesDef(testTypes);
}
 
源代码10 项目: atlas   文件: TestUtilsV2.java
public static AtlasTypesDef simpleType(){
    AtlasEntityDef superTypeDefinition =
            createClassTypeDef("h_type", Collections.<String>emptySet(),
                    createOptionalAttrDef("attr", "string"));

    AtlasStructDef structTypeDefinition = new AtlasStructDef("s_type", "structType", "1.0",
            Arrays.asList(createRequiredAttrDef("name", "string")));

    AtlasClassificationDef traitTypeDefinition =
            AtlasTypeUtil.createTraitTypeDef("t_type", "traitType", Collections.<String>emptySet());

    AtlasEnumDef enumTypeDefinition = new AtlasEnumDef("e_type", "enumType", "1.0",
            Arrays.asList(new AtlasEnumElementDef("ONE", "Element Description", 1)));

    AtlasTypesDef ret = AtlasTypeUtil.getTypesDef(Collections.singletonList(enumTypeDefinition), Collections.singletonList(structTypeDefinition),
            Collections.singletonList(traitTypeDefinition), Collections.singletonList(superTypeDefinition));

    populateSystemAttributes(ret);

    return ret;
}
 
源代码11 项目: incubator-atlas   文件: EntityV2JerseyResourceIT.java
@Test(dependsOnMethods = "testSubmitEntity")
public void testGetTraitDefinitionForEntity() throws Exception{
    traitName = "PII_Trait" + randomString();
    AtlasClassificationDef piiTrait =
            AtlasTypeUtil.createTraitTypeDef(traitName, ImmutableSet.<String>of());
    AtlasTypesDef typesDef = new AtlasTypesDef();
    typesDef.getClassificationDefs().add(piiTrait);
    createType(typesDef);

    AtlasClassificationDef classificationByName = atlasClientV2.getClassificationDefByName(traitName);
    assertNotNull(classificationByName);

    AtlasEntity hiveTable = createHiveTable();
    assertEquals(hiveTable.getClassifications().size(), 7);

    AtlasClassification piiClassification = new AtlasClassification(piiTrait.getName());

    atlasClientV2.addClassifications(hiveTable.getGuid(), Lists.newArrayList(piiClassification));

    AtlasClassifications classifications = atlasClientV2.getClassifications(hiveTable.getGuid());
    assertNotNull(classifications);
    assertTrue(classifications.getList().size() > 0);
    assertEquals(classifications.getList().size(), 8);
}
 
源代码12 项目: atlas   文件: TypesDefScrubberTest.java
@Test
public void performScrub() {
    TypesDefScrubber typesDefScrubber = new TypesDefScrubber();
    AtlasTypesDef td = getTypesDefFromFile(LEGACY_TYPESDEF_JSON);

    int traitPrayIndex = 1;
    int vendorPIIIndex = 2;
    int financeIndex = 3;

    int classificationTraitPrayIndex = 0;
    int classificationVendorPiiIndex = 2;
    int classificationFinancendex = 3;

    String expectedTraitPrayStructName = TypesDefScrubber.getLegacyTypeNameForStructDef(td.getClassificationDefs().get(classificationTraitPrayIndex).getName());
    String expectedVendorPIIStructName = TypesDefScrubber.getLegacyTypeNameForStructDef(td.getClassificationDefs().get(classificationVendorPiiIndex).getName());
    String expectedFinanceStructName = TypesDefScrubber.getLegacyTypeNameForStructDef(td.getClassificationDefs().get(classificationFinancendex).getName());

    assertNewTypesDef(typesDefScrubber.scrub(td), traitPrayIndex, vendorPIIIndex, financeIndex, expectedTraitPrayStructName, expectedVendorPIIStructName, expectedFinanceStructName);

    assertTraitMap(typesDefScrubber, td, classificationTraitPrayIndex, expectedTraitPrayStructName, 0);
    assertTraitMap(typesDefScrubber, td, classificationVendorPiiIndex, expectedVendorPIIStructName, 1);
    assertTraitMap(typesDefScrubber, td, classificationFinancendex, expectedFinanceStructName, 2);
}
 
源代码13 项目: atlas   文件: TypesDefScrubberTest.java
private void assertNewTypesDef(AtlasTypesDef newTypes, int traitPrayIndex, int vendorPIIIndex, int financeIndex, String expectedTraitPrayStructName, String expectedVendorPIIStructName, String expectedFinanceStructName) {
    assertNotNull(newTypes);
    assertEquals(newTypes.getStructDefs().size(), 4);

    assertTrue(newTypes.getStructDefs().get(traitPrayIndex).getName().contains(LEGACY_TYPE_NAME_PREFIX));
    assertTrue(newTypes.getStructDefs().get(vendorPIIIndex).getName().contains(LEGACY_TYPE_NAME_PREFIX));
    assertTrue(newTypes.getStructDefs().get(financeIndex).getName().contains(LEGACY_TYPE_NAME_PREFIX));

    assertEquals(newTypes.getStructDefs().get(traitPrayIndex).getName(), expectedTraitPrayStructName);
    assertEquals(newTypes.getStructDefs().get(vendorPIIIndex).getName(), expectedVendorPIIStructName);
    assertEquals(newTypes.getStructDefs().get(financeIndex).getName(), expectedFinanceStructName);

    assertEquals(newTypes.getStructDefs().get(1).getAttributeDefs().size(), 1);
    assertEquals(newTypes.getEntityDefs().get(0).getAttributeDefs().get(0).getTypeName(), expectedTraitPrayStructName);
    assertEquals(newTypes.getEntityDefs().get(0).getAttributeDefs().get(1).getTypeName(), String.format("array<%s>", expectedVendorPIIStructName));
    assertEquals(newTypes.getEntityDefs().get(0).getAttributeDefs().get(2).getTypeName(), String.format("map<String,%s>", expectedFinanceStructName));
}
 
源代码14 项目: atlas   文件: AtlasEntityStoreV2Test.java
@BeforeClass
public void setUp() throws Exception {
    super.setUp();

    AtlasTypesDef[] testTypesDefs = new AtlasTypesDef[] { TestUtilsV2.defineDeptEmployeeTypes(),
                                                          TestUtilsV2.defineHiveTypes(),
                                                          TestUtilsV2.defineTypeWithNestedCollectionAttributes(),
                                                          TestUtilsV2.defineEnumTypes(),
                                                          TestUtilsV2.defineBusinessMetadataTypes()
                                                        };
    createTypesDef(testTypesDefs);

    deptEntity                 = TestUtilsV2.createDeptEg2();
    dbEntity                   = TestUtilsV2.createDBEntityV2();
    tblEntity                  = TestUtilsV2.createTableEntityV2(dbEntity.getEntity());
    nestedCollectionAttrEntity = TestUtilsV2.createNestedCollectionAttrEntity();
    primitiveEntity            = TestUtilsV2.createprimitiveEntityV2();

    AtlasTypesDef typesDef11         = new AtlasTypesDef();
    List          primitiveEntityDef = new ArrayList<AtlasEntityDef>();

    primitiveEntityDef.add(TestUtilsV2.createPrimitiveEntityDef());
    typesDef11.setEntityDefs(primitiveEntityDef);

    typeDefStore.createTypesDef(typesDef11);
}
 
源代码15 项目: atlas   文件: AtlasRelationshipStoreV2Test.java
@BeforeClass
public void setUp() throws Exception {
    new GraphBackedSearchIndexer(typeRegistry);

    // create employee relationship types
    AtlasTypesDef employeeTypes = getDepartmentEmployeeTypes();
    typeDefStore.createTypesDef(employeeTypes);

    AtlasEntitiesWithExtInfo employeeInstances = getDepartmentEmployeeInstances();
    EntityMutationResponse response = entityStore.createOrUpdate(new AtlasEntityStream(employeeInstances), false);

    for (AtlasEntityHeader entityHeader : response.getCreatedEntities()) {
        employeeNameIdMap.put((String) entityHeader.getAttribute(NAME), getAtlasObjectId(entityHeader));
    }

    init();
    AtlasTypesDef typesDef = getInverseReferenceTestTypes();

    AtlasTypesDef typesToCreate = AtlasTypeDefStoreInitializer.getTypesToCreate(typesDef, typeRegistry);

    if (!typesToCreate.isEmpty()) {
        typeDefStore.createTypesDef(typesToCreate);
    }
}
 
源代码16 项目: incubator-atlas   文件: ZipSourceTest.java
@Test(dataProvider = "zipFileStocks")
public void examineContents_BehavesAsExpected(ZipSource zipSource) throws IOException, AtlasBaseException {
    List<String> creationOrder = zipSource.getCreationOrder();

    assertNotNull(creationOrder);
    assertEquals(creationOrder.size(), 4);

    AtlasTypesDef typesDef = zipSource.getTypesDef();
    assertNotNull(typesDef);
    assertEquals(typesDef.getEntityDefs().size(), 6);

    useCreationOrderToFetchEntitiesWithExtInfo(zipSource, creationOrder);
    useCreationOrderToFetchEntities(zipSource, creationOrder);
    attemptToFetchNonExistentGuid_ReturnsNull(zipSource, "non-existent-guid");
    verifyGuidRemovalOnImportComplete(zipSource, creationOrder.get(0));
}
 
@Test(dependsOnMethods = {"testUpdate"}, dataProvider = "allCreatedTypes")
public void testDelete(AtlasTypesDef atlasTypesDef){
    try {
        typeDefStore.deleteTypesDef(atlasTypesDef);
    } catch (AtlasBaseException e) {
        fail("Deletion should've succeeded");
    }
}
 
源代码18 项目: atlas   文件: EntityV2JerseyResourceIT.java
private String addNewType() throws Exception {
    String typeName = "test" + randomString();
    AtlasEntityDef classTypeDef = AtlasTypeUtil
            .createClassTypeDef(typeName, Collections.<String>emptySet(),
                    AtlasTypeUtil.createRequiredAttrDef("name", "string"),
                    AtlasTypeUtil.createRequiredAttrDef("description", "string"));
    AtlasTypesDef typesDef = new AtlasTypesDef();
    typesDef.getEntityDefs().add(classTypeDef);
    createType(typesDef);
    return typeName;
}
 
源代码19 项目: atlas   文件: TestUtilsV2.java
public static void populateSystemAttributes(AtlasTypesDef typesDef) {
    populateSystemAttributes(typesDef.getEnumDefs());
    populateSystemAttributes(typesDef.getStructDefs());
    populateSystemAttributes(typesDef.getClassificationDefs());
    populateSystemAttributes(typesDef.getEntityDefs());
    populateSystemAttributes(typesDef.getRelationshipDefs());
    populateSystemAttributes(typesDef.getBusinessMetadataDefs());
}
 
源代码20 项目: incubator-atlas   文件: TypeAttributeDifference.java
public void updateTypes(AtlasTypesDef typeDefinitionMap, AtlasImportResult result) throws AtlasBaseException {

        updateEntityDef(typeDefinitionMap, result);
        updateClassificationDef(typeDefinitionMap, result);
        updateEnumDef(typeDefinitionMap, result);
        updateStructDef(typeDefinitionMap, result);
    }
 
源代码21 项目: incubator-atlas   文件: BaseResourceIT.java
protected void batchCreateTypes(AtlasTypesDef typesDef) throws AtlasServiceException {
    AtlasTypesDef toCreate = new AtlasTypesDef();
    for (AtlasEnumDef enumDef : typesDef.getEnumDefs()) {
        if (atlasClientV2.typeWithNameExists(enumDef.getName())) {
            LOG.warn("Type with name {} already exists. Skipping", enumDef.getName());
        } else {
            toCreate.getEnumDefs().add(enumDef);
        }
    }

    for (AtlasStructDef structDef : typesDef.getStructDefs()) {
        if (atlasClientV2.typeWithNameExists(structDef.getName())) {
            LOG.warn("Type with name {} already exists. Skipping", structDef.getName());
        } else {
            toCreate.getStructDefs().add(structDef);
        }
    }

    for (AtlasEntityDef entityDef : typesDef.getEntityDefs()) {
        if (atlasClientV2.typeWithNameExists(entityDef.getName())) {
            LOG.warn("Type with name {} already exists. Skipping", entityDef.getName());
        } else  {
            toCreate.getEntityDefs().add(entityDef);
        }
    }

    for (AtlasClassificationDef classificationDef : typesDef.getClassificationDefs()) {
        if (atlasClientV2.typeWithNameExists(classificationDef.getName())) {
            LOG.warn("Type with name {} already exists. Skipping", classificationDef.getName());
        } else  {
            toCreate.getClassificationDefs().add(classificationDef);
        }
    }

    atlasClientV2.createAtlasTypeDefs(toCreate);
}
 
源代码22 项目: incubator-atlas   文件: TypedefsJerseyResourceIT.java
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;
}
 
源代码23 项目: atlas   文件: RestUtilsTest.java
private List<AtlasEntityDef> convertV1toV2(List<ClassTypeDefinition> types) throws AtlasBaseException {
    List<ClassTypeDefinition> classTypeList       = new ArrayList(types);
    TypesDef                  toConvert           = new TypesDef(Collections.emptyList(), Collections.emptyList(), Collections.emptyList(), classTypeList);
    String                    json                = AtlasType.toV1Json(toConvert);
    AtlasTypeRegistry         emptyRegistry       = new AtlasTypeRegistry();
    AtlasTypesDef             converted           = TypeConverterUtil.toAtlasTypesDef(json, emptyRegistry);
    List<AtlasEntityDef>      convertedEntityDefs = converted.getEntityDefs();

    return convertedEntityDefs;
}
 
源代码24 项目: atlas   文件: ImportTransformsShaper.java
private String getCreateTag(String classificationName) throws AtlasBaseException {
    AtlasClassificationDef classificationDef = typeRegistry.getClassificationDefByName(classificationName);
    if(classificationDef != null) {
        return classificationName;
    }

    classificationDef = new AtlasClassificationDef(classificationName);
    AtlasTypesDef typesDef = new AtlasTypesDef();
    typesDef.setClassificationDefs(Collections.singletonList(classificationDef));
    typeDefStore.createTypesDef(typesDef);
    LOG.info("created classification: {}", classificationName);
    return classificationName;
}
 
源代码25 项目: incubator-atlas   文件: TypeConverterUtil.java
public static AtlasTypesDef toAtlasTypesDef(String typeDefinition, AtlasTypeRegistry registry) throws AtlasBaseException {
    AtlasTypesDef ret = new AtlasTypesDef();

    try {
        if (StringUtils.isEmpty(typeDefinition)) {
            throw new AtlasBaseException(INVALID_TYPE_DEFINITION, typeDefinition);
        }

        TypesDef typesDef = TypesSerialization.fromJson(typeDefinition);
        if (CollectionUtils.isNotEmpty(typesDef.enumTypesAsJavaList())) {
            List<AtlasEnumDef> enumDefs = toAtlasEnumDefs(typesDef.enumTypesAsJavaList());
            ret.setEnumDefs(enumDefs);
        }

        if (CollectionUtils.isNotEmpty(typesDef.structTypesAsJavaList())) {
            List<AtlasStructDef> structDefs = toAtlasStructDefs(typesDef.structTypesAsJavaList());
            ret.setStructDefs(structDefs);
        }

        if (CollectionUtils.isNotEmpty(typesDef.classTypesAsJavaList())) {
            List<AtlasEntityDef> entityDefs = toAtlasEntityDefs(typesDef.classTypesAsJavaList(), registry);
            ret.setEntityDefs(entityDefs);
        }

        if (CollectionUtils.isNotEmpty(typesDef.traitTypesAsJavaList())) {
            List<AtlasClassificationDef> classificationDefs = toAtlasClassificationDefs(typesDef.traitTypesAsJavaList());
            ret.setClassificationDefs(classificationDefs);
        }

    } catch (Exception e) {
        LOG.error("Invalid type definition = {}", typeDefinition, e);
        throw new AtlasBaseException(INVALID_TYPE_DEFINITION, typeDefinition);
    }

    return ret;
}
 
源代码26 项目: atlas   文件: TestRelationshipUtilsV2.java
public static AtlasTypesDef getInverseReferenceTestTypes() throws AtlasBaseException {
    AtlasEntityDef aType = createClassTypeDef(TYPE_A, superType(null), createUniqueRequiredAttrDef("name", "string"));
    AtlasEntityDef bType = createClassTypeDef(TYPE_B, superType(null), createUniqueRequiredAttrDef("name", "string"));

    AtlasRelationshipDef relationshipType1 = new AtlasRelationshipDef("TypeA_to_TypeB_on_b", description("TypeA_to_TypeB_on_b"),
                                                    DEFAULT_VERSION, ASSOCIATION, ONE_TO_TWO,
                                                    new AtlasRelationshipEndDef(TYPE_A, "b", SINGLE),
                                                    new AtlasRelationshipEndDef(TYPE_B, "a", SINGLE));

    AtlasRelationshipDef relationshipType2 = new AtlasRelationshipDef("TypeA_to_TypeB_on_oneB", description("TypeA_to_TypeB_on_oneB"),
                                                    DEFAULT_VERSION, ASSOCIATION, ONE_TO_TWO,
                                                    new AtlasRelationshipEndDef(TYPE_A, "oneB", SINGLE),
                                                    new AtlasRelationshipEndDef(TYPE_B, "manyA", SET));

    AtlasRelationshipDef relationshipType3 = new AtlasRelationshipDef("TypeA_to_TypeB_on_manyB", description("TypeA_to_TypeB_on_manyB"),
                                                    DEFAULT_VERSION, ASSOCIATION, ONE_TO_TWO,
                                                    new AtlasRelationshipEndDef(TYPE_A, "manyB", SET),
                                                    new AtlasRelationshipEndDef(TYPE_B, "manyToManyA", SET));

    AtlasRelationshipDef relationshipType4 = new AtlasRelationshipDef("TypeB_to_TypeA_on_mappedFromA", description("TypeB_to_TypeA_on_mappedFromA"),
                                                    DEFAULT_VERSION, ASSOCIATION, ONE_TO_TWO,
                                                    new AtlasRelationshipEndDef(TYPE_B, "mappedFromA", SINGLE),
                                                    new AtlasRelationshipEndDef(TYPE_A, "mapToB", SET));

    return new AtlasTypesDef(Collections.<AtlasEnumDef>emptyList(), Collections.<AtlasStructDef>emptyList(), Collections.<AtlasClassificationDef>emptyList(),  Arrays.asList(aType, bType),
                             Arrays.asList(relationshipType1, relationshipType2, relationshipType3, relationshipType4), Collections.<AtlasBusinessMetadataDef>emptyList());
}
 
源代码27 项目: atlas   文件: ExportService.java
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);
    }
}
 
源代码28 项目: atlas   文件: TypeAttributeDifference.java
public void updateTypes(AtlasTypesDef typeDefinitionMap, AtlasImportResult result) throws AtlasBaseException {
    updateEnumDef(typeDefinitionMap.getEnumDefs(), result);
    updateStructDef(typeDefinitionMap.getStructDefs(), result);
    updateClassificationDef(typeDefinitionMap.getClassificationDefs(), result);
    updateEntityDef(typeDefinitionMap.getEntityDefs(), result);
    updateRelationshipDefs(typeDefinitionMap.getRelationshipDefs(), result);
}
 
源代码29 项目: incubator-atlas   文件: EntityV2JerseyResourceIT.java
private String addNewType() throws Exception {
    String typeName = "test" + randomString();
    AtlasEntityDef classTypeDef = AtlasTypeUtil
            .createClassTypeDef(typeName, ImmutableSet.<String>of(),
                    AtlasTypeUtil.createRequiredAttrDef("name", "string"),
                    AtlasTypeUtil.createRequiredAttrDef("description", "string"));
    AtlasTypesDef typesDef = new AtlasTypesDef();
    typesDef.getEntityDefs().add(classTypeDef);
    createType(typesDef);
    return typeName;
}
 
源代码30 项目: incubator-atlas   文件: TypeAttributeDifference.java
private void updateClassificationDef(AtlasTypesDef typeDefinitionMap, AtlasImportResult result) throws AtlasBaseException {
    for (AtlasClassificationDef def: typeDefinitionMap.getClassificationDefs()) {
        AtlasClassificationDef existing = typeRegistry.getClassificationDefByName(def.getName());
        if(existing != null && addAttributes(existing, def)) {
            typeDefStore.updateClassificationDefByName(existing.getName(), existing);
            result.incrementMeticsCounter("typedef:classification:update");
        }
    }
}