You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@atlas.apache.org by ma...@apache.org on 2017/11/05 20:31:29 UTC

[07/40] atlas git commit: ATLAS-2251: Remove TypeSystem and related implementation, to avoid unncessary duplicate of type details in cache

http://git-wip-us.apache.org/repos/asf/atlas/blob/0877e47c/typesystem/src/main/java/org/apache/atlas/typesystem/types/TypeSystem.java
----------------------------------------------------------------------
diff --git a/typesystem/src/main/java/org/apache/atlas/typesystem/types/TypeSystem.java b/typesystem/src/main/java/org/apache/atlas/typesystem/types/TypeSystem.java
deleted file mode 100755
index 262f784..0000000
--- a/typesystem/src/main/java/org/apache/atlas/typesystem/types/TypeSystem.java
+++ /dev/null
@@ -1,821 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.atlas.typesystem.types;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableSet;
-import org.apache.atlas.AtlasException;
-import org.apache.atlas.classification.InterfaceAudience;
-import org.apache.atlas.typesystem.TypesDef;
-import org.apache.atlas.typesystem.exception.TypeExistsException;
-import org.apache.atlas.typesystem.exception.TypeNotFoundException;
-import org.apache.atlas.typesystem.types.cache.DefaultTypeCache;
-import org.apache.atlas.typesystem.types.cache.TypeCache;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.inject.Singleton;
-import java.lang.reflect.Constructor;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TimeZone;
-import java.util.concurrent.ConcurrentHashMap;
-
-@Singleton
-@InterfaceAudience.Private
-@Deprecated
-public class TypeSystem {
-    private static final Logger LOG = LoggerFactory.getLogger(TypeSystem.class);
-
-    private static final TypeSystem INSTANCE = new TypeSystem();
-    private static ThreadLocal<SimpleDateFormat> dateFormat = new ThreadLocal<SimpleDateFormat>() {
-        @Override
-        public SimpleDateFormat initialValue() {
-            SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
-            dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
-            return dateFormat;
-        }
-    };
-
-    private TypeCache typeCache  = new DefaultTypeCache();
-    private IdType idType;
-    private Map<String, IDataType> coreTypes;
-
-    public TypeSystem() {
-        initialize();
-    }
-
-    public static TypeSystem getInstance() {
-        return INSTANCE;
-    }
-
-    /**
-     * This is only used for testing purposes. Not intended for public use.
-     */
-    @InterfaceAudience.Private
-    public TypeSystem reset() {
-
-        typeCache.clear(); // clear all entries in cache
-        initialize();
-
-        return this;
-    }
-
-    public void setTypeCache(TypeCache typeCache) {
-        this.typeCache = typeCache;
-    }
-
-    private void initialize() {
-
-        coreTypes = new ConcurrentHashMap<>();
-
-        registerPrimitiveTypes();
-        registerCoreTypes();
-    }
-
-    public ImmutableList<String> getCoreTypes() {
-        return ImmutableList.copyOf(coreTypes.keySet());
-    }
-
-    public ImmutableList<String> getTypeNames() throws AtlasException {
-        List<String> typeNames = new ArrayList<>(typeCache.getAllTypeNames());
-        return ImmutableList.copyOf(typeNames);
-    }
-
-    public ImmutableList<String> getTypeNamesByCategory(final DataTypes.TypeCategory typeCategory) throws AtlasException {
-        return getTypeNames(new HashMap<TypeCache.TYPE_FILTER, String>() {{
-            put(TypeCache.TYPE_FILTER.CATEGORY, typeCategory.name());
-        }});
-    }
-
-    public ImmutableList<String> getTypeNames(Map<TypeCache.TYPE_FILTER, String> filterMap) throws AtlasException {
-        return ImmutableList.copyOf(typeCache.getTypeNames(filterMap));
-    }
-
-    private void registerPrimitiveTypes() {
-        coreTypes.put(DataTypes.BOOLEAN_TYPE.getName(), DataTypes.BOOLEAN_TYPE);
-        coreTypes.put(DataTypes.BYTE_TYPE.getName(), DataTypes.BYTE_TYPE);
-        coreTypes.put(DataTypes.SHORT_TYPE.getName(), DataTypes.SHORT_TYPE);
-        coreTypes.put(DataTypes.INT_TYPE.getName(), DataTypes.INT_TYPE);
-        coreTypes.put(DataTypes.LONG_TYPE.getName(), DataTypes.LONG_TYPE);
-        coreTypes.put(DataTypes.FLOAT_TYPE.getName(), DataTypes.FLOAT_TYPE);
-        coreTypes.put(DataTypes.DOUBLE_TYPE.getName(), DataTypes.DOUBLE_TYPE);
-        coreTypes.put(DataTypes.BIGINTEGER_TYPE.getName(), DataTypes.BIGINTEGER_TYPE);
-        coreTypes.put(DataTypes.BIGDECIMAL_TYPE.getName(), DataTypes.BIGDECIMAL_TYPE);
-        coreTypes.put(DataTypes.DATE_TYPE.getName(), DataTypes.DATE_TYPE);
-        coreTypes.put(DataTypes.STRING_TYPE.getName(), DataTypes.STRING_TYPE);
-    }
-
-    /*
-     * The only core OOB type we will define is the Struct to represent the Identity of an Instance.
-     */
-    private void registerCoreTypes() {
-
-        idType = new IdType();
-        coreTypes.put(idType.getStructType().getName(), idType.getStructType());
-    }
-
-    public IdType getIdType() {
-        return idType;
-    }
-
-    public boolean isRegistered(String typeName) throws AtlasException {
-        return isCoreType(typeName) || typeCache.has(typeName);
-    }
-
-    protected boolean isCoreType(String typeName) {
-
-        return coreTypes.containsKey(typeName);
-    }
-
-    public IDataType getDataType(String name) throws AtlasException {
-        if (isCoreType(name)) {
-            return coreTypes.get(name);
-        }
-
-        if (typeCache.has(name)) {
-            return typeCache.get(name);
-        }
-
-        /*
-         * is this an Array Type?
-         */
-        String arrElemType = TypeUtils.parseAsArrayType(name);
-        if (arrElemType != null) {
-            IDataType dT = defineArrayType(getDataType(arrElemType));
-            return dT;
-        }
-
-        /*
-         * is this a Map Type?
-         */
-        String[] mapType = TypeUtils.parseAsMapType(name);
-        if (mapType != null) {
-            IDataType dT =
-                    defineMapType(getDataType(mapType[0]), getDataType(mapType[1]));
-            return dT;
-        }
-
-        /*
-         * Invoke cache callback to possibly obtain type from other storage.
-         */
-        IDataType dT = typeCache.onTypeFault(name);
-        if (dT != null) {
-            return dT;
-        }
-
-        throw new TypeNotFoundException(String.format("Unknown datatype: %s", name));
-    }
-
-    public <T extends IDataType> T getDataType(Class<T> cls, String name) throws AtlasException {
-        try {
-            IDataType dt = getDataType(name);
-            return cls.cast(dt);
-        } catch (ClassCastException cce) {
-            throw new AtlasException(cce);
-        }
-
-    }
-
-    public StructType defineStructType(String name, boolean errorIfExists, AttributeDefinition... attrDefs)
-    throws AtlasException {
-        return defineStructType(name, null, errorIfExists, attrDefs);
-    }
-
-    public StructType defineStructType(String name, String description, boolean errorIfExists, AttributeDefinition... attrDefs)
-    throws AtlasException {
-        StructTypeDefinition structDef = new StructTypeDefinition(name, description, attrDefs);
-        defineTypes(ImmutableList.<EnumTypeDefinition>of(), ImmutableList.of(structDef),
-                ImmutableList.<HierarchicalTypeDefinition<TraitType>>of(),
-                ImmutableList.<HierarchicalTypeDefinition<ClassType>>of());
-        return getDataType(StructType.class, structDef.typeName);
-    }
-
-    /**
-     * construct a temporary StructType for a Query Result. This is not registered in the
-     * typeSystem.
-     * The attributes in the typeDefinition can only reference permanent types.
-     * @param name     struct type name
-     * @param attrDefs struct type definition
-     * @return temporary struct type
-     * @throws AtlasException
-     */
-    public StructType defineQueryResultType(String name, Map<String, IDataType> tempTypes,
-            AttributeDefinition... attrDefs) throws AtlasException {
-
-        AttributeInfo[] infos = new AttributeInfo[attrDefs.length];
-        for (int i = 0; i < attrDefs.length; i++) {
-            infos[i] = new AttributeInfo(this, attrDefs[i], tempTypes);
-        }
-
-        return new StructType(this, name, null, infos);
-    }
-
-    public TraitType defineTraitType(HierarchicalTypeDefinition<TraitType> traitDef) throws AtlasException {
-        defineTypes(ImmutableList.<EnumTypeDefinition>of(), ImmutableList.<StructTypeDefinition>of(),
-                ImmutableList.of(traitDef), ImmutableList.<HierarchicalTypeDefinition<ClassType>>of());
-        return getDataType(TraitType.class, traitDef.typeName);
-    }
-
-    public ClassType defineClassType(HierarchicalTypeDefinition<ClassType> classDef) throws AtlasException {
-        defineTypes(ImmutableList.<EnumTypeDefinition>of(), ImmutableList.<StructTypeDefinition>of(),
-                ImmutableList.<HierarchicalTypeDefinition<TraitType>>of(), ImmutableList.of(classDef));
-        return getDataType(ClassType.class, classDef.typeName);
-    }
-
-    public Map<String, IDataType> defineTraitTypes(HierarchicalTypeDefinition<TraitType>... traitDefs)
-    throws AtlasException {
-        TransientTypeSystem transientTypes =
-                new TransientTypeSystem(ImmutableList.<EnumTypeDefinition>of(),
-                        ImmutableList.<StructTypeDefinition>of(), ImmutableList.copyOf(traitDefs),
-                        ImmutableList.<HierarchicalTypeDefinition<ClassType>>of());
-        return transientTypes.defineTypes(false);
-    }
-
-    public Map<String, IDataType> defineClassTypes(HierarchicalTypeDefinition<ClassType>... classDefs)
-    throws AtlasException {
-        TransientTypeSystem transientTypes = new TransientTypeSystem(ImmutableList.<EnumTypeDefinition>of(),
-                ImmutableList.<StructTypeDefinition>of(), ImmutableList.<HierarchicalTypeDefinition<TraitType>>of(),
-                ImmutableList.copyOf(classDefs));
-        return transientTypes.defineTypes(false);
-    }
-
-    public Map<String, IDataType> updateTypes(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());
-
-        TransientTypeSystem transientTypes = new TransientTypeSystem(enumDefs, structDefs, traitDefs, classDefs);
-        return transientTypes.defineTypes(true);
-    }
-
-    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);
-    }
-
-    public Map<String, IDataType> defineTypes(ImmutableList<EnumTypeDefinition> enumDefs,
-            ImmutableList<StructTypeDefinition> structDefs,
-            ImmutableList<HierarchicalTypeDefinition<TraitType>> traitDefs,
-            ImmutableList<HierarchicalTypeDefinition<ClassType>> classDefs) throws AtlasException {
-        TransientTypeSystem transientTypes = new TransientTypeSystem(enumDefs, structDefs, traitDefs, classDefs);
-        return transientTypes.defineTypes(false);
-    }
-
-    public DataTypes.ArrayType defineArrayType(IDataType elemType) throws AtlasException {
-        assert elemType != null;
-        DataTypes.ArrayType dT = new DataTypes.ArrayType(elemType);
-        return dT;
-    }
-
-    public DataTypes.MapType defineMapType(IDataType keyType, IDataType valueType) throws AtlasException {
-        assert keyType != null;
-        assert valueType != null;
-        DataTypes.MapType dT = new DataTypes.MapType(keyType, valueType);
-        return dT;
-    }
-
-    public EnumType defineEnumType(String name, EnumValue... values) throws AtlasException {
-        return defineEnumType(new EnumTypeDefinition(name, values));
-    }
-
-    public EnumType defineEnumType(String name, String description, EnumValue... values) throws AtlasException {
-        return defineEnumType(new EnumTypeDefinition(name, description, values));
-    }
-
-    public EnumType defineEnumType(EnumTypeDefinition eDef) throws AtlasException {
-        assert eDef.name != null;
-        if (isRegistered(eDef.name)) {
-            throw new AtlasException(String.format("Redefinition of type %s not supported", eDef.name));
-        }
-
-        EnumType eT = new EnumType(this, eDef.name, eDef.description, eDef.version, eDef.enumValues);
-        typeCache.put(eT);
-        return eT;
-    }
-
-    public SimpleDateFormat getDateFormat() {
-        return dateFormat.get();
-    }
-
-    public boolean allowNullsInCollections() {
-        return false;
-    }
-
-    /**
-     * Create an instance of {@link TransientTypeSystem} with the types defined in the {@link TypesDef}.
-     *
-     * As part of this, a set of verifications are run on the types defined.
-     * @param typesDef The new list of types to be created or updated.
-     * @param isUpdate True, if types are updated, false otherwise.
-     * @return {@link TransientTypeSystem} that holds the newly added types.
-     * @throws AtlasException
-     */
-    public TransientTypeSystem createTransientTypeSystem(TypesDef typesDef, boolean isUpdate) 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());
-        TransientTypeSystem transientTypeSystem = new TransientTypeSystem(enumDefs, structDefs, traitDefs, classDefs);
-        transientTypeSystem.verifyTypes(isUpdate);
-        return transientTypeSystem;
-    }
-
-    /**
-     * Commit the given types to this {@link TypeSystem} instance.
-     *
-     * This step should be called only after the types have been committed to the backend stores successfully.
-     * @param typesAdded newly added types.
-     * @throws AtlasException
-     */
-    public void commitTypes(Map<String, IDataType> typesAdded) throws AtlasException {
-        for (Map.Entry<String, IDataType> typeEntry : typesAdded.entrySet()) {
-            IDataType type = typeEntry.getValue();
-            //Add/replace the new type in the typesystem
-            typeCache.put(type);
-        }
-    }
-
-    public class TransientTypeSystem extends TypeSystem {
-
-        final ImmutableList<StructTypeDefinition> structDefs;
-        final ImmutableList<HierarchicalTypeDefinition<TraitType>> traitDefs;
-        final ImmutableList<HierarchicalTypeDefinition<ClassType>> classDefs;
-        private final ImmutableList<EnumTypeDefinition> enumDefs;
-
-        Map<String, StructTypeDefinition> structNameToDefMap = new HashMap<>();
-        Map<String, HierarchicalTypeDefinition<TraitType>> traitNameToDefMap = new HashMap<>();
-        Map<String, HierarchicalTypeDefinition<ClassType>> classNameToDefMap = new HashMap<>();
-
-        Map<String, IDataType> transientTypes = null;
-
-        List<AttributeInfo> recursiveRefs = new ArrayList<>();
-        List<DataTypes.ArrayType> recursiveArrayTypes = new ArrayList<>();
-        List<DataTypes.MapType> recursiveMapTypes = new ArrayList<>();
-
-
-        TransientTypeSystem(ImmutableList<EnumTypeDefinition> enumDefs, ImmutableList<StructTypeDefinition> structDefs,
-                            ImmutableList<HierarchicalTypeDefinition<TraitType>> traitDefs,
-                            ImmutableList<HierarchicalTypeDefinition<ClassType>> classDefs) {
-            this.enumDefs = enumDefs;
-            this.structDefs = structDefs;
-            this.traitDefs = traitDefs;
-            this.classDefs = classDefs;
-            transientTypes = new HashMap<>();
-        }
-
-        private IDataType dataType(String name) throws AtlasException {
-            if (transientTypes.containsKey(name)) {
-                return transientTypes.get(name);
-            }
-
-            return TypeSystem.this.getDataType(IDataType.class, name);
-        }
-
-        /*
-         * Step 1:
-         * - validate cannot redefine types
-         * - setup shallow Type instances to facilitate recursive type graphs
-         */
-        private void validateAndSetupShallowTypes(boolean update) throws AtlasException {
-            for (EnumTypeDefinition eDef : enumDefs) {
-                assert eDef.name != null;
-                if (!update) {
-                    if (TypeSystem.this.isRegistered(eDef.name)) {
-                        throw new TypeExistsException(String.format("Redefinition of type %s is not supported", eDef.name));
-                    } else if (transientTypes.containsKey(eDef.name)) {
-                        LOG.warn("Found duplicate definition of type {}. Ignoring..", eDef.name);
-                        continue;
-                    }
-                }
-
-                EnumType eT = new EnumType(this, eDef.name, eDef.description, eDef.version, eDef.enumValues);
-                transientTypes.put(eDef.name, eT);
-            }
-
-            for (StructTypeDefinition sDef : structDefs) {
-                assert sDef.typeName != null;
-                if (!update) {
-                    if (TypeSystem.this.isRegistered(sDef.typeName)) {
-                        throw new TypeExistsException(String.format("Redefinition of type %s is not supported", sDef.typeName));
-                    } else if (transientTypes.containsKey(sDef.typeName)) {
-                        LOG.warn("Found duplicate definition of type {}. Ignoring..", sDef.typeName);
-                        continue;
-                    }
-                }
-
-                StructType sT = new StructType(this, sDef.typeName, sDef.typeDescription, sDef.typeVersion, sDef.attributeDefinitions.length);
-                structNameToDefMap.put(sDef.typeName, sDef);
-                transientTypes.put(sDef.typeName, sT);
-            }
-
-            for (HierarchicalTypeDefinition<TraitType> traitDef : traitDefs) {
-                assert traitDef.typeName != null;
-                if (!update) {
-                    if (TypeSystem.this.isRegistered(traitDef.typeName)) {
-                        throw new TypeExistsException(String.format("Redefinition of type %s is not supported", traitDef.typeName));
-                    } else if (transientTypes.containsKey(traitDef.typeName)) {
-                        LOG.warn("Found duplicate definition of type {}. Ignoring..", traitDef.typeName);
-                        continue;
-                    }
-                }
-
-                TraitType tT = new TraitType(this, traitDef.typeName, traitDef.typeDescription, traitDef.typeVersion, traitDef.superTypes,
-                        traitDef.attributeDefinitions.length);
-                traitNameToDefMap.put(traitDef.typeName, traitDef);
-                transientTypes.put(traitDef.typeName, tT);
-            }
-
-            for (HierarchicalTypeDefinition<ClassType> classDef : classDefs) {
-                assert classDef.typeName != null;
-                if (!update) {
-                    if (TypeSystem.this.isRegistered(classDef.typeName)) {
-                        throw new TypeExistsException(String.format("Redefinition of type %s is not supported", classDef.typeName));
-                    } else if (transientTypes.containsKey(classDef.typeName)) {
-                        LOG.warn("Found duplicate definition of type {}. Ignoring..", classDef.typeName);
-                        continue;
-                    }
-                }
-
-                ClassType cT = new ClassType(this, classDef.typeName, classDef.typeDescription, classDef.typeVersion, classDef.superTypes,
-                        classDef.attributeDefinitions.length);
-                classNameToDefMap.put(classDef.typeName, classDef);
-                transientTypes.put(classDef.typeName, cT);
-            }
-        }
-
-        @Override
-        public boolean isRegistered(String typeName) throws AtlasException {
-            return transientTypes.containsKey(typeName) || TypeSystem.this.isRegistered(typeName);
-        }
-
-        private <U extends HierarchicalType> void validateSuperTypes(Class<U> cls, HierarchicalTypeDefinition<U> def)
-        throws AtlasException {
-            for (String superTypeName : def.superTypes) {
-
-                IDataType dT = dataType(superTypeName);
-
-                if (dT == null) {
-                    throw new AtlasException(
-                            String.format("Unknown superType %s in definition of type %s", superTypeName,
-                                    def.typeName));
-                }
-
-                if (!cls.isAssignableFrom(dT.getClass())) {
-                    throw new AtlasException(
-                            String.format("SuperType %s must be a %s, in definition of type %s", superTypeName,
-                                    cls.getName(), def.typeName));
-                }
-            }
-        }
-
-        /*
-         * Step 2:
-         * - for Hierarchical Types, validate SuperTypes.
-         * - for each Hierarchical Type setup their SuperTypes Graph
-         */
-        private void validateAndSetupSuperTypes() throws AtlasException {
-            for (HierarchicalTypeDefinition<TraitType> traitDef : traitDefs) {
-                validateSuperTypes(TraitType.class, traitDef);
-                TraitType traitType = getDataType(TraitType.class, traitDef.typeName);
-                traitType.setupSuperTypesGraph();
-            }
-
-            for (HierarchicalTypeDefinition<ClassType> classDef : classDefs) {
-                validateSuperTypes(ClassType.class, classDef);
-                ClassType classType = getDataType(ClassType.class, classDef.typeName);
-                classType.setupSuperTypesGraph();
-            }
-        }
-
-        private AttributeInfo constructAttributeInfo(AttributeDefinition attrDef) throws AtlasException {
-            AttributeInfo info = new AttributeInfo(this, attrDef, null);
-            if (transientTypes.keySet().contains(attrDef.dataTypeName)) {
-                recursiveRefs.add(info);
-            }
-            if (info.dataType().getTypeCategory() == DataTypes.TypeCategory.ARRAY) {
-                DataTypes.ArrayType arrType = (DataTypes.ArrayType) info.dataType();
-                if (transientTypes.keySet().contains(arrType.getElemType().getName())) {
-                    recursiveArrayTypes.add(arrType);
-                }
-            }
-            if (info.dataType().getTypeCategory() == DataTypes.TypeCategory.MAP) {
-                DataTypes.MapType mapType = (DataTypes.MapType) info.dataType();
-                if (transientTypes.keySet().contains(mapType.getKeyType().getName())) {
-                    recursiveMapTypes.add(mapType);
-                } else if (transientTypes.keySet().contains(mapType.getValueType().getName())) {
-                    recursiveMapTypes.add(mapType);
-                }
-            }
-
-            if (info.multiplicity.upper > 1 && !(info.dataType().getTypeCategory() == DataTypes.TypeCategory.MAP
-                    || info.dataType().getTypeCategory() == DataTypes.TypeCategory.ARRAY)) {
-                throw new AtlasException(
-                        String.format("A multiplicty of more than one requires a collection type for attribute '%s'",
-                                info.name));
-            }
-
-            return info;
-        }
-
-        private StructType constructStructureType(StructTypeDefinition def) throws AtlasException {
-            AttributeInfo[] infos = new AttributeInfo[def.attributeDefinitions.length];
-            for (int i = 0; i < def.attributeDefinitions.length; i++) {
-                infos[i] = constructAttributeInfo(def.attributeDefinitions[i]);
-            }
-
-            StructType type = new StructType(this, def.typeName, def.typeDescription, def.typeVersion, infos);
-            transientTypes.put(def.typeName, type);
-            return type;
-        }
-
-        private <U extends HierarchicalType> U constructHierarchicalType(Class<U> cls,
-                HierarchicalTypeDefinition<U> def) throws AtlasException {
-            AttributeInfo[] infos = new AttributeInfo[def.attributeDefinitions.length];
-            for (int i = 0; i < def.attributeDefinitions.length; i++) {
-                infos[i] = constructAttributeInfo(def.attributeDefinitions[i]);
-            }
-
-            try {
-                Constructor<U> cons = cls.getDeclaredConstructor(TypeSystem.class, String.class, String.class, String.class, ImmutableSet.class,
-                        AttributeInfo[].class);
-                U type = cons.newInstance(this, def.typeName, def.typeDescription, def.typeVersion, def.superTypes, infos);
-                transientTypes.put(def.typeName, type);
-                return type;
-            } catch (Exception e) {
-                e.printStackTrace();
-                throw new AtlasException(String.format("Cannot construct Type of MetaType %s - %s", cls.getName(), def.typeName), e);
-            }
-        }
-
-        /*
-         * Step 3:
-         * - Order Hierarchical Types in order of SuperType before SubType.
-         * - Construct all the Types
-         */
-        private void orderAndConstructTypes() throws AtlasException {
-
-            List<TraitType> traitTypes = new ArrayList<>();
-            for (String traitTypeName : traitNameToDefMap.keySet()) {
-                traitTypes.add(getDataType(TraitType.class, traitTypeName));
-            }
-            traitTypes = HierarchicalTypeDependencySorter.sortTypes(traitTypes);
-
-            List<ClassType> classTypes = new ArrayList<>();
-            for (String classTypeName : classNameToDefMap.keySet()) {
-                classTypes.add(getDataType(ClassType.class, classTypeName));
-            }
-            classTypes = HierarchicalTypeDependencySorter.sortTypes(classTypes);
-
-            for (StructTypeDefinition structDef : structDefs) {
-                constructStructureType(structDef);
-            }
-
-            for (TraitType traitType : traitTypes) {
-                constructHierarchicalType(TraitType.class, traitNameToDefMap.get(traitType.getName()));
-            }
-
-            for (ClassType classType : classTypes) {
-                constructHierarchicalType(ClassType.class, classNameToDefMap.get(classType.getName()));
-            }
-        }
-
-        /*
-         * Step 4:
-         * - fix up references in recursive AttrInfo and recursive Collection Types.
-         */
-        private void setupRecursiveTypes() throws AtlasException {
-            for (AttributeInfo info : recursiveRefs) {
-                info.setDataType(dataType(info.dataType().getName()));
-            }
-            for (DataTypes.ArrayType arrType : recursiveArrayTypes) {
-                arrType.setElemType(dataType(arrType.getElemType().getName()));
-            }
-            for (DataTypes.MapType mapType : recursiveMapTypes) {
-                mapType.setKeyType(dataType(mapType.getKeyType().getName()));
-                mapType.setValueType(dataType(mapType.getValueType().getName()));
-            }
-        }
-
-        /**
-         * Step 5:
-         * - Validate that the update can be done
-         */
-        private void validateUpdateIsPossible() throws TypeUpdateException, AtlasException {
-            //If the type is modified, validate that update can be done
-            for (IDataType newType : transientTypes.values()) {
-                IDataType oldType = null;
-                try {
-                    oldType = TypeSystem.this.getDataType(IDataType.class, newType.getName());
-                } catch (TypeNotFoundException e) {
-                    LOG.debug(String.format("No existing type %s found - update OK", newType.getName()));
-                }
-                if (oldType != null) {
-                    oldType.validateUpdate(newType);
-                }
-            }
-        }
-
-        Map<String, IDataType> defineTypes(boolean update) throws AtlasException {
-            verifyTypes(update);
-            Map<String, IDataType> typesAdded = getTypesAdded();
-            commitTypes(typesAdded);
-            return typesAdded;
-        }
-
-        @Override
-        public ImmutableList<String> getTypeNames() throws AtlasException {
-            Set<String> typeNames = transientTypes.keySet();
-            typeNames.addAll(TypeSystem.this.getTypeNames());
-            return ImmutableList.copyOf(typeNames);
-        }
-
-        //get from transient types. Else, from main type system
-        @Override
-        public IDataType getDataType(String name) throws AtlasException {
-
-            if (transientTypes != null) {
-                if (transientTypes.containsKey(name)) {
-                    return transientTypes.get(name);
-                }
-
-            /*
-             * is this an Array Type?
-             */
-                String arrElemType = TypeUtils.parseAsArrayType(name);
-                if (arrElemType != null) {
-                    IDataType dT = defineArrayType(getDataType(IDataType.class, arrElemType));
-                    return dT;
-                }
-
-            /*
-             * is this a Map Type?
-             */
-                String[] mapType = TypeUtils.parseAsMapType(name);
-                if (mapType != null) {
-                    IDataType dT =
-                            defineMapType(getDataType(IDataType.class, mapType[0]), getDataType(IDataType.class, mapType[1]));
-                    return dT;
-                }
-            }
-
-            return TypeSystem.this.getDataType(name);
-        }
-
-        @Override
-        public StructType defineStructType(String name, boolean errorIfExists, AttributeDefinition... attrDefs)
-        throws AtlasException {
-            throw new AtlasException("Internal Error: define type called on TransientTypeSystem");
-        }
-
-        @Override
-        public TraitType defineTraitType(HierarchicalTypeDefinition traitDef) throws AtlasException {
-            throw new AtlasException("Internal Error: define type called on TransientTypeSystem");
-        }
-
-        @Override
-        public ClassType defineClassType(HierarchicalTypeDefinition<ClassType> classDef) throws AtlasException {
-            throw new AtlasException("Internal Error: define type called on TransientTypeSystem");
-        }
-
-        @Override
-        public Map<String, IDataType> defineTypes(ImmutableList<EnumTypeDefinition> enumDefs,
-                ImmutableList<StructTypeDefinition> structDefs,
-                ImmutableList<HierarchicalTypeDefinition<TraitType>> traitDefs,
-                ImmutableList<HierarchicalTypeDefinition<ClassType>> classDefs) throws AtlasException {
-            throw new AtlasException("Internal Error: define type called on TransientTypeSystem");
-        }
-
-        @Override
-        public DataTypes.ArrayType defineArrayType(IDataType elemType) throws AtlasException {
-            return super.defineArrayType(elemType);
-        }
-
-        @Override
-        public DataTypes.MapType defineMapType(IDataType keyType, IDataType valueType) throws AtlasException {
-            return super.defineMapType(keyType, valueType);
-        }
-
-        void verifyTypes(boolean isUpdate) throws AtlasException {
-            validateAndSetupShallowTypes(isUpdate);
-            validateAndSetupSuperTypes();
-            orderAndConstructTypes();
-            setupRecursiveTypes();
-            if (isUpdate) {
-                validateUpdateIsPossible();
-            }
-        }
-
-        @Override
-        public void commitTypes(Map<String, IDataType> typesAdded) throws AtlasException {
-            TypeSystem.this.commitTypes(typesAdded);
-        }
-
-        public Map<String, IDataType> getTypesAdded() {
-            return new HashMap<>(transientTypes);
-        }
-
-        /**
-         * The core types do not change and they are registered
-         * once in the main type system.
-         */
-        @Override
-        public ImmutableList<String> getCoreTypes() {
-            return TypeSystem.this.getCoreTypes();
-        }
-    }
-
-    public class IdType {
-        private static final String ID_ATTRNAME = "guid";
-        private static final String TYPENAME_ATTRNAME = "typeName";
-        private static final String STATE_ATTRNAME = "state";
-        private static final String VERSION_ATTRNAME = "version";
-        private static final String TYP_NAME = "__IdType";
-
-        private StructType type;
-
-        private IdType() {
-            AttributeDefinition idAttr =
-                    new AttributeDefinition(ID_ATTRNAME, DataTypes.STRING_TYPE.getName(), Multiplicity.REQUIRED, false,
-                            null);
-            AttributeDefinition typNmAttr =
-                    new AttributeDefinition(TYPENAME_ATTRNAME, DataTypes.STRING_TYPE.getName(), Multiplicity.REQUIRED,
-                            false, null);
-            AttributeDefinition stateAttr =
-                    new AttributeDefinition(STATE_ATTRNAME, DataTypes.STRING_TYPE.getName(), Multiplicity.REQUIRED,
-                            false, null);
-            AttributeDefinition versionAttr =
-                    new AttributeDefinition(VERSION_ATTRNAME, DataTypes.INT_TYPE.getName(), Multiplicity.REQUIRED,
-                            false, null);
-            try {
-                AttributeInfo[] infos = new AttributeInfo[4];
-                infos[0] = new AttributeInfo(TypeSystem.this, idAttr, null);
-                infos[1] = new AttributeInfo(TypeSystem.this, typNmAttr, null);
-                infos[2] = new AttributeInfo(TypeSystem.this, stateAttr, null);
-                infos[3] = new AttributeInfo(TypeSystem.this, versionAttr, null);
-
-                type = new StructType(TypeSystem.this, TYP_NAME, null, infos);
-            } catch (AtlasException me) {
-                throw new RuntimeException(me);
-            }
-        }
-
-        public StructType getStructType() {
-            return type;
-        }
-
-        public String getName() {
-            return TYP_NAME;
-        }
-
-        public String idAttrName() {
-            return ID_ATTRNAME;
-        }
-
-        public String typeNameAttrName() {
-            return TYPENAME_ATTRNAME;
-        }
-
-        public String stateAttrName() {
-            return STATE_ATTRNAME;
-        }
-
-        public String versionAttrName() {
-            return VERSION_ATTRNAME;
-        }
-    }
-
-    public static final String ID_STRUCT_ID_ATTRNAME = IdType.ID_ATTRNAME;
-    public static final String ID_STRUCT_TYP_NAME = IdType.TYP_NAME;
-}

