atlas-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mad...@apache.org
Subject [2/2] incubator-atlas git commit: ATLAS-1232: added preCreate(), preDelete() in typedef persistence, to enable edge creation for references in a later stage
Date Wed, 19 Oct 2016 23:54:56 GMT
ATLAS-1232: added preCreate(), preDelete() in typedef persistence, to enable edge creation for references in a later stage


Project: http://git-wip-us.apache.org/repos/asf/incubator-atlas/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-atlas/commit/08f56903
Tree: http://git-wip-us.apache.org/repos/asf/incubator-atlas/tree/08f56903
Diff: http://git-wip-us.apache.org/repos/asf/incubator-atlas/diff/08f56903

Branch: refs/heads/master
Commit: 08f56903929861a4c81445646be07fb18d099b5b
Parents: b6acff6
Author: Madhan Neethiraj <madhan@apache.org>
Authored: Wed Oct 19 04:09:59 2016 -0700
Committer: Madhan Neethiraj <madhan@apache.org>
Committed: Wed Oct 19 16:54:13 2016 -0700

----------------------------------------------------------------------
 .../apache/atlas/store/AtlasTypeDefStore.java   |  10 +-
 .../org/apache/atlas/type/AtlasStructType.java  |  15 +-
 .../apache/atlas/type/AtlasTypeRegistry.java    |  93 +++++-
 release-log.txt                                 |   1 +
 .../graph/AtlasClassificationDefStore.java      |  18 +-
 .../store/graph/AtlasEntityDefStore.java        |  17 +-
 .../store/graph/AtlasEnumDefStore.java          |  10 +-
 .../store/graph/AtlasStructDefStore.java        |  16 +-
 .../store/graph/AtlasTypeDefGraphStore.java     | 333 ++++++++++++++-----
 .../graph/v1/AtlasClassificationDefStoreV1.java | 169 ++++++----
 .../store/graph/v1/AtlasEntityDefStoreV1.java   | 169 ++++++----
 .../store/graph/v1/AtlasEnumDefStoreV1.java     |  87 +----
 .../store/graph/v1/AtlasStructDefStoreV1.java   | 199 ++++++-----
 .../graph/v1/AtlasTypeDefGraphStoreV1.java      |  12 +-
 .../org/apache/atlas/web/rest/TypesREST.java    |  24 ++
 15 files changed, 753 insertions(+), 420 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/08f56903/intg/src/main/java/org/apache/atlas/store/AtlasTypeDefStore.java
