Java Code Examples for org.apache.atlas.model.typedef.AtlasTypesDef#setEntityDefs()
The following examples show how to use
org.apache.atlas.model.typedef.AtlasTypesDef#setEntityDefs() .
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: AtlasEntityStoreV2Test.java From atlas with Apache License 2.0 | 6 votes |
@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); }
Example 2
Source File: TypeConverterUtil.java From atlas with Apache License 2.0 | 5 votes |
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 = AtlasType.fromV1Json(typeDefinition, TypesDef.class); if (CollectionUtils.isNotEmpty(typesDef.getEnumTypes())) { List<AtlasEnumDef> enumDefs = toAtlasEnumDefs(typesDef.getEnumTypes()); ret.setEnumDefs(enumDefs); } if (CollectionUtils.isNotEmpty(typesDef.getStructTypes())) { List<AtlasStructDef> structDefs = toAtlasStructDefs(typesDef.getStructTypes()); ret.setStructDefs(structDefs); } if (CollectionUtils.isNotEmpty(typesDef.getClassTypes())) { List<AtlasEntityDef> entityDefs = toAtlasEntityDefs(typesDef.getClassTypes(), registry); ret.setEntityDefs(entityDefs); } if (CollectionUtils.isNotEmpty(typesDef.getTraitTypes())) { List<AtlasClassificationDef> classificationDefs = toAtlasClassificationDefs(typesDef.getTraitTypes()); ret.setClassificationDefs(classificationDefs); } } catch (Exception e) { LOG.error("Invalid type definition = {}", typeDefinition, e); throw new AtlasBaseException(INVALID_TYPE_DEFINITION, typeDefinition); } return ret; }
Example 3
Source File: TransformationHandlerTest.java From atlas with Apache License 2.0 | 5 votes |
private AtlasTypeRegistry getTypeRegistry() { AtlasTypeRegistry ret = new AtlasTypeRegistry(); AtlasEntityDef defReferenceable = new AtlasEntityDef(TYPENAME_REFERENCEABLE); AtlasEntityDef defAsset = new AtlasEntityDef(TYPENAME_ASSET); AtlasEntityDef defHdfsPath = new AtlasEntityDef(HDFS_PATH); AtlasEntityDef defHiveDb = new AtlasEntityDef(HIVE_DATABASE); AtlasEntityDef defHiveTable = new AtlasEntityDef(HIVE_TABLE); AtlasEntityDef defHiveColumn = new AtlasEntityDef(HIVE_COLUMN); AtlasEntityDef defHiveStorDesc = new AtlasEntityDef(HIVE_STORAGE_DESCRIPTOR); AtlasEntityDef defNonAsset = new AtlasEntityDef(TYPENAME_NON_ASSET); defAsset.addSuperType(TYPENAME_REFERENCEABLE); defHdfsPath.addSuperType(TYPENAME_ASSET); defHiveDb.addSuperType(TYPENAME_ASSET); defHiveTable.addSuperType(TYPENAME_ASSET); defHiveColumn.addSuperType(TYPENAME_ASSET); defNonAsset.addSuperType(TYPENAME_REFERENCEABLE); AtlasTypesDef typesDef = new AtlasTypesDef(); typesDef.setEntityDefs(Arrays.asList(defReferenceable, defAsset, defHdfsPath, defHiveDb, defHiveTable, defHiveColumn, defHiveStorDesc, defNonAsset)); try { AtlasTypeRegistry.AtlasTransientTypeRegistry ttr = ret.lockTypeRegistryForUpdate(); ttr.addTypes(typesDef); ret.releaseTypeRegistryForUpdate(ttr, true); } catch (AtlasBaseException excp) { LOG.warn("failed to initialize type-registry", excp); } return ret; }
Example 4
Source File: TypeConverterUtil.java From incubator-atlas with Apache License 2.0 | 5 votes |
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; }
Example 5
Source File: AtlasEntityStoreV1Test.java From incubator-atlas with Apache License 2.0 | 5 votes |
@BeforeClass public void setUp() throws Exception { metadataService = TestUtils.addSessionCleanupWrapper(metadataService); new GraphBackedSearchIndexer(typeRegistry); AtlasTypesDef[] testTypesDefs = new AtlasTypesDef[] { TestUtilsV2.defineDeptEmployeeTypes(), TestUtilsV2.defineHiveTypes() }; for (AtlasTypesDef typesDef : testTypesDefs) { AtlasTypesDef typesToCreate = AtlasTypeDefStoreInitializer.getTypesToCreate(typesDef, typeRegistry); if (!typesToCreate.isEmpty()) { typeDefStore.createTypesDef(typesToCreate); } } deptEntity = TestUtilsV2.createDeptEg2(); dbEntity = TestUtilsV2.createDBEntityV2(); tblEntity = TestUtilsV2.createTableEntityV2(dbEntity.getEntity()); AtlasTypesDef typesDef11 = new AtlasTypesDef(); List primitiveEntityDef = new ArrayList<AtlasEntityDef>(); primitiveEntityDef.add(TestUtilsV2.createPrimitiveEntityDef()); typesDef11.setEntityDefs(primitiveEntityDef); typeDefStore.createTypesDef( typesDef11 ); primitiveEntity = TestUtilsV2.createprimitiveEntityV2(); }