http://git-wip-us.apache.org/repos/asf/atlas/blob/0877e47c/typesystem/src/main/java/org/apache/atlas/typesystem/types/TypeUpdateException.java
----------------------------------------------------------------------
diff --git a/typesystem/src/main/java/org/apache/atlas/typesystem/types/TypeUpdateException.java b/typesystem/src/main/java/org/apache/atlas/typesystem/types/TypeUpdateException.java
deleted file mode 100644
index 33d1cb5..0000000
--- a/typesystem/src/main/java/org/apache/atlas/typesystem/types/TypeUpdateException.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * <p/>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p/>
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.atlas.typesystem.types;
-
-import org.apache.atlas.AtlasException;
-
-public class TypeUpdateException extends AtlasException {
-    public TypeUpdateException(IDataType newType) {
-        super(newType.getName() + " can't be updated");
-    }
-
-    public TypeUpdateException(IDataType newType, Exception e) {
-        super(newType.getName() + " can't be updated - " + e.getMessage(), e);
-    }
-
-    public TypeUpdateException(String message) {
-        super(message);
-    }
-
-    public TypeUpdateException(IDataType newType, String message) {
-        super(newType.getName() + " can't be updated - " + message);
-    }
-}

http://git-wip-us.apache.org/repos/asf/atlas/blob/0877e47c/typesystem/src/main/java/org/apache/atlas/typesystem/types/TypeUtils.java
----------------------------------------------------------------------
diff --git a/typesystem/src/main/java/org/apache/atlas/typesystem/types/TypeUtils.java b/typesystem/src/main/java/org/apache/atlas/typesystem/types/TypeUtils.java
deleted file mode 100755
index 6a14dc4..0000000
--- a/typesystem/src/main/java/org/apache/atlas/typesystem/types/TypeUtils.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.atlas.typesystem.types;
-
-import com.google.common.collect.ImmutableList;
-import org.apache.atlas.AtlasException;
-
-import java.io.IOException;
-import java.util.*;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-public class TypeUtils {
-
-    public static final String NAME_REGEX = "[a-zA-z][a-zA-Z0-9_]*";
-    public static final Pattern NAME_PATTERN = Pattern.compile(NAME_REGEX);
-    public static final Pattern ARRAY_TYPE_NAME_PATTERN = Pattern.compile(String.format("array<(%s)>", NAME_REGEX));
-    public static final Pattern MAP_TYPE_NAME_PATTERN =
-            Pattern.compile(String.format("map<(%s),(%s)>", NAME_REGEX, NAME_REGEX));
-
-    public static void outputVal(String val, Appendable buf, String prefix) throws AtlasException {
-        try {
-            buf.append(prefix).append(val);
-        } catch (IOException ie) {
-            throw new AtlasException(ie);
-        }
-    }
-
-    public static String parseAsArrayType(String typeName) {
-        Matcher m = ARRAY_TYPE_NAME_PATTERN.matcher(typeName);
-        return m.matches() ? m.group(1) : null;
-    }
-
-    public static String[] parseAsMapType(String typeName) {
-        Matcher m = MAP_TYPE_NAME_PATTERN.matcher(typeName);
-        return m.matches() ? new String[]{m.group(1), m.group(2)} : null;
-    }
-
-    public static Map<AttributeInfo, List<String>> buildAttrInfoToNameMap(FieldMapping f) {
-        Map<AttributeInfo, List<String>> b = new HashMap();
-        for (Map.Entry<String, AttributeInfo> e : f.fields.entrySet()) {
-            List<String> names = b.get(e.getValue());
-            if (names == null) {
-                names = new ArrayList<>();
-                b.put(e.getValue(), names);
-            }
-            names.add(e.getKey());
-        }
-        return b;
-    }
-
-    public static class Pair<L, R> {
-        public L left;
-        public R right;
-
-        public Pair(L left, R right) {
-            this.left = left;
-            this.right = right;
-        }
-
-        public static <L, R> Pair<L, R> of(L left, R right) {
-            return new Pair<>(left, right);
-        }
-
-        public boolean equals(Object o) {
-            if (this == o) {
-                return true;
-            }
-
-            if (o == null || getClass() != o.getClass()) {
-                return false;
-            }
-
-            Pair p = (Pair)o;
-
-            return Objects.equals(left, p.left) && Objects.equals(right, p.right);
-        }
-
-        public int hashCode() { return Objects.hash(left, right); }
-    }
-
-    /**
-     * Validates that the old field mapping can be replaced with new field mapping
-     * @param oldFieldMapping
-     * @param newFieldMapping
-     */
-    public static void validateUpdate(FieldMapping oldFieldMapping, FieldMapping newFieldMapping)
-            throws TypeUpdateException {
-        Map<String, AttributeInfo> newFields = newFieldMapping.fields;
-        for (AttributeInfo attribute : oldFieldMapping.fields.values()) {
-            if (newFields.containsKey(attribute.name)) {
-                AttributeInfo newAttribute = newFields.get(attribute.name);
-                //If old attribute is also in new definition, only allowed change is multiplicity change from REQUIRED to OPTIONAL
-                if (!newAttribute.equals(attribute)) {
-                    if (attribute.multiplicity == Multiplicity.REQUIRED
-                            && newAttribute.multiplicity == Multiplicity.OPTIONAL) {
-                        continue;
-                    } else {
-                        throw new TypeUpdateException("Attribute " + attribute.name + " can't be updated");
-                    }
-                }
-
-            } else {
-                //If old attribute is missing in new definition, return false as attributes can't be deleted
-                throw new TypeUpdateException("Old Attribute " + attribute.name + " is missing");
-            }
-        }
-
-        //Only new attributes
-        Set<String> newAttributes = new HashSet<>(ImmutableList.copyOf(newFields.keySet()));
-        newAttributes.removeAll(oldFieldMapping.fields.keySet());
-        for (String attributeName : newAttributes) {
-            AttributeInfo newAttribute = newFields.get(attributeName);
-            //New required attribute can't be added
-            if (newAttribute.multiplicity == Multiplicity.REQUIRED) {
-                throw new TypeUpdateException("Can't add required attribute " + attributeName);
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/atlas/blob/0877e47c/typesystem/src/main/java/org/apache/atlas/typesystem/types/TypedStructHandler.java
----------------------------------------------------------------------
diff --git a/typesystem/src/main/java/org/apache/atlas/typesystem/types/TypedStructHandler.java b/typesystem/src/main/java/org/apache/atlas/typesystem/types/TypedStructHandler.java
deleted file mode 100755
index 9afa873..0000000
--- a/typesystem/src/main/java/org/apache/atlas/typesystem/types/TypedStructHandler.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.atlas.typesystem.types;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
-
-import org.apache.atlas.AtlasException;
-import org.apache.atlas.typesystem.IStruct;
-import org.apache.atlas.typesystem.ITypedStruct;
-import org.apache.atlas.typesystem.Struct;
-import org.apache.atlas.typesystem.persistence.Id;
-import org.apache.atlas.typesystem.persistence.ReferenceableInstance;
-import org.apache.atlas.typesystem.persistence.StructInstance;
-
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.util.Date;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Set;
-
-public class TypedStructHandler {
-
-    private final IConstructableType<IStruct, ITypedStruct> structType;
-    private final FieldMapping fieldMapping;
-
-    public TypedStructHandler(IConstructableType<IStruct, ITypedStruct> structType) {
-        this.structType = structType;
-        fieldMapping = structType.fieldMapping();
-    }
-
-    public ITypedStruct convert(Object val, Multiplicity m) throws AtlasException {
-        if (val != null) {
-            if (val instanceof ITypedStruct) {
-                ITypedStruct ts = (ITypedStruct) val;
-                if (!Objects.equals(ts.getTypeName(), structType.getName())) {
-                    throw new ValueConversionException(structType, val);
-                }
-                return ts;
-            } else if (val instanceof Struct) {
-                Struct s = (Struct) val;
-                if (!s.typeName.equals(structType.getName())) {
-                    throw new ValueConversionException(structType, val);
-                }
-                ITypedStruct ts = createInstance();
-                for (Map.Entry<String, AttributeInfo> e : fieldMapping.fields.entrySet()) {
-                    String attrKey = e.getKey();
-                    AttributeInfo i = e.getValue();
-                    Object aVal = s.get(attrKey);
-                    try {
-                        ts.set(attrKey, aVal);
-                    } catch (ValueConversionException ve) {
-                        throw new ValueConversionException(structType, val, ve);
-                    }
-                }
-                return ts;
-            } else if (val instanceof StructInstance && Objects.equals(((StructInstance) val).getTypeName(), structType.getName())) {
-                return (StructInstance) val;
-            } else {
-                throw new ValueConversionException(structType, val);
-            }
-        }
-        if (!m.nullAllowed()) {
-            throw new ValueConversionException.NullConversionException(m);
-        }
-        return null;
-    }
-
-    public DataTypes.TypeCategory getTypeCategory() {
-        return DataTypes.TypeCategory.STRUCT;
-    }
-
-    public ITypedStruct createInstance() {
-        return new StructInstance(structType.getName(), fieldMapping, new boolean[fieldMapping.fields.size()],
-                new boolean[fieldMapping.fields.size()],
-                fieldMapping.numBools == 0 ? null : new boolean[fieldMapping.numBools],
-                fieldMapping.numBytes == 0 ? null : new byte[fieldMapping.numBytes],
-                fieldMapping.numShorts == 0 ? null : new short[fieldMapping.numShorts],
-                fieldMapping.numInts == 0 ? null : new int[fieldMapping.numInts],
-                fieldMapping.numLongs == 0 ? null : new long[fieldMapping.numLongs],
-                fieldMapping.numFloats == 0 ? null : new float[fieldMapping.numFloats],
-                fieldMapping.numDoubles == 0 ? null : new double[fieldMapping.numDoubles],
-                fieldMapping.numBigDecimals == 0 ? null : new BigDecimal[fieldMapping.numBigDecimals],
-                fieldMapping.numBigInts == 0 ? null : new BigInteger[fieldMapping.numBigInts],
-                fieldMapping.numDates == 0 ? null : new Date[fieldMapping.numDates],
-                fieldMapping.numStrings == 0 ? null : new String[fieldMapping.numStrings],
-                fieldMapping.numArrays == 0 ? null : new ImmutableList[fieldMapping.numArrays],
-                fieldMapping.numMaps == 0 ? null : new ImmutableMap[fieldMapping.numMaps],
-                fieldMapping.numStructs == 0 ? null : new StructInstance[fieldMapping.numStructs],
-                fieldMapping.numReferenceables == 0 ? null : new ReferenceableInstance[fieldMapping.numReferenceables],
-                fieldMapping.numReferenceables == 0 ? null : new Id[fieldMapping.numReferenceables]);
-    }
-
-    public void output(IStruct s, Appendable buf, String prefix, Set<IStruct> inProcess) throws AtlasException {
-        fieldMapping.output(s, buf, prefix, inProcess);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/atlas/blob/0877e47c/typesystem/src/main/java/org/apache/atlas/typesystem/types/ValueConversionException.java
----------------------------------------------------------------------
diff --git a/typesystem/src/main/java/org/apache/atlas/typesystem/types/ValueConversionException.java b/typesystem/src/main/java/org/apache/atlas/typesystem/types/ValueConversionException.java
deleted file mode 100755
index f756135..0000000
--- a/typesystem/src/main/java/org/apache/atlas/typesystem/types/ValueConversionException.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.atlas.typesystem.types;
-
-import org.apache.atlas.AtlasException;
-
-public class ValueConversionException extends AtlasException {
-
-    public ValueConversionException(IDataType typ, Object val) {
-        this(typ, val, (Throwable) null);
-    }
-
-    public ValueConversionException(IDataType typ, Object val, Throwable t) {
-        super(String.format("Cannot convert value '%s' to datatype %s", val.toString(), typ.getName()), t);
-    }
-
-    public ValueConversionException(IDataType typ, Object val, String msg) {
-        super(String
-                .format("Cannot convert value '%s' to datatype %s because: %s", val.toString(), typ.getName(), msg));
-    }
-
-    public ValueConversionException(String typeName, Object val, String msg) {
-        super(String.format("Cannot convert value '%s' to datatype %s because: %s", val.toString(), typeName, msg));
-    }
-
-    protected ValueConversionException(String msg) {
-        super(msg);
-    }
-
-    protected ValueConversionException(String msg, Exception e) {
-        super(msg, e);
-    }
-
-    public static class NullConversionException extends ValueConversionException {
-        public NullConversionException(Multiplicity m) {
-            super(String.format("Null value not allowed for multiplicty %s", m));
-        }
-
-        public NullConversionException(Multiplicity m, String msg){
-            super(String.format("Null value not allowed for multiplicty %s . Message %s", m, msg));
-        }
-
-        public NullConversionException(String msg, Exception e) {
-            super(msg, e);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/atlas/blob/0877e47c/typesystem/src/main/java/org/apache/atlas/typesystem/types/cache/DefaultTypeCache.java
----------------------------------------------------------------------
diff --git a/typesystem/src/main/java/org/apache/atlas/typesystem/types/cache/DefaultTypeCache.java b/typesystem/src/main/java/org/apache/atlas/typesystem/types/cache/DefaultTypeCache.java
deleted file mode 100644
index 0d86474..0000000
--- a/typesystem/src/main/java/org/apache/atlas/typesystem/types/cache/DefaultTypeCache.java
+++ /dev/null
@@ -1,301 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.atlas.typesystem.types.cache;
-
-import org.apache.atlas.AtlasException;
-import org.apache.atlas.annotation.ConditionalOnAtlasProperty;
-import org.apache.atlas.typesystem.types.ClassType;
-import org.apache.atlas.typesystem.types.DataTypes.TypeCategory;
-import org.apache.atlas.typesystem.types.EnumType;
-import org.apache.atlas.typesystem.types.HierarchicalType;
-import org.apache.atlas.typesystem.types.IDataType;
-import org.apache.atlas.typesystem.types.StructType;
-import org.apache.atlas.typesystem.types.TraitType;
-import org.apache.commons.lang.StringUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Component;
-
-import javax.inject.Singleton;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.concurrent.ConcurrentHashMap;
-
-/**
- * Caches the types in-memory within the same process space.
- */
-@SuppressWarnings("rawtypes")
-@Singleton
-@Component
-@ConditionalOnAtlasProperty(property = "atlas.TypeCache.impl", isDefault = true)
-public class DefaultTypeCache implements TypeCache {
-    private static final Logger LOG = LoggerFactory.getLogger(DefaultTypeCache.class);
-
-    private Map<String, IDataType> types_ = new ConcurrentHashMap<>();
-    private static final List<TypeCategory> validTypeFilterCategories =
-            Arrays.asList(TypeCategory.CLASS, TypeCategory.TRAIT, TypeCategory.ENUM, TypeCategory.STRUCT);
-    private static final List<TypeCategory> validSupertypeFilterCategories =
-            Arrays.asList(TypeCategory.CLASS, TypeCategory.TRAIT);
-
-    /*
-     * (non-Javadoc)
-     * @see
-     * org.apache.atlas.typesystem.types.cache.TypeCache#has(java.lang
-     * .String)
-     */
-    @Override
-    public boolean has(String typeName) throws AtlasException {
-
-        return types_.containsKey(typeName);
-    }
-
-    /* (non-Javadoc)
-     * @see org.apache.atlas.typesystem.types.cache.TypeCache#has(org.
-     * apache.atlas.typesystem.types.DataTypes.TypeCategory, java.lang.String)
-     */
-    @Override
-    public boolean has(TypeCategory typeCategory, String typeName)
-            throws AtlasException {
-
-        assertValidTypeCategory(typeCategory);
-        return has(typeName);
-    }
-
-    private void assertValidTypeCategory(String typeCategory) {
-        assertValidTypeCategory(TypeCategory.valueOf(typeCategory));
-    }
-
-    private void assertValidTypeCategory(TypeCategory typeCategory) {
-        // there might no need of 'typeCategory' in this implementation for
-        // certain API, but for a distributed cache, it might help for the
-        // implementers to partition the types per their category
-        // while persisting so that look can be efficient
-
-        if (typeCategory == null) {
-            throw new IllegalArgumentException("Category of the types to be filtered is null.");
-        }
-
-        if (!validTypeFilterCategories.contains(typeCategory)) {
-            throw new IllegalArgumentException("Category of the types should be one of " +
-                    StringUtils.join(validTypeFilterCategories, ", "));
-        }
-    }
-
-    /*
-     * (non-Javadoc)
-     * @see
-     * org.apache.atlas.typesystem.types.cache.TypeCache#get(java.lang
-     * .String)
-     */
-    @Override
-    public IDataType get(String typeName) throws AtlasException {
-
-        return types_.get(typeName);
-    }
-
-    /* (non-Javadoc)
-     * @see org.apache.atlas.typesystem.types.cache.TypeCache#get(org.apache.
-     * atlas.typesystem.types.DataTypes.TypeCategory, java.lang.String)
-     */
-    @Override
-    public IDataType get(TypeCategory typeCategory, String typeName) throws AtlasException {
-
-        assertValidTypeCategory(typeCategory);
-        return get(typeName);
-    }
-
-    /**
-     * Return the list of type names in the type system which match the specified filter.
-     *
-     * @return list of type names
-     * @param filterMap - Map of filter for type names. Valid keys are CATEGORY, SUPERTYPE, NOT_SUPERTYPE
-     * For example, CATEGORY = TRAIT && SUPERTYPE contains 'X' && SUPERTYPE !contains 'Y'
-     */
-    @Override
-    public Collection<String> getTypeNames(Map<TYPE_FILTER, String> filterMap) throws AtlasException {
-        assertFilter(filterMap);
-
-        List<String> typeNames = new ArrayList<>();
-        for (IDataType type : types_.values()) {
-            if (shouldIncludeType(type, filterMap)) {
-                typeNames.add(type.getName());
-            }
-        }
-        return typeNames;
-    }
-
-    private boolean shouldIncludeType(IDataType type, Map<TYPE_FILTER, String> filterMap) {
-        if (filterMap == null) {
-            return true;
-        }
-
-        for (Entry<TYPE_FILTER, String> filterEntry : filterMap.entrySet()) {
-            switch (filterEntry.getKey()) {
-            case CATEGORY:
-                if (!filterEntry.getValue().equals(type.getTypeCategory().name())) {
-                    return false;
-                }
-                break;
-
-            case SUPERTYPE:
-                if (!validSupertypeFilterCategories.contains(type.getTypeCategory()) ||
-                        !((HierarchicalType) type).getAllSuperTypeNames().contains(filterEntry.getValue())) {
-                    return false;
-                }
-                break;
-
-            case NOT_SUPERTYPE:
-                if (!validSupertypeFilterCategories.contains(type.getTypeCategory()) ||
-                        type.getName().equals(filterEntry.getValue()) ||
-                        ((HierarchicalType) type).getAllSuperTypeNames().contains(filterEntry.getValue())) {
-                    return false;
-                }
-                break;
-            }
-        }
-        return true;
-    }
-
-
-    private void assertFilter(Map<TYPE_FILTER, String> filterMap) throws AtlasException {
-        if (filterMap == null) {
-            return;
-        }
-
-        for (Entry<TYPE_FILTER, String> filterEntry : filterMap.entrySet()) {
-            switch (filterEntry.getKey()) {
-            case CATEGORY:
-                assertValidTypeCategory(filterEntry.getValue());
-                break;
-
-            case SUPERTYPE:
-            case NOT_SUPERTYPE:
-                if (!has(filterEntry.getValue())) {
-                    if (LOG.isDebugEnabled()) {
-                        LOG.debug("{}: supertype does not exist", filterEntry.getValue());
-                    }
-                }
-                break;
-
-            default:
-                throw new IllegalStateException("Unhandled filter " + filterEntry.getKey());
-            }
-        }
-    }
-
-    /*
-     * (non-Javadoc)
-     * @see
-     * org.apache.atlas.typesystem.types.cache.TypeCache#getAllNames()
-     */
-    @Override
-    public Collection<String> getAllTypeNames() throws AtlasException {
-
-        return types_.keySet();
-    }
-
-    /*
-     * (non-Javadoc)
-     * @see
-     * org.apache.atlas.typesystem.types.cache.TypeCache#put(org.apache
-     * .atlas.typesystem.types.IDataType)
-     */
-    @Override
-    public void put(IDataType type) throws AtlasException {
-
-        assertValidType(type);
-        types_.put(type.getName(), type);
-    }
-
-    private void assertValidType(IDataType type) throws
-        AtlasException {
-
-        if (type == null) {
-            throw new AtlasException("type is null.");
-        }
-
-        boolean validTypeCategory = (type instanceof ClassType) ||
-            (type instanceof TraitType) ||
-            (type instanceof EnumType) ||
-            (type instanceof StructType);
-
-        if (!validTypeCategory) {
-            throw new AtlasException("Category of the types should be one of ClassType | "
-                + "TraitType | EnumType | StructType.");
-        }
-    }
-
-    /*
-     * (non-Javadoc)
-     * @see
-     * org.apache.atlas.typesystem.types.cache.TypeCache#putAll(java
-     * .util.Collection)
-     */
-    @Override
-    public void putAll(Collection<IDataType> types) throws AtlasException {
-
-        for (IDataType type : types) {
-            assertValidType(type);
-            types_.put(type.getName(), type);
-        }
-    }
-
-    /*
-     * (non-Javadoc)
-     * @see
-     * org.apache.atlas.typesystem.types.cache.TypeCache#remove(java
-     * .lang.String)
-     */
-    @Override
-    public void remove(String typeName) throws AtlasException {
-
-        types_.remove(typeName);
-    }
-
-    /* (non-Javadoc)
-     * @see org.apache.atlas.typesystem.types.cache.TypeCache#remove(org.
-     * apache.atlas.typesystem.types.DataTypes.TypeCategory, java.lang.String)
-     */
-    @Override
-    public void remove(TypeCategory typeCategory, String typeName)
-            throws AtlasException {
-
-        assertValidTypeCategory(typeCategory);
-        remove(typeName);
-    }
-
-    /*
-     * (non-Javadoc)
-     * @see org.apache.atlas.typesystem.types.cache.TypeCache#clear()
-     */
-    @Override
-    public void clear() {
-
-        types_.clear();
-    }
-
-    @Override
-    public IDataType onTypeFault(String typeName) throws AtlasException {
-
-        return null;
-    }
-}

http://git-wip-us.apache.org/repos/asf/atlas/blob/0877e47c/typesystem/src/main/java/org/apache/atlas/typesystem/types/cache/TypeCache.java
----------------------------------------------------------------------
diff --git a/typesystem/src/main/java/org/apache/atlas/typesystem/types/cache/TypeCache.java b/typesystem/src/main/java/org/apache/atlas/typesystem/types/cache/TypeCache.java
deleted file mode 100644
index c8f65be..0000000
--- a/typesystem/src/main/java/org/apache/atlas/typesystem/types/cache/TypeCache.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.atlas.typesystem.types.cache;
-
-import org.apache.atlas.AtlasException;
-import org.apache.atlas.typesystem.types.DataTypes;
-import org.apache.atlas.typesystem.types.IDataType;
-import org.apache.atlas.typesystem.types.TypeSystem;
-
-import java.util.Collection;
-import java.util.Map;
-
-/**
- * The types are cached to allow faster lookup when type info is needed during
- * creation/updation of entities, DSL query translation/execution.
- * Implementations of this can chose to plugin a distributed cache
- * or an in-memory cache synched across nodes in an Altas cluster. <br>
- * <br>
- * Type entries in the cache can be one of ... <br>
- * {@link org.apache.atlas.typesystem.types.ClassType} <br>
- * {@link org.apache.atlas.typesystem.types.TraitType} <br>
- * {@link org.apache.atlas.typesystem.types.StructType} <br>
- * {@link org.apache.atlas.typesystem.types.EnumType}
- */
-@SuppressWarnings("rawtypes")
-public interface TypeCache {
-
-    enum TYPE_FILTER {
-        CATEGORY, SUPERTYPE, NOT_SUPERTYPE
-    }
-
-    /**
-     * @param typeName
-     * @return true if the type exists in cache, false otherwise.
-     * @throws AtlasException
-     */
-    boolean has(String typeName) throws AtlasException;
-
-    /**
-     * @param typeCategory Non-null category of type. The category can be one of
-     * TypeCategory.CLASS | TypeCategory.TRAIT | TypeCategory.STRUCT | TypeCategory.ENUM.
-     * @param typeName
-     * @return true if the type of given category exists in cache, false otherwise.
-     * @throws AtlasException
-     */
-    boolean has(DataTypes.TypeCategory typeCategory, String typeName) throws AtlasException;
-
-    /**
-     * @param typeName The name of the type.
-     * @return returns non-null type if cached, otherwise null
-     * @throws AtlasException
-     */
-    IDataType get(String typeName) throws AtlasException;
-
-    /**
-     * @param typeCategory Non-null category of type. The category can be one of
-     * TypeCategory.CLASS | TypeCategory.TRAIT | TypeCategory.STRUCT | TypeCategory.ENUM.
-     * @param typeName
-     * @return returns non-null type (of the specified category) if cached, otherwise null
-     * @throws AtlasException
-     */
-    IDataType get(DataTypes.TypeCategory typeCategory, String typeName) throws AtlasException;
-
-    /**
-     *
-     * @param filter @return
-     * @throws AtlasException
-     */
-    Collection<String> getTypeNames(Map<TYPE_FILTER, String> filter) throws AtlasException;
-
-    /**
-     * This is a convenience API to get the names of all types.
-     *
-     * @see TypeCache#getTypeNames(Map)
-     * @return
-     * @throws AtlasException
-     */
-    Collection<String> getAllTypeNames() throws AtlasException;
-
-    /**
-     * @param type The type to be added to the cache. The type should not be
-     * null, otherwise throws NullPointerException. <br>
-     * Type entries in the cache can be one of ... <br>
-     * {@link org.apache.atlas.typesystem.types.ClassType} <br>
-     * {@link org.apache.atlas.typesystem.types.TraitType} <br>
-     * {@link org.apache.atlas.typesystem.types.StructType} <br>
-     * {@link org.apache.atlas.typesystem.types.EnumType}
-     * @throws AtlasException
-     */
-    void put(IDataType type) throws AtlasException;
-
-    /**
-     * @param types The types to be added to the cache. The type should not be
-     * null, otherwise throws NullPointerException. <br>
-     * Type entries in the cache can be one of ... <br>
-     * {@link org.apache.atlas.typesystem.types.ClassType} <br>
-     * {@link org.apache.atlas.typesystem.types.TraitType} <br>
-     * {@link org.apache.atlas.typesystem.types.StructType} <br>
-     * {@link org.apache.atlas.typesystem.types.EnumType}
-     * @throws AtlasException
-     */
-    void putAll(Collection<IDataType> types) throws AtlasException;
-
-    /**
-     * @param typeName Name of the type to be removed from the cache. If type
-     * exists, it will be removed, otherwise does nothing.
-     * @throws AtlasException
-     */
-    void remove(String typeName) throws AtlasException;
-
-    /**
-     * @param typeCategory Non-null category of type. The category can be one of
-     * TypeCategory.CLASS | TypeCategory.TRAIT | TypeCategory.STRUCT | TypeCategory.ENUM.
-     * @param typeName Name of the type to be removed from the cache. If type
-     * exists, it will be removed, otherwise does nothing.
-     * @throws AtlasException
-     */
-    void remove(DataTypes.TypeCategory typeCategory, String typeName) throws AtlasException;
-
-    /**
-     * Clear the type cache
-     *
-     */
-    void clear();
-
-    /**
-     * Called when a type lookup request on {@link TypeSystem}
-     * fails because the type is not present in the runtime type information.
-     * Implementations can take action such as retrieving the requested type
-     * from some persistent storage.
-
-     * @param typeName
-     * @throws AtlasException
-     */
-    IDataType onTypeFault(String typeName) throws AtlasException;
-
-}

http://git-wip-us.apache.org/repos/asf/atlas/blob/0877e47c/typesystem/src/main/java/org/apache/atlas/typesystem/types/utils/TypesUtil.java
----------------------------------------------------------------------
diff --git a/typesystem/src/main/java/org/apache/atlas/typesystem/types/utils/TypesUtil.java b/typesystem/src/main/java/org/apache/atlas/typesystem/types/utils/TypesUtil.java
deleted file mode 100755
index 39244dc..0000000
--- a/typesystem/src/main/java/org/apache/atlas/typesystem/types/utils/TypesUtil.java
+++ /dev/null
@@ -1,158 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.atlas.typesystem.types.utils;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableSet;
-
-import org.apache.atlas.AtlasException;
-import org.apache.atlas.typesystem.TypesDef;
-import org.apache.atlas.typesystem.types.AttributeDefinition;
-import org.apache.atlas.typesystem.types.AttributeInfo;
-import org.apache.atlas.typesystem.types.ClassType;
-import org.apache.atlas.typesystem.types.EnumTypeDefinition;
-import org.apache.atlas.typesystem.types.EnumValue;
-import org.apache.atlas.typesystem.types.FieldMapping;
-import org.apache.atlas.typesystem.types.HierarchicalType;
-import org.apache.atlas.typesystem.types.HierarchicalTypeDefinition;
-import org.apache.atlas.typesystem.types.IDataType;
-import org.apache.atlas.typesystem.types.Multiplicity;
-import org.apache.atlas.typesystem.types.StructType;
-import org.apache.atlas.typesystem.types.StructTypeDefinition;
-import org.apache.atlas.typesystem.types.TraitType;
-import org.apache.atlas.AtlasConstants;
-
-import org.apache.atlas.typesystem.types.TypeSystem;
-import scala.collection.JavaConversions;
-
-/**
- * Types utilities class.
- */
-public class TypesUtil {
-
-    private TypesUtil() {
-    }
-
-    public static AttributeDefinition createOptionalAttrDef(String name, IDataType dataType) {
-        return new AttributeDefinition(name, dataType.getName(), Multiplicity.OPTIONAL, false, null);
-    }
-
-    public static AttributeDefinition createOptionalAttrDef(String name, String dataType) {
-        return new AttributeDefinition(name, dataType, Multiplicity.OPTIONAL, false, null);
-    }
-
-    public static AttributeDefinition createRequiredAttrDef(String name, String dataType) {
-        return new AttributeDefinition(name, dataType, Multiplicity.REQUIRED, false, null);
-    }
-
-    public static AttributeDefinition createUniqueRequiredAttrDef(String name, IDataType dataType) {
-        return new AttributeDefinition(name, dataType.getName(), Multiplicity.REQUIRED, false, true, true, null);
-    }
-
-    public static AttributeDefinition createRequiredAttrDef(String name, IDataType dataType) {
-        return new AttributeDefinition(name, dataType.getName(), Multiplicity.REQUIRED, false, null);
-    }
-
-    public static EnumTypeDefinition createEnumTypeDef(String name, EnumValue... enumValues) {
-        return new EnumTypeDefinition(name, enumValues);
-    }
-
-    public static HierarchicalTypeDefinition<TraitType> createTraitTypeDef(String name,
-            ImmutableSet<String> superTypes, AttributeDefinition... attrDefs) {
-        return createTraitTypeDef(name, null, superTypes, attrDefs);
-    }
-
-    public static HierarchicalTypeDefinition<TraitType> createTraitTypeDef(String name, String description,
-        ImmutableSet<String> superTypes, AttributeDefinition... attrDefs) {
-        return createTraitTypeDef(name, description, AtlasConstants.DEFAULT_TYPE_VERSION, superTypes, attrDefs);
-    }
-
-    public static HierarchicalTypeDefinition<TraitType> createTraitTypeDef(String name, String description, String version,
-        ImmutableSet<String> superTypes, AttributeDefinition... attrDefs) {
-        return new HierarchicalTypeDefinition<>(TraitType.class, name, description, version, superTypes, attrDefs);
-    }
-
-    public static StructTypeDefinition createStructTypeDef(String name, AttributeDefinition... attrDefs) {
-        return createStructTypeDef(name, null, attrDefs);
-    }
-
-    public static StructTypeDefinition createStructTypeDef(String name, String description, AttributeDefinition... attrDefs) {
-        return new StructTypeDefinition(name, description, attrDefs);
-    }
-
-    public static StructTypeDefinition createStructTypeDef(String name, String description, String version, AttributeDefinition... attrDefs) {
-        return new StructTypeDefinition(name, description, version, attrDefs);
-    }
-
-    public static HierarchicalTypeDefinition<ClassType> createClassTypeDef(String name,
-            ImmutableSet<String> superTypes, AttributeDefinition... attrDefs) {
-        return createClassTypeDef(name, null, superTypes, attrDefs);
-    }
-
-    public static HierarchicalTypeDefinition<ClassType> createClassTypeDef(String name, String description,
-        ImmutableSet<String> superTypes, AttributeDefinition... attrDefs) {
-        return createClassTypeDef(name, description, AtlasConstants.DEFAULT_TYPE_VERSION, superTypes, attrDefs);
-    }
-
-    public static HierarchicalTypeDefinition<ClassType> createClassTypeDef(String name, String description, String version,
-        ImmutableSet<String> superTypes, AttributeDefinition... attrDefs) {
-        return new HierarchicalTypeDefinition<>(ClassType.class, name, description, version, superTypes, attrDefs);
-    }
-
-    public static TypesDef getTypesDef(ImmutableList<EnumTypeDefinition> enums,
-                                       ImmutableList<StructTypeDefinition> structs, ImmutableList<HierarchicalTypeDefinition<TraitType>> traits,
-                                       ImmutableList<HierarchicalTypeDefinition<ClassType>> classes) {
-        return new TypesDef(JavaConversions.asScalaBuffer(enums), JavaConversions.asScalaBuffer(structs),
-                JavaConversions.asScalaBuffer(traits), JavaConversions.asScalaBuffer(classes));
-    }
-
-    private static final TypeSystem ts = TypeSystem.getInstance();
-
-    public static AttributeInfo newAttributeInfo(String attribute, IDataType type) {
-        try {
-            return new AttributeInfo(ts, new AttributeDefinition(attribute, type.getName(), Multiplicity.REQUIRED,
-                    false, null), null);
-        } catch (AtlasException e) {
-            throw new RuntimeException(e);
-        }
-    }
-
-
-    /**
-     * Get the field mappings for the specified data type.
-     * Field mappings are only relevant for CLASS, TRAIT, and STRUCT types.
-     *
-     * @param type
-     * @return {@link FieldMapping} for the specified type
-     * @throws IllegalArgumentException if type is not a CLASS, TRAIT, or STRUCT type.
-     */
-    public static FieldMapping getFieldMapping(IDataType type) {
-        switch (type.getTypeCategory()) {
-        case CLASS:
-        case TRAIT:
-            return ((HierarchicalType)type).fieldMapping();
-
-        case STRUCT:
-            return ((StructType)type).fieldMapping();
-
-        default:
-            throw new IllegalArgumentException("Type " + type + " doesn't have any fields!");
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/atlas/blob/0877e47c/typesystem/src/main/scala/org/apache/atlas/typesystem/TypesDef.scala
----------------------------------------------------------------------
diff --git a/typesystem/src/main/scala/org/apache/atlas/typesystem/TypesDef.scala b/typesystem/src/main/scala/org/apache/atlas/typesystem/TypesDef.scala
deleted file mode 100755
index b51048d..0000000
--- a/typesystem/src/main/scala/org/apache/atlas/typesystem/TypesDef.scala
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.atlas.typesystem
-
-import org.apache.atlas.typesystem.types._
-
-case class TypesDef(enumTypes: Seq[EnumTypeDefinition],
-                    structTypes: Seq[StructTypeDefinition],
-                    traitTypes: Seq[HierarchicalTypeDefinition[TraitType]],
-                    classTypes: Seq[HierarchicalTypeDefinition[ClassType]]) {
-    def this() = this(Seq(), Seq(), Seq(), Seq())
-    def this(enumType : EnumTypeDefinition) = this(Seq(enumType), Seq(), Seq(), Seq())
-    def this(structType: StructTypeDefinition) = this(Seq(), Seq(structType), Seq(), Seq())
-    def this(typ: HierarchicalTypeDefinition[_], isTrait : Boolean) = this(
-      Seq(),
-      Seq(),
-      if ( isTrait )
-        Seq(typ.asInstanceOf[HierarchicalTypeDefinition[TraitType]]) else Seq(),
-      if (!isTrait )
-        Seq(typ.asInstanceOf[HierarchicalTypeDefinition[ClassType]]) else Seq()
-    )
-
-    def enumTypesAsJavaList() = {
-        import scala.collection.JavaConverters._
-        enumTypes.asJava
-    }
-
-    def structTypesAsJavaList() = {
-        import scala.collection.JavaConverters._
-        structTypes.asJava
-    }
-
-    def traitTypesAsJavaList() = {
-        import scala.collection.JavaConverters._
-        traitTypes.asJava
-    }
-
-    def classTypesAsJavaList() = {
-        import scala.collection.JavaConverters._
-        classTypes.asJava
-    }
-
-    def isEmpty() = {
-      enumTypes.isEmpty & structTypes.isEmpty & traitTypes.isEmpty & classTypes.isEmpty
-    }
-}

http://git-wip-us.apache.org/repos/asf/atlas/blob/0877e47c/typesystem/src/main/scala/org/apache/atlas/typesystem/builders/InstanceBuilder.scala
----------------------------------------------------------------------
diff --git a/typesystem/src/main/scala/org/apache/atlas/typesystem/builders/InstanceBuilder.scala b/typesystem/src/main/scala/org/apache/atlas/typesystem/builders/InstanceBuilder.scala
deleted file mode 100644
index 9e22f67..0000000
--- a/typesystem/src/main/scala/org/apache/atlas/typesystem/builders/InstanceBuilder.scala
+++ /dev/null
@@ -1,217 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.atlas.typesystem.builders
-
-import org.apache.atlas.typesystem.{IReferenceableInstance, IStruct, Referenceable, Struct}
-
-import scala.collection.JavaConversions._
-import scala.collection.JavaConverters._
-import scala.collection.mutable.ArrayBuffer
-import scala.language.{dynamics, implicitConversions}
-import scala.util.DynamicVariable
-
-class InstanceBuilder extends Dynamic {
-
-  private val references : ArrayBuffer[Referenceable] = new ArrayBuffer[Referenceable]()
-
-  val context = new DynamicVariable[DynamicStruct](null)
-
-  def struct(typeName : String) : DynamicStruct = {
-    context.value = new DynamicStruct(this, new Struct(typeName))
-    context.value
-  }
-
-  def instance(typeName: String, traitNames: String*)(f : => Unit) : DynamicReference = {
-    val r = new Referenceable(typeName, traitNames:_*)
-    references.append(r)
-    val dr = new DynamicReference(this, r)
-    context.withValue(dr){f}
-    dr
-  }
-
-  def create( f : => Unit ) : java.util.List[Referenceable] = {
-    f
-    references.asJava
-  }
-
-  def applyDynamic(name : String)(value : Any) : Any = {
-    context.value.updateDynamic(name)(value)
-  }
-
-  implicit def symbolToDynamicStruct(s : Symbol) : DynamicValue =
-    new DynamicValue(this, s.name, if (context.value == null) null else context.value.s)
-
-}
-
-object DynamicValue {
-
-  private[builders] def transformOut(s: IStruct, attr : String, v : Any)(implicit ib : InstanceBuilder) : DynamicValue =
-    v match {
-    case r : Referenceable => new DynamicReference(ib, r)
-    case s : Struct => new DynamicStruct(ib, s)
-    case jL : java.util.List[_] => {
-      if ( s != null ) {
-        new DynamicCollection(ib, attr, s)
-      } else {
-        new DynamicValue(ib, attr, s, jL.map { e => transformOut(null, null, e) })
-      }
-    }
-    case jM : java.util.Map[_,_] => {
-      if ( s != null ) {
-        new DynamicMap(ib, attr, s)
-      } else {
-        new DynamicValue(ib, attr, s, jM.map {
-          case (k, v) => k -> transformOut(null, null, v)
-        }.toMap)
-      }
-    }
-    case x => {
-      if ( s != null ) {
-        new DynamicValue(ib, attr, s)
-      } else {
-        new DynamicValue(ib, attr, s, x)
-      }
-    }
-  }
-
-  private[builders] def transformIn(v : Any) : Any = v match {
-    case dr : DynamicReference => dr.r
-    case ds : DynamicStruct => ds.s
-    case dv : DynamicValue => dv.get
-    case l : Seq[_] => l.map{ e => transformIn(e)}.asJava
-    case m : Map[_,_] => m.map {
-      case (k,v) => k -> transformIn(v)
-    }.asJava
-    case x => x
-  }
-
-}
-
-class DynamicValue(val ib : InstanceBuilder, val attrName : String, val s: IStruct, var value : Any = null) extends Dynamic {
-  import DynamicValue._
-
-  implicit val iib : InstanceBuilder = ib
-
-  def ~(v : Any): Unit = {
-    if ( s != null ) {
-      s.set(attrName, transformIn(v))
-    } else {
-      value = v
-    }
-  }
-
-  def get : Any = if ( s != null ) s.get(attrName) else value
-
-  def selectDynamic(name: String) : DynamicValue = {
-
-    throw new UnsupportedOperationException()
-  }
-
-  def update(key : Any, value : Object): Unit = {
-    throw new UnsupportedOperationException()
-  }
-
-  def apply(key : Any): DynamicValue = {
-
-    if ( s != null && s.isInstanceOf[Referenceable] && key.isInstanceOf[String]) {
-      val r = s.asInstanceOf[Referenceable]
-      if ( r.getTraits contains attrName ) {
-        val traitAttr = key.asInstanceOf[String]
-        return new DynamicStruct(ib, r.getTrait(attrName)).selectDynamic(traitAttr)
-      }
-    }
-    throw new UnsupportedOperationException()
-  }
-}
-
-class DynamicCollection(ib : InstanceBuilder, attrName : String, s: IStruct) extends DynamicValue(ib, attrName ,s) {
-  import DynamicValue._
-
-  override def update(key : Any, value : Object): Unit = {
-    var jL = s.get(attrName)
-    val idx = key.asInstanceOf[Int]
-    if (jL == null ) {
-      val l = new java.util.ArrayList[Object]()
-      l.ensureCapacity(idx)
-      jL = l
-    }
-    val nJL = new java.util.ArrayList[Object](jL.asInstanceOf[java.util.List[Object]])
-    nJL.asInstanceOf[java.util.List[Object]].set(idx, transformIn(value).asInstanceOf[Object])
-    s.set(attrName, nJL)
-  }
-
-  override def apply(key : Any): DynamicValue = {
-    var jL = s.get(attrName)
-    val idx = key.asInstanceOf[Int]
-    if (jL == null ) {
-      null
-    } else {
-      transformOut(null, null, jL.asInstanceOf[java.util.List[Object]].get(idx))
-    }
-  }
-}
-
-class DynamicMap(ib : InstanceBuilder, attrName : String, s: IStruct) extends DynamicValue(ib, attrName ,s) {
-  import DynamicValue._
-  override def update(key : Any, value : Object): Unit = {
-    var jM = s.get(attrName)
-    if (jM == null ) {
-      jM = new java.util.HashMap[Object, Object]()
-    }
-    jM.asInstanceOf[java.util.Map[Object, Object]].put(key.asInstanceOf[AnyRef], value)
-  }
-
-  override def apply(key : Any): DynamicValue = {
-    var jM = s.get(attrName)
-    if (jM == null ) {
-      null
-    } else {
-      transformOut(null, null, jM.asInstanceOf[java.util.Map[Object, Object]].get(key))
-    }
-  }
-}
-
-class DynamicStruct(ib : InstanceBuilder, s: IStruct) extends DynamicValue(ib, null ,s) {
-  import DynamicValue._
-  override def selectDynamic(name: String) : DynamicValue = {
-    transformOut(s, name, s.get(name))
-  }
-
-  def updateDynamic(name: String)(value: Any) {
-    s.set(name, transformIn(value))
-  }
-
-  override def ~(v : Any): Unit = { throw new UnsupportedOperationException()}
-  override def get : Any = s
-
-}
-
-class DynamicReference(ib : InstanceBuilder, val r : IReferenceableInstance) extends DynamicStruct(ib, r) {
-
-  private def _trait(name : String) = new DynamicStruct(ib, r.getTrait(name))
-
-  override def selectDynamic(name: String) : DynamicValue = {
-    if ( r.getTraits contains name ) {
-      _trait(name)
-    } else {
-      super.selectDynamic(name)
-    }
-  }
-
-}