TypeSystem { public Map<String, IDataType> defineTypes(TypesDef typesDef) throws AtlasException { ImmutableList<EnumTypeDefinition> enumDefs = ImmutableList.copyOf(typesDef.enumTypesAsJavaList()); ImmutableList<StructTypeDefinition> structDefs = ImmutableList.copyOf(typesDef.structTypesAsJavaList()); ImmutableList<HierarchicalTypeDefinition<TraitType>> traitDefs = ImmutableList.copyOf(typesDef.traitTypesAsJavaList()); ImmutableList<HierarchicalTypeDefinition<ClassType>> classDefs = ImmutableList.copyOf(typesDef.classTypesAsJavaList()); return defineTypes(enumDefs, structDefs, traitDefs, classDefs); } TypeSystem(); static TypeSystem getInstance(); @InterfaceAudience.Private TypeSystem reset(); void setTypeCache(TypeCache typeCache); ImmutableList<String> getCoreTypes(); ImmutableList<String> getTypeNames(); ImmutableList<String> getTypeNamesByCategory(final DataTypes.TypeCategory typeCategory); ImmutableList<String> getTypeNames(Map<TypeCache.TYPE_FILTER, String> filterMap); IdType getIdType(); boolean isRegistered(String typeName); IDataType getDataType(String name); T getDataType(Class<T> cls, String name); StructType defineStructType(String name, boolean errorIfExists, AttributeDefinition... attrDefs); StructType defineStructType(String name, String description, boolean errorIfExists, AttributeDefinition... attrDefs); StructType defineQueryResultType(String name, Map<String, IDataType> tempTypes,
            AttributeDefinition... attrDefs); TraitType defineTraitType(HierarchicalTypeDefinition<TraitType> traitDef); ClassType defineClassType(HierarchicalTypeDefinition<ClassType> classDef); Map<String, IDataType> defineTraitTypes(HierarchicalTypeDefinition<TraitType>... traitDefs); Map<String, IDataType> defineClassTypes(HierarchicalTypeDefinition<ClassType>... classDefs); Map<String, IDataType> updateTypes(TypesDef typesDef); Map<String, IDataType> defineTypes(TypesDef typesDef); Map<String, IDataType> defineTypes(ImmutableList<EnumTypeDefinition> enumDefs,
            ImmutableList<StructTypeDefinition> structDefs,
            ImmutableList<HierarchicalTypeDefinition<TraitType>> traitDefs,
            ImmutableList<HierarchicalTypeDefinition<ClassType>> classDefs); DataTypes.ArrayType defineArrayType(IDataType elemType); DataTypes.MapType defineMapType(IDataType keyType, IDataType valueType); EnumType defineEnumType(String name, EnumValue... values); EnumType defineEnumType(String name, String description, EnumValue... values); EnumType defineEnumType(EnumTypeDefinition eDef); SimpleDateFormat getDateFormat(); boolean allowNullsInCollections(); TransientTypeSystem createTransientTypeSystem(TypesDef typesDef, boolean isUpdate); void commitTypes(Map<String, IDataType> typesAdded); static final String ID_STRUCT_ID_ATTRNAME; static final String ID_STRUCT_TYP_NAME; }
@Test public void testUTFNames() throws Exception { TypeSystem ts = getTypeSystem(); String enumType = random(); EnumTypeDefinition orgLevelEnum = new EnumTypeDefinition(enumType, new EnumValue(random(), 1), new EnumValue(random(), 2)); String structName = random(); String attrType = random(); StructTypeDefinition structType = createStructTypeDef(structName, createRequiredAttrDef(attrType, DataTypes.STRING_TYPE)); String className = random(); HierarchicalTypeDefinition<ClassType> classType = createClassTypeDef(className, ImmutableSet.<String>of(), createRequiredAttrDef(attrType, DataTypes.STRING_TYPE)); String traitName = random(); HierarchicalTypeDefinition<TraitType> traitType = createTraitTypeDef(traitName, ImmutableSet.<String>of(), createRequiredAttrDef(attrType, DataTypes.INT_TYPE)); ts.defineTypes(ImmutableList.of(orgLevelEnum), ImmutableList.of(structType), ImmutableList.of(traitType), ImmutableList.of(classType)); }
@Test public void testDuplicateNewTypenames() throws Exception { TypeSystem typeSystem = getTypeSystem(); HierarchicalTypeDefinition<TraitType> trait1 = TypesUtil .createTraitTypeDef(random(), "description", ImmutableSet.<String>of(), TypesUtil.createRequiredAttrDef("type", DataTypes.STRING_TYPE)); HierarchicalTypeDefinition<TraitType> trait2 = TypesUtil .createTraitTypeDef(trait1.typeName, "description", ImmutableSet.<String>of(), TypesUtil.createRequiredAttrDef("type", DataTypes.STRING_TYPE)); try { typeSystem.defineTypes(ImmutableList.<EnumTypeDefinition>of(), ImmutableList.<StructTypeDefinition>of(), ImmutableList.of(trait1, trait2), ImmutableList.<HierarchicalTypeDefinition<ClassType>>of()); } catch(AtlasException e) { fail("Exception unexpected"); } }