----------------------------------------------------------------------
diff --git a/intg/src/main/java/org/apache/atlas/store/AtlasTypeDefStore.java b/intg/src/main/java/org/apache/atlas/store/AtlasTypeDefStore.java
index 058ea44..95c5e64 100644
--- a/intg/src/main/java/org/apache/atlas/store/AtlasTypeDefStore.java
+++ b/intg/src/main/java/org/apache/atlas/store/AtlasTypeDefStore.java
@@ -43,8 +43,6 @@ public interface AtlasTypeDefStore {
 
     AtlasEnumDef createEnumDef(AtlasEnumDef enumDef) throws AtlasBaseException;
 
-    List<AtlasEnumDef> createEnumDefs(List<AtlasEnumDef> atlasEnumDefs) throws AtlasBaseException;
-
     List<AtlasEnumDef> getAllEnumDefs() throws AtlasBaseException;
 
     AtlasEnumDef getEnumDefByName(String name) throws AtlasBaseException;
@@ -66,8 +64,6 @@ public interface AtlasTypeDefStore {
     /*************************/
     AtlasStructDef createStructDef(AtlasStructDef structDef) throws AtlasBaseException;
 
-    List<AtlasStructDef> createStructDefs(List<AtlasStructDef> structDefs) throws AtlasBaseException;
-
     List<AtlasStructDef> getAllStructDefs() throws AtlasBaseException;
 
     AtlasStructDef getStructDefByName(String name) throws AtlasBaseException;
@@ -90,8 +86,6 @@ public interface AtlasTypeDefStore {
     /*********************************/
     AtlasClassificationDef createClassificationDef(AtlasClassificationDef classificationDef) throws AtlasBaseException;
 
-    List<AtlasClassificationDef> createClassificationDefs(List<AtlasClassificationDef> classificationDefs) throws AtlasBaseException;
-
     List<AtlasClassificationDef> getAllClassificationDefs() throws AtlasBaseException;
 
     AtlasClassificationDef getClassificationDefByName(String name) throws AtlasBaseException;
@@ -116,8 +110,6 @@ public interface AtlasTypeDefStore {
     /*************************/
     AtlasEntityDef createEntityDef(AtlasEntityDef entityDef) throws AtlasBaseException;
 
-    List<AtlasEntityDef> createEntityDefs(List<AtlasEntityDef> entityDefs) throws AtlasBaseException;
-
     List<AtlasEntityDef> getAllEntityDefs() throws AtlasBaseException;
 
     AtlasEntityDef getEntityDefByName(String name) throws AtlasBaseException;
@@ -140,5 +132,7 @@ public interface AtlasTypeDefStore {
 
     AtlasTypesDef updateTypesDef(AtlasTypesDef atlasTypesDef) throws AtlasBaseException;
 
+    void deleteTypesDef(AtlasTypesDef atlasTypesDef) throws AtlasBaseException;
+
     AtlasTypesDef searchTypesDef(SearchFilter searchFilter) throws AtlasBaseException;
 }

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/08f56903/intg/src/main/java/org/apache/atlas/type/AtlasStructType.java
----------------------------------------------------------------------
diff --git a/intg/src/main/java/org/apache/atlas/type/AtlasStructType.java b/intg/src/main/java/org/apache/atlas/type/AtlasStructType.java
index 4e741e5..fa0b02a 100644
--- a/intg/src/main/java/org/apache/atlas/type/AtlasStructType.java
+++ b/intg/src/main/java/org/apache/atlas/type/AtlasStructType.java
@@ -357,16 +357,16 @@ public class AtlasStructType extends AtlasType {
      */
     private void resolveForeignKeyConstraint(AtlasAttributeDef attribDef, AtlasConstraintDef constraintDef,
                                              AtlasType attribType) throws AtlasBaseException {
-        if (!(this instanceof AtlasEntityType)) {
+        if (this.getTypeCategory() != TypeCategory.ENTITY) {
             throw new AtlasBaseException(getTypeName() + "." + attribDef.getName() + ": "
                          + AtlasStructDef.AtlasConstraintDef.CONSTRAINT_TYPE_FOREIGN_KEY + " constraint not supported");
         }
 
-        if (attribType instanceof AtlasArrayType) {
+        if (attribType.getTypeCategory() == TypeCategory.ARRAY) {
             attribType = ((AtlasArrayType)attribType).getElementType();
         }
 
-        if (!(attribType instanceof AtlasEntityType)) {
+        if (attribType.getTypeCategory() != TypeCategory.ENTITY) {
             throw new AtlasBaseException(getTypeName() + "." + attribDef.getName() + ": "
                                       + AtlasConstraintDef.CONSTRAINT_TYPE_FOREIGN_KEY + " incompatible attribute type "
                                       + attribType.getTypeName());
@@ -383,16 +383,17 @@ public class AtlasStructType extends AtlasType {
      */
     private void resolveMappedFromRefConstraint(AtlasAttributeDef attribDef, AtlasConstraintDef constraintDef,
                                                 AtlasType attribType) throws AtlasBaseException {
-        if (!(this instanceof AtlasEntityType)) {
+
+        if (this.getTypeCategory() != TypeCategory.ENTITY) {
             throw new AtlasBaseException(getTypeName() + "." + attribDef.getName() + ": "
                                     + CONSTRAINT_TYPE_MAPPED_FROM_REF + " constraint not supported");
         }
 
-        if (attribType instanceof AtlasArrayType) {
+        if (attribType.getTypeCategory() == TypeCategory.ARRAY) {
             attribType = ((AtlasArrayType)attribType).getElementType();
         }
 
-        if (!(attribType instanceof AtlasEntityType)) {
+        if (attribType.getTypeCategory() != TypeCategory.ENTITY) {
             throw new AtlasBaseException(getTypeName() + "." + attribDef.getName() + ": "
                                   + CONSTRAINT_TYPE_MAPPED_FROM_REF + " incompatible attribute type "
                                   + attribType.getTypeName());
@@ -421,7 +422,7 @@ public class AtlasStructType extends AtlasType {
                     + " should be " + getTypeName() + ", but found " + refAttrib.getTypeName());
         }
 
-        mappedFromRefAttributes.put(attribDef.getName(), new TypeAttributePair(refAttrib.getTypeName(), refAttribName));
+        mappedFromRefAttributes.put(attribDef.getName(), new TypeAttributePair(attribType.getTypeName(), refAttribName));
     }
 
     private class TypeAttributePair {

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/08f56903/intg/src/main/java/org/apache/atlas/type/AtlasTypeRegistry.java
----------------------------------------------------------------------
diff --git a/intg/src/main/java/org/apache/atlas/type/AtlasTypeRegistry.java b/intg/src/main/java/org/apache/atlas/type/AtlasTypeRegistry.java
index f31ee50..bfdf8ea 100644
--- a/intg/src/main/java/org/apache/atlas/type/AtlasTypeRegistry.java
+++ b/intg/src/main/java/org/apache/atlas/type/AtlasTypeRegistry.java
@@ -40,7 +40,6 @@ import org.slf4j.LoggerFactory;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Map;
-import java.util.UUID;
 import java.util.concurrent.ConcurrentHashMap;
 
 /**
@@ -197,6 +196,33 @@ public class AtlasTypeRegistry {
             classificationDefs = new TypeDefCache<>(other.classificationDefs, allTypes);
             entityDefs         = new TypeDefCache<>(other.entityDefs, allTypes);
         }
+
+        void updateGuid(String typeName, String guid) {
+            if (typeName != null) {
+                enumDefs.updateGuid(typeName, guid);
+                structDefs.updateGuid(typeName, guid);
+                classificationDefs.updateGuid(typeName, guid);
+                entityDefs.updateGuid(typeName, guid);
+            }
+        }
+
+        void removeByGuid(String guid) {
+            if (guid != null) {
+                enumDefs.removeTypeDefByGuid(guid);
+                structDefs.removeTypeDefByGuid(guid);
+                classificationDefs.removeTypeDefByGuid(guid);
+                entityDefs.removeTypeDefByGuid(guid);
+            }
+        }
+
+        void removeByName(String typeName) {
+            if (typeName != null) {
+                enumDefs.removeTypeDefByName(typeName);
+                structDefs.removeTypeDefByName(typeName);
+                classificationDefs.removeTypeDefByName(typeName);
+                entityDefs.removeTypeDefByName(typeName);
+            }
+        }
     }
 
     public static class AtlasTransientTypeRegistry extends AtlasTypeRegistry {
@@ -227,6 +253,19 @@ public class AtlasTypeRegistry {
             }
         }
 
+        public void updateGuid(String typeName, String guid) {
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("==> AtlasTypeRegistry.updateGuid({}, {})", typeName, guid);
+            }
+
+            registryData.updateGuid(typeName, guid);
+
+
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("<== AtlasTypeRegistry.updateGuid({}, {})", typeName, guid);
+            }
+        }
+
         public void addTypes(Collection<? extends AtlasBaseTypeDef> typeDefs) throws AtlasBaseException {
             if (LOG.isDebugEnabled()) {
                 LOG.debug("==> AtlasTypeRegistry.addTypes(length={})", (typeDefs == null ? 0 : typeDefs.size()));
@@ -351,10 +390,7 @@ public class AtlasTypeRegistry {
             }
 
             if (guid != null) {
-                registryData.enumDefs.removeTypeDefByGuid(guid);
-                registryData.structDefs.removeTypeDefByGuid(guid);
-                registryData.classificationDefs.removeTypeDefByGuid(guid);
-                registryData.entityDefs.removeTypeDefByGuid(guid);
+                registryData.removeByGuid(guid);
 
                 resolveReferences();
             }
@@ -370,10 +406,7 @@ public class AtlasTypeRegistry {
             }
 
             if (name != null) {
-                registryData.enumDefs.removeTypeDefByName(name);
-                registryData.structDefs.removeTypeDefByName(name);
-                registryData.classificationDefs.removeTypeDefByName(name);
-                registryData.entityDefs.removeTypeDefByName(name);
+                registryData.removeByName(name);
 
                 resolveReferences();
             }
@@ -390,10 +423,6 @@ public class AtlasTypeRegistry {
             }
 
             if (typeDef != null) {
-                if (StringUtils.isBlank(typeDef.getGuid())) {
-                    typeDef.setGuid(UUID.randomUUID().toString());
-                }
-
                 if (typeDef.getClass().equals(AtlasEnumDef.class)) {
                     AtlasEnumDef enumDef = (AtlasEnumDef) typeDef;
 
@@ -599,6 +628,20 @@ class TypeCache {
         return ret;
     }
 
+    public void updateGuid(String typeName, String currGuid, String newGuid) {
+        if (currGuid != null) {
+            typeGuidMap.remove(currGuid);
+        }
+
+        if (typeName != null && newGuid != null) {
+            AtlasType type = typeNameMap.get(typeName);
+
+            if (type != null) {
+                typeGuidMap.put(newGuid, type);
+            }
+        }
+    }
+
     public void removeTypeByGuid(String guid) {
         if (guid != null) {
             typeGuidMap.remove(guid);
@@ -659,6 +702,30 @@ class TypeDefCache<T extends AtlasBaseTypeDef> {
         return ret;
     }
 
+    public void updateGuid(String typeName, String newGuid) {
+        if (typeName != null) {
+            T typeDef = typeDefNameMap.get(typeName);
+
+            if (typeDef != null) {
+                String currGuid = typeDef.getGuid();
+
+                if (!StringUtils.equals(currGuid, newGuid)) {
+                    if (currGuid != null) {
+                        typeDefGuidMap.remove(currGuid);
+                    }
+
+                    typeDef.setGuid(newGuid);
+
+                    if (newGuid != null) {
+                        typeDefGuidMap.put(newGuid, typeDef);
+                    }
+
+                    typeCache.updateGuid(typeName, currGuid, newGuid);
+                }
+            }
+        }
+    }
+
     public void removeTypeDefByGuid(String guid) {
         if (guid != null) {
             T typeDef = typeDefGuidMap.remove(guid);

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/08f56903/release-log.txt
----------------------------------------------------------------------
diff --git a/release-log.txt b/release-log.txt
index e4e52b0..88af9fc 100644
--- a/release-log.txt
+++ b/release-log.txt
@@ -9,6 +9,7 @@ ATLAS-1060 Add composite indexes for exact match performance improvements for al
 ATLAS-1127 Modify creation and modification timestamps to Date instead of Long(sumasai)
 
 ALL CHANGES:
+ATLAS-1232 added preCreate(), preDelete() in typedef persistence, to enable edge creation for references in a later stage (mneethiraj)
 ATLAS-1183 UI: help link should point to atlas website (kevalbhatt via shwethags)
 ATLAS-1182 Hive Column level lineage docs (svimal2106 via shwethags)
 ATLAS-1230 updated AtlasTypeRegistry to support batch, atomic type updates (mneethiraj)

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/08f56903/repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasClassificationDefStore.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasClassificationDefStore.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasClassificationDefStore.java
index 2917c20..ff00186 100644
--- a/repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasClassificationDefStore.java
+++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasClassificationDefStore.java
@@ -28,9 +28,9 @@ import java.util.List;
  * Interface for graph persistence store for AtlasClassificationDef
  */
 public interface AtlasClassificationDefStore {
-    AtlasClassificationDef create(AtlasClassificationDef classificationDef) throws AtlasBaseException;
+    Object preCreate(AtlasClassificationDef classificationDef) throws AtlasBaseException;
 
-    List<AtlasClassificationDef> create(List<AtlasClassificationDef> classificationDefs) throws AtlasBaseException;
+    AtlasClassificationDef create(AtlasClassificationDef classifiDef, Object preCreateResult) throws AtlasBaseException;
 
     List<AtlasClassificationDef> getAll() throws AtlasBaseException;
 
@@ -38,19 +38,19 @@ public interface AtlasClassificationDefStore {
 
     AtlasClassificationDef getByGuid(String guid) throws AtlasBaseException;
 
-    AtlasClassificationDef updateByName(String name, AtlasClassificationDef classificationDef) throws AtlasBaseException;
+    AtlasClassificationDef update(AtlasClassificationDef classifiDef) throws AtlasBaseException;
 
-    AtlasClassificationDef updateByGuid(String guid, AtlasClassificationDef classificationDef) throws AtlasBaseException;
+    AtlasClassificationDef updateByName(String name, AtlasClassificationDef classifiDef) throws AtlasBaseException;
 
-    List<AtlasClassificationDef> update(List<AtlasClassificationDef> classificationDefs) throws AtlasBaseException;
+    AtlasClassificationDef updateByGuid(String guid, AtlasClassificationDef classifiDef) throws AtlasBaseException;
 
-    void deleteByName(String name) throws AtlasBaseException;
+    Object preDeleteByName(String name) throws AtlasBaseException;
 
-    void deleteByNames(List<String> names) throws AtlasBaseException;
+    void deleteByName(String name, Object preDeleteResult) throws AtlasBaseException;
 
-    void deleteByGuid(String guid) throws AtlasBaseException;
+    Object preDeleteByGuid(String guid) throws AtlasBaseException;
 
-    void deleteByGuids(List<String> guids) throws AtlasBaseException;
+    void deleteByGuid(String guid, Object preDeleteResult) throws AtlasBaseException;
 
     AtlasClassificationDefs search(SearchFilter filter) throws AtlasBaseException;
 }

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/08f56903/repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasEntityDefStore.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasEntityDefStore.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasEntityDefStore.java
index 2c81cdf..1ad04b3 100644
--- a/repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasEntityDefStore.java
+++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasEntityDefStore.java
@@ -19,6 +19,7 @@ package org.apache.atlas.repository.store.graph;
 
 import org.apache.atlas.exception.AtlasBaseException;
 import org.apache.atlas.model.SearchFilter;
+import org.apache.atlas.model.typedef.AtlasClassificationDef;
 import org.apache.atlas.model.typedef.AtlasEntityDef;
 import org.apache.atlas.model.typedef.AtlasEntityDef.AtlasEntityDefs;
 
@@ -28,9 +29,9 @@ import java.util.List;
  * Interface for graph persistence store for AtlasEntityDef
  */
 public interface AtlasEntityDefStore {
-    AtlasEntityDef create(AtlasEntityDef entityDef) throws AtlasBaseException;
+    Object preCreate(AtlasEntityDef entityDef) throws AtlasBaseException;
 
-    List<AtlasEntityDef> create(List<AtlasEntityDef> entityDefs) throws AtlasBaseException;
+    AtlasEntityDef create(AtlasEntityDef entityDef, Object preCreateResult) throws AtlasBaseException;
 
     List<AtlasEntityDef> getAll() throws AtlasBaseException;
 
@@ -38,19 +39,19 @@ public interface AtlasEntityDefStore {
 
     AtlasEntityDef getByGuid(String guid) throws AtlasBaseException;
 
+    AtlasEntityDef update(AtlasEntityDef entityDef) throws AtlasBaseException;
+
     AtlasEntityDef updateByName(String name, AtlasEntityDef entityDef) throws AtlasBaseException;
 
     AtlasEntityDef updateByGuid(String guid, AtlasEntityDef entityDef) throws AtlasBaseException;
 
-    List<AtlasEntityDef> update(List<AtlasEntityDef> entityDefs) throws AtlasBaseException;
-
-    void deleteByName(String name) throws AtlasBaseException;
+    Object preDeleteByName(String name) throws AtlasBaseException;
 
-    void deleteByNames(List<String> names) throws AtlasBaseException;
+    void deleteByName(String name, Object preDeleteResult) throws AtlasBaseException;
 
-    void deleteByGuid(String guid) throws AtlasBaseException;
+    Object preDeleteByGuid(String guid) throws AtlasBaseException;
 
-    void deleteByGuids(List<String> guids) throws AtlasBaseException;
+    void deleteByGuid(String guid, Object preDeleteResult) throws AtlasBaseException;
 
     AtlasEntityDefs search(SearchFilter filter) throws AtlasBaseException;
 }

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/08f56903/repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasEnumDefStore.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasEnumDefStore.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasEnumDefStore.java
index d997a90..217a927 100644
--- a/repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasEnumDefStore.java
+++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasEnumDefStore.java
@@ -30,27 +30,21 @@ import java.util.List;
 public interface AtlasEnumDefStore {
     AtlasEnumDef create(AtlasEnumDef enumDef) throws AtlasBaseException;
 
-    List<AtlasEnumDef> create(List<AtlasEnumDef> atlasEnumDefs) throws AtlasBaseException;
-
     List<AtlasEnumDef> getAll() throws AtlasBaseException;
 
     AtlasEnumDef getByName(String name) throws AtlasBaseException;
 
     AtlasEnumDef getByGuid(String guid) throws AtlasBaseException;
 
+    AtlasEnumDef update(AtlasEnumDef enumDef) throws AtlasBaseException;
+
     AtlasEnumDef updateByName(String name, AtlasEnumDef enumDef) throws AtlasBaseException;
 
     AtlasEnumDef updateByGuid(String guid, AtlasEnumDef enumDef) throws AtlasBaseException;
 
-    List<AtlasEnumDef> update(List<AtlasEnumDef> enumDefs) throws AtlasBaseException;
-
     void deleteByName(String name) throws AtlasBaseException;
 
-    void deleteByNames(List<String> names) throws AtlasBaseException;
-
     void deleteByGuid(String guid) throws AtlasBaseException;
 
-    void deleteByGuids(List<String> guids) throws AtlasBaseException;
-
     AtlasEnumDefs search(SearchFilter filter) throws AtlasBaseException;
 }

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/08f56903/repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasStructDefStore.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasStructDefStore.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasStructDefStore.java
index 1308bb3..fc3ffb5 100644
--- a/repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasStructDefStore.java
+++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasStructDefStore.java
@@ -28,9 +28,9 @@ import java.util.List;
  * Interface for graph persistence store for AtlasStructDef
  */
 public interface AtlasStructDefStore {
-    AtlasStructDef create(AtlasStructDef structDef) throws AtlasBaseException;
+    Object preCreate(AtlasStructDef structDef) throws AtlasBaseException;
 
-    List<AtlasStructDef> create(List<AtlasStructDef> structDefs) throws AtlasBaseException;
+    AtlasStructDef create(AtlasStructDef structDef, Object preCreateResult) throws AtlasBaseException;
 
     List<AtlasStructDef> getAll() throws AtlasBaseException;
 
@@ -38,19 +38,19 @@ public interface AtlasStructDefStore {
 
     AtlasStructDef getByGuid(String guid) throws AtlasBaseException;
 
+    AtlasStructDef update(AtlasStructDef structDef) throws AtlasBaseException;
+
     AtlasStructDef updateByName(String name, AtlasStructDef structDef) throws AtlasBaseException;
 
     AtlasStructDef updateByGuid(String guid, AtlasStructDef structDef) throws AtlasBaseException;
 
-    List<AtlasStructDef> update(List<AtlasStructDef> structDefs) throws AtlasBaseException;
-
-    void deleteByName(String name) throws AtlasBaseException;
+    Object preDeleteByName(String name) throws AtlasBaseException;
 
-    void deleteByNames(List<String> names) throws AtlasBaseException;
+    void deleteByName(String name, Object preDeleteResult) throws AtlasBaseException;
 
-    void deleteByGuid(String guid) throws AtlasBaseException;
+    Object preDeleteByGuid(String name) throws AtlasBaseException;
 
-    void deleteByGuids(List<String> guids) throws AtlasBaseException;
+    void deleteByGuid(String guid, Object preDeleteResult) throws AtlasBaseException;
 
     AtlasStructDefs search(SearchFilter filter) throws AtlasBaseException;
 }

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/08f56903/repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasTypeDefGraphStore.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasTypeDefGraphStore.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasTypeDefGraphStore.java
index 12047bf..1aca5eb 100644
--- a/repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasTypeDefGraphStore.java
+++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasTypeDefGraphStore.java
@@ -35,6 +35,7 @@ import org.apache.atlas.type.AtlasTypeRegistry;
 import org.apache.atlas.type.AtlasTypeRegistry.AtlasTransientTypeRegistry;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.collections.Predicate;
+import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -87,19 +88,7 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore {
 
         AtlasEnumDef ret = getEnumDefStore(ttr).create(enumDef);
 
-        typeRegistry.commitTransientTypeRegistry(ttr);
-
-        return ret;
-    }
-
-    @Override
-    @GraphTransaction
-    public List<AtlasEnumDef> createEnumDefs(List<AtlasEnumDef> enumDefs) throws AtlasBaseException {
-        AtlasTransientTypeRegistry ttr = typeRegistry.createTransientTypeRegistry();
-
-        ttr.addTypes(enumDefs);
-
-        List<AtlasEnumDef> ret = getEnumDefStore(ttr).create(enumDefs);
+        ttr.updateGuid(ret.getName(), ret.getGuid());
 
         typeRegistry.commitTransientTypeRegistry(ttr);
 
@@ -201,21 +190,9 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore {
 
         ttr.addType(structDef);
 
-        AtlasStructDef ret = getStructDefStore(ttr).create(structDef);
+        AtlasStructDef ret = getStructDefStore(ttr).create(structDef, null);
 
-        typeRegistry.commitTransientTypeRegistry(ttr);
-
-        return ret;
-    }
-
-    @Override
-    @GraphTransaction
-    public List<AtlasStructDef> createStructDefs(List<AtlasStructDef> structDefs) throws AtlasBaseException {
-        AtlasTransientTypeRegistry ttr = typeRegistry.createTransientTypeRegistry();
-
-        ttr.addTypes(structDefs);
-
-        List<AtlasStructDef> ret = getStructDefStore(ttr).create(structDefs);
+        ttr.updateGuid(ret.getName(), ret.getGuid());
 
         typeRegistry.commitTransientTypeRegistry(ttr);
 
@@ -287,7 +264,7 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore {
 
         ttr.removeTypeByName(name);
 
-        getStructDefStore(ttr).deleteByName(name);
+        getStructDefStore(ttr).deleteByName(name, null);
 
         typeRegistry.commitTransientTypeRegistry(ttr);
     }
@@ -299,7 +276,7 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore {
 
         ttr.removeTypeByGuid(guid);
 
-        getStructDefStore(ttr).deleteByGuid(guid);
+        getStructDefStore(ttr).deleteByGuid(guid, null);
 
         typeRegistry.commitTransientTypeRegistry(ttr);
     }
@@ -318,22 +295,9 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore {
 
         ttr.addType(classificationDef);
 
-        AtlasClassificationDef ret = getClassificationDefStore(ttr).create(classificationDef);
-
-        typeRegistry.commitTransientTypeRegistry(ttr);
-
-        return ret;
-    }
-
-    @Override
-    @GraphTransaction
-    public List<AtlasClassificationDef> createClassificationDefs(List<AtlasClassificationDef> classificationDefs)
-        throws AtlasBaseException {
-        AtlasTransientTypeRegistry ttr = typeRegistry.createTransientTypeRegistry();
-
-        ttr.addTypes(classificationDefs);
+        AtlasClassificationDef ret = getClassificationDefStore(ttr).create(classificationDef, null);
 
-        List<AtlasClassificationDef> ret = getClassificationDefStore(ttr).create(classificationDefs);
+        ttr.updateGuid(ret.getName(), ret.getGuid());
 
         typeRegistry.commitTransientTypeRegistry(ttr);
 
@@ -407,7 +371,7 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore {
 
         ttr.removeTypeByName(name);
 
-        getClassificationDefStore(ttr).deleteByName(name);
+        getClassificationDefStore(ttr).deleteByName(name, null);
 
         typeRegistry.commitTransientTypeRegistry(ttr);
     }
@@ -419,7 +383,7 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore {
 
         ttr.removeTypeByGuid(guid);
 
-        getClassificationDefStore(ttr).deleteByGuid(guid);
+        getClassificationDefStore(ttr).deleteByGuid(guid, null);
 
         typeRegistry.commitTransientTypeRegistry(ttr);
     }
@@ -437,21 +401,9 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore {
 
         ttr.addType(entityDef);
 
-        AtlasEntityDef ret = getEntityDefStore(ttr).create(entityDef);
-
-        typeRegistry.commitTransientTypeRegistry(ttr);
-
-        return ret;
-    }
-
-    @Override
-    @GraphTransaction
-    public List<AtlasEntityDef> createEntityDefs(List<AtlasEntityDef> entityDefs) throws AtlasBaseException {
-        AtlasTransientTypeRegistry ttr = typeRegistry.createTransientTypeRegistry();
-
-        ttr.addTypes(entityDefs);
+        AtlasEntityDef ret = getEntityDefStore(ttr).create(entityDef, null);
 
-        List<AtlasEntityDef> ret = getEntityDefStore(ttr).create(entityDefs);
+        ttr.updateGuid(ret.getName(), ret.getGuid());
 
         typeRegistry.commitTransientTypeRegistry(ttr);
 
@@ -523,7 +475,7 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore {
 
         ttr.removeTypeByName(name);
 
-        getEntityDefStore(ttr).deleteByName(name);
+        getEntityDefStore(ttr).deleteByName(name, null);
 
         typeRegistry.commitTransientTypeRegistry(ttr);
     }
@@ -535,7 +487,7 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore {
 
         ttr.removeTypeByGuid(guid);
 
-        getEntityDefStore(ttr).deleteByGuid(guid);
+        getEntityDefStore(ttr).deleteByGuid(guid, null);
 
         typeRegistry.commitTransientTypeRegistry(ttr);
     }
@@ -549,39 +501,161 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore {
     @Override
     @GraphTransaction
     public AtlasTypesDef createTypesDef(AtlasTypesDef typesDef) throws AtlasBaseException {
-        LOG.info("Creating EnumDefs");
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("==> AtlasTypeDefGraphStore.createTypesDef(enums={}, structs={}, classfications={}, entities={})",
+                      CollectionUtils.size(typesDef.getEnumDefs()),
+                      CollectionUtils.size(typesDef.getStructDefs()),
+                      CollectionUtils.size(typesDef.getClassificationDefs()),
+                      CollectionUtils.size(typesDef.getEntityDefs()));
+        }
+
+        AtlasTypesDef ret = new AtlasTypesDef();
+
         AtlasTransientTypeRegistry ttr = typeRegistry.createTransientTypeRegistry();
 
         ttr.addTypes(typesDef);
 
-        List<AtlasEnumDef>           enumDefs     = getEnumDefStore(ttr).create(typesDef.getEnumDefs());
-        List<AtlasStructDef>         structDefs   = getStructDefStore(ttr).create(typesDef.getStructDefs());
-        List<AtlasClassificationDef> classifiDefs = getClassificationDefStore(ttr).create(typesDef.getClassificationDefs());
-        List<AtlasEntityDef>         entityDefs   = getEntityDefStore(ttr).create(typesDef.getEntityDefs());
+        AtlasEnumDefStore           enumDefStore     = getEnumDefStore(ttr);
+        AtlasStructDefStore         structDefStore   = getStructDefStore(ttr);
+        AtlasClassificationDefStore classifiDefStore = getClassificationDefStore(ttr);
+        AtlasEntityDefStore         entityDefStore   = getEntityDefStore(ttr);
+
+        List<Object> preCreateStructDefs   = new ArrayList<>();
+        List<Object> preCreateClassifiDefs = new ArrayList<>();
+        List<Object> preCreateEntityDefs   = new ArrayList<>();
 
-        AtlasTypesDef ret = new AtlasTypesDef(enumDefs, structDefs, classifiDefs, entityDefs);
+        if (CollectionUtils.isNotEmpty(typesDef.getEnumDefs())) {
+            for (AtlasEnumDef enumDef : typesDef.getEnumDefs()) {
+                AtlasEnumDef createdDef = enumDefStore.create(enumDef);
+
+                ttr.updateGuid(createdDef.getName(), createdDef.getGuid());
+
+                ret.getEnumDefs().add(createdDef);
+            }
+        }
+
+        if (CollectionUtils.isNotEmpty(typesDef.getStructDefs())) {
+            for (AtlasStructDef structDef : typesDef.getStructDefs()) {
+                preCreateStructDefs.add(structDefStore.preCreate(structDef));
+            }
+        }
+
+        if (CollectionUtils.isNotEmpty(typesDef.getClassificationDefs())) {
+            for (AtlasClassificationDef classifiDef : typesDef.getClassificationDefs()) {
+                preCreateClassifiDefs.add(classifiDefStore.preCreate(classifiDef));
+            }
+        }
+
+        if (CollectionUtils.isNotEmpty(typesDef.getEntityDefs())) {
+            for (AtlasEntityDef entityDef : typesDef.getEntityDefs()) {
+                preCreateEntityDefs.add(entityDefStore.preCreate(entityDef));
+            }
+        }
+
+        if (CollectionUtils.isNotEmpty(typesDef.getStructDefs())) {
+            int i = 0;
+            for (AtlasStructDef structDef : typesDef.getStructDefs()) {
+                AtlasStructDef createdDef = structDefStore.create(structDef, preCreateStructDefs.get(i));
+
+                ttr.updateGuid(createdDef.getName(), createdDef.getGuid());
+
+                ret.getStructDefs().add(createdDef);
+                i++;
+            }
+        }
+
+        if (CollectionUtils.isNotEmpty(typesDef.getClassificationDefs())) {
+            int i = 0;
+            for (AtlasClassificationDef classifiDef : typesDef.getClassificationDefs()) {
+                AtlasClassificationDef createdDef = classifiDefStore.create(classifiDef, preCreateClassifiDefs.get(i));
+
+                ttr.updateGuid(createdDef.getName(), createdDef.getGuid());
+
+                ret.getClassificationDefs().add(createdDef);
+                i++;
+            }
+        }
+
+        if (CollectionUtils.isNotEmpty(typesDef.getEntityDefs())) {
+            int i = 0;
+            for (AtlasEntityDef entityDef : typesDef.getEntityDefs()) {
+                AtlasEntityDef createdDef = entityDefStore.create(entityDef, preCreateEntityDefs.get(i));
+
+                ttr.updateGuid(createdDef.getName(), createdDef.getGuid());
+
+                ret.getEntityDefs().add(createdDef);
+                i++;
+            }
+        }
 
         typeRegistry.commitTransientTypeRegistry(ttr);
 
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("<== AtlasTypeDefGraphStore.createTypesDef(enums={}, structs={}, classfications={}, entities={})",
+                    CollectionUtils.size(typesDef.getEnumDefs()),
+                    CollectionUtils.size(typesDef.getStructDefs()),
+                    CollectionUtils.size(typesDef.getClassificationDefs()),
+                    CollectionUtils.size(typesDef.getEntityDefs()));
+        }
+
         return ret;
     }
 
     @Override
     @GraphTransaction
     public AtlasTypesDef updateTypesDef(AtlasTypesDef typesDef) throws AtlasBaseException {
-        LOG.info("Updating EnumDefs");
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("==> AtlasTypeDefGraphStore.updateTypesDef(enums={}, structs={}, classfications={}, entities={})",
+                    CollectionUtils.size(typesDef.getEnumDefs()),
+                    CollectionUtils.size(typesDef.getStructDefs()),
+                    CollectionUtils.size(typesDef.getClassificationDefs()),
+                    CollectionUtils.size(typesDef.getEntityDefs()));
+        }
+
+        AtlasTypesDef ret = new AtlasTypesDef();
+
         AtlasTransientTypeRegistry ttr = typeRegistry.createTransientTypeRegistry();
 
         ttr.updateTypes(typesDef);
 
-        List<AtlasEnumDef>           enumDefs     = getEnumDefStore(ttr).update(typesDef.getEnumDefs());
-        List<AtlasStructDef>         structDefs   = getStructDefStore(ttr).update(typesDef.getStructDefs());
-        List<AtlasClassificationDef> classifiDefs = getClassificationDefStore(ttr).update(typesDef.getClassificationDefs());
-        List<AtlasEntityDef>         entityDefs   = getEntityDefStore(ttr).update(typesDef.getEntityDefs());
+        AtlasEnumDefStore           enumDefStore     = getEnumDefStore(ttr);
+        AtlasStructDefStore         structDefStore   = getStructDefStore(ttr);
+        AtlasClassificationDefStore classifiDefStore = getClassificationDefStore(ttr);
+        AtlasEntityDefStore         entityDefStore   = getEntityDefStore(ttr);
+
+        if (CollectionUtils.isNotEmpty(typesDef.getEnumDefs())) {
+            for (AtlasEnumDef enumDef : typesDef.getEnumDefs()) {
+                ret.getEnumDefs().add(enumDefStore.update(enumDef));
+            }
+        }
+
+        if (CollectionUtils.isNotEmpty(typesDef.getStructDefs())) {
+            for (AtlasStructDef structDef : typesDef.getStructDefs()) {
+                ret.getStructDefs().add(structDefStore.update(structDef));
+            }
+        }
+
+        if (CollectionUtils.isNotEmpty(typesDef.getClassificationDefs())) {
+            for (AtlasClassificationDef classifiDef : typesDef.getClassificationDefs()) {
+                ret.getClassificationDefs().add(classifiDefStore.update(classifiDef));
+            }
+        }
+
+        if (CollectionUtils.isNotEmpty(typesDef.getEntityDefs())) {
+            for (AtlasEntityDef entityDef : typesDef.getEntityDefs()) {
+                ret.getEntityDefs().add(entityDefStore.update(entityDef));
+            }
+        }
 
         typeRegistry.commitTransientTypeRegistry(ttr);
 
-        AtlasTypesDef ret = new AtlasTypesDef(enumDefs, structDefs, classifiDefs, entityDefs);
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("<== AtlasTypeDefGraphStore.updateTypesDef(enums={}, structs={}, classfications={}, entities={})",
+                    CollectionUtils.size(typesDef.getEnumDefs()),
+                    CollectionUtils.size(typesDef.getStructDefs()),
+                    CollectionUtils.size(typesDef.getClassificationDefs()),
+                    CollectionUtils.size(typesDef.getEntityDefs()));
+        }
 
         return ret;
 
@@ -589,6 +663,117 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore {
 
     @Override
     @GraphTransaction
+    public void deleteTypesDef(AtlasTypesDef typesDef) throws AtlasBaseException {
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("==> AtlasTypeDefGraphStore.deleteTypesDef(enums={}, structs={}, classfications={}, entities={})",
+                    CollectionUtils.size(typesDef.getEnumDefs()),
+                    CollectionUtils.size(typesDef.getStructDefs()),
+                    CollectionUtils.size(typesDef.getClassificationDefs()),
+                    CollectionUtils.size(typesDef.getEntityDefs()));
+        }
+
+        AtlasTransientTypeRegistry ttr = typeRegistry.createTransientTypeRegistry();
+
+        ttr.addTypes(typesDef);
+
+        AtlasEnumDefStore           enumDefStore     = getEnumDefStore(ttr);
+        AtlasStructDefStore         structDefStore   = getStructDefStore(ttr);
+        AtlasClassificationDefStore classifiDefStore = getClassificationDefStore(ttr);
+        AtlasEntityDefStore         entityDefStore   = getEntityDefStore(ttr);
+
+        List<Object> preDeleteStructDefs   = new ArrayList<>();
+        List<Object> preDeleteClassifiDefs = new ArrayList<>();
+        List<Object> preDeleteEntityDefs   = new ArrayList<>();
+
+        if (CollectionUtils.isNotEmpty(typesDef.getStructDefs())) {
+            for (AtlasStructDef structDef : typesDef.getStructDefs()) {
+                if (StringUtils.isNotBlank(structDef.getGuid())) {
+                    preDeleteStructDefs.add(structDefStore.preDeleteByGuid(structDef.getGuid()));
+                } else {
+                    preDeleteStructDefs.add(structDefStore.preDeleteByName(structDef.getName()));
+                }
+            }
+        }
+
+        if (CollectionUtils.isNotEmpty(typesDef.getClassificationDefs())) {
+            for (AtlasClassificationDef classifiDef : typesDef.getClassificationDefs()) {
+                if (StringUtils.isNotBlank(classifiDef.getGuid())) {
+                    preDeleteClassifiDefs.add(classifiDefStore.preDeleteByGuid(classifiDef.getGuid()));
+                } else {
+                    preDeleteClassifiDefs.add(classifiDefStore.preDeleteByName(classifiDef.getName()));
+                }
+            }
+        }
+
+        if (CollectionUtils.isNotEmpty(typesDef.getEntityDefs())) {
+            for (AtlasEntityDef entityDef : typesDef.getEntityDefs()) {
+                if (StringUtils.isNotBlank(entityDef.getGuid())) {
+                    preDeleteEntityDefs.add(entityDefStore.preDeleteByGuid(entityDef.getGuid()));
+                } else {
+                    preDeleteEntityDefs.add(entityDefStore.preDeleteByName(entityDef.getName()));
+                }
+            }
+        }
+
+        if (CollectionUtils.isNotEmpty(typesDef.getStructDefs())) {
+            int i = 0;
+            for (AtlasStructDef structDef : typesDef.getStructDefs()) {
+                if (StringUtils.isNotBlank(structDef.getGuid())) {
+                    structDefStore.deleteByGuid(structDef.getGuid(), preDeleteStructDefs.get(i));
+                } else {
+                    structDefStore.deleteByName(structDef.getName(), preDeleteStructDefs.get(i));
+                }
+                i++;
+            }
+        }
+
+        if (CollectionUtils.isNotEmpty(typesDef.getClassificationDefs())) {
+            int i = 0;
+            for (AtlasClassificationDef classifiDef : typesDef.getClassificationDefs()) {
+                if (StringUtils.isNotBlank(classifiDef.getGuid())) {
+                    classifiDefStore.deleteByGuid(classifiDef.getGuid(), preDeleteClassifiDefs.get(i));
+                } else {
+                    classifiDefStore.deleteByName(classifiDef.getName(), preDeleteClassifiDefs.get(i));
+                }
+                i++;
+            }
+        }
+
+        if (CollectionUtils.isNotEmpty(typesDef.getEntityDefs())) {
+            int i = 0;
+            for (AtlasEntityDef entityDef : typesDef.getEntityDefs()) {
+                if (StringUtils.isNotBlank(entityDef.getGuid())) {
+                    entityDefStore.deleteByGuid(entityDef.getGuid(), preDeleteEntityDefs.get(i));
+                } else {
+                    entityDefStore.deleteByName(entityDef.getName(), preDeleteEntityDefs.get(i));
+                }
+                i++;
+            }
+        }
+
+        if (CollectionUtils.isNotEmpty(typesDef.getEnumDefs())) {
+            for (AtlasEnumDef enumDef : typesDef.getEnumDefs()) {
+                if (StringUtils.isNotBlank(enumDef.getGuid())) {
+                    enumDefStore.deleteByGuid(enumDef.getGuid());
+                } else {
+                    enumDefStore.deleteByName(enumDef.getName());
+                }
+            }
+        }
+
+        typeRegistry.commitTransientTypeRegistry(ttr);
+
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("<== AtlasTypeDefGraphStore.deleteTypesDef(enums={}, structs={}, classfications={}, entities={})",
+                    CollectionUtils.size(typesDef.getEnumDefs()),
+                    CollectionUtils.size(typesDef.getStructDefs()),
+                    CollectionUtils.size(typesDef.getClassificationDefs()),
+                    CollectionUtils.size(typesDef.getEntityDefs()));
+        }
+    }
+
+    @Override
+    @GraphTransaction
     public AtlasTypesDef searchTypesDef(SearchFilter searchFilter) throws AtlasBaseException {
         AtlasTypesDef typesDef = new AtlasTypesDef();
         Predicate searchPredicates = FilterUtil.getPredicateFromSearchFilter(searchFilter);

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/08f56903/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasClassificationDefStoreV1.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasClassificationDefStoreV1.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasClassificationDefStoreV1.java
index 7b6e08a..4bdcf00 100644
--- a/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasClassificationDefStoreV1.java
+++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasClassificationDefStoreV1.java
@@ -31,6 +31,7 @@ import org.apache.atlas.type.AtlasType;
 import org.apache.atlas.type.AtlasTypeRegistry;
 import org.apache.atlas.typesystem.types.DataTypes.TypeCategory;
 import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -49,45 +50,57 @@ public class AtlasClassificationDefStoreV1 extends AtlasAbstractDefStoreV1 imple
     }
 
     @Override
-    public AtlasClassificationDef create(AtlasClassificationDef classificationDef) throws AtlasBaseException {
+    public AtlasVertex preCreate(AtlasClassificationDef classificationDef) throws AtlasBaseException {
         if (LOG.isDebugEnabled()) {
-            LOG.debug("==> AtlasClassificationDefStoreV1.create({})", classificationDef);
+            LOG.debug("==> AtlasClassificationDefStoreV1.preCreate({})", classificationDef);
         }
 
-        AtlasVertex vertex = typeDefStore.findTypeVertexByName(classificationDef.getName());
+        AtlasType type = typeRegistry.getType(classificationDef.getName());
 
-        if (vertex != null) {
-            throw new AtlasBaseException(classificationDef.getName() + ": type already exists");
+        if (type.getTypeCategory() != AtlasType.TypeCategory.CLASSIFICATION) {
+            throw new AtlasBaseException(classificationDef.getName() + ": not a classification type");
         }
 
-        vertex = typeDefStore.createTypeVertex(classificationDef);
+        AtlasVertex ret = typeDefStore.findTypeVertexByName(classificationDef.getName());
 
-        toVertex(classificationDef, vertex);
+        if (ret != null) {
+            throw new AtlasBaseException(classificationDef.getName() + ": type already exists");
+        }
 
-        AtlasClassificationDef ret = toClassificationDef(vertex);
+        ret = typeDefStore.createTypeVertex(classificationDef);
+
+        updateVertexPreCreate(classificationDef, (AtlasClassificationType)type, ret);
 
         if (LOG.isDebugEnabled()) {
-            LOG.debug("<== AtlasClassificationDefStoreV1.create({}): {}", classificationDef, ret);
+            LOG.debug("<== AtlasClassificationDefStoreV1.preCreate({}): {}", classificationDef, ret);
         }
 
         return ret;
     }
 
     @Override
-    public List<AtlasClassificationDef> create(List<AtlasClassificationDef> classificationDefs) throws AtlasBaseException {
+    public AtlasClassificationDef create(AtlasClassificationDef classificationDef, Object preCreateResult)
+        throws AtlasBaseException {
         if (LOG.isDebugEnabled()) {
-            LOG.debug("==> AtlasClassificationDefStoreV1.create({})", classificationDefs);
+            LOG.debug("==> AtlasClassificationDefStoreV1.create({}, {})", classificationDef, preCreateResult);
         }
 
-        List<AtlasClassificationDef> ret = new ArrayList<>();
+        AtlasVertex vertex;
 
-        for (AtlasClassificationDef classificationDef : classificationDefs) {
-            ret.add(create(classificationDef));
+        if (preCreateResult == null || !(preCreateResult instanceof AtlasVertex)) {
+            vertex = preCreate(classificationDef);
+        } else {
+            vertex = (AtlasVertex)preCreateResult;
         }
 
+        updateVertexAddReferences(classificationDef, vertex);
+
+        AtlasClassificationDef ret = toClassificationDef(vertex);
+
         if (LOG.isDebugEnabled()) {
-            LOG.debug("<== AtlasClassificationDefStoreV1.create({}, {})", classificationDefs, ret);
+            LOG.debug("<== AtlasClassificationDefStoreV1.create({}, {}): {}", classificationDef, preCreateResult, ret);
         }
+
         return ret;
     }
 
@@ -155,18 +168,42 @@ public class AtlasClassificationDefStoreV1 extends AtlasAbstractDefStoreV1 imple
     }
 
     @Override
-    public AtlasClassificationDef updateByName(String name, AtlasClassificationDef classificationDef) throws AtlasBaseException {
+    public AtlasClassificationDef update(AtlasClassificationDef classifiDef) throws AtlasBaseException {
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("==> AtlasClassificationDefStoreV1.update({})", classifiDef);
+        }
+
+        AtlasClassificationDef ret = StringUtils.isNotBlank(classifiDef.getName())
+                  ? updateByName(classifiDef.getName(), classifiDef) : updateByGuid(classifiDef.getGuid(), classifiDef);
+
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("<== AtlasClassificationDefStoreV1.update({}): {}", classifiDef, ret);
+        }
+
+        return ret;
+    }
+
+    @Override
+    public AtlasClassificationDef updateByName(String name, AtlasClassificationDef classificationDef)
+        throws AtlasBaseException {
         if (LOG.isDebugEnabled()) {
             LOG.debug("==> AtlasClassificationDefStoreV1.updateByName({}, {})", name, classificationDef);
         }
 
+        AtlasType type = typeRegistry.getType(classificationDef.getName());
+
+        if (type.getTypeCategory() != AtlasType.TypeCategory.CLASSIFICATION) {
+            throw new AtlasBaseException(classificationDef.getName() + ": not a struct type");
+        }
+
         AtlasVertex vertex = typeDefStore.findTypeVertexByNameAndCategory(name, TypeCategory.TRAIT);
 
         if (vertex == null) {
             throw new AtlasBaseException("no classificationDef exists with name " + name);
         }
 
-        toVertex(classificationDef, vertex);
+        updateVertexPreUpdate(classificationDef, (AtlasClassificationType)type, vertex);
+        updateVertexAddReferences(classificationDef, vertex);
 
         AtlasClassificationDef ret = toClassificationDef(vertex);
 
@@ -183,13 +220,20 @@ public class AtlasClassificationDefStoreV1 extends AtlasAbstractDefStoreV1 imple
             LOG.debug("==> AtlasClassificationDefStoreV1.updateByGuid({})", guid);
         }
 
+        AtlasType type = typeRegistry.getTypeByGuid(guid);
+
+        if (type.getTypeCategory() != AtlasType.TypeCategory.CLASSIFICATION) {
+            throw new AtlasBaseException(classificationDef.getName() + ": not a struct type");
+        }
+
         AtlasVertex vertex = typeDefStore.findTypeVertexByGuidAndCategory(guid, TypeCategory.TRAIT);
 
         if (vertex == null) {
             throw new AtlasBaseException("no classificationDef exists with guid " + guid);
         }
 
-        toVertex(classificationDef, vertex);
+        updateVertexPreUpdate(classificationDef, (AtlasClassificationType)type, vertex);
+        updateVertexAddReferences(classificationDef, vertex);
 
         AtlasClassificationDef ret = toClassificationDef(vertex);
 
@@ -201,34 +245,38 @@ public class AtlasClassificationDefStoreV1 extends AtlasAbstractDefStoreV1 imple
     }
 
     @Override
-    public List<AtlasClassificationDef> update(List<AtlasClassificationDef> classificationDefs) throws AtlasBaseException {
+    public AtlasVertex preDeleteByName(String name) throws AtlasBaseException {
         if (LOG.isDebugEnabled()) {
-            LOG.debug("==> AtlasClassificationDefStoreV1.update({})", classificationDefs);
+            LOG.debug("==> AtlasClassificationDefStoreV1.preDeleteByName({})", name);
         }
 
-        List<AtlasClassificationDef> ret = new ArrayList<>();
+        AtlasVertex ret = typeDefStore.findTypeVertexByNameAndCategory(name, TypeCategory.TRAIT);
 
-        for (AtlasClassificationDef classificationDef : classificationDefs) {
-            ret.add(updateByName(classificationDef.getName(), classificationDef));
+        if (ret == null) {
+            throw new AtlasBaseException("no classificationDef exists with name " + name);
         }
 
+        typeDefStore.deleteTypeVertexOutEdges(ret);
+
         if (LOG.isDebugEnabled()) {
-            LOG.debug("<== AtlasClassificationDefStoreV1.update({}): {}", classificationDefs, ret);
+            LOG.debug("<== AtlasClassificationDefStoreV1.preDeleteByName({}): ret=", name, ret);
         }
 
         return ret;
     }
 
     @Override
-    public void deleteByName(String name) throws AtlasBaseException {
+    public void deleteByName(String name, Object preDeleteResult) throws AtlasBaseException {
         if (LOG.isDebugEnabled()) {
             LOG.debug("==> AtlasClassificationDefStoreV1.deleteByName({})", name);
         }
 
-        AtlasVertex vertex = typeDefStore.findTypeVertexByNameAndCategory(name, TypeCategory.TRAIT);
+        AtlasVertex vertex;
 
-        if (vertex == null) {
-            throw new AtlasBaseException("no classificationDef exists with name " + name);
+        if (preDeleteResult == null || !(preDeleteResult instanceof AtlasVertex)) {
+            vertex = preDeleteByName(name);
+        } else {
+            vertex = (AtlasVertex)preDeleteResult;
         }
 
         typeDefStore.deleteTypeVertex(vertex);
@@ -239,30 +287,38 @@ public class AtlasClassificationDefStoreV1 extends AtlasAbstractDefStoreV1 imple
     }
 
     @Override
-    public void deleteByNames(List<String> names) throws AtlasBaseException {
+    public AtlasVertex preDeleteByGuid(String guid) throws AtlasBaseException {
         if (LOG.isDebugEnabled()) {
-            LOG.debug("==> AtlasClassificationDefStoreV1.deleteByNames({})", names);
+            LOG.debug("==> AtlasClassificationDefStoreV1.preDeleteByGuid({})", guid);
         }
 
-        for (String name : names) {
-            deleteByName(name);
+        AtlasVertex ret = typeDefStore.findTypeVertexByGuidAndCategory(guid, TypeCategory.TRAIT);
+
+        if (ret == null) {
+            throw new AtlasBaseException("no classificationDef exists with guid " + guid);
         }
 
+        typeDefStore.deleteTypeVertexOutEdges(ret);
+
         if (LOG.isDebugEnabled()) {
-            LOG.debug("<== AtlasClassificationDefStoreV1.deleteByNames({})", names);
+            LOG.debug("<== AtlasClassificationDefStoreV1.preDeleteByGuid({}): ret=", guid, ret);
         }
+
+        return ret;
     }
 
     @Override
-    public void deleteByGuid(String guid) throws AtlasBaseException {
+    public void deleteByGuid(String guid, Object preDeleteResult) throws AtlasBaseException {
         if (LOG.isDebugEnabled()) {
             LOG.debug("==> AtlasClassificationDefStoreV1.deleteByGuid({})", guid);
         }
 
-        AtlasVertex vertex = typeDefStore.findTypeVertexByGuidAndCategory(guid, TypeCategory.TRAIT);
+        AtlasVertex vertex;
 
-        if (vertex == null) {
-            throw new AtlasBaseException("no classificationDef exists with guid " + guid);
+        if (preDeleteResult == null || !(preDeleteResult instanceof AtlasVertex)) {
+            vertex = preDeleteByGuid(guid);
+        } else {
+            vertex = (AtlasVertex)preDeleteResult;
         }
 
         typeDefStore.deleteTypeVertex(vertex);
@@ -273,28 +329,12 @@ public class AtlasClassificationDefStoreV1 extends AtlasAbstractDefStoreV1 imple
     }
 
     @Override
-    public void deleteByGuids(List<String> guids) throws AtlasBaseException {
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("==> AtlasClassificationDefStoreV1.deleteByGuids({})", guids);
-        }
-
-        for (String guid : guids) {
-            deleteByGuid(guid);
-        }
-
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("<== AtlasClassificationDefStoreV1.deleteByGuids({})", guids);
-        }
-
-    }
-
-    @Override
     public AtlasClassificationDefs search(SearchFilter filter) throws AtlasBaseException {
         if (LOG.isDebugEnabled()) {
             LOG.debug("==> AtlasClassificationDefStoreV1.search({})", filter);
         }
 
-        List<AtlasClassificationDef> classificationDefs = new ArrayList<AtlasClassificationDef>();
+        List<AtlasClassificationDef> classificationDefs = new ArrayList<>();
         Iterator<AtlasVertex>        vertices           = typeDefStore.findTypeVerticesByCategory(TypeCategory.TRAIT);
 
         while(vertices.hasNext()) {
@@ -317,17 +357,22 @@ public class AtlasClassificationDefStoreV1 extends AtlasAbstractDefStoreV1 imple
         return ret;
     }
 
-    private void toVertex(AtlasClassificationDef classificationDef, AtlasVertex vertex) throws AtlasBaseException {
-        AtlasType type = typeRegistry.getType(classificationDef.getName());
+    private void updateVertexPreCreate(AtlasClassificationDef  classificationDef,
+                                       AtlasClassificationType classificationType,
+                                       AtlasVertex             vertex) {
+        AtlasStructDefStoreV1.updateVertexPreCreate(classificationDef, classificationType, vertex);
+    }
 
-        if (type.getTypeCategory() != AtlasType.TypeCategory.CLASSIFICATION) {
-            throw new AtlasBaseException(classificationDef.getName() + ": not a classification type");
-        }
+    private void updateVertexPreUpdate(AtlasClassificationDef  classificationDef,
+                                       AtlasClassificationType classificationType,
+                                       AtlasVertex             vertex) {
+        AtlasStructDefStoreV1.updateVertexPreUpdate(classificationDef, classificationType, vertex);
+    }
 
-        AtlasStructDefStoreV1.toVertex(classificationDef, (AtlasClassificationType)type,
-                                       vertex, typeDefStore, typeRegistry);
+    private void updateVertexAddReferences(AtlasClassificationDef classificationDef, AtlasVertex vertex) throws AtlasBaseException {
+        AtlasStructDefStoreV1.updateVertexAddReferences(classificationDef, vertex, typeDefStore);
 
-        typeDefStore.createSuperTypeEdges(vertex, classificationDef.getSuperTypes());
+        typeDefStore.createSuperTypeEdges(vertex, classificationDef.getSuperTypes(), TypeCategory.TRAIT);
     }
 
     private AtlasClassificationDef toClassificationDef(AtlasVertex vertex) throws AtlasBaseException {

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/08f56903/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityDefStoreV1.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityDefStoreV1.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityDefStoreV1.java
index 308a529..fd16cbd 100644
--- a/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityDefStoreV1.java
+++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityDefStoreV1.java
@@ -30,6 +30,7 @@ import org.apache.atlas.type.AtlasType;
 import org.apache.atlas.type.AtlasTypeRegistry;
 import org.apache.atlas.typesystem.types.DataTypes.TypeCategory;
 import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -48,43 +49,56 @@ public class AtlasEntityDefStoreV1 extends AtlasAbstractDefStoreV1 implements At
     }
 
     @Override
-    public AtlasEntityDef create(AtlasEntityDef entityDef) throws AtlasBaseException {
+    public AtlasVertex preCreate(AtlasEntityDef entityDef) throws AtlasBaseException {
         if (LOG.isDebugEnabled()) {
-            LOG.debug("==> AtlasEntityDefStoreV1.create({})", entityDef);
+            LOG.debug("==> AtlasEntityDefStoreV1.preCreate({})", entityDef);
         }
 
-        AtlasVertex vertex = typeDefStore.findTypeVertexByName(entityDef.getName());
+        AtlasType type = typeRegistry.getType(entityDef.getName());
 
-        if (vertex != null) {
-            throw new AtlasBaseException(entityDef.getName() + ": type already exists");
+        if (type.getTypeCategory() != AtlasType.TypeCategory.ENTITY) {
+            throw new AtlasBaseException(entityDef.getName() + ": not an entity type");
         }
 
-        vertex = typeDefStore.createTypeVertex(entityDef);
+        AtlasVertex ret = typeDefStore.findTypeVertexByName(entityDef.getName());
+
+        if (ret != null) {
+            throw new AtlasBaseException(entityDef.getName() + ": type already exists");
+        }
 
-        toVertex(entityDef, vertex);
+        ret = typeDefStore.createTypeVertex(entityDef);
 
-        AtlasEntityDef ret = toEntityDef(vertex);
+        updateVertexPreCreate(entityDef, (AtlasEntityType)type, ret);
 
         if (LOG.isDebugEnabled()) {
-            LOG.debug("<== AtlasEntityDefStoreV1.create({}): {}", entityDef, ret);
+            LOG.debug("<== AtlasEntityDefStoreV1.preCreate({}): {}", entityDef, ret);
         }
 
         return ret;
     }
 
     @Override
-    public List<AtlasEntityDef> create(List<AtlasEntityDef> entityDefs) throws AtlasBaseException {
+    public AtlasEntityDef create(AtlasEntityDef entityDef, Object preCreateResult) throws AtlasBaseException {
         if (LOG.isDebugEnabled()) {
-            LOG.debug("==> AtlasEntityDefStoreV1.create({})", entityDefs);
+            LOG.debug("==> AtlasEntityDefStoreV1.create({}, {})", entityDef, preCreateResult);
         }
-        List<AtlasEntityDef> ret = new ArrayList<>();
 
-        for (AtlasEntityDef entityDef : entityDefs) {
-            ret.add(create(entityDef));
+        AtlasVertex vertex;
+
+        if (preCreateResult == null || !(preCreateResult instanceof AtlasVertex)) {
+            vertex = preCreate(entityDef);
+        } else {
+            vertex = (AtlasVertex)preCreateResult;
         }
+
+        updateVertexAddReferences(entityDef, vertex);
+
+        AtlasEntityDef ret = toEntityDef(vertex);
+
         if (LOG.isDebugEnabled()) {
-            LOG.debug("<== AtlasEntityDefStoreV1.create({}, {})", entityDefs, ret);
+            LOG.debug("<== AtlasEntityDefStoreV1.create({}, {}): {}", entityDef, preCreateResult, ret);
         }
+
         return ret;
     }
 
@@ -153,18 +167,41 @@ public class AtlasEntityDefStoreV1 extends AtlasAbstractDefStoreV1 implements At
     }
 
     @Override
+    public AtlasEntityDef update(AtlasEntityDef entityDef) throws AtlasBaseException {
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("==> AtlasEntityDefStoreV1.update({})", entityDef);
+        }
+
+        AtlasEntityDef ret = StringUtils.isNotBlank(entityDef.getName()) ? updateByName(entityDef.getName(), entityDef)
+                                                                         : updateByGuid(entityDef.getGuid(), entityDef);
+
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("<== AtlasEntityDefStoreV1.update({}): {}", entityDef, ret);
+        }
+
+        return ret;
+    }
+
+    @Override
     public AtlasEntityDef updateByName(String name, AtlasEntityDef entityDef) throws AtlasBaseException {
         if (LOG.isDebugEnabled()) {
             LOG.debug("==> AtlasEntityDefStoreV1.updateByName({}, {})", name, entityDef);
         }
 
+        AtlasType type = typeRegistry.getType(entityDef.getName());
+
+        if (type.getTypeCategory() != AtlasType.TypeCategory.ENTITY) {
+            throw new AtlasBaseException(entityDef.getName() + ": not an entity type");
+        }
+
         AtlasVertex vertex = typeDefStore.findTypeVertexByNameAndCategory(name, TypeCategory.CLASS);
 
         if (vertex == null) {
             throw new AtlasBaseException("no entityDef exists with name " + name);
         }
 
-        toVertex(entityDef, vertex);
+        updateVertexPreUpdate(entityDef, (AtlasEntityType)type, vertex);
+        updateVertexAddReferences(entityDef, vertex);
 
         AtlasEntityDef ret = toEntityDef(vertex);
 
@@ -181,13 +218,20 @@ public class AtlasEntityDefStoreV1 extends AtlasAbstractDefStoreV1 implements At
             LOG.debug("==> AtlasEntityDefStoreV1.updateByGuid({})", guid);
         }
 
+        AtlasType type = typeRegistry.getTypeByGuid(guid);
+
+        if (type.getTypeCategory() != AtlasType.TypeCategory.ENTITY) {
+            throw new AtlasBaseException(entityDef.getName() + ": not an entity type");
+        }
+
         AtlasVertex vertex = typeDefStore.findTypeVertexByGuidAndCategory(guid, TypeCategory.CLASS);
 
         if (vertex == null) {
             throw new AtlasBaseException("no entityDef exists with guid " + guid);
         }
 
-        toVertex(entityDef, vertex);
+        updateVertexPreUpdate(entityDef, (AtlasEntityType)type, vertex);
+        updateVertexAddReferences(entityDef, vertex);
 
         AtlasEntityDef ret = toEntityDef(vertex);
 
@@ -199,89 +243,86 @@ public class AtlasEntityDefStoreV1 extends AtlasAbstractDefStoreV1 implements At
     }
 
     @Override
-    public List<AtlasEntityDef> update(List<AtlasEntityDef> entityDefs) throws AtlasBaseException {
+    public AtlasVertex preDeleteByName(String name) throws AtlasBaseException {
         if (LOG.isDebugEnabled()) {
-            LOG.debug("==> AtlasEntityDefStoreV1.update({})", entityDefs);
+            LOG.debug("==> AtlasEntityDefStoreV1.preDeleteByName({})", name);
         }
 
-        List<AtlasEntityDef> ret = new ArrayList<>();
+        AtlasVertex ret = typeDefStore.findTypeVertexByNameAndCategory(name, TypeCategory.CLASS);
 
-        for (AtlasEntityDef entityDef : entityDefs) {
-            ret.add(updateByName(entityDef.getName(), entityDef));
+        if (ret == null) {
+            throw new AtlasBaseException("no entityDef exists with name " + name);
         }
 
+        typeDefStore.deleteTypeVertexOutEdges(ret);
+
         if (LOG.isDebugEnabled()) {
-            LOG.debug("<== AtlasEntityDefStoreV1.update({}): {}", entityDefs, ret);
+            LOG.debug("<== AtlasEntityDefStoreV1.preDeleteByName({}): {}", name, ret);
         }
 
         return ret;
     }
 
     @Override
-    public void deleteByName(String name) throws AtlasBaseException {
+    public void deleteByName(String name, Object preDeleteResult) throws AtlasBaseException {
         if (LOG.isDebugEnabled()) {
-            LOG.debug("==> AtlasEntityDefStoreV1.deleteByName({})", name);
+            LOG.debug("==> AtlasEntityDefStoreV1.deleteByName({}, {})", name, preDeleteResult);
         }
 
-        AtlasVertex vertex = typeDefStore.findTypeVertexByNameAndCategory(name, TypeCategory.CLASS);
+        AtlasVertex vertex;
 
-        if (vertex == null) {
-            throw new AtlasBaseException("no entityDef exists with name " + name);
+        if (preDeleteResult == null || !(preDeleteResult instanceof AtlasVertex)) {
+            vertex = preDeleteByName(name);
+        } else {
+            vertex = (AtlasVertex)preDeleteResult;
         }
 
         typeDefStore.deleteTypeVertex(vertex);
 
         if (LOG.isDebugEnabled()) {
-            LOG.debug("<== AtlasEntityDefStoreV1.deleteByName({})", name);
-        }
-    }
-
-    @Override
-    public void deleteByNames(List<String> names) throws AtlasBaseException {
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("==> AtlasEntityDefStoreV1.deleteByNames({})", names);
-        }
-
-        for (String name : names) {
-            deleteByName(name);
-        }
-
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("<== AtlasEntityDefStoreV1.deleteByNames({})", names);
+            LOG.debug("<== AtlasEntityDefStoreV1.deleteByName({}, {})", name, preDeleteResult);
         }
     }
 
     @Override
-    public void deleteByGuid(String guid) throws AtlasBaseException {
+    public AtlasVertex preDeleteByGuid(String guid) throws AtlasBaseException {
         if (LOG.isDebugEnabled()) {
-            LOG.debug("==> AtlasEntityDefStoreV1.deleteByGuid({})", guid);
+            LOG.debug("==> AtlasEntityDefStoreV1.preDeleteByGuid({})", guid);
         }
 
-        AtlasVertex vertex = typeDefStore.findTypeVertexByGuidAndCategory(guid, TypeCategory.CLASS);
+        AtlasVertex ret = typeDefStore.findTypeVertexByGuidAndCategory(guid, TypeCategory.CLASS);
 
-        if (vertex == null) {
+        if (ret == null) {
             throw new AtlasBaseException("no entityDef exists with guid " + guid);
         }
 
-        typeDefStore.deleteTypeVertex(vertex);
+        typeDefStore.deleteTypeVertexOutEdges(ret);
 
         if (LOG.isDebugEnabled()) {
-            LOG.debug("<== AtlasEntityDefStoreV1.deleteByGuid({})", guid);
+            LOG.debug("<== AtlasEntityDefStoreV1.preDeleteByGuid({}): {}", guid, ret);
         }
+
+        return ret;
     }
 
     @Override
-    public void deleteByGuids(List<String> guids) throws AtlasBaseException {
+    public void deleteByGuid(String guid, Object preDeleteResult) throws AtlasBaseException {
         if (LOG.isDebugEnabled()) {
-            LOG.debug("==> AtlasEntityDefStoreV1.deleteByGuids({})", guids);
+            LOG.debug("==> AtlasEntityDefStoreV1.deleteByGuid({}, {})", guid, preDeleteResult);
         }
 
-        for (String guid : guids) {
-            deleteByGuid(guid);
+        AtlasVertex vertex;
+
+        if (preDeleteResult == null || !(preDeleteResult instanceof AtlasVertex)) {
+            vertex = preDeleteByGuid(guid);
+        } else {
+            vertex = (AtlasVertex)preDeleteResult;
         }
 
+        typeDefStore.deleteTypeVertex(vertex);
+
         if (LOG.isDebugEnabled()) {
-            LOG.debug("<== AtlasEntityDefStoreV1.deleteByGuids({})", guids);
+            LOG.debug("<== AtlasEntityDefStoreV1.deleteByGuid({}, {})", guid, preDeleteResult);
         }
     }
 
@@ -291,7 +332,7 @@ public class AtlasEntityDefStoreV1 extends AtlasAbstractDefStoreV1 implements At
             LOG.debug("==> AtlasEntityDefStoreV1.search({})", filter);
         }
 
-        List<AtlasEntityDef>  entityDefs = new ArrayList<AtlasEntityDef>();
+        List<AtlasEntityDef>  entityDefs = new ArrayList<>();
         Iterator<AtlasVertex> vertices   = typeDefStore.findTypeVerticesByCategory(TypeCategory.CLASS);
 
         while(vertices.hasNext()) {
@@ -314,16 +355,18 @@ public class AtlasEntityDefStoreV1 extends AtlasAbstractDefStoreV1 implements At
         return ret;
     }
 
-    private void toVertex(AtlasEntityDef entityDef, AtlasVertex vertex) throws AtlasBaseException {
-        AtlasType type = typeRegistry.getType(entityDef.getName());
+    private void updateVertexPreCreate(AtlasEntityDef entityDef, AtlasEntityType entityType, AtlasVertex vertex) {
+        AtlasStructDefStoreV1.updateVertexPreCreate(entityDef, entityType, vertex);
+    }
 
-        if (type.getTypeCategory() != AtlasType.TypeCategory.ENTITY) {
-            throw new AtlasBaseException(entityDef.getName() + ": not a entity type");
-        }
+    private void updateVertexPreUpdate(AtlasEntityDef entityDef, AtlasEntityType entityType, AtlasVertex vertex) {
+        AtlasStructDefStoreV1.updateVertexPreUpdate(entityDef, entityType, vertex);
+    }
 
-        AtlasStructDefStoreV1.toVertex(entityDef, (AtlasEntityType)type, vertex, typeDefStore, typeRegistry);
+    private void updateVertexAddReferences(AtlasEntityDef  entityDef, AtlasVertex vertex) throws AtlasBaseException {
+        AtlasStructDefStoreV1.updateVertexAddReferences(entityDef, vertex, typeDefStore);
 
-        typeDefStore.createSuperTypeEdges(vertex, entityDef.getSuperTypes());
+        typeDefStore.createSuperTypeEdges(vertex, entityDef.getSuperTypes(), TypeCategory.CLASS);
     }
 
     private AtlasEntityDef toEntityDef(AtlasVertex vertex) throws AtlasBaseException {

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/08f56903/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEnumDefStoreV1.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEnumDefStoreV1.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEnumDefStoreV1.java
index 5c55d42..32ef939 100644
--- a/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEnumDefStoreV1.java
+++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEnumDefStoreV1.java
@@ -26,6 +26,7 @@ import org.apache.atlas.repository.Constants;
 import org.apache.atlas.repository.graphdb.AtlasVertex;
 import org.apache.atlas.repository.store.graph.AtlasEnumDefStore;
 import org.apache.atlas.repository.util.FilterUtil;
+import org.apache.atlas.type.AtlasType;
 import org.apache.atlas.type.AtlasTypeRegistry;
 import org.apache.atlas.typesystem.types.DataTypes.TypeCategory;
 import org.apache.commons.collections.CollectionUtils;
@@ -73,25 +74,6 @@ public class AtlasEnumDefStoreV1 extends AtlasAbstractDefStoreV1 implements Atla
     }
 
     @Override
-    public List<AtlasEnumDef> create(List<AtlasEnumDef> enumDefs) throws AtlasBaseException {
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("==> AtlasEnumDefStoreV1.create({})", enumDefs);
-        }
-
-        List<AtlasEnumDef> ret = new ArrayList<>();
-
-        for (AtlasEnumDef enumDef : enumDefs) {
-            ret.add(create(enumDef));
-        }
-
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("<== AtlasEnumDefStoreV1.create({}): {}", enumDefs, ret);
-        }
-
-        return ret;
-    }
-
-    @Override
     public List<AtlasEnumDef> getAll() throws AtlasBaseException {
         if (LOG.isDebugEnabled()) {
             LOG.debug("==> AtlasEnumDefStoreV1.getAll()");
@@ -156,6 +138,22 @@ public class AtlasEnumDefStoreV1 extends AtlasAbstractDefStoreV1 implements Atla
     }
 
     @Override
+    public AtlasEnumDef update(AtlasEnumDef enumDef) throws AtlasBaseException {
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("==> AtlasEnumDefStoreV1.update({})", enumDef);
+        }
+
+        AtlasEnumDef ret = StringUtils.isNotBlank(enumDef.getGuid()) ? updateByGuid(enumDef.getGuid(), enumDef)
+                                                                     : updateByName(enumDef.getName(), enumDef);
+
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("<== AtlasEnumDefStoreV1.update({}): {}", enumDef, ret);
+        }
+
+        return ret;
+    }
+
+    @Override
     public AtlasEnumDef updateByName(String name, AtlasEnumDef enumDef) throws AtlasBaseException {
         if (LOG.isDebugEnabled()) {
             LOG.debug("==> AtlasEnumDefStoreV1.updateByName({}, {})", name, enumDef);
@@ -202,25 +200,6 @@ public class AtlasEnumDefStoreV1 extends AtlasAbstractDefStoreV1 implements Atla
     }
 
     @Override
-    public List<AtlasEnumDef> update(List<AtlasEnumDef> enumDefs) throws AtlasBaseException {
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("==> AtlasEnumDefStoreV1.update({})", enumDefs);
-        }
-
-        List<AtlasEnumDef> ret = new ArrayList<>();
-
-        for (AtlasEnumDef enumDef : enumDefs) {
-            ret.add(updateByName(enumDef.getName(), enumDef));
-        }
-
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("<== AtlasEnumDefStoreV1.update({}): {}", enumDefs, ret);
-        }
-
-        return ret;
-    }
-
-    @Override
     public void deleteByName(String name) throws AtlasBaseException {
         if (LOG.isDebugEnabled()) {
             LOG.debug("==> AtlasEnumDefStoreV1.deleteByName({})", name);
@@ -240,21 +219,6 @@ public class AtlasEnumDefStoreV1 extends AtlasAbstractDefStoreV1 implements Atla
     }
 
     @Override
-    public void deleteByNames(List<String> names) throws AtlasBaseException {
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("==> AtlasEnumDefStoreV1.deleteByNames({})", names);
-        }
-
-        for (String name : names) {
-            deleteByName(name);
-        }
-
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("<== AtlasEnumDefStoreV1.deleteByName({})", names);
-        }
-    }
-
-    @Override
     public void deleteByGuid(String guid) throws AtlasBaseException {
         if (LOG.isDebugEnabled()) {
             LOG.debug("==> AtlasEnumDefStoreV1.deleteByGuid({})", guid);
@@ -274,27 +238,12 @@ public class AtlasEnumDefStoreV1 extends AtlasAbstractDefStoreV1 implements Atla
     }
 
     @Override
-    public void deleteByGuids(List<String> guids) throws AtlasBaseException {
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("==> AtlasEnumDefStoreV1.deleteByGuids({})", guids);
-        }
-
-        for (String guid : guids) {
-            deleteByGuid(guid);
-        }
-
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("<== AtlasEnumDefStoreV1.deleteByGuids({})", guids);
-        }
-    }
-
-    @Override
     public AtlasEnumDefs search(SearchFilter filter) throws AtlasBaseException {
         if (LOG.isDebugEnabled()) {
             LOG.debug("==> AtlasEnumDefStoreV1.search({})", filter);
         }
 
-        List<AtlasEnumDef>    enumDefs = new ArrayList<AtlasEnumDef>();
+        List<AtlasEnumDef>    enumDefs = new ArrayList<>();
         Iterator<AtlasVertex> vertices = typeDefStore.findTypeVerticesByCategory(TypeCategory.ENUM);
 
         while(vertices.hasNext()) {


Mime
View raw message