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:56 UTC

[34/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/repository/src/main/java/org/apache/atlas/query/Expressions.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/query/Expressions.java b/repository/src/main/java/org/apache/atlas/query/Expressions.java
new file mode 100644
index 0000000..9e93ce4
--- /dev/null
+++ b/repository/src/main/java/org/apache/atlas/query/Expressions.java
@@ -0,0 +1,45 @@
+/**
+ * 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.query;
+
+
+import java.util.List;
+
+public class Expressions {
+    public static class Expression {
+
+    }
+
+    public static class AliasExpression {
+        public String alias() {
+            String ret = null;
+
+            return ret;
+        }
+
+    }
+
+    public static class SelectExpression {
+        public List<AliasExpression> toJavaList() {
+            List<AliasExpression> ret = null;
+
+            return ret;
+        }
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/atlas/blob/0877e47c/repository/src/main/java/org/apache/atlas/query/GremlinQuery.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/query/GremlinQuery.java b/repository/src/main/java/org/apache/atlas/query/GremlinQuery.java
new file mode 100644
index 0000000..fcb1f48
--- /dev/null
+++ b/repository/src/main/java/org/apache/atlas/query/GremlinQuery.java
@@ -0,0 +1,42 @@
+/**
+ * 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.query;
+
+import org.apache.atlas.query.Expressions.Expression;
+
+
+public class GremlinQuery {
+
+    public boolean hasSelectList() {
+        boolean ret = false;
+
+        return ret;
+    }
+
+    public String queryStr() {
+        String ret = null;
+
+        return ret;
+    }
+
+    public Expression expr() {
+        Expression ret = null;
+
+        return ret;
+    }
+}

http://git-wip-us.apache.org/repos/asf/atlas/blob/0877e47c/repository/src/main/java/org/apache/atlas/query/GremlinTranslator.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/query/GremlinTranslator.java b/repository/src/main/java/org/apache/atlas/query/GremlinTranslator.java
new file mode 100644
index 0000000..5395ddd
--- /dev/null
+++ b/repository/src/main/java/org/apache/atlas/query/GremlinTranslator.java
@@ -0,0 +1,34 @@
+/**
+ * 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.query;
+
+import org.apache.atlas.query.Expressions.Expression;
+
+public class GremlinTranslator {
+    private Expression expression;
+
+    public GremlinTranslator(Expression expression) {
+        this.expression = expression;
+    }
+
+    public GremlinQuery translate() {
+        GremlinQuery ret = null;
+
+        return ret;
+    }
+}

http://git-wip-us.apache.org/repos/asf/atlas/blob/0877e47c/repository/src/main/java/org/apache/atlas/query/QueryParams.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/query/QueryParams.java b/repository/src/main/java/org/apache/atlas/query/QueryParams.java
new file mode 100644
index 0000000..5af8bc7
--- /dev/null
+++ b/repository/src/main/java/org/apache/atlas/query/QueryParams.java
@@ -0,0 +1,50 @@
+/**
+ * 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.query;
+
+
+public class QueryParams {
+    private int limit;
+    private int offset;
+
+    public QueryParams() {
+        this.limit  = -1;
+        this.offset = 0;
+    }
+
+    public QueryParams(int limit, int offset) {
+        this.limit  = limit;
+        this.offset = offset;
+    }
+
+    public int limit() {
+        return limit;
+    }
+
+    public void limit(int limit) {
+        this.limit = limit;
+    }
+
+    public int offset() {
+        return offset;
+    }
+
+    public void offset(int offset) {
+        this.offset = offset;
+    }
+}

http://git-wip-us.apache.org/repos/asf/atlas/blob/0877e47c/repository/src/main/java/org/apache/atlas/query/QueryParser.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/query/QueryParser.java b/repository/src/main/java/org/apache/atlas/query/QueryParser.java
new file mode 100644
index 0000000..3e5c297
--- /dev/null
+++ b/repository/src/main/java/org/apache/atlas/query/QueryParser.java
@@ -0,0 +1,36 @@
+/**
+ * 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.query;
+
+import org.apache.atlas.query.Expressions.Expression;
+
+
+import scala.util.Either;
+import scala.util.parsing.combinator.Parsers.NoSuccess;
+
+public class QueryParser {
+    public static boolean isKeyword(String word) {
+        return false; // TODO:
+    }
+
+    public static Either<NoSuccess, Expression> apply(String queryStr, QueryParams params) {
+        Either<NoSuccess, Expression> ret = null;
+
+        return ret;
+    }
+}

http://git-wip-us.apache.org/repos/asf/atlas/blob/0877e47c/repository/src/main/java/org/apache/atlas/query/QueryProcessor.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/query/QueryProcessor.java b/repository/src/main/java/org/apache/atlas/query/QueryProcessor.java
new file mode 100644
index 0000000..04cf0b4
--- /dev/null
+++ b/repository/src/main/java/org/apache/atlas/query/QueryProcessor.java
@@ -0,0 +1,28 @@
+/**
+ * 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.query;
+
+import org.apache.atlas.query.Expressions.Expression;
+
+public class QueryProcessor {
+    public static Expression validate(Expression expression) {
+        Expressions.Expression ret = null;
+
+        return ret;
+    }
+}

http://git-wip-us.apache.org/repos/asf/atlas/blob/0877e47c/repository/src/main/java/org/apache/atlas/query/SelectExpressionHelper.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/query/SelectExpressionHelper.java b/repository/src/main/java/org/apache/atlas/query/SelectExpressionHelper.java
new file mode 100644
index 0000000..80f0a7a
--- /dev/null
+++ b/repository/src/main/java/org/apache/atlas/query/SelectExpressionHelper.java
@@ -0,0 +1,30 @@
+/**
+ * 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.query;
+
+import org.apache.atlas.query.Expressions.Expression;
+import org.apache.atlas.query.Expressions.SelectExpression;
+import scala.Option;
+
+public class SelectExpressionHelper {
+    public static Option<SelectExpression> extractSelectExpression(Expression expr) {
+        Option<SelectExpression> ret = null;
+
+        return ret;
+    }
+}

http://git-wip-us.apache.org/repos/asf/atlas/blob/0877e47c/repository/src/main/java/org/apache/atlas/repository/DiscoverInstances.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/repository/DiscoverInstances.java b/repository/src/main/java/org/apache/atlas/repository/DiscoverInstances.java
deleted file mode 100755
index 6261499..0000000
--- a/repository/src/main/java/org/apache/atlas/repository/DiscoverInstances.java
+++ /dev/null
@@ -1,77 +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.repository;
-
-import org.apache.atlas.AtlasException;
-import org.apache.atlas.typesystem.IReferenceableInstance;
-import org.apache.atlas.typesystem.persistence.Id;
-import org.apache.atlas.typesystem.types.DataTypes;
-import org.apache.atlas.typesystem.types.ObjectGraphWalker;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Graph walker implementation for discovering instances.
- */
-@Deprecated
-public class DiscoverInstances implements ObjectGraphWalker.NodeProcessor {
-
-    public final Map<Id, Id> idToNewIdMap;
-    public final Map<Id, IReferenceableInstance> idToInstanceMap;
-    final IRepository repository;
-
-    public DiscoverInstances(IRepository repository) {
-        this.repository = repository;
-        idToNewIdMap = new HashMap<>();
-        idToInstanceMap = new HashMap<>();
-    }
-
-    @Override
-    public void processNode(ObjectGraphWalker.Node nd) throws AtlasException {
-
-        IReferenceableInstance ref = null;
-        Id id = null;
-
-        if (nd.attributeName == null) {
-            ref = (IReferenceableInstance) nd.instance;
-            id = ref.getId();
-        } else if (nd.aInfo.dataType().getTypeCategory() == DataTypes.TypeCategory.CLASS) {
-            if (nd.value != null && (nd.value instanceof Id)) {
-                id = (Id) nd.value;
-            }
-        }
-
-        if (id != null) {
-            if (id.isUnassigned()) {
-                if (!idToNewIdMap.containsKey(id)) {
-                    idToNewIdMap.put(id, repository.newId(id.typeName));
-                }
-                if (ref != null && idToInstanceMap.containsKey(ref)) {
-                    // Oops
-                    throw new RepositoryException(
-                            String.format("Unexpected internal error: Id %s processed again", id));
-                }
-                if (ref != null) {
-                    idToInstanceMap.put(id, ref);
-                }
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/atlas/blob/0877e47c/repository/src/main/java/org/apache/atlas/repository/IRepository.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/repository/IRepository.java b/repository/src/main/java/org/apache/atlas/repository/IRepository.java
deleted file mode 100755
index 1637e11..0000000
--- a/repository/src/main/java/org/apache/atlas/repository/IRepository.java
+++ /dev/null
@@ -1,51 +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.repository;
-
-import org.apache.atlas.typesystem.IReferenceableInstance;
-import org.apache.atlas.typesystem.ITypedReferenceableInstance;
-import org.apache.atlas.typesystem.persistence.Id;
-import org.apache.atlas.typesystem.types.ClassType;
-import org.apache.atlas.typesystem.types.HierarchicalType;
-import org.apache.atlas.typesystem.types.TraitType;
-
-import java.util.List;
-
-/**
- * Metadata Repository interface.
- */
-@Deprecated
-public interface IRepository {
-
-    ITypedReferenceableInstance create(IReferenceableInstance i) throws RepositoryException;
-
-    ITypedReferenceableInstance update(ITypedReferenceableInstance i) throws RepositoryException;
-
-    void delete(ITypedReferenceableInstance i) throws RepositoryException;
-
-    Id newId(String typeName);
-
-    ITypedReferenceableInstance get(Id id) throws RepositoryException;
-
-    void defineClass(ClassType type) throws RepositoryException;
-
-    void defineTrait(TraitType type) throws RepositoryException;
-
-    void defineTypes(List<HierarchicalType> types) throws RepositoryException;
-}

http://git-wip-us.apache.org/repos/asf/atlas/blob/0877e47c/repository/src/main/java/org/apache/atlas/repository/MetadataRepository.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/repository/MetadataRepository.java b/repository/src/main/java/org/apache/atlas/repository/MetadataRepository.java
deleted file mode 100644
index b72ee7d..0000000
--- a/repository/src/main/java/org/apache/atlas/repository/MetadataRepository.java
+++ /dev/null
@@ -1,198 +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.repository;
-
-import org.apache.atlas.AtlasException;
-import org.apache.atlas.CreateUpdateEntitiesResult;
-import org.apache.atlas.model.legacy.EntityResult;
-import org.apache.atlas.typesystem.ITypedReferenceableInstance;
-import org.apache.atlas.typesystem.ITypedStruct;
-import org.apache.atlas.typesystem.exception.EntityExistsException;
-import org.apache.atlas.typesystem.exception.EntityNotFoundException;
-import org.apache.atlas.typesystem.exception.TraitNotFoundException;
-import org.apache.atlas.typesystem.types.AttributeInfo;
-import org.apache.atlas.typesystem.types.IDataType;
-
-import java.util.List;
-
-/**
- * An interface for persisting metadata into a blueprints enabled graph db.
- */
-@Deprecated
-public interface MetadataRepository {
-
-    /**
-     * Returns the property key used to store entity type name.
-     *
-     * @return property key used to store entity type name.
-     */
-    String getTypeAttributeName();
-
-    /**
-     * Returns the property key used to store super type names.
-     *
-     * @return property key used to store super type names.
-     */
-    String getSuperTypeAttributeName();
-
-    /**
-     * Returns the attribute name used for entity state
-     * @return
-     */
-    String getStateAttributeName();
-    /**
-     * Returns the attribute name used for entity version
-     * @return
-     */
-    String getVersionAttributeName();
-
-    /**
-     * Return the property key used to store a given traitName in the repository.
-     *
-     * @param dataType  data type
-     * @param traitName trait name
-     * @return property key used to store a given traitName
-     */
-    String getTraitLabel(IDataType<?> dataType, String traitName);
-
-    /**
-     * Return the property key used to store a given attribute in the repository.
-     *
-     * @param dataType data type
-     * @param aInfo    attribute info
-     * @return property key used to store a given attribute
-     */
-    String getFieldNameInVertex(IDataType<?> dataType, AttributeInfo aInfo) throws AtlasException;
-
-    /**
-     * Return the edge label for a given attribute in the repository.
-     *
-     * @param dataType  data type
-     * @param aInfo    attribute info
-     * @return edge label for a given attribute
-     */
-    String getEdgeLabel(IDataType<?> dataType, AttributeInfo aInfo) throws AtlasException;
-
-    /**
-     * Creates an entity definition (instance) corresponding to a given type.
-     *
-     * @param entities     entity (typed instance)
-     * @return CreateOrUpdateEntitiesResult with the guids of the entities that were created
-     * @throws RepositoryException
-     * @throws EntityExistsException
-     */
-    CreateUpdateEntitiesResult createEntities(ITypedReferenceableInstance... entities) throws RepositoryException, EntityExistsException;
-
-    /**
-     * Fetch the complete definition of an entity given its GUID.
-     *
-     * @param guid globally unique identifier for the entity
-     * @return entity (typed instance) definition
-     * @throws RepositoryException
-     * @throws EntityNotFoundException
-     */
-    ITypedReferenceableInstance getEntityDefinition(String guid) throws RepositoryException, EntityNotFoundException;
-
-    /**
-     * Fetch the complete entity definitions for the entities with the given GUIDs
-     *
-     * @param guids globally unique identifiers for the entities
-     * @return entity (typed instance) definitions list
-     * @throws RepositoryException
-     * @throws EntityNotFoundException
-     */
-    List<ITypedReferenceableInstance> getEntityDefinitions(String... guids) throws RepositoryException, EntityNotFoundException;
-
-    /**
-     * Gets the list of entities for a given entity type.
-     *
-     * @param entityType name of a type which is unique
-     * @return a list of entity names for the given type
-     * @throws RepositoryException
-     */
-    List<String> getEntityList(String entityType) throws RepositoryException;
-
-    /**
-     * Deletes entities for the specified guids.
-     *
-     * @param guids globally unique identifiers for the deletion candidate entities
-     * @return guids of deleted entities
-     * @throws RepositoryException
-     */
-    EntityResult deleteEntities(List<String> guids) throws RepositoryException;
-    
-    
-    // Trait management functions
-
-    /**
-     * Gets the list of trait names for a given entity represented by a guid.
-     *
-     * @param guid globally unique identifier for the entity
-     * @return a list of trait names for the given entity guid
-     * @throws RepositoryException
-     */
-    List<String> getTraitNames(String guid) throws AtlasException;
-
-    /**
-     * Adds a new trait to an existing entity represented by a guid.
-     *
-     * @param guid          globally unique identifier for the entity
-     * @param traitInstance trait instance that needs to be added to entity
-     * @throws RepositoryException
-     */
-    void addTrait(String guid, ITypedStruct traitInstance) throws RepositoryException;
-
-    /**
-     * Adds a new trait to a list of entities represented by their respective guids
-     * @param entityGuids   list of globally unique identifier for the entities
-     * @param traitInstance trait instance that needs to be added to entities
-     * @throws RepositoryException
-     */
-    void addTrait(List<String> entityGuids, ITypedStruct traitInstance) throws RepositoryException;
-
-    /**
-     * Deletes a given trait from an existing entity represented by a guid.
-     *
-     * @param guid                 globally unique identifier for the entity
-     * @param traitNameToBeDeleted name of the trait
-     * @throws RepositoryException
-     */
-    void deleteTrait(String guid, String traitNameToBeDeleted) throws TraitNotFoundException, EntityNotFoundException, RepositoryException;
-
-    /**
-     * Adds/Updates the property to the entity that corresponds to the GUID
-     * Supports only primitive attribute/Class Id updations.
-     */
-    CreateUpdateEntitiesResult updatePartial(ITypedReferenceableInstance entity) throws RepositoryException;
-
-    /**
-     * Adds the property to the entity that corresponds to the GUID
-     * @param entitiesToBeUpdated The entities to be updated
-     */
-    CreateUpdateEntitiesResult updateEntities(ITypedReferenceableInstance... entitiesToBeUpdated) throws RepositoryException;
-
-    /**
-     * Returns the entity for the given type and qualified name
-     * @param entityType
-     * @param attribute
-     * @param value
-     * @return entity instance
-     */
-    ITypedReferenceableInstance getEntityDefinition(String entityType, String attribute, Object value) throws AtlasException;
-}

http://git-wip-us.apache.org/repos/asf/atlas/blob/0877e47c/repository/src/main/java/org/apache/atlas/repository/RepositoryConfiguration.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/repository/RepositoryConfiguration.java b/repository/src/main/java/org/apache/atlas/repository/RepositoryConfiguration.java
deleted file mode 100644
index 261a6d0..0000000
--- a/repository/src/main/java/org/apache/atlas/repository/RepositoryConfiguration.java
+++ /dev/null
@@ -1,37 +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.repository;
-
-import org.apache.atlas.repository.graphdb.GraphDatabase;
-import org.apache.atlas.typesystem.types.TypeSystem;
-import org.apache.atlas.util.AtlasRepositoryConfiguration;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-
-@Configuration
-public class RepositoryConfiguration {
-    @Bean
-    public GraphDatabase getGraphDatabase() throws IllegalAccessException, InstantiationException {
-        return AtlasRepositoryConfiguration.getGraphDatabaseImpl().newInstance();
-    }
-
-    @Bean
-    public TypeSystem getTypeSystem() {
-        return TypeSystem.getInstance();
-    }
-}

http://git-wip-us.apache.org/repos/asf/atlas/blob/0877e47c/repository/src/main/java/org/apache/atlas/repository/audit/EntityAuditListener.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/repository/audit/EntityAuditListener.java b/repository/src/main/java/org/apache/atlas/repository/audit/EntityAuditListener.java
index 2a1881b..36a2d54 100644
--- a/repository/src/main/java/org/apache/atlas/repository/audit/EntityAuditListener.java
+++ b/repository/src/main/java/org/apache/atlas/repository/audit/EntityAuditListener.java
@@ -23,11 +23,12 @@ import org.apache.atlas.EntityAuditEvent;
 import org.apache.atlas.EntityAuditEvent.EntityAuditAction;
 import org.apache.atlas.RequestContextV1;
 import org.apache.atlas.listener.EntityChangeListener;
-import org.apache.atlas.typesystem.IReferenceableInstance;
-import org.apache.atlas.typesystem.IStruct;
-import org.apache.atlas.typesystem.ITypedReferenceableInstance;
-import org.apache.atlas.typesystem.json.InstanceSerialization;
-import org.apache.atlas.typesystem.types.AttributeInfo;
+import org.apache.atlas.model.v1.instance.Referenceable;
+import org.apache.atlas.model.v1.instance.Struct;
+import org.apache.atlas.type.AtlasEntityType;
+import org.apache.atlas.type.AtlasStructType;
+import org.apache.atlas.type.AtlasType;
+import org.apache.atlas.type.AtlasTypeRegistry;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.collections.MapUtils;
 import org.slf4j.Logger;
@@ -49,17 +50,19 @@ import java.util.Map;
 public class EntityAuditListener implements EntityChangeListener {
     private static final Logger LOG = LoggerFactory.getLogger(EntityAuditListener.class);
 
-    private EntityAuditRepository auditRepository;
+    private final EntityAuditRepository auditRepository;
+    private final AtlasTypeRegistry     typeRegistry;
 
     @Inject
-    public EntityAuditListener(EntityAuditRepository auditRepository) {
+    public EntityAuditListener(EntityAuditRepository auditRepository, AtlasTypeRegistry typeRegistry) {
         this.auditRepository = auditRepository;
+        this.typeRegistry    = typeRegistry;
     }
 
     @Override
-    public void onEntitiesAdded(Collection<ITypedReferenceableInstance> entities, boolean isImport) throws AtlasException {
+    public void onEntitiesAdded(Collection<Referenceable> entities, boolean isImport) throws AtlasException {
         List<EntityAuditEvent> events = new ArrayList<>();
-        for (ITypedReferenceableInstance entity : entities) {
+        for (Referenceable entity : entities) {
             EntityAuditEvent event = createEvent(entity, isImport ? EntityAuditAction.ENTITY_IMPORT_CREATE : EntityAuditAction.ENTITY_CREATE);
             events.add(event);
         }
@@ -68,9 +71,9 @@ public class EntityAuditListener implements EntityChangeListener {
     }
 
     @Override
-    public void onEntitiesUpdated(Collection<ITypedReferenceableInstance> entities, boolean isImport) throws AtlasException {
+    public void onEntitiesUpdated(Collection<Referenceable> entities, boolean isImport) throws AtlasException {
         List<EntityAuditEvent> events = new ArrayList<>();
-        for (ITypedReferenceableInstance entity : entities) {
+        for (Referenceable entity : entities) {
             EntityAuditEvent event = createEvent(entity, isImport ? EntityAuditAction.ENTITY_IMPORT_UPDATE : EntityAuditAction.ENTITY_UPDATE);
             events.add(event);
         }
@@ -79,11 +82,11 @@ public class EntityAuditListener implements EntityChangeListener {
     }
 
     @Override
-    public void onTraitsAdded(ITypedReferenceableInstance entity, Collection<? extends IStruct> traits) throws AtlasException {
+    public void onTraitsAdded(Referenceable entity, Collection<? extends Struct> traits) throws AtlasException {
         if (traits != null) {
-            for (IStruct trait : traits) {
+            for (Struct trait : traits) {
                 EntityAuditEvent event = createEvent(entity, EntityAuditAction.TAG_ADD,
-                                                     "Added trait: " + InstanceSerialization.toJson(trait, true));
+                                                     "Added trait: " + AtlasType.toV1Json(trait));
 
                 auditRepository.putEvents(event);
             }
@@ -91,7 +94,7 @@ public class EntityAuditListener implements EntityChangeListener {
     }
 
     @Override
-    public void onTraitsDeleted(ITypedReferenceableInstance entity, Collection<String> traitNames) throws AtlasException {
+    public void onTraitsDeleted(Referenceable entity, Collection<String> traitNames) throws AtlasException {
         if (traitNames != null) {
             for (String traitName : traitNames) {
                 EntityAuditEvent event = createEvent(entity, EntityAuditAction.TAG_DELETE, "Deleted trait: " + traitName);
@@ -102,11 +105,11 @@ public class EntityAuditListener implements EntityChangeListener {
     }
 
     @Override
-    public void onTraitsUpdated(ITypedReferenceableInstance entity, Collection<? extends IStruct> traits) throws AtlasException {
+    public void onTraitsUpdated(Referenceable entity, Collection<? extends Struct> traits) throws AtlasException {
         if (traits != null) {
-            for (IStruct trait : traits) {
+            for (Struct trait : traits) {
                 EntityAuditEvent event = createEvent(entity, EntityAuditAction.TAG_UPDATE,
-                                                     "Updated trait: " + InstanceSerialization.toJson(trait, true));
+                                                     "Updated trait: " + AtlasType.toV1Json(trait));
 
                 auditRepository.putEvents(event);
             }
@@ -114,9 +117,9 @@ public class EntityAuditListener implements EntityChangeListener {
     }
 
     @Override
-    public void onEntitiesDeleted(Collection<ITypedReferenceableInstance> entities, boolean isImport) throws AtlasException {
+    public void onEntitiesDeleted(Collection<Referenceable> entities, boolean isImport) throws AtlasException {
         List<EntityAuditEvent> events = new ArrayList<>();
-        for (ITypedReferenceableInstance entity : entities) {
+        for (Referenceable entity : entities) {
             EntityAuditEvent event = createEvent(entity, isImport ? EntityAuditAction.ENTITY_IMPORT_DELETE : EntityAuditAction.ENTITY_DELETE, "Deleted entity");
             events.add(event);
         }
@@ -128,23 +131,23 @@ public class EntityAuditListener implements EntityChangeListener {
         return auditRepository.listEvents(guid, null, (short) 10);
     }
 
-    private EntityAuditEvent createEvent(ITypedReferenceableInstance entity, EntityAuditAction action)
+    private EntityAuditEvent createEvent(Referenceable entity, EntityAuditAction action)
             throws AtlasException {
         String detail = getAuditEventDetail(entity, action);
 
         return createEvent(entity, action, detail);
     }
 
-    private EntityAuditEvent createEvent(ITypedReferenceableInstance entity, EntityAuditAction action, String details)
+    private EntityAuditEvent createEvent(Referenceable entity, EntityAuditAction action, String details)
             throws AtlasException {
         return new EntityAuditEvent(entity.getId()._getId(), RequestContextV1.get().getRequestTime(), RequestContextV1.get().getUser(), action, details, entity);
     }
 
-    private String getAuditEventDetail(ITypedReferenceableInstance entity, EntityAuditAction action) throws AtlasException {
+    private String getAuditEventDetail(Referenceable entity, EntityAuditAction action) throws AtlasException {
         Map<String, Object> prunedAttributes = pruneEntityAttributesForAudit(entity);
 
         String auditPrefix  = getAuditPrefix(action);
-        String auditString  = auditPrefix + InstanceSerialization.toJson(entity, true);
+        String auditString  = auditPrefix + AtlasType.toV1Json(entity);
         byte[] auditBytes   = auditString.getBytes(StandardCharsets.UTF_8);
         long   auditSize    = auditBytes != null ? auditBytes.length : 0;
         long   auditMaxSize = auditRepository.repositoryMaxSize();
@@ -157,7 +160,7 @@ public class EntityAuditListener implements EntityChangeListener {
 
             clearAttributeValues(entity);
 
-            auditString = auditPrefix + InstanceSerialization.toJson(entity, true);
+            auditString = auditPrefix + AtlasType.toV1Json(entity);
 
             addAttributeValues(entity, attrValues);
         }
@@ -167,7 +170,7 @@ public class EntityAuditListener implements EntityChangeListener {
         return auditString;
     }
 
-    private void clearAttributeValues(IReferenceableInstance entity) throws AtlasException {
+    private void clearAttributeValues(Referenceable entity) throws AtlasException {
         Map<String, Object> attributesMap = entity.getValuesMap();
 
         if (MapUtils.isNotEmpty(attributesMap)) {
@@ -177,7 +180,7 @@ public class EntityAuditListener implements EntityChangeListener {
         }
     }
 
-    private void addAttributeValues(ITypedReferenceableInstance entity, Map<String, Object> attributesMap) throws AtlasException {
+    private void addAttributeValues(Referenceable entity, Map<String, Object> attributesMap) throws AtlasException {
         if (MapUtils.isNotEmpty(attributesMap)) {
             for (String attr : attributesMap.keySet()) {
                 entity.set(attr, attributesMap.get(attr));
@@ -185,17 +188,16 @@ public class EntityAuditListener implements EntityChangeListener {
         }
     }
 
-    private Map<String, Object> pruneEntityAttributesForAudit(ITypedReferenceableInstance entity) throws AtlasException {
+    private Map<String, Object> pruneEntityAttributesForAudit(Referenceable entity) throws AtlasException {
         Map<String, Object> ret               = null;
         Map<String, Object> entityAttributes  = entity.getValuesMap();
         List<String>        excludeAttributes = auditRepository.getAuditExcludeAttributes(entity.getTypeName());
+        AtlasEntityType     entityType        = typeRegistry.getEntityTypeByName(entity.getTypeName());
 
-        if (CollectionUtils.isNotEmpty(excludeAttributes) && MapUtils.isNotEmpty(entityAttributes)) {
-            Map<String, AttributeInfo> attributeInfoMap = entity.fieldMapping().fields;
-
-            for (String attrName : entityAttributes.keySet()) {
+        if (CollectionUtils.isNotEmpty(excludeAttributes) && MapUtils.isNotEmpty(entityAttributes) && entityType != null) {
+            for (AtlasStructType.AtlasAttribute attribute : entityType.getAllAttributes().values()) {
+                String        attrName  = attribute.getName();
                 Object        attrValue = entityAttributes.get(attrName);
-                AttributeInfo attrInfo  = attributeInfoMap.get(attrName);
 
                 if (excludeAttributes.contains(attrName)) {
                     if (ret == null) {
@@ -204,15 +206,15 @@ public class EntityAuditListener implements EntityChangeListener {
 
                     ret.put(attrName, attrValue);
                     entity.setNull(attrName);
-                } else if (attrInfo.isComposite) {
+                } else if (attribute.isOwnedRef()) {
                     if (attrValue instanceof Collection) {
-                        for (Object attribute : (Collection) attrValue) {
-                            if (attribute instanceof ITypedReferenceableInstance) {
-                                ret = pruneAttributes(ret, (ITypedReferenceableInstance) attribute);
+                        for (Object arrElem : (Collection) attrValue) {
+                            if (arrElem instanceof Referenceable) {
+                                ret = pruneAttributes(ret, (Referenceable) arrElem);
                             }
                         }
-                    } else if (attrValue instanceof ITypedReferenceableInstance) {
-                        ret = pruneAttributes(ret, (ITypedReferenceableInstance) attrValue);
+                    } else if (attrValue instanceof Referenceable) {
+                        ret = pruneAttributes(ret, (Referenceable) attrValue);
                     }
                 }
             }
@@ -221,9 +223,9 @@ public class EntityAuditListener implements EntityChangeListener {
         return ret;
     }
 
-    private Map<String, Object> pruneAttributes(Map<String, Object> ret, ITypedReferenceableInstance attribute) throws AtlasException {
-        ITypedReferenceableInstance attrInstance = attribute;
-        Map<String, Object>         prunedAttrs  = pruneEntityAttributesForAudit(attrInstance);
+    private Map<String, Object> pruneAttributes(Map<String, Object> ret, Referenceable attribute) throws AtlasException {
+        Referenceable       attrInstance = attribute;
+        Map<String, Object> prunedAttrs  = pruneEntityAttributesForAudit(attrInstance);
 
         if (MapUtils.isNotEmpty(prunedAttrs)) {
             if (ret == null) {
@@ -232,41 +234,42 @@ public class EntityAuditListener implements EntityChangeListener {
 
             ret.put(attrInstance.getId()._getId(), prunedAttrs);
         }
+
         return ret;
     }
 
-    private void restoreEntityAttributes(ITypedReferenceableInstance entity, Map<String, Object> prunedAttributes) throws AtlasException {
+    private void restoreEntityAttributes(Referenceable entity, Map<String, Object> prunedAttributes) throws AtlasException {
         if (MapUtils.isEmpty(prunedAttributes)) {
             return;
         }
 
-        Map<String, Object> entityAttributes = entity.getValuesMap();
+        AtlasEntityType     entityType       = typeRegistry.getEntityTypeByName(entity.getTypeName());
 
-        if (MapUtils.isNotEmpty(entityAttributes)) {
-            Map<String, AttributeInfo> attributeInfoMap = entity.fieldMapping().fields;
+        if (entityType != null && MapUtils.isNotEmpty(entityType.getAllAttributes())) {
+            Map<String, Object> entityAttributes = entity.getValuesMap();
 
-            for (String attrName : entityAttributes.keySet()) {
-                Object        attrValue = entityAttributes.get(attrName);
-                AttributeInfo attrInfo  = attributeInfoMap.get(attrName);
+            for (AtlasStructType.AtlasAttribute attribute : entityType.getAllAttributes().values()) {
+                String attrName  = attribute.getName();
+                Object attrValue = entityAttributes.get(attrName);
 
                 if (prunedAttributes.containsKey(attrName)) {
                     entity.set(attrName, prunedAttributes.get(attrName));
-                } else if (attrInfo.isComposite) {
+                } else if (attribute.isOwnedRef()) {
                     if (attrValue instanceof Collection) {
-                        for (Object attributeEntity : (Collection) attrValue) {
-                            if (attributeEntity instanceof ITypedReferenceableInstance) {
-                                restoreAttributes(prunedAttributes, (ITypedReferenceableInstance) attributeEntity);
+                        for (Object arrElem : (Collection) attrValue) {
+                            if (arrElem instanceof Referenceable) {
+                                restoreAttributes(prunedAttributes, (Referenceable) arrElem);
                             }
                         }
-                    } else if (attrValue instanceof ITypedReferenceableInstance) {
-                        restoreAttributes(prunedAttributes, (ITypedReferenceableInstance) attrValue);
+                    } else if (attrValue instanceof Referenceable) {
+                        restoreAttributes(prunedAttributes, (Referenceable) attrValue);
                     }
                 }
             }
         }
     }
 
-    private void restoreAttributes(Map<String, Object> prunedAttributes, ITypedReferenceableInstance attributeEntity) throws AtlasException {
+    private void restoreAttributes(Map<String, Object> prunedAttributes, Referenceable attributeEntity) throws AtlasException {
         Object                      obj          = prunedAttributes.get(attributeEntity.getId()._getId());
 
         if (obj instanceof Map) {

http://git-wip-us.apache.org/repos/asf/atlas/blob/0877e47c/repository/src/main/java/org/apache/atlas/repository/audit/InMemoryEntityAuditRepository.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/repository/audit/InMemoryEntityAuditRepository.java b/repository/src/main/java/org/apache/atlas/repository/audit/InMemoryEntityAuditRepository.java
deleted file mode 100644
index 22d2a81..0000000
--- a/repository/src/main/java/org/apache/atlas/repository/audit/InMemoryEntityAuditRepository.java
+++ /dev/null
@@ -1,84 +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.repository.audit;
-
-import org.apache.atlas.AtlasException;
-import org.apache.atlas.EntityAuditEvent;
-import org.apache.atlas.annotation.ConditionalOnAtlasProperty;
-import org.springframework.stereotype.Component;
-
-import javax.inject.Singleton;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.SortedMap;
-import java.util.TreeMap;
-
-/**
- * Entity audit repository where audit events are stored in-memory. Used only for integration tests
- */
-@Singleton
-@Component
-@ConditionalOnAtlasProperty(property = "atlas.EntityAuditRepository.impl")
-public class InMemoryEntityAuditRepository implements EntityAuditRepository {
-    private TreeMap<String, EntityAuditEvent> auditEvents = new TreeMap<>();
-
-    @Override
-    public void putEvents(EntityAuditEvent... events) throws AtlasException {
-        putEvents(Arrays.asList(events));
-    }
-
-    @Override
-    public synchronized void putEvents(List<EntityAuditEvent> events) throws AtlasException {
-        for (EntityAuditEvent event : events) {
-            String rowKey = event.getEntityId() + (Long.MAX_VALUE - event.getTimestamp());
-            event.setEventKey(rowKey);
-            auditEvents.put(rowKey, event);
-        }
-    }
-
-    //synchronized to avoid concurrent modification exception that occurs if events are added
-    //while we are iterating through the map
-    @Override
-    public synchronized List<EntityAuditEvent> listEvents(String entityId, String startKey, short maxResults)
-            throws AtlasException {
-        List<EntityAuditEvent> events = new ArrayList<>();
-        String myStartKey = startKey;
-        if (myStartKey == null) {
-            myStartKey = entityId;
-        }
-        SortedMap<String, EntityAuditEvent> subMap = auditEvents.tailMap(myStartKey);
-        for (EntityAuditEvent event : subMap.values()) {
-            if (events.size() < maxResults && event.getEntityId().equals(entityId)) {
-                events.add(event);
-            }
-        }
-        return events;
-    }
-
-    @Override
-    public long repositoryMaxSize() throws AtlasException {
-        return -1;
-    }
-
-    @Override
-    public List<String> getAuditExcludeAttributes(String entityType) throws AtlasException {
-        return null;
-    }
-}

http://git-wip-us.apache.org/repos/asf/atlas/blob/0877e47c/repository/src/main/java/org/apache/atlas/repository/audit/NoopEntityAuditRepository.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/repository/audit/NoopEntityAuditRepository.java b/repository/src/main/java/org/apache/atlas/repository/audit/NoopEntityAuditRepository.java
deleted file mode 100644
index c382601..0000000
--- a/repository/src/main/java/org/apache/atlas/repository/audit/NoopEntityAuditRepository.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
- * <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.repository.audit;
-
-import org.apache.atlas.AtlasException;
-import org.apache.atlas.EntityAuditEvent;
-import org.apache.atlas.annotation.ConditionalOnAtlasProperty;
-import org.springframework.stereotype.Component;
-
-import javax.inject.Singleton;
-import java.util.Collections;
-import java.util.List;
-
-/**
- * Implementation that completely disables the audit repository.
- */
-@Singleton
-@Component
-@ConditionalOnAtlasProperty(property = "atlas.EntityAuditRepository.impl")
-public class NoopEntityAuditRepository implements EntityAuditRepository {
-
-    @Override
-    public void putEvents(EntityAuditEvent... events) throws AtlasException {
-        //do nothing
-    }
-
-    @Override
-    public synchronized void putEvents(List<EntityAuditEvent> events) throws AtlasException {
-        //do nothing
-    }
-
-    @Override
-    public List<EntityAuditEvent> listEvents(String entityId, String startKey, short maxResults)
-            throws AtlasException {
-        return Collections.emptyList();
-    }
-
-    @Override
-    public long repositoryMaxSize() throws AtlasException {
-        return -1;
-    }
-
-    @Override
-    public List<String> getAuditExcludeAttributes(String entityType) throws AtlasException {
-        return null;
-    }
-}

http://git-wip-us.apache.org/repos/asf/atlas/blob/0877e47c/repository/src/main/java/org/apache/atlas/repository/converters/AtlasClassificationFormatConverter.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/repository/converters/AtlasClassificationFormatConverter.java b/repository/src/main/java/org/apache/atlas/repository/converters/AtlasClassificationFormatConverter.java
index cd4f165..39e7c2f 100644
--- a/repository/src/main/java/org/apache/atlas/repository/converters/AtlasClassificationFormatConverter.java
+++ b/repository/src/main/java/org/apache/atlas/repository/converters/AtlasClassificationFormatConverter.java
@@ -18,14 +18,13 @@
 package org.apache.atlas.repository.converters;
 
 import org.apache.atlas.AtlasErrorCode;
-import org.apache.atlas.AtlasException;
 import org.apache.atlas.exception.AtlasBaseException;
 import org.apache.atlas.model.TypeCategory;
 import org.apache.atlas.model.instance.AtlasClassification;
+import org.apache.atlas.model.v1.instance.Struct;
 import org.apache.atlas.type.AtlasClassificationType;
 import org.apache.atlas.type.AtlasType;
 import org.apache.atlas.type.AtlasTypeRegistry;
-import org.apache.atlas.typesystem.IStruct;
 import org.apache.commons.collections.MapUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -55,19 +54,12 @@ public class AtlasClassificationFormatConverter extends AtlasStructFormatConvert
                 } else {
                     ret = new AtlasClassification(type.getTypeName());
                 }
-            } else if (v1Obj instanceof IStruct) {
-                IStruct             struct    = (IStruct) v1Obj;
-                Map<String, Object> v1Attribs = null;
+            } else if (v1Obj instanceof Struct) {
+                Struct struct = (Struct) v1Obj;
 
-                try {
-                    v1Attribs = struct.getValuesMap();
-                } catch (AtlasException excp) {
-                    LOG.error("IStruct.getValuesMap() failed", excp);
-                }
-
-                ret = new AtlasClassification(type.getTypeName(), fromV1ToV2(classificationType, v1Attribs, ctx));
+                ret = new AtlasClassification(type.getTypeName(), fromV1ToV2(classificationType, struct.getValues(), ctx));
             } else {
-                throw new AtlasBaseException(AtlasErrorCode.UNEXPECTED_TYPE, "Map or IStruct",
+                throw new AtlasBaseException(AtlasErrorCode.UNEXPECTED_TYPE, "Map or Struct",
                                              v1Obj.getClass().getCanonicalName());
             }
         }

http://git-wip-us.apache.org/repos/asf/atlas/blob/0877e47c/repository/src/main/java/org/apache/atlas/repository/converters/AtlasEntityFormatConverter.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/repository/converters/AtlasEntityFormatConverter.java b/repository/src/main/java/org/apache/atlas/repository/converters/AtlasEntityFormatConverter.java
index 1ce6168..940890c 100644
--- a/repository/src/main/java/org/apache/atlas/repository/converters/AtlasEntityFormatConverter.java
+++ b/repository/src/main/java/org/apache/atlas/repository/converters/AtlasEntityFormatConverter.java
@@ -18,21 +18,20 @@
 package org.apache.atlas.repository.converters;
 
 import org.apache.atlas.AtlasErrorCode;
-import org.apache.atlas.AtlasException;
 import org.apache.atlas.exception.AtlasBaseException;
 import org.apache.atlas.model.TypeCategory;
 import org.apache.atlas.model.instance.AtlasClassification;
 import org.apache.atlas.model.instance.AtlasEntity;
 import org.apache.atlas.model.instance.AtlasEntity.Status;
 import org.apache.atlas.model.instance.AtlasObjectId;
+import org.apache.atlas.model.v1.instance.AtlasSystemAttributes;
+import org.apache.atlas.model.v1.instance.Id;
+import org.apache.atlas.model.v1.instance.Referenceable;
+import org.apache.atlas.model.v1.instance.Struct;
+import org.apache.atlas.type.AtlasClassificationType;
 import org.apache.atlas.type.AtlasEntityType;
 import org.apache.atlas.type.AtlasType;
 import org.apache.atlas.type.AtlasTypeRegistry;
-import org.apache.atlas.typesystem.IReferenceableInstance;
-import org.apache.atlas.typesystem.IStruct;
-import org.apache.atlas.typesystem.Referenceable;
-import org.apache.atlas.typesystem.persistence.Id;
-import org.apache.atlas.typesystem.persistence.Id.EntityState;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.collections.MapUtils;
 import org.apache.commons.lang3.StringUtils;
@@ -40,6 +39,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
@@ -57,37 +57,29 @@ public class AtlasEntityFormatConverter extends AtlasStructFormatConverter {
         if (v1Obj != null) {
             AtlasEntityType entityType = (AtlasEntityType) type;
 
-            if (v1Obj instanceof IReferenceableInstance) {
-                IReferenceableInstance entRef = (IReferenceableInstance) v1Obj;
+            if (v1Obj instanceof Referenceable) {
+                Referenceable entRef = (Referenceable)v1Obj;
 
-                String guid = entRef.getId()._getId();
+                String guid = entRef.getId().getId();
 
                 if (!context.entityExists(guid)) {
-                    Map<String, Object> v1Attribs = null;
+                    entity = new AtlasEntity(entRef.getTypeName(), super.fromV1ToV2(entityType, entRef.getValues(), context));
 
-                    try {
-                        v1Attribs = entRef.getValuesMap();
-                    } catch (AtlasException excp) {
-                        LOG.error("IReferenceableInstance.getValuesMap() failed", excp);
-                    }
-
-                    entity = new AtlasEntity(entRef.getTypeName(),
-                                                         super.fromV1ToV2(entityType, v1Attribs, context));
-                    entity.setGuid(entRef.getId()._getId());
+                    entity.setGuid(entRef.getId().getId());
                     entity.setStatus(convertState(entRef.getId().getState()));
-                    entity.setCreatedBy(entRef.getSystemAttributes().createdBy);
-                    entity.setCreateTime(entRef.getSystemAttributes().createdTime);
-                    entity.setUpdatedBy(entRef.getSystemAttributes().modifiedBy);
-                    entity.setUpdateTime(entRef.getSystemAttributes().modifiedTime);
-                    entity.setVersion((long) entRef.getId().version);
+                    entity.setCreatedBy(entRef.getSystemAttributes().getCreatedBy());
+                    entity.setCreateTime(entRef.getSystemAttributes().getCreatedTime());
+                    entity.setUpdatedBy(entRef.getSystemAttributes().getModifiedBy());
+                    entity.setUpdateTime(entRef.getSystemAttributes().getModifiedTime());
+                    entity.setVersion((long) entRef.getId().getVersion());
 
-                    if (CollectionUtils.isNotEmpty(entRef.getTraits())) {
+                    if (CollectionUtils.isNotEmpty(entRef.getTraitNames())) {
                         List<AtlasClassification> classifications = new ArrayList<>();
-                        AtlasFormatConverter traitConverter = converterRegistry.getConverter(TypeCategory.CLASSIFICATION);
+                        AtlasFormatConverter      traitConverter  = converterRegistry.getConverter(TypeCategory.CLASSIFICATION);
 
-                        for (String traitName : entRef.getTraits()) {
-                            IStruct trait = entRef.getTrait(traitName);
-                            AtlasType classifiType = typeRegistry.getType(traitName);
+                        for (String traitName : entRef.getTraitNames()) {
+                            Struct              trait          = entRef.getTraits().get(traitName);
+                            AtlasType           classifiType   = typeRegistry.getType(traitName);
                             AtlasClassification classification = (AtlasClassification) traitConverter.fromV1ToV2(trait, classifiType, context);
 
                             classifications.add(classification);
@@ -95,26 +87,16 @@ public class AtlasEntityFormatConverter extends AtlasStructFormatConverter {
 
                         entity.setClassifications(classifications);
                     }
-                } else {
-                    entity = context.getById(guid);
                 }
+
             } else {
-                throw new AtlasBaseException(AtlasErrorCode.UNEXPECTED_TYPE, "IReferenceableInstance",
+                throw new AtlasBaseException(AtlasErrorCode.UNEXPECTED_TYPE, "Referenceable",
                                              v1Obj.getClass().getCanonicalName());
             }
         }
         return entity;
     }
 
-    private Status convertState(EntityState state){
-        Status status = Status.ACTIVE;
-        if(state != null && state.equals(EntityState.DELETED)){
-            status = Status.DELETED;
-        }
-        LOG.debug("Setting state to {}", state);
-        return status;
-    }
-
     @Override
     public Object fromV2ToV1(Object v2Obj, AtlasType type, ConverterContext context) throws AtlasBaseException {
         Object ret = null;
@@ -141,9 +123,25 @@ public class AtlasEntityFormatConverter extends AtlasStructFormatConverter {
             } else if (v2Obj instanceof AtlasEntity) {
                 AtlasEntity entity = (AtlasEntity) v2Obj;
 
-                ret = new Referenceable(entity.getGuid(), entity.getTypeName(),
-                                        fromV2ToV1(entityType, entity.getAttributes(), context));
+                Referenceable referenceable = new Referenceable(entity.getGuid(), entity.getTypeName(),
+                                                                fromV2ToV1(entityType, entity.getAttributes(), context),
+                                                                new AtlasSystemAttributes(entity.getCreatedBy(), entity.getUpdatedBy(), entity.getCreateTime(), entity.getUpdateTime()));
 
+                if (CollectionUtils.isNotEmpty(entity.getClassifications())) {
+                    for (AtlasClassification classification : entity.getClassifications()) {
+                        String                  traitName          = classification.getTypeName();
+                        AtlasClassificationType classificationType = typeRegistry.getClassificationTypeByName(traitName);
+                        AtlasFormatConverter    formatConverter    = classificationType != null ? converterRegistry.getConverter(classificationType.getTypeCategory()) : null;
+                        Struct                  trait              = formatConverter != null ? (Struct)formatConverter.fromV2ToV1(classification, classificationType, context) : null;
+
+                        if (trait != null) {
+                            referenceable.getTraitNames().add(trait.getTypeName());
+                            referenceable.getTraits().put(trait.getTypeName(), trait);
+                        }
+                    }
+                }
+
+                ret = referenceable;
             } else if (v2Obj instanceof AtlasObjectId) { // transient-id
                 AtlasEntity entity = context.getById(((AtlasObjectId) v2Obj).getGuid());
                 if ( entity == null) {
@@ -158,4 +156,8 @@ public class AtlasEntityFormatConverter extends AtlasStructFormatConverter {
         }
         return ret;
     }
+
+    private Status convertState(Id.EntityState state){
+        return (state != null && state.equals(Id.EntityState.DELETED)) ? Status.DELETED : Status.ACTIVE;
+    }
 }

http://git-wip-us.apache.org/repos/asf/atlas/blob/0877e47c/repository/src/main/java/org/apache/atlas/repository/converters/AtlasEnumFormatConverter.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/repository/converters/AtlasEnumFormatConverter.java b/repository/src/main/java/org/apache/atlas/repository/converters/AtlasEnumFormatConverter.java
index 734bd0c..29c74dc 100644
--- a/repository/src/main/java/org/apache/atlas/repository/converters/AtlasEnumFormatConverter.java
+++ b/repository/src/main/java/org/apache/atlas/repository/converters/AtlasEnumFormatConverter.java
@@ -21,10 +21,10 @@ package org.apache.atlas.repository.converters;
 import org.apache.atlas.exception.AtlasBaseException;
 import org.apache.atlas.model.TypeCategory;
 import org.apache.atlas.model.typedef.AtlasEnumDef.AtlasEnumElementDef;
+import org.apache.atlas.model.v1.typedef.EnumTypeDefinition.EnumValue;
 import org.apache.atlas.type.AtlasEnumType;
 import org.apache.atlas.type.AtlasType;
 import org.apache.atlas.type.AtlasTypeRegistry;
-import org.apache.atlas.typesystem.types.EnumValue;
 
 import java.util.Map;
 
@@ -47,10 +47,10 @@ public class AtlasEnumFormatConverter extends AtlasAbstractFormatConverter {
         if (v1Obj instanceof EnumValue) {
             EnumValue enumValue = (EnumValue)v1Obj;
 
-            v1Value = enumValue.value;
+            v1Value = enumValue.getValue();
 
             if (v1Value == null) {
-                v1Value = enumValue.ordinal;
+                v1Value = enumValue.getOrdinal();
             }
         } else if (v1Obj instanceof Map) {
             Map mapValue = (Map)v1Obj;

http://git-wip-us.apache.org/repos/asf/atlas/blob/0877e47c/repository/src/main/java/org/apache/atlas/repository/converters/AtlasInstanceConverter.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/repository/converters/AtlasInstanceConverter.java b/repository/src/main/java/org/apache/atlas/repository/converters/AtlasInstanceConverter.java
index 9bde5db..6f27fff 100644
--- a/repository/src/main/java/org/apache/atlas/repository/converters/AtlasInstanceConverter.java
+++ b/repository/src/main/java/org/apache/atlas/repository/converters/AtlasInstanceConverter.java
@@ -27,27 +27,16 @@ import org.apache.atlas.model.instance.AtlasEntity;
 import org.apache.atlas.model.instance.AtlasEntity.AtlasEntitiesWithExtInfo;
 import org.apache.atlas.model.instance.AtlasEntityHeader;
 import org.apache.atlas.model.instance.EntityMutationResponse;
-import org.apache.atlas.model.instance.EntityMutations;
 import org.apache.atlas.model.instance.EntityMutations.EntityOperation;
 import org.apache.atlas.model.instance.GuidMapping;
 import org.apache.atlas.model.legacy.EntityResult;
+import org.apache.atlas.model.v1.instance.Referenceable;
+import org.apache.atlas.model.v1.instance.Struct;
 import org.apache.atlas.repository.converters.AtlasFormatConverter.ConverterContext;
-import org.apache.atlas.services.MetadataService;
 import org.apache.atlas.type.AtlasClassificationType;
 import org.apache.atlas.type.AtlasEntityType;
 import org.apache.atlas.type.AtlasType;
 import org.apache.atlas.type.AtlasTypeRegistry;
-import org.apache.atlas.typesystem.IReferenceableInstance;
-import org.apache.atlas.typesystem.IStruct;
-import org.apache.atlas.typesystem.ITypedReferenceableInstance;
-import org.apache.atlas.typesystem.ITypedStruct;
-import org.apache.atlas.typesystem.Referenceable;
-import org.apache.atlas.typesystem.Struct;
-import org.apache.atlas.typesystem.exception.EntityExistsException;
-import org.apache.atlas.typesystem.exception.EntityNotFoundException;
-import org.apache.atlas.typesystem.exception.TraitNotFoundException;
-import org.apache.atlas.typesystem.exception.TypeNotFoundException;
-import org.apache.atlas.typesystem.types.ValueConversionException;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.collections.MapUtils;
 import org.slf4j.Logger;
@@ -66,54 +55,47 @@ import java.util.Map;
 @Singleton
 @Component
 public class AtlasInstanceConverter {
-
     private static final Logger LOG = LoggerFactory.getLogger(AtlasInstanceConverter.class);
 
-    private AtlasTypeRegistry typeRegistry;
-
-    private AtlasFormatConverters instanceFormatters;
-
-    private MetadataService metadataService;
+    private final AtlasTypeRegistry     typeRegistry;
+    private final AtlasFormatConverters instanceFormatters;
 
     @Inject
-    public AtlasInstanceConverter(AtlasTypeRegistry typeRegistry, AtlasFormatConverters instanceFormatters, MetadataService metadataService) {
-        this.typeRegistry = typeRegistry;
+    public AtlasInstanceConverter(AtlasTypeRegistry typeRegistry, AtlasFormatConverters instanceFormatters) {
+        this.typeRegistry       = typeRegistry;
         this.instanceFormatters = instanceFormatters;
-        this.metadataService = metadataService;
     }
 
-    public ITypedReferenceableInstance[] getITypedReferenceables(Collection<AtlasEntity> entities) throws AtlasBaseException {
-        ITypedReferenceableInstance[] entitiesInOldFormat = new ITypedReferenceableInstance[entities.size()];
+    public Referenceable[] getReferenceables(Collection<AtlasEntity> entities) throws AtlasBaseException {
+        Referenceable[] ret = new Referenceable[entities.size()];
 
         AtlasFormatConverter.ConverterContext ctx = new AtlasFormatConverter.ConverterContext();
+
         for(Iterator<AtlasEntity> i = entities.iterator(); i.hasNext(); ) {
             ctx.addEntity(i.next());
         }
 
         Iterator<AtlasEntity> entityIterator = entities.iterator();
         for (int i = 0; i < entities.size(); i++) {
-            ITypedReferenceableInstance typedInstance = getITypedReferenceable(entityIterator.next());
-            entitiesInOldFormat[i] = typedInstance;
+            ret[i] = getReferenceable(entityIterator.next(), ctx);
         }
-        return entitiesInOldFormat;
+
+        return ret;
     }
 
-    public ITypedReferenceableInstance getITypedReferenceable(AtlasEntity entity) throws AtlasBaseException {
-        try {
-            return metadataService.getEntityDefinition(entity.getGuid());
-        } catch (AtlasException e) {
-            LOG.error("Exception while getting a typed reference for the entity ", e);
-            throw toAtlasBaseException(e);
-        }
+    public Referenceable getReferenceable(AtlasEntity entity) throws AtlasBaseException {
+        return getReferenceable(entity, new ConverterContext());
     }
 
-    public ITypedReferenceableInstance getITypedReferenceable(String guid) throws AtlasBaseException {
-        try {
-            return metadataService.getEntityDefinition(guid);
-        } catch (AtlasException e) {
-            LOG.error("Exception while getting a typed reference for the entity ", e);
-            throw toAtlasBaseException(e);
+    public Referenceable getReferenceable(AtlasEntity.AtlasEntityWithExtInfo entity) throws AtlasBaseException {
+        AtlasFormatConverter.ConverterContext ctx = new AtlasFormatConverter.ConverterContext();
+
+        ctx.addEntity(entity.getEntity());
+        for(Map.Entry<String, AtlasEntity> entry : entity.getReferredEntities().entrySet()) {
+            ctx.addEntity(entry.getValue());
         }
+
+        return getReferenceable(entity.getEntity(), ctx);
     }
 
     public Referenceable getReferenceable(AtlasEntity entity, final ConverterContext ctx) throws AtlasBaseException {
@@ -124,31 +106,28 @@ public class AtlasInstanceConverter {
         return ref;
     }
 
-    public ITypedStruct getTrait(AtlasClassification classification) throws AtlasBaseException {
+    public Struct getTrait(AtlasClassification classification) throws AtlasBaseException {
         AtlasFormatConverter converter          = instanceFormatters.getConverter(TypeCategory.CLASSIFICATION);
         AtlasType            classificationType = typeRegistry.getType(classification.getTypeName());
         Struct               trait               = (Struct)converter.fromV2ToV1(classification, classificationType, new ConverterContext());
 
-        try {
-            return metadataService.createTraitInstance(trait);
-        } catch (AtlasException e) {
-            LOG.error("Exception while getting a typed reference for the entity ", e);
-            throw toAtlasBaseException(e);
-        }
+        return trait;
     }
 
-    public AtlasClassification getClassification(IStruct classification) throws AtlasBaseException {
-        AtlasFormatConverter converter          = instanceFormatters.getConverter(TypeCategory.CLASSIFICATION);
+    public AtlasClassification toAtlasClassification(Struct classification) throws AtlasBaseException {
+        AtlasFormatConverter    converter          = instanceFormatters.getConverter(TypeCategory.CLASSIFICATION);
         AtlasClassificationType classificationType = typeRegistry.getClassificationTypeByName(classification.getTypeName());
+
         if (classificationType == null) {
             throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_INVALID, TypeCategory.CLASSIFICATION.name(), classification.getTypeName());
         }
-        AtlasClassification  ret                = (AtlasClassification)converter.fromV1ToV2(classification, classificationType, new AtlasFormatConverter.ConverterContext());
+
+        AtlasClassification  ret = (AtlasClassification)converter.fromV1ToV2(classification, classificationType, new AtlasFormatConverter.ConverterContext());
 
         return ret;
     }
 
-    public AtlasEntitiesWithExtInfo toAtlasEntity(IReferenceableInstance referenceable) throws AtlasBaseException {
+    public AtlasEntitiesWithExtInfo toAtlasEntity(Referenceable referenceable) throws AtlasBaseException {
         AtlasEntityFormatConverter converter  = (AtlasEntityFormatConverter) instanceFormatters.getConverter(TypeCategory.ENTITY);
         AtlasEntityType            entityType = typeRegistry.getEntityTypeByName(referenceable.getTypeName());
 
@@ -156,13 +135,6 @@ public class AtlasInstanceConverter {
             throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_INVALID, TypeCategory.ENTITY.name(), referenceable.getTypeName());
         }
 
-        // validate
-        try {
-            metadataService.validateAndConvertToTypedInstance(referenceable, entityType.getTypeName());
-        } catch (AtlasException excp) {
-            throw toAtlasBaseException(excp);
-        }
-
         ConverterContext ctx    = new ConverterContext();
         AtlasEntity      entity = converter.fromV1ToV2(referenceable, entityType, ctx);
 
@@ -171,106 +143,59 @@ public class AtlasInstanceConverter {
         return ctx.getEntities();
     }
 
-    public static EntityMutationResponse toEntityMutationResponse(EntityResult entityResult) {
-
-        CreateUpdateEntitiesResult result = new CreateUpdateEntitiesResult();
-        result.setEntityResult(entityResult);
-        return toEntityMutationResponse(result);
-    }
-
-    public static EntityMutationResponse toEntityMutationResponse(CreateUpdateEntitiesResult result) {
-        EntityMutationResponse response = new EntityMutationResponse();
-        for (String guid : result.getCreatedEntities()) {
-            AtlasEntityHeader header = new AtlasEntityHeader();
-            header.setGuid(guid);
-            response.addEntity(EntityMutations.EntityOperation.CREATE, header);
-        }
-
-        for (String guid : result.getUpdatedEntities()) {
-            AtlasEntityHeader header = new AtlasEntityHeader();
-            header.setGuid(guid);
-            response.addEntity(EntityMutations.EntityOperation.UPDATE, header);
-        }
-
-        for (String guid : result.getDeletedEntities()) {
-            AtlasEntityHeader header = new AtlasEntityHeader();
-            header.setGuid(guid);
-            response.addEntity(EntityMutations.EntityOperation.DELETE, header);
-        }
-        GuidMapping guidMapping = result.getGuidMapping();
-        if(guidMapping != null) {
-            response.setGuidAssignments(guidMapping.getGuidAssignments());
-        }
-        return response;
-    }
-
-    public static AtlasBaseException toAtlasBaseException(AtlasException e) {
-        if (e instanceof EntityExistsException) {
-            return new AtlasBaseException(AtlasErrorCode.INSTANCE_ALREADY_EXISTS, e.getMessage());
-        }
-
-        if ( e instanceof EntityNotFoundException || e instanceof TraitNotFoundException) {
-            return new AtlasBaseException(AtlasErrorCode.INSTANCE_NOT_FOUND, e.getMessage());
-        }
-
-        if ( e instanceof TypeNotFoundException) {
-            return new AtlasBaseException(AtlasErrorCode.TYPE_NAME_NOT_FOUND, e.getMessage());
-        }
-
-        if (e instanceof ValueConversionException) {
-            return new AtlasBaseException(AtlasErrorCode.INVALID_VALUE, e, e.getMessage());
-        }
-
-        return new AtlasBaseException(AtlasErrorCode.BAD_REQUEST, e.getMessage());
-    }
-
 
     public AtlasEntity.AtlasEntitiesWithExtInfo toAtlasEntities(List<Referenceable> referenceables) throws AtlasBaseException {
         if (LOG.isDebugEnabled()) {
-            LOG.debug("==> toAtlasEntities");
+            LOG.debug("==> toAtlasEntities({})", referenceables);
         }
 
         AtlasFormatConverter.ConverterContext context = new AtlasFormatConverter.ConverterContext();
+
         for (Referenceable referenceable : referenceables) {
             AtlasEntity entity = fromV1toV2Entity(referenceable, context);
 
             context.addEntity(entity);
         }
+
+        AtlasEntity.AtlasEntitiesWithExtInfo ret = context.getEntities();
+
         if (LOG.isDebugEnabled()) {
-            LOG.debug("<== toAtlasEntities");
+            LOG.debug("<== toAtlasEntities({}): ret=", referenceables, ret);
         }
 
-        return context.getEntities();
+        return ret;
     }
 
-    public AtlasEntitiesWithExtInfo toAtlasEntities(String entitiesJson) throws AtlasBaseException, AtlasException {
-        ITypedReferenceableInstance[] referenceables = metadataService.deserializeClassInstances(entitiesJson);
-        AtlasEntityFormatConverter    converter      = (AtlasEntityFormatConverter) instanceFormatters.getConverter(TypeCategory.ENTITY);
-        ConverterContext              context        = new ConverterContext();
-        AtlasEntitiesWithExtInfo      ret            = null;
+    public AtlasEntitiesWithExtInfo toAtlasEntities(String[] jsonEntities) throws AtlasBaseException, AtlasException {
+        Referenceable[] referenceables = new Referenceable[jsonEntities.length];
 
-        if (referenceables != null) {
-            for (IReferenceableInstance referenceable : referenceables) {
-                AtlasEntityType entityType = typeRegistry.getEntityTypeByName(referenceable.getTypeName());
+        for (int i = 0; i < jsonEntities.length; i++) {
+            referenceables[i] = AtlasType.fromV1Json(jsonEntities[i], Referenceable.class);
+        }
 
-                if (entityType == null) {
-                    throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_INVALID, TypeCategory.ENTITY.name(), referenceable.getTypeName());
-                }
+        AtlasEntityFormatConverter converter = (AtlasEntityFormatConverter) instanceFormatters.getConverter(TypeCategory.ENTITY);
+        ConverterContext           context   = new ConverterContext();
 
-                AtlasEntity entity = converter.fromV1ToV2(referenceable, entityType, context);
+        for (Referenceable referenceable : referenceables) {
+            AtlasEntityType entityType = typeRegistry.getEntityTypeByName(referenceable.getTypeName());
 
-                context.addEntity(entity);
+            if (entityType == null) {
+                throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_INVALID, TypeCategory.ENTITY.name(), referenceable.getTypeName());
             }
 
-            ret = context.getEntities();
+            AtlasEntity entity = converter.fromV1ToV2(referenceable, entityType, context);
+
+            context.addEntity(entity);
         }
 
+        AtlasEntitiesWithExtInfo ret = context.getEntities();
+
         return ret;
     }
 
     private AtlasEntity fromV1toV2Entity(Referenceable referenceable, AtlasFormatConverter.ConverterContext context) throws AtlasBaseException {
         if (LOG.isDebugEnabled()) {
-            LOG.debug("==> fromV1toV2Entity");
+            LOG.debug("==> fromV1toV2Entity({})", referenceable);
         }
 
         AtlasEntityFormatConverter converter = (AtlasEntityFormatConverter) instanceFormatters.getConverter(TypeCategory.ENTITY);
@@ -278,8 +203,9 @@ public class AtlasInstanceConverter {
         AtlasEntity entity = converter.fromV1ToV2(referenceable, typeRegistry.getType(referenceable.getTypeName()), context);
 
         if (LOG.isDebugEnabled()) {
-            LOG.debug("<== fromV1toV2Entity");
+            LOG.debug("<== fromV1toV2Entity({}): {}", referenceable, entity);
         }
+
         return entity;
     }
 

http://git-wip-us.apache.org/repos/asf/atlas/blob/0877e47c/repository/src/main/java/org/apache/atlas/repository/converters/AtlasObjectIdConverter.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/repository/converters/AtlasObjectIdConverter.java b/repository/src/main/java/org/apache/atlas/repository/converters/AtlasObjectIdConverter.java
index f946b9c..e03a6a9 100644
--- a/repository/src/main/java/org/apache/atlas/repository/converters/AtlasObjectIdConverter.java
+++ b/repository/src/main/java/org/apache/atlas/repository/converters/AtlasObjectIdConverter.java
@@ -19,18 +19,15 @@ package org.apache.atlas.repository.converters;
 
 
 import org.apache.atlas.AtlasErrorCode;
-import org.apache.atlas.AtlasException;
 import org.apache.atlas.exception.AtlasBaseException;
 import org.apache.atlas.model.TypeCategory;
 import org.apache.atlas.model.instance.AtlasEntity;
 import org.apache.atlas.model.instance.AtlasObjectId;
+import org.apache.atlas.model.v1.instance.Id;
+import org.apache.atlas.model.v1.instance.Referenceable;
 import org.apache.atlas.type.AtlasEntityType;
 import org.apache.atlas.type.AtlasType;
 import org.apache.atlas.type.AtlasTypeRegistry;
-import org.apache.atlas.typesystem.IReferenceableInstance;
-import org.apache.atlas.typesystem.Referenceable;
-import org.apache.atlas.typesystem.persistence.Id;
-import org.apache.atlas.typesystem.persistence.StructInstance;
 import org.apache.commons.collections.MapUtils;
 import org.apache.commons.lang3.StringUtils;
 
@@ -54,10 +51,10 @@ public class AtlasObjectIdConverter extends  AtlasAbstractFormatConverter {
             if (v1Obj instanceof Id) {
                 Id id = (Id) v1Obj;
 
-                ret = new AtlasObjectId(id._getId(), id.getTypeName());
-            } else if (v1Obj instanceof IReferenceableInstance) {
-                IReferenceableInstance refInst = (IReferenceableInstance) v1Obj;
-                String                 guid    = refInst.getId()._getId();
+                ret = new AtlasObjectId(id.getId(), id.getTypeName());
+            } else if (v1Obj instanceof Referenceable) {
+                Referenceable refInst = (Referenceable) v1Obj;
+                String        guid    = refInst.getId().getId();
 
                 ret = new AtlasObjectId(guid, refInst.getTypeName());
 
@@ -79,11 +76,10 @@ public class AtlasObjectIdConverter extends  AtlasAbstractFormatConverter {
         Id ret = null;
 
         if (v2Obj != null) {
-
             if (v2Obj instanceof Map) {
                 Map    v2Map    = (Map) v2Obj;
                 String idStr    = (String)v2Map.get(AtlasObjectId.KEY_GUID);
-                String typeName = type.getTypeName();
+                String typeName = (String)v2Map.get(AtlasObjectId.KEY_TYPENAME);
 
                 if (StringUtils.isEmpty(idStr)) {
                     throw new AtlasBaseException(AtlasErrorCode.INSTANCE_GUID_NOT_FOUND);
@@ -91,47 +87,33 @@ public class AtlasObjectIdConverter extends  AtlasAbstractFormatConverter {
 
                 ret = new Id(idStr, 0, typeName);
             } else if (v2Obj instanceof AtlasObjectId) { // transient-id
-                ret = new Id(((AtlasObjectId) v2Obj).getGuid(), 0, type.getTypeName());
+                AtlasObjectId objId = (AtlasObjectId) v2Obj;
+
+                ret = new Id(objId.getGuid(), 0, objId.getTypeName());
             } else if (v2Obj instanceof AtlasEntity) {
                 AtlasEntity entity = (AtlasEntity) v2Obj;
-                ret = new Id(((AtlasObjectId) v2Obj).getGuid(), 0, type.getTypeName());
+
+                ret = new Id(entity.getGuid(), entity.getVersion() == null ? 0 : entity.getVersion().intValue(), entity.getTypeName());
             } else {
                 throw new AtlasBaseException(AtlasErrorCode.TYPE_CATEGORY_INVALID, type.getTypeCategory().name());
             }
         }
+
         return ret;
     }
 
-    private boolean hasAnyAssignedAttribute(IReferenceableInstance rInstance) {
+    private boolean hasAnyAssignedAttribute(org.apache.atlas.model.v1.instance.Referenceable rInstance) {
         boolean ret = false;
 
-        if (rInstance instanceof StructInstance) {
-            StructInstance sInstance = (StructInstance) rInstance;
+        Map<String, Object> attributes = rInstance.getValues();
 
-            Map<String, Object> attributes = null;
-
-            try {
-                attributes = sInstance.getValuesMap();
-            } catch (AtlasException e) {
-                // ignore
-            }
-
-            if (MapUtils.isNotEmpty(attributes)) {
-                for (String attrName : attributes.keySet()) {
-                    try {
-                        if (sInstance.isValueSet(attrName)) {
-                            ret = true;
-                            break;
-                        }
-                    } catch (AtlasException e) {
-                            // ignore
-                    }
+        if (MapUtils.isNotEmpty(attributes)) {
+            for (Map.Entry<String, Object> attribute : attributes.entrySet()) {
+                if (attribute.getValue() != null) {
+                    ret = true;
+                    break;
                 }
             }
-        } else if (rInstance instanceof Referenceable) {
-            Referenceable referenceable = (Referenceable) rInstance;
-
-            ret = MapUtils.isNotEmpty(referenceable.getValuesMap());
         }
 
         return ret;