Commit 3d5b4880 by apoorvnaik

ATLAS-2490: updates to make usage of v1/v2 in class names consistent

parent 85e08c28
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
package org.apache.atlas.authorize; package org.apache.atlas.authorize;
import org.apache.atlas.AtlasErrorCode; import org.apache.atlas.AtlasErrorCode;
import org.apache.atlas.RequestContext;
import org.apache.atlas.exception.AtlasBaseException; import org.apache.atlas.exception.AtlasBaseException;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
...@@ -33,7 +34,6 @@ import java.net.InetAddress; ...@@ -33,7 +34,6 @@ import java.net.InetAddress;
import java.net.UnknownHostException; import java.net.UnknownHostException;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import org.apache.atlas.RequestContextV1;
public class AtlasAuthorizationUtils { public class AtlasAuthorizationUtils {
private static final Logger LOG = LoggerFactory.getLogger(AtlasAuthorizationUtils.class); private static final Logger LOG = LoggerFactory.getLogger(AtlasAuthorizationUtils.class);
...@@ -71,7 +71,7 @@ public class AtlasAuthorizationUtils { ...@@ -71,7 +71,7 @@ public class AtlasAuthorizationUtils {
AtlasAuthorizer authorizer = AtlasAuthorizerFactory.getAtlasAuthorizer(); AtlasAuthorizer authorizer = AtlasAuthorizerFactory.getAtlasAuthorizer();
request.setUser(userName, getCurrentUserGroups()); request.setUser(userName, getCurrentUserGroups());
request.setClientIPAddress(RequestContextV1.get().getClientIPAddress()); request.setClientIPAddress(RequestContext.get().getClientIPAddress());
ret = authorizer.isAccessAllowed(request); ret = authorizer.isAccessAllowed(request);
} catch (AtlasAuthorizationException e) { } catch (AtlasAuthorizationException e) {
LOG.error("Unable to obtain AtlasAuthorizer", e); LOG.error("Unable to obtain AtlasAuthorizer", e);
...@@ -92,7 +92,7 @@ public class AtlasAuthorizationUtils { ...@@ -92,7 +92,7 @@ public class AtlasAuthorizationUtils {
AtlasAuthorizer authorizer = AtlasAuthorizerFactory.getAtlasAuthorizer(); AtlasAuthorizer authorizer = AtlasAuthorizerFactory.getAtlasAuthorizer();
request.setUser(getCurrentUserName(), getCurrentUserGroups()); request.setUser(getCurrentUserName(), getCurrentUserGroups());
request.setClientIPAddress(RequestContextV1.get().getClientIPAddress()); request.setClientIPAddress(RequestContext.get().getClientIPAddress());
ret = authorizer.isAccessAllowed(request); ret = authorizer.isAccessAllowed(request);
} catch (AtlasAuthorizationException e) { } catch (AtlasAuthorizationException e) {
LOG.error("Unable to obtain AtlasAuthorizer", e); LOG.error("Unable to obtain AtlasAuthorizer", e);
...@@ -113,7 +113,7 @@ public class AtlasAuthorizationUtils { ...@@ -113,7 +113,7 @@ public class AtlasAuthorizationUtils {
AtlasAuthorizer authorizer = AtlasAuthorizerFactory.getAtlasAuthorizer(); AtlasAuthorizer authorizer = AtlasAuthorizerFactory.getAtlasAuthorizer();
request.setUser(getCurrentUserName(), getCurrentUserGroups()); request.setUser(getCurrentUserName(), getCurrentUserGroups());
request.setClientIPAddress(RequestContextV1.get().getClientIPAddress()); request.setClientIPAddress(RequestContext.get().getClientIPAddress());
ret = authorizer.isAccessAllowed(request); ret = authorizer.isAccessAllowed(request);
} catch (AtlasAuthorizationException e) { } catch (AtlasAuthorizationException e) {
LOG.error("Unable to obtain AtlasAuthorizer", e); LOG.error("Unable to obtain AtlasAuthorizer", e);
......
...@@ -27,7 +27,7 @@ import org.apache.atlas.repository.graphdb.AtlasGraph; ...@@ -27,7 +27,7 @@ import org.apache.atlas.repository.graphdb.AtlasGraph;
import org.apache.atlas.repository.graphdb.AtlasGraphQuery; import org.apache.atlas.repository.graphdb.AtlasGraphQuery;
import org.apache.atlas.repository.graphdb.AtlasIndexQuery; import org.apache.atlas.repository.graphdb.AtlasIndexQuery;
import org.apache.atlas.repository.graphdb.AtlasVertex; import org.apache.atlas.repository.graphdb.AtlasVertex;
import org.apache.atlas.repository.store.graph.v1.AtlasGraphUtilsV1; import org.apache.atlas.repository.store.graph.v2.AtlasGraphUtilsV2;
import org.apache.atlas.type.AtlasClassificationType; import org.apache.atlas.type.AtlasClassificationType;
import org.apache.atlas.util.AtlasGremlinQueryProvider; import org.apache.atlas.util.AtlasGremlinQueryProvider;
import org.apache.atlas.util.SearchPredicateUtil; import org.apache.atlas.util.SearchPredicateUtil;
...@@ -268,11 +268,11 @@ public class ClassificationSearchProcessor extends SearchProcessor { ...@@ -268,11 +268,11 @@ public class ClassificationSearchProcessor extends SearchProcessor {
for (AtlasEdge edge : edges) { for (AtlasEdge edge : edges) {
AtlasVertex entityVertex = edge.getOutVertex(); AtlasVertex entityVertex = edge.getOutVertex();
if (activeOnly && AtlasGraphUtilsV1.getState(entityVertex) != AtlasEntity.Status.ACTIVE) { if (activeOnly && AtlasGraphUtilsV2.getState(entityVertex) != AtlasEntity.Status.ACTIVE) {
continue; continue;
} }
String guid = AtlasGraphUtilsV1.getIdFromVertex(entityVertex); String guid = AtlasGraphUtilsV2.getIdFromVertex(entityVertex);
if (processedGuids.contains(guid)) { if (processedGuids.contains(guid)) {
continue; continue;
......
...@@ -42,8 +42,8 @@ import org.apache.atlas.repository.graphdb.AtlasGraph; ...@@ -42,8 +42,8 @@ import org.apache.atlas.repository.graphdb.AtlasGraph;
import org.apache.atlas.repository.graphdb.AtlasIndexQuery; import org.apache.atlas.repository.graphdb.AtlasIndexQuery;
import org.apache.atlas.repository.graphdb.AtlasIndexQuery.Result; import org.apache.atlas.repository.graphdb.AtlasIndexQuery.Result;
import org.apache.atlas.repository.graphdb.AtlasVertex; import org.apache.atlas.repository.graphdb.AtlasVertex;
import org.apache.atlas.repository.store.graph.v1.AtlasGraphUtilsV1; import org.apache.atlas.repository.store.graph.v2.AtlasGraphUtilsV2;
import org.apache.atlas.repository.store.graph.v1.EntityGraphRetriever; import org.apache.atlas.repository.store.graph.v2.EntityGraphRetriever;
import org.apache.atlas.repository.userprofile.UserProfileService; import org.apache.atlas.repository.userprofile.UserProfileService;
import org.apache.atlas.type.AtlasArrayType; import org.apache.atlas.type.AtlasArrayType;
import org.apache.atlas.type.AtlasBuiltInTypes.AtlasObjectIdType; import org.apache.atlas.type.AtlasBuiltInTypes.AtlasObjectIdType;
...@@ -112,7 +112,7 @@ public class EntityDiscoveryService implements AtlasDiscoveryService { ...@@ -112,7 +112,7 @@ public class EntityDiscoveryService implements AtlasDiscoveryService {
this.maxResultSetSize = ApplicationProperties.get().getInt(Constants.INDEX_SEARCH_MAX_RESULT_SET_SIZE, 150); this.maxResultSetSize = ApplicationProperties.get().getInt(Constants.INDEX_SEARCH_MAX_RESULT_SET_SIZE, 150);
this.maxTypesLengthInIdxQuery = ApplicationProperties.get().getInt(Constants.INDEX_SEARCH_TYPES_MAX_QUERY_STR_LENGTH, 512); this.maxTypesLengthInIdxQuery = ApplicationProperties.get().getInt(Constants.INDEX_SEARCH_TYPES_MAX_QUERY_STR_LENGTH, 512);
this.maxTagsLengthInIdxQuery = ApplicationProperties.get().getInt(Constants.INDEX_SEARCH_TAGS_MAX_QUERY_STR_LENGTH, 512); this.maxTagsLengthInIdxQuery = ApplicationProperties.get().getInt(Constants.INDEX_SEARCH_TAGS_MAX_QUERY_STR_LENGTH, 512);
this.indexSearchPrefix = AtlasGraphUtilsV1.getIndexSearchPrefix(); this.indexSearchPrefix = AtlasGraphUtilsV2.getIndexSearchPrefix();
this.userProfileService = userProfileService; this.userProfileService = userProfileService;
} }
......
...@@ -37,8 +37,8 @@ import org.apache.atlas.repository.Constants; ...@@ -37,8 +37,8 @@ import org.apache.atlas.repository.Constants;
import org.apache.atlas.repository.graphdb.AtlasEdge; import org.apache.atlas.repository.graphdb.AtlasEdge;
import org.apache.atlas.repository.graphdb.AtlasGraph; import org.apache.atlas.repository.graphdb.AtlasGraph;
import org.apache.atlas.repository.graphdb.AtlasVertex; import org.apache.atlas.repository.graphdb.AtlasVertex;
import org.apache.atlas.repository.store.graph.v1.AtlasGraphUtilsV1; import org.apache.atlas.repository.store.graph.v2.AtlasGraphUtilsV2;
import org.apache.atlas.repository.store.graph.v1.EntityGraphRetriever; import org.apache.atlas.repository.store.graph.v2.EntityGraphRetriever;
import org.apache.atlas.type.AtlasEntityType; import org.apache.atlas.type.AtlasEntityType;
import org.apache.atlas.type.AtlasTypeRegistry; import org.apache.atlas.type.AtlasTypeRegistry;
import org.apache.atlas.type.AtlasTypeUtil; import org.apache.atlas.type.AtlasTypeUtil;
...@@ -126,7 +126,7 @@ public class EntityLineageService implements AtlasLineageService { ...@@ -126,7 +126,7 @@ public class EntityLineageService implements AtlasLineageService {
Map<String, Object> lookupAttributes = new HashMap<>(); Map<String, Object> lookupAttributes = new HashMap<>();
lookupAttributes.put("qualifiedName", datasetName); lookupAttributes.put("qualifiedName", datasetName);
String guid = AtlasGraphUtilsV1.getGuidByUniqueAttributes(hive_table, lookupAttributes); String guid = AtlasGraphUtilsV2.getGuidByUniqueAttributes(hive_table, lookupAttributes);
return getSchemaForHiveTableByGuid(guid); return getSchemaForHiveTableByGuid(guid);
} }
...@@ -220,9 +220,9 @@ public class EntityLineageService implements AtlasLineageService { ...@@ -220,9 +220,9 @@ public class EntityLineageService implements AtlasLineageService {
private void processEdge(final AtlasEdge edge, final Map<String, AtlasEntityHeader> entities, final Set<LineageRelation> relations) throws AtlasBaseException { private void processEdge(final AtlasEdge edge, final Map<String, AtlasEntityHeader> entities, final Set<LineageRelation> relations) throws AtlasBaseException {
AtlasVertex inVertex = edge.getInVertex(); AtlasVertex inVertex = edge.getInVertex();
AtlasVertex outVertex = edge.getOutVertex(); AtlasVertex outVertex = edge.getOutVertex();
String inGuid = AtlasGraphUtilsV1.getIdFromVertex(inVertex); String inGuid = AtlasGraphUtilsV2.getIdFromVertex(inVertex);
String outGuid = AtlasGraphUtilsV1.getIdFromVertex(outVertex); String outGuid = AtlasGraphUtilsV2.getIdFromVertex(outVertex);
String relationGuid = AtlasGraphUtilsV1.getProperty(edge, Constants.RELATIONSHIP_GUID_PROPERTY_KEY, String.class); String relationGuid = AtlasGraphUtilsV2.getProperty(edge, Constants.RELATIONSHIP_GUID_PROPERTY_KEY, String.class);
boolean isInputEdge = edge.getLabel().equalsIgnoreCase(PROCESS_INPUTS_EDGE); boolean isInputEdge = edge.getLabel().equalsIgnoreCase(PROCESS_INPUTS_EDGE);
if (!entities.containsKey(inGuid)) { if (!entities.containsKey(inGuid)) {
......
...@@ -22,7 +22,7 @@ import org.apache.atlas.model.instance.AtlasEntity; ...@@ -22,7 +22,7 @@ import org.apache.atlas.model.instance.AtlasEntity;
import org.apache.atlas.repository.Constants; import org.apache.atlas.repository.Constants;
import org.apache.atlas.repository.graphdb.AtlasIndexQuery; import org.apache.atlas.repository.graphdb.AtlasIndexQuery;
import org.apache.atlas.repository.graphdb.AtlasVertex; import org.apache.atlas.repository.graphdb.AtlasVertex;
import org.apache.atlas.repository.store.graph.v1.AtlasGraphUtilsV1; import org.apache.atlas.repository.store.graph.v2.AtlasGraphUtilsV2;
import org.apache.atlas.utils.AtlasPerfTracer; import org.apache.atlas.utils.AtlasPerfTracer;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -124,7 +124,7 @@ public class FullTextSearchProcessor extends SearchProcessor { ...@@ -124,7 +124,7 @@ public class FullTextSearchProcessor extends SearchProcessor {
AtlasVertex vertex = idxQueryResult.next().getVertex(); AtlasVertex vertex = idxQueryResult.next().getVertex();
// skip non-entity vertices // skip non-entity vertices
if (!AtlasGraphUtilsV1.isEntityVertex(vertex)) { if (!AtlasGraphUtilsV2.isEntityVertex(vertex)) {
if (LOG.isDebugEnabled()) { if (LOG.isDebugEnabled()) {
LOG.debug("FullTextSearchProcessor.execute(): ignoring non-entity vertex (id={})", vertex.getId()); LOG.debug("FullTextSearchProcessor.execute(): ignoring non-entity vertex (id={})", vertex.getId());
} }
...@@ -132,7 +132,7 @@ public class FullTextSearchProcessor extends SearchProcessor { ...@@ -132,7 +132,7 @@ public class FullTextSearchProcessor extends SearchProcessor {
continue; continue;
} }
if (activeOnly && AtlasGraphUtilsV1.getState(vertex) != AtlasEntity.Status.ACTIVE) { if (activeOnly && AtlasGraphUtilsV2.getState(vertex) != AtlasEntity.Status.ACTIVE) {
continue; continue;
} }
......
...@@ -30,7 +30,7 @@ import org.apache.atlas.repository.graphdb.AtlasEdge; ...@@ -30,7 +30,7 @@ import org.apache.atlas.repository.graphdb.AtlasEdge;
import org.apache.atlas.repository.graphdb.AtlasGraph; import org.apache.atlas.repository.graphdb.AtlasGraph;
import org.apache.atlas.repository.graphdb.AtlasGraphQuery; import org.apache.atlas.repository.graphdb.AtlasGraphQuery;
import org.apache.atlas.repository.graphdb.AtlasVertex; import org.apache.atlas.repository.graphdb.AtlasVertex;
import org.apache.atlas.repository.store.graph.v1.AtlasGraphUtilsV1; import org.apache.atlas.repository.store.graph.v2.AtlasGraphUtilsV2;
import org.apache.atlas.type.AtlasClassificationType; import org.apache.atlas.type.AtlasClassificationType;
import org.apache.atlas.type.AtlasEntityType; import org.apache.atlas.type.AtlasEntityType;
import org.apache.atlas.type.AtlasStructType; import org.apache.atlas.type.AtlasStructType;
...@@ -238,7 +238,7 @@ public class SearchContext { ...@@ -238,7 +238,7 @@ public class SearchContext {
AtlasEdge edge = edges.next(); AtlasEdge edge = edges.next();
AtlasVertex inVertex = edge.getInVertex(); AtlasVertex inVertex = edge.getInVertex();
if (excludeDeletedEntities && AtlasGraphUtilsV1.getState(inVertex) == AtlasEntity.Status.DELETED) { if (excludeDeletedEntities && AtlasGraphUtilsV2.getState(inVertex) == AtlasEntity.Status.DELETED) {
continue; continue;
} }
ret.add(inVertex); ret.add(inVertex);
......
...@@ -28,7 +28,7 @@ import org.apache.atlas.repository.Constants; ...@@ -28,7 +28,7 @@ import org.apache.atlas.repository.Constants;
import org.apache.atlas.repository.graphdb.AtlasGraphQuery; import org.apache.atlas.repository.graphdb.AtlasGraphQuery;
import org.apache.atlas.repository.graphdb.AtlasIndexQuery; import org.apache.atlas.repository.graphdb.AtlasIndexQuery;
import org.apache.atlas.repository.graphdb.AtlasVertex; import org.apache.atlas.repository.graphdb.AtlasVertex;
import org.apache.atlas.repository.store.graph.v1.AtlasGraphUtilsV1; import org.apache.atlas.repository.store.graph.v2.AtlasGraphUtilsV2;
import org.apache.atlas.type.AtlasArrayType; import org.apache.atlas.type.AtlasArrayType;
import org.apache.atlas.type.AtlasEntityType; import org.apache.atlas.type.AtlasEntityType;
import org.apache.atlas.type.AtlasEnumType; import org.apache.atlas.type.AtlasEnumType;
...@@ -68,7 +68,7 @@ public abstract class SearchProcessor { ...@@ -68,7 +68,7 @@ public abstract class SearchProcessor {
public static final int MAX_RESULT_SIZE = getApplicationProperty(Constants.INDEX_SEARCH_MAX_RESULT_SET_SIZE, 150); public static final int MAX_RESULT_SIZE = getApplicationProperty(Constants.INDEX_SEARCH_MAX_RESULT_SET_SIZE, 150);
public static final int MAX_QUERY_STR_LENGTH_TYPES = getApplicationProperty(Constants.INDEX_SEARCH_TYPES_MAX_QUERY_STR_LENGTH, 512); public static final int MAX_QUERY_STR_LENGTH_TYPES = getApplicationProperty(Constants.INDEX_SEARCH_TYPES_MAX_QUERY_STR_LENGTH, 512);
public static final int MAX_QUERY_STR_LENGTH_TAGS = getApplicationProperty(Constants.INDEX_SEARCH_TAGS_MAX_QUERY_STR_LENGTH, 512); public static final int MAX_QUERY_STR_LENGTH_TAGS = getApplicationProperty(Constants.INDEX_SEARCH_TAGS_MAX_QUERY_STR_LENGTH, 512);
public static final String INDEX_SEARCH_PREFIX = AtlasGraphUtilsV1.getIndexSearchPrefix(); public static final String INDEX_SEARCH_PREFIX = AtlasGraphUtilsV2.getIndexSearchPrefix();
public static final String AND_STR = " AND "; public static final String AND_STR = " AND ";
public static final String EMPTY_STRING = ""; public static final String EMPTY_STRING = "";
public static final String SPACE_STRING = " "; public static final String SPACE_STRING = " ";
...@@ -784,7 +784,7 @@ public abstract class SearchProcessor { ...@@ -784,7 +784,7 @@ public abstract class SearchProcessor {
if (vertices != null) { if (vertices != null) {
for(AtlasVertex vertex : vertices) { for(AtlasVertex vertex : vertices) {
String guid = AtlasGraphUtilsV1.getIdFromVertex(vertex); String guid = AtlasGraphUtilsV2.getIdFromVertex(vertex);
if (StringUtils.isNotEmpty(guid)) { if (StringUtils.isNotEmpty(guid)) {
ret.add(guid); ret.add(guid);
......
...@@ -31,8 +31,8 @@ import org.apache.atlas.model.instance.AtlasRelatedObjectId; ...@@ -31,8 +31,8 @@ import org.apache.atlas.model.instance.AtlasRelatedObjectId;
import org.apache.atlas.repository.graphdb.AtlasVertex; import org.apache.atlas.repository.graphdb.AtlasVertex;
import org.apache.atlas.repository.ogm.DataAccess; import org.apache.atlas.repository.ogm.DataAccess;
import org.apache.atlas.repository.store.graph.AtlasRelationshipStore; import org.apache.atlas.repository.store.graph.AtlasRelationshipStore;
import org.apache.atlas.repository.store.graph.v1.AtlasEntityChangeNotifier; import org.apache.atlas.repository.store.graph.v2.AtlasEntityChangeNotifier;
import org.apache.atlas.repository.store.graph.v1.AtlasGraphUtilsV1; import org.apache.atlas.repository.store.graph.v2.AtlasGraphUtilsV2;
import org.apache.atlas.type.AtlasTypeRegistry; import org.apache.atlas.type.AtlasTypeRegistry;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
...@@ -94,7 +94,7 @@ public class GlossaryService { ...@@ -94,7 +94,7 @@ public class GlossaryService {
LOG.debug("==> GlossaryService.getGlossaries({}, {}, {})", limit, offset, sortOrder); LOG.debug("==> GlossaryService.getGlossaries({}, {}, {})", limit, offset, sortOrder);
} }
List<String> glossaryGuids = AtlasGraphUtilsV1.findEntityGUIDsByType(GlossaryUtils.ATLAS_GLOSSARY_TYPENAME, sortOrder); List<String> glossaryGuids = AtlasGraphUtilsV2.findEntityGUIDsByType(GlossaryUtils.ATLAS_GLOSSARY_TYPENAME, sortOrder);
PaginationHelper paginationHelper = new PaginationHelper<>(glossaryGuids, offset, limit); PaginationHelper paginationHelper = new PaginationHelper<>(glossaryGuids, offset, limit);
List<AtlasGlossary> ret; List<AtlasGlossary> ret;
...@@ -916,21 +916,21 @@ public class GlossaryService { ...@@ -916,21 +916,21 @@ public class GlossaryService {
} }
private boolean glossaryExists(AtlasGlossary atlasGlossary) { private boolean glossaryExists(AtlasGlossary atlasGlossary) {
AtlasVertex vertex = AtlasGraphUtilsV1.findByUniqueAttributes(atlasTypeRegistry.getEntityTypeByName(GlossaryUtils.ATLAS_GLOSSARY_TYPENAME), new HashMap<String, Object>() {{ AtlasVertex vertex = AtlasGraphUtilsV2.findByUniqueAttributes(atlasTypeRegistry.getEntityTypeByName(GlossaryUtils.ATLAS_GLOSSARY_TYPENAME), new HashMap<String, Object>() {{
put(QUALIFIED_NAME_ATTR, atlasGlossary.getQualifiedName()); put(QUALIFIED_NAME_ATTR, atlasGlossary.getQualifiedName());
}}); }});
return Objects.nonNull(vertex); return Objects.nonNull(vertex);
} }
private boolean termExists(AtlasGlossaryTerm term) { private boolean termExists(AtlasGlossaryTerm term) {
AtlasVertex vertex = AtlasGraphUtilsV1.findByUniqueAttributes(atlasTypeRegistry.getEntityTypeByName(GlossaryUtils.ATLAS_GLOSSARY_TERM_TYPENAME), new HashMap<String, Object>() {{ AtlasVertex vertex = AtlasGraphUtilsV2.findByUniqueAttributes(atlasTypeRegistry.getEntityTypeByName(GlossaryUtils.ATLAS_GLOSSARY_TERM_TYPENAME), new HashMap<String, Object>() {{
put(QUALIFIED_NAME_ATTR, term.getQualifiedName()); put(QUALIFIED_NAME_ATTR, term.getQualifiedName());
}}); }});
return Objects.nonNull(vertex); return Objects.nonNull(vertex);
} }
private boolean categoryExists(AtlasGlossaryCategory category) { private boolean categoryExists(AtlasGlossaryCategory category) {
AtlasVertex vertex = AtlasGraphUtilsV1.findByUniqueAttributes(atlasTypeRegistry.getEntityTypeByName(GlossaryUtils.ATLAS_GLOSSARY_CATEGORY_TYPENAME), new HashMap<String, Object>() {{ AtlasVertex vertex = AtlasGraphUtilsV2.findByUniqueAttributes(atlasTypeRegistry.getEntityTypeByName(GlossaryUtils.ATLAS_GLOSSARY_CATEGORY_TYPENAME), new HashMap<String, Object>() {{
put(QUALIFIED_NAME_ATTR, category.getQualifiedName()); put(QUALIFIED_NAME_ATTR, category.getQualifiedName());
}}); }});
return Objects.nonNull(vertex); return Objects.nonNull(vertex);
......
...@@ -21,7 +21,7 @@ package org.apache.atlas.repository.audit; ...@@ -21,7 +21,7 @@ package org.apache.atlas.repository.audit;
import org.apache.atlas.AtlasException; import org.apache.atlas.AtlasException;
import org.apache.atlas.EntityAuditEvent; import org.apache.atlas.EntityAuditEvent;
import org.apache.atlas.EntityAuditEvent.EntityAuditAction; import org.apache.atlas.EntityAuditEvent.EntityAuditAction;
import org.apache.atlas.RequestContextV1; import org.apache.atlas.RequestContext;
import org.apache.atlas.listener.EntityChangeListener; import org.apache.atlas.listener.EntityChangeListener;
import org.apache.atlas.model.glossary.AtlasGlossaryTerm; import org.apache.atlas.model.glossary.AtlasGlossaryTerm;
import org.apache.atlas.v1.model.instance.Referenceable; import org.apache.atlas.v1.model.instance.Referenceable;
...@@ -166,7 +166,7 @@ public class EntityAuditListener implements EntityChangeListener { ...@@ -166,7 +166,7 @@ public class EntityAuditListener implements EntityChangeListener {
private EntityAuditEvent createEvent(Referenceable entity, EntityAuditAction action, String details) private EntityAuditEvent createEvent(Referenceable entity, EntityAuditAction action, String details)
throws AtlasException { throws AtlasException {
return new EntityAuditEvent(entity.getId()._getId(), RequestContextV1.get().getRequestTime(), RequestContextV1.get().getUser(), action, details, entity); return new EntityAuditEvent(entity.getId()._getId(), RequestContext.get().getRequestTime(), RequestContext.get().getUser(), action, details, entity);
} }
private String getAuditEventDetail(Referenceable entity, EntityAuditAction action) throws AtlasException { private String getAuditEventDetail(Referenceable entity, EntityAuditAction action) throws AtlasException {
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
package org.apache.atlas.repository.audit; package org.apache.atlas.repository.audit;
import org.apache.atlas.EntityAuditEvent.EntityAuditAction; import org.apache.atlas.EntityAuditEvent.EntityAuditAction;
import org.apache.atlas.RequestContextV1; import org.apache.atlas.RequestContext;
import org.apache.atlas.model.audit.EntityAuditEventV2; import org.apache.atlas.model.audit.EntityAuditEventV2;
import org.apache.atlas.model.audit.EntityAuditEventV2.EntityAuditActionV2; import org.apache.atlas.model.audit.EntityAuditEventV2.EntityAuditActionV2;
import org.apache.atlas.exception.AtlasBaseException; import org.apache.atlas.exception.AtlasBaseException;
...@@ -211,8 +211,8 @@ public class EntityAuditListenerV2 implements EntityChangeListenerV2 { ...@@ -211,8 +211,8 @@ public class EntityAuditListenerV2 implements EntityChangeListenerV2 {
} }
private EntityAuditEventV2 createEvent(AtlasEntity entity, EntityAuditActionV2 action, String details) { private EntityAuditEventV2 createEvent(AtlasEntity entity, EntityAuditActionV2 action, String details) {
return new EntityAuditEventV2(entity.getGuid(), RequestContextV1.get().getRequestTime(), return new EntityAuditEventV2(entity.getGuid(), RequestContext.get().getRequestTime(),
RequestContextV1.get().getUser(), action, details, entity); RequestContext.get().getUser(), action, details, entity);
} }
private EntityAuditEventV2 createEvent(AtlasEntity entity, EntityAuditActionV2 action) { private EntityAuditEventV2 createEvent(AtlasEntity entity, EntityAuditActionV2 action) {
...@@ -249,13 +249,13 @@ public class EntityAuditListenerV2 implements EntityChangeListenerV2 { ...@@ -249,13 +249,13 @@ public class EntityAuditListenerV2 implements EntityChangeListenerV2 {
} }
private boolean isPropagatedClassificationAdded(String guid, AtlasClassification classification) { private boolean isPropagatedClassificationAdded(String guid, AtlasClassification classification) {
Map<String, List<AtlasClassification>> addedPropagations = RequestContextV1.get().getAddedPropagations(); Map<String, List<AtlasClassification>> addedPropagations = RequestContext.get().getAddedPropagations();
return hasPropagatedEntry(addedPropagations, guid, classification); return hasPropagatedEntry(addedPropagations, guid, classification);
} }
private boolean isPropagatedClassificationDeleted(String guid, AtlasClassification classification) { private boolean isPropagatedClassificationDeleted(String guid, AtlasClassification classification) {
Map<String, List<AtlasClassification>> removedPropagations = RequestContextV1.get().getRemovedPropagations(); Map<String, List<AtlasClassification>> removedPropagations = RequestContext.get().getRemovedPropagations();
return hasPropagatedEntry(removedPropagations, guid, classification); return hasPropagatedEntry(removedPropagations, guid, classification);
} }
......
...@@ -21,7 +21,7 @@ import org.apache.atlas.AtlasErrorCode; ...@@ -21,7 +21,7 @@ import org.apache.atlas.AtlasErrorCode;
import org.apache.atlas.AtlasException; import org.apache.atlas.AtlasException;
import org.apache.atlas.CreateUpdateEntitiesResult; import org.apache.atlas.CreateUpdateEntitiesResult;
import org.apache.atlas.EntityAuditEvent; import org.apache.atlas.EntityAuditEvent;
import org.apache.atlas.RequestContextV1; import org.apache.atlas.RequestContext;
import org.apache.atlas.model.audit.EntityAuditEventV2; import org.apache.atlas.model.audit.EntityAuditEventV2;
import org.apache.atlas.exception.AtlasBaseException; import org.apache.atlas.exception.AtlasBaseException;
import org.apache.atlas.model.TypeCategory; import org.apache.atlas.model.TypeCategory;
...@@ -33,7 +33,7 @@ import org.apache.atlas.model.instance.EntityMutationResponse; ...@@ -33,7 +33,7 @@ import org.apache.atlas.model.instance.EntityMutationResponse;
import org.apache.atlas.model.instance.EntityMutations.EntityOperation; import org.apache.atlas.model.instance.EntityMutations.EntityOperation;
import org.apache.atlas.model.instance.GuidMapping; import org.apache.atlas.model.instance.GuidMapping;
import org.apache.atlas.model.legacy.EntityResult; import org.apache.atlas.model.legacy.EntityResult;
import org.apache.atlas.repository.store.graph.v1.EntityGraphRetriever; import org.apache.atlas.repository.store.graph.v2.EntityGraphRetriever;
import org.apache.atlas.v1.model.instance.Referenceable; import org.apache.atlas.v1.model.instance.Referenceable;
import org.apache.atlas.v1.model.instance.Struct; import org.apache.atlas.v1.model.instance.Struct;
import org.apache.atlas.repository.converters.AtlasFormatConverter.ConverterContext; import org.apache.atlas.repository.converters.AtlasFormatConverter.ConverterContext;
...@@ -293,7 +293,7 @@ public class AtlasInstanceConverter { ...@@ -293,7 +293,7 @@ public class AtlasInstanceConverter {
public AtlasEntity.AtlasEntityWithExtInfo getAndCacheEntity(String guid) throws AtlasBaseException { public AtlasEntity.AtlasEntityWithExtInfo getAndCacheEntity(String guid) throws AtlasBaseException {
RequestContextV1 context = RequestContextV1.get(); RequestContext context = RequestContext.get();
AtlasEntity.AtlasEntityWithExtInfo entityWithExtInfo = context.getInstanceV2(guid); AtlasEntity.AtlasEntityWithExtInfo entityWithExtInfo = context.getInstanceV2(guid);
if (entityWithExtInfo == null) { if (entityWithExtInfo == null) {
......
...@@ -44,7 +44,7 @@ import org.apache.atlas.v1.model.typedef.Multiplicity; ...@@ -44,7 +44,7 @@ import org.apache.atlas.v1.model.typedef.Multiplicity;
import org.apache.atlas.v1.model.typedef.StructTypeDefinition; import org.apache.atlas.v1.model.typedef.StructTypeDefinition;
import org.apache.atlas.v1.model.typedef.TraitTypeDefinition; import org.apache.atlas.v1.model.typedef.TraitTypeDefinition;
import org.apache.atlas.v1.model.typedef.TypesDef; import org.apache.atlas.v1.model.typedef.TypesDef;
import org.apache.atlas.repository.store.graph.v1.AtlasStructDefStoreV1; import org.apache.atlas.repository.store.graph.v2.AtlasStructDefStoreV2;
import org.apache.atlas.type.AtlasClassificationType; import org.apache.atlas.type.AtlasClassificationType;
import org.apache.atlas.type.AtlasEntityType; import org.apache.atlas.type.AtlasEntityType;
import org.apache.atlas.type.AtlasEnumType; import org.apache.atlas.type.AtlasEnumType;
...@@ -360,7 +360,7 @@ public final class TypeConverterUtil { ...@@ -360,7 +360,7 @@ public final class TypeConverterUtil {
for (AtlasAttributeDef attrDef : attrDefs) { for (AtlasAttributeDef attrDef : attrDefs) {
AtlasAttribute attribute = structType.getAttribute(attrDef.getName()); AtlasAttribute attribute = structType.getAttribute(attrDef.getName());
AttributeDefinition oldAttrDef = AtlasStructDefStoreV1.toAttributeDefinition(attribute); AttributeDefinition oldAttrDef = AtlasStructDefStoreV2.toAttributeDefinition(attribute);
ret.add(new AttributeDefinition(oldAttrDef.getName(), oldAttrDef.getDataTypeName(), new Multiplicity(oldAttrDef.getMultiplicity()), oldAttrDef.getIsComposite(), oldAttrDef.getIsUnique(), oldAttrDef.getIsIndexable(), oldAttrDef.getReverseAttributeName())); ret.add(new AttributeDefinition(oldAttrDef.getName(), oldAttrDef.getDataTypeName(), new Multiplicity(oldAttrDef.getMultiplicity()), oldAttrDef.getIsComposite(), oldAttrDef.getIsUnique(), oldAttrDef.getIsIndexable(), oldAttrDef.getReverseAttributeName()));
} }
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
*/ */
package org.apache.atlas.repository.graph; package org.apache.atlas.repository.graph;
import org.apache.atlas.RequestContextV1; import org.apache.atlas.RequestContext;
import org.apache.atlas.exception.AtlasBaseException; import org.apache.atlas.exception.AtlasBaseException;
import org.apache.atlas.model.instance.AtlasClassification; import org.apache.atlas.model.instance.AtlasClassification;
import org.apache.atlas.model.instance.AtlasEntity; import org.apache.atlas.model.instance.AtlasEntity;
...@@ -25,7 +25,7 @@ import org.apache.atlas.model.instance.AtlasEntity.AtlasEntityExtInfo; ...@@ -25,7 +25,7 @@ import org.apache.atlas.model.instance.AtlasEntity.AtlasEntityExtInfo;
import org.apache.atlas.model.instance.AtlasEntity.AtlasEntityWithExtInfo; import org.apache.atlas.model.instance.AtlasEntity.AtlasEntityWithExtInfo;
import org.apache.atlas.model.instance.AtlasObjectId; import org.apache.atlas.model.instance.AtlasObjectId;
import org.apache.atlas.model.instance.AtlasStruct; import org.apache.atlas.model.instance.AtlasStruct;
import org.apache.atlas.repository.store.graph.v1.EntityGraphRetriever; import org.apache.atlas.repository.store.graph.v2.EntityGraphRetriever;
import org.apache.atlas.type.AtlasTypeRegistry; import org.apache.atlas.type.AtlasTypeRegistry;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils; import org.apache.commons.collections.MapUtils;
...@@ -203,7 +203,7 @@ public class FullTextMapperV2 { ...@@ -203,7 +203,7 @@ public class FullTextMapperV2 {
} }
private AtlasEntityWithExtInfo getAndCacheEntity(String guid) throws AtlasBaseException { private AtlasEntityWithExtInfo getAndCacheEntity(String guid) throws AtlasBaseException {
RequestContextV1 context = RequestContextV1.get(); RequestContext context = RequestContext.get();
AtlasEntityWithExtInfo entityWithExtInfo = context.getInstanceV2(guid); AtlasEntityWithExtInfo entityWithExtInfo = context.getInstanceV2(guid);
if (entityWithExtInfo == null) { if (entityWithExtInfo == null) {
......
...@@ -42,7 +42,6 @@ import org.apache.atlas.repository.graphdb.AtlasGraph; ...@@ -42,7 +42,6 @@ import org.apache.atlas.repository.graphdb.AtlasGraph;
import org.apache.atlas.repository.graphdb.AtlasGraphIndex; import org.apache.atlas.repository.graphdb.AtlasGraphIndex;
import org.apache.atlas.repository.graphdb.AtlasGraphManagement; import org.apache.atlas.repository.graphdb.AtlasGraphManagement;
import org.apache.atlas.repository.graphdb.AtlasPropertyKey; import org.apache.atlas.repository.graphdb.AtlasPropertyKey;
import org.apache.atlas.repository.store.graph.v1.AtlasGraphUtilsV1;
import org.apache.atlas.type.AtlasArrayType; import org.apache.atlas.type.AtlasArrayType;
import org.apache.atlas.type.AtlasClassificationType; import org.apache.atlas.type.AtlasClassificationType;
import org.apache.atlas.type.AtlasEntityType; import org.apache.atlas.type.AtlasEntityType;
...@@ -75,7 +74,7 @@ import static org.apache.atlas.repository.Constants.*; ...@@ -75,7 +74,7 @@ import static org.apache.atlas.repository.Constants.*;
import static org.apache.atlas.repository.graphdb.AtlasCardinality.LIST; import static org.apache.atlas.repository.graphdb.AtlasCardinality.LIST;
import static org.apache.atlas.repository.graphdb.AtlasCardinality.SET; import static org.apache.atlas.repository.graphdb.AtlasCardinality.SET;
import static org.apache.atlas.repository.graphdb.AtlasCardinality.SINGLE; import static org.apache.atlas.repository.graphdb.AtlasCardinality.SINGLE;
import static org.apache.atlas.repository.store.graph.v1.AtlasGraphUtilsV1.isReference; import static org.apache.atlas.repository.store.graph.v2.AtlasGraphUtilsV2.isReference;
import static org.apache.atlas.type.AtlasTypeUtil.isArrayType; import static org.apache.atlas.type.AtlasTypeUtil.isArrayType;
import static org.apache.atlas.type.AtlasTypeUtil.isMapType; import static org.apache.atlas.type.AtlasTypeUtil.isMapType;
......
...@@ -24,13 +24,14 @@ import com.google.common.collect.HashBiMap; ...@@ -24,13 +24,14 @@ import com.google.common.collect.HashBiMap;
import org.apache.atlas.ApplicationProperties; import org.apache.atlas.ApplicationProperties;
import org.apache.atlas.AtlasErrorCode; import org.apache.atlas.AtlasErrorCode;
import org.apache.atlas.AtlasException; import org.apache.atlas.AtlasException;
import org.apache.atlas.RequestContextV1; import org.apache.atlas.RequestContext;
import org.apache.atlas.exception.AtlasBaseException; import org.apache.atlas.exception.AtlasBaseException;
import org.apache.atlas.model.instance.AtlasEntity.Status; import org.apache.atlas.model.instance.AtlasEntity.Status;
import org.apache.atlas.model.instance.AtlasObjectId; import org.apache.atlas.model.instance.AtlasObjectId;
import org.apache.atlas.model.instance.AtlasRelationship; import org.apache.atlas.model.instance.AtlasRelationship;
import org.apache.atlas.model.typedef.AtlasRelationshipDef; import org.apache.atlas.model.typedef.AtlasRelationshipDef;
import org.apache.atlas.repository.graphdb.AtlasVertexQuery; import org.apache.atlas.repository.graphdb.AtlasVertexQuery;
import org.apache.atlas.repository.store.graph.v2.AtlasGraphUtilsV2;
import org.apache.atlas.type.AtlasArrayType; import org.apache.atlas.type.AtlasArrayType;
import org.apache.atlas.type.AtlasMapType; import org.apache.atlas.type.AtlasMapType;
import org.apache.atlas.util.AtlasGremlinQueryProvider; import org.apache.atlas.util.AtlasGremlinQueryProvider;
...@@ -47,7 +48,6 @@ import org.apache.atlas.repository.graphdb.AtlasElement; ...@@ -47,7 +48,6 @@ import org.apache.atlas.repository.graphdb.AtlasElement;
import org.apache.atlas.repository.graphdb.AtlasGraph; import org.apache.atlas.repository.graphdb.AtlasGraph;
import org.apache.atlas.repository.graphdb.AtlasGraphQuery; import org.apache.atlas.repository.graphdb.AtlasGraphQuery;
import org.apache.atlas.repository.graphdb.AtlasVertex; import org.apache.atlas.repository.graphdb.AtlasVertex;
import org.apache.atlas.repository.store.graph.v1.AtlasGraphUtilsV1;
import org.apache.atlas.type.AtlasEntityType; import org.apache.atlas.type.AtlasEntityType;
import org.apache.atlas.type.AtlasRelationshipType; import org.apache.atlas.type.AtlasRelationshipType;
import org.apache.atlas.type.AtlasType; import org.apache.atlas.type.AtlasType;
...@@ -86,7 +86,7 @@ import static org.apache.atlas.repository.Constants.CLASSIFICATION_EDGE_NAME_PRO ...@@ -86,7 +86,7 @@ import static org.apache.atlas.repository.Constants.CLASSIFICATION_EDGE_NAME_PRO
import static org.apache.atlas.repository.Constants.CLASSIFICATION_VERTEX_NAME_KEY; import static org.apache.atlas.repository.Constants.CLASSIFICATION_VERTEX_NAME_KEY;
import static org.apache.atlas.repository.Constants.CLASSIFICATION_VERTEX_PROPAGATE_KEY; import static org.apache.atlas.repository.Constants.CLASSIFICATION_VERTEX_PROPAGATE_KEY;
import static org.apache.atlas.repository.Constants.PROPAGATED_TRAIT_NAMES_PROPERTY_KEY; import static org.apache.atlas.repository.Constants.PROPAGATED_TRAIT_NAMES_PROPERTY_KEY;
import static org.apache.atlas.repository.store.graph.v1.AtlasGraphUtilsV1.isReference; import static org.apache.atlas.repository.store.graph.v2.AtlasGraphUtilsV2.isReference;
import static org.apache.atlas.type.AtlasStructType.AtlasAttribute.AtlasRelationshipEdgeDirection.BOTH; import static org.apache.atlas.type.AtlasStructType.AtlasAttribute.AtlasRelationshipEdgeDirection.BOTH;
import static org.apache.atlas.type.AtlasStructType.AtlasAttribute.AtlasRelationshipEdgeDirection.IN; import static org.apache.atlas.type.AtlasStructType.AtlasAttribute.AtlasRelationshipEdgeDirection.IN;
import static org.apache.atlas.type.AtlasStructType.AtlasAttribute.AtlasRelationshipEdgeDirection.OUT; import static org.apache.atlas.type.AtlasStructType.AtlasAttribute.AtlasRelationshipEdgeDirection.OUT;
...@@ -185,12 +185,12 @@ public final class GraphHelper { ...@@ -185,12 +185,12 @@ public final class GraphHelper {
setProperty(vertexWithoutIdentity, Constants.STATE_PROPERTY_KEY, Id.EntityState.ACTIVE.name()); setProperty(vertexWithoutIdentity, Constants.STATE_PROPERTY_KEY, Id.EntityState.ACTIVE.name());
// add timestamp information // add timestamp information
setProperty(vertexWithoutIdentity, Constants.TIMESTAMP_PROPERTY_KEY, RequestContextV1.get().getRequestTime()); setProperty(vertexWithoutIdentity, Constants.TIMESTAMP_PROPERTY_KEY, RequestContext.get().getRequestTime());
setProperty(vertexWithoutIdentity, Constants.MODIFICATION_TIMESTAMP_PROPERTY_KEY, setProperty(vertexWithoutIdentity, Constants.MODIFICATION_TIMESTAMP_PROPERTY_KEY,
RequestContextV1.get().getRequestTime()); RequestContext.get().getRequestTime());
setProperty(vertexWithoutIdentity, Constants.CREATED_BY_KEY, RequestContextV1.get().getUser()); setProperty(vertexWithoutIdentity, Constants.CREATED_BY_KEY, RequestContext.get().getUser());
setProperty(vertexWithoutIdentity, Constants.MODIFIED_BY_KEY, RequestContextV1.get().getUser()); setProperty(vertexWithoutIdentity, Constants.MODIFIED_BY_KEY, RequestContext.get().getUser());
return vertexWithoutIdentity; return vertexWithoutIdentity;
} }
...@@ -198,8 +198,8 @@ public final class GraphHelper { ...@@ -198,8 +198,8 @@ public final class GraphHelper {
AtlasEdge ret = addEdge(entityVertex, classificationVertex, CLASSIFICATION_LABEL); AtlasEdge ret = addEdge(entityVertex, classificationVertex, CLASSIFICATION_LABEL);
if (ret != null) { if (ret != null) {
AtlasGraphUtilsV1.setProperty(ret, CLASSIFICATION_EDGE_NAME_PROPERTY_KEY, getTypeName(classificationVertex)); AtlasGraphUtilsV2.setProperty(ret, CLASSIFICATION_EDGE_NAME_PROPERTY_KEY, getTypeName(classificationVertex));
AtlasGraphUtilsV1.setProperty(ret, CLASSIFICATION_EDGE_IS_PROPAGATED_PROPERTY_KEY, isPropagated); AtlasGraphUtilsV2.setProperty(ret, CLASSIFICATION_EDGE_IS_PROPAGATED_PROPERTY_KEY, isPropagated);
} }
return ret; return ret;
...@@ -216,10 +216,10 @@ public final class GraphHelper { ...@@ -216,10 +216,10 @@ public final class GraphHelper {
if (ret != null) { if (ret != null) {
setProperty(ret, Constants.STATE_PROPERTY_KEY, Id.EntityState.ACTIVE.name()); setProperty(ret, Constants.STATE_PROPERTY_KEY, Id.EntityState.ACTIVE.name());
setProperty(ret, Constants.TIMESTAMP_PROPERTY_KEY, RequestContextV1.get().getRequestTime()); setProperty(ret, Constants.TIMESTAMP_PROPERTY_KEY, RequestContext.get().getRequestTime());
setProperty(ret, Constants.MODIFICATION_TIMESTAMP_PROPERTY_KEY, RequestContextV1.get().getRequestTime()); setProperty(ret, Constants.MODIFICATION_TIMESTAMP_PROPERTY_KEY, RequestContext.get().getRequestTime());
setProperty(ret, Constants.CREATED_BY_KEY, RequestContextV1.get().getUser()); setProperty(ret, Constants.CREATED_BY_KEY, RequestContext.get().getUser());
setProperty(ret, Constants.MODIFIED_BY_KEY, RequestContextV1.get().getUser()); setProperty(ret, Constants.MODIFIED_BY_KEY, RequestContext.get().getUser());
if (LOG.isDebugEnabled()) { if (LOG.isDebugEnabled()) {
LOG.debug("Added {}", string(ret)); LOG.debug("Added {}", string(ret));
...@@ -376,7 +376,7 @@ public final class GraphHelper { ...@@ -376,7 +376,7 @@ public final class GraphHelper {
boolean ret = false; boolean ret = false;
if (classificationVertex != null) { if (classificationVertex != null) {
Boolean enabled = AtlasGraphUtilsV1.getProperty(classificationVertex, CLASSIFICATION_VERTEX_PROPAGATE_KEY, Boolean.class); Boolean enabled = AtlasGraphUtilsV2.getProperty(classificationVertex, CLASSIFICATION_VERTEX_PROPAGATE_KEY, Boolean.class);
ret = (enabled == null) ? true : enabled; ret = (enabled == null) ? true : enabled;
} }
...@@ -433,7 +433,7 @@ public final class GraphHelper { ...@@ -433,7 +433,7 @@ public final class GraphHelper {
AtlasVertex classificationVertex = (edge != null) ? edge.getInVertex() : null; AtlasVertex classificationVertex = (edge != null) ? edge.getInVertex() : null;
if (classificationVertex != null) { if (classificationVertex != null) {
String guid = AtlasGraphUtilsV1.getProperty(classificationVertex, CLASSIFICATION_ENTITY_GUID, String.class); String guid = AtlasGraphUtilsV2.getProperty(classificationVertex, CLASSIFICATION_ENTITY_GUID, String.class);
if (StringUtils.equals(guid, associatedEntityGuid)) { if (StringUtils.equals(guid, associatedEntityGuid)) {
ret = edge; ret = edge;
...@@ -960,8 +960,8 @@ public final class GraphHelper { ...@@ -960,8 +960,8 @@ public final class GraphHelper {
} }
public static void updateModificationMetadata(AtlasVertex vertex) { public static void updateModificationMetadata(AtlasVertex vertex) {
AtlasGraphUtilsV1.setProperty(vertex, Constants.MODIFICATION_TIMESTAMP_PROPERTY_KEY, RequestContextV1.get().getRequestTime()); AtlasGraphUtilsV2.setProperty(vertex, Constants.MODIFICATION_TIMESTAMP_PROPERTY_KEY, RequestContext.get().getRequestTime());
AtlasGraphUtilsV1.setProperty(vertex, Constants.MODIFIED_BY_KEY, RequestContextV1.get().getUser()); AtlasGraphUtilsV2.setProperty(vertex, Constants.MODIFIED_BY_KEY, RequestContext.get().getUser());
} }
public static String getQualifiedNameForMapKey(String prefix, String key) { public static String getQualifiedNameForMapKey(String prefix, String key) {
...@@ -1000,7 +1000,7 @@ public final class GraphHelper { ...@@ -1000,7 +1000,7 @@ public final class GraphHelper {
while (iterator.hasNext()) { while (iterator.hasNext()) {
AtlasEdge edge = iterator.next(); AtlasEdge edge = iterator.next();
ret.add(AtlasGraphUtilsV1.getProperty(edge, CLASSIFICATION_EDGE_NAME_PROPERTY_KEY, String.class)); ret.add(AtlasGraphUtilsV2.getProperty(edge, CLASSIFICATION_EDGE_NAME_PROPERTY_KEY, String.class));
} }
} }
...@@ -1168,11 +1168,11 @@ public final class GraphHelper { ...@@ -1168,11 +1168,11 @@ public final class GraphHelper {
} }
public static String getClassificationName(AtlasVertex classificationVertex) { public static String getClassificationName(AtlasVertex classificationVertex) {
return AtlasGraphUtilsV1.getProperty(classificationVertex, CLASSIFICATION_VERTEX_NAME_KEY, String.class); return AtlasGraphUtilsV2.getProperty(classificationVertex, CLASSIFICATION_VERTEX_NAME_KEY, String.class);
} }
public static String getClassificationEntityGuid(AtlasVertex classificationVertex) { public static String getClassificationEntityGuid(AtlasVertex classificationVertex) {
return AtlasGraphUtilsV1.getProperty(classificationVertex, CLASSIFICATION_ENTITY_GUID, String.class); return AtlasGraphUtilsV2.getProperty(classificationVertex, CLASSIFICATION_ENTITY_GUID, String.class);
} }
public static Integer getIndexValue(AtlasEdge edge) { public static Integer getIndexValue(AtlasEdge edge) {
...@@ -1198,7 +1198,7 @@ public final class GraphHelper { ...@@ -1198,7 +1198,7 @@ public final class GraphHelper {
List<String> ret = null; List<String> ret = null;
if (edge != null) { if (edge != null) {
List<String> classificationIds = AtlasGraphUtilsV1.getProperty(edge, Constants.RELATIONSHIPTYPE_BLOCKED_PROPAGATED_CLASSIFICATIONS_KEY, List.class); List<String> classificationIds = AtlasGraphUtilsV2.getProperty(edge, Constants.RELATIONSHIPTYPE_BLOCKED_PROPAGATED_CLASSIFICATIONS_KEY, List.class);
ret = CollectionUtils.isNotEmpty(classificationIds) ? classificationIds : Collections.emptyList(); ret = CollectionUtils.isNotEmpty(classificationIds) ? classificationIds : Collections.emptyList();
} }
...@@ -1825,7 +1825,7 @@ public final class GraphHelper { ...@@ -1825,7 +1825,7 @@ public final class GraphHelper {
Iterator<AtlasEdge> iter = entityVertex.getEdges(AtlasEdgeDirection.IN).iterator(); Iterator<AtlasEdge> iter = entityVertex.getEdges(AtlasEdgeDirection.IN).iterator();
while (iter.hasNext() && ret == null) { while (iter.hasNext() && ret == null) {
String edgeTypeName = AtlasGraphUtilsV1.getTypeName(iter.next()); String edgeTypeName = AtlasGraphUtilsV2.getTypeName(iter.next());
for (AtlasRelationshipType relationType : relationshipTypes) { for (AtlasRelationshipType relationType : relationshipTypes) {
AtlasRelationshipDef relationshipDef = relationType.getRelationshipDef(); AtlasRelationshipDef relationshipDef = relationType.getRelationshipDef();
......
...@@ -37,7 +37,7 @@ import org.apache.atlas.model.typedef.AtlasStructDef; ...@@ -37,7 +37,7 @@ import org.apache.atlas.model.typedef.AtlasStructDef;
import org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef; import org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef;
import org.apache.atlas.model.typedef.AtlasTypesDef; import org.apache.atlas.model.typedef.AtlasTypesDef;
import org.apache.atlas.repository.graphdb.AtlasGraph; import org.apache.atlas.repository.graphdb.AtlasGraph;
import org.apache.atlas.repository.store.graph.v1.EntityGraphRetriever; import org.apache.atlas.repository.store.graph.v2.EntityGraphRetriever;
import org.apache.atlas.type.AtlasArrayType; import org.apache.atlas.type.AtlasArrayType;
import org.apache.atlas.type.AtlasClassificationType; import org.apache.atlas.type.AtlasClassificationType;
import org.apache.atlas.type.AtlasEntityType; import org.apache.atlas.type.AtlasEntityType;
......
...@@ -22,7 +22,7 @@ import org.apache.atlas.model.impexp.AtlasExportResult; ...@@ -22,7 +22,7 @@ import org.apache.atlas.model.impexp.AtlasExportResult;
import org.apache.atlas.model.instance.AtlasEntity; import org.apache.atlas.model.instance.AtlasEntity;
import org.apache.atlas.model.instance.AtlasEntity.AtlasEntityWithExtInfo; import org.apache.atlas.model.instance.AtlasEntity.AtlasEntityWithExtInfo;
import org.apache.atlas.model.typedef.AtlasTypesDef; import org.apache.atlas.model.typedef.AtlasTypesDef;
import org.apache.atlas.repository.store.graph.v1.EntityImportStream; import org.apache.atlas.repository.store.graph.v2.EntityImportStream;
import org.apache.atlas.type.AtlasType; import org.apache.atlas.type.AtlasType;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
......
...@@ -24,7 +24,7 @@ import org.apache.atlas.model.instance.AtlasEntity; ...@@ -24,7 +24,7 @@ import org.apache.atlas.model.instance.AtlasEntity;
import org.apache.atlas.model.instance.AtlasEntity.AtlasEntityWithExtInfo; import org.apache.atlas.model.instance.AtlasEntity.AtlasEntityWithExtInfo;
import org.apache.atlas.model.instance.EntityMutationResponse; import org.apache.atlas.model.instance.EntityMutationResponse;
import org.apache.atlas.repository.store.graph.AtlasEntityStore; import org.apache.atlas.repository.store.graph.AtlasEntityStore;
import org.apache.atlas.repository.store.graph.v1.AtlasEntityStream; import org.apache.atlas.repository.store.graph.v2.AtlasEntityStream;
import org.apache.atlas.utils.AtlasPerfTracer; import org.apache.atlas.utils.AtlasPerfTracer;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
......
...@@ -23,7 +23,7 @@ import org.apache.atlas.model.instance.AtlasEntity.AtlasEntitiesWithExtInfo; ...@@ -23,7 +23,7 @@ import org.apache.atlas.model.instance.AtlasEntity.AtlasEntitiesWithExtInfo;
import org.apache.atlas.model.instance.AtlasEntity.AtlasEntityWithExtInfo; import org.apache.atlas.model.instance.AtlasEntity.AtlasEntityWithExtInfo;
import org.apache.atlas.model.instance.AtlasObjectId; import org.apache.atlas.model.instance.AtlasObjectId;
import org.apache.atlas.model.instance.EntityMutationResponse; import org.apache.atlas.model.instance.EntityMutationResponse;
import org.apache.atlas.repository.store.graph.v1.EntityStream; import org.apache.atlas.repository.store.graph.v2.EntityStream;
import org.apache.atlas.type.AtlasEntityType; import org.apache.atlas.type.AtlasEntityType;
import java.util.List; import java.util.List;
......
...@@ -20,7 +20,7 @@ package org.apache.atlas.repository.store.graph; ...@@ -20,7 +20,7 @@ package org.apache.atlas.repository.store.graph;
import org.apache.atlas.exception.AtlasBaseException; import org.apache.atlas.exception.AtlasBaseException;
import org.apache.atlas.model.impexp.AtlasImportResult; import org.apache.atlas.model.impexp.AtlasImportResult;
import org.apache.atlas.model.instance.EntityMutationResponse; import org.apache.atlas.model.instance.EntityMutationResponse;
import org.apache.atlas.repository.store.graph.v1.EntityImportStream; import org.apache.atlas.repository.store.graph.v2.EntityImportStream;
public interface BulkImporter { public interface BulkImporter {
......
...@@ -20,10 +20,6 @@ package org.apache.atlas.repository.store.graph; ...@@ -20,10 +20,6 @@ package org.apache.atlas.repository.store.graph;
import org.apache.atlas.exception.AtlasBaseException; import org.apache.atlas.exception.AtlasBaseException;
import org.apache.atlas.model.instance.AtlasEntity; import org.apache.atlas.model.instance.AtlasEntity;
import org.apache.atlas.repository.store.graph.v1.AtlasEntityStream;
import java.util.List;
import java.util.Map;
public interface EntityGraphDiscovery { public interface EntityGraphDiscovery {
......
...@@ -20,7 +20,7 @@ package org.apache.atlas.repository.store.graph; ...@@ -20,7 +20,7 @@ package org.apache.atlas.repository.store.graph;
import org.apache.atlas.exception.AtlasBaseException; import org.apache.atlas.exception.AtlasBaseException;
import org.apache.atlas.model.instance.AtlasObjectId; import org.apache.atlas.model.instance.AtlasObjectId;
import org.apache.atlas.repository.graphdb.AtlasVertex; import org.apache.atlas.repository.graphdb.AtlasVertex;
import org.apache.atlas.repository.store.graph.v1.EntityStream; import org.apache.atlas.repository.store.graph.v2.EntityStream;
import org.apache.atlas.type.AtlasEntityType; import org.apache.atlas.type.AtlasEntityType;
import org.apache.atlas.type.AtlasTypeRegistry; import org.apache.atlas.type.AtlasTypeRegistry;
import org.slf4j.Logger; import org.slf4j.Logger;
......
...@@ -20,7 +20,7 @@ package org.apache.atlas.repository.store.graph.v1; ...@@ -20,7 +20,7 @@ package org.apache.atlas.repository.store.graph.v1;
import org.apache.atlas.AtlasErrorCode; import org.apache.atlas.AtlasErrorCode;
import org.apache.atlas.AtlasException; import org.apache.atlas.AtlasException;
import org.apache.atlas.RequestContextV1; import org.apache.atlas.RequestContext;
import org.apache.atlas.exception.AtlasBaseException; import org.apache.atlas.exception.AtlasBaseException;
import org.apache.atlas.model.TypeCategory; import org.apache.atlas.model.TypeCategory;
import org.apache.atlas.model.instance.AtlasClassification; import org.apache.atlas.model.instance.AtlasClassification;
...@@ -35,6 +35,8 @@ import org.apache.atlas.repository.graph.GraphHelper; ...@@ -35,6 +35,8 @@ import org.apache.atlas.repository.graph.GraphHelper;
import org.apache.atlas.repository.graphdb.AtlasEdge; import org.apache.atlas.repository.graphdb.AtlasEdge;
import org.apache.atlas.repository.graphdb.AtlasEdgeDirection; import org.apache.atlas.repository.graphdb.AtlasEdgeDirection;
import org.apache.atlas.repository.graphdb.AtlasVertex; import org.apache.atlas.repository.graphdb.AtlasVertex;
import org.apache.atlas.repository.store.graph.v2.AtlasGraphUtilsV2;
import org.apache.atlas.repository.store.graph.v2.EntityGraphRetriever;
import org.apache.atlas.type.AtlasArrayType; import org.apache.atlas.type.AtlasArrayType;
import org.apache.atlas.type.AtlasClassificationType; import org.apache.atlas.type.AtlasClassificationType;
import org.apache.atlas.type.AtlasEntityType; import org.apache.atlas.type.AtlasEntityType;
...@@ -61,10 +63,10 @@ import static org.apache.atlas.repository.Constants.CLASSIFICATION_LABEL; ...@@ -61,10 +63,10 @@ import static org.apache.atlas.repository.Constants.CLASSIFICATION_LABEL;
import static org.apache.atlas.repository.Constants.PROPAGATED_TRAIT_NAMES_PROPERTY_KEY; import static org.apache.atlas.repository.Constants.PROPAGATED_TRAIT_NAMES_PROPERTY_KEY;
import static org.apache.atlas.repository.Constants.RELATIONSHIP_GUID_PROPERTY_KEY; import static org.apache.atlas.repository.Constants.RELATIONSHIP_GUID_PROPERTY_KEY;
import static org.apache.atlas.repository.graph.GraphHelper.*; import static org.apache.atlas.repository.graph.GraphHelper.*;
import static org.apache.atlas.repository.store.graph.v1.AtlasGraphUtilsV1.getIdFromEdge; import static org.apache.atlas.repository.store.graph.v2.AtlasGraphUtilsV2.getIdFromEdge;
import static org.apache.atlas.repository.store.graph.v1.AtlasGraphUtilsV1.getQualifiedAttributePropertyKey; import static org.apache.atlas.repository.store.graph.v2.AtlasGraphUtilsV2.getQualifiedAttributePropertyKey;
import static org.apache.atlas.repository.store.graph.v1.AtlasGraphUtilsV1.getState; import static org.apache.atlas.repository.store.graph.v2.AtlasGraphUtilsV2.getState;
import static org.apache.atlas.repository.store.graph.v1.AtlasGraphUtilsV1.isReference; import static org.apache.atlas.repository.store.graph.v2.AtlasGraphUtilsV2.isReference;
import static org.apache.atlas.type.AtlasStructType.AtlasAttribute.AtlasRelationshipEdgeDirection.OUT; import static org.apache.atlas.type.AtlasStructType.AtlasAttribute.AtlasRelationshipEdgeDirection.OUT;
public abstract class DeleteHandlerV1 { public abstract class DeleteHandlerV1 {
...@@ -91,11 +93,11 @@ public abstract class DeleteHandlerV1 { ...@@ -91,11 +93,11 @@ public abstract class DeleteHandlerV1 {
* @throws AtlasException * @throws AtlasException
*/ */
public void deleteEntities(Collection<AtlasVertex> instanceVertices) throws AtlasBaseException { public void deleteEntities(Collection<AtlasVertex> instanceVertices) throws AtlasBaseException {
RequestContextV1 requestContext = RequestContextV1.get(); RequestContext requestContext = RequestContext.get();
Set<AtlasVertex> deletionCandidateVertices = new HashSet<>(); Set<AtlasVertex> deletionCandidateVertices = new HashSet<>();
for (AtlasVertex instanceVertex : instanceVertices) { for (AtlasVertex instanceVertex : instanceVertices) {
String guid = AtlasGraphUtilsV1.getIdFromVertex(instanceVertex); String guid = AtlasGraphUtilsV2.getIdFromVertex(instanceVertex);
AtlasEntity.Status state = getState(instanceVertex); AtlasEntity.Status state = getState(instanceVertex);
if (state == DELETED || requestContext.isDeletedEntity(guid)) { if (state == DELETED || requestContext.isDeletedEntity(guid)) {
...@@ -295,7 +297,7 @@ public abstract class DeleteHandlerV1 { ...@@ -295,7 +297,7 @@ public abstract class DeleteHandlerV1 {
AtlasVertex referencedVertex = entityRetriever.getReferencedEntityVertex(edge, relationshipDirection, entityVertex); AtlasVertex referencedVertex = entityRetriever.getReferencedEntityVertex(edge, relationshipDirection, entityVertex);
if (referencedVertex != null) { if (referencedVertex != null) {
RequestContextV1 requestContext = RequestContextV1.get(); RequestContext requestContext = RequestContext.get();
if (!requestContext.isUpdatedEntity(GraphHelper.getGuid(referencedVertex))) { if (!requestContext.isUpdatedEntity(GraphHelper.getGuid(referencedVertex))) {
GraphHelper.setProperty(referencedVertex, Constants.MODIFICATION_TIMESTAMP_PROPERTY_KEY, requestContext.getRequestTime()); GraphHelper.setProperty(referencedVertex, Constants.MODIFICATION_TIMESTAMP_PROPERTY_KEY, requestContext.getRequestTime());
...@@ -407,7 +409,7 @@ public abstract class DeleteHandlerV1 { ...@@ -407,7 +409,7 @@ public abstract class DeleteHandlerV1 {
addToPropagatedTraitNames(propagatedEntityVertex, classificationName); addToPropagatedTraitNames(propagatedEntityVertex, classificationName);
// record add propagation details to send notifications at the end // record add propagation details to send notifications at the end
RequestContextV1 context = RequestContextV1.get(); RequestContext context = RequestContext.get();
AtlasClassification classification = entityRetriever.toAtlasClassification(classificationVertex); AtlasClassification classification = entityRetriever.toAtlasClassification(classificationVertex);
context.recordAddedPropagation(entityGuid, classification); context.recordAddedPropagation(entityGuid, classification);
...@@ -475,7 +477,7 @@ public abstract class DeleteHandlerV1 { ...@@ -475,7 +477,7 @@ public abstract class DeleteHandlerV1 {
ret.add(entityVertex); ret.add(entityVertex);
// record remove propagation details to send notifications at the end // record remove propagation details to send notifications at the end
RequestContextV1.get().recordRemovedPropagation(getGuid(entityVertex), classification); RequestContext.get().recordRemovedPropagation(getGuid(entityVertex), classification);
deletePropagatedEdge(propagatedEdge); deletePropagatedEdge(propagatedEdge);
} }
...@@ -490,7 +492,7 @@ public abstract class DeleteHandlerV1 { ...@@ -490,7 +492,7 @@ public abstract class DeleteHandlerV1 {
String classificationName = getClassificationName(classificationVertex); String classificationName = getClassificationName(classificationVertex);
AtlasClassification classification = entityRetriever.toAtlasClassification(classificationVertex); AtlasClassification classification = entityRetriever.toAtlasClassification(classificationVertex);
String entityGuid = getClassificationEntityGuid(classificationVertex); String entityGuid = getClassificationEntityGuid(classificationVertex);
RequestContextV1 context = RequestContextV1.get(); RequestContext context = RequestContext.get();
for (AtlasVertex entityVertex : entityVertices) { for (AtlasVertex entityVertex : entityVertices) {
AtlasEdge propagatedEdge = getPropagatedClassificationEdge(entityVertex, classificationName, entityGuid); AtlasEdge propagatedEdge = getPropagatedClassificationEdge(entityVertex, classificationName, entityGuid);
...@@ -575,7 +577,7 @@ public abstract class DeleteHandlerV1 { ...@@ -575,7 +577,7 @@ public abstract class DeleteHandlerV1 {
} }
public void deletePropagatedEdge(AtlasEdge edge) throws AtlasBaseException { public void deletePropagatedEdge(AtlasEdge edge) throws AtlasBaseException {
String classificationName = AtlasGraphUtilsV1.getProperty(edge, CLASSIFICATION_EDGE_NAME_PROPERTY_KEY, String.class); String classificationName = AtlasGraphUtilsV2.getProperty(edge, CLASSIFICATION_EDGE_NAME_PROPERTY_KEY, String.class);
AtlasVertex entityVertex = edge.getOutVertex(); AtlasVertex entityVertex = edge.getOutVertex();
if (LOG.isDebugEnabled()) { if (LOG.isDebugEnabled()) {
...@@ -738,7 +740,7 @@ public abstract class DeleteHandlerV1 { ...@@ -738,7 +740,7 @@ public abstract class DeleteHandlerV1 {
final String outId = GraphHelper.getGuid(outVertex); final String outId = GraphHelper.getGuid(outVertex);
final Status state = getState(outVertex); final Status state = getState(outVertex);
if (state == DELETED || (outId != null && RequestContextV1.get().isDeletedEntity(outId))) { if (state == DELETED || (outId != null && RequestContext.get().isDeletedEntity(outId))) {
//If the reference vertex is marked for deletion, skip updating the reference //If the reference vertex is marked for deletion, skip updating the reference
return; return;
} }
...@@ -832,7 +834,7 @@ public abstract class DeleteHandlerV1 { ...@@ -832,7 +834,7 @@ public abstract class DeleteHandlerV1 {
if (edge != null) { if (edge != null) {
deleteEdge(edge, isInternalType(inVertex) && isInternalType(outVertex)); deleteEdge(edge, isInternalType(inVertex) && isInternalType(outVertex));
RequestContextV1 requestContext = RequestContextV1.get(); RequestContext requestContext = RequestContext.get();
if (! requestContext.isUpdatedEntity(outId)) { if (! requestContext.isUpdatedEntity(outId)) {
GraphHelper.setProperty(outVertex, Constants.MODIFICATION_TIMESTAMP_PROPERTY_KEY, requestContext.getRequestTime()); GraphHelper.setProperty(outVertex, Constants.MODIFICATION_TIMESTAMP_PROPERTY_KEY, requestContext.getRequestTime());
......
...@@ -18,13 +18,14 @@ ...@@ -18,13 +18,14 @@
package org.apache.atlas.repository.store.graph.v1; package org.apache.atlas.repository.store.graph.v1;
import org.apache.atlas.RequestContextV1; import org.apache.atlas.RequestContext;
import org.apache.atlas.annotation.ConditionalOnAtlasProperty; import org.apache.atlas.annotation.ConditionalOnAtlasProperty;
import org.apache.atlas.exception.AtlasBaseException; import org.apache.atlas.exception.AtlasBaseException;
import org.apache.atlas.model.instance.AtlasEntity; import org.apache.atlas.model.instance.AtlasEntity;
import org.apache.atlas.repository.graph.GraphHelper; import org.apache.atlas.repository.graph.GraphHelper;
import org.apache.atlas.repository.graphdb.AtlasEdge; import org.apache.atlas.repository.graphdb.AtlasEdge;
import org.apache.atlas.repository.graphdb.AtlasVertex; import org.apache.atlas.repository.graphdb.AtlasVertex;
import org.apache.atlas.repository.store.graph.v2.AtlasGraphUtilsV2;
import org.apache.atlas.type.AtlasTypeRegistry; import org.apache.atlas.type.AtlasTypeRegistry;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
...@@ -52,12 +53,12 @@ public class SoftDeleteHandlerV1 extends DeleteHandlerV1 { ...@@ -52,12 +53,12 @@ public class SoftDeleteHandlerV1 extends DeleteHandlerV1 {
if (force) { if (force) {
graphHelper.removeVertex(instanceVertex); graphHelper.removeVertex(instanceVertex);
} else { } else {
AtlasEntity.Status state = AtlasGraphUtilsV1.getState(instanceVertex); AtlasEntity.Status state = AtlasGraphUtilsV2.getState(instanceVertex);
if (state != AtlasEntity.Status.DELETED) { if (state != AtlasEntity.Status.DELETED) {
GraphHelper.setProperty(instanceVertex, STATE_PROPERTY_KEY, AtlasEntity.Status.DELETED.name()); GraphHelper.setProperty(instanceVertex, STATE_PROPERTY_KEY, AtlasEntity.Status.DELETED.name());
GraphHelper.setProperty(instanceVertex, MODIFICATION_TIMESTAMP_PROPERTY_KEY, RequestContextV1.get().getRequestTime()); GraphHelper.setProperty(instanceVertex, MODIFICATION_TIMESTAMP_PROPERTY_KEY, RequestContext.get().getRequestTime());
GraphHelper.setProperty(instanceVertex, MODIFIED_BY_KEY, RequestContextV1.get().getUser()); GraphHelper.setProperty(instanceVertex, MODIFIED_BY_KEY, RequestContext.get().getUser());
} }
} }
} }
...@@ -74,12 +75,12 @@ public class SoftDeleteHandlerV1 extends DeleteHandlerV1 { ...@@ -74,12 +75,12 @@ public class SoftDeleteHandlerV1 extends DeleteHandlerV1 {
if (force) { if (force) {
graphHelper.removeEdge(edge); graphHelper.removeEdge(edge);
} else { } else {
AtlasEntity.Status state = AtlasGraphUtilsV1.getState(edge); AtlasEntity.Status state = AtlasGraphUtilsV2.getState(edge);
if (state != AtlasEntity.Status.DELETED) { if (state != AtlasEntity.Status.DELETED) {
GraphHelper.setProperty(edge, STATE_PROPERTY_KEY, AtlasEntity.Status.DELETED.name()); GraphHelper.setProperty(edge, STATE_PROPERTY_KEY, AtlasEntity.Status.DELETED.name());
GraphHelper.setProperty(edge, MODIFICATION_TIMESTAMP_PROPERTY_KEY, RequestContextV1.get().getRequestTime()); GraphHelper.setProperty(edge, MODIFICATION_TIMESTAMP_PROPERTY_KEY, RequestContext.get().getRequestTime());
GraphHelper.setProperty(edge, MODIFIED_BY_KEY, RequestContextV1.get().getUser()); GraphHelper.setProperty(edge, MODIFIED_BY_KEY, RequestContext.get().getUser());
} }
} }
} }
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.apache.atlas.repository.store.graph.v1; package org.apache.atlas.repository.store.graph.v2;
import org.apache.atlas.ApplicationProperties; import org.apache.atlas.ApplicationProperties;
import org.apache.atlas.AtlasErrorCode; import org.apache.atlas.AtlasErrorCode;
...@@ -36,9 +36,10 @@ import java.util.regex.Pattern; ...@@ -36,9 +36,10 @@ import java.util.regex.Pattern;
/** /**
* Abstract typedef-store for v1 format. * Abstract typedef-store for v1 format.
*/ */
abstract class AtlasAbstractDefStoreV1 <T extends AtlasBaseTypeDef> implements AtlasDefStore<T> { abstract class AtlasAbstractDefStoreV2<T extends AtlasBaseTypeDef> implements AtlasDefStore<T> {
private static final Logger LOG = LoggerFactory.getLogger(AtlasAbstractDefStoreV1.class); private static final Logger LOG = LoggerFactory.getLogger(AtlasAbstractDefStoreV2.class);
protected final AtlasTypeDefGraphStoreV1 typeDefStore;
protected final AtlasTypeDefGraphStoreV2 typeDefStore;
protected final AtlasTypeRegistry typeRegistry; protected final AtlasTypeRegistry typeRegistry;
private static final String NAME_REGEX = "[a-zA-Z][a-zA-Z0-9_ ]*"; private static final String NAME_REGEX = "[a-zA-Z][a-zA-Z0-9_ ]*";
...@@ -48,7 +49,7 @@ import java.util.regex.Pattern; ...@@ -48,7 +49,7 @@ import java.util.regex.Pattern;
public static final String ALLOW_RESERVED_KEYWORDS = "atlas.types.allowReservedKeywords"; public static final String ALLOW_RESERVED_KEYWORDS = "atlas.types.allowReservedKeywords";
public AtlasAbstractDefStoreV1(AtlasTypeDefGraphStoreV1 typeDefStore, AtlasTypeRegistry typeRegistry) { public AtlasAbstractDefStoreV2(AtlasTypeDefGraphStoreV2 typeDefStore, AtlasTypeRegistry typeRegistry) {
this.typeDefStore = typeDefStore; this.typeDefStore = typeDefStore;
this.typeRegistry = typeRegistry; this.typeRegistry = typeRegistry;
} }
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.apache.atlas.repository.store.graph.v1; package org.apache.atlas.repository.store.graph.v2;
import org.apache.atlas.AtlasErrorCode; import org.apache.atlas.AtlasErrorCode;
...@@ -43,14 +43,14 @@ import java.util.regex.Pattern; ...@@ -43,14 +43,14 @@ import java.util.regex.Pattern;
/** /**
* ClassificationDef store in v1 format. * ClassificationDef store in v1 format.
*/ */
class AtlasClassificationDefStoreV1 extends AtlasAbstractDefStoreV1<AtlasClassificationDef> { class AtlasClassificationDefStoreV2 extends AtlasAbstractDefStoreV2<AtlasClassificationDef> {
private static final Logger LOG = LoggerFactory.getLogger(AtlasClassificationDefStoreV1.class); private static final Logger LOG = LoggerFactory.getLogger(AtlasClassificationDefStoreV2.class);
private static final String TRAIT_NAME_REGEX = "[a-zA-Z][a-zA-Z0-9_ .]*"; private static final String TRAIT_NAME_REGEX = "[a-zA-Z][a-zA-Z0-9_ .]*";
private static final Pattern TRAIT_NAME_PATTERN = Pattern.compile(TRAIT_NAME_REGEX); private static final Pattern TRAIT_NAME_PATTERN = Pattern.compile(TRAIT_NAME_REGEX);
public AtlasClassificationDefStoreV1(AtlasTypeDefGraphStoreV1 typeDefStore, AtlasTypeRegistry typeRegistry) { public AtlasClassificationDefStoreV2(AtlasTypeDefGraphStoreV2 typeDefStore, AtlasTypeRegistry typeRegistry) {
super(typeDefStore, typeRegistry); super(typeDefStore, typeRegistry);
} }
...@@ -272,7 +272,7 @@ class AtlasClassificationDefStoreV1 extends AtlasAbstractDefStoreV1<AtlasClassif ...@@ -272,7 +272,7 @@ class AtlasClassificationDefStoreV1 extends AtlasAbstractDefStoreV1<AtlasClassif
AtlasVertex ret = typeDefStore.findTypeVertexByNameAndCategory(name, TypeCategory.TRAIT); AtlasVertex ret = typeDefStore.findTypeVertexByNameAndCategory(name, TypeCategory.TRAIT);
if (AtlasGraphUtilsV1.typeHasInstanceVertex(name)) { if (AtlasGraphUtilsV2.typeHasInstanceVertex(name)) {
throw new AtlasBaseException(AtlasErrorCode.TYPE_HAS_REFERENCES, name); throw new AtlasBaseException(AtlasErrorCode.TYPE_HAS_REFERENCES, name);
} }
...@@ -301,9 +301,9 @@ class AtlasClassificationDefStoreV1 extends AtlasAbstractDefStoreV1<AtlasClassif ...@@ -301,9 +301,9 @@ class AtlasClassificationDefStoreV1 extends AtlasAbstractDefStoreV1<AtlasClassif
AtlasVertex ret = typeDefStore.findTypeVertexByGuidAndCategory(guid, TypeCategory.TRAIT); AtlasVertex ret = typeDefStore.findTypeVertexByGuidAndCategory(guid, TypeCategory.TRAIT);
String typeName = AtlasGraphUtilsV1.getProperty(ret, Constants.TYPENAME_PROPERTY_KEY, String.class); String typeName = AtlasGraphUtilsV2.getProperty(ret, Constants.TYPENAME_PROPERTY_KEY, String.class);
if (AtlasGraphUtilsV1.typeHasInstanceVertex(typeName)) { if (AtlasGraphUtilsV2.typeHasInstanceVertex(typeName)) {
throw new AtlasBaseException(AtlasErrorCode.TYPE_HAS_REFERENCES, typeName); throw new AtlasBaseException(AtlasErrorCode.TYPE_HAS_REFERENCES, typeName);
} }
...@@ -323,17 +323,17 @@ class AtlasClassificationDefStoreV1 extends AtlasAbstractDefStoreV1<AtlasClassif ...@@ -323,17 +323,17 @@ class AtlasClassificationDefStoreV1 extends AtlasAbstractDefStoreV1<AtlasClassif
private void updateVertexPreCreate(AtlasClassificationDef classificationDef, private void updateVertexPreCreate(AtlasClassificationDef classificationDef,
AtlasClassificationType classificationType, AtlasClassificationType classificationType,
AtlasVertex vertex) throws AtlasBaseException { AtlasVertex vertex) throws AtlasBaseException {
AtlasStructDefStoreV1.updateVertexPreCreate(classificationDef, classificationType, vertex, typeDefStore); AtlasStructDefStoreV2.updateVertexPreCreate(classificationDef, classificationType, vertex, typeDefStore);
} }
private void updateVertexPreUpdate(AtlasClassificationDef classificationDef, private void updateVertexPreUpdate(AtlasClassificationDef classificationDef,
AtlasClassificationType classificationType, AtlasClassificationType classificationType,
AtlasVertex vertex) throws AtlasBaseException { AtlasVertex vertex) throws AtlasBaseException {
AtlasStructDefStoreV1.updateVertexPreUpdate(classificationDef, classificationType, vertex, typeDefStore); AtlasStructDefStoreV2.updateVertexPreUpdate(classificationDef, classificationType, vertex, typeDefStore);
} }
private void updateVertexAddReferences(AtlasClassificationDef classificationDef, AtlasVertex vertex) throws AtlasBaseException { private void updateVertexAddReferences(AtlasClassificationDef classificationDef, AtlasVertex vertex) throws AtlasBaseException {
AtlasStructDefStoreV1.updateVertexAddReferences(classificationDef, vertex, typeDefStore); AtlasStructDefStoreV2.updateVertexAddReferences(classificationDef, vertex, typeDefStore);
typeDefStore.createSuperTypeEdges(vertex, classificationDef.getSuperTypes(), TypeCategory.TRAIT); typeDefStore.createSuperTypeEdges(vertex, classificationDef.getSuperTypes(), TypeCategory.TRAIT);
// create edges from this vertex to entity Type vertices with the supplied entity type names // create edges from this vertex to entity Type vertices with the supplied entity type names
...@@ -346,7 +346,7 @@ class AtlasClassificationDefStoreV1 extends AtlasAbstractDefStoreV1<AtlasClassif ...@@ -346,7 +346,7 @@ class AtlasClassificationDefStoreV1 extends AtlasAbstractDefStoreV1<AtlasClassif
if (vertex != null && typeDefStore.isTypeVertex(vertex, TypeCategory.TRAIT)) { if (vertex != null && typeDefStore.isTypeVertex(vertex, TypeCategory.TRAIT)) {
ret = new AtlasClassificationDef(); ret = new AtlasClassificationDef();
AtlasStructDefStoreV1.toStructDef(vertex, ret, typeDefStore); AtlasStructDefStoreV2.toStructDef(vertex, ret, typeDefStore);
ret.setSuperTypes(typeDefStore.getSuperTypeNames(vertex)); ret.setSuperTypes(typeDefStore.getSuperTypeNames(vertex));
ret.setEntityTypes(typeDefStore.getEntityTypeNames(vertex)); ret.setEntityTypes(typeDefStore.getEntityTypeNames(vertex));
......
...@@ -15,12 +15,12 @@ ...@@ -15,12 +15,12 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.apache.atlas.repository.store.graph.v1; package org.apache.atlas.repository.store.graph.v2;
import org.apache.atlas.AtlasErrorCode; import org.apache.atlas.AtlasErrorCode;
import org.apache.atlas.AtlasException; import org.apache.atlas.AtlasException;
import org.apache.atlas.RequestContextV1; import org.apache.atlas.RequestContext;
import org.apache.atlas.exception.AtlasBaseException; import org.apache.atlas.exception.AtlasBaseException;
import org.apache.atlas.listener.EntityChangeListener; import org.apache.atlas.listener.EntityChangeListener;
import org.apache.atlas.listener.EntityChangeListenerV2; import org.apache.atlas.listener.EntityChangeListenerV2;
...@@ -233,7 +233,7 @@ public class AtlasEntityChangeNotifier { ...@@ -233,7 +233,7 @@ public class AtlasEntityChangeNotifier {
} }
public void notifyPropagatedEntities() throws AtlasBaseException { public void notifyPropagatedEntities() throws AtlasBaseException {
RequestContextV1 context = RequestContextV1.get(); RequestContext context = RequestContext.get();
Map<String, List<AtlasClassification>> addedPropagations = context.getAddedPropagations(); Map<String, List<AtlasClassification>> addedPropagations = context.getAddedPropagations();
Map<String, List<AtlasClassification>> removedPropagations = context.getRemovedPropagations(); Map<String, List<AtlasClassification>> removedPropagations = context.getRemovedPropagations();
...@@ -424,7 +424,7 @@ public class AtlasEntityChangeNotifier { ...@@ -424,7 +424,7 @@ public class AtlasEntityChangeNotifier {
} }
String guid = entityHeader.getGuid(); String guid = entityHeader.getGuid();
AtlasVertex vertex = AtlasGraphUtilsV1.findByGuid(guid); AtlasVertex vertex = AtlasGraphUtilsV2.findByGuid(guid);
if(vertex == null) { if(vertex == null) {
continue; continue;
...@@ -453,7 +453,7 @@ public class AtlasEntityChangeNotifier { ...@@ -453,7 +453,7 @@ public class AtlasEntityChangeNotifier {
return; return;
} }
AtlasVertex atlasVertex = AtlasGraphUtilsV1.findByGuid(entityId); AtlasVertex atlasVertex = AtlasGraphUtilsV2.findByGuid(entityId);
if(atlasVertex == null || GraphHelper.isInternalType(atlasVertex)) { if(atlasVertex == null || GraphHelper.isInternalType(atlasVertex)) {
return; return;
} }
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.apache.atlas.repository.store.graph.v1; package org.apache.atlas.repository.store.graph.v2;
import org.apache.atlas.AtlasErrorCode; import org.apache.atlas.AtlasErrorCode;
import org.apache.atlas.authorize.AtlasPrivilege; import org.apache.atlas.authorize.AtlasPrivilege;
...@@ -41,11 +41,11 @@ import java.util.List; ...@@ -41,11 +41,11 @@ import java.util.List;
/** /**
* EntityDef store in v1 format. * EntityDef store in v1 format.
*/ */
public class AtlasEntityDefStoreV1 extends AtlasAbstractDefStoreV1<AtlasEntityDef> { public class AtlasEntityDefStoreV2 extends AtlasAbstractDefStoreV2<AtlasEntityDef> {
private static final Logger LOG = LoggerFactory.getLogger(AtlasEntityDefStoreV1.class); private static final Logger LOG = LoggerFactory.getLogger(AtlasEntityDefStoreV2.class);
@Inject @Inject
public AtlasEntityDefStoreV1(AtlasTypeDefGraphStoreV1 typeDefStore, AtlasTypeRegistry typeRegistry) { public AtlasEntityDefStoreV2(AtlasTypeDefGraphStoreV2 typeDefStore, AtlasTypeRegistry typeRegistry) {
super(typeDefStore, typeRegistry); super(typeDefStore, typeRegistry);
} }
...@@ -269,7 +269,7 @@ public class AtlasEntityDefStoreV1 extends AtlasAbstractDefStoreV1<AtlasEntityDe ...@@ -269,7 +269,7 @@ public class AtlasEntityDefStoreV1 extends AtlasAbstractDefStoreV1<AtlasEntityDe
AtlasVertex ret = typeDefStore.findTypeVertexByNameAndCategory(name, TypeCategory.CLASS); AtlasVertex ret = typeDefStore.findTypeVertexByNameAndCategory(name, TypeCategory.CLASS);
if (AtlasGraphUtilsV1.typeHasInstanceVertex(name)) { if (AtlasGraphUtilsV2.typeHasInstanceVertex(name)) {
throw new AtlasBaseException(AtlasErrorCode.TYPE_HAS_REFERENCES, name); throw new AtlasBaseException(AtlasErrorCode.TYPE_HAS_REFERENCES, name);
} }
...@@ -278,7 +278,7 @@ public class AtlasEntityDefStoreV1 extends AtlasAbstractDefStoreV1<AtlasEntityDe ...@@ -278,7 +278,7 @@ public class AtlasEntityDefStoreV1 extends AtlasAbstractDefStoreV1<AtlasEntityDe
} }
// error if we are trying to delete an entityDef that has a relationshipDef // error if we are trying to delete an entityDef that has a relationshipDef
if (typeDefStore.hasIncomingEdgesWithLabel(ret, AtlasGraphUtilsV1.RELATIONSHIPTYPE_EDGE_LABEL)){ if (typeDefStore.hasIncomingEdgesWithLabel(ret, AtlasGraphUtilsV2.RELATIONSHIPTYPE_EDGE_LABEL)){
throw new AtlasBaseException(AtlasErrorCode.TYPE_HAS_RELATIONSHIPS, name); throw new AtlasBaseException(AtlasErrorCode.TYPE_HAS_RELATIONSHIPS, name);
} }
...@@ -303,9 +303,9 @@ public class AtlasEntityDefStoreV1 extends AtlasAbstractDefStoreV1<AtlasEntityDe ...@@ -303,9 +303,9 @@ public class AtlasEntityDefStoreV1 extends AtlasAbstractDefStoreV1<AtlasEntityDe
AtlasVertex ret = typeDefStore.findTypeVertexByGuidAndCategory(guid, TypeCategory.CLASS); AtlasVertex ret = typeDefStore.findTypeVertexByGuidAndCategory(guid, TypeCategory.CLASS);
String typeName = AtlasGraphUtilsV1.getProperty(ret, Constants.TYPENAME_PROPERTY_KEY, String.class); String typeName = AtlasGraphUtilsV2.getProperty(ret, Constants.TYPENAME_PROPERTY_KEY, String.class);
if (AtlasGraphUtilsV1.typeHasInstanceVertex(typeName)) { if (AtlasGraphUtilsV2.typeHasInstanceVertex(typeName)) {
throw new AtlasBaseException(AtlasErrorCode.TYPE_HAS_REFERENCES, typeName); throw new AtlasBaseException(AtlasErrorCode.TYPE_HAS_REFERENCES, typeName);
} }
...@@ -314,7 +314,7 @@ public class AtlasEntityDefStoreV1 extends AtlasAbstractDefStoreV1<AtlasEntityDe ...@@ -314,7 +314,7 @@ public class AtlasEntityDefStoreV1 extends AtlasAbstractDefStoreV1<AtlasEntityDe
} }
// error if we are trying to delete an entityDef that has a relationshipDef // error if we are trying to delete an entityDef that has a relationshipDef
if (typeDefStore.hasIncomingEdgesWithLabel(ret, AtlasGraphUtilsV1.RELATIONSHIPTYPE_EDGE_LABEL)){ if (typeDefStore.hasIncomingEdgesWithLabel(ret, AtlasGraphUtilsV2.RELATIONSHIPTYPE_EDGE_LABEL)){
throw new AtlasBaseException(AtlasErrorCode.TYPE_HAS_RELATIONSHIPS, typeName); throw new AtlasBaseException(AtlasErrorCode.TYPE_HAS_RELATIONSHIPS, typeName);
} }
...@@ -328,16 +328,16 @@ public class AtlasEntityDefStoreV1 extends AtlasAbstractDefStoreV1<AtlasEntityDe ...@@ -328,16 +328,16 @@ public class AtlasEntityDefStoreV1 extends AtlasAbstractDefStoreV1<AtlasEntityDe
} }
private void updateVertexPreCreate(AtlasEntityDef entityDef, AtlasEntityType entityType, AtlasVertex vertex) throws AtlasBaseException { private void updateVertexPreCreate(AtlasEntityDef entityDef, AtlasEntityType entityType, AtlasVertex vertex) throws AtlasBaseException {
AtlasStructDefStoreV1.updateVertexPreCreate(entityDef, entityType, vertex, typeDefStore); AtlasStructDefStoreV2.updateVertexPreCreate(entityDef, entityType, vertex, typeDefStore);
} }
private void updateVertexPreUpdate(AtlasEntityDef entityDef, AtlasEntityType entityType, AtlasVertex vertex) private void updateVertexPreUpdate(AtlasEntityDef entityDef, AtlasEntityType entityType, AtlasVertex vertex)
throws AtlasBaseException { throws AtlasBaseException {
AtlasStructDefStoreV1.updateVertexPreUpdate(entityDef, entityType, vertex, typeDefStore); AtlasStructDefStoreV2.updateVertexPreUpdate(entityDef, entityType, vertex, typeDefStore);
} }
private void updateVertexAddReferences(AtlasEntityDef entityDef, AtlasVertex vertex) throws AtlasBaseException { private void updateVertexAddReferences(AtlasEntityDef entityDef, AtlasVertex vertex) throws AtlasBaseException {
AtlasStructDefStoreV1.updateVertexAddReferences(entityDef, vertex, typeDefStore); AtlasStructDefStoreV2.updateVertexAddReferences(entityDef, vertex, typeDefStore);
typeDefStore.createSuperTypeEdges(vertex, entityDef.getSuperTypes(), TypeCategory.CLASS); typeDefStore.createSuperTypeEdges(vertex, entityDef.getSuperTypes(), TypeCategory.CLASS);
} }
...@@ -348,7 +348,7 @@ public class AtlasEntityDefStoreV1 extends AtlasAbstractDefStoreV1<AtlasEntityDe ...@@ -348,7 +348,7 @@ public class AtlasEntityDefStoreV1 extends AtlasAbstractDefStoreV1<AtlasEntityDe
if (vertex != null && typeDefStore.isTypeVertex(vertex, TypeCategory.CLASS)) { if (vertex != null && typeDefStore.isTypeVertex(vertex, TypeCategory.CLASS)) {
ret = new AtlasEntityDef(); ret = new AtlasEntityDef();
AtlasStructDefStoreV1.toStructDef(vertex, ret, typeDefStore); AtlasStructDefStoreV2.toStructDef(vertex, ret, typeDefStore);
ret.setSuperTypes(typeDefStore.getSuperTypeNames(vertex)); ret.setSuperTypes(typeDefStore.getSuperTypeNames(vertex));
} }
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.apache.atlas.repository.store.graph.v1; package org.apache.atlas.repository.store.graph.v2;
import org.apache.atlas.AtlasErrorCode; import org.apache.atlas.AtlasErrorCode;
import org.apache.atlas.exception.AtlasBaseException; import org.apache.atlas.exception.AtlasBaseException;
...@@ -47,13 +47,13 @@ import java.util.Map; ...@@ -47,13 +47,13 @@ import java.util.Map;
import java.util.Set; import java.util.Set;
public class AtlasEntityGraphDiscoveryV1 implements EntityGraphDiscovery { public class AtlasEntityGraphDiscoveryV2 implements EntityGraphDiscovery {
private static final Logger LOG = LoggerFactory.getLogger(AtlasEntityGraphDiscoveryV1.class); private static final Logger LOG = LoggerFactory.getLogger(AtlasEntityGraphDiscoveryV2.class);
private final AtlasTypeRegistry typeRegistry; private final AtlasTypeRegistry typeRegistry;
private final EntityGraphDiscoveryContext discoveryContext; private final EntityGraphDiscoveryContext discoveryContext;
public AtlasEntityGraphDiscoveryV1(AtlasTypeRegistry typeRegistry, EntityStream entityStream) { public AtlasEntityGraphDiscoveryV2(AtlasTypeRegistry typeRegistry, EntityStream entityStream) {
this.typeRegistry = typeRegistry; this.typeRegistry = typeRegistry;
this.discoveryContext = new EntityGraphDiscoveryContext(typeRegistry, entityStream); this.discoveryContext = new EntityGraphDiscoveryContext(typeRegistry, entityStream);
} }
......
...@@ -15,12 +15,12 @@ ...@@ -15,12 +15,12 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.apache.atlas.repository.store.graph.v1; package org.apache.atlas.repository.store.graph.v2;
import org.apache.atlas.AtlasErrorCode; import org.apache.atlas.AtlasErrorCode;
import org.apache.atlas.GraphTransactionInterceptor; import org.apache.atlas.GraphTransactionInterceptor;
import org.apache.atlas.RequestContextV1; import org.apache.atlas.RequestContext;
import org.apache.atlas.annotation.GraphTransaction; import org.apache.atlas.annotation.GraphTransaction;
import org.apache.atlas.authorize.AtlasEntityAccessRequest; import org.apache.atlas.authorize.AtlasEntityAccessRequest;
import org.apache.atlas.authorize.AtlasPrivilege; import org.apache.atlas.authorize.AtlasPrivilege;
...@@ -33,6 +33,7 @@ import org.apache.atlas.repository.graphdb.AtlasVertex; ...@@ -33,6 +33,7 @@ import org.apache.atlas.repository.graphdb.AtlasVertex;
import org.apache.atlas.repository.store.graph.AtlasEntityStore; import org.apache.atlas.repository.store.graph.AtlasEntityStore;
import org.apache.atlas.repository.store.graph.EntityGraphDiscovery; import org.apache.atlas.repository.store.graph.EntityGraphDiscovery;
import org.apache.atlas.repository.store.graph.EntityGraphDiscoveryContext; import org.apache.atlas.repository.store.graph.EntityGraphDiscoveryContext;
import org.apache.atlas.repository.store.graph.v1.DeleteHandlerV1;
import org.apache.atlas.type.AtlasClassificationType; import org.apache.atlas.type.AtlasClassificationType;
import org.apache.atlas.type.AtlasEntityType; import org.apache.atlas.type.AtlasEntityType;
import org.apache.atlas.type.AtlasStructType.AtlasAttribute; import org.apache.atlas.type.AtlasStructType.AtlasAttribute;
...@@ -43,7 +44,6 @@ import org.apache.atlas.utils.AtlasEntityUtil; ...@@ -43,7 +44,6 @@ import org.apache.atlas.utils.AtlasEntityUtil;
import org.apache.atlas.utils.AtlasPerfTracer; import org.apache.atlas.utils.AtlasPerfTracer;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils; import org.apache.commons.collections.MapUtils;
import org.apache.commons.configuration.Configuration;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -52,14 +52,13 @@ import org.springframework.stereotype.Component; ...@@ -52,14 +52,13 @@ import org.springframework.stereotype.Component;
import javax.inject.Inject; import javax.inject.Inject;
import java.util.*; import java.util.*;
import static org.apache.atlas.AtlasConstants.ATLAS_MIGRATION_MODE_FILENAME;
import static org.apache.atlas.model.instance.EntityMutations.EntityOperation.DELETE; import static org.apache.atlas.model.instance.EntityMutations.EntityOperation.DELETE;
import static org.apache.atlas.model.instance.EntityMutations.EntityOperation.UPDATE; import static org.apache.atlas.model.instance.EntityMutations.EntityOperation.UPDATE;
@Component @Component
public class AtlasEntityStoreV1 implements AtlasEntityStore { public class AtlasEntityStoreV2 implements AtlasEntityStore {
private static final Logger LOG = LoggerFactory.getLogger(AtlasEntityStoreV1.class); private static final Logger LOG = LoggerFactory.getLogger(AtlasEntityStoreV2.class);
private static final Logger PERF_LOG = AtlasPerfTracer.getPerfLogger("store.EntityStore"); private static final Logger PERF_LOG = AtlasPerfTracer.getPerfLogger("store.EntityStore");
...@@ -70,7 +69,7 @@ public class AtlasEntityStoreV1 implements AtlasEntityStore { ...@@ -70,7 +69,7 @@ public class AtlasEntityStoreV1 implements AtlasEntityStore {
private final EntityGraphRetriever entityRetriever; private final EntityGraphRetriever entityRetriever;
@Inject @Inject
public AtlasEntityStoreV1(DeleteHandlerV1 deleteHandler, AtlasTypeRegistry typeRegistry, public AtlasEntityStoreV2(DeleteHandlerV1 deleteHandler, AtlasTypeRegistry typeRegistry,
AtlasEntityChangeNotifier entityChangeNotifier, EntityGraphMapper entityGraphMapper) { AtlasEntityChangeNotifier entityChangeNotifier, EntityGraphMapper entityGraphMapper) {
this.deleteHandler = deleteHandler; this.deleteHandler = deleteHandler;
this.typeRegistry = typeRegistry; this.typeRegistry = typeRegistry;
...@@ -90,7 +89,7 @@ public class AtlasEntityStoreV1 implements AtlasEntityStore { ...@@ -90,7 +89,7 @@ public class AtlasEntityStoreV1 implements AtlasEntityStore {
throw new AtlasBaseException(AtlasErrorCode.UNKNOWN_TYPENAME); throw new AtlasBaseException(AtlasErrorCode.UNKNOWN_TYPENAME);
} }
List<String> ret = AtlasGraphUtilsV1.findEntityGUIDsByType(typename); List<String> ret = AtlasGraphUtilsV2.findEntityGUIDsByType(typename);
if (LOG.isDebugEnabled()) { if (LOG.isDebugEnabled()) {
LOG.debug("<== getEntityGUIDS({})", typename); LOG.debug("<== getEntityGUIDS({})", typename);
...@@ -149,7 +148,7 @@ public class AtlasEntityStoreV1 implements AtlasEntityStore { ...@@ -149,7 +148,7 @@ public class AtlasEntityStoreV1 implements AtlasEntityStore {
LOG.debug("==> getByUniqueAttribute({}, {})", entityType.getTypeName(), uniqAttributes); LOG.debug("==> getByUniqueAttribute({}, {})", entityType.getTypeName(), uniqAttributes);
} }
AtlasVertex entityVertex = AtlasGraphUtilsV1.getVertexByUniqueAttributes(entityType, uniqAttributes); AtlasVertex entityVertex = AtlasGraphUtilsV2.getVertexByUniqueAttributes(entityType, uniqAttributes);
AtlasEntityWithExtInfo ret = entityRetriever.toAtlasEntityWithExtInfo(entityVertex); AtlasEntityWithExtInfo ret = entityRetriever.toAtlasEntityWithExtInfo(entityVertex);
AtlasAuthorizationUtils.verifyAccess(new AtlasEntityAccessRequest(typeRegistry, AtlasPrivilege.ENTITY_READ, new AtlasEntityHeader(ret.getEntity())), "read entity: typeName=", entityType.getTypeName(), ", uniqueAttributes=", uniqAttributes); AtlasAuthorizationUtils.verifyAccess(new AtlasEntityAccessRequest(typeRegistry, AtlasPrivilege.ENTITY_READ, new AtlasEntityHeader(ret.getEntity())), "read entity: typeName=", entityType.getTypeName(), ", uniqueAttributes=", uniqAttributes);
...@@ -195,7 +194,7 @@ public class AtlasEntityStoreV1 implements AtlasEntityStore { ...@@ -195,7 +194,7 @@ public class AtlasEntityStoreV1 implements AtlasEntityStore {
throw new AtlasBaseException(AtlasErrorCode.UNKNOWN_TYPENAME, objectId.getTypeName()); throw new AtlasBaseException(AtlasErrorCode.UNKNOWN_TYPENAME, objectId.getTypeName());
} }
guid = AtlasGraphUtilsV1.getGuidByUniqueAttributes(typeRegistry.getEntityTypeByName(objectId.getTypeName()), objectId.getUniqueAttributes()); guid = AtlasGraphUtilsV2.getGuidByUniqueAttributes(typeRegistry.getEntityTypeByName(objectId.getTypeName()), objectId.getUniqueAttributes());
} }
AtlasEntity entity = updatedEntityInfo.getEntity(); AtlasEntity entity = updatedEntityInfo.getEntity();
...@@ -217,7 +216,7 @@ public class AtlasEntityStoreV1 implements AtlasEntityStore { ...@@ -217,7 +216,7 @@ public class AtlasEntityStoreV1 implements AtlasEntityStore {
throw new AtlasBaseException(AtlasErrorCode.INVALID_PARAMETERS, "no entity to update."); throw new AtlasBaseException(AtlasErrorCode.INVALID_PARAMETERS, "no entity to update.");
} }
String guid = AtlasGraphUtilsV1.getGuidByUniqueAttributes(entityType, uniqAttributes); String guid = AtlasGraphUtilsV2.getGuidByUniqueAttributes(entityType, uniqAttributes);
AtlasEntity entity = updatedEntityInfo.getEntity(); AtlasEntity entity = updatedEntityInfo.getEntity();
entity.setGuid(guid); entity.setGuid(guid);
...@@ -278,7 +277,7 @@ public class AtlasEntityStoreV1 implements AtlasEntityStore { ...@@ -278,7 +277,7 @@ public class AtlasEntityStoreV1 implements AtlasEntityStore {
} }
Collection<AtlasVertex> deletionCandidates = new ArrayList<>(); Collection<AtlasVertex> deletionCandidates = new ArrayList<>();
AtlasVertex vertex = AtlasGraphUtilsV1.findByGuid(guid); AtlasVertex vertex = AtlasGraphUtilsV2.findByGuid(guid);
if (vertex != null) { if (vertex != null) {
AtlasEntityHeader entityHeader = entityRetriever.toAtlasEntityHeaderWithClassifications(vertex); AtlasEntityHeader entityHeader = entityRetriever.toAtlasEntityHeaderWithClassifications(vertex);
...@@ -312,7 +311,7 @@ public class AtlasEntityStoreV1 implements AtlasEntityStore { ...@@ -312,7 +311,7 @@ public class AtlasEntityStoreV1 implements AtlasEntityStore {
Collection<AtlasVertex> deletionCandidates = new ArrayList<>(); Collection<AtlasVertex> deletionCandidates = new ArrayList<>();
for (String guid : guids) { for (String guid : guids) {
AtlasVertex vertex = AtlasGraphUtilsV1.findByGuid(guid); AtlasVertex vertex = AtlasGraphUtilsV2.findByGuid(guid);
if (vertex == null) { if (vertex == null) {
if (LOG.isDebugEnabled()) { if (LOG.isDebugEnabled()) {
...@@ -351,7 +350,7 @@ public class AtlasEntityStoreV1 implements AtlasEntityStore { ...@@ -351,7 +350,7 @@ public class AtlasEntityStoreV1 implements AtlasEntityStore {
} }
Collection<AtlasVertex> deletionCandidates = new ArrayList<>(); Collection<AtlasVertex> deletionCandidates = new ArrayList<>();
AtlasVertex vertex = AtlasGraphUtilsV1.findByUniqueAttributes(entityType, uniqAttributes); AtlasVertex vertex = AtlasGraphUtilsV2.findByUniqueAttributes(entityType, uniqAttributes);
if (vertex != null) { if (vertex != null) {
AtlasEntityHeader entityHeader = entityRetriever.toAtlasEntityHeaderWithClassifications(vertex); AtlasEntityHeader entityHeader = entityRetriever.toAtlasEntityHeaderWithClassifications(vertex);
...@@ -378,7 +377,7 @@ public class AtlasEntityStoreV1 implements AtlasEntityStore { ...@@ -378,7 +377,7 @@ public class AtlasEntityStoreV1 implements AtlasEntityStore {
@Override @Override
@GraphTransaction @GraphTransaction
public String getGuidByUniqueAttributes(AtlasEntityType entityType, Map<String, Object> uniqAttributes) throws AtlasBaseException{ public String getGuidByUniqueAttributes(AtlasEntityType entityType, Map<String, Object> uniqAttributes) throws AtlasBaseException{
return AtlasGraphUtilsV1.getGuidByUniqueAttributes(entityType, uniqAttributes); return AtlasGraphUtilsV2.getGuidByUniqueAttributes(entityType, uniqAttributes);
} }
@Override @Override
...@@ -640,7 +639,7 @@ public class AtlasEntityStoreV1 implements AtlasEntityStore { ...@@ -640,7 +639,7 @@ public class AtlasEntityStoreV1 implements AtlasEntityStore {
} }
private EntityMutationContext preCreateOrUpdate(EntityStream entityStream, EntityGraphMapper entityGraphMapper, boolean isPartialUpdate) throws AtlasBaseException { private EntityMutationContext preCreateOrUpdate(EntityStream entityStream, EntityGraphMapper entityGraphMapper, boolean isPartialUpdate) throws AtlasBaseException {
EntityGraphDiscovery graphDiscoverer = new AtlasEntityGraphDiscoveryV1(typeRegistry, entityStream); EntityGraphDiscovery graphDiscoverer = new AtlasEntityGraphDiscoveryV2(typeRegistry, entityStream);
EntityGraphDiscoveryContext discoveryContext = graphDiscoverer.discoverEntities(); EntityGraphDiscoveryContext discoveryContext = graphDiscoverer.discoverEntities();
EntityMutationContext context = new EntityMutationContext(discoveryContext); EntityMutationContext context = new EntityMutationContext(discoveryContext);
...@@ -658,7 +657,7 @@ public class AtlasEntityStoreV1 implements AtlasEntityStore { ...@@ -658,7 +657,7 @@ public class AtlasEntityStoreV1 implements AtlasEntityStore {
AtlasEntityType entityType = typeRegistry.getEntityTypeByName(entity.getTypeName()); AtlasEntityType entityType = typeRegistry.getEntityTypeByName(entity.getTypeName());
String guidVertex = AtlasGraphUtilsV1.getIdFromVertex(vertex); String guidVertex = AtlasGraphUtilsV2.getIdFromVertex(vertex);
if (!StringUtils.equals(guidVertex, guid)) { // if entity was found by unique attribute if (!StringUtils.equals(guidVertex, guid)) { // if entity was found by unique attribute
entity.setGuid(guidVertex); entity.setGuid(guidVertex);
...@@ -680,7 +679,7 @@ public class AtlasEntityStoreV1 implements AtlasEntityStore { ...@@ -680,7 +679,7 @@ public class AtlasEntityStoreV1 implements AtlasEntityStore {
discoveryContext.addResolvedGuid(guid, vertex); discoveryContext.addResolvedGuid(guid, vertex);
String generatedGuid = AtlasGraphUtilsV1.getIdFromVertex(vertex); String generatedGuid = AtlasGraphUtilsV2.getIdFromVertex(vertex);
entity.setGuid(generatedGuid); entity.setGuid(generatedGuid);
...@@ -699,7 +698,7 @@ public class AtlasEntityStoreV1 implements AtlasEntityStore { ...@@ -699,7 +698,7 @@ public class AtlasEntityStoreV1 implements AtlasEntityStore {
private EntityMutationResponse deleteVertices(Collection<AtlasVertex> deletionCandidates) throws AtlasBaseException { private EntityMutationResponse deleteVertices(Collection<AtlasVertex> deletionCandidates) throws AtlasBaseException {
EntityMutationResponse response = new EntityMutationResponse(); EntityMutationResponse response = new EntityMutationResponse();
RequestContextV1 req = RequestContextV1.get(); RequestContext req = RequestContext.get();
deleteHandler.deleteEntities(deletionCandidates); // this will update req with list of deleted/updated entities deleteHandler.deleteEntities(deletionCandidates); // this will update req with list of deleted/updated entities
...@@ -740,7 +739,7 @@ public class AtlasEntityStoreV1 implements AtlasEntityStore { ...@@ -740,7 +739,7 @@ public class AtlasEntityStoreV1 implements AtlasEntityStore {
*/ */
private void validateEntityAssociations(String guid, List<AtlasClassification> classifications) throws AtlasBaseException { private void validateEntityAssociations(String guid, List<AtlasClassification> classifications) throws AtlasBaseException {
List<String> entityClassifications = getClassificationNames(guid); List<String> entityClassifications = getClassificationNames(guid);
String entityTypeName = AtlasGraphUtilsV1.getTypeNameFromGuid(guid); String entityTypeName = AtlasGraphUtilsV2.getTypeNameFromGuid(guid);
AtlasEntityType entityType = typeRegistry.getEntityTypeByName(entityTypeName); AtlasEntityType entityType = typeRegistry.getEntityTypeByName(entityTypeName);
for (AtlasClassification classification : classifications) { for (AtlasClassification classification : classifications) {
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.apache.atlas.repository.store.graph.v1; package org.apache.atlas.repository.store.graph.v2;
import org.apache.atlas.model.instance.AtlasEntity; import org.apache.atlas.model.instance.AtlasEntity;
import org.apache.atlas.model.instance.AtlasEntity.AtlasEntitiesWithExtInfo; import org.apache.atlas.model.instance.AtlasEntity.AtlasEntitiesWithExtInfo;
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.apache.atlas.repository.store.graph.v1; package org.apache.atlas.repository.store.graph.v2;
import org.apache.atlas.model.instance.AtlasEntity; import org.apache.atlas.model.instance.AtlasEntity;
import org.apache.atlas.model.instance.AtlasEntity.AtlasEntityWithExtInfo; import org.apache.atlas.model.instance.AtlasEntity.AtlasEntityWithExtInfo;
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.apache.atlas.repository.store.graph.v1; package org.apache.atlas.repository.store.graph.v2;
import org.apache.atlas.AtlasErrorCode; import org.apache.atlas.AtlasErrorCode;
import org.apache.atlas.exception.AtlasBaseException; import org.apache.atlas.exception.AtlasBaseException;
...@@ -39,10 +39,10 @@ import java.util.List; ...@@ -39,10 +39,10 @@ import java.util.List;
/** /**
* EnumDef store in v1 format. * EnumDef store in v1 format.
*/ */
class AtlasEnumDefStoreV1 extends AtlasAbstractDefStoreV1<AtlasEnumDef> { class AtlasEnumDefStoreV2 extends AtlasAbstractDefStoreV2<AtlasEnumDef> {
private static final Logger LOG = LoggerFactory.getLogger(AtlasEnumDefStoreV1.class); private static final Logger LOG = LoggerFactory.getLogger(AtlasEnumDefStoreV2.class);
public AtlasEnumDefStoreV1(AtlasTypeDefGraphStoreV1 typeDefStore, AtlasTypeRegistry typeRegistry) { public AtlasEnumDefStoreV2(AtlasTypeDefGraphStoreV2 typeDefStore, AtlasTypeRegistry typeRegistry) {
super(typeDefStore, typeRegistry); super(typeDefStore, typeRegistry);
} }
...@@ -277,19 +277,19 @@ class AtlasEnumDefStoreV1 extends AtlasAbstractDefStoreV1<AtlasEnumDef> { ...@@ -277,19 +277,19 @@ class AtlasEnumDefStoreV1 extends AtlasAbstractDefStoreV1<AtlasEnumDef> {
throw new AtlasBaseException(AtlasErrorCode.MISSING_MANDATORY_ATTRIBUTE, enumDef.getName(), "elementValue"); throw new AtlasBaseException(AtlasErrorCode.MISSING_MANDATORY_ATTRIBUTE, enumDef.getName(), "elementValue");
} }
String elemKey = AtlasGraphUtilsV1.getTypeDefPropertyKey(enumDef, element.getValue()); String elemKey = AtlasGraphUtilsV2.getTypeDefPropertyKey(enumDef, element.getValue());
AtlasGraphUtilsV1.setProperty(vertex, elemKey, element.getOrdinal()); AtlasGraphUtilsV2.setProperty(vertex, elemKey, element.getOrdinal());
if (StringUtils.isNotBlank(element.getDescription())) { if (StringUtils.isNotBlank(element.getDescription())) {
String descKey = AtlasGraphUtilsV1.getTypeDefPropertyKey(elemKey, "description"); String descKey = AtlasGraphUtilsV2.getTypeDefPropertyKey(elemKey, "description");
AtlasGraphUtilsV1.setProperty(vertex, descKey, element.getDescription()); AtlasGraphUtilsV2.setProperty(vertex, descKey, element.getDescription());
} }
values.add(element.getValue()); values.add(element.getValue());
} }
AtlasGraphUtilsV1.setProperty(vertex, AtlasGraphUtilsV1.getTypeDefPropertyKey(enumDef), values); AtlasGraphUtilsV2.setProperty(vertex, AtlasGraphUtilsV2.getTypeDefPropertyKey(enumDef), values);
} }
private AtlasEnumDef toEnumDef(AtlasVertex vertex) { private AtlasEnumDef toEnumDef(AtlasVertex vertex) {
...@@ -302,19 +302,19 @@ class AtlasEnumDefStoreV1 extends AtlasAbstractDefStoreV1<AtlasEnumDef> { ...@@ -302,19 +302,19 @@ class AtlasEnumDefStoreV1 extends AtlasAbstractDefStoreV1<AtlasEnumDef> {
return ret; return ret;
} }
private static AtlasEnumDef toEnumDef(AtlasVertex vertex, AtlasEnumDef enumDef, AtlasTypeDefGraphStoreV1 typeDefStore) { private static AtlasEnumDef toEnumDef(AtlasVertex vertex, AtlasEnumDef enumDef, AtlasTypeDefGraphStoreV2 typeDefStore) {
AtlasEnumDef ret = enumDef != null ? enumDef : new AtlasEnumDef(); AtlasEnumDef ret = enumDef != null ? enumDef : new AtlasEnumDef();
typeDefStore.vertexToTypeDef(vertex, ret); typeDefStore.vertexToTypeDef(vertex, ret);
List<AtlasEnumElementDef> elements = new ArrayList<>(); List<AtlasEnumElementDef> elements = new ArrayList<>();
List<String> elemValues = vertex.getProperty(AtlasGraphUtilsV1.getTypeDefPropertyKey(ret), List.class); List<String> elemValues = vertex.getProperty(AtlasGraphUtilsV2.getTypeDefPropertyKey(ret), List.class);
for (String elemValue : elemValues) { for (String elemValue : elemValues) {
String elemKey = AtlasGraphUtilsV1.getTypeDefPropertyKey(ret, elemValue); String elemKey = AtlasGraphUtilsV2.getTypeDefPropertyKey(ret, elemValue);
String descKey = AtlasGraphUtilsV1.getTypeDefPropertyKey(elemKey, "description"); String descKey = AtlasGraphUtilsV2.getTypeDefPropertyKey(elemKey, "description");
Integer ordinal = AtlasGraphUtilsV1.getProperty(vertex, elemKey, Integer.class); Integer ordinal = AtlasGraphUtilsV2.getProperty(vertex, elemKey, Integer.class);
String desc = AtlasGraphUtilsV1.getProperty(vertex, descKey, String.class); String desc = AtlasGraphUtilsV2.getProperty(vertex, descKey, String.class);
elements.add(new AtlasEnumElementDef(elemValue, desc, ordinal)); elements.add(new AtlasEnumElementDef(elemValue, desc, ordinal));
} }
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.apache.atlas.repository.store.graph.v1; package org.apache.atlas.repository.store.graph.v2;
import org.apache.atlas.ApplicationProperties; import org.apache.atlas.ApplicationProperties;
...@@ -60,8 +60,8 @@ import static org.apache.atlas.repository.graphdb.AtlasGraphQuery.SortOrder.*; ...@@ -60,8 +60,8 @@ import static org.apache.atlas.repository.graphdb.AtlasGraphQuery.SortOrder.*;
/** /**
* Utility methods for Graph. * Utility methods for Graph.
*/ */
public class AtlasGraphUtilsV1 { public class AtlasGraphUtilsV2 {
private static final Logger LOG = LoggerFactory.getLogger(AtlasGraphUtilsV1.class); private static final Logger LOG = LoggerFactory.getLogger(AtlasGraphUtilsV2.class);
public static final String PROPERTY_PREFIX = Constants.INTERNAL_PROPERTY_KEY_PREFIX + "type."; public static final String PROPERTY_PREFIX = Constants.INTERNAL_PROPERTY_KEY_PREFIX + "type.";
public static final String SUPERTYPE_EDGE_LABEL = PROPERTY_PREFIX + ".supertype"; public static final String SUPERTYPE_EDGE_LABEL = PROPERTY_PREFIX + ".supertype";
...@@ -250,13 +250,13 @@ public class AtlasGraphUtilsV1 { ...@@ -250,13 +250,13 @@ public class AtlasGraphUtilsV1 {
} }
if (canUseIndexQuery(entityType, attribute.getName())) { if (canUseIndexQuery(entityType, attribute.getName())) {
vertex = AtlasGraphUtilsV1.getAtlasVertexFromIndexQuery(entityType, attribute, attrValue); vertex = AtlasGraphUtilsV2.getAtlasVertexFromIndexQuery(entityType, attribute, attrValue);
} else { } else {
vertex = AtlasGraphUtilsV1.findByTypeAndPropertyName(entityType.getTypeName(), attribute.getVertexPropertyName(), attrValue); vertex = AtlasGraphUtilsV2.findByTypeAndPropertyName(entityType.getTypeName(), attribute.getVertexPropertyName(), attrValue);
// if no instance of given typeName is found, try to find an instance of type's sub-type // if no instance of given typeName is found, try to find an instance of type's sub-type
if (vertex == null && !entityType.getAllSubTypes().isEmpty()) { if (vertex == null && !entityType.getAllSubTypes().isEmpty()) {
vertex = AtlasGraphUtilsV1.findBySuperTypeAndPropertyName(entityType.getTypeName(), attribute.getVertexPropertyName(), attrValue); vertex = AtlasGraphUtilsV2.findBySuperTypeAndPropertyName(entityType.getTypeName(), attribute.getVertexPropertyName(), attrValue);
} }
} }
...@@ -289,9 +289,9 @@ public class AtlasGraphUtilsV1 { ...@@ -289,9 +289,9 @@ public class AtlasGraphUtilsV1 {
String ret = null; String ret = null;
if (StringUtils.isNotEmpty(guid)) { if (StringUtils.isNotEmpty(guid)) {
AtlasVertex vertex = AtlasGraphUtilsV1.findByGuid(guid); AtlasVertex vertex = AtlasGraphUtilsV2.findByGuid(guid);
ret = (vertex != null) ? AtlasGraphUtilsV1.getTypeName(vertex) : null; ret = (vertex != null) ? AtlasGraphUtilsV2.getTypeName(vertex) : null;
} }
return ret; return ret;
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.apache.atlas.repository.store.graph.v1; package org.apache.atlas.repository.store.graph.v2;
import org.apache.atlas.ApplicationProperties; import org.apache.atlas.ApplicationProperties;
import org.apache.atlas.AtlasErrorCode; import org.apache.atlas.AtlasErrorCode;
...@@ -47,11 +47,11 @@ import java.util.List; ...@@ -47,11 +47,11 @@ import java.util.List;
/** /**
* RelationshipDef store in v1 format. * RelationshipDef store in v1 format.
*/ */
public class AtlasRelationshipDefStoreV1 extends AtlasAbstractDefStoreV1<AtlasRelationshipDef> { public class AtlasRelationshipDefStoreV2 extends AtlasAbstractDefStoreV2<AtlasRelationshipDef> {
private static final Logger LOG = LoggerFactory.getLogger(AtlasRelationshipDefStoreV1.class); private static final Logger LOG = LoggerFactory.getLogger(AtlasRelationshipDefStoreV2.class);
@Inject @Inject
public AtlasRelationshipDefStoreV1(AtlasTypeDefGraphStoreV1 typeDefStore, AtlasTypeRegistry typeRegistry) { public AtlasRelationshipDefStoreV2(AtlasTypeDefGraphStoreV2 typeDefStore, AtlasTypeRegistry typeRegistry) {
super(typeDefStore, typeRegistry); super(typeDefStore, typeRegistry);
} }
...@@ -97,7 +97,7 @@ public class AtlasRelationshipDefStoreV1 extends AtlasAbstractDefStoreV1<AtlasRe ...@@ -97,7 +97,7 @@ public class AtlasRelationshipDefStoreV1 extends AtlasAbstractDefStoreV1<AtlasRe
} }
// create an edge between the relationshipDef and each of the entityDef vertices. // create an edge between the relationshipDef and each of the entityDef vertices.
AtlasEdge edge1 = typeDefStore.getOrCreateEdge(relationshipDefVertex, end1TypeVertex, AtlasGraphUtilsV1.RELATIONSHIPTYPE_EDGE_LABEL); AtlasEdge edge1 = typeDefStore.getOrCreateEdge(relationshipDefVertex, end1TypeVertex, AtlasGraphUtilsV2.RELATIONSHIPTYPE_EDGE_LABEL);
/* /*
Where edge1 and edge2 have the same names and types we do not need a second edge. Where edge1 and edge2 have the same names and types we do not need a second edge.
...@@ -111,7 +111,7 @@ public class AtlasRelationshipDefStoreV1 extends AtlasAbstractDefStoreV1<AtlasRe ...@@ -111,7 +111,7 @@ public class AtlasRelationshipDefStoreV1 extends AtlasAbstractDefStoreV1<AtlasRe
} }
} else { } else {
AtlasEdge edge2 = typeDefStore.getOrCreateEdge(relationshipDefVertex, end2TypeVertex, AtlasGraphUtilsV1.RELATIONSHIPTYPE_EDGE_LABEL); AtlasEdge edge2 = typeDefStore.getOrCreateEdge(relationshipDefVertex, end2TypeVertex, AtlasGraphUtilsV2.RELATIONSHIPTYPE_EDGE_LABEL);
if (LOG.isDebugEnabled()) { if (LOG.isDebugEnabled()) {
LOG.debug("AtlasRelationshipDefStoreV1.preCreate({}): created relationshipDef vertex {}," + LOG.debug("AtlasRelationshipDefStoreV1.preCreate({}): created relationshipDef vertex {}," +
" edge1 as {}, edge2 as {} ", relationshipDef, relationshipDefVertex, edge1, edge2); " edge1 as {}, edge2 as {} ", relationshipDef, relationshipDefVertex, edge1, edge2);
...@@ -316,7 +316,7 @@ public class AtlasRelationshipDefStoreV1 extends AtlasAbstractDefStoreV1<AtlasRe ...@@ -316,7 +316,7 @@ public class AtlasRelationshipDefStoreV1 extends AtlasAbstractDefStoreV1<AtlasRe
throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_NOT_FOUND, name); throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_NOT_FOUND, name);
} }
if (AtlasGraphUtilsV1.relationshipTypeHasInstanceEdges(name)) { if (AtlasGraphUtilsV2.relationshipTypeHasInstanceEdges(name)) {
throw new AtlasBaseException(AtlasErrorCode.TYPE_HAS_REFERENCES, name); throw new AtlasBaseException(AtlasErrorCode.TYPE_HAS_REFERENCES, name);
} }
...@@ -345,9 +345,9 @@ public class AtlasRelationshipDefStoreV1 extends AtlasAbstractDefStoreV1<AtlasRe ...@@ -345,9 +345,9 @@ public class AtlasRelationshipDefStoreV1 extends AtlasAbstractDefStoreV1<AtlasRe
throw new AtlasBaseException(AtlasErrorCode.TYPE_GUID_NOT_FOUND, guid); throw new AtlasBaseException(AtlasErrorCode.TYPE_GUID_NOT_FOUND, guid);
} }
String typeName = AtlasGraphUtilsV1.getProperty(ret, Constants.TYPENAME_PROPERTY_KEY, String.class); String typeName = AtlasGraphUtilsV2.getProperty(ret, Constants.TYPENAME_PROPERTY_KEY, String.class);
if (AtlasGraphUtilsV1.relationshipTypeHasInstanceEdges(typeName)) { if (AtlasGraphUtilsV2.relationshipTypeHasInstanceEdges(typeName)) {
throw new AtlasBaseException(AtlasErrorCode.TYPE_HAS_REFERENCES, typeName); throw new AtlasBaseException(AtlasErrorCode.TYPE_HAS_REFERENCES, typeName);
} }
...@@ -383,7 +383,7 @@ public class AtlasRelationshipDefStoreV1 extends AtlasAbstractDefStoreV1<AtlasRe ...@@ -383,7 +383,7 @@ public class AtlasRelationshipDefStoreV1 extends AtlasAbstractDefStoreV1<AtlasRe
} }
} }
AtlasStructDefStoreV1.updateVertexPreCreate(relationshipDef, relationshipType, vertex, typeDefStore); AtlasStructDefStoreV2.updateVertexPreCreate(relationshipDef, relationshipType, vertex, typeDefStore);
// Update ends // Update ends
setVertexPropertiesFromRelationshipDef(relationshipDef, vertex); setVertexPropertiesFromRelationshipDef(relationshipDef, vertex);
} }
...@@ -396,7 +396,7 @@ public class AtlasRelationshipDefStoreV1 extends AtlasAbstractDefStoreV1<AtlasRe ...@@ -396,7 +396,7 @@ public class AtlasRelationshipDefStoreV1 extends AtlasAbstractDefStoreV1<AtlasRe
preUpdateCheck(newRelationshipDef, existingRelationshipDef); preUpdateCheck(newRelationshipDef, existingRelationshipDef);
// we do allow change to tag propagation and the addition of new attributes. // we do allow change to tag propagation and the addition of new attributes.
AtlasStructDefStoreV1.updateVertexPreUpdate(newRelationshipDef, relationshipType, vertex, typeDefStore); AtlasStructDefStoreV2.updateVertexPreUpdate(newRelationshipDef, relationshipType, vertex, typeDefStore);
setVertexPropertiesFromRelationshipDef(newRelationshipDef, vertex); setVertexPropertiesFromRelationshipDef(newRelationshipDef, vertex);
} }
...@@ -499,7 +499,7 @@ public class AtlasRelationshipDefStoreV1 extends AtlasAbstractDefStoreV1<AtlasRe ...@@ -499,7 +499,7 @@ public class AtlasRelationshipDefStoreV1 extends AtlasAbstractDefStoreV1<AtlasRe
ret = new AtlasRelationshipDef(name, description, version, relationshipCategory, propagateTags, endDef1, endDef2); ret = new AtlasRelationshipDef(name, description, version, relationshipCategory, propagateTags, endDef1, endDef2);
// add in the attributes // add in the attributes
AtlasStructDefStoreV1.toStructDef(vertex, ret, typeDefStore); AtlasStructDefStoreV2.toStructDef(vertex, ret, typeDefStore);
} }
return ret; return ret;
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.apache.atlas.repository.store.graph.v1; package org.apache.atlas.repository.store.graph.v2;
import org.apache.atlas.AtlasErrorCode; import org.apache.atlas.AtlasErrorCode;
import org.apache.atlas.annotation.GraphTransaction; import org.apache.atlas.annotation.GraphTransaction;
...@@ -37,6 +37,7 @@ import org.apache.atlas.repository.graphdb.AtlasEdge; ...@@ -37,6 +37,7 @@ import org.apache.atlas.repository.graphdb.AtlasEdge;
import org.apache.atlas.repository.graphdb.AtlasEdgeDirection; import org.apache.atlas.repository.graphdb.AtlasEdgeDirection;
import org.apache.atlas.repository.graphdb.AtlasVertex; import org.apache.atlas.repository.graphdb.AtlasVertex;
import org.apache.atlas.repository.store.graph.AtlasRelationshipStore; import org.apache.atlas.repository.store.graph.AtlasRelationshipStore;
import org.apache.atlas.repository.store.graph.v1.DeleteHandlerV1;
import org.apache.atlas.type.AtlasEntityType; import org.apache.atlas.type.AtlasEntityType;
import org.apache.atlas.type.AtlasRelationshipType; import org.apache.atlas.type.AtlasRelationshipType;
import org.apache.atlas.type.AtlasStructType.AtlasAttribute; import org.apache.atlas.type.AtlasStructType.AtlasAttribute;
...@@ -71,13 +72,13 @@ import static org.apache.atlas.repository.graph.GraphHelper.getClassificationNam ...@@ -71,13 +72,13 @@ import static org.apache.atlas.repository.graph.GraphHelper.getClassificationNam
import static org.apache.atlas.repository.graph.GraphHelper.getClassificationVertices; import static org.apache.atlas.repository.graph.GraphHelper.getClassificationVertices;
import static org.apache.atlas.repository.graph.GraphHelper.getOutGoingEdgesByLabel; import static org.apache.atlas.repository.graph.GraphHelper.getOutGoingEdgesByLabel;
import static org.apache.atlas.repository.graph.GraphHelper.getPropagateTags; import static org.apache.atlas.repository.graph.GraphHelper.getPropagateTags;
import static org.apache.atlas.repository.store.graph.v1.AtlasGraphUtilsV1.getIdFromVertex; import static org.apache.atlas.repository.store.graph.v2.AtlasGraphUtilsV2.getIdFromVertex;
import static org.apache.atlas.repository.store.graph.v1.AtlasGraphUtilsV1.getState; import static org.apache.atlas.repository.store.graph.v2.AtlasGraphUtilsV2.getState;
import static org.apache.atlas.repository.store.graph.v1.AtlasGraphUtilsV1.getTypeName; import static org.apache.atlas.repository.store.graph.v2.AtlasGraphUtilsV2.getTypeName;
@Component @Component
public class AtlasRelationshipStoreV1 implements AtlasRelationshipStore { public class AtlasRelationshipStoreV2 implements AtlasRelationshipStore {
private static final Logger LOG = LoggerFactory.getLogger(AtlasRelationshipStoreV1.class); private static final Logger LOG = LoggerFactory.getLogger(AtlasRelationshipStoreV2.class);
private static final Long DEFAULT_RELATIONSHIP_VERSION = 0L; private static final Long DEFAULT_RELATIONSHIP_VERSION = 0L;
...@@ -88,7 +89,7 @@ public class AtlasRelationshipStoreV1 implements AtlasRelationshipStore { ...@@ -88,7 +89,7 @@ public class AtlasRelationshipStoreV1 implements AtlasRelationshipStore {
private final AtlasEntityChangeNotifier entityChangeNotifier; private final AtlasEntityChangeNotifier entityChangeNotifier;
@Inject @Inject
public AtlasRelationshipStoreV1(AtlasTypeRegistry typeRegistry, DeleteHandlerV1 deleteHandler, AtlasEntityChangeNotifier entityChangeNotifier) { public AtlasRelationshipStoreV2(AtlasTypeRegistry typeRegistry, DeleteHandlerV1 deleteHandler, AtlasEntityChangeNotifier entityChangeNotifier) {
this.typeRegistry = typeRegistry; this.typeRegistry = typeRegistry;
this.entityRetriever = new EntityGraphRetriever(typeRegistry); this.entityRetriever = new EntityGraphRetriever(typeRegistry);
this.deleteHandler = deleteHandler; this.deleteHandler = deleteHandler;
...@@ -135,7 +136,7 @@ public class AtlasRelationshipStoreV1 implements AtlasRelationshipStore { ...@@ -135,7 +136,7 @@ public class AtlasRelationshipStoreV1 implements AtlasRelationshipStore {
} }
AtlasEdge edge = graphHelper.getEdgeForGUID(guid); AtlasEdge edge = graphHelper.getEdgeForGUID(guid);
String edgeType = AtlasGraphUtilsV1.getTypeName(edge); String edgeType = AtlasGraphUtilsV2.getTypeName(edge);
AtlasVertex end1Vertex = edge.getOutVertex(); AtlasVertex end1Vertex = edge.getOutVertex();
AtlasVertex end2Vertex = edge.getInVertex(); AtlasVertex end2Vertex = edge.getInVertex();
...@@ -151,11 +152,11 @@ public class AtlasRelationshipStoreV1 implements AtlasRelationshipStore { ...@@ -151,11 +152,11 @@ public class AtlasRelationshipStoreV1 implements AtlasRelationshipStore {
if (updatedEnd1Guid == null) { if (updatedEnd1Guid == null) {
AtlasVertex updatedEnd1Vertex = getVertexFromEndPoint(relationship.getEnd1()); AtlasVertex updatedEnd1Vertex = getVertexFromEndPoint(relationship.getEnd1());
updatedEnd1Guid = updatedEnd1Vertex == null ? null : AtlasGraphUtilsV1.getIdFromVertex(updatedEnd1Vertex); updatedEnd1Guid = updatedEnd1Vertex == null ? null : AtlasGraphUtilsV2.getIdFromVertex(updatedEnd1Vertex);
} }
if (updatedEnd1Guid != null) { if (updatedEnd1Guid != null) {
String end1Guid = AtlasGraphUtilsV1.getIdFromVertex(end1Vertex); String end1Guid = AtlasGraphUtilsV2.getIdFromVertex(end1Vertex);
if (!StringUtils.equalsIgnoreCase(relationship.getEnd1().getGuid(), end1Guid)) { if (!StringUtils.equalsIgnoreCase(relationship.getEnd1().getGuid(), end1Guid)) {
throw new AtlasBaseException(AtlasErrorCode.RELATIONSHIP_UPDATE_END_CHANGE_NOT_ALLOWED, edgeType, guid, end1Guid, relationship.getEnd1().getGuid()); throw new AtlasBaseException(AtlasErrorCode.RELATIONSHIP_UPDATE_END_CHANGE_NOT_ALLOWED, edgeType, guid, end1Guid, relationship.getEnd1().getGuid());
...@@ -170,14 +171,14 @@ public class AtlasRelationshipStoreV1 implements AtlasRelationshipStore { ...@@ -170,14 +171,14 @@ public class AtlasRelationshipStoreV1 implements AtlasRelationshipStore {
if (updatedEnd2Guid == null) { if (updatedEnd2Guid == null) {
AtlasVertex updatedEnd2Vertex = getVertexFromEndPoint(relationship.getEnd2()); AtlasVertex updatedEnd2Vertex = getVertexFromEndPoint(relationship.getEnd2());
updatedEnd2Guid = updatedEnd2Vertex == null ? null : AtlasGraphUtilsV1.getIdFromVertex(updatedEnd2Vertex); updatedEnd2Guid = updatedEnd2Vertex == null ? null : AtlasGraphUtilsV2.getIdFromVertex(updatedEnd2Vertex);
} }
if (updatedEnd2Guid != null) { if (updatedEnd2Guid != null) {
String end2Guid = AtlasGraphUtilsV1.getIdFromVertex(end2Vertex); String end2Guid = AtlasGraphUtilsV2.getIdFromVertex(end2Vertex);
if (!StringUtils.equalsIgnoreCase(relationship.getEnd2().getGuid(), end2Guid)) { if (!StringUtils.equalsIgnoreCase(relationship.getEnd2().getGuid(), end2Guid)) {
throw new AtlasBaseException(AtlasErrorCode.RELATIONSHIP_UPDATE_END_CHANGE_NOT_ALLOWED, AtlasGraphUtilsV1.getTypeName(edge), guid, end2Guid, relationship.getEnd2().getGuid()); throw new AtlasBaseException(AtlasErrorCode.RELATIONSHIP_UPDATE_END_CHANGE_NOT_ALLOWED, AtlasGraphUtilsV2.getTypeName(edge), guid, end2Guid, relationship.getEnd2().getGuid());
} }
} }
} }
...@@ -330,12 +331,12 @@ public class AtlasRelationshipStoreV1 implements AtlasRelationshipStore { ...@@ -330,12 +331,12 @@ public class AtlasRelationshipStoreV1 implements AtlasRelationshipStore {
String attrVertexProperty = attr.getVertexPropertyName(); String attrVertexProperty = attr.getVertexPropertyName();
Object attrValue = relationship.getAttribute(attrName); Object attrValue = relationship.getAttribute(attrName);
AtlasGraphUtilsV1.setProperty(ret, attrVertexProperty, attrValue); AtlasGraphUtilsV2.setProperty(ret, attrVertexProperty, attrValue);
} }
} }
} else { } else {
throw new AtlasBaseException(AtlasErrorCode.RELATIONSHIP_ALREADY_EXISTS, relationship.getTypeName(), throw new AtlasBaseException(AtlasErrorCode.RELATIONSHIP_ALREADY_EXISTS, relationship.getTypeName(),
AtlasGraphUtilsV1.getIdFromVertex(end1Vertex), AtlasGraphUtilsV1.getIdFromVertex(end2Vertex)); AtlasGraphUtilsV2.getIdFromVertex(end1Vertex), AtlasGraphUtilsV2.getIdFromVertex(end2Vertex));
} }
} catch (RepositoryException e) { } catch (RepositoryException e) {
throw new AtlasBaseException(AtlasErrorCode.INTERNAL_ERROR, e); throw new AtlasBaseException(AtlasErrorCode.INTERNAL_ERROR, e);
...@@ -355,7 +356,7 @@ public class AtlasRelationshipStoreV1 implements AtlasRelationshipStore { ...@@ -355,7 +356,7 @@ public class AtlasRelationshipStoreV1 implements AtlasRelationshipStore {
String attrVertexProperty = attr.getVertexPropertyName(); String attrVertexProperty = attr.getVertexPropertyName();
if (relationship.hasAttribute(attrName)) { if (relationship.hasAttribute(attrName)) {
AtlasGraphUtilsV1.setProperty(relationshipEdge, attrVertexProperty, relationship.getAttribute(attrName)); AtlasGraphUtilsV2.setProperty(relationshipEdge, attrVertexProperty, relationship.getAttribute(attrName));
} }
} }
} }
...@@ -460,7 +461,7 @@ public class AtlasRelationshipStoreV1 implements AtlasRelationshipStore { ...@@ -460,7 +461,7 @@ public class AtlasRelationshipStoreV1 implements AtlasRelationshipStore {
Map<AtlasVertex, List<AtlasVertex>> currentClassificationsMap = graphHelper.getClassificationPropagatedEntitiesMapping(currentClassificationVertices); Map<AtlasVertex, List<AtlasVertex>> currentClassificationsMap = graphHelper.getClassificationPropagatedEntitiesMapping(currentClassificationVertices);
// Update propagation edge // Update propagation edge
AtlasGraphUtilsV1.setProperty(edge, Constants.RELATIONSHIPTYPE_TAG_PROPAGATION_KEY, newTagPropagation.name()); AtlasGraphUtilsV2.setProperty(edge, Constants.RELATIONSHIPTYPE_TAG_PROPAGATION_KEY, newTagPropagation.name());
List<AtlasVertex> updatedClassificationVertices = getClassificationVertices(edge); List<AtlasVertex> updatedClassificationVertices = getClassificationVertices(edge);
List<AtlasVertex> classificationVerticesUnion = (List<AtlasVertex>) CollectionUtils.union(currentClassificationVertices, updatedClassificationVertices); List<AtlasVertex> classificationVerticesUnion = (List<AtlasVertex>) CollectionUtils.union(currentClassificationVertices, updatedClassificationVertices);
...@@ -557,8 +558,8 @@ public class AtlasRelationshipStoreV1 implements AtlasRelationshipStore { ...@@ -557,8 +558,8 @@ public class AtlasRelationshipStoreV1 implements AtlasRelationshipStore {
throw new AtlasBaseException(AtlasErrorCode.RELATIONSHIP_END_IS_NULL, relationshipType.getEnd2Type().getTypeName()); throw new AtlasBaseException(AtlasErrorCode.RELATIONSHIP_END_IS_NULL, relationshipType.getEnd2Type().getTypeName());
} }
String end1TypeName = AtlasGraphUtilsV1.getTypeName(end1Vertex); String end1TypeName = AtlasGraphUtilsV2.getTypeName(end1Vertex);
String end2TypeName = AtlasGraphUtilsV1.getTypeName(end2Vertex); String end2TypeName = AtlasGraphUtilsV2.getTypeName(end2Vertex);
boolean validEndTypes = false; boolean validEndTypes = false;
...@@ -609,7 +610,7 @@ public class AtlasRelationshipStoreV1 implements AtlasRelationshipStore { ...@@ -609,7 +610,7 @@ public class AtlasRelationshipStoreV1 implements AtlasRelationshipStore {
String guid = end.getGuid(); String guid = end.getGuid();
String typeName = end.getTypeName(); String typeName = end.getTypeName();
Map<String, Object> uniqueAttributes = end.getUniqueAttributes(); Map<String, Object> uniqueAttributes = end.getUniqueAttributes();
AtlasVertex endVertex = AtlasGraphUtilsV1.findByGuid(guid); AtlasVertex endVertex = AtlasGraphUtilsV2.findByGuid(guid);
if (!AtlasTypeUtil.isValidGuid(guid) || endVertex == null) { if (!AtlasTypeUtil.isValidGuid(guid) || endVertex == null) {
throw new AtlasBaseException(AtlasErrorCode.INSTANCE_GUID_NOT_FOUND, guid); throw new AtlasBaseException(AtlasErrorCode.INSTANCE_GUID_NOT_FOUND, guid);
...@@ -617,7 +618,7 @@ public class AtlasRelationshipStoreV1 implements AtlasRelationshipStore { ...@@ -617,7 +618,7 @@ public class AtlasRelationshipStoreV1 implements AtlasRelationshipStore {
} else if (MapUtils.isNotEmpty(uniqueAttributes)) { } else if (MapUtils.isNotEmpty(uniqueAttributes)) {
AtlasEntityType entityType = typeRegistry.getEntityTypeByName(typeName); AtlasEntityType entityType = typeRegistry.getEntityTypeByName(typeName);
if (AtlasGraphUtilsV1.findByUniqueAttributes(entityType, uniqueAttributes) == null) { if (AtlasGraphUtilsV2.findByUniqueAttributes(entityType, uniqueAttributes) == null) {
throw new AtlasBaseException(AtlasErrorCode.INSTANCE_BY_UNIQUE_ATTRIBUTE_NOT_FOUND, typeName, uniqueAttributes.toString()); throw new AtlasBaseException(AtlasErrorCode.INSTANCE_BY_UNIQUE_ATTRIBUTE_NOT_FOUND, typeName, uniqueAttributes.toString());
} }
} else { } else {
...@@ -691,11 +692,11 @@ public class AtlasRelationshipStoreV1 implements AtlasRelationshipStore { ...@@ -691,11 +692,11 @@ public class AtlasRelationshipStoreV1 implements AtlasRelationshipStore {
AtlasVertex ret = null; AtlasVertex ret = null;
if (StringUtils.isNotEmpty(endPoint.getGuid())) { if (StringUtils.isNotEmpty(endPoint.getGuid())) {
ret = AtlasGraphUtilsV1.findByGuid(endPoint.getGuid()); ret = AtlasGraphUtilsV2.findByGuid(endPoint.getGuid());
} else if (StringUtils.isNotEmpty(endPoint.getTypeName()) && MapUtils.isNotEmpty(endPoint.getUniqueAttributes())) { } else if (StringUtils.isNotEmpty(endPoint.getTypeName()) && MapUtils.isNotEmpty(endPoint.getUniqueAttributes())) {
AtlasEntityType entityType = typeRegistry.getEntityTypeByName(endPoint.getTypeName()); AtlasEntityType entityType = typeRegistry.getEntityTypeByName(endPoint.getTypeName());
ret = AtlasGraphUtilsV1.findByUniqueAttributes(entityType, endPoint.getUniqueAttributes()); ret = AtlasGraphUtilsV2.findByUniqueAttributes(entityType, endPoint.getUniqueAttributes());
} }
return ret; return ret;
...@@ -714,10 +715,10 @@ public class AtlasRelationshipStoreV1 implements AtlasRelationshipStore { ...@@ -714,10 +715,10 @@ public class AtlasRelationshipStoreV1 implements AtlasRelationshipStore {
if (ret != null) { if (ret != null) {
final String guid = UUID.randomUUID().toString(); final String guid = UUID.randomUUID().toString();
AtlasGraphUtilsV1.setProperty(ret, Constants.ENTITY_TYPE_PROPERTY_KEY, relationship.getTypeName()); AtlasGraphUtilsV2.setProperty(ret, Constants.ENTITY_TYPE_PROPERTY_KEY, relationship.getTypeName());
AtlasGraphUtilsV1.setProperty(ret, Constants.RELATIONSHIP_GUID_PROPERTY_KEY, guid); AtlasGraphUtilsV2.setProperty(ret, Constants.RELATIONSHIP_GUID_PROPERTY_KEY, guid);
AtlasGraphUtilsV1.setProperty(ret, Constants.VERSION_PROPERTY_KEY, getRelationshipVersion(relationship)); AtlasGraphUtilsV2.setProperty(ret, Constants.VERSION_PROPERTY_KEY, getRelationshipVersion(relationship));
AtlasGraphUtilsV1.setProperty(ret, Constants.RELATIONSHIPTYPE_TAG_PROPAGATION_KEY, tagPropagation.name()); AtlasGraphUtilsV2.setProperty(ret, Constants.RELATIONSHIPTYPE_TAG_PROPAGATION_KEY, tagPropagation.name());
// blocked propagated classifications // blocked propagated classifications
handleBlockedClassifications(ret, relationship.getBlockedPropagatedClassifications()); handleBlockedClassifications(ret, relationship.getBlockedPropagatedClassifications());
...@@ -760,8 +761,8 @@ public class AtlasRelationshipStoreV1 implements AtlasRelationshipStore { ...@@ -760,8 +761,8 @@ public class AtlasRelationshipStoreV1 implements AtlasRelationshipStore {
String ret = relationshipType.getRelationshipDef().getRelationshipLabel(); String ret = relationshipType.getRelationshipDef().getRelationshipLabel();
AtlasRelationshipEndDef endDef1 = relationshipType.getRelationshipDef().getEndDef1(); AtlasRelationshipEndDef endDef1 = relationshipType.getRelationshipDef().getEndDef1();
AtlasRelationshipEndDef endDef2 = relationshipType.getRelationshipDef().getEndDef2(); AtlasRelationshipEndDef endDef2 = relationshipType.getRelationshipDef().getEndDef2();
Set<String> fromVertexTypes = getTypeAndAllSuperTypes(AtlasGraphUtilsV1.getTypeName(fromVertex)); Set<String> fromVertexTypes = getTypeAndAllSuperTypes(AtlasGraphUtilsV2.getTypeName(fromVertex));
Set<String> toVertexTypes = getTypeAndAllSuperTypes(AtlasGraphUtilsV1.getTypeName(toVertex)); Set<String> toVertexTypes = getTypeAndAllSuperTypes(AtlasGraphUtilsV2.getTypeName(toVertex));
AtlasAttribute attribute = null; AtlasAttribute attribute = null;
// validate entity type and all its supertypes contains relationshipDefs end type // validate entity type and all its supertypes contains relationshipDefs end type
...@@ -794,7 +795,7 @@ public class AtlasRelationshipStoreV1 implements AtlasRelationshipStore { ...@@ -794,7 +795,7 @@ public class AtlasRelationshipStoreV1 implements AtlasRelationshipStore {
String typeName = objectId.getTypeName(); String typeName = objectId.getTypeName();
if (StringUtils.isBlank(typeName)) { if (StringUtils.isBlank(typeName)) {
typeName = AtlasGraphUtilsV1.getTypeNameFromGuid(objectId.getGuid()); typeName = AtlasGraphUtilsV2.getTypeNameFromGuid(objectId.getGuid());
} }
return typeName; return typeName;
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.apache.atlas.repository.store.graph.v1; package org.apache.atlas.repository.store.graph.v2;
import com.google.common.annotations.VisibleForTesting; import com.google.common.annotations.VisibleForTesting;
import org.apache.atlas.AtlasErrorCode; import org.apache.atlas.AtlasErrorCode;
...@@ -52,10 +52,10 @@ import java.util.Set; ...@@ -52,10 +52,10 @@ import java.util.Set;
/** /**
* StructDef store in v1 format. * StructDef store in v1 format.
*/ */
public class AtlasStructDefStoreV1 extends AtlasAbstractDefStoreV1<AtlasStructDef> { public class AtlasStructDefStoreV2 extends AtlasAbstractDefStoreV2<AtlasStructDef> {
private static final Logger LOG = LoggerFactory.getLogger(AtlasStructDefStoreV1.class); private static final Logger LOG = LoggerFactory.getLogger(AtlasStructDefStoreV2.class);
public AtlasStructDefStoreV1(AtlasTypeDefGraphStoreV1 typeDefStore, AtlasTypeRegistry typeRegistry) { public AtlasStructDefStoreV2(AtlasTypeDefGraphStoreV2 typeDefStore, AtlasTypeRegistry typeRegistry) {
super(typeDefStore, typeRegistry); super(typeDefStore, typeRegistry);
} }
...@@ -81,7 +81,7 @@ public class AtlasStructDefStoreV1 extends AtlasAbstractDefStoreV1<AtlasStructDe ...@@ -81,7 +81,7 @@ public class AtlasStructDefStoreV1 extends AtlasAbstractDefStoreV1<AtlasStructDe
ret = typeDefStore.createTypeVertex(structDef); ret = typeDefStore.createTypeVertex(structDef);
AtlasStructDefStoreV1.updateVertexPreCreate(structDef, (AtlasStructType)type, ret, typeDefStore); AtlasStructDefStoreV2.updateVertexPreCreate(structDef, (AtlasStructType)type, ret, typeDefStore);
if (LOG.isDebugEnabled()) { if (LOG.isDebugEnabled()) {
LOG.debug("<== AtlasStructDefStoreV1.preCreate({}): {}", structDef, ret); LOG.debug("<== AtlasStructDefStoreV1.preCreate({}): {}", structDef, ret);
...@@ -104,7 +104,7 @@ public class AtlasStructDefStoreV1 extends AtlasAbstractDefStoreV1<AtlasStructDe ...@@ -104,7 +104,7 @@ public class AtlasStructDefStoreV1 extends AtlasAbstractDefStoreV1<AtlasStructDe
AtlasVertex vertex = (preCreateResult == null) ? preCreate(structDef) : preCreateResult; AtlasVertex vertex = (preCreateResult == null) ? preCreate(structDef) : preCreateResult;
AtlasStructDefStoreV1.updateVertexAddReferences(structDef, vertex, typeDefStore); AtlasStructDefStoreV2.updateVertexAddReferences(structDef, vertex, typeDefStore);
AtlasStructDef ret = toStructDef(vertex); AtlasStructDef ret = toStructDef(vertex);
...@@ -220,8 +220,8 @@ public class AtlasStructDefStoreV1 extends AtlasAbstractDefStoreV1<AtlasStructDe ...@@ -220,8 +220,8 @@ public class AtlasStructDefStoreV1 extends AtlasAbstractDefStoreV1<AtlasStructDe
throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_NOT_FOUND, name); throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_NOT_FOUND, name);
} }
AtlasStructDefStoreV1.updateVertexPreUpdate(structDef, (AtlasStructType)type, vertex, typeDefStore); AtlasStructDefStoreV2.updateVertexPreUpdate(structDef, (AtlasStructType)type, vertex, typeDefStore);
AtlasStructDefStoreV1.updateVertexAddReferences(structDef, vertex, typeDefStore); AtlasStructDefStoreV2.updateVertexAddReferences(structDef, vertex, typeDefStore);
AtlasStructDef ret = toStructDef(vertex); AtlasStructDef ret = toStructDef(vertex);
...@@ -256,8 +256,8 @@ public class AtlasStructDefStoreV1 extends AtlasAbstractDefStoreV1<AtlasStructDe ...@@ -256,8 +256,8 @@ public class AtlasStructDefStoreV1 extends AtlasAbstractDefStoreV1<AtlasStructDe
throw new AtlasBaseException(AtlasErrorCode.TYPE_GUID_NOT_FOUND, guid); throw new AtlasBaseException(AtlasErrorCode.TYPE_GUID_NOT_FOUND, guid);
} }
AtlasStructDefStoreV1.updateVertexPreUpdate(structDef, (AtlasStructType)type, vertex, typeDefStore); AtlasStructDefStoreV2.updateVertexPreUpdate(structDef, (AtlasStructType)type, vertex, typeDefStore);
AtlasStructDefStoreV1.updateVertexAddReferences(structDef, vertex, typeDefStore); AtlasStructDefStoreV2.updateVertexAddReferences(structDef, vertex, typeDefStore);
AtlasStructDef ret = toStructDef(vertex); AtlasStructDef ret = toStructDef(vertex);
...@@ -280,7 +280,7 @@ public class AtlasStructDefStoreV1 extends AtlasAbstractDefStoreV1<AtlasStructDe ...@@ -280,7 +280,7 @@ public class AtlasStructDefStoreV1 extends AtlasAbstractDefStoreV1<AtlasStructDe
AtlasVertex ret = typeDefStore.findTypeVertexByNameAndCategory(name, TypeCategory.STRUCT); AtlasVertex ret = typeDefStore.findTypeVertexByNameAndCategory(name, TypeCategory.STRUCT);
if (AtlasGraphUtilsV1.typeHasInstanceVertex(name)) { if (AtlasGraphUtilsV2.typeHasInstanceVertex(name)) {
throw new AtlasBaseException(AtlasErrorCode.TYPE_HAS_REFERENCES, name); throw new AtlasBaseException(AtlasErrorCode.TYPE_HAS_REFERENCES, name);
} }
...@@ -309,9 +309,9 @@ public class AtlasStructDefStoreV1 extends AtlasAbstractDefStoreV1<AtlasStructDe ...@@ -309,9 +309,9 @@ public class AtlasStructDefStoreV1 extends AtlasAbstractDefStoreV1<AtlasStructDe
AtlasVertex ret = typeDefStore.findTypeVertexByGuidAndCategory(guid, TypeCategory.STRUCT); AtlasVertex ret = typeDefStore.findTypeVertexByGuidAndCategory(guid, TypeCategory.STRUCT);
String typeName = AtlasGraphUtilsV1.getProperty(ret, Constants.TYPENAME_PROPERTY_KEY, String.class); String typeName = AtlasGraphUtilsV2.getProperty(ret, Constants.TYPENAME_PROPERTY_KEY, String.class);
if (AtlasGraphUtilsV1.typeHasInstanceVertex(typeName)) { if (AtlasGraphUtilsV2.typeHasInstanceVertex(typeName)) {
throw new AtlasBaseException(AtlasErrorCode.TYPE_HAS_REFERENCES, typeName); throw new AtlasBaseException(AtlasErrorCode.TYPE_HAS_REFERENCES, typeName);
} }
...@@ -339,7 +339,7 @@ public class AtlasStructDefStoreV1 extends AtlasAbstractDefStoreV1<AtlasStructDe ...@@ -339,7 +339,7 @@ public class AtlasStructDefStoreV1 extends AtlasAbstractDefStoreV1<AtlasStructDe
} }
public static void updateVertexPreCreate(AtlasStructDef structDef, AtlasStructType structType, public static void updateVertexPreCreate(AtlasStructDef structDef, AtlasStructType structType,
AtlasVertex vertex, AtlasTypeDefGraphStoreV1 typeDefStore) throws AtlasBaseException { AtlasVertex vertex, AtlasTypeDefGraphStoreV2 typeDefStore) throws AtlasBaseException {
List<String> attrNames = new ArrayList<>(structDef.getAttributeDefs().size()); List<String> attrNames = new ArrayList<>(structDef.getAttributeDefs().size());
for (AtlasAttributeDef attributeDef : structDef.getAttributeDefs()) { for (AtlasAttributeDef attributeDef : structDef.getAttributeDefs()) {
...@@ -351,17 +351,17 @@ public class AtlasStructDefStoreV1 extends AtlasAbstractDefStoreV1<AtlasStructDe ...@@ -351,17 +351,17 @@ public class AtlasStructDefStoreV1 extends AtlasAbstractDefStoreV1<AtlasStructDe
throw new AtlasBaseException(AtlasErrorCode.MISSING_MANDATORY_ATTRIBUTE, structDef.getName(), "typeName"); throw new AtlasBaseException(AtlasErrorCode.MISSING_MANDATORY_ATTRIBUTE, structDef.getName(), "typeName");
} }
String propertyKey = AtlasGraphUtilsV1.getTypeDefPropertyKey(structDef, attributeDef.getName()); String propertyKey = AtlasGraphUtilsV2.getTypeDefPropertyKey(structDef, attributeDef.getName());
AtlasGraphUtilsV1.setProperty(vertex, propertyKey, toJsonFromAttribute(structType.getAttribute(attributeDef.getName()))); AtlasGraphUtilsV2.setProperty(vertex, propertyKey, toJsonFromAttribute(structType.getAttribute(attributeDef.getName())));
attrNames.add(attributeDef.getName()); attrNames.add(attributeDef.getName());
} }
AtlasGraphUtilsV1.setProperty(vertex, AtlasGraphUtilsV1.getTypeDefPropertyKey(structDef), attrNames); AtlasGraphUtilsV2.setProperty(vertex, AtlasGraphUtilsV2.getTypeDefPropertyKey(structDef), attrNames);
} }
public static void updateVertexPreUpdate(AtlasStructDef structDef, AtlasStructType structType, public static void updateVertexPreUpdate(AtlasStructDef structDef, AtlasStructType structType,
AtlasVertex vertex, AtlasTypeDefGraphStoreV1 typeDefStore) AtlasVertex vertex, AtlasTypeDefGraphStoreV2 typeDefStore)
throws AtlasBaseException { throws AtlasBaseException {
List<String> attrNames = new ArrayList<>(); List<String> attrNames = new ArrayList<>();
...@@ -371,7 +371,7 @@ public class AtlasStructDefStoreV1 extends AtlasAbstractDefStoreV1<AtlasStructDe ...@@ -371,7 +371,7 @@ public class AtlasStructDefStoreV1 extends AtlasAbstractDefStoreV1<AtlasStructDe
} }
} }
List<String> currAttrNames = vertex.getProperty(AtlasGraphUtilsV1.getTypeDefPropertyKey(structDef), List.class); List<String> currAttrNames = vertex.getProperty(AtlasGraphUtilsV2.getTypeDefPropertyKey(structDef), List.class);
// delete attributes that are not present in updated structDef // delete attributes that are not present in updated structDef
if (CollectionUtils.isNotEmpty(currAttrNames)) { if (CollectionUtils.isNotEmpty(currAttrNames)) {
...@@ -411,34 +411,34 @@ public class AtlasStructDefStoreV1 extends AtlasAbstractDefStoreV1<AtlasStructDe ...@@ -411,34 +411,34 @@ public class AtlasStructDefStoreV1 extends AtlasAbstractDefStoreV1<AtlasStructDe
throw new AtlasBaseException(AtlasErrorCode.BAD_REQUEST, "Data type update for attribute is not supported"); throw new AtlasBaseException(AtlasErrorCode.BAD_REQUEST, "Data type update for attribute is not supported");
} }
String propertyKey = AtlasGraphUtilsV1.getTypeDefPropertyKey(structDef, attributeDef.getName()); String propertyKey = AtlasGraphUtilsV2.getTypeDefPropertyKey(structDef, attributeDef.getName());
AtlasGraphUtilsV1.setProperty(vertex, propertyKey, toJsonFromAttribute(structType.getAttribute(attributeDef.getName()))); AtlasGraphUtilsV2.setProperty(vertex, propertyKey, toJsonFromAttribute(structType.getAttribute(attributeDef.getName())));
} }
} }
AtlasGraphUtilsV1.setProperty(vertex, AtlasGraphUtilsV1.getTypeDefPropertyKey(structDef), attrNames); AtlasGraphUtilsV2.setProperty(vertex, AtlasGraphUtilsV2.getTypeDefPropertyKey(structDef), attrNames);
} }
public static void updateVertexAddReferences(AtlasStructDef structDef, AtlasVertex vertex, public static void updateVertexAddReferences(AtlasStructDef structDef, AtlasVertex vertex,
AtlasTypeDefGraphStoreV1 typeDefStore) throws AtlasBaseException { AtlasTypeDefGraphStoreV2 typeDefStore) throws AtlasBaseException {
for (AtlasAttributeDef attributeDef : structDef.getAttributeDefs()) { for (AtlasAttributeDef attributeDef : structDef.getAttributeDefs()) {
addReferencesForAttribute(vertex, attributeDef, typeDefStore); addReferencesForAttribute(vertex, attributeDef, typeDefStore);
} }
} }
public static AtlasStructDef toStructDef(AtlasVertex vertex, AtlasStructDef structDef, public static AtlasStructDef toStructDef(AtlasVertex vertex, AtlasStructDef structDef,
AtlasTypeDefGraphStoreV1 typeDefStore) throws AtlasBaseException { AtlasTypeDefGraphStoreV2 typeDefStore) throws AtlasBaseException {
AtlasStructDef ret = (structDef != null) ? structDef :new AtlasStructDef(); AtlasStructDef ret = (structDef != null) ? structDef :new AtlasStructDef();
typeDefStore.vertexToTypeDef(vertex, ret); typeDefStore.vertexToTypeDef(vertex, ret);
List<AtlasAttributeDef> attributeDefs = new ArrayList<>(); List<AtlasAttributeDef> attributeDefs = new ArrayList<>();
List<String> attrNames = vertex.getProperty(AtlasGraphUtilsV1.getTypeDefPropertyKey(ret), List.class); List<String> attrNames = vertex.getProperty(AtlasGraphUtilsV2.getTypeDefPropertyKey(ret), List.class);
if (CollectionUtils.isNotEmpty(attrNames)) { if (CollectionUtils.isNotEmpty(attrNames)) {
for (String attrName : attrNames) { for (String attrName : attrNames) {
String propertyKey = AtlasGraphUtilsV1.getTypeDefPropertyKey(ret, attrName); String propertyKey = AtlasGraphUtilsV2.getTypeDefPropertyKey(ret, attrName);
String attribJson = vertex.getProperty(GraphHelper.encodePropertyKey(propertyKey), String.class); String attribJson = vertex.getProperty(GraphHelper.encodePropertyKey(propertyKey), String.class);
attributeDefs.add(toAttributeDefFromJson(structDef, AtlasType.fromJson(attribJson, Map.class), attributeDefs.add(toAttributeDefFromJson(structDef, AtlasType.fromJson(attribJson, Map.class),
...@@ -451,7 +451,7 @@ public class AtlasStructDefStoreV1 extends AtlasAbstractDefStoreV1<AtlasStructDe ...@@ -451,7 +451,7 @@ public class AtlasStructDefStoreV1 extends AtlasAbstractDefStoreV1<AtlasStructDe
} }
private static void addReferencesForAttribute(AtlasVertex vertex, AtlasAttributeDef attributeDef, private static void addReferencesForAttribute(AtlasVertex vertex, AtlasAttributeDef attributeDef,
AtlasTypeDefGraphStoreV1 typeDefStore) throws AtlasBaseException { AtlasTypeDefGraphStoreV2 typeDefStore) throws AtlasBaseException {
Set<String> referencedTypeNames = AtlasTypeUtil.getReferencedTypeNames(attributeDef.getTypeName()); Set<String> referencedTypeNames = AtlasTypeUtil.getReferencedTypeNames(attributeDef.getTypeName());
String typeName = vertex.getProperty(Constants.TYPENAME_PROPERTY_KEY, String.class); String typeName = vertex.getProperty(Constants.TYPENAME_PROPERTY_KEY, String.class);
...@@ -464,7 +464,7 @@ public class AtlasStructDefStoreV1 extends AtlasAbstractDefStoreV1<AtlasStructDe ...@@ -464,7 +464,7 @@ public class AtlasStructDefStoreV1 extends AtlasAbstractDefStoreV1<AtlasStructDe
throw new AtlasBaseException(AtlasErrorCode.UNKNOWN_TYPE, referencedTypeName, typeName, attributeDef.getName()); throw new AtlasBaseException(AtlasErrorCode.UNKNOWN_TYPE, referencedTypeName, typeName, attributeDef.getName());
} }
String label = AtlasGraphUtilsV1.getEdgeLabel(typeName, attributeDef.getName()); String label = AtlasGraphUtilsV2.getEdgeLabel(typeName, attributeDef.getName());
typeDefStore.getOrCreateEdge(vertex, referencedTypeVertex, label); typeDefStore.getOrCreateEdge(vertex, referencedTypeVertex, label);
} }
...@@ -515,7 +515,7 @@ public class AtlasStructDefStoreV1 extends AtlasAbstractDefStoreV1<AtlasStructDe ...@@ -515,7 +515,7 @@ public class AtlasStructDefStoreV1 extends AtlasAbstractDefStoreV1<AtlasStructDe
@VisibleForTesting @VisibleForTesting
public static AtlasAttributeDef toAttributeDefFromJson(AtlasStructDef structDef, public static AtlasAttributeDef toAttributeDefFromJson(AtlasStructDef structDef,
Map attribInfo, Map attribInfo,
AtlasTypeDefGraphStoreV1 typeDefStore) AtlasTypeDefGraphStoreV2 typeDefStore)
throws AtlasBaseException { throws AtlasBaseException {
AtlasAttributeDef ret = new AtlasAttributeDef(); AtlasAttributeDef ret = new AtlasAttributeDef();
......
...@@ -15,14 +15,14 @@ ...@@ -15,14 +15,14 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.apache.atlas.repository.store.graph.v1; package org.apache.atlas.repository.store.graph.v2;
import com.google.common.annotations.VisibleForTesting; import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Preconditions; import com.google.common.base.Preconditions;
import static org.apache.atlas.repository.Constants.TYPE_CATEGORY_PROPERTY_KEY; import static org.apache.atlas.repository.Constants.TYPE_CATEGORY_PROPERTY_KEY;
import static org.apache.atlas.repository.Constants.VERTEX_TYPE_PROPERTY_KEY; import static org.apache.atlas.repository.Constants.VERTEX_TYPE_PROPERTY_KEY;
import static org.apache.atlas.repository.store.graph.v1.AtlasGraphUtilsV1.VERTEX_TYPE; import static org.apache.atlas.repository.store.graph.v2.AtlasGraphUtilsV2.VERTEX_TYPE;
import java.util.Date; import java.util.Date;
import java.util.HashSet; import java.util.HashSet;
...@@ -31,7 +31,7 @@ import java.util.Map; ...@@ -31,7 +31,7 @@ import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
import org.apache.atlas.AtlasErrorCode; import org.apache.atlas.AtlasErrorCode;
import org.apache.atlas.RequestContextV1; import org.apache.atlas.RequestContext;
import org.apache.atlas.annotation.GraphTransaction; import org.apache.atlas.annotation.GraphTransaction;
import org.apache.atlas.exception.AtlasBaseException; import org.apache.atlas.exception.AtlasBaseException;
import org.apache.atlas.listener.TypeDefChangeListener; import org.apache.atlas.listener.TypeDefChangeListener;
...@@ -57,13 +57,13 @@ import javax.inject.Singleton; ...@@ -57,13 +57,13 @@ import javax.inject.Singleton;
*/ */
@Singleton @Singleton
@Component @Component
public class AtlasTypeDefGraphStoreV1 extends AtlasTypeDefGraphStore { public class AtlasTypeDefGraphStoreV2 extends AtlasTypeDefGraphStore {
private static final Logger LOG = LoggerFactory.getLogger(AtlasTypeDefGraphStoreV1.class); private static final Logger LOG = LoggerFactory.getLogger(AtlasTypeDefGraphStoreV2.class);
protected final AtlasGraph atlasGraph; protected final AtlasGraph atlasGraph;
@Inject @Inject
public AtlasTypeDefGraphStoreV1(AtlasTypeRegistry typeRegistry, public AtlasTypeDefGraphStoreV2(AtlasTypeRegistry typeRegistry,
Set<TypeDefChangeListener> typeDefChangeListeners, Set<TypeDefChangeListener> typeDefChangeListeners,
AtlasGraph atlasGraph) { AtlasGraph atlasGraph) {
super(typeRegistry, typeDefChangeListeners); super(typeRegistry, typeDefChangeListeners);
...@@ -74,27 +74,27 @@ public class AtlasTypeDefGraphStoreV1 extends AtlasTypeDefGraphStore { ...@@ -74,27 +74,27 @@ public class AtlasTypeDefGraphStoreV1 extends AtlasTypeDefGraphStore {
@Override @Override
protected AtlasDefStore<AtlasEnumDef> getEnumDefStore(AtlasTypeRegistry typeRegistry) { protected AtlasDefStore<AtlasEnumDef> getEnumDefStore(AtlasTypeRegistry typeRegistry) {
return new AtlasEnumDefStoreV1(this, typeRegistry); return new AtlasEnumDefStoreV2(this, typeRegistry);
} }
@Override @Override
protected AtlasDefStore<AtlasStructDef> getStructDefStore(AtlasTypeRegistry typeRegistry) { protected AtlasDefStore<AtlasStructDef> getStructDefStore(AtlasTypeRegistry typeRegistry) {
return new AtlasStructDefStoreV1(this, typeRegistry); return new AtlasStructDefStoreV2(this, typeRegistry);
} }
@Override @Override
protected AtlasDefStore<AtlasClassificationDef> getClassificationDefStore(AtlasTypeRegistry typeRegistry) { protected AtlasDefStore<AtlasClassificationDef> getClassificationDefStore(AtlasTypeRegistry typeRegistry) {
return new AtlasClassificationDefStoreV1(this, typeRegistry); return new AtlasClassificationDefStoreV2(this, typeRegistry);
} }
@Override @Override
protected AtlasDefStore<AtlasEntityDef> getEntityDefStore(AtlasTypeRegistry typeRegistry) { protected AtlasDefStore<AtlasEntityDef> getEntityDefStore(AtlasTypeRegistry typeRegistry) {
return new AtlasEntityDefStoreV1(this, typeRegistry); return new AtlasEntityDefStoreV2(this, typeRegistry);
} }
@Override @Override
protected AtlasDefStore<AtlasRelationshipDef> getRelationshipDefStore(AtlasTypeRegistry typeRegistry) { protected AtlasDefStore<AtlasRelationshipDef> getRelationshipDefStore(AtlasTypeRegistry typeRegistry) {
return new AtlasRelationshipDefStoreV1(this, typeRegistry); return new AtlasRelationshipDefStoreV2(this, typeRegistry);
} }
...@@ -399,7 +399,7 @@ public class AtlasTypeDefGraphStoreV1 extends AtlasTypeDefGraphStore { ...@@ -399,7 +399,7 @@ public class AtlasTypeDefGraphStoreV1 extends AtlasTypeDefGraphStore {
for (String superType : superTypes) { for (String superType : superTypes) {
AtlasVertex superTypeVertex = findTypeVertexByNameAndCategory(superType, typeCategory); AtlasVertex superTypeVertex = findTypeVertexByNameAndCategory(superType, typeCategory);
getOrCreateEdge(vertex, superTypeVertex, AtlasGraphUtilsV1.SUPERTYPE_EDGE_LABEL); getOrCreateEdge(vertex, superTypeVertex, AtlasGraphUtilsV2.SUPERTYPE_EDGE_LABEL);
} }
} else if (CollectionUtils.isNotEmpty(currentSuperTypes)) { } else if (CollectionUtils.isNotEmpty(currentSuperTypes)) {
throw new AtlasBaseException(AtlasErrorCode.SUPERTYPE_REMOVAL_NOT_SUPPORTED); throw new AtlasBaseException(AtlasErrorCode.SUPERTYPE_REMOVAL_NOT_SUPPORTED);
...@@ -421,7 +421,7 @@ public class AtlasTypeDefGraphStoreV1 extends AtlasTypeDefGraphStore { ...@@ -421,7 +421,7 @@ public class AtlasTypeDefGraphStoreV1 extends AtlasTypeDefGraphStore {
throw new AtlasBaseException(AtlasErrorCode.CLASSIFICATIONDEF_INVALID_ENTITYTYPES, classificationTypeName,entityType); throw new AtlasBaseException(AtlasErrorCode.CLASSIFICATIONDEF_INVALID_ENTITYTYPES, classificationTypeName,entityType);
} }
getOrCreateEdge(classificationVertex, entityTypeVertex, AtlasGraphUtilsV1.ENTITYTYPE_EDGE_LABEL); getOrCreateEdge(classificationVertex, entityTypeVertex, AtlasGraphUtilsV2.ENTITYTYPE_EDGE_LABEL);
} }
} else if (CollectionUtils.isNotEmpty(currentEntityTypes)) { // remove the restrictions, if present } else if (CollectionUtils.isNotEmpty(currentEntityTypes)) { // remove the restrictions, if present
for (String entityType : currentEntityTypes) { for (String entityType : currentEntityTypes) {
...@@ -432,18 +432,18 @@ public class AtlasTypeDefGraphStoreV1 extends AtlasTypeDefGraphStore { ...@@ -432,18 +432,18 @@ public class AtlasTypeDefGraphStoreV1 extends AtlasTypeDefGraphStore {
} }
removeEdge(classificationVertex, entityTypeVertex, AtlasGraphUtilsV1.ENTITYTYPE_EDGE_LABEL); removeEdge(classificationVertex, entityTypeVertex, AtlasGraphUtilsV2.ENTITYTYPE_EDGE_LABEL);
} }
} }
} }
Set<String> getSuperTypeNames(AtlasVertex vertex) { Set<String> getSuperTypeNames(AtlasVertex vertex) {
return getTypeNamesFromEdges(vertex,AtlasGraphUtilsV1.SUPERTYPE_EDGE_LABEL); return getTypeNamesFromEdges(vertex, AtlasGraphUtilsV2.SUPERTYPE_EDGE_LABEL);
} }
Set<String> getEntityTypeNames(AtlasVertex vertex) { Set<String> getEntityTypeNames(AtlasVertex vertex) {
return getTypeNamesFromEdges(vertex,AtlasGraphUtilsV1.ENTITYTYPE_EDGE_LABEL); return getTypeNamesFromEdges(vertex, AtlasGraphUtilsV2.ENTITYTYPE_EDGE_LABEL);
} }
/** /**
...@@ -524,7 +524,7 @@ public class AtlasTypeDefGraphStoreV1 extends AtlasTypeDefGraphStore { ...@@ -524,7 +524,7 @@ public class AtlasTypeDefGraphStoreV1 extends AtlasTypeDefGraphStore {
} }
private String getCurrentUser() { private String getCurrentUser() {
String ret = RequestContextV1.get().getUser(); String ret = RequestContext.get().getUser();
if (StringUtils.isBlank(ret)) { if (StringUtils.isBlank(ret)) {
ret = System.getProperty("user.name"); ret = System.getProperty("user.name");
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.apache.atlas.repository.store.graph.v1; package org.apache.atlas.repository.store.graph.v2;
import org.apache.atlas.model.instance.EntityMutations.EntityOperation; import org.apache.atlas.model.instance.EntityMutations.EntityOperation;
......
...@@ -15,11 +15,11 @@ ...@@ -15,11 +15,11 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.apache.atlas.repository.store.graph.v1; package org.apache.atlas.repository.store.graph.v2;
import com.google.common.annotations.VisibleForTesting; import com.google.common.annotations.VisibleForTesting;
import org.apache.atlas.AtlasErrorCode; import org.apache.atlas.AtlasErrorCode;
import org.apache.atlas.RequestContextV1; import org.apache.atlas.RequestContext;
import org.apache.atlas.exception.AtlasBaseException; import org.apache.atlas.exception.AtlasBaseException;
import org.apache.atlas.model.impexp.AtlasImportResult; import org.apache.atlas.model.impexp.AtlasImportResult;
import org.apache.atlas.model.instance.AtlasEntity; import org.apache.atlas.model.instance.AtlasEntity;
...@@ -41,7 +41,7 @@ import java.util.Set; ...@@ -41,7 +41,7 @@ import java.util.Set;
@Component @Component
public class BulkImporterImpl implements BulkImporter { public class BulkImporterImpl implements BulkImporter {
private static final Logger LOG = LoggerFactory.getLogger(AtlasEntityStoreV1.class); private static final Logger LOG = LoggerFactory.getLogger(AtlasEntityStoreV2.class);
private final AtlasEntityStore entityStore; private final AtlasEntityStore entityStore;
...@@ -100,7 +100,7 @@ public class BulkImporterImpl implements BulkImporter { ...@@ -100,7 +100,7 @@ public class BulkImporterImpl implements BulkImporter {
throw abe; throw abe;
} }
} finally { } finally {
RequestContextV1.clear(); RequestContext.clear();
} }
} }
......
...@@ -15,11 +15,11 @@ ...@@ -15,11 +15,11 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.apache.atlas.repository.store.graph.v1; package org.apache.atlas.repository.store.graph.v2;
import org.apache.atlas.AtlasErrorCode; import org.apache.atlas.AtlasErrorCode;
import org.apache.atlas.RequestContextV1; import org.apache.atlas.RequestContext;
import org.apache.atlas.exception.AtlasBaseException; import org.apache.atlas.exception.AtlasBaseException;
import org.apache.atlas.model.TimeBoundary; import org.apache.atlas.model.TimeBoundary;
import org.apache.atlas.model.TypeCategory; import org.apache.atlas.model.TypeCategory;
...@@ -43,6 +43,7 @@ import org.apache.atlas.repository.graphdb.AtlasEdge; ...@@ -43,6 +43,7 @@ import org.apache.atlas.repository.graphdb.AtlasEdge;
import org.apache.atlas.repository.graphdb.AtlasGraph; import org.apache.atlas.repository.graphdb.AtlasGraph;
import org.apache.atlas.repository.graphdb.AtlasVertex; import org.apache.atlas.repository.graphdb.AtlasVertex;
import org.apache.atlas.repository.store.graph.AtlasRelationshipStore; import org.apache.atlas.repository.store.graph.AtlasRelationshipStore;
import org.apache.atlas.repository.store.graph.v1.DeleteHandlerV1;
import org.apache.atlas.type.AtlasArrayType; import org.apache.atlas.type.AtlasArrayType;
import org.apache.atlas.type.AtlasClassificationType; import org.apache.atlas.type.AtlasClassificationType;
import org.apache.atlas.type.AtlasEntityType; import org.apache.atlas.type.AtlasEntityType;
...@@ -91,8 +92,8 @@ import static org.apache.atlas.repository.graph.GraphHelper.isPropagationEnabled ...@@ -91,8 +92,8 @@ import static org.apache.atlas.repository.graph.GraphHelper.isPropagationEnabled
import static org.apache.atlas.repository.graph.GraphHelper.isRelationshipEdge; import static org.apache.atlas.repository.graph.GraphHelper.isRelationshipEdge;
import static org.apache.atlas.repository.graph.GraphHelper.string; import static org.apache.atlas.repository.graph.GraphHelper.string;
import static org.apache.atlas.repository.graph.GraphHelper.updateModificationMetadata; import static org.apache.atlas.repository.graph.GraphHelper.updateModificationMetadata;
import static org.apache.atlas.repository.store.graph.v1.AtlasGraphUtilsV1.getIdFromVertex; import static org.apache.atlas.repository.store.graph.v2.AtlasGraphUtilsV2.getIdFromVertex;
import static org.apache.atlas.repository.store.graph.v1.AtlasGraphUtilsV1.isReference; import static org.apache.atlas.repository.store.graph.v2.AtlasGraphUtilsV2.isReference;
import static org.apache.atlas.type.AtlasStructType.AtlasAttribute.AtlasRelationshipEdgeDirection.IN; import static org.apache.atlas.type.AtlasStructType.AtlasAttribute.AtlasRelationshipEdgeDirection.IN;
import static org.apache.atlas.type.AtlasStructType.AtlasAttribute.AtlasRelationshipEdgeDirection.OUT; import static org.apache.atlas.type.AtlasStructType.AtlasAttribute.AtlasRelationshipEdgeDirection.OUT;
...@@ -137,34 +138,34 @@ public class EntityGraphMapper { ...@@ -137,34 +138,34 @@ public class EntityGraphMapper {
AtlasVertex ret = createStructVertex(entity); AtlasVertex ret = createStructVertex(entity);
for (String superTypeName : entityType.getAllSuperTypes()) { for (String superTypeName : entityType.getAllSuperTypes()) {
AtlasGraphUtilsV1.addProperty(ret, Constants.SUPER_TYPES_PROPERTY_KEY, superTypeName); AtlasGraphUtilsV2.addProperty(ret, Constants.SUPER_TYPES_PROPERTY_KEY, superTypeName);
} }
AtlasGraphUtilsV1.setProperty(ret, Constants.GUID_PROPERTY_KEY, guid); AtlasGraphUtilsV2.setProperty(ret, Constants.GUID_PROPERTY_KEY, guid);
AtlasGraphUtilsV1.setProperty(ret, Constants.VERSION_PROPERTY_KEY, getEntityVersion(entity)); AtlasGraphUtilsV2.setProperty(ret, Constants.VERSION_PROPERTY_KEY, getEntityVersion(entity));
return ret; return ret;
} }
public void updateSystemAttributes(AtlasVertex vertex, AtlasEntity entity) { public void updateSystemAttributes(AtlasVertex vertex, AtlasEntity entity) {
if (entity.getStatus() != null) { if (entity.getStatus() != null) {
AtlasGraphUtilsV1.setProperty(vertex, Constants.STATE_PROPERTY_KEY, entity.getStatus().name()); AtlasGraphUtilsV2.setProperty(vertex, Constants.STATE_PROPERTY_KEY, entity.getStatus().name());
} }
if (entity.getCreateTime() != null) { if (entity.getCreateTime() != null) {
AtlasGraphUtilsV1.setProperty(vertex, Constants.TIMESTAMP_PROPERTY_KEY, entity.getCreateTime().getTime()); AtlasGraphUtilsV2.setProperty(vertex, Constants.TIMESTAMP_PROPERTY_KEY, entity.getCreateTime().getTime());
} }
if (entity.getUpdateTime() != null) { if (entity.getUpdateTime() != null) {
AtlasGraphUtilsV1.setProperty(vertex, Constants.MODIFICATION_TIMESTAMP_PROPERTY_KEY, entity.getUpdateTime().getTime()); AtlasGraphUtilsV2.setProperty(vertex, Constants.MODIFICATION_TIMESTAMP_PROPERTY_KEY, entity.getUpdateTime().getTime());
} }
if (StringUtils.isNotEmpty(entity.getCreatedBy())) { if (StringUtils.isNotEmpty(entity.getCreatedBy())) {
AtlasGraphUtilsV1.setProperty(vertex, Constants.CREATED_BY_KEY, entity.getCreatedBy()); AtlasGraphUtilsV2.setProperty(vertex, Constants.CREATED_BY_KEY, entity.getCreatedBy());
} }
if (StringUtils.isNotEmpty(entity.getUpdatedBy())) { if (StringUtils.isNotEmpty(entity.getUpdatedBy())) {
AtlasGraphUtilsV1.setProperty(vertex, Constants.MODIFIED_BY_KEY, entity.getUpdatedBy()); AtlasGraphUtilsV2.setProperty(vertex, Constants.MODIFIED_BY_KEY, entity.getUpdatedBy());
} }
} }
...@@ -216,7 +217,7 @@ public class EntityGraphMapper { ...@@ -216,7 +217,7 @@ public class EntityGraphMapper {
} }
} }
RequestContextV1 req = RequestContextV1.get(); RequestContext req = RequestContext.get();
for (AtlasObjectId entity : req.getDeletedEntities()) { for (AtlasObjectId entity : req.getDeletedEntities()) {
resp.addEntity(DELETE, entity); resp.addEntity(DELETE, entity);
...@@ -241,12 +242,12 @@ public class EntityGraphMapper { ...@@ -241,12 +242,12 @@ public class EntityGraphMapper {
final AtlasVertex ret = graph.addVertex(); final AtlasVertex ret = graph.addVertex();
AtlasGraphUtilsV1.setProperty(ret, Constants.ENTITY_TYPE_PROPERTY_KEY, struct.getTypeName()); AtlasGraphUtilsV2.setProperty(ret, Constants.ENTITY_TYPE_PROPERTY_KEY, struct.getTypeName());
AtlasGraphUtilsV1.setProperty(ret, Constants.STATE_PROPERTY_KEY, AtlasEntity.Status.ACTIVE.name()); AtlasGraphUtilsV2.setProperty(ret, Constants.STATE_PROPERTY_KEY, AtlasEntity.Status.ACTIVE.name());
AtlasGraphUtilsV1.setProperty(ret, Constants.TIMESTAMP_PROPERTY_KEY, RequestContextV1.get().getRequestTime()); AtlasGraphUtilsV2.setProperty(ret, Constants.TIMESTAMP_PROPERTY_KEY, RequestContext.get().getRequestTime());
AtlasGraphUtilsV1.setProperty(ret, Constants.MODIFICATION_TIMESTAMP_PROPERTY_KEY, RequestContextV1.get().getRequestTime()); AtlasGraphUtilsV2.setProperty(ret, Constants.MODIFICATION_TIMESTAMP_PROPERTY_KEY, RequestContext.get().getRequestTime());
AtlasGraphUtilsV1.setProperty(ret, Constants.CREATED_BY_KEY, RequestContextV1.get().getUser()); AtlasGraphUtilsV2.setProperty(ret, Constants.CREATED_BY_KEY, RequestContext.get().getUser());
GraphHelper.setProperty(ret, Constants.MODIFIED_BY_KEY, RequestContextV1.get().getUser()); GraphHelper.setProperty(ret, Constants.MODIFIED_BY_KEY, RequestContext.get().getUser());
if (LOG.isDebugEnabled()) { if (LOG.isDebugEnabled()) {
LOG.debug("<== createStructVertex({})", struct.getTypeName()); LOG.debug("<== createStructVertex({})", struct.getTypeName());
...@@ -264,8 +265,8 @@ public class EntityGraphMapper { ...@@ -264,8 +265,8 @@ public class EntityGraphMapper {
AtlasVertex ret = createStructVertex(classification); AtlasVertex ret = createStructVertex(classification);
AtlasGraphUtilsV1.addProperty(ret, Constants.SUPER_TYPES_PROPERTY_KEY, classificationType.getAllSuperTypes()); AtlasGraphUtilsV2.addProperty(ret, Constants.SUPER_TYPES_PROPERTY_KEY, classificationType.getAllSuperTypes());
AtlasGraphUtilsV1.setProperty(ret, Constants.CLASSIFICATION_ENTITY_GUID, classification.getEntityGuid()); AtlasGraphUtilsV2.setProperty(ret, Constants.CLASSIFICATION_ENTITY_GUID, classification.getEntityGuid());
return ret; return ret;
} }
...@@ -376,7 +377,7 @@ public class EntityGraphMapper { ...@@ -376,7 +377,7 @@ public class EntityGraphMapper {
return mapPrimitiveValue(ctx); return mapPrimitiveValue(ctx);
case STRUCT: { case STRUCT: {
String edgeLabel = AtlasGraphUtilsV1.getEdgeLabel(ctx.getVertexProperty()); String edgeLabel = AtlasGraphUtilsV2.getEdgeLabel(ctx.getVertexProperty());
AtlasEdge currentEdge = graphHelper.getEdgeForLabel(ctx.getReferringVertex(), edgeLabel); AtlasEdge currentEdge = graphHelper.getEdgeForLabel(ctx.getReferringVertex(), edgeLabel);
AtlasEdge edge = currentEdge != null ? currentEdge : null; AtlasEdge edge = currentEdge != null ? currentEdge : null;
...@@ -397,7 +398,7 @@ public class EntityGraphMapper { ...@@ -397,7 +398,7 @@ public class EntityGraphMapper {
// if relationshipDefs doesn't exist, use legacy way of finding edge label. // if relationshipDefs doesn't exist, use legacy way of finding edge label.
if (StringUtils.isEmpty(edgeLabel)) { if (StringUtils.isEmpty(edgeLabel)) {
edgeLabel = AtlasGraphUtilsV1.getEdgeLabel(ctx.getVertexProperty()); edgeLabel = AtlasGraphUtilsV2.getEdgeLabel(ctx.getVertexProperty());
} }
String relationshipGuid = getRelationshipGuid(ctx.getValue()); String relationshipGuid = getRelationshipGuid(ctx.getValue());
...@@ -476,7 +477,7 @@ public class EntityGraphMapper { ...@@ -476,7 +477,7 @@ public class EntityGraphMapper {
AtlasVertex inverseVertex = edge.getInVertex(); AtlasVertex inverseVertex = edge.getInVertex();
String inverseEdgeLabel = inverseAttribute.getRelationshipEdgeLabel(); String inverseEdgeLabel = inverseAttribute.getRelationshipEdgeLabel();
AtlasEdge inverseEdge = graphHelper.getEdgeForLabel(inverseVertex, inverseEdgeLabel); AtlasEdge inverseEdge = graphHelper.getEdgeForLabel(inverseVertex, inverseEdgeLabel);
String propertyName = AtlasGraphUtilsV1.getQualifiedAttributePropertyKey(inverseType, inverseAttribute.getName()); String propertyName = AtlasGraphUtilsV2.getQualifiedAttributePropertyKey(inverseType, inverseAttribute.getName());
// create new inverse reference // create new inverse reference
AtlasEdge newEdge = createInverseReferenceUsingRelationship(context, inverseAttribute, edge, relationshipAttributes); AtlasEdge newEdge = createInverseReferenceUsingRelationship(context, inverseAttribute, edge, relationshipAttributes);
...@@ -520,7 +521,7 @@ public class EntityGraphMapper { ...@@ -520,7 +521,7 @@ public class EntityGraphMapper {
} }
if (inverseUpdated) { if (inverseUpdated) {
RequestContextV1 requestContext = RequestContextV1.get(); RequestContext requestContext = RequestContext.get();
if (!requestContext.isDeletedEntity(GraphHelper.getGuid(inverseVertex))) { if (!requestContext.isDeletedEntity(GraphHelper.getGuid(inverseVertex))) {
updateModificationMetadata(inverseVertex); updateModificationMetadata(inverseVertex);
...@@ -552,7 +553,7 @@ public class EntityGraphMapper { ...@@ -552,7 +553,7 @@ public class EntityGraphMapper {
} else { } else {
if (LOG.isDebugEnabled()) { if (LOG.isDebugEnabled()) {
LOG.debug("No RelationshipDef defined between {} and {} on attribute: {}", inverseAttributeType, LOG.debug("No RelationshipDef defined between {} and {} on attribute: {}", inverseAttributeType,
AtlasGraphUtilsV1.getTypeName(vertex), inverseAttributeName); AtlasGraphUtilsV2.getTypeName(vertex), inverseAttributeName);
} }
// if no RelationshipDef found, use legacy way to create edges // if no RelationshipDef found, use legacy way to create edges
ret = createInverseReference(inverseAttribute, (AtlasStructType) inverseAttributeType, inverseVertex, vertex); ret = createInverseReference(inverseAttribute, (AtlasStructType) inverseAttributeType, inverseVertex, vertex);
...@@ -591,15 +592,15 @@ public class EntityGraphMapper { ...@@ -591,15 +592,15 @@ public class EntityGraphMapper {
return; return;
} }
AtlasGraphUtilsV1.setProperty(edge, Constants.RELATIONSHIP_GUID_PROPERTY_KEY, parentRelationshipGuid); AtlasGraphUtilsV2.setProperty(edge, Constants.RELATIONSHIP_GUID_PROPERTY_KEY, parentRelationshipGuid);
} }
// legacy method to create edges for inverse reference // legacy method to create edges for inverse reference
private AtlasEdge createInverseReference(AtlasAttribute inverseAttribute, AtlasStructType inverseAttributeType, private AtlasEdge createInverseReference(AtlasAttribute inverseAttribute, AtlasStructType inverseAttributeType,
AtlasVertex inverseVertex, AtlasVertex vertex) throws AtlasBaseException { AtlasVertex inverseVertex, AtlasVertex vertex) throws AtlasBaseException {
String propertyName = AtlasGraphUtilsV1.getQualifiedAttributePropertyKey(inverseAttributeType, inverseAttribute.getName()); String propertyName = AtlasGraphUtilsV2.getQualifiedAttributePropertyKey(inverseAttributeType, inverseAttribute.getName());
String inverseEdgeLabel = AtlasGraphUtilsV1.getEdgeLabel(propertyName); String inverseEdgeLabel = AtlasGraphUtilsV2.getEdgeLabel(propertyName);
AtlasEdge ret; AtlasEdge ret;
try { try {
...@@ -613,7 +614,7 @@ public class EntityGraphMapper { ...@@ -613,7 +614,7 @@ public class EntityGraphMapper {
} }
private Object mapPrimitiveValue(AttributeMutationContext ctx) { private Object mapPrimitiveValue(AttributeMutationContext ctx) {
AtlasGraphUtilsV1.setProperty(ctx.getReferringVertex(), ctx.getVertexProperty(), ctx.getValue()); AtlasGraphUtilsV2.setProperty(ctx.getReferringVertex(), ctx.getVertexProperty(), ctx.getValue());
return ctx.getValue(); return ctx.getValue();
} }
...@@ -639,7 +640,7 @@ public class EntityGraphMapper { ...@@ -639,7 +640,7 @@ public class EntityGraphMapper {
ret = ctx.getCurrentEdge(); ret = ctx.getCurrentEdge();
} else if (ctx.getValue() != null) { } else if (ctx.getValue() != null) {
String edgeLabel = AtlasGraphUtilsV1.getEdgeLabel(ctx.getVertexProperty()); String edgeLabel = AtlasGraphUtilsV2.getEdgeLabel(ctx.getVertexProperty());
AtlasStruct structVal = null; AtlasStruct structVal = null;
if (ctx.getValue() instanceof AtlasStruct) { if (ctx.getValue() instanceof AtlasStruct) {
...@@ -686,7 +687,7 @@ public class EntityGraphMapper { ...@@ -686,7 +687,7 @@ public class EntityGraphMapper {
if (ctx.getCurrentEdge() != null) { if (ctx.getCurrentEdge() != null) {
ret = updateEdge(ctx.getAttributeDef(), ctx.getValue(), ctx.getCurrentEdge(), entityVertex); ret = updateEdge(ctx.getAttributeDef(), ctx.getValue(), ctx.getCurrentEdge(), entityVertex);
} else if (ctx.getValue() != null) { } else if (ctx.getValue() != null) {
String edgeLabel = AtlasGraphUtilsV1.getEdgeLabel(ctx.getVertexProperty()); String edgeLabel = AtlasGraphUtilsV2.getEdgeLabel(ctx.getVertexProperty());
try { try {
ret = graphHelper.getOrCreateEdge(ctx.getReferringVertex(), entityVertex, edgeLabel); ret = graphHelper.getOrCreateEdge(ctx.getReferringVertex(), entityVertex, edgeLabel);
...@@ -726,7 +727,7 @@ public class EntityGraphMapper { ...@@ -726,7 +727,7 @@ public class EntityGraphMapper {
} }
String attributeName = ctx.getAttribute().getName(); String attributeName = ctx.getAttribute().getName();
AtlasType type = typeRegistry.getType(AtlasGraphUtilsV1.getTypeName(entityVertex)); AtlasType type = typeRegistry.getType(AtlasGraphUtilsV2.getTypeName(entityVertex));
AtlasRelationshipEdgeDirection edgeDirection = ctx.getAttribute().getRelationshipEdgeDirection(); AtlasRelationshipEdgeDirection edgeDirection = ctx.getAttribute().getRelationshipEdgeDirection();
String edgeLabel = ctx.getAttribute().getRelationshipEdgeLabel(); String edgeLabel = ctx.getAttribute().getRelationshipEdgeLabel();
...@@ -762,7 +763,7 @@ public class EntityGraphMapper { ...@@ -762,7 +763,7 @@ public class EntityGraphMapper {
if (context.isImport()) { if (context.isImport()) {
String relationshipGuid = getRelationshipGuid(ctx.getValue()); String relationshipGuid = getRelationshipGuid(ctx.getValue());
if(!StringUtils.isEmpty(relationshipGuid)) { if(!StringUtils.isEmpty(relationshipGuid)) {
AtlasGraphUtilsV1.setProperty(ret, Constants.RELATIONSHIP_GUID_PROPERTY_KEY, relationshipGuid); AtlasGraphUtilsV2.setProperty(ret, Constants.RELATIONSHIP_GUID_PROPERTY_KEY, relationshipGuid);
} }
} }
...@@ -911,7 +912,7 @@ public class EntityGraphMapper { ...@@ -911,7 +912,7 @@ public class EntityGraphMapper {
Object element = newElementsCreated.get(index); Object element = newElementsCreated.get(index);
if (element instanceof AtlasEdge) { if (element instanceof AtlasEdge) {
AtlasGraphUtilsV1.setProperty((AtlasEdge) element, ATTRIBUTE_INDEX_PROPERTY_KEY, index); AtlasGraphUtilsV2.setProperty((AtlasEdge) element, ATTRIBUTE_INDEX_PROPERTY_KEY, index);
} }
} }
...@@ -1162,7 +1163,7 @@ public class EntityGraphMapper { ...@@ -1162,7 +1163,7 @@ public class EntityGraphMapper {
if (!currentEntityId.equals(newEntityId)) { if (!currentEntityId.equals(newEntityId)) {
// create a new relationship edge to the new attribute vertex from the instance // create a new relationship edge to the new attribute vertex from the instance
String relationshipName = AtlasGraphUtilsV1.getTypeName(currentEdge); String relationshipName = AtlasGraphUtilsV2.getTypeName(currentEdge);
if (relationshipName == null) { if (relationshipName == null) {
relationshipName = currentEdge.getLabel(); relationshipName = currentEdge.getLabel();
...@@ -1270,13 +1271,13 @@ public class EntityGraphMapper { ...@@ -1270,13 +1271,13 @@ public class EntityGraphMapper {
public void addClassifications(final EntityMutationContext context, String guid, List<AtlasClassification> classifications) throws AtlasBaseException { public void addClassifications(final EntityMutationContext context, String guid, List<AtlasClassification> classifications) throws AtlasBaseException {
if (CollectionUtils.isNotEmpty(classifications)) { if (CollectionUtils.isNotEmpty(classifications)) {
AtlasVertex entityVertex = AtlasGraphUtilsV1.findByGuid(guid); AtlasVertex entityVertex = AtlasGraphUtilsV2.findByGuid(guid);
if (entityVertex == null) { if (entityVertex == null) {
throw new AtlasBaseException(AtlasErrorCode.INSTANCE_GUID_NOT_FOUND, guid); throw new AtlasBaseException(AtlasErrorCode.INSTANCE_GUID_NOT_FOUND, guid);
} }
final String entityTypeName = AtlasGraphUtilsV1.getTypeName(entityVertex); final String entityTypeName = AtlasGraphUtilsV2.getTypeName(entityVertex);
final AtlasEntityType entityType = typeRegistry.getEntityTypeByName(entityTypeName); final AtlasEntityType entityType = typeRegistry.getEntityTypeByName(entityTypeName);
List<AtlasVertex> entitiesToPropagateTo = null; List<AtlasVertex> entitiesToPropagateTo = null;
Map<AtlasVertex, List<AtlasClassification>> propagations = null; Map<AtlasVertex, List<AtlasClassification>> propagations = null;
...@@ -1390,7 +1391,7 @@ public class EntityGraphMapper { ...@@ -1390,7 +1391,7 @@ public class EntityGraphMapper {
throw new AtlasBaseException(AtlasErrorCode.INVALID_CLASSIFICATION_PARAMS, "delete", entityGuid); throw new AtlasBaseException(AtlasErrorCode.INVALID_CLASSIFICATION_PARAMS, "delete", entityGuid);
} }
AtlasVertex entityVertex = AtlasGraphUtilsV1.findByGuid(entityGuid); AtlasVertex entityVertex = AtlasGraphUtilsV2.findByGuid(entityGuid);
if (entityVertex == null) { if (entityVertex == null) {
throw new AtlasBaseException(AtlasErrorCode.INSTANCE_GUID_NOT_FOUND, entityGuid); throw new AtlasBaseException(AtlasErrorCode.INSTANCE_GUID_NOT_FOUND, entityGuid);
...@@ -1473,13 +1474,13 @@ public class EntityGraphMapper { ...@@ -1473,13 +1474,13 @@ public class EntityGraphMapper {
throw new AtlasBaseException(AtlasErrorCode.INVALID_CLASSIFICATION_PARAMS, "update", guid); throw new AtlasBaseException(AtlasErrorCode.INVALID_CLASSIFICATION_PARAMS, "update", guid);
} }
AtlasVertex entityVertex = AtlasGraphUtilsV1.findByGuid(guid); AtlasVertex entityVertex = AtlasGraphUtilsV2.findByGuid(guid);
if (entityVertex == null) { if (entityVertex == null) {
throw new AtlasBaseException(AtlasErrorCode.INSTANCE_GUID_NOT_FOUND, guid); throw new AtlasBaseException(AtlasErrorCode.INSTANCE_GUID_NOT_FOUND, guid);
} }
String entityTypeName = AtlasGraphUtilsV1.getTypeName(entityVertex); String entityTypeName = AtlasGraphUtilsV2.getTypeName(entityVertex);
AtlasEntityType entityType = typeRegistry.getEntityTypeByName(entityTypeName); AtlasEntityType entityType = typeRegistry.getEntityTypeByName(entityTypeName);
List<AtlasClassification> updatedClassifications = new ArrayList<>(); List<AtlasClassification> updatedClassifications = new ArrayList<>();
List<AtlasVertex> entitiesToPropagateTo = new ArrayList<>(); List<AtlasVertex> entitiesToPropagateTo = new ArrayList<>();
...@@ -1634,13 +1635,13 @@ public class EntityGraphMapper { ...@@ -1634,13 +1635,13 @@ public class EntityGraphMapper {
if (classification.getValidityPeriods() != null) { if (classification.getValidityPeriods() != null) {
String strValidityPeriods = AtlasJson.toJson(classification.getValidityPeriods()); String strValidityPeriods = AtlasJson.toJson(classification.getValidityPeriods());
AtlasGraphUtilsV1.setProperty(traitInstanceVertex, Constants.CLASSIFICATION_VALIDITY_PERIODS_KEY, strValidityPeriods); AtlasGraphUtilsV2.setProperty(traitInstanceVertex, Constants.CLASSIFICATION_VALIDITY_PERIODS_KEY, strValidityPeriods);
} else { } else {
// if 'null', don't update existing value in the classification // if 'null', don't update existing value in the classification
} }
if (classification.isPropagate() != null) { if (classification.isPropagate() != null) {
AtlasGraphUtilsV1.setProperty(traitInstanceVertex, Constants.CLASSIFICATION_VERTEX_PROPAGATE_KEY, classification.isPropagate()); AtlasGraphUtilsV2.setProperty(traitInstanceVertex, Constants.CLASSIFICATION_VERTEX_PROPAGATE_KEY, classification.isPropagate());
} }
// map all the attributes to this newly created AtlasVertex // map all the attributes to this newly created AtlasVertex
...@@ -1656,7 +1657,7 @@ public class EntityGraphMapper { ...@@ -1656,7 +1657,7 @@ public class EntityGraphMapper {
} }
public void deleteClassifications(String guid) throws AtlasBaseException { public void deleteClassifications(String guid) throws AtlasBaseException {
AtlasVertex instanceVertex = AtlasGraphUtilsV1.findByGuid(guid); AtlasVertex instanceVertex = AtlasGraphUtilsV2.findByGuid(guid);
if (instanceVertex == null) { if (instanceVertex == null) {
throw new AtlasBaseException(AtlasErrorCode.INSTANCE_GUID_NOT_FOUND, guid); throw new AtlasBaseException(AtlasErrorCode.INSTANCE_GUID_NOT_FOUND, guid);
...@@ -1710,7 +1711,7 @@ public class EntityGraphMapper { ...@@ -1710,7 +1711,7 @@ public class EntityGraphMapper {
} }
private void recordEntityUpdate(AtlasVertex vertex) throws AtlasBaseException { private void recordEntityUpdate(AtlasVertex vertex) throws AtlasBaseException {
RequestContextV1 req = RequestContextV1.get(); RequestContext req = RequestContext.get();
if (!req.isUpdatedEntity(GraphHelper.getGuid(vertex))) { if (!req.isUpdatedEntity(GraphHelper.getGuid(vertex))) {
updateModificationMetadata(vertex); updateModificationMetadata(vertex);
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.apache.atlas.repository.store.graph.v1; package org.apache.atlas.repository.store.graph.v2;
import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.core.type.TypeReference;
import org.apache.atlas.AtlasErrorCode; import org.apache.atlas.AtlasErrorCode;
...@@ -110,8 +110,8 @@ import static org.apache.atlas.repository.graph.GraphHelper.getPropagateTags; ...@@ -110,8 +110,8 @@ import static org.apache.atlas.repository.graph.GraphHelper.getPropagateTags;
import static org.apache.atlas.repository.graph.GraphHelper.getRelationshipGuid; import static org.apache.atlas.repository.graph.GraphHelper.getRelationshipGuid;
import static org.apache.atlas.repository.graph.GraphHelper.getTypeName; import static org.apache.atlas.repository.graph.GraphHelper.getTypeName;
import static org.apache.atlas.repository.graph.GraphHelper.isPropagationEnabled; import static org.apache.atlas.repository.graph.GraphHelper.isPropagationEnabled;
import static org.apache.atlas.repository.store.graph.v1.AtlasGraphUtilsV1.getIdFromVertex; import static org.apache.atlas.repository.store.graph.v2.AtlasGraphUtilsV2.getIdFromVertex;
import static org.apache.atlas.repository.store.graph.v1.AtlasGraphUtilsV1.isReference; import static org.apache.atlas.repository.store.graph.v2.AtlasGraphUtilsV2.isReference;
import static org.apache.atlas.type.AtlasStructType.AtlasAttribute.AtlasRelationshipEdgeDirection; import static org.apache.atlas.type.AtlasStructType.AtlasAttribute.AtlasRelationshipEdgeDirection;
import static org.apache.atlas.type.AtlasStructType.AtlasAttribute.AtlasRelationshipEdgeDirection.BOTH; import static org.apache.atlas.type.AtlasStructType.AtlasAttribute.AtlasRelationshipEdgeDirection.BOTH;
import static org.apache.atlas.type.AtlasStructType.AtlasAttribute.AtlasRelationshipEdgeDirection.IN; import static org.apache.atlas.type.AtlasStructType.AtlasAttribute.AtlasRelationshipEdgeDirection.IN;
...@@ -279,10 +279,10 @@ public final class EntityGraphRetriever { ...@@ -279,10 +279,10 @@ public final class EntityGraphRetriever {
public AtlasClassification toAtlasClassification(AtlasVertex classificationVertex) throws AtlasBaseException { public AtlasClassification toAtlasClassification(AtlasVertex classificationVertex) throws AtlasBaseException {
AtlasClassification ret = new AtlasClassification(getTypeName(classificationVertex)); AtlasClassification ret = new AtlasClassification(getTypeName(classificationVertex));
ret.setEntityGuid(AtlasGraphUtilsV1.getProperty(classificationVertex, CLASSIFICATION_ENTITY_GUID, String.class)); ret.setEntityGuid(AtlasGraphUtilsV2.getProperty(classificationVertex, CLASSIFICATION_ENTITY_GUID, String.class));
ret.setPropagate(isPropagationEnabled(classificationVertex)); ret.setPropagate(isPropagationEnabled(classificationVertex));
String strValidityPeriods = AtlasGraphUtilsV1.getProperty(classificationVertex, CLASSIFICATION_VALIDITY_PERIODS_KEY, String.class); String strValidityPeriods = AtlasGraphUtilsV2.getProperty(classificationVertex, CLASSIFICATION_VALIDITY_PERIODS_KEY, String.class);
if (strValidityPeriods != null) { if (strValidityPeriods != null) {
ret.setValidityPeriods(AtlasJson.fromJson(strValidityPeriods, TIME_BOUNDARIES_LIST_TYPE)); ret.setValidityPeriods(AtlasJson.fromJson(strValidityPeriods, TIME_BOUNDARIES_LIST_TYPE));
...@@ -314,7 +314,7 @@ public final class EntityGraphRetriever { ...@@ -314,7 +314,7 @@ public final class EntityGraphRetriever {
} }
public AtlasVertex getEntityVertex(String guid) throws AtlasBaseException { public AtlasVertex getEntityVertex(String guid) throws AtlasBaseException {
AtlasVertex ret = AtlasGraphUtilsV1.findByGuid(guid); AtlasVertex ret = AtlasGraphUtilsV2.findByGuid(guid);
if (ret == null) { if (ret == null) {
throw new AtlasBaseException(AtlasErrorCode.INSTANCE_GUID_NOT_FOUND, guid); throw new AtlasBaseException(AtlasErrorCode.INSTANCE_GUID_NOT_FOUND, guid);
...@@ -331,12 +331,12 @@ public final class EntityGraphRetriever { ...@@ -331,12 +331,12 @@ public final class EntityGraphRetriever {
} }
if (AtlasTypeUtil.isAssignedGuid(objId)) { if (AtlasTypeUtil.isAssignedGuid(objId)) {
ret = AtlasGraphUtilsV1.findByGuid(objId.getGuid()); ret = AtlasGraphUtilsV2.findByGuid(objId.getGuid());
} else { } else {
AtlasEntityType entityType = typeRegistry.getEntityTypeByName(objId.getTypeName()); AtlasEntityType entityType = typeRegistry.getEntityTypeByName(objId.getTypeName());
Map<String, Object> uniqAttributes = objId.getUniqueAttributes(); Map<String, Object> uniqAttributes = objId.getUniqueAttributes();
ret = AtlasGraphUtilsV1.getVertexByUniqueAttributes(entityType, uniqAttributes); ret = AtlasGraphUtilsV2.getVertexByUniqueAttributes(entityType, uniqAttributes);
} }
if (ret == null) { if (ret == null) {
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.apache.atlas.repository.store.graph.v1; package org.apache.atlas.repository.store.graph.v2;
import org.apache.atlas.model.instance.AtlasEntity.AtlasEntityWithExtInfo; import org.apache.atlas.model.instance.AtlasEntity.AtlasEntityWithExtInfo;
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.apache.atlas.repository.store.graph.v1; package org.apache.atlas.repository.store.graph.v2;
import org.apache.atlas.model.instance.AtlasEntity; import org.apache.atlas.model.instance.AtlasEntity;
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.apache.atlas.repository.store.graph.v1; package org.apache.atlas.repository.store.graph.v2;
import org.apache.atlas.model.instance.AtlasEntity; import org.apache.atlas.model.instance.AtlasEntity;
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.apache.atlas.repository.store.graph.v1; package org.apache.atlas.repository.store.graph.v2;
import org.apache.atlas.AtlasErrorCode; import org.apache.atlas.AtlasErrorCode;
import org.apache.atlas.exception.AtlasBaseException; import org.apache.atlas.exception.AtlasBaseException;
...@@ -49,7 +49,7 @@ public class IDBasedEntityResolver implements EntityResolver { ...@@ -49,7 +49,7 @@ public class IDBasedEntityResolver implements EntityResolver {
for (String guid : context.getReferencedGuids()) { for (String guid : context.getReferencedGuids()) {
boolean isAssignedGuid = AtlasTypeUtil.isAssignedGuid(guid); boolean isAssignedGuid = AtlasTypeUtil.isAssignedGuid(guid);
AtlasVertex vertex = isAssignedGuid ? AtlasGraphUtilsV1.findByGuid(guid) : null; AtlasVertex vertex = isAssignedGuid ? AtlasGraphUtilsV2.findByGuid(guid) : null;
if (vertex == null && !(entityStream instanceof EntityImportStream)) { // if not found in the store, look if the entity is present in the stream if (vertex == null && !(entityStream instanceof EntityImportStream)) { // if not found in the store, look if the entity is present in the stream
AtlasEntity entity = entityStream.getByGuid(guid); AtlasEntity entity = entityStream.getByGuid(guid);
...@@ -61,7 +61,7 @@ public class IDBasedEntityResolver implements EntityResolver { ...@@ -61,7 +61,7 @@ public class IDBasedEntityResolver implements EntityResolver {
throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_INVALID, TypeCategory.ENTITY.name(), entity.getTypeName()); throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_INVALID, TypeCategory.ENTITY.name(), entity.getTypeName());
} }
vertex = AtlasGraphUtilsV1.findByUniqueAttributes(entityType, entity.getAttributes()); vertex = AtlasGraphUtilsV2.findByUniqueAttributes(entityType, entity.getAttributes());
} else if (!isAssignedGuid) { // for local-guids, entity must be in the stream } else if (!isAssignedGuid) { // for local-guids, entity must be in the stream
throw new AtlasBaseException(AtlasErrorCode.REFERENCED_ENTITY_NOT_FOUND, guid); throw new AtlasBaseException(AtlasErrorCode.REFERENCED_ENTITY_NOT_FOUND, guid);
} }
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.apache.atlas.repository.store.graph.v1; package org.apache.atlas.repository.store.graph.v2;
import org.apache.atlas.model.instance.AtlasEntity; import org.apache.atlas.model.instance.AtlasEntity;
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.apache.atlas.repository.store.graph.v1; package org.apache.atlas.repository.store.graph.v2;
import org.apache.atlas.exception.AtlasBaseException; import org.apache.atlas.exception.AtlasBaseException;
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.apache.atlas.repository.store.graph.v1; package org.apache.atlas.repository.store.graph.v2;
import org.apache.atlas.AtlasErrorCode; import org.apache.atlas.AtlasErrorCode;
import org.apache.atlas.exception.AtlasBaseException; import org.apache.atlas.exception.AtlasBaseException;
...@@ -59,7 +59,7 @@ public class UniqAttrBasedEntityResolver implements EntityResolver { ...@@ -59,7 +59,7 @@ public class UniqAttrBasedEntityResolver implements EntityResolver {
throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_INVALID, TypeCategory.ENTITY.name(), objId.getTypeName()); throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_INVALID, TypeCategory.ENTITY.name(), objId.getTypeName());
} }
AtlasVertex vertex = AtlasGraphUtilsV1.findByUniqueAttributes(entityType, objId.getUniqueAttributes()); AtlasVertex vertex = AtlasGraphUtilsV2.findByUniqueAttributes(entityType, objId.getUniqueAttributes());
if (vertex != null) { if (vertex != null) {
context.addResolvedIdByUniqAttribs(objId, vertex); context.addResolvedIdByUniqAttribs(objId, vertex);
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
package org.apache.atlas.util; package org.apache.atlas.util;
import org.apache.atlas.repository.graphdb.AtlasVertex; import org.apache.atlas.repository.graphdb.AtlasVertex;
import org.apache.atlas.repository.store.graph.v1.AtlasGraphUtilsV1; import org.apache.atlas.repository.store.graph.v2.AtlasGraphUtilsV2;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.Predicate; import org.apache.commons.collections.Predicate;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
...@@ -680,7 +680,7 @@ public class SearchPredicateUtil { ...@@ -680,7 +680,7 @@ public class SearchPredicateUtil {
if (Collection.class.isAssignableFrom(attrClass)) { if (Collection.class.isAssignableFrom(attrClass)) {
attrValue = vertex.getPropertyValues(attrName, attrClass); attrValue = vertex.getPropertyValues(attrName, attrClass);
} else { } else {
attrValue = AtlasGraphUtilsV1.getProperty(vertex, attrName, attrClass); attrValue = AtlasGraphUtilsV2.getProperty(vertex, attrName, attrClass);
} }
ret = (isNullValid || attrValue != null) && compareValue(attrValue); ret = (isNullValid || attrValue != null) && compareValue(attrValue);
......
...@@ -50,13 +50,13 @@ import org.apache.atlas.repository.ogm.glossary.AtlasGlossaryTermDTO; ...@@ -50,13 +50,13 @@ import org.apache.atlas.repository.ogm.glossary.AtlasGlossaryTermDTO;
import org.apache.atlas.repository.store.graph.AtlasEntityStore; import org.apache.atlas.repository.store.graph.AtlasEntityStore;
import org.apache.atlas.repository.store.graph.AtlasRelationshipStore; import org.apache.atlas.repository.store.graph.AtlasRelationshipStore;
import org.apache.atlas.repository.store.graph.BulkImporter; import org.apache.atlas.repository.store.graph.BulkImporter;
import org.apache.atlas.repository.store.graph.v1.AtlasEntityChangeNotifier; import org.apache.atlas.repository.store.graph.v2.AtlasEntityChangeNotifier;
import org.apache.atlas.repository.store.graph.v1.AtlasEntityStoreV1; import org.apache.atlas.repository.store.graph.v2.AtlasEntityStoreV2;
import org.apache.atlas.repository.store.graph.v1.AtlasRelationshipStoreV1; import org.apache.atlas.repository.store.graph.v2.AtlasRelationshipStoreV2;
import org.apache.atlas.repository.store.graph.v1.AtlasTypeDefGraphStoreV1; import org.apache.atlas.repository.store.graph.v2.AtlasTypeDefGraphStoreV2;
import org.apache.atlas.repository.store.graph.v1.BulkImporterImpl; import org.apache.atlas.repository.store.graph.v2.BulkImporterImpl;
import org.apache.atlas.repository.store.graph.v1.DeleteHandlerV1; import org.apache.atlas.repository.store.graph.v1.DeleteHandlerV1;
import org.apache.atlas.repository.store.graph.v1.EntityGraphMapper; import org.apache.atlas.repository.store.graph.v2.EntityGraphMapper;
import org.apache.atlas.repository.store.graph.v1.HardDeleteHandlerV1; import org.apache.atlas.repository.store.graph.v1.HardDeleteHandlerV1;
import org.apache.atlas.repository.store.graph.v1.SoftDeleteHandlerV1; import org.apache.atlas.repository.store.graph.v1.SoftDeleteHandlerV1;
import org.apache.atlas.runner.LocalSolrRunner; import org.apache.atlas.runner.LocalSolrRunner;
...@@ -129,7 +129,7 @@ public class TestModules { ...@@ -129,7 +129,7 @@ public class TestModules {
bind(Configuration.class).toProvider(AtlasConfigurationProvider.class).in(Singleton.class); bind(Configuration.class).toProvider(AtlasConfigurationProvider.class).in(Singleton.class);
// bind the AtlasTypeDefStore interface to an implementation // bind the AtlasTypeDefStore interface to an implementation
bind(AtlasTypeDefStore.class).to(AtlasTypeDefGraphStoreV1.class).asEagerSingleton(); bind(AtlasTypeDefStore.class).to(AtlasTypeDefGraphStoreV2.class).asEagerSingleton();
bind(AtlasTypeRegistry.class).asEagerSingleton(); bind(AtlasTypeRegistry.class).asEagerSingleton();
bind(EntityGraphMapper.class).asEagerSingleton(); bind(EntityGraphMapper.class).asEagerSingleton();
...@@ -142,8 +142,8 @@ public class TestModules { ...@@ -142,8 +142,8 @@ public class TestModules {
bind(SearchTracker.class).asEagerSingleton(); bind(SearchTracker.class).asEagerSingleton();
bind(AtlasEntityStore.class).to(AtlasEntityStoreV1.class); bind(AtlasEntityStore.class).to(AtlasEntityStoreV2.class);
bind(AtlasRelationshipStore.class).to(AtlasRelationshipStoreV1.class); bind(AtlasRelationshipStore.class).to(AtlasRelationshipStoreV2.class);
// bind the DiscoveryService interface to an implementation // bind the DiscoveryService interface to an implementation
bind(AtlasDiscoveryService.class).to(EntityDiscoveryService.class).asEagerSingleton(); bind(AtlasDiscoveryService.class).to(EntityDiscoveryService.class).asEagerSingleton();
......
...@@ -38,7 +38,7 @@ import org.apache.atlas.model.typedef.AtlasClassificationDef; ...@@ -38,7 +38,7 @@ import org.apache.atlas.model.typedef.AtlasClassificationDef;
import org.apache.atlas.model.typedef.AtlasTypesDef; import org.apache.atlas.model.typedef.AtlasTypesDef;
import org.apache.atlas.repository.impexp.ZipFileResourceTestUtils; import org.apache.atlas.repository.impexp.ZipFileResourceTestUtils;
import org.apache.atlas.repository.store.graph.AtlasEntityStore; import org.apache.atlas.repository.store.graph.AtlasEntityStore;
import org.apache.atlas.repository.store.graph.v1.AtlasEntityStream; import org.apache.atlas.repository.store.graph.v2.AtlasEntityStream;
import org.apache.atlas.store.AtlasTypeDefStore; import org.apache.atlas.store.AtlasTypeDefStore;
import org.apache.atlas.type.AtlasTypeRegistry; import org.apache.atlas.type.AtlasTypeRegistry;
import org.apache.atlas.utils.AtlasJson; import org.apache.atlas.utils.AtlasJson;
......
...@@ -24,13 +24,11 @@ import org.apache.atlas.exception.AtlasBaseException; ...@@ -24,13 +24,11 @@ import org.apache.atlas.exception.AtlasBaseException;
import org.apache.atlas.model.instance.AtlasClassification; import org.apache.atlas.model.instance.AtlasClassification;
import org.apache.atlas.model.instance.AtlasEntity; import org.apache.atlas.model.instance.AtlasEntity;
import org.apache.atlas.model.instance.AtlasObjectId; import org.apache.atlas.model.instance.AtlasObjectId;
import org.apache.atlas.model.instance.AtlasStruct;
import org.apache.atlas.model.typedef.*; import org.apache.atlas.model.typedef.*;
import org.apache.atlas.repository.store.graph.AtlasEntityStore; import org.apache.atlas.repository.store.graph.AtlasEntityStore;
import org.apache.atlas.repository.store.graph.v1.AtlasEntityStream; import org.apache.atlas.repository.store.graph.v2.AtlasEntityStream;
import org.apache.atlas.store.AtlasTypeDefStore; import org.apache.atlas.store.AtlasTypeDefStore;
import org.apache.atlas.type.AtlasTypeRegistry; import org.apache.atlas.type.AtlasTypeRegistry;
import org.apache.atlas.type.AtlasTypeUtil;
import javax.inject.Inject; import javax.inject.Inject;
import java.io.IOException; import java.io.IOException;
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
package org.apache.atlas.repository.impexp; package org.apache.atlas.repository.impexp;
import org.apache.atlas.RequestContextV1; import org.apache.atlas.RequestContext;
import org.apache.atlas.TestModules; import org.apache.atlas.TestModules;
import org.apache.atlas.TestUtilsV2; import org.apache.atlas.TestUtilsV2;
import org.apache.atlas.exception.AtlasBaseException; import org.apache.atlas.exception.AtlasBaseException;
...@@ -29,11 +29,11 @@ import org.apache.atlas.model.instance.AtlasObjectId; ...@@ -29,11 +29,11 @@ import org.apache.atlas.model.instance.AtlasObjectId;
import org.apache.atlas.model.typedef.AtlasTypesDef; import org.apache.atlas.model.typedef.AtlasTypesDef;
import org.apache.atlas.repository.graph.AtlasGraphProvider; import org.apache.atlas.repository.graph.AtlasGraphProvider;
import org.apache.atlas.repository.store.bootstrap.AtlasTypeDefStoreInitializer; import org.apache.atlas.repository.store.bootstrap.AtlasTypeDefStoreInitializer;
import org.apache.atlas.repository.store.graph.v1.AtlasEntityChangeNotifier; import org.apache.atlas.repository.store.graph.v2.AtlasEntityChangeNotifier;
import org.apache.atlas.repository.store.graph.v1.AtlasEntityStoreV1; import org.apache.atlas.repository.store.graph.v2.AtlasEntityStoreV2;
import org.apache.atlas.repository.store.graph.v1.AtlasEntityStream; import org.apache.atlas.repository.store.graph.v2.AtlasEntityStream;
import org.apache.atlas.repository.store.graph.v1.DeleteHandlerV1; import org.apache.atlas.repository.store.graph.v1.DeleteHandlerV1;
import org.apache.atlas.repository.store.graph.v1.EntityGraphMapper; import org.apache.atlas.repository.store.graph.v2.EntityGraphMapper;
import org.apache.atlas.repository.store.graph.v1.SoftDeleteHandlerV1; import org.apache.atlas.repository.store.graph.v1.SoftDeleteHandlerV1;
import org.apache.atlas.runner.LocalSolrRunner; import org.apache.atlas.runner.LocalSolrRunner;
import org.apache.atlas.store.AtlasTypeDefStore; import org.apache.atlas.store.AtlasTypeDefStore;
...@@ -51,7 +51,6 @@ import org.testng.annotations.Test; ...@@ -51,7 +51,6 @@ import org.testng.annotations.Test;
import javax.inject.Inject; import javax.inject.Inject;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.util.Arrays; import java.util.Arrays;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -81,17 +80,17 @@ public class ExportServiceTest { ...@@ -81,17 +80,17 @@ public class ExportServiceTest {
ExportService exportService; ExportService exportService;
private DeleteHandlerV1 deleteHandler = mock(SoftDeleteHandlerV1.class);; private DeleteHandlerV1 deleteHandler = mock(SoftDeleteHandlerV1.class);;
private AtlasEntityChangeNotifier mockChangeNotifier = mock(AtlasEntityChangeNotifier.class); private AtlasEntityChangeNotifier mockChangeNotifier = mock(AtlasEntityChangeNotifier.class);
private AtlasEntityStoreV1 entityStore; private AtlasEntityStoreV2 entityStore;
@BeforeTest @BeforeTest
public void setupTest() { public void setupTest() {
RequestContextV1.clear(); RequestContext.clear();
RequestContextV1.get().setUser(TestUtilsV2.TEST_USER, null); RequestContext.get().setUser(TestUtilsV2.TEST_USER, null);
} }
@BeforeClass @BeforeClass
public void setupSampleData() throws AtlasBaseException { public void setupSampleData() throws AtlasBaseException {
entityStore = new AtlasEntityStoreV1(deleteHandler, typeRegistry, mockChangeNotifier, graphMapper);; entityStore = new AtlasEntityStoreV2(deleteHandler, typeRegistry, mockChangeNotifier, graphMapper);;
AtlasTypesDef sampleTypes = TestUtilsV2.defineDeptEmployeeTypes(); AtlasTypesDef sampleTypes = TestUtilsV2.defineDeptEmployeeTypes();
AtlasTypesDef typesToCreate = AtlasTypeDefStoreInitializer.getTypesToCreate(sampleTypes, typeRegistry); AtlasTypesDef typesToCreate = AtlasTypeDefStoreInitializer.getTypesToCreate(sampleTypes, typeRegistry);
......
...@@ -19,7 +19,7 @@ package org.apache.atlas.repository.impexp; ...@@ -19,7 +19,7 @@ package org.apache.atlas.repository.impexp;
import com.google.inject.Inject; import com.google.inject.Inject;
import org.apache.atlas.AtlasErrorCode; import org.apache.atlas.AtlasErrorCode;
import org.apache.atlas.RequestContextV1; import org.apache.atlas.RequestContext;
import org.apache.atlas.TestModules; import org.apache.atlas.TestModules;
import org.apache.atlas.TestUtilsV2; import org.apache.atlas.TestUtilsV2;
import org.apache.atlas.discovery.EntityDiscoveryService; import org.apache.atlas.discovery.EntityDiscoveryService;
...@@ -81,8 +81,8 @@ public class ImportServiceTest { ...@@ -81,8 +81,8 @@ public class ImportServiceTest {
@BeforeTest @BeforeTest
public void setupTest() { public void setupTest() {
RequestContextV1.clear(); RequestContext.clear();
RequestContextV1.get().setUser(TestUtilsV2.TEST_USER, null); RequestContext.get().setUser(TestUtilsV2.TEST_USER, null);
} }
@AfterClass @AfterClass
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
package org.apache.atlas.repository.impexp; package org.apache.atlas.repository.impexp;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import org.apache.atlas.RequestContextV1; import org.apache.atlas.RequestContext;
import org.apache.atlas.TestUtilsV2; import org.apache.atlas.TestUtilsV2;
import org.apache.atlas.exception.AtlasBaseException; import org.apache.atlas.exception.AtlasBaseException;
import org.apache.atlas.model.impexp.AtlasExportResult; import org.apache.atlas.model.impexp.AtlasExportResult;
...@@ -247,8 +247,8 @@ public class ZipFileResourceTestUtils { ...@@ -247,8 +247,8 @@ public class ZipFileResourceTestUtils {
AtlasExportResult exportResult = zipSource.getExportResult(); AtlasExportResult exportResult = zipSource.getExportResult();
List<String> creationOrder = zipSource.getCreationOrder(); List<String> creationOrder = zipSource.getCreationOrder();
RequestContextV1.clear(); RequestContext.clear();
RequestContextV1.get().setUser(TestUtilsV2.TEST_USER, null); RequestContext.get().setUser(TestUtilsV2.TEST_USER, null);
AtlasImportRequest request = getDefaultImportRequest(); AtlasImportRequest request = getDefaultImportRequest();
AtlasImportResult result = runImportWithParameters(importService, request, zipSource); AtlasImportResult result = runImportWithParameters(importService, request, zipSource);
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
package org.apache.atlas.repository.store.graph; package org.apache.atlas.repository.store.graph;
import com.google.inject.Inject; import com.google.inject.Inject;
import org.apache.atlas.RequestContextV1; import org.apache.atlas.RequestContext;
import org.apache.atlas.TestModules; import org.apache.atlas.TestModules;
import org.apache.atlas.TestUtilsV2; import org.apache.atlas.TestUtilsV2;
import org.apache.atlas.exception.AtlasBaseException; import org.apache.atlas.exception.AtlasBaseException;
...@@ -56,8 +56,8 @@ public class AtlasTypeDefGraphStoreTest { ...@@ -56,8 +56,8 @@ public class AtlasTypeDefGraphStoreTest {
@BeforeTest @BeforeTest
public void setupTest() { public void setupTest() {
RequestContextV1.clear(); RequestContext.clear();
RequestContextV1.get().setUser(TestUtilsV2.TEST_USER, null); RequestContext.get().setUser(TestUtilsV2.TEST_USER, null);
} }
@AfterClass @AfterClass
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.apache.atlas.repository.store.graph.v1; package org.apache.atlas.repository.store.graph.v2;
import org.apache.atlas.TestModules; import org.apache.atlas.TestModules;
import org.apache.atlas.TestUtilsV2; import org.apache.atlas.TestUtilsV2;
...@@ -486,7 +486,7 @@ public class AtlasComplexAttributesTest extends AtlasEntityTestBase { ...@@ -486,7 +486,7 @@ public class AtlasComplexAttributesTest extends AtlasEntityTestBase {
AtlasEntityHeader entityDeleted = response.getFirstDeletedEntityByTypeName(ENTITY_TYPE_WITH_COMPLEX_COLLECTION_ATTR); AtlasEntityHeader entityDeleted = response.getFirstDeletedEntityByTypeName(ENTITY_TYPE_WITH_COMPLEX_COLLECTION_ATTR);
AtlasEntityWithExtInfo deletedEntityWithExtInfo = entityStore.getById(entityDeleted.getGuid()); AtlasEntityWithExtInfo deletedEntityWithExtInfo = entityStore.getById(entityDeleted.getGuid());
AtlasVertex deletedEntityVertex = AtlasGraphUtilsV1.findByGuid(entityDeleted.getGuid()); AtlasVertex deletedEntityVertex = AtlasGraphUtilsV2.findByGuid(entityDeleted.getGuid());
Iterator<AtlasEdge> edges = deletedEntityVertex.getEdges(AtlasEdgeDirection.OUT).iterator(); Iterator<AtlasEdge> edges = deletedEntityVertex.getEdges(AtlasEdgeDirection.OUT).iterator();
// validate all attribute edges are deleted // validate all attribute edges are deleted
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.apache.atlas.repository.store.graph.v1; package org.apache.atlas.repository.store.graph.v2;
import com.google.inject.Inject; import com.google.inject.Inject;
import org.apache.atlas.ApplicationProperties; import org.apache.atlas.ApplicationProperties;
...@@ -41,11 +41,11 @@ import static org.apache.atlas.graph.GraphSandboxUtil.useLocalSolr; ...@@ -41,11 +41,11 @@ import static org.apache.atlas.graph.GraphSandboxUtil.useLocalSolr;
* Tests for AtlasEntityStoreV1 * Tests for AtlasEntityStoreV1
*/ */
@Guice(modules = TestModules.TestOnlyModule.class) @Guice(modules = TestModules.TestOnlyModule.class)
public class AtlasEntityDefStoreV1Test { public class AtlasEntityDefStoreV2Test {
@Inject @Inject
private private
AtlasEntityDefStoreV1 entityDefStore; AtlasEntityDefStoreV2 entityDefStore;
@DataProvider @DataProvider
public Object[][] invalidAttributeNameWithReservedKeywords(){ public Object[][] invalidAttributeNameWithReservedKeywords(){
...@@ -62,7 +62,7 @@ public class AtlasEntityDefStoreV1Test { ...@@ -62,7 +62,7 @@ public class AtlasEntityDefStoreV1Test {
@Test(dataProvider = "invalidAttributeNameWithReservedKeywords") @Test(dataProvider = "invalidAttributeNameWithReservedKeywords")
public void testCreateTypeWithReservedKeywords(AtlasEntityDef atlasEntityDef) throws AtlasException { public void testCreateTypeWithReservedKeywords(AtlasEntityDef atlasEntityDef) throws AtlasException {
try { try {
ApplicationProperties.get().setProperty(AtlasAbstractDefStoreV1.ALLOW_RESERVED_KEYWORDS, false); ApplicationProperties.get().setProperty(AtlasAbstractDefStoreV2.ALLOW_RESERVED_KEYWORDS, false);
entityDefStore.create(atlasEntityDef, null); entityDefStore.create(atlasEntityDef, null);
} catch (AtlasBaseException e) { } catch (AtlasBaseException e) {
Assert.assertEquals(e.getAtlasErrorCode(), AtlasErrorCode.ATTRIBUTE_NAME_INVALID); Assert.assertEquals(e.getAtlasErrorCode(), AtlasErrorCode.ATTRIBUTE_NAME_INVALID);
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.apache.atlas.repository.store.graph.v1; package org.apache.atlas.repository.store.graph.v2;
import org.mockito.invocation.InvocationOnMock; import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer; import org.mockito.stubbing.Answer;
...@@ -32,7 +32,7 @@ import static org.mockito.Mockito.mock; ...@@ -32,7 +32,7 @@ import static org.mockito.Mockito.mock;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue; import static org.testng.Assert.assertTrue;
public class AtlasEntityStoreV1BulkImportPercentTest { public class AtlasEntityStoreV2BulkImportPercentTest {
private final int MAX_PERCENT = 100; private final int MAX_PERCENT = 100;
private List<Integer> percentHolder; private List<Integer> percentHolder;
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.apache.atlas.repository.store.graph.v1; package org.apache.atlas.repository.store.graph.v2;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import org.apache.atlas.AtlasErrorCode; import org.apache.atlas.AtlasErrorCode;
...@@ -62,7 +62,7 @@ import static org.testng.Assert.assertTrue; ...@@ -62,7 +62,7 @@ import static org.testng.Assert.assertTrue;
import static org.testng.Assert.fail; import static org.testng.Assert.fail;
@Guice(modules = TestModules.TestOnlyModule.class) @Guice(modules = TestModules.TestOnlyModule.class)
public class AtlasEntityStoreV1Test extends AtlasEntityTestBase { public class AtlasEntityStoreV2Test extends AtlasEntityTestBase {
private AtlasEntitiesWithExtInfo deptEntity; private AtlasEntitiesWithExtInfo deptEntity;
private AtlasEntityWithExtInfo dbEntity; private AtlasEntityWithExtInfo dbEntity;
private AtlasEntityWithExtInfo tblEntity; private AtlasEntityWithExtInfo tblEntity;
......
...@@ -15,10 +15,10 @@ ...@@ -15,10 +15,10 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.apache.atlas.repository.store.graph.v1; package org.apache.atlas.repository.store.graph.v2;
import org.apache.atlas.AtlasException; import org.apache.atlas.AtlasException;
import org.apache.atlas.RequestContextV1; import org.apache.atlas.RequestContext;
import org.apache.atlas.TestModules; import org.apache.atlas.TestModules;
import org.apache.atlas.TestUtilsV2; import org.apache.atlas.TestUtilsV2;
import org.apache.atlas.exception.AtlasBaseException; import org.apache.atlas.exception.AtlasBaseException;
...@@ -38,6 +38,7 @@ import org.apache.atlas.repository.graph.GraphBackedSearchIndexer; ...@@ -38,6 +38,7 @@ import org.apache.atlas.repository.graph.GraphBackedSearchIndexer;
import org.apache.atlas.repository.graphdb.AtlasGraph; import org.apache.atlas.repository.graphdb.AtlasGraph;
import org.apache.atlas.repository.store.bootstrap.AtlasTypeDefStoreInitializer; import org.apache.atlas.repository.store.bootstrap.AtlasTypeDefStoreInitializer;
import org.apache.atlas.repository.store.graph.AtlasEntityStore; import org.apache.atlas.repository.store.graph.AtlasEntityStore;
import org.apache.atlas.repository.store.graph.v1.DeleteHandlerV1;
import org.apache.atlas.runner.LocalSolrRunner; import org.apache.atlas.runner.LocalSolrRunner;
import org.apache.atlas.store.AtlasTypeDefStore; import org.apache.atlas.store.AtlasTypeDefStore;
import org.apache.atlas.type.AtlasArrayType; import org.apache.atlas.type.AtlasArrayType;
...@@ -89,8 +90,8 @@ public class AtlasEntityTestBase { ...@@ -89,8 +90,8 @@ public class AtlasEntityTestBase {
@BeforeClass @BeforeClass
public void setUp() throws Exception { public void setUp() throws Exception {
RequestContextV1.clear(); RequestContext.clear();
RequestContextV1.get().setUser(TestUtilsV2.TEST_USER, null); RequestContext.get().setUser(TestUtilsV2.TEST_USER, null);
new GraphBackedSearchIndexer(typeRegistry); new GraphBackedSearchIndexer(typeRegistry);
} }
...@@ -106,10 +107,10 @@ public class AtlasEntityTestBase { ...@@ -106,10 +107,10 @@ public class AtlasEntityTestBase {
@BeforeTest @BeforeTest
public void init() throws Exception { public void init() throws Exception {
entityStore = new AtlasEntityStoreV1(deleteHandler, typeRegistry, mockChangeNotifier, graphMapper); entityStore = new AtlasEntityStoreV2(deleteHandler, typeRegistry, mockChangeNotifier, graphMapper);
RequestContextV1.clear(); RequestContext.clear();
RequestContextV1.get().setUser(TestUtilsV2.TEST_USER, null); RequestContext.get().setUser(TestUtilsV2.TEST_USER, null);
} }
protected AtlasClassificationDef getTagWithName(AtlasTypesDef typesDef, String tagName, String attributeType) { protected AtlasClassificationDef getTagWithName(AtlasTypesDef typesDef, String tagName, String attributeType) {
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.apache.atlas.repository.store.graph.v1; package org.apache.atlas.repository.store.graph.v2;
import com.google.inject.Inject; import com.google.inject.Inject;
import org.apache.atlas.ApplicationProperties; import org.apache.atlas.ApplicationProperties;
...@@ -42,11 +42,11 @@ import static org.testng.AssertJUnit.fail; ...@@ -42,11 +42,11 @@ import static org.testng.AssertJUnit.fail;
* Tests for AtlasRelationshipStoreV1 * Tests for AtlasRelationshipStoreV1
*/ */
@Guice(modules = TestModules.TestOnlyModule.class) @Guice(modules = TestModules.TestOnlyModule.class)
public class AtlasRelationshipDefStoreV1Test { public class AtlasRelationshipDefStoreV2Test {
@Inject @Inject
private private
AtlasRelationshipDefStoreV1 relationshipDefStore; AtlasRelationshipDefStoreV2 relationshipDefStore;
@DataProvider @DataProvider
public Object[][] invalidAttributeNameWithReservedKeywords(){ public Object[][] invalidAttributeNameWithReservedKeywords(){
...@@ -264,7 +264,7 @@ public class AtlasRelationshipDefStoreV1Test { ...@@ -264,7 +264,7 @@ public class AtlasRelationshipDefStoreV1Test {
@Test(dataProvider = "invalidAttributeNameWithReservedKeywords") @Test(dataProvider = "invalidAttributeNameWithReservedKeywords")
public void testCreateTypeWithReservedKeywords(AtlasRelationshipDef atlasRelationshipDef) throws AtlasException { public void testCreateTypeWithReservedKeywords(AtlasRelationshipDef atlasRelationshipDef) throws AtlasException {
try { try {
ApplicationProperties.get().setProperty(AtlasAbstractDefStoreV1.ALLOW_RESERVED_KEYWORDS, false); ApplicationProperties.get().setProperty(AtlasAbstractDefStoreV2.ALLOW_RESERVED_KEYWORDS, false);
relationshipDefStore.create(atlasRelationshipDef, null); relationshipDefStore.create(atlasRelationshipDef, null);
} catch (AtlasBaseException e) { } catch (AtlasBaseException e) {
Assert.assertEquals(e.getAtlasErrorCode(), AtlasErrorCode.ATTRIBUTE_NAME_INVALID); Assert.assertEquals(e.getAtlasErrorCode(), AtlasErrorCode.ATTRIBUTE_NAME_INVALID);
...@@ -273,14 +273,14 @@ public class AtlasRelationshipDefStoreV1Test { ...@@ -273,14 +273,14 @@ public class AtlasRelationshipDefStoreV1Test {
@Test(dataProvider = "updateValidProperties") @Test(dataProvider = "updateValidProperties")
public void testupdateVertexPreUpdatepropagateTags(AtlasRelationshipDef existingRelationshipDef,AtlasRelationshipDef newRelationshipDef) throws AtlasBaseException { public void testupdateVertexPreUpdatepropagateTags(AtlasRelationshipDef existingRelationshipDef,AtlasRelationshipDef newRelationshipDef) throws AtlasBaseException {
AtlasRelationshipDefStoreV1.preUpdateCheck(existingRelationshipDef,newRelationshipDef); AtlasRelationshipDefStoreV2.preUpdateCheck(existingRelationshipDef, newRelationshipDef);
} }
@Test(dataProvider = "updateRename") @Test(dataProvider = "updateRename")
public void testupdateVertexPreUpdateRename(AtlasRelationshipDef existingRelationshipDef,AtlasRelationshipDef newRelationshipDef) { public void testupdateVertexPreUpdateRename(AtlasRelationshipDef existingRelationshipDef,AtlasRelationshipDef newRelationshipDef) {
try { try {
AtlasRelationshipDefStoreV1.preUpdateCheck(existingRelationshipDef,newRelationshipDef); AtlasRelationshipDefStoreV2.preUpdateCheck(existingRelationshipDef, newRelationshipDef);
fail("expected error"); fail("expected error");
} catch (AtlasBaseException e) { } catch (AtlasBaseException e) {
if (!e.getAtlasErrorCode().equals(AtlasErrorCode.RELATIONSHIPDEF_INVALID_NAME_UPDATE)){ if (!e.getAtlasErrorCode().equals(AtlasErrorCode.RELATIONSHIPDEF_INVALID_NAME_UPDATE)){
...@@ -292,7 +292,7 @@ public class AtlasRelationshipDefStoreV1Test { ...@@ -292,7 +292,7 @@ public class AtlasRelationshipDefStoreV1Test {
public void testupdateVertexPreUpdateRelcat(AtlasRelationshipDef existingRelationshipDef,AtlasRelationshipDef newRelationshipDef) { public void testupdateVertexPreUpdateRelcat(AtlasRelationshipDef existingRelationshipDef,AtlasRelationshipDef newRelationshipDef) {
try { try {
AtlasRelationshipDefStoreV1.preUpdateCheck(existingRelationshipDef,newRelationshipDef); AtlasRelationshipDefStoreV2.preUpdateCheck(existingRelationshipDef, newRelationshipDef);
fail("expected error"); fail("expected error");
} catch (AtlasBaseException e) { } catch (AtlasBaseException e) {
if (!e.getAtlasErrorCode().equals(AtlasErrorCode.RELATIONSHIPDEF_INVALID_CATEGORY_UPDATE)){ if (!e.getAtlasErrorCode().equals(AtlasErrorCode.RELATIONSHIPDEF_INVALID_CATEGORY_UPDATE)){
...@@ -304,7 +304,7 @@ public class AtlasRelationshipDefStoreV1Test { ...@@ -304,7 +304,7 @@ public class AtlasRelationshipDefStoreV1Test {
public void testupdateVertexPreUpdateEnd1(AtlasRelationshipDef existingRelationshipDef,AtlasRelationshipDef newRelationshipDef) { public void testupdateVertexPreUpdateEnd1(AtlasRelationshipDef existingRelationshipDef,AtlasRelationshipDef newRelationshipDef) {
try { try {
AtlasRelationshipDefStoreV1.preUpdateCheck(existingRelationshipDef,newRelationshipDef); AtlasRelationshipDefStoreV2.preUpdateCheck(existingRelationshipDef, newRelationshipDef);
fail("expected error"); fail("expected error");
} catch (AtlasBaseException e) { } catch (AtlasBaseException e) {
if (!e.getAtlasErrorCode().equals(AtlasErrorCode.RELATIONSHIPDEF_INVALID_END1_UPDATE)){ if (!e.getAtlasErrorCode().equals(AtlasErrorCode.RELATIONSHIPDEF_INVALID_END1_UPDATE)){
...@@ -317,7 +317,7 @@ public class AtlasRelationshipDefStoreV1Test { ...@@ -317,7 +317,7 @@ public class AtlasRelationshipDefStoreV1Test {
public void testupdateVertexPreUpdateEnd2(AtlasRelationshipDef existingRelationshipDef,AtlasRelationshipDef newRelationshipDef) { public void testupdateVertexPreUpdateEnd2(AtlasRelationshipDef existingRelationshipDef,AtlasRelationshipDef newRelationshipDef) {
try { try {
AtlasRelationshipDefStoreV1.preUpdateCheck(existingRelationshipDef,newRelationshipDef); AtlasRelationshipDefStoreV2.preUpdateCheck(existingRelationshipDef, newRelationshipDef);
fail("expected error"); fail("expected error");
} catch (AtlasBaseException e) { } catch (AtlasBaseException e) {
if (!e.getAtlasErrorCode().equals(AtlasErrorCode.RELATIONSHIPDEF_INVALID_END2_UPDATE)){ if (!e.getAtlasErrorCode().equals(AtlasErrorCode.RELATIONSHIPDEF_INVALID_END2_UPDATE)){
......
...@@ -15,12 +15,13 @@ ...@@ -15,12 +15,13 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.apache.atlas.repository.store.graph.v1; package org.apache.atlas.repository.store.graph.v2;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import org.apache.atlas.TestModules; import org.apache.atlas.TestModules;
import org.apache.atlas.model.instance.AtlasEntity; import org.apache.atlas.model.instance.AtlasEntity;
import org.apache.atlas.model.instance.AtlasObjectId; import org.apache.atlas.model.instance.AtlasObjectId;
import org.apache.atlas.repository.store.graph.v1.HardDeleteHandlerV1;
import org.testng.annotations.Guice; import org.testng.annotations.Guice;
import java.util.List; import java.util.List;
...@@ -34,7 +35,7 @@ import static org.testng.Assert.assertNull; ...@@ -34,7 +35,7 @@ import static org.testng.Assert.assertNull;
* Inverse reference update test with {@link HardDeleteHandlerV1} * Inverse reference update test with {@link HardDeleteHandlerV1}
*/ */
@Guice(modules = TestModules.HardDeleteModule.class) @Guice(modules = TestModules.HardDeleteModule.class)
public class AtlasRelationshipStoreHardDeleteV1Test extends AtlasRelationshipStoreV1Test { public class AtlasRelationshipStoreHardDeleteV2Test extends AtlasRelationshipStoreV2Test {
@Override @Override
protected void verifyRelationshipAttributeUpdate_NonComposite_OneToMany(AtlasEntity jane) throws Exception { protected void verifyRelationshipAttributeUpdate_NonComposite_OneToMany(AtlasEntity jane) throws Exception {
......
...@@ -15,12 +15,13 @@ ...@@ -15,12 +15,13 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.apache.atlas.repository.store.graph.v1; package org.apache.atlas.repository.store.graph.v2;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import org.apache.atlas.TestModules; import org.apache.atlas.TestModules;
import org.apache.atlas.model.instance.AtlasEntity; import org.apache.atlas.model.instance.AtlasEntity;
import org.apache.atlas.model.instance.AtlasObjectId; import org.apache.atlas.model.instance.AtlasObjectId;
import org.apache.atlas.repository.store.graph.v1.SoftDeleteHandlerV1;
import org.testng.annotations.Guice; import org.testng.annotations.Guice;
import java.util.List; import java.util.List;
...@@ -34,7 +35,7 @@ import static org.testng.Assert.assertNotNull; ...@@ -34,7 +35,7 @@ import static org.testng.Assert.assertNotNull;
* Inverse reference update test with {@link SoftDeleteHandlerV1} * Inverse reference update test with {@link SoftDeleteHandlerV1}
*/ */
@Guice(modules = TestModules.SoftDeleteModule.class) @Guice(modules = TestModules.SoftDeleteModule.class)
public class AtlasRelationshipStoreSoftDeleteV1Test extends AtlasRelationshipStoreV1Test { public class AtlasRelationshipStoreSoftDeleteV2Test extends AtlasRelationshipStoreV2Test {
@Override @Override
protected void verifyRelationshipAttributeUpdate_NonComposite_OneToMany(AtlasEntity jane) throws Exception { protected void verifyRelationshipAttributeUpdate_NonComposite_OneToMany(AtlasEntity jane) throws Exception {
......
...@@ -15,11 +15,10 @@ ...@@ -15,11 +15,10 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.apache.atlas.repository.store.graph.v1; package org.apache.atlas.repository.store.graph.v2;
import org.apache.commons.configuration.Configuration;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import org.apache.atlas.RequestContextV1; import org.apache.atlas.RequestContext;
import org.apache.atlas.TestModules; import org.apache.atlas.TestModules;
import org.apache.atlas.TestUtilsV2; import org.apache.atlas.TestUtilsV2;
import org.apache.atlas.exception.AtlasBaseException; import org.apache.atlas.exception.AtlasBaseException;
...@@ -36,6 +35,7 @@ import org.apache.atlas.repository.graph.GraphBackedSearchIndexer; ...@@ -36,6 +35,7 @@ import org.apache.atlas.repository.graph.GraphBackedSearchIndexer;
import org.apache.atlas.repository.store.bootstrap.AtlasTypeDefStoreInitializer; import org.apache.atlas.repository.store.bootstrap.AtlasTypeDefStoreInitializer;
import org.apache.atlas.repository.store.graph.AtlasEntityStore; import org.apache.atlas.repository.store.graph.AtlasEntityStore;
import org.apache.atlas.repository.store.graph.AtlasRelationshipStore; import org.apache.atlas.repository.store.graph.AtlasRelationshipStore;
import org.apache.atlas.repository.store.graph.v1.DeleteHandlerV1;
import org.apache.atlas.runner.LocalSolrRunner; import org.apache.atlas.runner.LocalSolrRunner;
import org.apache.atlas.store.AtlasTypeDefStore; import org.apache.atlas.store.AtlasTypeDefStore;
import org.apache.atlas.type.AtlasEntityType; import org.apache.atlas.type.AtlasEntityType;
...@@ -68,7 +68,7 @@ import static org.testng.Assert.assertNull; ...@@ -68,7 +68,7 @@ import static org.testng.Assert.assertNull;
import static org.testng.Assert.assertTrue; import static org.testng.Assert.assertTrue;
@Guice(modules = TestModules.TestOnlyModule.class) @Guice(modules = TestModules.TestOnlyModule.class)
public abstract class AtlasRelationshipStoreV1Test { public abstract class AtlasRelationshipStoreV2Test {
@Inject @Inject
AtlasTypeRegistry typeRegistry; AtlasTypeRegistry typeRegistry;
...@@ -118,11 +118,11 @@ public abstract class AtlasRelationshipStoreV1Test { ...@@ -118,11 +118,11 @@ public abstract class AtlasRelationshipStoreV1Test {
@BeforeTest @BeforeTest
public void init() throws Exception { public void init() throws Exception {
entityStore = new AtlasEntityStoreV1(deleteHandler, typeRegistry, mockChangeNotifier, graphMapper); entityStore = new AtlasEntityStoreV2(deleteHandler, typeRegistry, mockChangeNotifier, graphMapper);
relationshipStore = new AtlasRelationshipStoreV1(typeRegistry, deleteHandler, entityNotifier); relationshipStore = new AtlasRelationshipStoreV2(typeRegistry, deleteHandler, entityNotifier);
RequestContextV1.clear(); RequestContext.clear();
RequestContextV1.get().setUser(TestUtilsV2.TEST_USER, null); RequestContext.get().setUser(TestUtilsV2.TEST_USER, null);
} }
@AfterClass @AfterClass
......
...@@ -15,12 +15,13 @@ ...@@ -15,12 +15,13 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.apache.atlas.repository.store.graph.v1; package org.apache.atlas.repository.store.graph.v2;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import org.apache.atlas.TestModules; import org.apache.atlas.TestModules;
import org.apache.atlas.model.instance.AtlasEntity; import org.apache.atlas.model.instance.AtlasEntity;
import org.apache.atlas.model.instance.AtlasObjectId; import org.apache.atlas.model.instance.AtlasObjectId;
import org.apache.atlas.repository.store.graph.v1.HardDeleteHandlerV1;
import org.apache.atlas.type.AtlasTypeUtil; import org.apache.atlas.type.AtlasTypeUtil;
import org.testng.annotations.Guice; import org.testng.annotations.Guice;
...@@ -33,7 +34,7 @@ import static org.testng.Assert.assertTrue; ...@@ -33,7 +34,7 @@ import static org.testng.Assert.assertTrue;
* Inverse reference update test with {@link HardDeleteHandlerV1} * Inverse reference update test with {@link HardDeleteHandlerV1}
*/ */
@Guice(modules = TestModules.HardDeleteModule.class) @Guice(modules = TestModules.HardDeleteModule.class)
public class InverseReferenceUpdateHardDeleteV1Test extends InverseReferenceUpdateV1Test { public class InverseReferenceUpdateHardDeleteV2Test extends InverseReferenceUpdateV2Test {
@Override @Override
protected void verify_testInverseReferenceAutoUpdate_NonComposite_OneToMany(AtlasEntity jane) throws Exception { protected void verify_testInverseReferenceAutoUpdate_NonComposite_OneToMany(AtlasEntity jane) throws Exception {
......
...@@ -15,12 +15,13 @@ ...@@ -15,12 +15,13 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.apache.atlas.repository.store.graph.v1; package org.apache.atlas.repository.store.graph.v2;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import org.apache.atlas.TestModules; import org.apache.atlas.TestModules;
import org.apache.atlas.model.instance.AtlasEntity; import org.apache.atlas.model.instance.AtlasEntity;
import org.apache.atlas.model.instance.AtlasObjectId; import org.apache.atlas.model.instance.AtlasObjectId;
import org.apache.atlas.repository.store.graph.v1.SoftDeleteHandlerV1;
import org.apache.atlas.type.AtlasTypeUtil; import org.apache.atlas.type.AtlasTypeUtil;
import org.testng.annotations.Guice; import org.testng.annotations.Guice;
...@@ -34,7 +35,7 @@ import static org.testng.Assert.assertTrue; ...@@ -34,7 +35,7 @@ import static org.testng.Assert.assertTrue;
* Inverse reference update test with {@link SoftDeleteHandlerV1} * Inverse reference update test with {@link SoftDeleteHandlerV1}
*/ */
@Guice(modules = TestModules.SoftDeleteModule.class) @Guice(modules = TestModules.SoftDeleteModule.class)
public class InverseReferenceUpdateSoftDeleteV1Test extends InverseReferenceUpdateV1Test { public class InverseReferenceUpdateSoftDeleteV2Test extends InverseReferenceUpdateV2Test {
@Override @Override
protected void verify_testInverseReferenceAutoUpdate_NonComposite_OneToMany(AtlasEntity jane) protected void verify_testInverseReferenceAutoUpdate_NonComposite_OneToMany(AtlasEntity jane)
......
...@@ -15,11 +15,11 @@ ...@@ -15,11 +15,11 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.apache.atlas.repository.store.graph.v1; package org.apache.atlas.repository.store.graph.v2;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import org.apache.atlas.RequestContextV1; import org.apache.atlas.RequestContext;
import org.apache.atlas.TestUtilsV2; import org.apache.atlas.TestUtilsV2;
import org.apache.atlas.model.instance.AtlasEntity; import org.apache.atlas.model.instance.AtlasEntity;
import org.apache.atlas.model.instance.AtlasEntity.AtlasEntitiesWithExtInfo; import org.apache.atlas.model.instance.AtlasEntity.AtlasEntitiesWithExtInfo;
...@@ -58,7 +58,7 @@ import static org.apache.atlas.TestUtilsV2.NAME; ...@@ -58,7 +58,7 @@ import static org.apache.atlas.TestUtilsV2.NAME;
* Test automatic inverse reference updating in V1 (V2?) code path. * Test automatic inverse reference updating in V1 (V2?) code path.
* *
*/ */
public abstract class InverseReferenceUpdateV1Test { public abstract class InverseReferenceUpdateV2Test {
@Inject @Inject
AtlasTypeRegistry typeRegistry; AtlasTypeRegistry typeRegistry;
...@@ -74,8 +74,8 @@ public abstract class InverseReferenceUpdateV1Test { ...@@ -74,8 +74,8 @@ public abstract class InverseReferenceUpdateV1Test {
@BeforeClass @BeforeClass
public void setUp() throws Exception { public void setUp() throws Exception {
RequestContextV1.clear(); RequestContext.clear();
RequestContextV1.get().setUser(TestUtilsV2.TEST_USER, null); RequestContext.get().setUser(TestUtilsV2.TEST_USER, null);
AtlasTypesDef[] testTypesDefs = new AtlasTypesDef[] { TestUtilsV2.defineDeptEmployeeTypes(), AtlasTypesDef[] testTypesDefs = new AtlasTypesDef[] { TestUtilsV2.defineDeptEmployeeTypes(),
TestUtilsV2.defineInverseReferenceTestTypes() TestUtilsV2.defineInverseReferenceTestTypes()
...@@ -108,8 +108,8 @@ public abstract class InverseReferenceUpdateV1Test { ...@@ -108,8 +108,8 @@ public abstract class InverseReferenceUpdateV1Test {
@BeforeMethod @BeforeMethod
public void init() throws Exception { public void init() throws Exception {
RequestContextV1.clear(); RequestContext.clear();
RequestContextV1.get().setUser(TestUtilsV2.TEST_USER, null); RequestContext.get().setUser(TestUtilsV2.TEST_USER, null);
} }
@Test @Test
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
*/ */
package org.apache.atlas.repository.tagpropagation; package org.apache.atlas.repository.tagpropagation;
import org.apache.atlas.RequestContextV1; import org.apache.atlas.RequestContext;
import org.apache.atlas.TestModules; import org.apache.atlas.TestModules;
import org.apache.atlas.discovery.AtlasLineageService; import org.apache.atlas.discovery.AtlasLineageService;
import org.apache.atlas.exception.AtlasBaseException; import org.apache.atlas.exception.AtlasBaseException;
...@@ -104,7 +104,7 @@ public class ClassificationPropagationTest { ...@@ -104,7 +104,7 @@ public class ClassificationPropagationTest {
@BeforeClass @BeforeClass
public void setup() { public void setup() {
RequestContextV1.clear(); RequestContext.clear();
loadModelFilesAndImportTestData(); loadModelFilesAndImportTestData();
} }
......
...@@ -27,10 +27,10 @@ import org.slf4j.LoggerFactory; ...@@ -27,10 +27,10 @@ import org.slf4j.LoggerFactory;
import java.util.*; import java.util.*;
public class RequestContextV1 { public class RequestContext {
private static final Logger LOG = LoggerFactory.getLogger(RequestContextV1.class); private static final Logger LOG = LoggerFactory.getLogger(RequestContext.class);
private static final ThreadLocal<RequestContextV1> CURRENT_CONTEXT = new ThreadLocal<>(); private static final ThreadLocal<RequestContext> CURRENT_CONTEXT = new ThreadLocal<>();
private final Map<String, AtlasObjectId> updatedEntities = new HashMap<>(); private final Map<String, AtlasObjectId> updatedEntities = new HashMap<>();
private final Map<String, AtlasObjectId> deletedEntities = new HashMap<>(); private final Map<String, AtlasObjectId> deletedEntities = new HashMap<>();
...@@ -44,16 +44,16 @@ public class RequestContextV1 { ...@@ -44,16 +44,16 @@ public class RequestContextV1 {
private String clientIPAddress; private String clientIPAddress;
private RequestContextV1() { private RequestContext() {
} }
//To handle gets from background threads where createContext() is not called //To handle gets from background threads where createContext() is not called
//createContext called for every request in the filter //createContext called for every request in the filter
public static RequestContextV1 get() { public static RequestContext get() {
RequestContextV1 ret = CURRENT_CONTEXT.get(); RequestContext ret = CURRENT_CONTEXT.get();
if (ret == null) { if (ret == null) {
ret = new RequestContextV1(); ret = new RequestContext();
CURRENT_CONTEXT.set(ret); CURRENT_CONTEXT.set(ret);
} }
...@@ -61,7 +61,7 @@ public class RequestContextV1 { ...@@ -61,7 +61,7 @@ public class RequestContextV1 {
} }
public static void clear() { public static void clear() {
RequestContextV1 instance = CURRENT_CONTEXT.get(); RequestContext instance = CURRENT_CONTEXT.get();
if (instance != null) { if (instance != null) {
instance.updatedEntities.clear(); instance.updatedEntities.clear();
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
package org.apache.atlas.notification; package org.apache.atlas.notification;
import org.apache.atlas.AtlasErrorCode; import org.apache.atlas.AtlasErrorCode;
import org.apache.atlas.RequestContextV1; import org.apache.atlas.RequestContext;
import org.apache.atlas.exception.AtlasBaseException; import org.apache.atlas.exception.AtlasBaseException;
import org.apache.atlas.listener.EntityChangeListenerV2; import org.apache.atlas.listener.EntityChangeListenerV2;
import org.apache.atlas.model.glossary.AtlasGlossaryTerm; import org.apache.atlas.model.glossary.AtlasGlossaryTerm;
...@@ -48,11 +48,11 @@ import java.util.Set; ...@@ -48,11 +48,11 @@ import java.util.Set;
import static org.apache.atlas.notification.NotificationInterface.NotificationType.ENTITIES; import static org.apache.atlas.notification.NotificationInterface.NotificationType.ENTITIES;
import static org.apache.atlas.repository.graph.GraphHelper.isInternalType; import static org.apache.atlas.repository.graph.GraphHelper.isInternalType;
import static org.apache.atlas.model.notification.EntityNotification.EntityNotificationV2.OperationType.*; import static org.apache.atlas.model.notification.EntityNotification.EntityNotificationV2.OperationType.*;
import static org.apache.atlas.repository.store.graph.v1.EntityGraphRetriever.CREATE_TIME; import static org.apache.atlas.repository.store.graph.v2.EntityGraphRetriever.CREATE_TIME;
import static org.apache.atlas.repository.store.graph.v1.EntityGraphRetriever.DESCRIPTION; import static org.apache.atlas.repository.store.graph.v2.EntityGraphRetriever.DESCRIPTION;
import static org.apache.atlas.repository.store.graph.v1.EntityGraphRetriever.NAME; import static org.apache.atlas.repository.store.graph.v2.EntityGraphRetriever.NAME;
import static org.apache.atlas.repository.store.graph.v1.EntityGraphRetriever.OWNER; import static org.apache.atlas.repository.store.graph.v2.EntityGraphRetriever.OWNER;
import static org.apache.atlas.repository.store.graph.v1.EntityGraphRetriever.QUALIFIED_NAME; import static org.apache.atlas.repository.store.graph.v2.EntityGraphRetriever.QUALIFIED_NAME;
@Component @Component
public class EntityNotificationListenerV2 implements EntityChangeListenerV2 { public class EntityNotificationListenerV2 implements EntityChangeListenerV2 {
...@@ -89,8 +89,8 @@ public class EntityNotificationListenerV2 implements EntityChangeListenerV2 { ...@@ -89,8 +89,8 @@ public class EntityNotificationListenerV2 implements EntityChangeListenerV2 {
@Override @Override
public void onClassificationsUpdated(AtlasEntity entity, List<AtlasClassification> classifications) throws AtlasBaseException { public void onClassificationsUpdated(AtlasEntity entity, List<AtlasClassification> classifications) throws AtlasBaseException {
Map<String, List<AtlasClassification>> addedPropagations = RequestContextV1.get().getAddedPropagations(); Map<String, List<AtlasClassification>> addedPropagations = RequestContext.get().getAddedPropagations();
Map<String, List<AtlasClassification>> removedPropagations = RequestContextV1.get().getRemovedPropagations(); Map<String, List<AtlasClassification>> removedPropagations = RequestContext.get().getRemovedPropagations();
if (addedPropagations.containsKey(entity.getGuid())) { if (addedPropagations.containsKey(entity.getGuid())) {
notifyEntityEvents(Collections.singletonList(entity), CLASSIFICATION_ADD); notifyEntityEvents(Collections.singletonList(entity), CLASSIFICATION_ADD);
......
...@@ -25,7 +25,7 @@ import org.apache.atlas.AtlasClient; ...@@ -25,7 +25,7 @@ import org.apache.atlas.AtlasClient;
import org.apache.atlas.AtlasClientV2; import org.apache.atlas.AtlasClientV2;
import org.apache.atlas.AtlasException; import org.apache.atlas.AtlasException;
import org.apache.atlas.AtlasServiceException; import org.apache.atlas.AtlasServiceException;
import org.apache.atlas.RequestContextV1; import org.apache.atlas.RequestContext;
import org.apache.atlas.ha.HAConfiguration; import org.apache.atlas.ha.HAConfiguration;
import org.apache.atlas.kafka.AtlasKafkaMessage; import org.apache.atlas.kafka.AtlasKafkaMessage;
import org.apache.atlas.listener.ActiveStateChangeHandler; import org.apache.atlas.listener.ActiveStateChangeHandler;
...@@ -45,8 +45,8 @@ import org.apache.atlas.v1.model.notification.HookNotificationV1.EntityPartialUp ...@@ -45,8 +45,8 @@ import org.apache.atlas.v1.model.notification.HookNotificationV1.EntityPartialUp
import org.apache.atlas.v1.model.notification.HookNotificationV1.EntityUpdateRequest; import org.apache.atlas.v1.model.notification.HookNotificationV1.EntityUpdateRequest;
import org.apache.atlas.repository.converters.AtlasInstanceConverter; import org.apache.atlas.repository.converters.AtlasInstanceConverter;
import org.apache.atlas.repository.store.graph.AtlasEntityStore; import org.apache.atlas.repository.store.graph.AtlasEntityStore;
import org.apache.atlas.repository.store.graph.v1.AtlasEntityStream; import org.apache.atlas.repository.store.graph.v2.AtlasEntityStream;
import org.apache.atlas.repository.store.graph.v1.AtlasGraphUtilsV1; import org.apache.atlas.repository.store.graph.v2.AtlasGraphUtilsV2;
import org.apache.atlas.service.Service; import org.apache.atlas.service.Service;
import org.apache.atlas.type.AtlasEntityType; import org.apache.atlas.type.AtlasEntityType;
import org.apache.atlas.type.AtlasTypeRegistry; import org.apache.atlas.type.AtlasTypeRegistry;
...@@ -55,7 +55,6 @@ import org.apache.atlas.web.filters.AuditFilter; ...@@ -55,7 +55,6 @@ import org.apache.atlas.web.filters.AuditFilter;
import org.apache.atlas.web.filters.AuditFilter.AuditLog; import org.apache.atlas.web.filters.AuditFilter.AuditLog;
import org.apache.atlas.web.service.ServiceState; import org.apache.atlas.web.service.ServiceState;
import org.apache.commons.configuration.Configuration; import org.apache.commons.configuration.Configuration;
import org.apache.kafka.common.KafkaException;
import org.apache.kafka.common.TopicPartition; import org.apache.kafka.common.TopicPartition;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -75,7 +74,7 @@ import java.util.concurrent.atomic.AtomicBoolean; ...@@ -75,7 +74,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
*/ */
@Component @Component
@Order(4) @Order(4)
@DependsOn(value = {"atlasTypeDefStoreInitializer", "atlasTypeDefGraphStoreV1"}) @DependsOn(value = {"atlasTypeDefStoreInitializer", "atlasTypeDefGraphStoreV2"})
public class NotificationHookConsumer implements Service, ActiveStateChangeHandler { public class NotificationHookConsumer implements Service, ActiveStateChangeHandler {
private static final Logger LOG = LoggerFactory.getLogger(NotificationHookConsumer.class); private static final Logger LOG = LoggerFactory.getLogger(NotificationHookConsumer.class);
private static final Logger PERF_LOG = AtlasPerfTracer.getPerfLogger(NotificationHookConsumer.class); private static final Logger PERF_LOG = AtlasPerfTracer.getPerfLogger(NotificationHookConsumer.class);
...@@ -375,7 +374,7 @@ public class NotificationHookConsumer implements Service, ActiveStateChangeHandl ...@@ -375,7 +374,7 @@ public class NotificationHookConsumer implements Service, ActiveStateChangeHandl
} }
try { try {
RequestContextV1 requestContext = RequestContextV1.get(); RequestContext requestContext = RequestContext.get();
requestContext.setUser(messageUser, null); requestContext.setUser(messageUser, null);
...@@ -406,7 +405,7 @@ public class NotificationHookConsumer implements Service, ActiveStateChangeHandl ...@@ -406,7 +405,7 @@ public class NotificationHookConsumer implements Service, ActiveStateChangeHandl
} }
AtlasEntityType entityType = typeRegistry.getEntityTypeByName(partialUpdateRequest.getTypeName()); AtlasEntityType entityType = typeRegistry.getEntityTypeByName(partialUpdateRequest.getTypeName());
String guid = AtlasGraphUtilsV1.getGuidByUniqueAttributes(entityType, Collections.singletonMap(partialUpdateRequest.getAttribute(), (Object)partialUpdateRequest.getAttributeValue())); String guid = AtlasGraphUtilsV2.getGuidByUniqueAttributes(entityType, Collections.singletonMap(partialUpdateRequest.getAttribute(), (Object)partialUpdateRequest.getAttributeValue()));
// There should only be one root entity // There should only be one root entity
entities.getEntities().get(0).setGuid(guid); entities.getEntities().get(0).setGuid(guid);
...@@ -541,7 +540,7 @@ public class NotificationHookConsumer implements Service, ActiveStateChangeHandl ...@@ -541,7 +540,7 @@ public class NotificationHookConsumer implements Service, ActiveStateChangeHandl
return; return;
} }
} finally { } finally {
RequestContextV1.clear(); RequestContext.clear();
} }
} }
......
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
package org.apache.atlas.web.filters; package org.apache.atlas.web.filters;
import org.apache.atlas.ApplicationProperties; import org.apache.atlas.ApplicationProperties;
import org.apache.atlas.RequestContextV1;
import org.apache.atlas.security.SecurityProperties; import org.apache.atlas.security.SecurityProperties;
import org.apache.atlas.utils.AuthenticationUtil; import org.apache.atlas.utils.AuthenticationUtil;
import org.apache.atlas.web.security.AtlasAuthenticationProvider; import org.apache.atlas.web.security.AtlasAuthenticationProvider;
......
...@@ -20,7 +20,7 @@ package org.apache.atlas.web.filters; ...@@ -20,7 +20,7 @@ package org.apache.atlas.web.filters;
import org.apache.atlas.AtlasClient; import org.apache.atlas.AtlasClient;
import org.apache.atlas.AtlasException; import org.apache.atlas.AtlasException;
import org.apache.atlas.RequestContextV1; import org.apache.atlas.RequestContext;
import org.apache.atlas.authorize.AtlasAuthorizationUtils; import org.apache.atlas.authorize.AtlasAuthorizationUtils;
import org.apache.atlas.util.AtlasRepositoryConfiguration; import org.apache.atlas.util.AtlasRepositoryConfiguration;
import org.apache.atlas.web.util.DateTimeHelper; import org.apache.atlas.web.util.DateTimeHelper;
...@@ -73,8 +73,8 @@ public class AuditFilter implements Filter { ...@@ -73,8 +73,8 @@ public class AuditFilter implements Filter {
try { try {
currentThread.setName(formatName(oldName, requestId)); currentThread.setName(formatName(oldName, requestId));
RequestContextV1.clear(); RequestContext.clear();
RequestContextV1 requestContext = RequestContextV1.get(); RequestContext requestContext = RequestContext.get();
requestContext.setUser(user, userGroups); requestContext.setUser(user, userGroups);
requestContext.setClientIPAddress(AtlasAuthorizationUtils.getRequestIpAddress(httpRequest)); requestContext.setClientIPAddress(AtlasAuthorizationUtils.getRequestIpAddress(httpRequest));
filterChain.doFilter(request, response); filterChain.doFilter(request, response);
...@@ -86,7 +86,7 @@ public class AuditFilter implements Filter { ...@@ -86,7 +86,7 @@ public class AuditFilter implements Filter {
// put the request id into the response so users can trace logs for this request // put the request id into the response so users can trace logs for this request
httpResponse.setHeader(AtlasClient.REQUEST_ID, requestId); httpResponse.setHeader(AtlasClient.REQUEST_ID, requestId);
currentThread.setName(oldName); currentThread.setName(oldName);
RequestContextV1.clear(); RequestContext.clear();
} }
} }
......
...@@ -38,8 +38,8 @@ import org.apache.atlas.model.legacy.EntityResult; ...@@ -38,8 +38,8 @@ import org.apache.atlas.model.legacy.EntityResult;
import org.apache.atlas.repository.audit.EntityAuditRepository; import org.apache.atlas.repository.audit.EntityAuditRepository;
import org.apache.atlas.repository.converters.AtlasInstanceConverter; import org.apache.atlas.repository.converters.AtlasInstanceConverter;
import org.apache.atlas.repository.store.graph.AtlasEntityStore; import org.apache.atlas.repository.store.graph.AtlasEntityStore;
import org.apache.atlas.repository.store.graph.v1.AtlasEntityStream; import org.apache.atlas.repository.store.graph.v2.AtlasEntityStream;
import org.apache.atlas.repository.store.graph.v1.AtlasGraphUtilsV1; import org.apache.atlas.repository.store.graph.v2.AtlasGraphUtilsV2;
import org.apache.atlas.type.AtlasEntityType; import org.apache.atlas.type.AtlasEntityType;
import org.apache.atlas.type.AtlasType; import org.apache.atlas.type.AtlasType;
import org.apache.atlas.type.AtlasTypeRegistry; import org.apache.atlas.type.AtlasTypeRegistry;
...@@ -382,7 +382,7 @@ public class EntityResource { ...@@ -382,7 +382,7 @@ public class EntityResource {
Id updateId = updatedEntity.getId(); Id updateId = updatedEntity.getId();
if (updateId != null && !AtlasTypeUtil.isAssignedGuid(updateId.getId())) { if (updateId != null && !AtlasTypeUtil.isAssignedGuid(updateId.getId())) {
String guid = AtlasGraphUtilsV1.getGuidByUniqueAttributes(getEntityType(entityType), attributes); String guid = AtlasGraphUtilsV2.getGuidByUniqueAttributes(getEntityType(entityType), attributes);
updatedEntity.setId(new Id(guid, 0, updatedEntity.getTypeName())); updatedEntity.setId(new Id(guid, 0, updatedEntity.getTypeName()));
} }
......
...@@ -23,7 +23,6 @@ import org.apache.atlas.model.audit.EntityAuditEventV2; ...@@ -23,7 +23,6 @@ import org.apache.atlas.model.audit.EntityAuditEventV2;
import org.apache.atlas.exception.AtlasBaseException; import org.apache.atlas.exception.AtlasBaseException;
import org.apache.atlas.model.TypeCategory; import org.apache.atlas.model.TypeCategory;
import org.apache.atlas.model.instance.AtlasClassification; import org.apache.atlas.model.instance.AtlasClassification;
import org.apache.atlas.model.instance.AtlasEntity;
import org.apache.atlas.model.instance.AtlasEntity.AtlasEntitiesWithExtInfo; import org.apache.atlas.model.instance.AtlasEntity.AtlasEntitiesWithExtInfo;
import org.apache.atlas.model.instance.AtlasEntity.AtlasEntityWithExtInfo; import org.apache.atlas.model.instance.AtlasEntity.AtlasEntityWithExtInfo;
import org.apache.atlas.model.instance.ClassificationAssociateRequest; import org.apache.atlas.model.instance.ClassificationAssociateRequest;
...@@ -32,8 +31,8 @@ import org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef; ...@@ -32,8 +31,8 @@ import org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef;
import org.apache.atlas.repository.audit.EntityAuditRepository; import org.apache.atlas.repository.audit.EntityAuditRepository;
import org.apache.atlas.repository.converters.AtlasInstanceConverter; import org.apache.atlas.repository.converters.AtlasInstanceConverter;
import org.apache.atlas.repository.store.graph.AtlasEntityStore; import org.apache.atlas.repository.store.graph.AtlasEntityStore;
import org.apache.atlas.repository.store.graph.v1.AtlasEntityStream; import org.apache.atlas.repository.store.graph.v2.AtlasEntityStream;
import org.apache.atlas.repository.store.graph.v1.EntityStream; import org.apache.atlas.repository.store.graph.v2.EntityStream;
import org.apache.atlas.type.AtlasClassificationType; import org.apache.atlas.type.AtlasClassificationType;
import org.apache.atlas.type.AtlasEntityType; import org.apache.atlas.type.AtlasEntityType;
import org.apache.atlas.type.AtlasTypeRegistry; import org.apache.atlas.type.AtlasTypeRegistry;
......
...@@ -29,7 +29,7 @@ import org.apache.atlas.v1.model.instance.Referenceable; ...@@ -29,7 +29,7 @@ import org.apache.atlas.v1.model.instance.Referenceable;
import org.apache.atlas.v1.model.notification.HookNotificationV1; import org.apache.atlas.v1.model.notification.HookNotificationV1;
import org.apache.atlas.repository.converters.AtlasInstanceConverter; import org.apache.atlas.repository.converters.AtlasInstanceConverter;
import org.apache.atlas.repository.store.graph.AtlasEntityStore; import org.apache.atlas.repository.store.graph.AtlasEntityStore;
import org.apache.atlas.repository.store.graph.v1.EntityStream; import org.apache.atlas.repository.store.graph.v2.EntityStream;
import org.apache.atlas.type.AtlasType; import org.apache.atlas.type.AtlasType;
import org.apache.atlas.type.AtlasTypeRegistry; import org.apache.atlas.type.AtlasTypeRegistry;
import org.apache.atlas.web.service.ServiceState; import org.apache.atlas.web.service.ServiceState;
......
...@@ -30,7 +30,7 @@ import org.apache.atlas.v1.model.instance.Referenceable; ...@@ -30,7 +30,7 @@ import org.apache.atlas.v1.model.instance.Referenceable;
import org.apache.atlas.v1.model.notification.HookNotificationV1.EntityCreateRequest; import org.apache.atlas.v1.model.notification.HookNotificationV1.EntityCreateRequest;
import org.apache.atlas.repository.converters.AtlasInstanceConverter; import org.apache.atlas.repository.converters.AtlasInstanceConverter;
import org.apache.atlas.repository.store.graph.AtlasEntityStore; import org.apache.atlas.repository.store.graph.AtlasEntityStore;
import org.apache.atlas.repository.store.graph.v1.EntityStream; import org.apache.atlas.repository.store.graph.v2.EntityStream;
import org.apache.atlas.type.AtlasType; import org.apache.atlas.type.AtlasType;
import org.apache.atlas.type.AtlasTypeRegistry; import org.apache.atlas.type.AtlasTypeRegistry;
import org.apache.atlas.web.service.ServiceState; import org.apache.atlas.web.service.ServiceState;
......
...@@ -33,9 +33,9 @@ import org.apache.atlas.model.typedef.AtlasTypesDef; ...@@ -33,9 +33,9 @@ import org.apache.atlas.model.typedef.AtlasTypesDef;
import org.apache.atlas.repository.Constants; import org.apache.atlas.repository.Constants;
import org.apache.atlas.repository.converters.TypeConverterUtil; import org.apache.atlas.repository.converters.TypeConverterUtil;
import org.apache.atlas.repository.graphdb.AtlasVertex; import org.apache.atlas.repository.graphdb.AtlasVertex;
import org.apache.atlas.repository.store.graph.v1.AtlasGraphUtilsV1; import org.apache.atlas.repository.store.graph.v2.AtlasGraphUtilsV2;
import org.apache.atlas.repository.store.graph.v1.AtlasStructDefStoreV1; import org.apache.atlas.repository.store.graph.v2.AtlasStructDefStoreV2;
import org.apache.atlas.repository.store.graph.v1.AtlasTypeDefGraphStoreV1; import org.apache.atlas.repository.store.graph.v2.AtlasTypeDefGraphStoreV2;
import org.apache.atlas.type.AtlasEntityType; import org.apache.atlas.type.AtlasEntityType;
import org.apache.atlas.type.AtlasStructType; import org.apache.atlas.type.AtlasStructType;
import org.apache.atlas.type.AtlasStructType.AtlasAttribute; import org.apache.atlas.type.AtlasStructType.AtlasAttribute;
...@@ -87,8 +87,8 @@ public class RestUtilsTest { ...@@ -87,8 +87,8 @@ public class RestUtilsTest {
testV1toV2toV1Conversion(Arrays.asList(dbV1Type, tableV1Type), new boolean[] { false, false }); testV1toV2toV1Conversion(Arrays.asList(dbV1Type, tableV1Type), new boolean[] { false, false });
} }
private AtlasTypeDefGraphStoreV1 makeTypeStore(AtlasTypeRegistry reg) { private AtlasTypeDefGraphStoreV2 makeTypeStore(AtlasTypeRegistry reg) {
AtlasTypeDefGraphStoreV1 result = mock(AtlasTypeDefGraphStoreV1.class); AtlasTypeDefGraphStoreV2 result = mock(AtlasTypeDefGraphStoreV2.class);
for (AtlasEntityType type : reg.getAllEntityTypes()) { for (AtlasEntityType type : reg.getAllEntityTypes()) {
String typeName = type.getTypeName(); String typeName = type.getTypeName();
...@@ -97,13 +97,13 @@ public class RestUtilsTest { ...@@ -97,13 +97,13 @@ public class RestUtilsTest {
when(result.isTypeVertex(eq(typeVertex), any(TypeCategory.class))).thenReturn(true); when(result.isTypeVertex(eq(typeVertex), any(TypeCategory.class))).thenReturn(true);
when(typeVertex.getProperty(eq(Constants.TYPE_CATEGORY_PROPERTY_KEY), eq(TypeCategory.class))).thenReturn(TypeCategory.CLASS); when(typeVertex.getProperty(eq(Constants.TYPE_CATEGORY_PROPERTY_KEY), eq(TypeCategory.class))).thenReturn(TypeCategory.CLASS);
String attributeListPropertyKey = AtlasGraphUtilsV1.getTypeDefPropertyKey(typeName); String attributeListPropertyKey = AtlasGraphUtilsV2.getTypeDefPropertyKey(typeName);
when(typeVertex.getProperty(eq(attributeListPropertyKey), eq(List.class))).thenReturn(new ArrayList<>(type.getAllAttributes().keySet())); when(typeVertex.getProperty(eq(attributeListPropertyKey), eq(List.class))).thenReturn(new ArrayList<>(type.getAllAttributes().keySet()));
for (AtlasAttribute attribute : type.getAllAttributes().values()) { for (AtlasAttribute attribute : type.getAllAttributes().values()) {
String attributeDefPropertyKey = AtlasGraphUtilsV1.getTypeDefPropertyKey(typeName, attribute.getName()); String attributeDefPropertyKey = AtlasGraphUtilsV2.getTypeDefPropertyKey(typeName, attribute.getName());
String attributeJson = AtlasStructDefStoreV1.toJsonFromAttribute(attribute); String attributeJson = AtlasStructDefStoreV2.toJsonFromAttribute(attribute);
when(typeVertex.getProperty(eq(attributeDefPropertyKey), eq(String.class))).thenReturn(attributeJson); when(typeVertex.getProperty(eq(attributeDefPropertyKey), eq(String.class))).thenReturn(attributeJson);
} }
...@@ -115,15 +115,15 @@ public class RestUtilsTest { ...@@ -115,15 +115,15 @@ public class RestUtilsTest {
} }
private AtlasAttributeDef convertToJsonAndBack(AtlasTypeRegistry registry, AtlasStructDef structDef, AtlasAttributeDef attributeDef, boolean compositeExpected) throws AtlasBaseException { private AtlasAttributeDef convertToJsonAndBack(AtlasTypeRegistry registry, AtlasStructDef structDef, AtlasAttributeDef attributeDef, boolean compositeExpected) throws AtlasBaseException {
AtlasTypeDefGraphStoreV1 typeDefStore = makeTypeStore(registry); AtlasTypeDefGraphStoreV2 typeDefStore = makeTypeStore(registry);
AtlasStructType structType = (AtlasStructType) registry.getType(structDef.getName()); AtlasStructType structType = (AtlasStructType) registry.getType(structDef.getName());
AtlasAttribute attribute = structType.getAttribute(attributeDef.getName()); AtlasAttribute attribute = structType.getAttribute(attributeDef.getName());
String attribJson = AtlasStructDefStoreV1.toJsonFromAttribute(attribute); String attribJson = AtlasStructDefStoreV2.toJsonFromAttribute(attribute);
Map attrInfo = AtlasType.fromJson(attribJson, Map.class); Map attrInfo = AtlasType.fromJson(attribJson, Map.class);
Assert.assertEquals(attrInfo.get("isComposite"), compositeExpected); Assert.assertEquals(attrInfo.get("isComposite"), compositeExpected);
return AtlasStructDefStoreV1.toAttributeDefFromJson(structDef, attrInfo, typeDefStore); return AtlasStructDefStoreV2.toAttributeDefFromJson(structDef, attrInfo, typeDefStore);
} }
private void testV1toV2toV1Conversion(List<ClassTypeDefinition> typesToTest, boolean[] compositeExpected) throws AtlasBaseException { private void testV1toV2toV1Conversion(List<ClassTypeDefinition> typesToTest, boolean[] compositeExpected) throws AtlasBaseException {
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
package org.apache.atlas.web.adapters; package org.apache.atlas.web.adapters;
import org.apache.atlas.AtlasClient; import org.apache.atlas.AtlasClient;
import org.apache.atlas.RequestContextV1; import org.apache.atlas.RequestContext;
import org.apache.atlas.TestModules; import org.apache.atlas.TestModules;
import org.apache.atlas.TestUtilsV2; import org.apache.atlas.TestUtilsV2;
import org.apache.atlas.model.instance.AtlasClassification; import org.apache.atlas.model.instance.AtlasClassification;
...@@ -98,7 +98,7 @@ public class TestEntitiesREST { ...@@ -98,7 +98,7 @@ public class TestEntitiesREST {
@AfterMethod @AfterMethod
public void cleanup() throws Exception { public void cleanup() throws Exception {
RequestContextV1.clear(); RequestContext.clear();
} }
@Test @Test
......
...@@ -17,8 +17,8 @@ ...@@ -17,8 +17,8 @@
*/ */
package org.apache.atlas.web.adapters; package org.apache.atlas.web.adapters;
import org.apache.atlas.RequestContext;
import org.apache.atlas.TestModules; import org.apache.atlas.TestModules;
import org.apache.atlas.RequestContextV1;
import org.apache.atlas.TestUtilsV2; import org.apache.atlas.TestUtilsV2;
import org.apache.atlas.model.instance.AtlasClassification; import org.apache.atlas.model.instance.AtlasClassification;
import org.apache.atlas.model.instance.AtlasClassification.AtlasClassifications; import org.apache.atlas.model.instance.AtlasClassification.AtlasClassifications;
...@@ -77,7 +77,7 @@ public class TestEntityREST { ...@@ -77,7 +77,7 @@ public class TestEntityREST {
@AfterMethod @AfterMethod
public void cleanup() throws Exception { public void cleanup() throws Exception {
RequestContextV1.clear(); RequestContext.clear();
} }
private void createTestEntity() throws Exception { private void createTestEntity() throws Exception {
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
*/ */
package org.apache.atlas.web.filters; package org.apache.atlas.web.filters;
import org.apache.atlas.RequestContextV1; import org.apache.atlas.RequestContext;
import org.apache.atlas.web.security.BaseSecurityTest; import org.apache.atlas.web.security.BaseSecurityTest;
import org.apache.atlas.web.service.EmbeddedServer; import org.apache.atlas.web.service.EmbeddedServer;
import org.apache.commons.configuration.PropertiesConfiguration; import org.apache.commons.configuration.PropertiesConfiguration;
...@@ -111,7 +111,7 @@ public class AtlasAuthenticationKerberosFilterTest extends BaseSecurityTest { ...@@ -111,7 +111,7 @@ public class AtlasAuthenticationKerberosFilterTest extends BaseSecurityTest {
connection.connect(); connection.connect();
assertEquals(connection.getResponseCode(), 200); assertEquals(connection.getResponseCode(), 200);
assertEquals(RequestContextV1.get().getUser(), TESTUSER); assertEquals(RequestContext.get().getUser(), TESTUSER);
return null; return null;
} }
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment