http://git-wip-us.apache.org/repos/asf/atlas/blob/435fe3fb/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..a529dc1 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.v1.model.instance.AtlasSystemAttributes;
+import org.apache.atlas.v1.model.instance.Id;
+import org.apache.atlas.v1.model.instance.Referenceable;
+import org.apache.atlas.v1.model.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;
@@ -57,37 +56,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 +86,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 +122,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 +155,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/435fe3fb/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..da76c5a 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.v1.model.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/435fe3fb/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..2884f8f 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
@@ -20,6 +20,7 @@ package org.apache.atlas.repository.converters;
 import org.apache.atlas.AtlasErrorCode;
 import org.apache.atlas.AtlasException;
 import org.apache.atlas.CreateUpdateEntitiesResult;
+import org.apache.atlas.RequestContextV1;
 import org.apache.atlas.exception.AtlasBaseException;
 import org.apache.atlas.model.TypeCategory;
 import org.apache.atlas.model.instance.AtlasClassification;
@@ -27,27 +28,17 @@ 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.repository.store.graph.v1.EntityGraphRetriever;
+import org.apache.atlas.v1.model.instance.Referenceable;
+import org.apache.atlas.v1.model.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 +57,55 @@ 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;
+    private final EntityGraphRetriever  entityGraphRetriever;
 
     @Inject
-    public AtlasInstanceConverter(AtlasTypeRegistry typeRegistry, 
AtlasFormatConverters instanceFormatters, MetadataService metadataService) {
-        this.typeRegistry = typeRegistry;
-        this.instanceFormatters = instanceFormatters;
-        this.metadataService = metadataService;
+    public AtlasInstanceConverter(AtlasTypeRegistry typeRegistry, 
AtlasFormatConverters instanceFormatters) {
+        this.typeRegistry         = typeRegistry;
+        this.instanceFormatters   = instanceFormatters;
+        this.entityGraphRetriever = new EntityGraphRetriever(typeRegistry);
     }
 
-    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 Referenceable getReferenceable(String guid) throws 
AtlasBaseException {
+        AtlasEntity.AtlasEntityWithExtInfo entity = getAndCacheEntity(guid);
+
+        return getReferenceable(entity);
     }
 
-    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 +116,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 +145,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 +153,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 +213,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;
     }
 
@@ -352,4 +288,24 @@ public class AtlasInstanceConverter {
 
         return ret;
     }
+
+
+    private AtlasEntity.AtlasEntityWithExtInfo getAndCacheEntity(String guid) 
throws AtlasBaseException {
+        RequestContextV1                   context           = 
RequestContextV1.get();
+        AtlasEntity.AtlasEntityWithExtInfo entityWithExtInfo = 
context.getInstanceV2(guid);
+
+        if (entityWithExtInfo == null) {
+            entityWithExtInfo = 
entityGraphRetriever.toAtlasEntityWithExtInfo(guid);
+
+            if (entityWithExtInfo != null) {
+                context.cache(entityWithExtInfo);
+
+                if (LOG.isDebugEnabled()) {
+                    LOG.debug("Cache miss -> GUID = {}", guid);
+                }
+            }
+        }
+
+        return entityWithExtInfo;
+    }
 }

http://git-wip-us.apache.org/repos/asf/atlas/blob/435fe3fb/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..a5b6d84 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.v1.model.instance.Id;
+import org.apache.atlas.v1.model.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.v1.model.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;

http://git-wip-us.apache.org/repos/asf/atlas/blob/435fe3fb/repository/src/main/java/org/apache/atlas/repository/converters/AtlasStructFormatConverter.java
----------------------------------------------------------------------
diff --git 
a/repository/src/main/java/org/apache/atlas/repository/converters/AtlasStructFormatConverter.java
 
b/repository/src/main/java/org/apache/atlas/repository/converters/AtlasStructFormatConverter.java
index 6b6ee01..70b23c5 100644
--- 
a/repository/src/main/java/org/apache/atlas/repository/converters/AtlasStructFormatConverter.java
+++ 
b/repository/src/main/java/org/apache/atlas/repository/converters/AtlasStructFormatConverter.java
@@ -18,21 +18,24 @@
 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.instance.AtlasStruct;
-import org.apache.atlas.type.AtlasStructType;
+import org.apache.atlas.v1.model.instance.Struct;
+import org.apache.atlas.type.*;
+import org.apache.atlas.type.AtlasBuiltInTypes.AtlasObjectIdType;
 import org.apache.atlas.type.AtlasStructType.AtlasAttribute;
-import org.apache.atlas.type.AtlasType;
-import org.apache.atlas.type.AtlasTypeRegistry;
-import org.apache.atlas.typesystem.IStruct;
-import org.apache.atlas.typesystem.Struct;
 import org.apache.commons.collections.MapUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.util.ArrayList;
+import java.util.Collection;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 public class AtlasStructFormatConverter extends AtlasAbstractFormatConverter {
@@ -64,19 +67,12 @@ public class AtlasStructFormatConverter extends 
AtlasAbstractFormatConverter {
                 } else {
                     ret = new AtlasStruct(type.getTypeName());
                 }
-            } else if (v1Obj instanceof IStruct) {
-                IStruct             struct    = (IStruct) v1Obj;
-                Map<String, Object> v1Attribs = null;
-
-                try {
-                    v1Attribs = struct.getValuesMap();
-                } catch (AtlasException excp) {
-                    LOG.error("IStruct.getValuesMap() failed", excp);
-                }
+            } else if (v1Obj instanceof Struct) {
+                Struct struct = (Struct) v1Obj;
 
-                ret = new AtlasStruct(type.getTypeName(), 
fromV1ToV2(structType, v1Attribs, converterContext));
+                ret = new AtlasStruct(type.getTypeName(), 
fromV1ToV2(structType, struct.getValues(), converterContext));
             } else {
-                throw new AtlasBaseException(AtlasErrorCode.UNEXPECTED_TYPE, 
"Map or IStruct", v1Obj.getClass().getCanonicalName());
+                throw new AtlasBaseException(AtlasErrorCode.UNEXPECTED_TYPE, 
"Map or Struct", v1Obj.getClass().getCanonicalName());
             }
         }
 
@@ -118,7 +114,8 @@ public class AtlasStructFormatConverter extends 
AtlasAbstractFormatConverter {
     }
 
     protected Map<String, Object> fromV2ToV1(AtlasStructType structType, 
Map<String, Object> attributes, ConverterContext context) throws 
AtlasBaseException {
-        Map<String, Object> ret = null;
+        Map<String, Object> ret          = null;
+        boolean             isEntityType = structType instanceof 
AtlasEntityType;
 
         if (MapUtils.isNotEmpty(attributes)) {
             ret = new HashMap<>();
@@ -132,13 +129,80 @@ public class AtlasStructFormatConverter extends 
AtlasAbstractFormatConverter {
                     continue;
                 }
 
-                AtlasType attrType = attr.getAttributeType();
+                AtlasType            attrType      = attr.getAttributeType();
+                AtlasFormatConverter attrConverter = 
converterRegistry.getConverter(attrType.getTypeCategory());
+                Object               v2Value       = 
attributes.get(attr.getName());
+
+                if (v2Value != null && isEntityType && attr.isOwnedRef()) {
+                    if (LOG.isDebugEnabled()) {
+                        LOG.debug("{}: is ownedRef, attrType={}", 
attr.getQualifiedName(), attrType.getTypeName());
+                    }
+
+                    if (attrType instanceof AtlasArrayType) {
+                        AtlasArrayType  arrayType  = (AtlasArrayType) attrType;
+                        AtlasType       elemType   = 
arrayType.getElementType();
+                        String          elemTypeName;
+
+                        if (elemType instanceof AtlasObjectIdType) {
+                            elemTypeName = ((AtlasObjectIdType) 
elemType).getObjectType();
+                        } else {
+                            elemTypeName = elemType.getTypeName();
+                        }
+
+                        AtlasEntityType entityType = 
typeRegistry.getEntityTypeByName(elemTypeName);;
+
+                        if (entityType != null) {
+                            Collection<?>     arrayValue = (Collection<?>) 
v2Value;
+                            List<AtlasEntity> entities   = new 
ArrayList<>(arrayValue.size());
+
+                            for (Object arrayElem : arrayValue) {
+                                String      entityGuid = getGuid(arrayElem);
+                                AtlasEntity entity = 
StringUtils.isNotEmpty(entityGuid) ? context.getById(entityGuid) : null;
+
+                                if (entity != null) {
+                                    entities.add(entity);
+                                } else {
+                                    LOG.warn("{}: not replacing objIdList with 
entityList - entity not found guid={}", attr.getQualifiedName(), entityGuid);
+
+                                    entities = null;
+                                    break;
+                                }
+                            }
+
+                            if (entities != null) {
+                                v2Value  = entities;
+                                attrType = new AtlasArrayType(entityType);
+
+                                if (LOG.isDebugEnabled()) {
+                                    LOG.debug("{}: replaced objIdList with 
entityList", attr.getQualifiedName());
+                                }
+                            }
+                        } else {
+                            LOG.warn("{}: not replacing objIdList with 
entityList - elementType {} is not an entityType", attr.getQualifiedName(), 
elemTypeName);
+                        }
+                    } else if (attrType instanceof AtlasObjectIdType) {
+                        String          entityGuid = getGuid(v2Value);
+                        AtlasEntity     entity     = 
StringUtils.isNotEmpty(entityGuid) ? context.getById(entityGuid) : null;
+                        AtlasEntityType entityType = entity != null ? 
typeRegistry.getEntityTypeByName(entity.getTypeName()) : null;
+
+                        if (entity != null && entityType != null) {
+                            v2Value       = entity;
+                            attrType      = entityType;
+                            attrConverter = 
converterRegistry.getConverter(attrType.getTypeCategory());
+
+                            if (LOG.isDebugEnabled()) {
+                                LOG.debug("{}: replaced objId with entity 
guid={}", attr.getQualifiedName(), entityGuid);
+                            }
+                        } else {
+                            LOG.warn("{}: not replacing objId with entity - 
entity not found guid={}", attr.getQualifiedName(), entityGuid);
+                        }
+                    } else {
+                        LOG.warn("{}: not replacing objId with entity - 
unexpected attribute-type {}", attr.getQualifiedName(), attrType.getTypeName());
+                    }
+                }
 
-                Object v2Value = attributes.get(attr.getName());
-                Object v1Value;
+                Object v1Value = attrConverter.fromV2ToV1(v2Value, attrType, 
context);
 
-                AtlasFormatConverter attrConverter = 
converterRegistry.getConverter(attrType.getTypeCategory());
-                v1Value = attrConverter.fromV2ToV1(v2Value, attrType, context);
                 ret.put(attr.getName(), v1Value);
             }
         }
@@ -146,6 +210,24 @@ public class AtlasStructFormatConverter extends 
AtlasAbstractFormatConverter {
         return ret;
     }
 
+    private String getGuid(Object obj) {
+        final String ret;
+
+        if (obj instanceof AtlasObjectId) {
+            AtlasObjectId objId = (AtlasObjectId) obj;
+
+            ret = objId.getGuid();
+        } else if (obj instanceof Map) {
+            Map v2Map = (Map) obj;
+
+            ret = (String)v2Map.get(AtlasObjectId.KEY_GUID);
+        } else {
+            ret = null;
+        }
+
+        return ret;
+    }
+
     protected Map<String, Object> fromV1ToV2(AtlasStructType structType, Map 
attributes, ConverterContext context) throws AtlasBaseException {
         Map<String, Object> ret = null;
 
@@ -162,8 +244,7 @@ public class AtlasStructFormatConverter extends 
AtlasAbstractFormatConverter {
                     continue;
                 }
 
-                AtlasType attrType = attr.getAttributeType();
-
+                AtlasType            attrType      = attr.getAttributeType();
                 AtlasFormatConverter attrConverter = 
converterRegistry.getConverter(attrType.getTypeCategory());
                 Object               v1Value       = 
attributes.get(attr.getName());
                 Object               v2Value       = 
attrConverter.fromV1ToV2(v1Value, attrType, context);

http://git-wip-us.apache.org/repos/asf/atlas/blob/435fe3fb/repository/src/main/java/org/apache/atlas/repository/converters/TypeConverterUtil.java
----------------------------------------------------------------------
diff --git 
a/repository/src/main/java/org/apache/atlas/repository/converters/TypeConverterUtil.java
 
b/repository/src/main/java/org/apache/atlas/repository/converters/TypeConverterUtil.java
index 7902100..33f092e 100644
--- 
a/repository/src/main/java/org/apache/atlas/repository/converters/TypeConverterUtil.java
+++ 
b/repository/src/main/java/org/apache/atlas/repository/converters/TypeConverterUtil.java
@@ -24,10 +24,7 @@ import static 
org.apache.atlas.model.typedef.AtlasStructDef.AtlasConstraintDef.C
 import static 
org.apache.atlas.model.typedef.AtlasStructDef.AtlasConstraintDef.CONSTRAINT_PARAM_ATTRIBUTE;
 import static org.apache.atlas.type.AtlasTypeUtil.isArrayType;
 
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Set;
+import java.util.*;
 
 import org.apache.atlas.exception.AtlasBaseException;
 import org.apache.atlas.model.typedef.AtlasClassificationDef;
@@ -40,6 +37,13 @@ import 
org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef.Cardinali
 import org.apache.atlas.model.typedef.AtlasStructDef.AtlasConstraintDef;
 import org.apache.atlas.model.typedef.AtlasTypeDefHeader;
 import org.apache.atlas.model.typedef.AtlasTypesDef;
+import org.apache.atlas.v1.model.typedef.AttributeDefinition;
+import org.apache.atlas.v1.model.typedef.ClassTypeDefinition;
+import org.apache.atlas.v1.model.typedef.EnumTypeDefinition;
+import org.apache.atlas.v1.model.typedef.Multiplicity;
+import org.apache.atlas.v1.model.typedef.StructTypeDefinition;
+import org.apache.atlas.v1.model.typedef.TraitTypeDefinition;
+import org.apache.atlas.v1.model.typedef.TypesDef;
 import org.apache.atlas.repository.store.graph.v1.AtlasStructDefStoreV1;
 import org.apache.atlas.type.AtlasClassificationType;
 import org.apache.atlas.type.AtlasEntityType;
@@ -49,25 +53,12 @@ import org.apache.atlas.type.AtlasStructType.AtlasAttribute;
 import org.apache.atlas.type.AtlasType;
 import org.apache.atlas.type.AtlasTypeRegistry;
 import org.apache.atlas.type.AtlasTypeUtil;
-import org.apache.atlas.typesystem.TypesDef;
-import org.apache.atlas.typesystem.json.TypesSerialization;
-import org.apache.atlas.typesystem.types.AttributeDefinition;
-import org.apache.atlas.typesystem.types.ClassType;
-import org.apache.atlas.typesystem.types.EnumTypeDefinition;
-import org.apache.atlas.typesystem.types.EnumValue;
-import org.apache.atlas.typesystem.types.HierarchicalTypeDefinition;
-import org.apache.atlas.typesystem.types.Multiplicity;
-import org.apache.atlas.typesystem.types.StructTypeDefinition;
-import org.apache.atlas.typesystem.types.TraitType;
-import org.apache.atlas.typesystem.types.utils.TypesUtil;
+import org.apache.atlas.v1.model.typedef.EnumTypeDefinition.EnumValue;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableSet;
-
 
 public final class TypeConverterUtil {
     private TypeConverterUtil() {}
@@ -92,75 +83,58 @@ public final class TypeConverterUtil {
     }
 
     private static TypesDef enumToTypesDef(AtlasEnumType enumType) {
-        TypesDef ret = null;
-
         AtlasEnumDef enumDef = enumType.getEnumDef();
 
-        String      enumName    = enumDef.getName();
-        String      enumDesc    = enumDef.getDescription();
-        String      enumVersion = enumDef.getTypeVersion();
-        EnumValue[] enumValues  = getEnumValues(enumDef.getElementDefs());
+        String          enumName    = enumDef.getName();
+        String          enumDesc    = enumDef.getDescription();
+        String          enumVersion = enumDef.getTypeVersion();
+        List<EnumValue> enumValues  = getEnumValues(enumDef.getElementDefs());
 
-        if (enumName != null && enumValues != null && enumValues.length > 0) {
-            EnumTypeDefinition enumTypeDef = new EnumTypeDefinition(enumName, 
enumDesc, enumVersion, enumValues);
+        EnumTypeDefinition enumTypeDef = new EnumTypeDefinition(enumName, 
enumDesc, enumVersion, enumValues);
 
-            ret = TypesUtil.getTypesDef(ImmutableList.of(enumTypeDef),
-                                        
ImmutableList.<StructTypeDefinition>of(),
-                                        
ImmutableList.<HierarchicalTypeDefinition<TraitType>>of(),
-                                        
ImmutableList.<HierarchicalTypeDefinition<ClassType>>of());
-        }
+        TypesDef ret = new TypesDef(Arrays.asList(enumTypeDef), null, null, 
null);
 
         return ret;
     }
 
-    private static TypesDef structToTypesDef(AtlasStructType structType, 
AtlasTypeRegistry registry)
-                                                                               
             throws AtlasBaseException {
-        String                typeName      = 
structType.getStructDef().getName();
-        String                typeDesc      = 
structType.getStructDef().getDescription();
-        String                typeVersion   = 
structType.getStructDef().getTypeVersion();
-        AttributeDefinition[] attributes    = getAttributes(structType, 
registry);
-        StructTypeDefinition  structTypeDef = 
TypesUtil.createStructTypeDef(typeName, typeDesc, typeVersion, attributes);
+    private static TypesDef structToTypesDef(AtlasStructType structType, 
AtlasTypeRegistry registry) {
+        String                    typeName    = 
structType.getStructDef().getName();
+        String                    typeDesc    = 
structType.getStructDef().getDescription();
+        String                    typeVersion = 
structType.getStructDef().getTypeVersion();
+        List<AttributeDefinition> attributes  = getAttributes(structType, 
registry);
 
-        TypesDef ret = 
TypesUtil.getTypesDef(ImmutableList.<EnumTypeDefinition>of(),
-                                             ImmutableList.of(structTypeDef),
-                                             
ImmutableList.<HierarchicalTypeDefinition<TraitType>>of(),
-                                             
ImmutableList.<HierarchicalTypeDefinition<ClassType>>of());
+        StructTypeDefinition  structTypeDef = new 
StructTypeDefinition(typeName, typeDesc, typeVersion, attributes);
+
+        TypesDef ret = new TypesDef(null, Arrays.asList(structTypeDef), null, 
null);
 
         return ret;
     }
 
-    private static TypesDef entityToTypesDef(AtlasEntityType entityType, 
AtlasTypeRegistry registry)
-                                                                               
              throws AtlasBaseException {
-        String                typeName    = 
entityType.getEntityDef().getName();
-        String                typeDesc    = 
entityType.getEntityDef().getDescription();
-        String                typeVersion = 
entityType.getEntityDef().getTypeVersion();
-        ImmutableSet          superTypes  = 
ImmutableSet.copyOf(entityType.getEntityDef().getSuperTypes());
-        AttributeDefinition[] attributes  = getAttributes(entityType, 
registry);
-
-        HierarchicalTypeDefinition<ClassType> classType = 
TypesUtil.createClassTypeDef(typeName, typeDesc, typeVersion,
-                                                                               
        superTypes, attributes);
-        TypesDef ret = 
TypesUtil.getTypesDef(ImmutableList.<EnumTypeDefinition>of(),
-                                             
ImmutableList.<StructTypeDefinition>of(),
-                                             
ImmutableList.<HierarchicalTypeDefinition<TraitType>>of(),
-                                             ImmutableList.of(classType));
+    private static TypesDef entityToTypesDef(AtlasEntityType entityType, 
AtlasTypeRegistry registry) {
+        String                    typeName    = 
entityType.getEntityDef().getName();
+        String                    typeDesc    = 
entityType.getEntityDef().getDescription();
+        String                    typeVersion = 
entityType.getEntityDef().getTypeVersion();
+        Set<String>               superTypes  = 
entityType.getEntityDef().getSuperTypes();
+        List<AttributeDefinition> attributes  = getAttributes(entityType, 
registry);
+
+        ClassTypeDefinition classTypeDef = new ClassTypeDefinition(typeName, 
typeDesc, typeVersion, attributes, superTypes);
+
+        TypesDef ret = new TypesDef(null, null, null, 
Arrays.asList(classTypeDef));
 
         return ret;
     }
 
-    private static TypesDef classificationToTypesDef(AtlasClassificationType 
classificationType,
-                                                     AtlasTypeRegistry 
registry) throws AtlasBaseException {
-        String                typeName    = 
classificationType.getClassificationDef().getName();
-        String                typeDesc    = 
classificationType.getClassificationDef().getDescription();
-        String                typeVersion = 
classificationType.getClassificationDef().getTypeVersion();
-        ImmutableSet          superTypes  = 
ImmutableSet.copyOf(classificationType.getClassificationDef().getSuperTypes());
-        AttributeDefinition[] attributes  = getAttributes(classificationType, 
registry);
-
-        HierarchicalTypeDefinition traitType = 
TypesUtil.createTraitTypeDef(typeName, typeDesc, typeVersion, superTypes,
-                                                                             
attributes);
-        TypesDef ret = 
TypesUtil.getTypesDef(ImmutableList.<EnumTypeDefinition>of(),
-                                             
ImmutableList.<StructTypeDefinition>of(),
-                                             
ImmutableList.<HierarchicalTypeDefinition<TraitType>>of(traitType),
-                                             
ImmutableList.<HierarchicalTypeDefinition<ClassType>>of());
+    private static TypesDef classificationToTypesDef(AtlasClassificationType 
classificationType, AtlasTypeRegistry registry) {
+        String                    typeName    = 
classificationType.getClassificationDef().getName();
+        String                    typeDesc    = 
classificationType.getClassificationDef().getDescription();
+        String                    typeVersion = 
classificationType.getClassificationDef().getTypeVersion();
+        Set<String>               superTypes  = new 
HashSet<>(classificationType.getClassificationDef().getSuperTypes());
+        List<AttributeDefinition> attributes  = 
getAttributes(classificationType, registry);
+
+        TraitTypeDefinition traitTypeDef = new TraitTypeDefinition(typeName, 
typeDesc, typeVersion, attributes, superTypes);
+
+        TypesDef ret = new TypesDef(null, null, Arrays.asList(traitTypeDef), 
null);
+
         return ret;
     }
 
@@ -174,24 +148,24 @@ public final class TypeConverterUtil {
                 throw new AtlasBaseException(INVALID_TYPE_DEFINITION, 
typeDefinition);
             }
 
-            TypesDef typesDef = TypesSerialization.fromJson(typeDefinition);
-            if (CollectionUtils.isNotEmpty(typesDef.enumTypesAsJavaList())) {
-                List<AtlasEnumDef> enumDefs = 
toAtlasEnumDefs(typesDef.enumTypesAsJavaList());
+            TypesDef typesDef = AtlasType.fromV1Json(typeDefinition, 
TypesDef.class);
+            if (CollectionUtils.isNotEmpty(typesDef.getEnumTypes())) {
+                List<AtlasEnumDef> enumDefs = 
toAtlasEnumDefs(typesDef.getEnumTypes());
                 ret.setEnumDefs(enumDefs);
             }
 
-            if (CollectionUtils.isNotEmpty(typesDef.structTypesAsJavaList())) {
-                List<AtlasStructDef> structDefs = 
toAtlasStructDefs(typesDef.structTypesAsJavaList());
+            if (CollectionUtils.isNotEmpty(typesDef.getStructTypes())) {
+                List<AtlasStructDef> structDefs = 
toAtlasStructDefs(typesDef.getStructTypes());
                 ret.setStructDefs(structDefs);
             }
 
-            if (CollectionUtils.isNotEmpty(typesDef.classTypesAsJavaList())) {
-                List<AtlasEntityDef> entityDefs = 
toAtlasEntityDefs(typesDef.classTypesAsJavaList(), registry);
+            if (CollectionUtils.isNotEmpty(typesDef.getClassTypes())) {
+                List<AtlasEntityDef> entityDefs = 
toAtlasEntityDefs(typesDef.getClassTypes(), registry);
                 ret.setEntityDefs(entityDefs);
             }
 
-            if (CollectionUtils.isNotEmpty(typesDef.traitTypesAsJavaList())) {
-                List<AtlasClassificationDef> classificationDefs = 
toAtlasClassificationDefs(typesDef.traitTypesAsJavaList());
+            if (CollectionUtils.isNotEmpty(typesDef.getTraitTypes())) {
+                List<AtlasClassificationDef> classificationDefs = 
toAtlasClassificationDefs(typesDef.getTraitTypes());
                 ret.setClassificationDefs(classificationDefs);
             }
 
@@ -203,7 +177,7 @@ public final class TypeConverterUtil {
         return ret;
     }
 
-    public static ImmutableList<String> getTypeNames(List<AtlasTypeDefHeader> 
atlasTypesDefs) {
+    public static List<String> getTypeNames(List<AtlasTypeDefHeader> 
atlasTypesDefs) {
         List<String> ret = new ArrayList<String>();
         if (CollectionUtils.isNotEmpty(atlasTypesDefs)) {
             for (AtlasTypeDefHeader atlasTypesDef : atlasTypesDefs) {
@@ -211,7 +185,7 @@ public final class TypeConverterUtil {
             }
         }
 
-        return ImmutableList.copyOf(ret);
+        return ret;
     }
 
     public static List<String> getTypeNames(AtlasTypesDef typesDef) {
@@ -224,10 +198,10 @@ public final class TypeConverterUtil {
 
         for (EnumTypeDefinition enumType : enumTypeDefinitions) {
             AtlasEnumDef enumDef = new AtlasEnumDef();
-            enumDef.setName(enumType.name);
-            enumDef.setDescription(enumType.description);
-            enumDef.setTypeVersion(enumType.version);
-            
enumDef.setElementDefs(getAtlasEnumElementDefs(enumType.enumValues));
+            enumDef.setName(enumType.getName());
+            enumDef.setDescription(enumType.getDescription());
+            enumDef.setTypeVersion(enumType.getVersion());
+            
enumDef.setElementDefs(getAtlasEnumElementDefs(enumType.getEnumValues()));
 
             ret.add(enumDef);
         }
@@ -235,80 +209,65 @@ public final class TypeConverterUtil {
         return ret;
     }
 
-    private static List<AtlasStructDef> 
toAtlasStructDefs(List<StructTypeDefinition> structTypeDefinitions)
-            throws AtlasBaseException {
-        List<AtlasStructDef> ret = new ArrayList<AtlasStructDef>();
+    private static List<AtlasStructDef> 
toAtlasStructDefs(List<StructTypeDefinition> structTypeDefinitions) {
+        List<AtlasStructDef> ret = new ArrayList<>();
 
         for (StructTypeDefinition structType : structTypeDefinitions) {
-            AtlasStructDef          structDef = new AtlasStructDef();
             List<AtlasAttributeDef> attrDefs  = new 
ArrayList<AtlasAttributeDef>();
 
-            structDef.setName(structType.typeName);
-            structDef.setDescription(structType.typeDescription);
-            structDef.setTypeVersion(structType.typeVersion);
-
-            AttributeDefinition[] attrDefinitions = 
structType.attributeDefinitions;
-            for (AttributeDefinition attrDefinition : attrDefinitions) {
-                attrDefs.add(toAtlasAttributeDef(attrDefinition));
+            if 
(CollectionUtils.isNotEmpty(structType.getAttributeDefinitions())) {
+                for (AttributeDefinition attrDefinition : 
structType.getAttributeDefinitions()) {
+                    attrDefs.add(toAtlasAttributeDef(attrDefinition));
+                }
             }
 
-            structDef.setAttributeDefs(attrDefs);
+            AtlasStructDef structDef = new 
AtlasStructDef(structType.getTypeName(), structType.getTypeDescription(), 
structType.getTypeVersion(), attrDefs);
+
             ret.add(structDef);
         }
 
         return ret;
     }
 
-    private static List<AtlasClassificationDef> 
toAtlasClassificationDefs(List<HierarchicalTypeDefinition<TraitType>> 
traitTypeDefinitions)
-            throws AtlasBaseException {
-        List<AtlasClassificationDef> ret = new 
ArrayList<AtlasClassificationDef>();
+    private static List<AtlasClassificationDef> 
toAtlasClassificationDefs(List<TraitTypeDefinition> traitTypeDefinitions) {
+        List<AtlasClassificationDef> ret = new ArrayList<>();
 
-        for (HierarchicalTypeDefinition<TraitType> traitType : 
traitTypeDefinitions) {
-            AtlasClassificationDef  classifDef = new AtlasClassificationDef();
+        for (TraitTypeDefinition traitType : traitTypeDefinitions) {
             List<AtlasAttributeDef> attrDefs   = new 
ArrayList<AtlasAttributeDef>();
 
-            classifDef.setName(traitType.typeName);
-            classifDef.setDescription(traitType.typeDescription);
-            classifDef.setTypeVersion(traitType.typeVersion);
-            classifDef.setSuperTypes(traitType.superTypes);
-
-            AttributeDefinition[] attrDefinitions = 
traitType.attributeDefinitions;
-            for (AttributeDefinition attrDefinition : attrDefinitions) {
-                attrDefs.add(toAtlasAttributeDef(attrDefinition));
+            if 
(CollectionUtils.isNotEmpty(traitType.getAttributeDefinitions())) {
+                for (AttributeDefinition attrDefinition : 
traitType.getAttributeDefinitions()) {
+                    attrDefs.add(toAtlasAttributeDef(attrDefinition));
+                }
             }
 
-            classifDef.setAttributeDefs(attrDefs);
+            AtlasClassificationDef classifDef = new 
AtlasClassificationDef(traitType.getTypeName(), traitType.getTypeDescription(), 
traitType.getTypeVersion(), attrDefs, traitType.getSuperTypes());
+
             ret.add(classifDef);
         }
 
         return ret;
     }
 
-    private static List<AtlasEntityDef> 
toAtlasEntityDefs(List<HierarchicalTypeDefinition<ClassType>> 
classTypeDefinitions,
-                                                          AtlasTypeRegistry 
registry) throws AtlasBaseException {
-        List<AtlasEntityDef> atlasEntityDefs = new ArrayList<AtlasEntityDef>();
+    private static List<AtlasEntityDef> 
toAtlasEntityDefs(List<ClassTypeDefinition> classTypeDefinitions, 
AtlasTypeRegistry registry) {
+        List<AtlasEntityDef> ret = new ArrayList<>();
 
-        for (HierarchicalTypeDefinition<ClassType> classType : 
classTypeDefinitions) {
+        for (ClassTypeDefinition classType : classTypeDefinitions) {
             List<AtlasAttributeDef> attrDefs         = new 
ArrayList<AtlasAttributeDef>();
-            AtlasEntityDef          atlasEntityDef   = new AtlasEntityDef();
-            String                  classTypeDefName = classType.typeName;
-
-            atlasEntityDef.setName(classTypeDefName);
-            atlasEntityDef.setDescription(classType.typeDescription);
-            atlasEntityDef.setTypeVersion(classType.typeVersion);
-            atlasEntityDef.setSuperTypes(classType.superTypes);
-
-            AttributeDefinition[] attrDefinitions = 
classType.attributeDefinitions;
-            for (AttributeDefinition oldAttr : attrDefinitions) {
-                AtlasAttributeDef newAttr = toAtlasAttributeDef(oldAttr);
-                attrDefs.add(newAttr);
+
+            if 
(CollectionUtils.isNotEmpty(classType.getAttributeDefinitions())) {
+                for (AttributeDefinition oldAttr : 
classType.getAttributeDefinitions()) {
+                    AtlasAttributeDef newAttr = toAtlasAttributeDef(oldAttr);
+                    attrDefs.add(newAttr);
+                }
             }
 
-            atlasEntityDef.setAttributeDefs(attrDefs);
-            atlasEntityDefs.add(atlasEntityDef);
+            AtlasEntityDef entityDef = new 
AtlasEntityDef(classType.getTypeName(), classType.getTypeDescription(), 
classType.getTypeVersion(), attrDefs, classType.getSuperTypes());
+
+            ret.add(entityDef);
         }
 
-        return atlasEntityDefs;
+        return ret;
     }
 
     private static String getArrayTypeName(String attrType) {
@@ -323,17 +282,17 @@ public final class TypeConverterUtil {
         return ret;
     }
 
-    private static List<AtlasEnumElementDef> 
getAtlasEnumElementDefs(EnumValue[] enums) {
-        List<AtlasEnumElementDef> ret = new ArrayList<AtlasEnumElementDef>();
+    private static List<AtlasEnumElementDef> 
getAtlasEnumElementDefs(List<EnumValue> enums) {
+        List<AtlasEnumElementDef> ret = new ArrayList<>();
 
         for (EnumValue enumElem : enums) {
-            ret.add(new AtlasEnumElementDef(enumElem.value, null, 
enumElem.ordinal));
+            ret.add(new AtlasEnumElementDef(enumElem.getValue(), null, 
enumElem.getOrdinal()));
         }
 
         return ret;
     }
 
-    private static EnumValue[] getEnumValues(List<AtlasEnumElementDef> 
enumDefs) {
+    private static List<EnumValue> getEnumValues(List<AtlasEnumElementDef> 
enumDefs) {
         List<EnumValue> ret = new ArrayList<EnumValue>();
 
         if (CollectionUtils.isNotEmpty(enumDefs)) {
@@ -344,32 +303,30 @@ public final class TypeConverterUtil {
             }
         }
 
-        return ret.toArray(new EnumValue[ret.size()]);
+        return ret;
     }
 
     public static AtlasAttributeDef toAtlasAttributeDef(final 
AttributeDefinition attrDefinition) {
-        AtlasAttributeDef ret = new AtlasAttributeDef();
+        AtlasAttributeDef ret = new 
AtlasAttributeDef(attrDefinition.getName(), attrDefinition.getDataTypeName());
 
-        ret.setName(attrDefinition.name);
-        ret.setTypeName(attrDefinition.dataTypeName);
-        ret.setIsIndexable(attrDefinition.isIndexable);
-        ret.setIsUnique(attrDefinition.isUnique);
-        if (attrDefinition.isComposite) {
+        ret.setIsIndexable(attrDefinition.getIsIndexable());
+        ret.setIsUnique(attrDefinition.getIsUnique());
+        if (attrDefinition.getIsComposite()) {
             ret.addConstraint(new 
AtlasConstraintDef(CONSTRAINT_TYPE_OWNED_REF));
         }
 
-        if (StringUtils.isNotBlank(attrDefinition.reverseAttributeName)) {
+        if (StringUtils.isNotBlank(attrDefinition.getReverseAttributeName())) {
             ret.addConstraint(new 
AtlasConstraintDef(CONSTRAINT_TYPE_INVERSE_REF,
                                        new HashMap<String, Object>() {{
-                                           put(CONSTRAINT_PARAM_ATTRIBUTE, 
attrDefinition.reverseAttributeName);
+                                           put(CONSTRAINT_PARAM_ATTRIBUTE, 
attrDefinition.getReverseAttributeName());
                                        }}));
         }
 
         // Multiplicity attribute mapping
-        Multiplicity multiplicity = attrDefinition.multiplicity;
-        int          minCount     = multiplicity.lower;
-        int          maxCount     = multiplicity.upper;
-        boolean      isUnique     = multiplicity.isUnique;
+        Multiplicity multiplicity = attrDefinition.getMultiplicity();
+        int          minCount     = multiplicity.getLower();
+        int          maxCount     = multiplicity.getUpper();
+        boolean      isUnique     = multiplicity.getIsUnique();
 
         if (minCount == 0) {
             ret.setIsOptional(true);
@@ -395,7 +352,7 @@ public final class TypeConverterUtil {
         return ret;
     }
 
-    private static AttributeDefinition[] getAttributes(AtlasStructType 
structType, AtlasTypeRegistry registry) throws AtlasBaseException {
+    private static List<AttributeDefinition> getAttributes(AtlasStructType 
structType, AtlasTypeRegistry registry) {
         List<AttributeDefinition> ret      = new ArrayList<>();
         List<AtlasAttributeDef>   attrDefs = 
structType.getStructDef().getAttributeDefs();
 
@@ -403,10 +360,12 @@ public final class TypeConverterUtil {
             for (AtlasAttributeDef attrDef : attrDefs) {
                 AtlasAttribute attribute = 
structType.getAttribute(attrDef.getName());
 
-                ret.add(AtlasStructDefStoreV1.toAttributeDefintion(attribute));
+                AttributeDefinition oldAttrDef = 
AtlasStructDefStoreV1.toAttributeDefintion(attribute);
+
+                ret.add(new AttributeDefinition(oldAttrDef.getName(), 
oldAttrDef.getDataTypeName(), new Multiplicity(oldAttrDef.getMultiplicity()), 
oldAttrDef.getIsComposite(), oldAttrDef.getIsUnique(), 
oldAttrDef.getIsIndexable(), oldAttrDef.getReverseAttributeName()));
             }
         }
 
-        return ret.toArray(new AttributeDefinition[ret.size()]);
+        return ret;
     }
 }

Reply via email to