You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@atlas.apache.org by ma...@apache.org on 2017/02/08 04:02:08 UTC
[1/3] incubator-atlas git commit: ATLAS-1523: v2 implementation of
get-entity by-guid/unique-attributes
Repository: incubator-atlas
Updated Branches:
refs/heads/master 48477e208 -> dd7447658
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/808eb1d1/webapp/src/main/java/org/apache/atlas/examples/QuickStartV2.java
----------------------------------------------------------------------
diff --git a/webapp/src/main/java/org/apache/atlas/examples/QuickStartV2.java b/webapp/src/main/java/org/apache/atlas/examples/QuickStartV2.java
index 0459061..ea6d217 100755
--- a/webapp/src/main/java/org/apache/atlas/examples/QuickStartV2.java
+++ b/webapp/src/main/java/org/apache/atlas/examples/QuickStartV2.java
@@ -34,12 +34,8 @@ import org.apache.atlas.model.SearchFilter;
import org.apache.atlas.model.discovery.AtlasSearchResult;
import org.apache.atlas.model.discovery.AtlasSearchResult.AtlasFullTextResult;
import org.apache.atlas.model.discovery.AtlasSearchResult.AttributeSearchResult;
-import org.apache.atlas.model.instance.AtlasClassification;
-import org.apache.atlas.model.instance.AtlasEntity;
-import org.apache.atlas.model.instance.AtlasEntityHeader;
-import org.apache.atlas.model.instance.AtlasEntityHeaderWithAssociations;
-import org.apache.atlas.model.instance.AtlasEntityWithAssociations;
-import org.apache.atlas.model.instance.EntityMutationResponse;
+import org.apache.atlas.model.instance.*;
+import org.apache.atlas.model.instance.AtlasEntity.AtlasEntityWithExtInfo;
import org.apache.atlas.model.instance.EntityMutations.EntityOperation;
import org.apache.atlas.model.lineage.AtlasLineageInfo;
import org.apache.atlas.model.lineage.AtlasLineageInfo.LineageDirection;
@@ -57,11 +53,7 @@ import org.apache.commons.configuration.Configuration;
import org.apache.commons.lang.ArrayUtils;
import javax.ws.rs.core.MultivaluedMap;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
import static org.apache.atlas.model.typedef.AtlasStructDef.AtlasConstraintDef.CONSTRAINT_TYPE_INVERSE_REF;
import static org.apache.atlas.model.typedef.AtlasStructDef.AtlasConstraintDef.CONSTRAINT_TYPE_OWNED_REF;
@@ -227,7 +219,7 @@ public class QuickStartV2 {
AtlasTypeUtil.createOptionalAttrDef("dataType", "string"),
AtlasTypeUtil.createOptionalAttrDef("comment", "string"),
AtlasTypeUtil.createOptionalAttrDefWithConstraint("table", TABLE_TYPE, CONSTRAINT_TYPE_INVERSE_REF,
- new HashMap<String, Object>() {{ put(CONSTRAINT_PARAM_ATTRIBUTE, "table"); }}));
+ new HashMap<String, Object>() {{ put(CONSTRAINT_PARAM_ATTRIBUTE, "columns"); }}));
colType.setOptions(new HashMap<String, String>() {{ put("schemaAttributes", "[\"name\", \"description\", \"owner\", \"type\", \"comment\", \"position\"]"); }});
@@ -353,8 +345,8 @@ public class QuickStartV2 {
List<AtlasEntityHeader> entities = response.getEntitiesByOperation(EntityOperation.CREATE);
if (CollectionUtils.isNotEmpty(entities)) {
- List<AtlasEntityWithAssociations> getByGuidResponse = entitiesClient.getEntityByGuid(entities.get(0).getGuid());
- ret = getByGuidResponse.get(0);
+ AtlasEntityWithExtInfo getByGuidResponse = entitiesClient.getEntityByGuid(entities.get(0).getGuid());
+ ret = getByGuidResponse.getEntity();
System.out.println("Created entity of type [" + ret.getTypeName() + "], guid: " + ret.getGuid());
}
@@ -367,7 +359,7 @@ public class QuickStartV2 {
AtlasEntity createDatabase(String name, String description, String owner, String locationUri, String... traitNames)
throws Exception {
- AtlasEntityWithAssociations entity = new AtlasEntityWithAssociations(DATABASE_TYPE);
+ AtlasEntity entity = new AtlasEntity(DATABASE_TYPE);
entity.setClassifications(toAtlasClassifications(traitNames));
entity.setAttribute("name", name);
@@ -406,7 +398,7 @@ public class QuickStartV2 {
AtlasEntity createColumn(String name, String dataType, String comment, String... traitNames) throws Exception {
- AtlasEntityWithAssociations entity = new AtlasEntityWithAssociations(COLUMN_TYPE);
+ AtlasEntity entity = new AtlasEntity(COLUMN_TYPE);
entity.setClassifications(toAtlasClassifications(traitNames));
entity.setAttribute("name", name);
entity.setAttribute("dataType", dataType);
@@ -417,7 +409,7 @@ public class QuickStartV2 {
AtlasEntity createTable(String name, String description, AtlasEntity db, AtlasEntity sd, String owner, String tableType,
List<AtlasEntity> columns, String... traitNames) throws Exception {
- AtlasEntityWithAssociations entity = new AtlasEntityWithAssociations(TABLE_TYPE);
+ AtlasEntity entity = new AtlasEntity(TABLE_TYPE);
entity.setClassifications(toAtlasClassifications(traitNames));
entity.setAttribute("name", name);
@@ -428,16 +420,16 @@ public class QuickStartV2 {
entity.setAttribute("createTime", System.currentTimeMillis());
entity.setAttribute("lastAccessTime", System.currentTimeMillis());
entity.setAttribute("retention", System.currentTimeMillis());
- entity.setAttribute("db", db);
- entity.setAttribute("sd", sd);
- entity.setAttribute("columns", columns);
+ entity.setAttribute("db", db.getAtlasObjectId());
+ entity.setAttribute("sd", sd.getAtlasObjectId());
+ entity.setAttribute("columns", getObjectIds(columns));
return createInstance(entity, traitNames);
}
AtlasEntity createProcess(String name, String description, String user, List<AtlasEntity> inputs, List<AtlasEntity> outputs,
String queryText, String queryPlan, String queryId, String queryGraph, String... traitNames) throws Exception {
- AtlasEntityWithAssociations entity = new AtlasEntityWithAssociations(LOAD_PROCESS_TYPE);
+ AtlasEntity entity = new AtlasEntity(LOAD_PROCESS_TYPE);
entity.setClassifications(toAtlasClassifications(traitNames));
entity.setAttribute(AtlasClient.NAME, name);
@@ -457,7 +449,7 @@ public class QuickStartV2 {
}
AtlasEntity createView(String name, AtlasEntity db, List<AtlasEntity> inputTables, String... traitNames) throws Exception {
- AtlasEntityWithAssociations entity = new AtlasEntityWithAssociations(VIEW_TYPE);
+ AtlasEntity entity = new AtlasEntity(VIEW_TYPE);
entity.setClassifications(toAtlasClassifications(traitNames));
entity.setAttribute("name", name);
@@ -531,7 +523,7 @@ public class QuickStartV2 {
AtlasSearchResult results = discoveryClient.dslSearchWithParams(dslQuery, 10, 0);
if (results != null) {
- List<AtlasEntityHeaderWithAssociations> entitiesResult = results.getEntities();
+ List<AtlasEntityHeader> entitiesResult = results.getEntities();
List<AtlasFullTextResult> fullTextResults = results.getFullTextResult();
AttributeSearchResult attribResult = results.getAttributes();
@@ -565,7 +557,24 @@ public class QuickStartV2 {
}
private String getTableId(String tableName) throws AtlasServiceException {
- AtlasEntity tableEntity = entitiesClient.getEntityByAttribute(TABLE_TYPE, AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, tableName).get(0);
+ Map<String, String> attributes = new HashMap<>();
+ attributes.put(AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, tableName);
+
+ AtlasEntity tableEntity = entitiesClient.getEntityByAttribute(TABLE_TYPE, attributes).getEntity();
return tableEntity.getGuid();
}
+
+ private Collection<AtlasObjectId> getObjectIds(Collection<AtlasEntity> entities) {
+ List<AtlasObjectId> ret = new ArrayList<>();
+
+ if (CollectionUtils.isNotEmpty(entities)) {
+ for (AtlasEntity entity : entities) {
+ if (entity != null) {
+ ret.add(entity.getAtlasObjectId());
+ }
+ }
+ }
+
+ return ret;
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/808eb1d1/webapp/src/main/java/org/apache/atlas/web/adapters/AtlasEntityFormatConverter.java
----------------------------------------------------------------------
diff --git a/webapp/src/main/java/org/apache/atlas/web/adapters/AtlasEntityFormatConverter.java b/webapp/src/main/java/org/apache/atlas/web/adapters/AtlasEntityFormatConverter.java
index 6818899..fb02318 100644
--- a/webapp/src/main/java/org/apache/atlas/web/adapters/AtlasEntityFormatConverter.java
+++ b/webapp/src/main/java/org/apache/atlas/web/adapters/AtlasEntityFormatConverter.java
@@ -24,7 +24,6 @@ import org.apache.atlas.model.TypeCategory;
import org.apache.atlas.model.instance.AtlasClassification;
import org.apache.atlas.model.instance.AtlasEntity;
import org.apache.atlas.model.instance.AtlasEntity.Status;
-import org.apache.atlas.model.instance.AtlasEntityWithAssociations;
import org.apache.atlas.model.instance.AtlasObjectId;
import org.apache.atlas.type.AtlasEntityType;
import org.apache.atlas.type.AtlasType;
@@ -32,7 +31,6 @@ import org.apache.atlas.type.AtlasTypeRegistry;
import org.apache.atlas.typesystem.IReferenceableInstance;
import org.apache.atlas.typesystem.IStruct;
import org.apache.atlas.typesystem.Referenceable;
-import org.apache.atlas.typesystem.persistence.AtlasSystemAttributes;
import org.apache.atlas.typesystem.persistence.Id;
import org.apache.atlas.typesystem.persistence.Id.EntityState;
import org.apache.commons.collections.CollectionUtils;
@@ -77,8 +75,8 @@ public class AtlasEntityFormatConverter extends AtlasStructFormatConverter {
LOG.error("IReferenceableInstance.getValuesMap() failed", excp);
}
- AtlasEntityWithAssociations entity = new AtlasEntityWithAssociations(entRef.getTypeName(),
- super.fromV1ToV2(entityType, v1Attribs, context));
+ AtlasEntity entity = new AtlasEntity(entRef.getTypeName(),
+ super.fromV1ToV2(entityType, v1Attribs, context));
entity.setGuid(entRef.getId()._getId());
entity.setStatus(convertState(entRef.getId().getState()));
entity.setCreatedBy(entRef.getSystemAttributes().createdBy);
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/808eb1d1/webapp/src/main/java/org/apache/atlas/web/adapters/AtlasFormatConverter.java
----------------------------------------------------------------------
diff --git a/webapp/src/main/java/org/apache/atlas/web/adapters/AtlasFormatConverter.java b/webapp/src/main/java/org/apache/atlas/web/adapters/AtlasFormatConverter.java
index a4799e8..a7157a3 100644
--- a/webapp/src/main/java/org/apache/atlas/web/adapters/AtlasFormatConverter.java
+++ b/webapp/src/main/java/org/apache/atlas/web/adapters/AtlasFormatConverter.java
@@ -21,7 +21,6 @@ package org.apache.atlas.web.adapters;
import org.apache.atlas.exception.AtlasBaseException;
import org.apache.atlas.model.TypeCategory;
import org.apache.atlas.model.instance.AtlasEntity;
-import org.apache.atlas.model.instance.AtlasEntityWithAssociations;
import org.apache.atlas.type.AtlasType;
import java.util.HashMap;
@@ -36,24 +35,16 @@ public interface AtlasFormatConverter {
public static class ConverterContext {
- private Map<String, AtlasEntityWithAssociations> entities = null;
+ private Map<String, AtlasEntity> entities = null;
- public void addEntity(AtlasEntityWithAssociations entity) {
+ public void addEntity(AtlasEntity entity) {
if (entities == null) {
entities = new HashMap<>();
}
entities.put(entity.getGuid(), entity);
}
- public void addEntity(AtlasEntity entity) {
- if (entity instanceof AtlasEntityWithAssociations) {
- this.addEntity((AtlasEntityWithAssociations)entity);
- } else {
- this.addEntity(new AtlasEntityWithAssociations(entity));
- }
- }
-
- public AtlasEntityWithAssociations getById(String guid) {
+ public AtlasEntity getById(String guid) {
if( entities != null) {
return entities.get(guid);
}
@@ -63,7 +54,7 @@ public interface AtlasFormatConverter {
public boolean entityExists(String guid) { return entities != null && entities.containsKey(guid); }
- public Map<String, AtlasEntityWithAssociations> getEntities() {
+ public Map<String, AtlasEntity> getEntities() {
return entities;
}
}
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/808eb1d1/webapp/src/main/java/org/apache/atlas/web/adapters/AtlasInstanceRestAdapters.java
----------------------------------------------------------------------
diff --git a/webapp/src/main/java/org/apache/atlas/web/adapters/AtlasInstanceRestAdapters.java b/webapp/src/main/java/org/apache/atlas/web/adapters/AtlasInstanceRestAdapters.java
index 6cdf9d1..b1dae56 100644
--- a/webapp/src/main/java/org/apache/atlas/web/adapters/AtlasInstanceRestAdapters.java
+++ b/webapp/src/main/java/org/apache/atlas/web/adapters/AtlasInstanceRestAdapters.java
@@ -17,8 +17,6 @@
*/
package org.apache.atlas.web.adapters;
-import java.util.List;
-
import org.apache.atlas.AtlasClient;
import org.apache.atlas.AtlasErrorCode;
import org.apache.atlas.AtlasException;
@@ -28,7 +26,6 @@ import org.apache.atlas.model.TypeCategory;
import org.apache.atlas.model.instance.AtlasClassification;
import org.apache.atlas.model.instance.AtlasEntity;
import org.apache.atlas.model.instance.AtlasEntityHeader;
-import org.apache.atlas.model.instance.AtlasEntityWithAssociations;
import org.apache.atlas.model.instance.EntityMutationResponse;
import org.apache.atlas.model.instance.EntityMutations;
import org.apache.atlas.model.instance.GuidMapping;
@@ -50,7 +47,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Collection;
-import java.util.HashMap;
import java.util.Iterator;
import com.google.inject.Inject;
import com.google.inject.Singleton;
@@ -129,7 +125,7 @@ public class AtlasInstanceRestAdapters {
return ret;
}
- public Map<String, AtlasEntityWithAssociations> getAtlasEntity(IReferenceableInstance referenceable) throws AtlasBaseException {
+ public Map<String, AtlasEntity> getAtlasEntity(IReferenceableInstance referenceable) throws AtlasBaseException {
AtlasFormatConverter converter = instanceFormatters.getConverter(TypeCategory.ENTITY);
AtlasEntityType entityType = typeRegistry.getEntityTypeByName(referenceable.getTypeName());
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/808eb1d1/webapp/src/main/java/org/apache/atlas/web/rest/EntitiesREST.java
----------------------------------------------------------------------
diff --git a/webapp/src/main/java/org/apache/atlas/web/rest/EntitiesREST.java b/webapp/src/main/java/org/apache/atlas/web/rest/EntitiesREST.java
index 24c2151..5b3a4c2 100644
--- a/webapp/src/main/java/org/apache/atlas/web/rest/EntitiesREST.java
+++ b/webapp/src/main/java/org/apache/atlas/web/rest/EntitiesREST.java
@@ -22,11 +22,8 @@ import org.apache.atlas.AtlasErrorCode;
import org.apache.atlas.AtlasException;
import org.apache.atlas.CreateUpdateEntitiesResult;
import org.apache.atlas.exception.AtlasBaseException;
-import org.apache.atlas.model.SearchFilter;
import org.apache.atlas.model.instance.AtlasClassification;
import org.apache.atlas.model.instance.AtlasEntity;
-import org.apache.atlas.model.instance.AtlasEntityHeader;
-import org.apache.atlas.model.instance.AtlasEntityWithAssociations;
import org.apache.atlas.model.instance.ClassificationAssociateRequest;
import org.apache.atlas.model.instance.EntityMutationResponse;
import org.apache.atlas.repository.store.graph.AtlasEntityStore;
@@ -54,9 +51,7 @@ import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Collection;
-import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@@ -138,8 +133,8 @@ public class EntitiesREST {
for (String guid : guids) {
try {
- ITypedReferenceableInstance ref = metadataService.getEntityDefinition(guid);
- Map<String, AtlasEntityWithAssociations> entityRet = restAdapters.getAtlasEntity(ref);
+ ITypedReferenceableInstance ref = metadataService.getEntityDefinition(guid);
+ Map<String, AtlasEntity> entityRet = restAdapters.getAtlasEntity(ref);
addToEntityList(entityList, entityRet.values());
@@ -152,8 +147,8 @@ public class EntitiesREST {
return entities;
}
- private void addToEntityList(final List<AtlasEntity> entityList, final Collection<AtlasEntityWithAssociations> values) {
- for (AtlasEntityWithAssociations val : values) {
+ private void addToEntityList(final List<AtlasEntity> entityList, final Collection<AtlasEntity> values) {
+ for (AtlasEntity val : values) {
if ( !entityList.contains(val)) {
entityList.add(val);
}
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/808eb1d1/webapp/src/main/java/org/apache/atlas/web/rest/EntityREST.java
----------------------------------------------------------------------
diff --git a/webapp/src/main/java/org/apache/atlas/web/rest/EntityREST.java b/webapp/src/main/java/org/apache/atlas/web/rest/EntityREST.java
index bca9091..1aac0f2 100644
--- a/webapp/src/main/java/org/apache/atlas/web/rest/EntityREST.java
+++ b/webapp/src/main/java/org/apache/atlas/web/rest/EntityREST.java
@@ -25,10 +25,12 @@ import org.apache.atlas.exception.AtlasBaseException;
import org.apache.atlas.model.TypeCategory;
import org.apache.atlas.model.instance.AtlasClassification;
import org.apache.atlas.model.instance.AtlasEntity;
-import org.apache.atlas.model.instance.AtlasEntityWithAssociations;
+import org.apache.atlas.model.instance.AtlasEntity.AtlasEntityWithExtInfo;
import org.apache.atlas.model.instance.EntityMutationResponse;
import org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef;
+import org.apache.atlas.repository.store.graph.AtlasEntityStore;
import org.apache.atlas.services.MetadataService;
+import org.apache.atlas.type.AtlasClassificationType;
import org.apache.atlas.type.AtlasEntityType;
import org.apache.atlas.type.AtlasType;
import org.apache.atlas.type.AtlasTypeRegistry;
@@ -39,15 +41,19 @@ import org.apache.atlas.typesystem.Referenceable;
import org.apache.atlas.web.adapters.AtlasFormatConverter;
import org.apache.atlas.web.adapters.AtlasInstanceRestAdapters;
import org.apache.atlas.web.util.Servlets;
+import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.inject.Inject;
import javax.inject.Singleton;
+import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.*;
+import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -63,49 +69,54 @@ public class EntityREST {
private static final Logger LOG = LoggerFactory.getLogger(EntityREST.class);
- private final AtlasTypeRegistry typeRegistry;
+ public static final String PREFIX_ATTR = "attr:";
+ private final AtlasTypeRegistry typeRegistry;
private final AtlasInstanceRestAdapters restAdapters;
-
- private final MetadataService metadataService;
+ private final MetadataService metadataService;
+ private final AtlasEntityStore entitiesStore;
@Inject
- public EntityREST(AtlasTypeRegistry typeRegistry, AtlasInstanceRestAdapters restAdapters, MetadataService metadataService) {
- this.typeRegistry = typeRegistry;
- this.restAdapters = restAdapters;
+ public EntityREST(AtlasTypeRegistry typeRegistry, AtlasInstanceRestAdapters restAdapters, MetadataService metadataService, AtlasEntityStore entitiesStore) {
+ this.typeRegistry = typeRegistry;
+ this.restAdapters = restAdapters;
this.metadataService = metadataService;
+ this.entitiesStore = entitiesStore;
}
/**
* Fetch the complete definition of an entity given its GUID.
*
* @param guid GUID for the entity
+ * @return AtlasEntity
+ * @throws AtlasBaseException
*/
@GET
@Path("/guid/{guid}")
+ @Consumes(Servlets.JSON_MEDIA_TYPE)
@Produces(Servlets.JSON_MEDIA_TYPE)
- public List<AtlasEntityWithAssociations> getById(@PathParam("guid") String guid) throws AtlasBaseException {
- try {
- ITypedReferenceableInstance ref = metadataService.getEntityDefinition(guid);
- Map<String, AtlasEntityWithAssociations> entities = restAdapters.getAtlasEntity(ref);
-
- return getOrderedEntityList(entities, guid);
- } catch (AtlasException e) {
- throw toAtlasBaseException(e);
- }
+ public AtlasEntityWithExtInfo getById(@PathParam("guid") String guid) throws AtlasBaseException {
+ return entitiesStore.getById(guid);
}
/**
- * Fetch the complete definition of an entity given its GUID including its associations
- * like classifications, terms etc.
- *
- * @param guid GUID for the entity
+ * Get entity information using entity type and unique attribute.
+ * @param typeName
+ * @return
+ * @throws AtlasBaseException
*/
@GET
- @Path("/guid/{guid}/associations")
+ @Path("/uniqueAttribute/type/{typeName}")
+ @Consumes(Servlets.JSON_MEDIA_TYPE)
@Produces(Servlets.JSON_MEDIA_TYPE)
- public List<AtlasEntityWithAssociations> getWithAssociationsByGuid(@PathParam("guid") String guid) throws AtlasBaseException {
- return this.getById(guid);
+ public AtlasEntityWithExtInfo getByUniqueAttributes(@PathParam("typeName") String typeName,
+ @Context HttpServletRequest servletRequest) throws AtlasBaseException {
+ AtlasEntityType entityType = ensureEntityType(typeName);
+ Map<String, Object> attributes = getAttributes(servletRequest);
+
+ validateAttributes(entityType, attributes);
+
+ return entitiesStore.getByUniqueAttribute(entityType, attributes);
}
/**
@@ -143,8 +154,8 @@ public class EntityREST {
@Produces(Servlets.JSON_MEDIA_TYPE)
@Path("/uniqueAttribute/type/{typeName}/attribute/{attrName}")
public EntityMutationResponse partialUpdateByUniqueAttribute(@PathParam("typeName") String entityType,
- @PathParam("attrName") String attribute,
- @QueryParam("value") String value, AtlasEntity entity) throws Exception {
+ @PathParam("attrName") String attribute,
+ @QueryParam("value") String value, AtlasEntity entity) throws Exception {
AtlasEntityType type = (AtlasEntityType) validateType(entityType, TypeCategory.ENTITY);
validateUniqueAttribute(type, attribute);
@@ -161,14 +172,15 @@ public class EntityREST {
@Consumes(Servlets.JSON_MEDIA_TYPE)
@Produces(Servlets.JSON_MEDIA_TYPE)
@Path("/uniqueAttribute/type/{typeName}/attribute/{attrName}")
- public EntityMutationResponse deleteByUniqueAttribute(@PathParam("typeName") String entityType,
+ public EntityMutationResponse deleteByUniqueAttribute(@PathParam("typeName") String typeName,
@PathParam("attrName") String attribute,
@QueryParam("value") String value) throws Exception {
- AtlasEntityType type = (AtlasEntityType) validateType(entityType, TypeCategory.ENTITY);
- validateUniqueAttribute(type, attribute);
+ AtlasEntityType entityType = ensureEntityType(typeName);
+
+ validateUniqueAttribute(entityType, attribute);
- final AtlasClient.EntityResult result = metadataService.deleteEntityByUniqueAttribute(entityType, attribute, value);
+ final AtlasClient.EntityResult result = metadataService.deleteEntityByUniqueAttribute(typeName, attribute, value);
return toEntityMutationResponse(result);
}
@@ -181,17 +193,18 @@ public class EntityREST {
@Consumes({Servlets.JSON_MEDIA_TYPE, MediaType.APPLICATION_JSON})
@Produces(Servlets.JSON_MEDIA_TYPE)
@Path("/uniqueAttribute/type/{typeName}/attribute/{attrName}")
- public List<AtlasEntityWithAssociations> getByUniqueAttribute(@PathParam("typeName") String entityType,
+ public List<AtlasEntity> getByUniqueAttribute(@PathParam("typeName") String typeName,
@PathParam("attrName") String attribute,
@QueryParam("value") String value) throws AtlasBaseException {
- List<AtlasEntityWithAssociations> entityList = new ArrayList<>();
- AtlasEntityType type = (AtlasEntityType) validateType(entityType, TypeCategory.ENTITY);
- validateUniqueAttribute(type, attribute);
+ List<AtlasEntity> entityList = new ArrayList<>();
+ AtlasEntityType entityType = ensureEntityType(typeName);
+
+ validateUniqueAttribute(entityType, attribute);
try {
- final ITypedReferenceableInstance entityDefinitionReference = metadataService.getEntityDefinitionReference(entityType, attribute, value);
- Map<String, AtlasEntityWithAssociations> entityRet = restAdapters.getAtlasEntity(entityDefinitionReference);
+ final ITypedReferenceableInstance entityDefinitionReference = metadataService.getEntityDefinitionReference(typeName, attribute, value);
+ Map<String, AtlasEntity> entityRet = restAdapters.getAtlasEntity(entityDefinitionReference);
entityList.addAll(entityRet.values());
} catch (AtlasException e) {
throw toAtlasBaseException(e);
@@ -209,16 +222,16 @@ public class EntityREST {
@GET
@Path("/guid/{guid}/classification/{classificationName}")
@Produces(Servlets.JSON_MEDIA_TYPE)
- public AtlasClassification getClassification(@PathParam("guid") String guid, @PathParam("classificationName") String classificationName) throws AtlasBaseException {
+ public AtlasClassification getClassification(@PathParam("guid") String guid, @PathParam("classificationName") String typeName) throws AtlasBaseException {
if (StringUtils.isEmpty(guid)) {
throw new AtlasBaseException(AtlasErrorCode.INSTANCE_GUID_NOT_FOUND, guid);
}
- validateType(classificationName, TypeCategory.CLASSIFICATION);
+ ensureClassificationType(typeName);
try {
- IStruct trait = metadataService.getTraitDefinition(guid, classificationName);
+ IStruct trait = metadataService.getTraitDefinition(guid, typeName);
return restAdapters.getClassification(trait);
} catch (AtlasException e) {
@@ -313,23 +326,23 @@ public class EntityREST {
* Deletes a given classification from an existing entity represented by a guid.
*
* @param guid globally unique identifier for the entity
- * @param classificationName name of the trait
+ * @param typeName name of the trait
*/
@DELETE
@Path("/guid/{guid}/classification/{classificationName}")
@Consumes({Servlets.JSON_MEDIA_TYPE, MediaType.APPLICATION_JSON})
@Produces(Servlets.JSON_MEDIA_TYPE)
public void deleteClassification(@PathParam("guid") String guid,
- @PathParam("classificationName") String classificationName) throws AtlasBaseException {
+ @PathParam("classificationName") String typeName) throws AtlasBaseException {
if (StringUtils.isEmpty(guid)) {
throw new AtlasBaseException(AtlasErrorCode.INSTANCE_GUID_NOT_FOUND, guid);
}
- validateType(classificationName, TypeCategory.CLASSIFICATION);
+ ensureClassificationType(typeName);
try {
- metadataService.deleteTrait(guid, classificationName);
+ metadataService.deleteTrait(guid, typeName);
} catch (AtlasException e) {
throw toAtlasBaseException(e);
}
@@ -348,7 +361,28 @@ public class EntityREST {
return type;
}
+ private AtlasEntityType ensureEntityType(String typeName) throws AtlasBaseException {
+ AtlasEntityType ret = typeRegistry.getEntityTypeByName(typeName);
+
+ if (ret == null) {
+ throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_INVALID, TypeCategory.ENTITY.name(), typeName);
+ }
+
+ return ret;
+ }
+
+ private AtlasClassificationType ensureClassificationType(String typeName) throws AtlasBaseException {
+ AtlasClassificationType ret = typeRegistry.getClassificationTypeByName(typeName);
+
+ if (ret == null) {
+ throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_INVALID, TypeCategory.CLASSIFICATION.name(), typeName);
+ }
+
+ return ret;
+ }
+
/**
+ * Deprecated method - not used
* Validate that attribute is unique attribute
* @param entityType the entity type
* @param attributeName the name of the attribute
@@ -361,10 +395,10 @@ public class EntityREST {
}
}
- private List<AtlasEntityWithAssociations> getOrderedEntityList(Map<String, AtlasEntityWithAssociations> entities, String firstItemGuid) {
- List<AtlasEntityWithAssociations> ret = new ArrayList<>(entities.size());
+ private List<AtlasEntity> getOrderedEntityList(Map<String, AtlasEntity> entities, String firstItemGuid) {
+ List<AtlasEntity> ret = new ArrayList<>(entities.size());
- for (AtlasEntityWithAssociations entity : entities.values()) {
+ for (AtlasEntity entity : entities.values()) {
if (StringUtils.equals(entity.getGuid(), firstItemGuid)) {
ret.add(0, entity);
} else {
@@ -374,4 +408,39 @@ public class EntityREST {
return ret;
}
+
+ private void validateAttributes(AtlasEntityType entityType, Map<String, Object> attributes)
+ throws AtlasBaseException {
+
+ if (MapUtils.isEmpty(attributes)) {
+ throw new AtlasBaseException(AtlasErrorCode.ATTRIBUTE_UNIQUE_INVALID, entityType.getTypeName(), "");
+ }
+
+ for (String attrName : attributes.keySet()) {
+ AtlasAttributeDef attrDef = entityType.getAttributeDef(attrName);
+
+ if (attrDef == null || !attrDef.getIsUnique()) {
+ throw new AtlasBaseException(AtlasErrorCode.ATTRIBUTE_UNIQUE_INVALID, entityType.getTypeName(), attrName);
+ }
+ }
+ }
+
+ private Map<String, Object> getAttributes(HttpServletRequest request) {
+ Map<String, Object> attributes = new HashMap<>();
+
+ if (MapUtils.isNotEmpty(request.getParameterMap())) {
+ for (Map.Entry<String, String[]> e : request.getParameterMap().entrySet()) {
+ String key = e.getKey();
+
+ if (key != null && key.startsWith(PREFIX_ATTR)) {
+ String[] values = e.getValue();
+ String value = values != null && values.length > 0 ? values[0] : null;
+
+ attributes.put(key.substring(PREFIX_ATTR.length()), value);
+ }
+ }
+ }
+
+ return attributes;
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/808eb1d1/webapp/src/test/java/org/apache/atlas/examples/QuickStartV2IT.java
----------------------------------------------------------------------
diff --git a/webapp/src/test/java/org/apache/atlas/examples/QuickStartV2IT.java b/webapp/src/test/java/org/apache/atlas/examples/QuickStartV2IT.java
index b7cc273..eb43384 100644
--- a/webapp/src/test/java/org/apache/atlas/examples/QuickStartV2IT.java
+++ b/webapp/src/test/java/org/apache/atlas/examples/QuickStartV2IT.java
@@ -32,6 +32,7 @@ import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -56,7 +57,9 @@ public class QuickStartV2IT extends BaseResourceIT {
}
private AtlasEntity getDB(String dbName) throws AtlasServiceException, JSONException {
- AtlasEntity dbEntity = entitiesClientV2.getEntityByAttribute(QuickStartV2.DATABASE_TYPE, "name", dbName).get(0);
+ Map<String, String> attributes = new HashMap<>();
+ attributes.put("name", dbName);
+ AtlasEntity dbEntity = entitiesClientV2.getEntityByAttribute(QuickStartV2.DATABASE_TYPE, attributes).getEntity();
return dbEntity;
}
@@ -73,12 +76,16 @@ public class QuickStartV2IT extends BaseResourceIT {
}
private AtlasEntity getTable(String tableName) throws AtlasServiceException {
- AtlasEntity tableEntity = entitiesClientV2.getEntityByAttribute(QuickStartV2.TABLE_TYPE, AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, tableName).get(0);
+ Map<String, String> attributes = new HashMap<>();
+ attributes.put(AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, tableName);
+ AtlasEntity tableEntity = entitiesClientV2.getEntityByAttribute(QuickStartV2.TABLE_TYPE, attributes).getEntity();
return tableEntity;
}
private AtlasEntity getProcess(String processName) throws AtlasServiceException {
- AtlasEntity processEntity = entitiesClientV2.getEntityByAttribute(QuickStartV2.LOAD_PROCESS_TYPE, AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, processName).get(0);
+ Map<String, String> attributes = new HashMap<>();
+ attributes.put(AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, processName);
+ AtlasEntity processEntity = entitiesClientV2.getEntityByAttribute(QuickStartV2.LOAD_PROCESS_TYPE, attributes).getEntity();
return processEntity;
}
@@ -115,8 +122,9 @@ public class QuickStartV2IT extends BaseResourceIT {
@Test
public void testProcessIsAdded() throws AtlasServiceException, JSONException {
- AtlasEntity loadProcess = entitiesClientV2.getEntityByAttribute(QuickStartV2.LOAD_PROCESS_TYPE, AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME,
- QuickStartV2.LOAD_SALES_DAILY_PROCESS).get(0);
+ Map<String, String> attributes = new HashMap<>();
+ attributes.put(AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, QuickStartV2.LOAD_SALES_DAILY_PROCESS);
+ AtlasEntity loadProcess = entitiesClientV2.getEntityByAttribute(QuickStartV2.LOAD_PROCESS_TYPE, attributes).getEntity();
Map loadProcessAttribs = loadProcess.getAttributes();
assertEquals(QuickStartV2.LOAD_SALES_DAILY_PROCESS, loadProcessAttribs.get(AtlasClient.NAME));
@@ -169,7 +177,9 @@ public class QuickStartV2IT extends BaseResourceIT {
@Test
public void testViewIsAdded() throws AtlasServiceException, JSONException {
- AtlasEntity view = entitiesClientV2.getEntityByAttribute(QuickStartV2.VIEW_TYPE, AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, QuickStartV2.PRODUCT_DIM_VIEW).get(0);
+ Map<String, String> attributes = new HashMap<>();
+ attributes.put(AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, QuickStartV2.PRODUCT_DIM_VIEW);
+ AtlasEntity view = entitiesClientV2.getEntityByAttribute(QuickStartV2.VIEW_TYPE, attributes).getEntity();
Map<String, Object> viewAttributes = view.getAttributes();
assertEquals(QuickStartV2.PRODUCT_DIM_VIEW, viewAttributes.get(AtlasClient.NAME));
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/808eb1d1/webapp/src/test/java/org/apache/atlas/web/adapters/TestEntityREST.java
----------------------------------------------------------------------
diff --git a/webapp/src/test/java/org/apache/atlas/web/adapters/TestEntityREST.java b/webapp/src/test/java/org/apache/atlas/web/adapters/TestEntityREST.java
index 2d49c47..354722f 100644
--- a/webapp/src/test/java/org/apache/atlas/web/adapters/TestEntityREST.java
+++ b/webapp/src/test/java/org/apache/atlas/web/adapters/TestEntityREST.java
@@ -22,8 +22,8 @@ import org.apache.atlas.RequestContext;
import org.apache.atlas.TestUtilsV2;
import org.apache.atlas.model.instance.AtlasClassification;
import org.apache.atlas.model.instance.AtlasEntity;
+import org.apache.atlas.model.instance.AtlasEntity.AtlasEntityWithExtInfo;
import org.apache.atlas.model.instance.AtlasEntityHeader;
-import org.apache.atlas.model.instance.AtlasEntityWithAssociations;
import org.apache.atlas.model.instance.EntityMutationResponse;
import org.apache.atlas.model.instance.EntityMutations;
import org.apache.atlas.model.typedef.AtlasTypesDef;
@@ -98,10 +98,11 @@ public class TestEntityREST {
@Test
public void testGetEntityById() throws Exception {
createOrUpdateEntity();
- final List<AtlasEntityWithAssociations> response = entityREST.getById(dbGuid);
+ AtlasEntityWithExtInfo response = entityREST.getById(dbGuid);
Assert.assertNotNull(response);
- TestEntitiesREST.verifyAttributes(response.get(0).getAttributes(), dbEntity.getAttributes());
+ Assert.assertNotNull(response.getEntity());
+ TestEntitiesREST.verifyAttributes(response.getEntity().getAttributes(), dbEntity.getAttributes());
}
@Test
@@ -130,8 +131,8 @@ public class TestEntityREST {
@Test(dependsOnMethods = "testAddAndGetClassification")
public void testGetEntityWithAssociations() throws Exception {
- List<AtlasEntityWithAssociations> entity = entityREST.getWithAssociationsByGuid(dbGuid);
- final List<AtlasClassification> retrievedClassifications = entity.get(0).getClassifications();
+ AtlasEntityWithExtInfo entity = entityREST.getById(dbGuid);
+ final List<AtlasClassification> retrievedClassifications = entity.getEntity().getClassifications();
Assert.assertNotNull(retrievedClassifications);
Assert.assertEquals(new ArrayList<AtlasClassification>() {{ add(testClassification); }}, retrievedClassifications);
@@ -172,7 +173,7 @@ public class TestEntityREST {
Assert.assertTrue(AtlasEntity.isAssigned(dbGuid));
//Get By unique attribute
- List<AtlasEntityWithAssociations> entities = entityREST.getByUniqueAttribute(TestUtilsV2.DATABASE_TYPE, TestUtilsV2.NAME, updatedDBName);
+ List<AtlasEntity> entities = entityREST.getByUniqueAttribute(TestUtilsV2.DATABASE_TYPE, TestUtilsV2.NAME, updatedDBName);
Assert.assertNotNull(entities);
Assert.assertNotNull(entities.get(0).getGuid());
Assert.assertEquals(entities.get(0).getGuid(), dbGuid);
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/808eb1d1/webapp/src/test/java/org/apache/atlas/web/resources/BaseResourceIT.java
----------------------------------------------------------------------
diff --git a/webapp/src/test/java/org/apache/atlas/web/resources/BaseResourceIT.java b/webapp/src/test/java/org/apache/atlas/web/resources/BaseResourceIT.java
index 6c4147c..64593b7 100755
--- a/webapp/src/test/java/org/apache/atlas/web/resources/BaseResourceIT.java
+++ b/webapp/src/test/java/org/apache/atlas/web/resources/BaseResourceIT.java
@@ -40,7 +40,6 @@ import org.apache.atlas.AtlasTypedefClientV2;
import org.apache.atlas.model.instance.AtlasClassification;
import org.apache.atlas.model.instance.AtlasEntity;
import org.apache.atlas.model.instance.AtlasEntityHeader;
-import org.apache.atlas.model.instance.AtlasEntityWithAssociations;
import org.apache.atlas.model.instance.AtlasStruct;
import org.apache.atlas.model.instance.EntityMutationResponse;
import org.apache.atlas.model.instance.EntityMutations;
@@ -561,9 +560,8 @@ public abstract class BaseResourceIT {
return tableInstance;
}
- protected AtlasEntityWithAssociations createHiveTableInstanceV2(AtlasEntity databaseInstance, String tableName) throws Exception {
- AtlasEntityWithAssociations tableInstance =
- new AtlasEntityWithAssociations(HIVE_TABLE_TYPE_V2);
+ protected AtlasEntity createHiveTableInstanceV2(AtlasEntity databaseInstance, String tableName) throws Exception {
+ AtlasEntity tableInstance = new AtlasEntity(HIVE_TABLE_TYPE_V2);
tableInstance.setClassifications(
Arrays.asList(new AtlasClassification("classification"),
new AtlasClassification("pii"),
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/808eb1d1/webapp/src/test/java/org/apache/atlas/web/resources/EntityDiscoveryJerseyResourceIT.java
----------------------------------------------------------------------
diff --git a/webapp/src/test/java/org/apache/atlas/web/resources/EntityDiscoveryJerseyResourceIT.java b/webapp/src/test/java/org/apache/atlas/web/resources/EntityDiscoveryJerseyResourceIT.java
index 8b51d1b..c99ff57 100755
--- a/webapp/src/test/java/org/apache/atlas/web/resources/EntityDiscoveryJerseyResourceIT.java
+++ b/webapp/src/test/java/org/apache/atlas/web/resources/EntityDiscoveryJerseyResourceIT.java
@@ -26,7 +26,7 @@ import org.apache.atlas.model.discovery.AtlasSearchResult;
import org.apache.atlas.model.discovery.AtlasSearchResult.AtlasFullTextResult;
import org.apache.atlas.model.discovery.AtlasSearchResult.AtlasQueryType;
import org.apache.atlas.model.instance.AtlasEntity.Status;
-import org.apache.atlas.model.instance.AtlasEntityHeaderWithAssociations;
+import org.apache.atlas.model.instance.AtlasEntityHeader;
import org.apache.atlas.typesystem.TypesDef;
import org.apache.atlas.typesystem.types.ClassType;
import org.apache.atlas.typesystem.types.DataTypes;
@@ -68,11 +68,11 @@ public class EntityDiscoveryJerseyResourceIT extends BaseResourceIT {
assertEquals(searchResult.getQueryText(), dslQuery);
assertEquals(searchResult.getQueryType(), AtlasQueryType.DSL);
- List<AtlasEntityHeaderWithAssociations> entities = searchResult.getEntities();
+ List<AtlasEntityHeader> entities = searchResult.getEntities();
assertNotNull(entities);
assertEquals(entities.size(), 1);
- AtlasEntityHeaderWithAssociations dbEntity = entities.get(0);
+ AtlasEntityHeader dbEntity = entities.get(0);
assertEquals(dbEntity.getTypeName(), DATABASE_TYPE_BUILTIN);
assertEquals(dbEntity.getDisplayText(), dbName);
assertEquals(dbEntity.getStatus(), Status.ACTIVE);
@@ -130,11 +130,11 @@ public class EntityDiscoveryJerseyResourceIT extends BaseResourceIT {
assertEquals(searchResult.getQueryText(), query);
assertEquals(searchResult.getQueryType(), AtlasQueryType.DSL);
- List<AtlasEntityHeaderWithAssociations> entities = searchResult.getEntities();
+ List<AtlasEntityHeader> entities = searchResult.getEntities();
assertNotNull(entities);
assertEquals(entities.size(), 1);
- AtlasEntityHeaderWithAssociations dbEntity = entities.get(0);
+ AtlasEntityHeader dbEntity = entities.get(0);
assertEquals(dbEntity.getTypeName(), DATABASE_TYPE_BUILTIN);
assertEquals(dbEntity.getDisplayText(), dbName);
assertEquals(dbEntity.getStatus(), Status.ACTIVE);
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/808eb1d1/webapp/src/test/java/org/apache/atlas/web/resources/EntityV2JerseyResourceIT.java
----------------------------------------------------------------------
diff --git a/webapp/src/test/java/org/apache/atlas/web/resources/EntityV2JerseyResourceIT.java b/webapp/src/test/java/org/apache/atlas/web/resources/EntityV2JerseyResourceIT.java
index 8c629b4..9f03718 100755
--- a/webapp/src/test/java/org/apache/atlas/web/resources/EntityV2JerseyResourceIT.java
+++ b/webapp/src/test/java/org/apache/atlas/web/resources/EntityV2JerseyResourceIT.java
@@ -37,7 +37,6 @@ import org.apache.atlas.model.instance.AtlasClassification;
import org.apache.atlas.model.instance.AtlasClassification.AtlasClassifications;
import org.apache.atlas.model.instance.AtlasEntity;
import org.apache.atlas.model.instance.AtlasEntityHeader;
-import org.apache.atlas.model.instance.AtlasEntityWithAssociations;
import org.apache.atlas.model.instance.EntityMutationResponse;
import org.apache.atlas.model.instance.EntityMutations;
import org.apache.atlas.model.typedef.AtlasClassificationDef;
@@ -80,7 +79,7 @@ public class EntityV2JerseyResourceIT extends BaseResourceIT {
private String traitName;
private AtlasEntity dbEntity;
- private AtlasEntityWithAssociations tableEntity;
+ private AtlasEntity tableEntity;
@Inject
private NotificationInterface notificationInterface;
private NotificationConsumer<EntityNotification> notificationConsumer;
@@ -187,7 +186,7 @@ public class EntityV2JerseyResourceIT extends BaseResourceIT {
//Test the same across references
final String tableName = randomString();
- AtlasEntityWithAssociations hiveTableInstanceV2 = createHiveTableInstanceV2(hiveDBInstanceV2, tableName);
+ AtlasEntity hiveTableInstanceV2 = createHiveTableInstanceV2(hiveDBInstanceV2, tableName);
hiveTableInstanceV2.setAttribute(AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, tableName);
EntityMutationResponse entity = entitiesClientV2.createEntity(hiveTableInstanceV2);
@@ -273,7 +272,9 @@ public class EntityV2JerseyResourceIT extends BaseResourceIT {
AtlasEntity hiveDB = createHiveDB();
String qualifiedName = (String) hiveDB.getAttribute(NAME);
//get entity by attribute
- AtlasEntity byAttribute = entitiesClientV2.getEntityByAttribute(DATABASE_TYPE_V2, NAME, qualifiedName).get(0);
+ Map<String, String> attributes = new HashMap<>();
+ attributes.put(NAME, qualifiedName);
+ AtlasEntity byAttribute = entitiesClientV2.getEntityByAttribute(DATABASE_TYPE_V2, attributes).getEntity();
assertEquals(byAttribute.getTypeName(), DATABASE_TYPE_V2);
assertEquals(byAttribute.getAttribute(NAME), qualifiedName);
}
@@ -427,13 +428,13 @@ public class EntityV2JerseyResourceIT extends BaseResourceIT {
return hiveDBInstanceV2;
}
- private TypeUtils.Pair<AtlasEntity, AtlasEntityWithAssociations> createDBAndTable() throws Exception {
+ private TypeUtils.Pair<AtlasEntity, AtlasEntity> createDBAndTable() throws Exception {
AtlasEntity dbInstanceV2 = createHiveDB();
- AtlasEntityWithAssociations hiveTableInstanceV2 = createHiveTable();
+ AtlasEntity hiveTableInstanceV2 = createHiveTable();
return TypeUtils.Pair.of(dbInstanceV2, hiveTableInstanceV2);
}
- private AtlasEntityWithAssociations createHiveTable() throws Exception {
+ private AtlasEntity createHiveTable() throws Exception {
if (tableEntity == null) {
tableEntity = createHiveTable(createHiveDB(), TABLE_NAME);
}
@@ -441,8 +442,8 @@ public class EntityV2JerseyResourceIT extends BaseResourceIT {
}
- private AtlasEntityWithAssociations createHiveTable(AtlasEntity dbInstanceV2, String tableName) throws Exception {
- AtlasEntityWithAssociations hiveTableInstanceV2 = createHiveTableInstanceV2(dbInstanceV2, tableName);
+ private AtlasEntity createHiveTable(AtlasEntity dbInstanceV2, String tableName) throws Exception {
+ AtlasEntity hiveTableInstanceV2 = createHiveTableInstanceV2(dbInstanceV2, tableName);
AtlasEntityHeader createdHeader = createEntity(hiveTableInstanceV2);
assertNotNull(createdHeader);
assertNotNull(createdHeader.getGuid());
@@ -478,7 +479,7 @@ public class EntityV2JerseyResourceIT extends BaseResourceIT {
AtlasClassificationDef classificationByName = typedefClientV2.getClassificationByName(traitName);
assertNotNull(classificationByName);
- AtlasEntityWithAssociations hiveTable = createHiveTable();
+ AtlasEntity hiveTable = createHiveTable();
assertEquals(hiveTable.getClassifications().size(), 7);
AtlasClassification piiClassification = new AtlasClassification(piiTrait.getName());
@@ -509,7 +510,7 @@ public class EntityV2JerseyResourceIT extends BaseResourceIT {
entitiesClientV2.addClassifications(guid, ImmutableList.of(traitInstance));
// verify the response
- AtlasEntityWithAssociations withAssociationByGuid = entitiesClientV2.getEntityWithAssociationByGuid(guid).get(0);
+ AtlasEntity withAssociationByGuid = entitiesClientV2.getEntityByGuid(guid).getEntity();
assertNotNull(withAssociationByGuid);
assertFalse(withAssociationByGuid.getClassifications().isEmpty());
@@ -620,8 +621,8 @@ public class EntityV2JerseyResourceIT extends BaseResourceIT {
AtlasEntity ref = new AtlasEntity(BaseResourceIT.COLUMN_TYPE_V2, values);
columns.add(ref);
- AtlasEntityWithAssociations hiveTable = createHiveTable();
- AtlasEntityWithAssociations tableUpdated = hiveTable;
+ AtlasEntity hiveTable = createHiveTable();
+ AtlasEntity tableUpdated = hiveTable;
hiveTable.setAttribute("columns", columns);
@@ -656,7 +657,7 @@ public class EntityV2JerseyResourceIT extends BaseResourceIT {
}
private AtlasEntity getEntityByGuid(String guid) throws AtlasServiceException {
- return entitiesClientV2.getEntityByGuid(guid).get(0);
+ return entitiesClientV2.getEntityByGuid(guid).getEntity();
}
@Test(dependsOnMethods = "testSubmitEntity")
@@ -678,7 +679,7 @@ public class EntityV2JerseyResourceIT extends BaseResourceIT {
AtlasEntity ref2 = new AtlasEntity(BaseResourceIT.COLUMN_TYPE_V2, values2);
columns.add(ref1);
columns.add(ref2);
- AtlasEntityWithAssociations hiveTable = createHiveTable();
+ AtlasEntity hiveTable = createHiveTable();
hiveTable.setAttribute("columns", columns);
EntityMutationResponse updateEntityResult = entitiesClientV2.updateEntity(hiveTable);
assertNotNull(updateEntityResult);
[2/3] incubator-atlas git commit: ATLAS-1523: v2 implementation of
get-entity by-guid/unique-attributes
Posted by ma...@apache.org.
ATLAS-1523: v2 implementation of get-entity by-guid/unique-attributes
Signed-off-by: Madhan Neethiraj <ma...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/incubator-atlas/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-atlas/commit/808eb1d1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-atlas/tree/808eb1d1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-atlas/diff/808eb1d1
Branch: refs/heads/master
Commit: 808eb1d1c314ae0445f05afa90ca90490e2723e8
Parents: 48477e2
Author: Sarath Subramanian <ss...@hortonworks.com>
Authored: Tue Feb 7 15:25:38 2017 -0800
Committer: Madhan Neethiraj <ma...@apache.org>
Committed: Tue Feb 7 19:36:38 2017 -0800
----------------------------------------------------------------------
.../org/apache/atlas/AtlasEntitiesClientV2.java | 43 +-
.../java/org/apache/atlas/AtlasErrorCode.java | 3 +-
.../model/discovery/AtlasSearchResult.java | 36 +-
.../atlas/model/instance/AtlasEntity.java | 355 +++++++++++++++-
.../atlas/model/instance/AtlasEntityHeader.java | 28 +-
.../AtlasEntityHeaderWithAssociations.java | 143 -------
.../instance/AtlasEntityWithAssociations.java | 147 -------
.../atlas/discovery/EntityDiscoveryService.java | 12 +-
.../atlas/repository/graph/GraphHelper.java | 73 +++-
.../store/graph/AtlasEntityStore.java | 31 +-
.../store/graph/v1/AtlasEntityStoreV1.java | 80 +++-
.../store/graph/v1/AtlasGraphUtilsV1.java | 6 -
.../store/graph/v1/GraphEntityMapper.java | 400 +++++++++++++++++++
.../store/graph/v1/AtlasEntityStoreV1Test.java | 4 +-
.../apache/atlas/services/MetadataService.java | 3 +-
.../org/apache/atlas/examples/QuickStartV2.java | 57 +--
.../adapters/AtlasEntityFormatConverter.java | 6 +-
.../web/adapters/AtlasFormatConverter.java | 17 +-
.../web/adapters/AtlasInstanceRestAdapters.java | 6 +-
.../org/apache/atlas/web/rest/EntitiesREST.java | 13 +-
.../org/apache/atlas/web/rest/EntityREST.java | 159 +++++---
.../apache/atlas/examples/QuickStartV2IT.java | 22 +-
.../atlas/web/adapters/TestEntityREST.java | 13 +-
.../atlas/web/resources/BaseResourceIT.java | 6 +-
.../EntityDiscoveryJerseyResourceIT.java | 10 +-
.../web/resources/EntityV2JerseyResourceIT.java | 31 +-
26 files changed, 1158 insertions(+), 546 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/808eb1d1/client/src/main/java/org/apache/atlas/AtlasEntitiesClientV2.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/atlas/AtlasEntitiesClientV2.java b/client/src/main/java/org/apache/atlas/AtlasEntitiesClientV2.java
index 2d6e708..be3088f 100644
--- a/client/src/main/java/org/apache/atlas/AtlasEntitiesClientV2.java
+++ b/client/src/main/java/org/apache/atlas/AtlasEntitiesClientV2.java
@@ -30,8 +30,9 @@ import org.apache.atlas.model.instance.AtlasClassification;
import org.apache.atlas.model.instance.AtlasClassification.AtlasClassifications;
import org.apache.atlas.model.instance.AtlasEntity;
import org.apache.atlas.model.instance.AtlasEntity.AtlasEntities;
-import org.apache.atlas.model.instance.AtlasEntityWithAssociations;
+import org.apache.atlas.model.instance.AtlasEntity.AtlasEntityWithExtInfo;
import org.apache.atlas.model.instance.EntityMutationResponse;
+import org.apache.commons.collections.MapUtils;
import org.apache.commons.configuration.Configuration;
import org.apache.hadoop.security.UserGroupInformation;
@@ -42,15 +43,14 @@ import com.sun.jersey.core.util.MultivaluedMapImpl;
public class AtlasEntitiesClientV2 extends AtlasBaseClient {
- private static final GenericType<List<AtlasEntityWithAssociations>> ENTITY_WITH_ASSOCIATIONS_LIST_TYPE = new GenericType<List<AtlasEntityWithAssociations>>(){};
+ private static final GenericType<List<AtlasEntity>> ENTITY_LIST_TYPE = new GenericType<List<AtlasEntity>>(){};
public static final String ENTITY_API = BASE_URI + "v2/entity/";
public static final String ENTITIES_API = BASE_URI + "v2/entities/";
private static final APIInfo GET_ENTITY_BY_GUID = new APIInfo(ENTITY_API + "guid/", HttpMethod.GET, Response.Status.OK);
- private static final APIInfo GET_ENTITY_WITH_ASSOCIATION_BY_GUID = new APIInfo(ENTITY_API + "guid/%s/associations", HttpMethod.GET, Response.Status.OK);
private static final APIInfo CREATE_ENTITY = new APIInfo(ENTITIES_API, HttpMethod.POST, Response.Status.OK);
private static final APIInfo UPDATE_ENTITY = CREATE_ENTITY;
- private static final APIInfo GET_ENTITY_BY_ATTRIBUTE = new APIInfo(ENTITY_API + "uniqueAttribute/type/%s/attribute/%s", HttpMethod.GET, Response.Status.OK);
+ private static final APIInfo GET_ENTITY_BY_ATTRIBUTE = new APIInfo(ENTITY_API + "uniqueAttribute/type/%s", HttpMethod.GET, Response.Status.OK);
private static final APIInfo UPDATE_ENTITY_BY_ATTRIBUTE = new APIInfo(ENTITY_API + "uniqueAttribute/type/%s/attribute/%s", HttpMethod.PUT, Response.Status.OK);
private static final APIInfo DELETE_ENTITY_BY_ATTRIBUTE = new APIInfo(ENTITY_API + "uniqueAttribute/type/%s/attribute/%s", HttpMethod.DELETE, Response.Status.OK);
private static final APIInfo DELETE_ENTITY_BY_GUID = new APIInfo(ENTITY_API + "guid/", HttpMethod.DELETE, Response.Status.OK);
@@ -87,25 +87,21 @@ public class AtlasEntitiesClientV2 extends AtlasBaseClient {
super(service, configuration);
}
- public List<AtlasEntityWithAssociations> getEntityByGuid(String guid) throws AtlasServiceException {
+ public AtlasEntityWithExtInfo getEntityByGuid(String guid) throws AtlasServiceException {
- return callAPI(GET_ENTITY_BY_GUID, null, ENTITY_WITH_ASSOCIATIONS_LIST_TYPE, guid);
+ return callAPI(GET_ENTITY_BY_GUID, null, AtlasEntityWithExtInfo.class, guid);
}
public AtlasEntities getEntityByGuids(List<String> guids) throws AtlasServiceException {
return callAPI(GET_ENTITY_BY_GUID, AtlasEntities.class, "guid", guids);
}
- public List<AtlasEntityWithAssociations> getEntityWithAssociationByGuid(String guid) throws AtlasServiceException {
+ public static final String PREFIX_ATTR = "attr:";
- return callAPI(formatPathForPathParams(GET_ENTITY_WITH_ASSOCIATION_BY_GUID, guid), null, ENTITY_WITH_ASSOCIATIONS_LIST_TYPE);
- }
-
- public List<AtlasEntityWithAssociations> getEntityByAttribute(String type, String attribute, String value) throws AtlasServiceException {
+ public AtlasEntityWithExtInfo getEntityByAttribute(String type, Map<String, String> attributes) throws AtlasServiceException {
+ MultivaluedMap<String, String> queryParams = attributesToQueryParams(attributes);
- MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl();
- queryParams.add("value", value);
- return callAPI(formatPathForPathParams(GET_ENTITY_BY_ATTRIBUTE, type, attribute), ENTITY_WITH_ASSOCIATIONS_LIST_TYPE, queryParams);
+ return callAPI(formatPathForPathParams(GET_ENTITY_BY_ATTRIBUTE, type), AtlasEntityWithExtInfo.class, queryParams);
}
public EntityMutationResponse updateEntityByAttribute(String type, String attribute, String value, AtlasEntity entity) throws AtlasServiceException {
@@ -182,4 +178,23 @@ public class AtlasEntitiesClientV2 extends AtlasBaseClient {
public AtlasEntity.AtlasEntities searchEntities(SearchFilter searchFilter) throws AtlasServiceException {
return callAPI(GET_ENTITIES, AtlasEntity.AtlasEntities.class, searchFilter.getParams());
}
+
+ private MultivaluedMap<String, String> attributesToQueryParams(Map<String, String> attributes) {
+ return attributesToQueryParams(attributes, null);
+ }
+
+ private MultivaluedMap<String, String> attributesToQueryParams(Map<String, String> attributes,
+ MultivaluedMap<String, String> queryParams) {
+ if (queryParams == null) {
+ queryParams = new MultivaluedMapImpl();
+ }
+
+ if (MapUtils.isNotEmpty(attributes)) {
+ for (Map.Entry<String, String> e : attributes.entrySet()) {
+ queryParams.putSingle(PREFIX_ATTR + e.getKey(), e.getValue());
+ }
+ }
+
+ return queryParams;
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/808eb1d1/intg/src/main/java/org/apache/atlas/AtlasErrorCode.java
----------------------------------------------------------------------
diff --git a/intg/src/main/java/org/apache/atlas/AtlasErrorCode.java b/intg/src/main/java/org/apache/atlas/AtlasErrorCode.java
index f9895cf..7b11b70 100644
--- a/intg/src/main/java/org/apache/atlas/AtlasErrorCode.java
+++ b/intg/src/main/java/org/apache/atlas/AtlasErrorCode.java
@@ -59,6 +59,7 @@ public enum AtlasErrorCode {
CONSTRAINT_INVERSE_REF_INVERSE_ATTRIBUTE_NON_EXISTING(400, "ATLAS40028E", "{0}.{1}: invalid {2} constraint. Inverse attribute {3}.{4} does not exist"),
CONSTRAINT_INVERSE_REF_INVERSE_ATTRIBUTE_INVALID_TYPE(400, "ATLAS40029E", "{0}.{1}: invalid {2} constraint. Inverse attribute {3}.{4} is not an entity type"),
CONSTRAINT_OWNED_REF_ATTRIBUTE_INVALID_TYPE(400, "ATLAS40030E", "{0}.{1}: invalid {2} constraint. Attribute {3} is not an entity type"),
+ CANNOT_MAP_ATTRIBUTE(400, "ATLAS40027E", "cannot map attribute: {0} of type: {1} from vertex"),
// All Not found enums go here
TYPE_NAME_NOT_FOUND(404, "ATLAS4041E", "Given typename {0} was invalid"),
@@ -82,7 +83,7 @@ public enum AtlasErrorCode {
INDEX_ROLLBACK_FAILED(500, "ATLAS5003E", "Index rollback failed for {0}"),
FAILED_TO_OBTAIN_TYPE_UPDATE_LOCK(500, "ATLAS5004E", "Failed to get the lock; another type update might be in progress. Please try again"),
- INSTANCE_BY_UNIQUE_ATTRIBUTE_NOT_FOUND(400, "ATLAS40018E", "Instance {0} with unique attribute {1} does not exist"),
+ INSTANCE_BY_UNIQUE_ATTRIBUTE_NOT_FOUND(400, "ATLAS40018E", "Instance {0} with unique attribute {1}={2} does not exist"),
UNRESOLVED_REFERENCES_FOUND(400, "ATLAS40010E", "Unresolved references: byId={0}; byUniqueAttributes={1}"),
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/808eb1d1/intg/src/main/java/org/apache/atlas/model/discovery/AtlasSearchResult.java
----------------------------------------------------------------------
diff --git a/intg/src/main/java/org/apache/atlas/model/discovery/AtlasSearchResult.java b/intg/src/main/java/org/apache/atlas/model/discovery/AtlasSearchResult.java
index e0f24b1..c4c0063 100644
--- a/intg/src/main/java/org/apache/atlas/model/discovery/AtlasSearchResult.java
+++ b/intg/src/main/java/org/apache/atlas/model/discovery/AtlasSearchResult.java
@@ -17,7 +17,7 @@
*/
package org.apache.atlas.model.discovery;
-import org.apache.atlas.model.instance.AtlasEntityHeaderWithAssociations;
+import org.apache.atlas.model.instance.AtlasEntityHeader;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.codehaus.jackson.annotate.JsonAutoDetect;
@@ -42,11 +42,11 @@ import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.PUBLIC_ONL
@XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY)
public class AtlasSearchResult implements Serializable {
- private String queryText;
- private AtlasQueryType queryType;
- private List<AtlasEntityHeaderWithAssociations> entities;
- private AttributeSearchResult attributes;
- private List<AtlasFullTextResult> fullTextResult;
+ private String queryText;
+ private AtlasQueryType queryType;
+ private List<AtlasEntityHeader> entities;
+ private AttributeSearchResult attributes;
+ private List<AtlasFullTextResult> fullTextResult;
public AtlasSearchResult() {}
@@ -66,9 +66,9 @@ public class AtlasSearchResult implements Serializable {
public void setQueryType(AtlasQueryType queryType) { this.queryType = queryType; }
- public List<AtlasEntityHeaderWithAssociations> getEntities() { return entities; }
+ public List<AtlasEntityHeader> getEntities() { return entities; }
- public void setEntities(List<AtlasEntityHeaderWithAssociations> entities) { this.entities = entities; }
+ public void setEntities(List<AtlasEntityHeader> entities) { this.entities = entities; }
public AttributeSearchResult getAttributes() { return attributes; }
@@ -104,7 +104,7 @@ public class AtlasSearchResult implements Serializable {
'}';
}
- public void addEntity(AtlasEntityHeaderWithAssociations newEntity) {
+ public void addEntity(AtlasEntityHeader newEntity) {
if (entities == null) {
entities = new ArrayList<>();
}
@@ -117,13 +117,13 @@ public class AtlasSearchResult implements Serializable {
}
}
- public void removeEntity(AtlasEntityHeaderWithAssociations entity) {
- List<AtlasEntityHeaderWithAssociations> entities = this.entities;
+ public void removeEntity(AtlasEntityHeader entity) {
+ List<AtlasEntityHeader> entities = this.entities;
if (CollectionUtils.isNotEmpty(entities)) {
- Iterator<AtlasEntityHeaderWithAssociations> iter = entities.iterator();
+ Iterator<AtlasEntityHeader> iter = entities.iterator();
while (iter.hasNext()) {
- AtlasEntityHeaderWithAssociations currEntity = iter.next();
+ AtlasEntityHeader currEntity = iter.next();
if (StringUtils.equals(currEntity.getGuid(), entity.getGuid())) {
iter.remove();
}
@@ -184,19 +184,19 @@ public class AtlasSearchResult implements Serializable {
@XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY)
public static class AtlasFullTextResult {
- AtlasEntityHeaderWithAssociations entity;
- Double score;
+ AtlasEntityHeader entity;
+ Double score;
public AtlasFullTextResult() {}
- public AtlasFullTextResult(AtlasEntityHeaderWithAssociations entity, Double score) {
+ public AtlasFullTextResult(AtlasEntityHeader entity, Double score) {
this.entity = entity;
this.score = score;
}
- public AtlasEntityHeaderWithAssociations getEntity() { return entity; }
+ public AtlasEntityHeader getEntity() { return entity; }
- public void setEntity(AtlasEntityHeaderWithAssociations entity) { this.entity = entity; }
+ public void setEntity(AtlasEntityHeader entity) { this.entity = entity; }
public Double getScore() { return score; }
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/808eb1d1/intg/src/main/java/org/apache/atlas/model/instance/AtlasEntity.java
----------------------------------------------------------------------
diff --git a/intg/src/main/java/org/apache/atlas/model/instance/AtlasEntity.java b/intg/src/main/java/org/apache/atlas/model/instance/AtlasEntity.java
index de57145..af936cc 100644
--- a/intg/src/main/java/org/apache/atlas/model/instance/AtlasEntity.java
+++ b/intg/src/main/java/org/apache/atlas/model/instance/AtlasEntity.java
@@ -19,7 +19,10 @@ package org.apache.atlas.model.instance;
import org.apache.atlas.model.PList;
import org.apache.atlas.model.SearchFilter.SortType;
+import org.apache.atlas.model.typedef.AtlasBaseTypeDef;
import org.apache.atlas.model.typedef.AtlasEntityDef;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang.StringUtils;
import org.codehaus.jackson.annotate.JsonAutoDetect;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
@@ -30,7 +33,9 @@ import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlSeeAlso;
import java.io.Serializable;
+import java.util.ArrayList;
import java.util.Date;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@@ -65,6 +70,8 @@ public class AtlasEntity extends AtlasStruct implements Serializable {
private Date updateTime = null;
private Long version = new Long(0);
+ private List<AtlasClassification> classifications;
+
@JsonIgnore
private static AtomicLong s_nextId = new AtomicLong(System.nanoTime());
@@ -89,6 +96,7 @@ public class AtlasEntity extends AtlasStruct implements Serializable {
setUpdatedBy(null);
setCreateTime(null);
setUpdateTime(null);
+ setClassifications(null);
}
public AtlasEntity(AtlasEntity other) {
@@ -102,6 +110,7 @@ public class AtlasEntity extends AtlasStruct implements Serializable {
setCreateTime(other.getCreateTime());
setUpdateTime(other.getUpdateTime());
setVersion(other.getVersion());
+ setClassifications(other.getClassifications());
}
}
@@ -161,6 +170,10 @@ public class AtlasEntity extends AtlasStruct implements Serializable {
this.version = version;
}
+ public List<AtlasClassification> getClassifications() { return classifications; }
+
+ public void setClassifications(List<AtlasClassification> classifications) { this.classifications = classifications; }
+
@JsonIgnore
public boolean isUnassigned() {
return isUnAssigned(guid);
@@ -210,6 +223,9 @@ public class AtlasEntity extends AtlasStruct implements Serializable {
dumpDateField(", createTime=", createTime, sb);
dumpDateField(", updateTime=", updateTime, sb);
sb.append(", version=").append(version);
+ sb.append(", classifications=[");
+ AtlasBaseTypeDef.dumpObjects(classifications, sb);
+ sb.append(']');
sb.append(", ");
super.toString(sb);
sb.append('}');
@@ -230,12 +246,14 @@ public class AtlasEntity extends AtlasStruct implements Serializable {
Objects.equals(updatedBy, that.updatedBy) &&
Objects.equals(createTime, that.createTime) &&
Objects.equals(updateTime, that.updateTime) &&
- Objects.equals(version, that.version);
+ Objects.equals(version, that.version) &&
+ Objects.equals(classifications, that.classifications);
}
@Override
public int hashCode() {
- return Objects.hash(super.hashCode(), guid, status, createdBy, updatedBy, createTime, updateTime, version);
+ return Objects.hash(super.hashCode(), guid, status, createdBy, updatedBy, createTime, updateTime, version,
+ classifications);
}
@Override
@@ -244,6 +262,339 @@ public class AtlasEntity extends AtlasStruct implements Serializable {
}
/**
+ * An instance of an entity along with extended info - like hive_table, hive_database.
+ */
+ @JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
+ @JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
+ @JsonIgnoreProperties(ignoreUnknown=true)
+ @XmlRootElement
+ @XmlAccessorType(XmlAccessType.PROPERTY)
+ public static class AtlasEntityExtInfo implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ private Map<String, AtlasEntity> referredEntities;
+
+
+ public AtlasEntityExtInfo() {
+ setReferredEntities(null);
+ }
+
+ public AtlasEntityExtInfo(Map<String, AtlasEntity> referredEntities) {
+ setReferredEntities(referredEntities);
+ }
+
+ public AtlasEntityExtInfo(AtlasEntityExtInfo other) {
+ if (other != null) {
+ setReferredEntities(other.getReferredEntities());
+ }
+ }
+
+ public Map<String, AtlasEntity> getReferredEntities() { return referredEntities; }
+
+ public void setReferredEntities(Map<String, AtlasEntity> referredEntities) { this.referredEntities = referredEntities; }
+
+ @JsonIgnore
+ public final void addReferredEntity(String guid, AtlasEntity entity) {
+ Map<String, AtlasEntity> r = this.referredEntities;
+
+ if (r == null) {
+ r = new HashMap<>();
+
+ this.referredEntities = r;
+ }
+
+ if (guid != null) {
+ r.put(guid, entity);
+ }
+ }
+
+ @JsonIgnore
+ public final AtlasEntity removeReferredEntity(String guid) {
+ Map<String, AtlasEntity> r = this.referredEntities;
+
+ return r != null && guid != null ? r.remove(guid) : null;
+ }
+
+ @JsonIgnore
+ public final AtlasEntity getReferredEntity(String guid) {
+ Map<String, AtlasEntity> r = this.referredEntities;
+
+ return r != null && guid != null ? r.get(guid) : null;
+ }
+
+ @JsonIgnore
+ public AtlasEntity getEntity(String guid) {
+ return getReferredEntity(guid);
+ }
+
+ @JsonIgnore
+ public AtlasEntity removeEntity(String guid) {
+ Map<String, AtlasEntity> r = this.referredEntities;
+
+ return r != null && guid != null ? r.remove(guid) : null;
+ }
+
+ public void updateEntityGuid(String oldGuid, String newGuid) {
+ AtlasEntity entity = getEntity(oldGuid);
+
+ if (entity != null) {
+ entity.setGuid(newGuid);
+
+ if(removeEntity(oldGuid) != null) {
+ addReferredEntity(newGuid, entity);
+ }
+ }
+ }
+
+ public boolean hasEntity(String guid) {
+ return getEntity(guid) != null;
+ }
+
+ public void compact() {
+ // for derived classes to implement their own logic
+ }
+
+ public StringBuilder toString(StringBuilder sb) {
+ if (sb == null) {
+ sb = new StringBuilder();
+ }
+
+ sb.append("AtlasEntityExtInfo{");
+ sb.append("referredEntities={");
+ AtlasBaseTypeDef.dumpObjects(referredEntities, sb);
+ sb.append("}");
+ sb.append("}");
+
+ return sb;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+
+ AtlasEntityExtInfo that = (AtlasEntityExtInfo) o;
+ return Objects.equals(referredEntities, that.referredEntities);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(referredEntities);
+ }
+
+ @Override
+ public String toString() {
+ return toString(new StringBuilder()).toString();
+ }
+ }
+
+ @JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
+ @JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
+ @JsonIgnoreProperties(ignoreUnknown=true)
+ @XmlRootElement
+ @XmlAccessorType(XmlAccessType.PROPERTY)
+ public static class AtlasEntityWithExtInfo extends AtlasEntityExtInfo {
+ private static final long serialVersionUID = 1L;
+
+ private AtlasEntity entity;
+
+ public AtlasEntityWithExtInfo() {
+ this(null, null);
+ }
+
+ public AtlasEntityWithExtInfo(AtlasEntity entity) {
+ this(entity, null);
+ }
+
+ public AtlasEntityWithExtInfo(AtlasEntity entity, AtlasEntityExtInfo extInfo) {
+ super(extInfo);
+
+ this.entity = entity;
+ }
+
+ public AtlasEntity getEntity() { return entity; }
+
+ public void setEntity(AtlasEntity entity) { this.entity = entity; }
+
+ @JsonIgnore
+ @Override
+ public AtlasEntity getEntity(String guid) {
+ AtlasEntity ret = super.getEntity(guid);
+
+ if (ret == null && entity != null) {
+ if (StringUtils.equals(guid, entity.getGuid())) {
+ ret = entity;
+ }
+ }
+
+ return ret;
+ }
+
+ @JsonIgnore
+ @Override
+ public void compact() {
+ super.compact();
+
+ // remove 'entity' from referredEntities
+ if (entity != null) {
+ removeEntity(entity.getGuid());
+ }
+ }
+
+ @Override
+ public StringBuilder toString(StringBuilder sb) {
+ if (sb == null) {
+ sb = new StringBuilder();
+ }
+
+ sb.append("AtlasEntityWithExtInfo{");
+ sb.append("entity=").append(entity).append(",");
+ super.toString(sb);
+ sb.append("}");
+
+ return sb;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+
+ AtlasEntityWithExtInfo that = (AtlasEntityWithExtInfo) o;
+ return Objects.equals(entity, that.entity);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(super.hashCode(), entity);
+ }
+ }
+
+ @JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
+ @JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
+ @JsonIgnoreProperties(ignoreUnknown=true)
+ @XmlRootElement
+ @XmlAccessorType(XmlAccessType.PROPERTY)
+ public static class AtlasEntitiesWithExtInfo extends AtlasEntityExtInfo {
+ private static final long serialVersionUID = 1L;
+
+ private List<AtlasEntity> entities;
+
+ public AtlasEntitiesWithExtInfo() {
+ this(null, null);
+ }
+
+ public AtlasEntitiesWithExtInfo(List<AtlasEntity> entities) {
+ this(entities, null);
+ }
+
+ public AtlasEntitiesWithExtInfo(List<AtlasEntity> entities, AtlasEntityExtInfo extInfo) {
+ super(extInfo);
+
+ this.entities = entities;
+ }
+
+ public List<AtlasEntity> getEntities() { return entities; }
+
+ public void setEntities(List<AtlasEntity> entities) { this.entities = entities; }
+
+ @JsonIgnore
+ @Override
+ public AtlasEntity getEntity(String guid) {
+ AtlasEntity ret = super.getEntity(guid);
+
+ if (ret == null && CollectionUtils.isNotEmpty(entities)) {
+ for (AtlasEntity entity : entities) {
+ if (StringUtils.equals(guid, entity.getGuid())) {
+ ret = entity;
+
+ break;
+ }
+ }
+ }
+
+ return ret;
+ }
+
+ public void addEntity(AtlasEntity entity) {
+ List<AtlasEntity> entities = this.entities;
+
+ if (entities == null) {
+ entities = new ArrayList<>();
+
+ this.entities = entities;
+ }
+
+ entities.add(entity);
+ }
+
+ public void removeEntity(AtlasEntity entity) {
+ List<AtlasEntity> entities = this.entities;
+
+ if (entity != null && entities != null) {
+ entities.remove(entity);
+ }
+ }
+
+ @Override
+ public void compact() {
+ super.compact();
+
+ // remove 'entities' from referredEntities
+ if (CollectionUtils.isNotEmpty(entities)) {
+ for (AtlasEntity entity : entities) {
+ removeReferredEntity(entity.getGuid());
+ }
+ }
+ }
+
+ @Override
+ public StringBuilder toString(StringBuilder sb) {
+ if (sb == null) {
+ sb = new StringBuilder();
+ }
+
+ sb.append("AtlasEntitiesWithExtInfo{");
+ sb.append("entities=[");
+ AtlasBaseTypeDef.dumpObjects(entities, sb);
+ sb.append("],");
+ super.toString(sb);
+ sb.append("}");
+
+ return sb;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+
+ AtlasEntitiesWithExtInfo that = (AtlasEntitiesWithExtInfo) o;
+ return Objects.equals(entities, that.entities);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(super.hashCode(), entities);
+ }
+ }
+
+ /**
* REST serialization friendly list.
*/
@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/808eb1d1/intg/src/main/java/org/apache/atlas/model/instance/AtlasEntityHeader.java
----------------------------------------------------------------------
diff --git a/intg/src/main/java/org/apache/atlas/model/instance/AtlasEntityHeader.java b/intg/src/main/java/org/apache/atlas/model/instance/AtlasEntityHeader.java
index 5797a69..93a77e0 100644
--- a/intg/src/main/java/org/apache/atlas/model/instance/AtlasEntityHeader.java
+++ b/intg/src/main/java/org/apache/atlas/model/instance/AtlasEntityHeader.java
@@ -18,7 +18,6 @@
package org.apache.atlas.model.instance;
import java.io.Serializable;
-import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@@ -49,9 +48,10 @@ import org.codehaus.jackson.map.annotate.JsonSerialize;
public class AtlasEntityHeader extends AtlasStruct implements Serializable {
private static final long serialVersionUID = 1L;
- private String guid = null;
- private AtlasEntity.Status status = AtlasEntity.Status.ACTIVE;
- private String displayText = null;
+ private String guid = null;
+ private AtlasEntity.Status status = AtlasEntity.Status.ACTIVE;
+ private String displayText = null;
+ private List<String> classificationNames = null;
public AtlasEntityHeader() {
this(null, null);
@@ -67,12 +67,15 @@ public class AtlasEntityHeader extends AtlasStruct implements Serializable {
public AtlasEntityHeader(String typeName, Map<String, Object> attributes) {
super(typeName, attributes);
+
+ setClassificationNames(null);
}
public AtlasEntityHeader(String typeName, String guid, Map<String, Object> attributes) {
super(typeName, attributes);
setGuid(guid);
+ setClassificationNames(null);
}
@@ -83,6 +86,7 @@ public class AtlasEntityHeader extends AtlasStruct implements Serializable {
setGuid(other.getGuid());
setStatus(other.getStatus());
setDisplayText(other.getDisplayText());
+ setClassificationNames(other.getClassificationNames());
}
}
@@ -110,6 +114,14 @@ public class AtlasEntityHeader extends AtlasStruct implements Serializable {
this.displayText = displayText;
}
+ public List<String> getClassificationNames(){
+ return classificationNames;
+ }
+
+ public void setClassificationNames(List<String> classificationNames) {
+ this.classificationNames = classificationNames;
+ }
+
@Override
public StringBuilder toString(StringBuilder sb) {
if (sb == null) {
@@ -120,6 +132,9 @@ public class AtlasEntityHeader extends AtlasStruct implements Serializable {
sb.append("guid='").append(guid).append('\'');
sb.append(", status=").append(status);
sb.append(", displayText=").append(displayText);
+ sb.append(", classificationNames=[");
+ dumpObjects(classificationNames, sb);
+ sb.append("],");
sb.append(", ");
super.toString(sb);
sb.append('}');
@@ -135,12 +150,13 @@ public class AtlasEntityHeader extends AtlasStruct implements Serializable {
AtlasEntityHeader that = (AtlasEntityHeader) o;
return Objects.equals(guid, that.guid) &&
status == that.status &&
- Objects.equals(displayText, that.displayText);
+ Objects.equals(displayText, that.displayText) &&
+ Objects.equals(classificationNames, that.classificationNames);
}
@Override
public int hashCode() {
- return Objects.hash(super.hashCode(), guid, status, displayText);
+ return Objects.hash(super.hashCode(), guid, status, displayText, classificationNames);
}
@Override
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/808eb1d1/intg/src/main/java/org/apache/atlas/model/instance/AtlasEntityHeaderWithAssociations.java
----------------------------------------------------------------------
diff --git a/intg/src/main/java/org/apache/atlas/model/instance/AtlasEntityHeaderWithAssociations.java b/intg/src/main/java/org/apache/atlas/model/instance/AtlasEntityHeaderWithAssociations.java
deleted file mode 100644
index ed1adb4..0000000
--- a/intg/src/main/java/org/apache/atlas/model/instance/AtlasEntityHeaderWithAssociations.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.atlas.model.instance;
-
-import org.apache.atlas.model.PList;
-import org.apache.atlas.model.SearchFilter;
-import org.apache.atlas.model.typedef.AtlasEntityDef;
-import org.codehaus.jackson.annotate.JsonAutoDetect;
-import org.codehaus.jackson.annotate.JsonIgnoreProperties;
-import org.codehaus.jackson.map.annotate.JsonSerialize;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlRootElement;
-import javax.xml.bind.annotation.XmlSeeAlso;
-import java.io.Serializable;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-
-import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.NONE;
-import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.PUBLIC_ONLY;
-
-/**
- * An instance of an entity and its associations - like hive_table, hive_database.
- */
-@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
-@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
-@JsonIgnoreProperties(ignoreUnknown=true)
-@XmlRootElement
-@XmlAccessorType(XmlAccessType.PROPERTY)
-public class AtlasEntityHeaderWithAssociations extends AtlasEntityHeader implements Serializable{
- private static final long serialVersionUID = 1L;
-
- private List<String> classificationNames;
-
- public AtlasEntityHeaderWithAssociations(){
- this(null, null);
- }
-
- public AtlasEntityHeaderWithAssociations(AtlasEntityDef entityDef) {
- this(entityDef != null ? entityDef.getName() : null, null);
- }
-
- public AtlasEntityHeaderWithAssociations(String typeName, Map<String, Object> attributes) {
- super(typeName, attributes);
- setClassificationNames(null);
- }
-
- public AtlasEntityHeaderWithAssociations(AtlasEntityHeaderWithAssociations other) {
- super(other);
-
- if (other != null) {
- setClassificationNames(other.getClassificationNames());
- }
- }
-
- public List<String> getClassificationNames(){
- return classificationNames;
- }
-
- public void setClassificationNames(List<String> classificationNames) {
- this.classificationNames = classificationNames;
- }
-
-
- @Override
- public StringBuilder toString(StringBuilder sb) {
- if (sb == null) {
- sb = new StringBuilder();
- }
-
- sb.append("AtlasEntityHeaderwithAssociations{");
- sb.append(", classificationNames=[");
- dumpObjects(classificationNames, sb);
- sb.append("],");
- super.toString(sb);
- sb.append('}');
-
- return sb;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
- if (!super.equals(o)) return false;
- AtlasEntityHeaderWithAssociations that = (AtlasEntityHeaderWithAssociations) o;
- return Objects.equals(classificationNames, that.classificationNames);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(super.hashCode(), classificationNames);
- }
-
- @Override
- public String toString() {
- return toString(new StringBuilder()).toString();
- }
-
- /**
- * REST serialization friendly list.
- */
- @JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
- @JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
- @JsonIgnoreProperties(ignoreUnknown=true)
- @XmlRootElement
- @XmlAccessorType(XmlAccessType.PROPERTY)
- @XmlSeeAlso(AtlasEntity.class)
- public static class AtlasEntityHeadersWithAssociations extends PList<AtlasEntityHeaderWithAssociations> {
- private static final long serialVersionUID = 1L;
-
- public AtlasEntityHeadersWithAssociations() {
- super();
- }
-
- public AtlasEntityHeadersWithAssociations(List<AtlasEntityHeaderWithAssociations> list) {
- super(list);
- }
-
- public AtlasEntityHeadersWithAssociations(List list, long startIndex, int pageSize, long totalCount,
- SearchFilter.SortType sortType, String sortBy) {
- super(list, startIndex, pageSize, totalCount, sortType, sortBy);
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/808eb1d1/intg/src/main/java/org/apache/atlas/model/instance/AtlasEntityWithAssociations.java
----------------------------------------------------------------------
diff --git a/intg/src/main/java/org/apache/atlas/model/instance/AtlasEntityWithAssociations.java b/intg/src/main/java/org/apache/atlas/model/instance/AtlasEntityWithAssociations.java
deleted file mode 100644
index abcf276..0000000
--- a/intg/src/main/java/org/apache/atlas/model/instance/AtlasEntityWithAssociations.java
+++ /dev/null
@@ -1,147 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.atlas.model.instance;
-
-import org.apache.atlas.model.PList;
-import org.apache.atlas.model.SearchFilter.SortType;
-import org.apache.atlas.model.typedef.AtlasEntityDef;
-import org.codehaus.jackson.annotate.JsonAutoDetect;
-import org.codehaus.jackson.annotate.JsonIgnoreProperties;
-import org.codehaus.jackson.map.annotate.JsonSerialize;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlRootElement;
-import javax.xml.bind.annotation.XmlSeeAlso;
-import java.io.Serializable;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-
-import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.NONE;
-import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.PUBLIC_ONLY;
-
-
-/**
- * An instance of an entity - like hive_table, hive_database along with its assictaed classifications, terms etc.
- */
-@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
-@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
-@JsonIgnoreProperties(ignoreUnknown=true)
-@XmlRootElement
-@XmlAccessorType(XmlAccessType.PROPERTY)
-public class AtlasEntityWithAssociations extends AtlasEntity implements Serializable {
- private static final long serialVersionUID = 1L;
-
- List<AtlasClassification> classifications;
-
- public AtlasEntityWithAssociations() {
- this(null, null);
- }
-
- public AtlasEntityWithAssociations(String typeName) {
- this(typeName, null);
- }
-
- public AtlasEntityWithAssociations(AtlasEntityDef entityDef) {
- this(entityDef != null ? entityDef.getName() : null, null);
- }
-
- public AtlasEntityWithAssociations(String typeName, Map<String, Object> attributes) {
- super(typeName, attributes);
- setClassifications(null);
- }
-
- public AtlasEntityWithAssociations(AtlasEntityWithAssociations other) {
- super(other);
-
- setClassifications(other != null ? other.getClassifications() : null);
- }
-
- public AtlasEntityWithAssociations(AtlasEntity other) {
- super(other);
- }
-
- @Override
- public StringBuilder toString(StringBuilder sb) {
- if (sb == null) {
- sb = new StringBuilder();
- }
-
- sb.append("AtlasEntityWithAssociations{");
- sb.append("classifications='").append(classifications).append('\'');
- sb.append(", ");
- super.toString(sb);
- sb.append('}');
-
- return sb;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
- if (!super.equals(o)) return false;
- AtlasEntityWithAssociations that = (AtlasEntityWithAssociations) o;
- return Objects.equals(classifications, that.classifications);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(super.hashCode(), classifications);
- }
-
- public List<AtlasClassification> getClassifications() {
- return classifications;
- }
-
- public void setClassifications(final List<AtlasClassification> classifications) {
- this.classifications = classifications;
- }
-
- @Override
- public String toString() {
- return toString(new StringBuilder()).toString();
- }
-
- /**
- * REST serialization friendly list.
- */
- @JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
- @JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
- @JsonIgnoreProperties(ignoreUnknown=true)
- @XmlRootElement
- @XmlAccessorType(XmlAccessType.PROPERTY)
- @XmlSeeAlso(AtlasEntityWithAssociations.class)
- public static class AtlasEntitiesWithAssociations extends PList<AtlasEntityWithAssociations> {
- private static final long serialVersionUID = 1L;
-
- public AtlasEntitiesWithAssociations() {
- super();
- }
-
- public AtlasEntitiesWithAssociations(List<AtlasEntityWithAssociations> list) {
- super(list);
- }
-
- public AtlasEntitiesWithAssociations(List list, long startIndex, int pageSize, long totalCount,
- SortType sortType, String sortBy) {
- super(list, startIndex, pageSize, totalCount, sortType, sortBy);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/808eb1d1/repository/src/main/java/org/apache/atlas/discovery/EntityDiscoveryService.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/discovery/EntityDiscoveryService.java b/repository/src/main/java/org/apache/atlas/discovery/EntityDiscoveryService.java
index 2b4561d..da06230 100644
--- a/repository/src/main/java/org/apache/atlas/discovery/EntityDiscoveryService.java
+++ b/repository/src/main/java/org/apache/atlas/discovery/EntityDiscoveryService.java
@@ -26,7 +26,7 @@ import org.apache.atlas.discovery.graph.DefaultGraphPersistenceStrategy;
import org.apache.atlas.exception.AtlasBaseException;
import org.apache.atlas.model.discovery.AtlasSearchResult;
import org.apache.atlas.model.instance.AtlasEntity.Status;
-import org.apache.atlas.model.instance.AtlasEntityHeaderWithAssociations;
+import org.apache.atlas.model.instance.AtlasEntityHeader;
import org.apache.atlas.model.typedef.AtlasBaseTypeDef;
import org.apache.atlas.query.Expressions.AliasExpression;
import org.apache.atlas.query.Expressions.Expression;
@@ -97,7 +97,7 @@ public class EntityDiscoveryService implements AtlasDiscoveryService {
if (firstElement instanceof AtlasVertex) {
for (Object element : queryResult) {
if (element instanceof AtlasVertex) {
- ret.addEntity(toAtlasEntityHeaderwithAssociations((AtlasVertex)element));
+ ret.addEntity(toAtlasEntityHeader((AtlasVertex)element));
} else {
LOG.warn("searchUsingDslQuery({}): expected an AtlasVertex; found unexpected entry in result {}", dslQuery, element);
}
@@ -115,7 +115,7 @@ public class EntityDiscoveryService implements AtlasDiscoveryService {
Object entry = ((List)value).get(0);
if (entry instanceof AtlasVertex) {
- ret.addEntity(toAtlasEntityHeaderwithAssociations((AtlasVertex)entry));
+ ret.addEntity(toAtlasEntityHeader((AtlasVertex)entry));
}
}
}
@@ -159,7 +159,7 @@ public class EntityDiscoveryService implements AtlasDiscoveryService {
String guid = vertex != null ? vertex.getProperty(Constants.GUID_PROPERTY_KEY, String.class) : null;
if (guid != null) {
- AtlasEntityHeaderWithAssociations entity = toAtlasEntityHeaderwithAssociations(vertex);
+ AtlasEntityHeader entity = toAtlasEntityHeader(vertex);
Double score = idxQueryResult.getScore();
ret.add(new AtlasFullTextResult(entity, score));
}
@@ -204,12 +204,12 @@ public class EntityDiscoveryService implements AtlasDiscoveryService {
return new QueryParams(limit, offset);
}
- private AtlasEntityHeaderWithAssociations toAtlasEntityHeaderwithAssociations(AtlasVertex vertex) {
+ private AtlasEntityHeader toAtlasEntityHeader(AtlasVertex vertex) {
if (vertex == null) {
return null;
}
- AtlasEntityHeaderWithAssociations ret = new AtlasEntityHeaderWithAssociations();
+ AtlasEntityHeader ret = new AtlasEntityHeader();
String typeName = vertex.getProperty(Constants.TYPE_NAME_PROPERTY_KEY, String.class);
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/808eb1d1/repository/src/main/java/org/apache/atlas/repository/graph/GraphHelper.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/repository/graph/GraphHelper.java b/repository/src/main/java/org/apache/atlas/repository/graph/GraphHelper.java
index 89e978d..65de1e5 100755
--- a/repository/src/main/java/org/apache/atlas/repository/graph/GraphHelper.java
+++ b/repository/src/main/java/org/apache/atlas/repository/graph/GraphHelper.java
@@ -18,23 +18,13 @@
package org.apache.atlas.repository.graph;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Set;
-import java.util.Stack;
-import java.util.UUID;
-
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.collect.BiMap;
+import com.google.common.collect.HashBiMap;
import org.apache.atlas.ApplicationProperties;
import org.apache.atlas.AtlasException;
import org.apache.atlas.RequestContext;
+import org.apache.atlas.model.instance.AtlasEntity.Status;
import org.apache.atlas.repository.Constants;
import org.apache.atlas.repository.RepositoryException;
import org.apache.atlas.repository.graphdb.AtlasEdge;
@@ -43,6 +33,7 @@ import org.apache.atlas.repository.graphdb.AtlasElement;
import org.apache.atlas.repository.graphdb.AtlasGraph;
import org.apache.atlas.repository.graphdb.AtlasGraphQuery;
import org.apache.atlas.repository.graphdb.AtlasVertex;
+import org.apache.atlas.type.AtlasType;
import org.apache.atlas.typesystem.IReferenceableInstance;
import org.apache.atlas.typesystem.ITypedInstance;
import org.apache.atlas.typesystem.ITypedReferenceableInstance;
@@ -70,9 +61,19 @@ import org.codehaus.jettison.json.JSONArray;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.collect.BiMap;
-import com.google.common.collect.HashBiMap;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+import java.util.Stack;
+import java.util.UUID;
/**
* Utility class for graph operations.
@@ -596,8 +597,8 @@ public final class GraphHelper {
public static String getQualifiedFieldName(IDataType dataType, String attributeName) throws AtlasException {
return dataType.getTypeCategory() == DataTypes.TypeCategory.STRUCT ? dataType.getName() + "." + attributeName
- // else class or trait
- : ((HierarchicalType) dataType).getQualifiedName(attributeName);
+ // else class or trait
+ : ((HierarchicalType) dataType).getQualifiedName(attributeName);
}
public static String getTraitLabel(String typeName, String attrName) {
@@ -649,10 +650,15 @@ public final class GraphHelper {
return element.getProperty(Constants.VERSION_PROPERTY_KEY, Integer.class);
}
+
+
public static String getStateAsString(AtlasElement element) {
return element.getProperty(Constants.STATE_PROPERTY_KEY, String.class);
}
+ public static Status getStatus(AtlasElement element) {
+ return (getState(element) == Id.EntityState.DELETED) ? Status.DELETED : Status.ACTIVE;
+ }
//Added conditions in fetching system attributes to handle test failures in GremlinTest where these properties are not set
public static String getCreatedByAsString(AtlasElement element){
@@ -812,6 +818,7 @@ public final class GraphHelper {
}
return Collections.emptyList();
}
+
/**
* Guid and AtlasVertex combo
*/
@@ -974,6 +981,12 @@ public final class GraphHelper {
}
+ public static boolean isReference(AtlasType type) {
+ return ((type.getTypeCategory() == org.apache.atlas.model.TypeCategory.STRUCT) ||
+ (type.getTypeCategory() == org.apache.atlas.model.TypeCategory.ENTITY));
+
+ }
+
public static void setArrayElementsProperty(IDataType elementType, AtlasVertex instanceVertex, String propertyName, List<Object> values) {
String actualPropertyName = GraphHelper.encodePropertyKey(propertyName);
if(GraphHelper.isReference(elementType)) {
@@ -1004,6 +1017,27 @@ public final class GraphHelper {
}
}
+ public static Object getMapValueProperty(AtlasType elementType, AtlasVertex instanceVertex, String propertyName) {
+ String vertexPropertyName = GraphHelper.encodePropertyKey(propertyName);
+
+ if (GraphHelper.isReference(elementType)) {
+ return instanceVertex.getProperty(vertexPropertyName, AtlasEdge.class);
+ } else {
+ return instanceVertex.getProperty(vertexPropertyName, Object.class).toString();
+ }
+ }
+
+ // newly added
+ public static List<Object> getArrayElementsProperty(AtlasType elementType, AtlasVertex instanceVertex, String propertyName) {
+ String encodedPropertyName = GraphHelper.encodePropertyKey(propertyName);
+ if(GraphHelper.isReference(elementType)) {
+ return (List)instanceVertex.getListProperty(encodedPropertyName, AtlasEdge.class);
+ }
+ else {
+ return (List)instanceVertex.getListProperty(encodedPropertyName);
+ }
+ }
+
public static List<Object> getArrayElementsProperty(IDataType elementType, AtlasVertex instanceVertex, String propertyName) {
String actualPropertyName = GraphHelper.encodePropertyKey(propertyName);
if(GraphHelper.isReference(elementType)) {
@@ -1014,7 +1048,6 @@ public final class GraphHelper {
}
}
-
public static void dumpToLog(final AtlasGraph<?,?> graph) {
LOG.debug("*******************Graph Dump****************************");
LOG.debug("Vertices of {}", graph);
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/808eb1d1/repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasEntityStore.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasEntityStore.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasEntityStore.java
index ed0fabb..4cfc012 100644
--- a/repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasEntityStore.java
+++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasEntityStore.java
@@ -19,12 +19,12 @@ package org.apache.atlas.repository.store.graph;
import org.apache.atlas.exception.AtlasBaseException;
-import org.apache.atlas.model.SearchFilter;
import org.apache.atlas.model.instance.AtlasClassification;
import org.apache.atlas.model.instance.AtlasEntity;
-import org.apache.atlas.model.instance.AtlasEntityWithAssociations;
-import org.apache.atlas.model.instance.EntityMutations;
+import org.apache.atlas.model.instance.AtlasEntity.AtlasEntityWithExtInfo;
+import org.apache.atlas.model.instance.AtlasEntity.AtlasEntitiesWithExtInfo;
import org.apache.atlas.model.instance.EntityMutationResponse;
+import org.apache.atlas.type.AtlasEntityType;
import org.apache.atlas.type.AtlasTypeRegistry;
import java.util.List;
@@ -45,9 +45,9 @@ public interface AtlasEntityStore {
*
* Get entity definition by its guid
* @param guid
- * @return
+ * @return AtlasEntity
*/
- AtlasEntity getById(String guid);
+ AtlasEntityWithExtInfo getById(String guid) throws AtlasBaseException;
/**
* Delete an entity by its guid
@@ -71,15 +71,7 @@ public interface AtlasEntityStore {
* @return
* @throws AtlasBaseException
*/
- AtlasEntity.AtlasEntities getByIds(List<String> guid) throws AtlasBaseException;
-
- /**
- * Batch GET to retrieve entities and their associations by their ID
- * @param guid
- * @return
- * @throws AtlasBaseException
- */
- AtlasEntityWithAssociations getWithAssociationsByIds(List<String> guid) throws AtlasBaseException;
+ AtlasEntitiesWithExtInfo getByIds(List<String> guid) throws AtlasBaseException;
/*
* Return list of deleted entity guids
@@ -89,12 +81,12 @@ public interface AtlasEntityStore {
/**
*
* Get an eneity by its unique attribute
- * @param typeName
- * @param attrName
- * @param attrValue
- * @return
+ * @param entityType
+ * @param uniqAttributes
+ * @return AtlasEntity
*/
- AtlasEntity getByUniqueAttribute(String typeName, String attrName, String attrValue);
+ AtlasEntityWithExtInfo getByUniqueAttribute(AtlasEntityType entityType, Map<String, Object> uniqAttributes)
+ throws AtlasBaseException;
/**
* @deprecated
@@ -134,5 +126,4 @@ public interface AtlasEntityStore {
* Delete classification(s)
*/
void deleteClassifications(String guid, List<String> classificationNames) throws AtlasBaseException;
-
}
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/808eb1d1/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityStoreV1.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityStoreV1.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityStoreV1.java
index 9e08282..a95ae8e 100644
--- a/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityStoreV1.java
+++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityStoreV1.java
@@ -18,9 +18,7 @@
package org.apache.atlas.repository.store.graph.v1;
-import java.util.ArrayList;
-import java.util.List;
-
+import com.google.inject.Inject;
import org.apache.atlas.AtlasErrorCode;
import org.apache.atlas.GraphTransaction;
import org.apache.atlas.RequestContextV1;
@@ -28,9 +26,16 @@ import org.apache.atlas.exception.AtlasBaseException;
import org.apache.atlas.model.TypeCategory;
import org.apache.atlas.model.instance.AtlasClassification;
import org.apache.atlas.model.instance.AtlasEntity;
-import org.apache.atlas.model.instance.AtlasEntityWithAssociations;
+import org.apache.atlas.model.instance.AtlasEntity.AtlasEntityWithExtInfo;
+import org.apache.atlas.model.instance.AtlasEntity.AtlasEntitiesWithExtInfo;
+import org.apache.atlas.model.instance.AtlasEntity.Status;
import org.apache.atlas.model.instance.AtlasObjectId;
import org.apache.atlas.model.instance.EntityMutationResponse;
+import org.apache.atlas.repository.graph.AtlasGraphProvider;
+import org.apache.atlas.repository.graph.GraphHelper;
+import org.apache.atlas.repository.Constants;
+import org.apache.atlas.repository.graphdb.AtlasGraph;
+import org.apache.atlas.repository.graphdb.AtlasGraphQuery;
import org.apache.atlas.repository.graphdb.AtlasVertex;
import org.apache.atlas.repository.store.graph.AtlasEntityStore;
import org.apache.atlas.repository.store.graph.EntityGraphDiscovery;
@@ -41,22 +46,28 @@ import org.apache.atlas.type.AtlasTypeRegistry;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
import java.util.Map;
-import com.google.inject.Inject;
-
public class AtlasEntityStoreV1 implements AtlasEntityStore {
protected AtlasTypeRegistry typeRegistry;
+ protected final GraphHelper graphHelper = GraphHelper.getInstance();
- private EntityGraphMapper graphMapper;
+ private final EntityGraphMapper graphMapper;
+ private final GraphEntityMapper entityMapper;
+ private final AtlasGraph graph;
private static final Logger LOG = LoggerFactory.getLogger(AtlasEntityStoreV1.class);
@Inject
- public AtlasEntityStoreV1(EntityGraphMapper vertexMapper) {
- this.graphMapper = vertexMapper;
+ public AtlasEntityStoreV1(EntityGraphMapper vertexMapper, GraphEntityMapper entityMapper) {
+ this.graphMapper = vertexMapper;
+ this.entityMapper = entityMapper;
+ this.graph = AtlasGraphProvider.getGraphInstance();
}
@Inject
@@ -65,8 +76,43 @@ public class AtlasEntityStoreV1 implements AtlasEntityStore {
}
@Override
- public AtlasEntity getById(final String guid) {
- return null;
+ public AtlasEntityWithExtInfo getById(final String guid) throws AtlasBaseException {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Retrieving entity with guid={}", guid);
+ }
+
+ return entityMapper.toAtlasEntity(guid, true);
+ }
+
+ @Override
+ public AtlasEntityWithExtInfo getByUniqueAttribute(AtlasEntityType entityType, Map<String, Object> uniqAttributes) throws AtlasBaseException {
+ String entityTypeName = entityType.getTypeName();
+
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Retrieving entity with type={} and attributes={}: values={}", entityTypeName, uniqAttributes);
+ }
+
+ AtlasGraphQuery query = graph.query();
+
+ for (Map.Entry<String, Object> e : uniqAttributes.entrySet()) {
+ String attrName = e.getKey();
+ Object attrValue = e.getValue();
+
+ query = query.has(entityType.getQualifiedAttributeName(attrName), attrValue);
+ }
+
+ Iterator<AtlasVertex> result = query.has(Constants.ENTITY_TYPE_PROPERTY_KEY, entityTypeName)
+ .has(Constants.STATE_PROPERTY_KEY, Status.ACTIVE.name())
+ .vertices().iterator();
+ AtlasVertex entityVertex = result.hasNext() ? result.next() : null;
+
+ if (entityVertex == null) {
+ throw new AtlasBaseException(AtlasErrorCode.INSTANCE_BY_UNIQUE_ATTRIBUTE_NOT_FOUND, entityTypeName, uniqAttributes.keySet().toString(), uniqAttributes.values().toString());
+ }
+
+ String guid = GraphHelper.getGuid(entityVertex);
+
+ return entityMapper.toAtlasEntity(guid, true);
}
@Override
@@ -96,12 +142,7 @@ public class AtlasEntityStoreV1 implements AtlasEntityStore {
}
@Override
- public AtlasEntity.AtlasEntities getByIds(final List<String> guid) throws AtlasBaseException {
- return null;
- }
-
- @Override
- public AtlasEntityWithAssociations getWithAssociationsByIds(final List<String> guid) throws AtlasBaseException {
+ public AtlasEntitiesWithExtInfo getByIds(final List<String> guids) throws AtlasBaseException {
return null;
}
@@ -111,11 +152,6 @@ public class AtlasEntityStoreV1 implements AtlasEntityStore {
}
@Override
- public AtlasEntity getByUniqueAttribute(final String typeName, final String attrName, final String attrValue) {
- return null;
- }
-
- @Override
public EntityMutationResponse updateByUniqueAttribute(final String typeName, final String attributeName, final String attributeValue, final AtlasEntity entity) throws AtlasBaseException {
return null;
}
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/808eb1d1/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasGraphUtilsV1.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasGraphUtilsV1.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasGraphUtilsV1.java
index 7fe5e14..bddac7a 100644
--- a/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasGraphUtilsV1.java
+++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasGraphUtilsV1.java
@@ -21,11 +21,9 @@ import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;
import org.apache.atlas.AtlasErrorCode;
-import org.apache.atlas.AtlasException;
import org.apache.atlas.exception.AtlasBaseException;
import org.apache.atlas.model.TypeCategory;
import org.apache.atlas.model.instance.AtlasEntity;
-import org.apache.atlas.model.instance.AtlasStruct;
import org.apache.atlas.model.typedef.AtlasBaseTypeDef;
import org.apache.atlas.repository.Constants;
import org.apache.atlas.repository.graph.GraphHelper;
@@ -34,14 +32,10 @@ import org.apache.atlas.repository.graphdb.AtlasElement;
import org.apache.atlas.repository.graphdb.AtlasVertex;
import org.apache.atlas.type.AtlasStructType;
import org.apache.atlas.type.AtlasType;
-import org.apache.atlas.typesystem.persistence.Id;
-import org.apache.atlas.typesystem.types.DataTypes;
-import org.apache.atlas.typesystem.types.IDataType;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/808eb1d1/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/GraphEntityMapper.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/GraphEntityMapper.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/GraphEntityMapper.java
new file mode 100644
index 0000000..a0d8940
--- /dev/null
+++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/GraphEntityMapper.java
@@ -0,0 +1,400 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.atlas.repository.store.graph.v1;
+
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import org.apache.atlas.AtlasErrorCode;
+import org.apache.atlas.AtlasException;
+import org.apache.atlas.exception.AtlasBaseException;
+import org.apache.atlas.model.instance.AtlasClassification;
+import org.apache.atlas.model.instance.AtlasEntity;
+import org.apache.atlas.model.instance.AtlasEntity.AtlasEntityExtInfo;
+import org.apache.atlas.model.instance.AtlasEntity.AtlasEntityWithExtInfo;
+import org.apache.atlas.model.instance.AtlasObjectId;
+import org.apache.atlas.model.instance.AtlasStruct;
+import org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef;
+import org.apache.atlas.repository.Constants;
+import org.apache.atlas.repository.graph.GraphHelper;
+import org.apache.atlas.repository.graphdb.AtlasEdge;
+import org.apache.atlas.repository.graphdb.AtlasEdgeDirection;
+import org.apache.atlas.repository.graphdb.AtlasVertex;
+import org.apache.atlas.type.AtlasArrayType;
+import org.apache.atlas.type.AtlasMapType;
+import org.apache.atlas.type.AtlasStructType;
+import org.apache.atlas.type.AtlasStructType.AtlasAttribute;
+import org.apache.atlas.type.AtlasType;
+import org.apache.atlas.type.AtlasTypeRegistry;
+import org.apache.commons.collections.CollectionUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static org.apache.atlas.model.typedef.AtlasBaseTypeDef.ATLAS_TYPE_BIGDECIMAL;
+import static org.apache.atlas.model.typedef.AtlasBaseTypeDef.ATLAS_TYPE_BIGINTEGER;
+import static org.apache.atlas.model.typedef.AtlasBaseTypeDef.ATLAS_TYPE_BOOLEAN;
+import static org.apache.atlas.model.typedef.AtlasBaseTypeDef.ATLAS_TYPE_BYTE;
+import static org.apache.atlas.model.typedef.AtlasBaseTypeDef.ATLAS_TYPE_DATE;
+import static org.apache.atlas.model.typedef.AtlasBaseTypeDef.ATLAS_TYPE_DOUBLE;
+import static org.apache.atlas.model.typedef.AtlasBaseTypeDef.ATLAS_TYPE_FLOAT;
+import static org.apache.atlas.model.typedef.AtlasBaseTypeDef.ATLAS_TYPE_INT;
+import static org.apache.atlas.model.typedef.AtlasBaseTypeDef.ATLAS_TYPE_LONG;
+import static org.apache.atlas.model.typedef.AtlasBaseTypeDef.ATLAS_TYPE_SHORT;
+import static org.apache.atlas.model.typedef.AtlasBaseTypeDef.ATLAS_TYPE_STRING;
+import static org.apache.atlas.repository.graph.GraphHelper.EDGE_LABEL_PREFIX;
+
+@Singleton
+public final class GraphEntityMapper {
+ private static final Logger LOG = LoggerFactory.getLogger(GraphEntityMapper.class);
+ private static final GraphHelper graphHelper = GraphHelper.getInstance();
+
+ @Inject
+ protected AtlasTypeRegistry typeRegistry;
+
+ public AtlasEntityWithExtInfo toAtlasEntity(String guid, boolean includeReferences) throws AtlasBaseException {
+ AtlasEntityExtInfo entityExtInfo = includeReferences ? new AtlasEntityExtInfo() : null;
+ AtlasEntity entity = mapVertexToAtlasEntity(guid, entityExtInfo);
+ AtlasEntityWithExtInfo ret = new AtlasEntityWithExtInfo(entity, entityExtInfo);
+
+ ret.compact();
+
+ return ret;
+ }
+
+ private AtlasEntity mapVertexToAtlasEntity(String guid, AtlasEntityExtInfo entityExtInfo) throws AtlasBaseException {
+ AtlasEntity entity = entityExtInfo != null ? entityExtInfo.getEntity(guid) : null;
+
+ if (entity != null) {
+ return entity;
+ }
+
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Mapping graph vertex to atlas entity for guid {}", guid);
+ }
+
+ try {
+ AtlasVertex entityVertex = graphHelper.getVertexForGUID(guid);
+ entity = new AtlasEntity();
+
+ if (entityExtInfo != null) {
+ entityExtInfo.addReferredEntity(guid, entity);
+ }
+
+ mapSystemAttributes(entityVertex, entity);
+
+ mapAttributes(entityVertex, entity, entityExtInfo);
+
+ mapClassifications(entityVertex, entity, entityExtInfo);
+
+ } catch (AtlasException e) {
+ throw new AtlasBaseException(AtlasErrorCode.INSTANCE_GUID_NOT_FOUND, guid);
+ }
+
+ return entity;
+ }
+
+ private AtlasEntity mapSystemAttributes(AtlasVertex entityVertex, AtlasEntity entity) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Mapping system attributes for type {}", entity.getTypeName());
+ }
+
+ entity.setGuid(GraphHelper.getGuid(entityVertex));
+ entity.setTypeName(GraphHelper.getSingleValuedProperty(entityVertex, Constants.ENTITY_TYPE_PROPERTY_KEY, String.class));
+ entity.setStatus(GraphHelper.getStatus(entityVertex));
+ entity.setVersion(GraphHelper.getVersion(entityVertex).longValue());
+
+ entity.setCreatedBy(GraphHelper.getCreatedByAsString(entityVertex));
+ entity.setUpdatedBy(GraphHelper.getModifiedByAsString(entityVertex));
+
+ entity.setCreateTime(new Date(GraphHelper.getCreatedTime(entityVertex)));
+ entity.setUpdateTime(new Date(GraphHelper.getModifiedTime(entityVertex)));
+
+ return entity;
+ }
+
+ private void mapAttributes(AtlasVertex entityVertex, AtlasStruct struct, AtlasEntityExtInfo entityExtInfo) throws AtlasBaseException {
+ AtlasType objType = typeRegistry.getType(struct.getTypeName());
+
+ if (!(objType instanceof AtlasStructType)) {
+ throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_INVALID, struct.getTypeName());
+ }
+
+ AtlasStructType structType = (AtlasStructType) objType;
+ Collection<AtlasAttribute> attributes = structType.getAllAttributes().values();
+
+ if (CollectionUtils.isNotEmpty(attributes)) {
+ for (AtlasAttribute attribute : attributes) {
+ Object attrValue = mapVertexToAttribute(entityVertex, attribute, entityExtInfo);
+
+ struct.setAttribute(attribute.getName(), attrValue);
+ }
+ }
+ }
+
+ private void mapClassifications(AtlasVertex entityVertex, AtlasEntity entity, AtlasEntityExtInfo entityExtInfo) throws AtlasBaseException {
+ List<String> classficationNames = GraphHelper.getTraitNames(entityVertex);
+
+ if (CollectionUtils.isNotEmpty(classficationNames)) {
+ List<AtlasClassification> classifications = new ArrayList<>();
+
+ for (String classficationName : classficationNames) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("mapping classification {} to atlas entity", classficationName);
+ }
+
+ Iterable<AtlasEdge> edges = entityVertex.getEdges(AtlasEdgeDirection.OUT, classficationName);
+
+ AtlasEdge edge = (edges != null && edges.iterator().hasNext()) ? edges.iterator().next() : null;
+
+ if (edge != null) {
+ AtlasClassification classification = new AtlasClassification(classficationName);
+
+ mapAttributes(edge.getInVertex(), classification, entityExtInfo);
+
+ classifications.add(classification);
+ }
+ }
+
+ entity.setClassifications(classifications);
+ }
+ }
+
+ private Object mapVertexToAttribute(AtlasVertex entityVertex, AtlasAttribute attribute, AtlasEntityExtInfo entityExtInfo) throws AtlasBaseException {
+ Object ret = null;
+ AtlasType attrType = attribute.getAttributeType();
+ String vertexPropertyName = attribute.getQualifiedName();
+ String edgeLabel = EDGE_LABEL_PREFIX + vertexPropertyName;
+ boolean isOwnedAttribute = attribute.isOwnedRef();
+
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Mapping vertex {} to atlas entity {}.{}", entityVertex, attribute.getDefinedInDef().getName(), attribute.getName());
+ }
+
+ switch (attrType.getTypeCategory()) {
+ case PRIMITIVE:
+ ret = mapVertexToPrimitive(entityVertex, vertexPropertyName, attribute.getAttributeDef());
+ break;
+ case ENUM:
+ ret = GraphHelper.getProperty(entityVertex, vertexPropertyName);
+ break;
+ case STRUCT:
+ ret = mapVertexToStruct(entityVertex, edgeLabel, null, entityExtInfo);
+ break;
+ case ENTITY:
+ ret = mapVertexToObjectId(entityVertex, edgeLabel, null, entityExtInfo, isOwnedAttribute);
+ break;
+ case ARRAY:
+ ret = mapVertexToArray(entityVertex, (AtlasArrayType) attrType, vertexPropertyName, entityExtInfo, isOwnedAttribute);
+ break;
+ case MAP:
+ ret = mapVertexToMap(entityVertex, (AtlasMapType) attrType, vertexPropertyName, entityExtInfo, isOwnedAttribute);
+ break;
+ case CLASSIFICATION:
+ // do nothing
+ break;
+ }
+
+ return ret;
+ }
+
+ private Map<String, Object> mapVertexToMap(AtlasVertex entityVertex, AtlasMapType atlasMapType, final String propertyName,
+ AtlasEntityExtInfo entityExtInfo, boolean isOwnedAttribute) throws AtlasBaseException {
+ Map<String, Object> ret = new HashMap<>();
+ List<String> mapKeys = GraphHelper.getListProperty(entityVertex, propertyName);
+ AtlasType mapValueType = atlasMapType.getValueType();
+
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Mapping map attribute {} for vertex {}", atlasMapType.getTypeName(), entityVertex);
+ }
+
+ if (CollectionUtils.isEmpty(mapKeys)) {
+ return null;
+ }
+
+ for (String mapKey : mapKeys) {
+ final String keyPropertyName = propertyName + "." + mapKey;
+ final String edgeLabel = EDGE_LABEL_PREFIX + keyPropertyName;
+ final Object keyValue = GraphHelper.getMapValueProperty(mapValueType, entityVertex, keyPropertyName);
+
+ Object mapValue = mapVertexToCollectionEntry(entityVertex, mapValueType, keyValue, edgeLabel, entityExtInfo, isOwnedAttribute);
+ if (mapValue != null) {
+ ret.put(mapKey, mapValue);
+ }
+ }
+
+ return ret;
+ }
+
+ private List<Object> mapVertexToArray(AtlasVertex entityVertex, AtlasArrayType arrayType, String propertyName,
+ AtlasEntityExtInfo entityExtInfo, boolean isOwnedAttribute) throws AtlasBaseException {
+ AtlasType arrayElementType = arrayType.getElementType();
+ List<Object> arrayElements = GraphHelper.getArrayElementsProperty(arrayElementType, entityVertex, propertyName);
+ List arrValues = new ArrayList();
+ String edgeLabel = EDGE_LABEL_PREFIX + propertyName;
+
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Mapping array attribute {} for vertex {}", arrayElementType.getTypeName(), entityVertex);
+ }
+
+ if (CollectionUtils.isEmpty(arrayElements)) {
+ return null;
+ }
+
+ for (Object element : arrayElements) {
+ Object arrValue = mapVertexToCollectionEntry(entityVertex, arrayElementType, element,
+ edgeLabel, entityExtInfo, isOwnedAttribute);
+
+ arrValues.add(arrValue);
+ }
+
+ return arrValues;
+ }
+
+ private Object mapVertexToCollectionEntry(AtlasVertex entityVertex, AtlasType arrayElement, Object value, String edgeLabel,
+ AtlasEntityExtInfo entityExtInfo, boolean isOwnedAttribute) throws AtlasBaseException {
+ Object ret = null;
+
+ switch (arrayElement.getTypeCategory()) {
+ case PRIMITIVE:
+ case ENUM:
+ ret = value;
+ break;
+
+ case ARRAY:
+ case MAP:
+ case CLASSIFICATION:
+ break;
+
+ case STRUCT:
+ ret = mapVertexToStruct(entityVertex, edgeLabel, (AtlasEdge) value, entityExtInfo);
+ break;
+
+ case ENTITY:
+ ret = mapVertexToObjectId(entityVertex, edgeLabel, (AtlasEdge) value, entityExtInfo, isOwnedAttribute);
+ break;
+
+ default:
+ break;
+ }
+
+ return ret;
+ }
+
+ private Object mapVertexToPrimitive(AtlasVertex entityVertex, final String vertexPropertyName, AtlasAttributeDef attrDef) {
+ Object ret = null;
+
+ if (GraphHelper.getSingleValuedProperty(entityVertex, vertexPropertyName, Object.class) == null) {
+ return null;
+ }
+
+ switch (attrDef.getTypeName().toLowerCase()) {
+ case ATLAS_TYPE_STRING:
+ ret = GraphHelper.getSingleValuedProperty(entityVertex, vertexPropertyName, String.class);
+ break;
+ case ATLAS_TYPE_SHORT:
+ ret = GraphHelper.getSingleValuedProperty(entityVertex, vertexPropertyName, Short.class);
+ break;
+ case ATLAS_TYPE_INT:
+ ret = GraphHelper.getSingleValuedProperty(entityVertex, vertexPropertyName, Integer.class);
+ break;
+ case ATLAS_TYPE_BIGINTEGER:
+ ret = GraphHelper.getSingleValuedProperty(entityVertex, vertexPropertyName, BigInteger.class);
+ break;
+ case ATLAS_TYPE_BOOLEAN:
+ ret = GraphHelper.getSingleValuedProperty(entityVertex, vertexPropertyName, Boolean.class);
+ break;
+ case ATLAS_TYPE_BYTE:
+ ret = GraphHelper.getSingleValuedProperty(entityVertex, vertexPropertyName, Byte.class);
+ break;
+ case ATLAS_TYPE_LONG:
+ ret = GraphHelper.getSingleValuedProperty(entityVertex, vertexPropertyName, Long.class);
+ break;
+ case ATLAS_TYPE_FLOAT:
+ ret = GraphHelper.getSingleValuedProperty(entityVertex, vertexPropertyName, Float.class);
+ break;
+ case ATLAS_TYPE_DOUBLE:
+ ret = GraphHelper.getSingleValuedProperty(entityVertex, vertexPropertyName, Double.class);
+ break;
+ case ATLAS_TYPE_BIGDECIMAL:
+ ret = GraphHelper.getSingleValuedProperty(entityVertex, vertexPropertyName, BigDecimal.class);
+ break;
+ case ATLAS_TYPE_DATE:
+ ret = new Date(GraphHelper.getSingleValuedProperty(entityVertex, vertexPropertyName, Long.class));
+ break;
+ default:
+ break;
+ }
+
+ return ret;
+ }
+
+ private AtlasObjectId mapVertexToObjectId(AtlasVertex entityVertex, final String edgeLabel, final AtlasEdge optionalEdge,
+ AtlasEntityExtInfo entityExtInfo, boolean isOwnedAttribute) throws AtlasBaseException {
+ AtlasObjectId ret = new AtlasObjectId();
+ AtlasEdge edge;
+
+ if (optionalEdge == null) {
+ edge = graphHelper.getEdgeForLabel(entityVertex, edgeLabel);
+ } else {
+ edge = optionalEdge;
+ }
+
+ if (GraphHelper.elementExists(edge)) {
+ final AtlasVertex referenceVertex = edge.getInVertex();
+ final String guid = GraphHelper.getSingleValuedProperty(referenceVertex, Constants.GUID_PROPERTY_KEY, String.class);
+ final String typeName = GraphHelper.getTypeName(referenceVertex);
+
+ if (entityExtInfo != null && isOwnedAttribute) {
+ mapVertexToAtlasEntity(guid, entityExtInfo);
+ }
+
+ ret = new AtlasObjectId(typeName, guid);
+ }
+
+ return ret;
+ }
+
+ private AtlasStruct mapVertexToStruct(AtlasVertex entityVertex, final String edgeLabel, final AtlasEdge optionalEdge,
+ AtlasEntityExtInfo entityExtInfo) throws AtlasBaseException {
+ AtlasStruct ret = null;
+ AtlasEdge edge;
+
+ if (optionalEdge == null) {
+ edge = graphHelper.getEdgeForLabel(entityVertex, edgeLabel);
+ } else {
+ edge = optionalEdge;
+ }
+
+ if (GraphHelper.elementExists(edge)) {
+ final AtlasVertex referenceVertex = edge.getInVertex();
+ ret = new AtlasStruct(GraphHelper.getSingleValuedProperty(referenceVertex, Constants.ENTITY_TYPE_PROPERTY_KEY, String.class));
+
+ mapAttributes(referenceVertex, ret, entityExtInfo);
+ }
+
+ return ret;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/808eb1d1/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityStoreV1Test.java
----------------------------------------------------------------------
diff --git a/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityStoreV1Test.java b/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityStoreV1Test.java
index 6cbb602..197e46a 100644
--- a/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityStoreV1Test.java
+++ b/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityStoreV1Test.java
@@ -35,8 +35,6 @@ import org.apache.atlas.model.typedef.AtlasTypesDef;
import org.apache.atlas.repository.graph.AtlasGraphProvider;
import org.apache.atlas.repository.graph.GraphBackedSearchIndexer;
import org.apache.atlas.repository.store.graph.AtlasEntityStore;
-import org.apache.atlas.repository.store.graph.EntityGraphDiscovery;
-import org.apache.atlas.repository.store.graph.EntityResolver;
import org.apache.atlas.services.MetadataService;
import org.apache.atlas.store.AtlasTypeDefStore;
import org.apache.atlas.type.AtlasArrayType;
@@ -135,7 +133,7 @@ public class AtlasEntityStoreV1Test {
MapVertexMapper mapVertexMapper = new MapVertexMapper(deleteHandler);
- entityStore = new AtlasEntityStoreV1(new EntityGraphMapper(arrVertexMapper, mapVertexMapper, deleteHandler));
+ entityStore = new AtlasEntityStoreV1(new EntityGraphMapper(arrVertexMapper, mapVertexMapper, deleteHandler), new GraphEntityMapper());
entityStore.init(typeRegistry);
RequestContextV1.clear();
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/808eb1d1/server-api/src/main/java/org/apache/atlas/services/MetadataService.java
----------------------------------------------------------------------
diff --git a/server-api/src/main/java/org/apache/atlas/services/MetadataService.java b/server-api/src/main/java/org/apache/atlas/services/MetadataService.java
index 9b2bc9e..e0fb66c 100644
--- a/server-api/src/main/java/org/apache/atlas/services/MetadataService.java
+++ b/server-api/src/main/java/org/apache/atlas/services/MetadataService.java
@@ -29,7 +29,6 @@ import org.apache.atlas.typesystem.Referenceable;
import org.apache.atlas.typesystem.Struct;
import org.apache.atlas.typesystem.IStruct;
import org.apache.atlas.typesystem.types.cache.TypeCache;
-import org.apache.atlas.utils.ParamChecker;
import org.codehaus.jettison.json.JSONObject;
import java.util.List;
@@ -49,7 +48,7 @@ public interface MetadataService {
*/
JSONObject createType(String typeDefinition) throws AtlasException;
- /**
+ /**z
* Updates the given types in the type definition
* @param typeDefinition
* @return
[3/3] incubator-atlas git commit: ATLAS-1521 : Update UI to eliminate
REST calls to obtain schema data
Posted by ma...@apache.org.
ATLAS-1521 : Update UI to eliminate REST calls to obtain schema data
Signed-off-by: Madhan Neethiraj <ma...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/incubator-atlas/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-atlas/commit/dd744765
Tree: http://git-wip-us.apache.org/repos/asf/incubator-atlas/tree/dd744765
Diff: http://git-wip-us.apache.org/repos/asf/incubator-atlas/diff/dd744765
Branch: refs/heads/master
Commit: dd7447658e4d917eb9a25aec6412b0a96016cc5c
Parents: 808eb1d
Author: kevalbhatt <kb...@apache.org>
Authored: Fri Feb 3 19:19:16 2017 +0530
Committer: Madhan Neethiraj <ma...@apache.org>
Committed: Tue Feb 7 19:40:09 2017 -0800
----------------------------------------------------------------------
dashboardv2/public/js/collection/VEntityList.js | 39 ++-
dashboardv2/public/js/main.js | 28 +-
dashboardv2/public/js/modules/Modal.js | 3 +-
dashboardv2/public/js/router/Router.js | 31 +--
.../public/js/utils/CommonViewFunction.js | 39 ++-
.../js/views/audit/AuditTableLayoutView.js | 18 +-
.../views/audit/CreateAuditTableLayoutView.js | 34 +--
.../BusinessCatalogDetailLayoutView.js | 2 +-
.../business_catalog/BusinessCatalogHeader.js | 2 +-
.../views/business_catalog/SideNavLayoutView.js | 6 +-
.../js/views/business_catalog/TreeLayoutView.js | 2 +-
.../public/js/views/common/aboutAtlas.js | 2 +-
.../views/detail_page/DetailPageLayoutView.js | 104 +++----
.../views/entity/EntityDetailTableLayoutView.js | 17 +-
.../public/js/views/graph/LineageLayoutView.js | 2 +-
.../public/js/views/schema/SchemaLayoutView.js | 271 +++++++------------
.../public/js/views/search/SearchLayoutView.js | 2 +-
.../views/tag/TagAttributeDetailLayoutView.js | 2 +-
.../public/js/views/tag/TagDetailLayoutView.js | 2 +-
.../js/views/tag/TagDetailTableLayoutView.js | 6 +-
.../public/js/views/tag/TagLayoutView.js | 14 +-
.../public/js/views/tag/addTagModalView.js | 4 +-
22 files changed, 292 insertions(+), 338 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/dd744765/dashboardv2/public/js/collection/VEntityList.js
----------------------------------------------------------------------
diff --git a/dashboardv2/public/js/collection/VEntityList.js b/dashboardv2/public/js/collection/VEntityList.js
index 642ef93..e5ee38e 100644
--- a/dashboardv2/public/js/collection/VEntityList.js
+++ b/dashboardv2/public/js/collection/VEntityList.js
@@ -39,22 +39,33 @@ define(['require',
// if (!this.modelAttrName) {
// throw new Error("this.modelAttrName not defined for " + this);
// }
- if (this.modelAttrName && this.modelAttrName === "createEntity") {
- var arr = [];
- arr.push({
- attributes: resp.attributes,
- classifications: resp.classifications,
- guid: resp.guid,
- typeName: resp.typeName
- });
- return arr;
- } else {
- if (resp[this.modelAttrName]) {
- return resp[this.modelAttrName];
- } else {
- return resp
+ if (resp.entity && resp.referredEntities) {
+ var obj = {
+ entity: resp.entity,
+ referredEntities: resp.referredEntities
}
+ return obj;
+ } else if (resp[this.modelAttrName]) {
+ return resp[this.modelAttrName];
+ } else {
+ return resp
}
+ // if (this.modelAttrName && this.modelAttrName === "createEntity") {
+ // var arr = [];
+ // arr.push({
+ // attributes: resp.attributes,
+ // classifications: resp.classifications,
+ // guid: resp.guid,
+ // typeName: resp.typeName
+ // });
+ // return arr;
+ // } else {
+ // if (resp[this.modelAttrName]) {
+ // return resp[this.modelAttrName];
+ // } else {
+ // return resp
+ // }
+ // }
} catch (e) {
console.log(e);
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/dd744765/dashboardv2/public/js/main.js
----------------------------------------------------------------------
diff --git a/dashboardv2/public/js/main.js b/dashboardv2/public/js/main.js
index 2ba87a7..ae5f6af 100644
--- a/dashboardv2/public/js/main.js
+++ b/dashboardv2/public/js/main.js
@@ -160,12 +160,27 @@ require(['App',
'utils/CommonViewFunction',
'utils/Globals',
'utils/UrlLinks',
+ 'collection/VEntityList',
'utils/Overrides',
'bootstrap',
'd3',
'select2'
-], function(App, Router, CommonViewFunction, Globals, UrlLinks) {
- App.appRouter = new Router();
+], function(App, Router, CommonViewFunction, Globals, UrlLinks, VEntityList) {
+ var that = this;
+ this.asyncFetchCounter = 2;
+ this.entityDefCollection = new VEntityList();
+ that.entityDefCollection.url = UrlLinks.entitiesDefApiUrl()
+ that.entityDefCollection.modelAttrName = 'list';
+
+ App.appRouter = new Router({
+ entityDefCollection: this.entityDefCollection
+ });
+
+ var startApp = function() {
+ if (that.asyncFetchCounter === 0) {
+ App.start();
+ }
+ };
CommonViewFunction.userDataFetch({
url: UrlLinks.sessionApiUrl(),
callback: function(response) {
@@ -192,7 +207,14 @@ require(['App',
}
}
}
- App.start();
+ --that.asyncFetchCounter;
+ startApp();
+ }
+ });
+ that.entityDefCollection.fetch({
+ complete: function() {
+ --that.asyncFetchCounter;
+ startApp();
}
});
});
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/dd744765/dashboardv2/public/js/modules/Modal.js
----------------------------------------------------------------------
diff --git a/dashboardv2/public/js/modules/Modal.js b/dashboardv2/public/js/modules/Modal.js
index 7889fea..1f64f40 100644
--- a/dashboardv2/public/js/modules/Modal.js
+++ b/dashboardv2/public/js/modules/Modal.js
@@ -82,6 +82,7 @@ define(function(require) {
okCloses: true,
cancelText: 'Cancel',
allowCancel: false,
+ allowBackdrop: true,
showFooter: true,
escape: true,
animate: true,
@@ -145,7 +146,7 @@ define(function(require) {
//Create it
$el.modal(_.extend({
keyboard: this.options.allowCancel,
- backdrop: this.options.allowCancel ? true : 'static'
+ backdrop: this.options.allowBackdrop ? 'static' : true
}, this.options.modalOptions));
//Focus OK button
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/dd744765/dashboardv2/public/js/router/Router.js
----------------------------------------------------------------------
diff --git a/dashboardv2/public/js/router/Router.js b/dashboardv2/public/js/router/Router.js
index 7394946..5fbd656 100644
--- a/dashboardv2/public/js/router/Router.js
+++ b/dashboardv2/public/js/router/Router.js
@@ -41,13 +41,11 @@ define([
// Default
'*actions': 'defaultAction'
},
- initialize: function() {
+ initialize: function(options) {
+ _.extend(this, _.pick(options, 'entityDefCollection'));
this.showRegions();
this.bindCommonEvents();
this.listenTo(this, 'route', this.postRouteExecute, this);
- this.globalVent = new Backbone.Wreqr.EventAggregator();
- this.catalogVent = new Backbone.Wreqr.EventAggregator();
- this.tagVent = new Backbone.Wreqr.EventAggregator();
this.tagCollection = new VTagList();
},
bindCommonEvents: function() {
@@ -111,15 +109,14 @@ define([
var paramObj = Utils.getUrlState.getQueryParams();
this.collection = new VCatalogList();
this.collection.url = url;
- App.rNHeader.show(new BusinessCatalogHeader({ 'globalVent': that.globalVent, 'url': url, 'collection': this.collection }));
+ App.rNHeader.show(new BusinessCatalogHeader({ 'url': url, 'collection': this.collection }));
if (!App.rSideNav.currentView) {
- App.rSideNav.show(new SideNavLayoutView({ 'globalVent': that.globalVent, 'url': url, 'collection': that.tagCollection }));
+ App.rSideNav.show(new SideNavLayoutView({ 'url': url, 'collection': that.tagCollection }));
} else {
App.rSideNav.currentView.RBusinessCatalogLayoutView.currentView.manualRender("/" + url);
App.rSideNav.currentView.selectTab();
}
App.rNContent.show(new BusinessCatalogDetailLayoutView({
- 'globalVent': that.globalVent,
'url': url,
'collection': this.collection
}));
@@ -139,16 +136,16 @@ define([
'collection/VEntityList'
], function(Header, DetailPageLayoutView, SideNavLayoutView, VEntityList) {
this.entityCollection = new VEntityList([], {});
- App.rNHeader.show(new Header({ 'globalVent': that.globalVent }));
+ App.rNHeader.show(new Header());
if (!App.rSideNav.currentView) {
- App.rSideNav.show(new SideNavLayoutView({ 'globalVent': that.globalVent, 'collection': that.tagCollection }));
+ App.rSideNav.show(new SideNavLayoutView({ 'collection': that.tagCollection }));
} else {
App.rSideNav.currentView.selectTab();
}
App.rNContent.show(new DetailPageLayoutView({
- 'globalVent': that.globalVent,
'collection': this.entityCollection,
'id': id,
+ 'entityDefCollection': that.entityDefCollection,
}));
this.entityCollection.url = UrlLinks.entitiesApiUrl(id);
this.entityCollection.fetch({ reset: true });
@@ -163,10 +160,9 @@ define([
'views/business_catalog/SideNavLayoutView',
'views/tag/TagDetailLayoutView',
], function(Header, BusinessCatalogLayoutView, SideNavLayoutView, TagDetailLayoutView) {
- App.rNHeader.show(new Header({ 'globalVent': that.globalVent, 'vent': that.catalogVent }));
+ App.rNHeader.show(new Header());
if (!App.rSideNav.currentView) {
App.rSideNav.show(new SideNavLayoutView({
- 'globalVent': that.globalVent,
'tag': tagName,
'collection': that.tagCollection
}));
@@ -177,7 +173,6 @@ define([
if (tagName) {
App.rNContent.show(new TagDetailLayoutView({
- 'globalVent': that.globalVent,
'tag': tagName,
'collection': that.tagCollection
}));
@@ -193,10 +188,9 @@ define([
'views/search/SearchDetailLayoutView',
], function(Header, BusinessCatalogLayoutView, SideNavLayoutView, SearchDetailLayoutView) {
var paramObj = Utils.getUrlState.getQueryParams();
- App.rNHeader.show(new Header({ 'globalVent': that.globalVent }));
+ App.rNHeader.show(new Header());
if (!App.rSideNav.currentView) {
App.rSideNav.show(new SideNavLayoutView({
- 'globalVent': that.globalVent,
'collection': that.tagCollection
}));
} else {
@@ -209,8 +203,8 @@ define([
}
if (Globals.entityCreate && Utils.getUrlState.isSearchTab()) {
App.rNContent.show(new SearchDetailLayoutView({
- 'globalVent': that.globalVent,
'value': paramObj,
+ 'entityDefCollection': that.entityDefCollection,
'initialView': true
}))
} else {
@@ -228,10 +222,9 @@ define([
'views/search/SearchDetailLayoutView'
], function(Header, BusinessCatalogLayoutView, SideNavLayoutView, SearchDetailLayoutView) {
var paramObj = Utils.getUrlState.getQueryParams();
- App.rNHeader.show(new Header({ 'globalVent': that.globalVent, 'vent': that.catalogVent }));
+ App.rNHeader.show(new Header());
if (!App.rSideNav.currentView) {
App.rSideNav.show(new SideNavLayoutView({
- 'globalVent': that.globalVent,
'value': paramObj,
'collection': that.tagCollection
}));
@@ -240,8 +233,8 @@ define([
}
App.rSideNav.currentView.selectTab();
App.rNContent.show(new SearchDetailLayoutView({
- 'globalVent': that.globalVent,
'value': paramObj,
+ 'entityDefCollection': that.entityDefCollection,
'initialView': paramObj.query.trim().length === 0
}));
});
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/dd744765/dashboardv2/public/js/utils/CommonViewFunction.js
----------------------------------------------------------------------
diff --git a/dashboardv2/public/js/utils/CommonViewFunction.js b/dashboardv2/public/js/utils/CommonViewFunction.js
index e15759a..318067b 100644
--- a/dashboardv2/public/js/utils/CommonViewFunction.js
+++ b/dashboardv2/public/js/utils/CommonViewFunction.js
@@ -36,6 +36,9 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum
require(['models/VTag'], function(VTag) {
var tagModel = new VTag();
if (options && options.guid && options.tagName) {
+ if (options.showLoader) {
+ options.showLoader();
+ }
tagModel.deleteTag(options.guid, options.tagName, {
skipDefaultError: true,
success: function(data) {
@@ -61,6 +64,9 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum
if (response && response.responseJSON) {
message = response.responseJSON.errorMessage;
}
+ if (options.hideLoader) {
+ options.hideLoader();
+ }
Utils.notifyError({
content: message
});
@@ -69,6 +75,19 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum
}
});
};
+ CommonViewFunction.findAndmergeRefEntity = function(attributeObject, referredEntities) {
+ _.each(attributeObject, function(obj, key) {
+ if (_.isObject(obj)) {
+ if (_.isArray(obj)) {
+ _.each(obj, function(value) {
+ _.extend(value, referredEntities[value.guid]);
+ });
+ } else {
+ _.extend(obj, referredEntities[obj.guid]);
+ }
+ }
+ });
+ }
CommonViewFunction.propertyTable = function(valueObject, scope, searchTable) {
var table = "",
fetchInputOutputValue = function(id) {
@@ -77,9 +96,10 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum
++scope.fetchList
}
scope.entityModel.getEntity(id, {
- success: function(data) {
+ success: function(serverData) {
var value = "",
- deleteButton = "";
+ deleteButton = "",
+ data = serverData.entity;
if (data && data.attributes) {
if (data.attributes.name) {
value = data.attributes.name;
@@ -118,18 +138,19 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum
key = _.escape(key)
var keyValue = valueObject[key],
valueOfArray = [];
- if (_.isArray(keyValue) || _.isObject(keyValue)) {
+ if (_.isObject(keyValue)) {
if (!_.isArray(keyValue) && _.isObject(keyValue)) {
keyValue = [keyValue];
}
var subLink = "";
for (var i = 0; i < keyValue.length; i++) {
var inputOutputField = keyValue[i],
- id = inputOutputField.guid || inputOutputField.id,
+ id = inputOutputField.guid || (_.isObject(inputOutputField.id) ? inputOutputField.id.id : inputOutputField.id),
tempLink = "",
- readOnly = false;
- if (Enums.entityStateReadOnly[inputOutputField.status]) {
- readOnly = inputOutputField.status
+ status = inputOutputField.status || (_.isObject(inputOutputField.id) ? inputOutputField.id.state : inputOutputField.state),
+ readOnly = Enums.entityStateReadOnly[status];
+ if (!inputOutputField.attributes && inputOutputField.values) {
+ inputOutputField['attributes'] = inputOutputField.values;
}
if (_.isString(inputOutputField) || _.isBoolean(inputOutputField) || _.isNumber(inputOutputField)) {
if (inputOutputField.indexOf("$") == -1) {
@@ -289,7 +310,7 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum
if (!obj) {
return "";
}
- var traits = obj.classificationNames,
+ var traits = obj.classificationNames || _.pluck(obj.classifications, 'typeName'),
url = "",
deleteHtml = "",
html = "",
@@ -332,7 +353,7 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum
}
CommonViewFunction.tagForTable = function(obj) {
- var traits = obj.classificationNames,
+ var traits = obj.classificationNames || _.pluck(obj.classifications, 'typeName'),
atags = "",
addTag = "",
popTag = "",
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/dd744765/dashboardv2/public/js/views/audit/AuditTableLayoutView.js
----------------------------------------------------------------------
diff --git a/dashboardv2/public/js/views/audit/AuditTableLayoutView.js b/dashboardv2/public/js/views/audit/AuditTableLayoutView.js
index 2c0bc8c..da8cfda 100644
--- a/dashboardv2/public/js/views/audit/AuditTableLayoutView.js
+++ b/dashboardv2/public/js/views/audit/AuditTableLayoutView.js
@@ -57,7 +57,7 @@ define(['require',
* @constructs
*/
initialize: function(options) {
- _.extend(this, _.pick(options, 'globalVent', 'guid', 'vent', 'entityObject'));
+ _.extend(this, _.pick(options, 'guid', 'entity'));
this.entityCollection = new VEntityList();
this.count = 26;
this.entityCollection.url = UrlLinks.entityCollectionaudit(this.guid);
@@ -78,7 +78,6 @@ define(['require',
paginatorOpts: {}
};
this.currPage = 1;
- this.bindEvents();
},
onRender: function() {
$.extend(this.entityCollection.queryParams, { count: this.count });
@@ -89,17 +88,7 @@ define(['require',
});
this.renderTableLayoutView();
},
- bindEvents: function() {
- var that = this;
- this.listenTo(this.vent, "reset:collection", function() {
- this.fetchCollection({
- next: this.ui.nextAuditData,
- nextClick: false,
- previous: this.ui.previousAuditData
- });
- }, this);
-
- },
+ bindEvents: function() {},
getToOffset: function() {
var toOffset = 0;
if (this.entityCollection.models.length < this.count) {
@@ -169,7 +158,6 @@ define(['require',
require(['utils/TableLayout'], function(TableLayout) {
var cols = new Backgrid.Columns(that.getAuditTableColumns());
that.RAuditTableLayoutView.show(new TableLayout(_.extend({}, that.commonTableOptions, {
- globalVent: that.globalVent,
columns: cols
})));
if (!(that.entityCollection.models.length < that.count)) {
@@ -236,7 +224,7 @@ define(['require',
that.action = $(e.target).data("action");
var eventModel = that.entityCollection.findWhere({ 'eventKey': $(e.currentTarget).data('modalid') }).toJSON(),
collectionModel = new that.entityCollection.model(eventModel),
- view = new CreateAuditTableLayoutView({ guid: that.guid, entityModel: collectionModel, action: that.action, entityObject: that.entityObject });
+ view = new CreateAuditTableLayoutView({ guid: that.guid, entityModel: collectionModel, action: that.action, entity: that.entity });
var modal = new Modal({
title: that.action,
content: view,
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/dd744765/dashboardv2/public/js/views/audit/CreateAuditTableLayoutView.js
----------------------------------------------------------------------
diff --git a/dashboardv2/public/js/views/audit/CreateAuditTableLayoutView.js b/dashboardv2/public/js/views/audit/CreateAuditTableLayoutView.js
index 330809f..0abff47 100644
--- a/dashboardv2/public/js/views/audit/CreateAuditTableLayoutView.js
+++ b/dashboardv2/public/js/views/audit/CreateAuditTableLayoutView.js
@@ -54,7 +54,7 @@ define(['require',
* @constructs
*/
initialize: function(options) {
- _.extend(this, _.pick(options, 'globalVent', 'guid', 'entityModel', 'action', 'entityObject'));
+ _.extend(this, _.pick(options, 'guid', 'entityModel', 'action', 'entity'));
},
bindEvents: function() {},
onRender: function() {
@@ -63,24 +63,27 @@ define(['require',
auditTableGenerate: function() {
var that = this,
table = "";
- if (this.entityModel.get('details').search('{') >= 0) {
- var appendedString = "{" + this.entityModel.get('details') + "}";
+ var detailObj = this.entityModel.get('details');
+ if (detailObj && detailObj.search(':') >= 0) {
+ var parseDetailsObject = detailObj;
+ var appendedString = "{" + detailObj + "}";
var auditData = appendedString.split('"')[0].split(':')[0].split("{")[1];
try {
- var detailsObject = JSON.parse(appendedString.replace("{" + auditData + ":", '{"' + auditData + '":'))[auditData];
+ parseDetailsObject = JSON.parse(appendedString.replace("{" + auditData + ":", '{"' + auditData + '":'))[auditData];
+ var name = _.escape(parseDetailsObject.typeName);
} catch (err) {
- Utils.serverErrorHandler();
- }
- //Append string for JSON parse
- if (detailsObject) {
- var valueObject = detailsObject.values;
+ if (parseDetailsObject.search(':') >= 0) {
+ var name = parseDetailsObject.split(":")[1];
+ }
}
- if ((this.action == Enums.auditAction.TAG_ADD || Enums.auditAction.ENTITY_CREATE) && detailsObject) {
- this.ui.auditHeaderValue.html('<th>' + (this.action === Enums.auditAction.ENTITY_CREATE ? Enums.auditAction.ENTITY_CREATE : Enums.auditAction.TAG_ADD) + '</th>');
- this.ui.auditValue.html("<tr><td>" + _.escape(detailsObject.typeName) + "</td></tr>");
- } else {
+ var values = parseDetailsObject.values;
+ if (this.action && (Enums.auditAction.ENTITY_CREATE !== this.action && Enums.auditAction.ENTITY_UPDATE !== this.action) && name) {
+ this.ui.auditHeaderValue.html('<th>' + this.action + '</th>');
+ this.ui.auditValue.html("<tr><td>" + name + "</td></tr>");
+ } else if (parseDetailsObject && parseDetailsObject.values) {
this.ui.auditHeaderValue.html('<th>Key</th><th>New Value</th>');
- table = CommonViewFunction.propertyTable(valueObject, this);
+ //CommonViewFunction.findAndmergeRefEntity(attributeObject, that.referredEntities);
+ table = CommonViewFunction.propertyTable(values, this);
if (table.length) {
this.ui.noData.hide();
this.ui.tableAudit.show();
@@ -90,9 +93,6 @@ define(['require',
this.ui.tableAudit.hide();
}
}
- } else if (this.action == Enums.auditAction.TAG_DELETE || Enums.auditAction.ENTITY_DELETE) {
- this.ui.auditHeaderValue.html('<th>' + Enums.auditAction.TAG_DELETE || Enums.auditAction.ENTITY_DELETE + '</th>');
- this.ui.auditValue.html("<tr><td>" + (this.entityObject.name || this.entityObject.qualifiedName) + "</td></tr>");
}
},
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/dd744765/dashboardv2/public/js/views/business_catalog/BusinessCatalogDetailLayoutView.js
----------------------------------------------------------------------
diff --git a/dashboardv2/public/js/views/business_catalog/BusinessCatalogDetailLayoutView.js b/dashboardv2/public/js/views/business_catalog/BusinessCatalogDetailLayoutView.js
index 6971a3a..c7fcfa1 100644
--- a/dashboardv2/public/js/views/business_catalog/BusinessCatalogDetailLayoutView.js
+++ b/dashboardv2/public/js/views/business_catalog/BusinessCatalogDetailLayoutView.js
@@ -55,7 +55,7 @@ define(['require',
* @constructs
*/
initialize: function(options) {
- _.extend(this, _.pick(options, 'globalVent', 'url', 'collection'));
+ _.extend(this, _.pick(options, 'url', 'collection'));
this.bindEvents();
},
bindEvents: function() {
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/dd744765/dashboardv2/public/js/views/business_catalog/BusinessCatalogHeader.js
----------------------------------------------------------------------
diff --git a/dashboardv2/public/js/views/business_catalog/BusinessCatalogHeader.js b/dashboardv2/public/js/views/business_catalog/BusinessCatalogHeader.js
index 7247ac0..4994372 100644
--- a/dashboardv2/public/js/views/business_catalog/BusinessCatalogHeader.js
+++ b/dashboardv2/public/js/views/business_catalog/BusinessCatalogHeader.js
@@ -29,7 +29,7 @@ define(['require',
regions: {},
events: {},
initialize: function(options) {
- _.extend(this, _.pick(options, 'globalVent', 'url', 'collection'));
+ _.extend(this, _.pick(options, 'url', 'collection'));
this.value = [];
},
/**
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/dd744765/dashboardv2/public/js/views/business_catalog/SideNavLayoutView.js
----------------------------------------------------------------------
diff --git a/dashboardv2/public/js/views/business_catalog/SideNavLayoutView.js b/dashboardv2/public/js/views/business_catalog/SideNavLayoutView.js
index 43bdaeb..9254213 100644
--- a/dashboardv2/public/js/views/business_catalog/SideNavLayoutView.js
+++ b/dashboardv2/public/js/views/business_catalog/SideNavLayoutView.js
@@ -66,7 +66,7 @@ define(['require',
return events;
},
initialize: function(options) {
- _.extend(this, _.pick(options, 'globalVent', 'url', 'value', 'tag', 'selectFirst','collection'));
+ _.extend(this, _.pick(options, 'url', 'value', 'tag', 'selectFirst', 'collection'));
if (Globals.taxonomy) {
this.tabClass = "tab col-sm-4";
} else {
@@ -88,7 +88,6 @@ define(['require',
var that = this;
require(['views/business_catalog/BusinessCatalogLayoutView'], function(BusinessCatalogLayoutView) {
that.RBusinessCatalogLayoutView.show(new BusinessCatalogLayoutView({
- globalVent: that.globalVent,
url: that.url
}));
});
@@ -97,7 +96,6 @@ define(['require',
var that = this;
require(['views/tag/TagLayoutView'], function(TagLayoutView) {
that.RTagLayoutView.show(new TagLayoutView({
- globalVent: that.globalVent,
collection: that.collection,
tag: that.tag
}));
@@ -107,8 +105,6 @@ define(['require',
var that = this;
require(['views/search/SearchLayoutView'], function(SearchLayoutView) {
that.RSearchLayoutView.show(new SearchLayoutView({
- globalVent: that.globalVent,
- vent: that.vent,
value: that.value
}));
});
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/dd744765/dashboardv2/public/js/views/business_catalog/TreeLayoutView.js
----------------------------------------------------------------------
diff --git a/dashboardv2/public/js/views/business_catalog/TreeLayoutView.js b/dashboardv2/public/js/views/business_catalog/TreeLayoutView.js
index b872e50..7c8eb23 100644
--- a/dashboardv2/public/js/views/business_catalog/TreeLayoutView.js
+++ b/dashboardv2/public/js/views/business_catalog/TreeLayoutView.js
@@ -92,7 +92,7 @@ define(['require',
* @constructs
*/
initialize: function(options) {
- _.extend(this, _.pick(options, 'globalVent', 'url', 'viewBased'));
+ _.extend(this, _.pick(options, 'url', 'viewBased'));
this.parentCollection = new VCatalogList();
this.childCollection = new VCatalogList();
this.taxanomy = new VCatalogList();
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/dd744765/dashboardv2/public/js/views/common/aboutAtlas.js
----------------------------------------------------------------------
diff --git a/dashboardv2/public/js/views/common/aboutAtlas.js b/dashboardv2/public/js/views/common/aboutAtlas.js
index 8fff13c..9561b83 100644
--- a/dashboardv2/public/js/views/common/aboutAtlas.js
+++ b/dashboardv2/public/js/views/common/aboutAtlas.js
@@ -41,7 +41,7 @@ define(['require',
* @constructs
*/
initialize: function(options) {
- _.extend(this, _.pick(options, 'globalVent'));
+ _.extend(this, options);
},
bindEvents: function() {
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/dd744765/dashboardv2/public/js/views/detail_page/DetailPageLayoutView.js
----------------------------------------------------------------------
diff --git a/dashboardv2/public/js/views/detail_page/DetailPageLayoutView.js b/dashboardv2/public/js/views/detail_page/DetailPageLayoutView.js
index d778e3e..83918e7 100644
--- a/dashboardv2/public/js/views/detail_page/DetailPageLayoutView.js
+++ b/dashboardv2/public/js/views/detail_page/DetailPageLayoutView.js
@@ -102,14 +102,14 @@ define(['require',
* @constructs
*/
initialize: function(options) {
- _.extend(this, _.pick(options, 'globalVent', 'collection', 'vent', 'id'));
+ _.extend(this, _.pick(options, 'collection', 'id', 'entityDefCollection'));
this.bindEvents();
- this.auditVent = new Backbone.Wreqr.EventAggregator();
},
bindEvents: function() {
var that = this;
this.listenTo(this.collection, 'reset', function() {
- var collectionJSON = this.collection.first().toJSON();
+ var entityObject = this.collection.first().toJSON();
+ var collectionJSON = entityObject.entity;
if (collectionJSON && collectionJSON.guid) {
var tagGuid = collectionJSON.guid;
this.readOnly = Enums.entityStateReadOnly[collectionJSON.status];
@@ -123,24 +123,13 @@ define(['require',
}
if (collectionJSON) {
if (collectionJSON.attributes) {
- if (collectionJSON.attributes.name) {
- this.name = collectionJSON.attributes.name
- }
- if (!this.name && collectionJSON.attributes.qualifiedName) {
- this.name = collectionJSON.attributes.qualifiedName;
- }
- if (!this.name && collectionJSON.displayText) {
- this.name = collectionJSON.displayText;
- }
+ this.name = (_.escape(collectionJSON.attributes && collectionJSON.attributes.name ? collectionJSON.attributes.name : null) || _.escape(collectionJSON.displayText) || collectionJSON.guid);
if (this.name && collectionJSON.typeName) {
this.name = this.name + ' (' + collectionJSON.typeName + ')';
}
if (!this.name && collectionJSON.typeName) {
this.name = collectionJSON.typeName;
}
- if (!this.name && this.id) {
- this.name = this.id;
- }
this.description = collectionJSON.attributes.description;
if (this.name) {
this.ui.title.show();
@@ -173,12 +162,27 @@ define(['require',
}
}
this.hideLoader();
- this.renderEntityDetailTableLayoutView();
- this.renderAuditTableLayoutView(this.id, collectionJSON.attributes);
- this.renderTagTableLayoutView(tagGuid);
- this.renderTermTableLayoutView(tagGuid);
- this.renderLineageLayoutView(this.id);
- this.renderSchemaLayoutView(this.id);
+ var obj = {
+ entity: collectionJSON,
+ referredEntities: entityObject.referredEntities,
+ guid: this.id,
+ assetName: this.name,
+ entityDefCollection: this.entityDefCollection,
+ fetchCollection: this.fetchCollection.bind(that)
+ }
+ this.renderEntityDetailTableLayoutView(obj);
+ this.renderAuditTableLayoutView(obj);
+ this.renderTagTableLayoutView(obj);
+ this.renderTermTableLayoutView(_.extend({}, obj, { term: true }));
+ this.renderLineageLayoutView(obj);
+ // To render Schema check attribute "schemaElementsAttribute"
+ var schemaOptions = this.entityDefCollection.find({ name: collectionJSON.typeName }).get('options');
+ if (schemaOptions && schemaOptions.hasOwnProperty('schemaElementsAttribute') && schemaOptions.schemaElementsAttribute !== "") {
+ this.$('.schemaTable').show();
+ this.renderSchemaLayoutView(_.extend({}, obj, {
+ attribute: collectionJSON.attributes[schemaOptions.schemaElementsAttribute]
+ }));
+ }
}, this);
this.listenTo(this.collection, 'error', function(model, response) {
this.$('.fontLoader').hide();
@@ -265,7 +269,6 @@ define(['require',
var that = this;
require(['views/tag/addTagModalView'], function(AddTagModalView) {
var view = new AddTagModalView({
- vent: that.vent,
guid: that.id,
tagList: _.map(that.collection.first().toJSON().classifications, function(obj) {
return obj.typeName;
@@ -300,65 +303,40 @@ define(['require',
});
},
- renderEntityDetailTableLayoutView: function() {
+ renderEntityDetailTableLayoutView: function(obj) {
var that = this;
require(['views/entity/EntityDetailTableLayoutView'], function(EntityDetailTableLayoutView) {
- that.REntityDetailTableLayoutView.show(new EntityDetailTableLayoutView({
- globalVent: that.globalVent,
- collection: that.collection
- }));
+ that.REntityDetailTableLayoutView.show(new EntityDetailTableLayoutView(obj));
});
},
- renderTagTableLayoutView: function(tagGuid) {
+ renderTagTableLayoutView: function(obj) {
var that = this;
require(['views/tag/TagDetailTableLayoutView'], function(TagDetailTableLayoutView) {
- that.RTagTableLayoutView.show(new TagDetailTableLayoutView({
- globalVent: that.globalVent,
- collection: that.collection,
- guid: tagGuid,
- assetName: that.name
- }));
+ that.RTagTableLayoutView.show(new TagDetailTableLayoutView(obj));
});
},
- renderLineageLayoutView: function(tagGuid) {
+ renderTermTableLayoutView: function(obj) {
var that = this;
- require(['views/graph/LineageLayoutView'], function(LineageLayoutView) {
- that.RLineageLayoutView.show(new LineageLayoutView({
- globalVent: that.globalVent,
- guid: tagGuid
- }));
+ require(['views/tag/TagDetailTableLayoutView'], function(TagDetailTableLayoutView) {
+ that.RTermTableLayoutView.show(new TagDetailTableLayoutView(obj));
});
},
- renderSchemaLayoutView: function(tagGuid) {
+ renderLineageLayoutView: function(obj) {
var that = this;
- require(['views/schema/SchemaLayoutView'], function(SchemaLayoutView) {
- that.RSchemaTableLayoutView.show(new SchemaLayoutView({
- globalVent: that.globalVent,
- guid: tagGuid
- }));
+ require(['views/graph/LineageLayoutView'], function(LineageLayoutView) {
+ that.RLineageLayoutView.show(new LineageLayoutView(obj));
});
},
- renderAuditTableLayoutView: function(tagGuid, entityObject) {
+ renderSchemaLayoutView: function(obj) {
var that = this;
- require(['views/audit/AuditTableLayoutView'], function(AuditTableLayoutView) {
- that.RAuditTableLayoutView.show(new AuditTableLayoutView({
- globalVent: that.globalVent,
- guid: tagGuid,
- vent: that.auditVent,
- entityObject: entityObject
- }));
+ require(['views/schema/SchemaLayoutView'], function(SchemaLayoutView) {
+ that.RSchemaTableLayoutView.show(new SchemaLayoutView(obj));
});
},
- renderTermTableLayoutView: function(tagGuid) {
+ renderAuditTableLayoutView: function(obj) {
var that = this;
- require(['views/tag/TagDetailTableLayoutView'], function(TagDetailTableLayoutView) {
- that.RTermTableLayoutView.show(new TagDetailTableLayoutView({
- globalVent: that.globalVent,
- collection: that.collection,
- guid: tagGuid,
- assetName: that.name,
- term: true
- }));
+ require(['views/audit/AuditTableLayoutView'], function(AuditTableLayoutView) {
+ that.RAuditTableLayoutView.show(new AuditTableLayoutView(obj));
});
},
onClickEditEntity: function(e) {
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/dd744765/dashboardv2/public/js/views/entity/EntityDetailTableLayoutView.js
----------------------------------------------------------------------
diff --git a/dashboardv2/public/js/views/entity/EntityDetailTableLayoutView.js b/dashboardv2/public/js/views/entity/EntityDetailTableLayoutView.js
index 4facf53..a9f7e29 100644
--- a/dashboardv2/public/js/views/entity/EntityDetailTableLayoutView.js
+++ b/dashboardv2/public/js/views/entity/EntityDetailTableLayoutView.js
@@ -19,8 +19,9 @@
define(['require',
'backbone',
'hbs!tmpl/entity/EntityDetailTableLayoutView_tmpl',
- 'utils/CommonViewFunction'
-], function(require, Backbone, EntityDetailTableLayoutView_tmpl, CommonViewFunction) {
+ 'utils/CommonViewFunction',
+ 'models/VEntity',
+], function(require, Backbone, EntityDetailTableLayoutView_tmpl, CommonViewFunction, VEntity) {
'use strict';
var EntityDetailTableLayoutView = Backbone.Marionette.LayoutView.extend(
@@ -47,9 +48,8 @@ define(['require',
* @constructs
*/
initialize: function(options) {
- _.extend(this, _.pick(options, 'globalVent', 'collection'));
- this.collectionObject = this.collection.toJSON();
- this.entityModel = new this.collection.model();
+ _.extend(this, _.pick(options, 'entity', 'referredEntities'));
+ this.entityModel = new VEntity({});
},
bindEvents: function() {},
onRender: function() {
@@ -57,13 +57,14 @@ define(['require',
},
entityTableGenerate: function() {
var that = this,
- attributeObject = this.collection.first().toJSON().attributes;
- if (attributeObject) {
+ attributeObject = this.entity.attributes;
+ CommonViewFunction.findAndmergeRefEntity(attributeObject, that.referredEntities);
+ if (attributeObject && attributeObject.columns) {
var valueSorted = _.sortBy(attributeObject.columns, function(val) {
return val.attributes.position
});
+ attributeObject.columns = valueSorted;
}
- attributeObject.columns = valueSorted;
var table = CommonViewFunction.propertyTable(attributeObject, this);
that.ui.detailValue.append(table);
}
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/dd744765/dashboardv2/public/js/views/graph/LineageLayoutView.js
----------------------------------------------------------------------
diff --git a/dashboardv2/public/js/views/graph/LineageLayoutView.js b/dashboardv2/public/js/views/graph/LineageLayoutView.js
index 853b0bd..32766c3 100644
--- a/dashboardv2/public/js/views/graph/LineageLayoutView.js
+++ b/dashboardv2/public/js/views/graph/LineageLayoutView.js
@@ -56,7 +56,7 @@ define(['require',
* @constructs
*/
initialize: function(options) {
- _.extend(this, _.pick(options, 'globalVent', 'guid'));
+ _.extend(this, _.pick(options, 'guid'));
this.entityModel = new VEntity();
this.collection = new VLineageList();
this.typeMap = {};
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/dd744765/dashboardv2/public/js/views/schema/SchemaLayoutView.js
----------------------------------------------------------------------
diff --git a/dashboardv2/public/js/views/schema/SchemaLayoutView.js b/dashboardv2/public/js/views/schema/SchemaLayoutView.js
index 483b36c..b15d206 100644
--- a/dashboardv2/public/js/views/schema/SchemaLayoutView.js
+++ b/dashboardv2/public/js/views/schema/SchemaLayoutView.js
@@ -91,9 +91,8 @@ define(['require',
* @constructs
*/
initialize: function(options) {
- _.extend(this, _.pick(options, 'globalVent', 'guid', 'vent'));
+ _.extend(this, _.pick(options, 'guid', 'entityDefCollection', 'attribute', 'referredEntities', 'fetchCollection'));
this.schemaCollection = new VSchemaList([], {});
- this.schemaCollection.url = UrlLinks.schemaApiUrl(this.guid);
this.commonTableOptions = {
collection: this.schemaCollection,
includeFilter: false,
@@ -121,15 +120,10 @@ define(['require',
this.arr = [];
var that = this;
this.schemaCollection.find(function(item) {
+ var obj = item.toJSON();
if (item.get('isEnable')) {
- var term = [];
- var obj = {}
- obj['displayText'] = item.get("name") || item.get("qualifiedName")
- obj['status'] = item.get("$id$").state;
- obj['classificationNames'] = _.keys(item.get('$traits$'));
- obj['guid'] = item.get("$id$").id || item.get("$id$");
that.arr.push({
- id: item.get("$id$").id || item.get("$id$"),
+ id: obj.guid,
model: obj
});
}
@@ -146,15 +140,24 @@ define(['require',
this.$('.multiSelectTag').hide();
}
});
- this.listenTo(this.schemaCollection, "error", function(value) {
- $('.schemaTable').hide();
- this.$('.fontLoader').hide();
- }, this);
},
onRender: function() {
var that = this;
- this.fetchCollection();
- this.renderTableLayoutView();
+ _.each(this.attribute, function(obj) {
+ var defObj = that.entityDefCollection.find({ name: obj.typeName });
+ if (defObj && defObj.get('options') && defObj.get('options').schemaAttributes) {
+ try {
+ var mapObj = JSON.parse(defObj.get('options').schemaAttributes);
+ var newModel = that.referredEntities[obj.guid];
+ newModel.schemaTableAttribute = _.pick(newModel.attributes, mapObj);
+ if (newModel.attributes['position']) {
+ newModel['position'] = newModel.attributes['position'];
+ }
+
+ that.schemaCollection.push(newModel);
+ } catch (e) {}
+ }
+ });
$('body').click(function(e) {
var iconEvnt = e.target.nodeName;
if (that.$('.popoverContainer').length) {
@@ -164,53 +167,41 @@ define(['require',
that.$('.popover.popoverTag').hide();
}
});
+ this.renderTableLayoutView();
},
- fetchCollection: function() {
- var that = this;
+ showLoader: function() {
this.$('.fontLoader').show();
- this.schemaCollection.fetch({
- skipDefaultError: true,
- success: function() {
- that.schemaCollection.sortByKey('position');
- that.renderTableLayoutView();
- $('.schemaTable').show();
- that.$('.fontLoader').hide();
- },
- silent: true
- });
},
hideLoader: function(argument) {
this.$('.fontLoader').hide();
},
renderTableLayoutView: function() {
- var that = this,
- count = 5;
+ var that = this;
require(['utils/TableLayout'], function(TableLayout) {
var columnCollection = Backgrid.Columns.extend({
- sortKey: "position",
- comparator: function(item) {
- return item.get(this.sortKey) || 999;
- },
- setPositions: function() {
- _.each(this.models, function(model, index) {
- if (model.get('name') == "name") {
- model.set("position", 2, { silent: true });
- model.set("label", "Name");
- } else if (model.get('name') == "description") {
- model.set("position", 3, { silent: true });
- model.set("label", "Description");
- } else if (model.get('name') == "owner") {
- model.set("position", 4, { silent: true });
- model.set("label", "Owner");
- }
- });
- return this;
- }
+ // sortKey: "position",
+ // comparator: function(item) {
+ // return item.get(this.sortKey) || 999;
+ // },
+ // setPositions: function() {
+ // _.each(this.models, function(model, index) {
+ // if (model.get('name') == "name") {
+ // model.set("position", 2, { silent: true });
+ // model.set("label", "Name");
+ // } else if (model.get('name') == "description") {
+ // model.set("position", 3, { silent: true });
+ // model.set("label", "Description");
+ // } else if (model.get('name') == "owner") {
+ // model.set("position", 4, { silent: true });
+ // model.set("label", "Owner");
+ // }
+ // });
+ // return this;
+ // }
});
var columns = new columnCollection(that.getSchemaTableColumns());
- columns.setPositions().sort();
+ //columns.setPositions().sort();
that.RTagLayoutView.show(new TableLayout(_.extend({}, that.commonTableOptions, {
- globalVent: that.globalVent,
columns: columns,
includeOrderAbleColumns: true
})));
@@ -230,137 +221,88 @@ define(['require',
},
getSchemaTableColumns: function() {
var that = this,
- col = {},
- nameCheck = false,
- modelJSON = this.schemaCollection.toJSON()[0];
- for (var i = 0; i < this.schemaCollection.models.length; i++) {
- var model = this.schemaCollection.models[i];
- if (model && (model.get('name') || model.get('qualifiedName'))) {
- nameCheck = true;
+ schemaFirstmodel = this.schemaCollection.first(),
+ col = {
+ Check: {
+ name: "selected",
+ label: "",
+ cell: "select-row",
+ headerCell: "select-all"
+ }
}
- }
- if (nameCheck === true) {
- col['name'] = {
- label: "Name",
- cell: "html",
- editable: false,
- sortable: false,
- className: "searchTableName",
- formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
- fromRaw: function(rawValue, model) {
- var nameHtml = "";
- if (rawValue === undefined) {
- if (model.get('qualifiedName')) {
- rawValue = model.get('qualifiedName');
- } else if (model.get('$id$') && model.get('$id$').qualifiedName) {
- rawValue = model.get('$id$').qualifiedName;
- } else {
- return "";
- }
- }
- if (model.get('$id$') && model.get('$id$').id) {
- nameHtml = '<a href="#!/detailPage/' + model.get('$id$').id + '">' + rawValue + '</a>';
- } else {
- nameHtml = '<a>' + rawValue + '</a>';
- }
- if (model.get('$id$') && model.get('$id$').state && Enums.entityStateReadOnly[model.get('$id$').state]) {
- nameHtml += '<button type="button" title="Deleted" class="btn btn-atlasAction btn-atlas deleteBtn"><i class="fa fa-trash"></i></button>';
- return '<div class="readOnly readOnlyLink">' + nameHtml + '</div>';
- } else {
- return nameHtml;
- }
- }
- })
- };
- };
- _.keys(modelJSON).map(function(key) {
- if (key.indexOf("$") == -1) {
- if (!(key === "qualifiedName" || key === "name" || key === "position")) {
+ if (schemaFirstmodel) {
+ _.each(_.keys(schemaFirstmodel.get('schemaTableAttribute')), function(key) {
+ if (key !== "position") {
col[key] = {
- cell: "Html",
+ label: key,
+ cell: "html",
editable: false,
sortable: false,
- orderable: true,
+ className: "searchTableName",
formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
fromRaw: function(rawValue, model) {
- if (model) {
- if (!_.isArray(rawValue) && _.isObject(rawValue)) {
- if (rawValue.id) {
- return '<div><a href="#!/detailPage/' + rawValue.id + '">' + rawValue.$typeName$ + '</a></div>';
- } else {
- return rawValue.$typeName$;
- }
- } else if (_.isArray(rawValue)) {
- var links = "";
- _.each(rawValue, function(val, key) {
- if (val.id) {
- links += '<div><a href="#!/detailPage/' + val.id + '">' + val.$typeName$ + '</a></div>';
- } else {
- links += '<div>' + val.$typeName$ + '</div>';
- }
- });
- return links;
+ var value = model.get('schemaTableAttribute')[key];
+ if (key === "name" && model.get('guid')) {
+ var nameHtml = '<a href="#!/detailPage/' + model.get('guid') + '">' + value + '</a>';
+ if (model.get('status') && Enums.entityStateReadOnly[model.get('status')]) {
+ nameHtml += '<button type="button" title="Deleted" class="btn btn-atlasAction btn-atlas deleteBtn"><i class="fa fa-trash"></i></button>';
+ return '<div class="readOnly readOnlyLink">' + nameHtml + '</div>';
} else {
- return rawValue;
+ return nameHtml;
}
} else {
- return rawValue;
+ return value
}
}
})
};
}
- }
- });
- col['Check'] = {
- name: "selected",
- label: "",
- cell: "select-row",
- headerCell: "select-all",
- position: 1
- };
- col['tag'] = {
- label: "Tags",
- cell: "Html",
- editable: false,
- sortable: false,
- className: 'searchTag',
- formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
- fromRaw: function(rawValue, model) {
- return CommonViewFunction.tagForTable({
- classificationNames: _.keys(model.get('$traits$')),
- guid: model.get('$id$').id || model.get('$id$') || model.get('guid'),
- displayText: model.get('name'),
- status: model.get('$id$').state
- });
- }
- })
- };
- if (Globals.taxonomy) {
- col['terms'] = {
- label: "Terms",
+ });
+ col['tag'] = {
+ label: "Tags",
cell: "Html",
editable: false,
sortable: false,
- orderable: true,
- className: 'searchTerm',
+ className: 'searchTag',
formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
fromRaw: function(rawValue, model) {
- var returnObject = CommonViewFunction.termTableBreadcrumbMaker({
- classificationNames: _.keys(model.get('$traits$')),
- guid: model.get('$id$').id || model.get('$id$') || model.get('guid'),
- displayText: model.get('name'),
- status: model.get('$id$').state
- });
- if (returnObject.object) {
- that.bradCrumbList.push(returnObject.object);
+ var obj = model.toJSON();
+ if (obj.status && Enums.entityStateReadOnly[obj.status]) {
+ return '<div class="readOnly">' + CommonViewFunction.tagForTable(obj); + '</div>';
+ } else {
+ return CommonViewFunction.tagForTable(obj);
}
- return returnObject.html;
}
})
};
+ if (Globals.taxonomy) {
+ col['terms'] = {
+ label: "Terms",
+ cell: "Html",
+ editable: false,
+ sortable: false,
+ orderable: true,
+ className: 'searchTerm',
+ formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
+ fromRaw: function(rawValue, model) {
+ var obj = model.toJSON();
+ var returnObject = CommonViewFunction.termTableBreadcrumbMaker(obj);
+ if (returnObject.object) {
+ that.bradCrumbList.push(returnObject.object);
+ }
+ if (obj.status && Enums.entityStateReadOnly[obj.status]) {
+ return '<div class="readOnly">' + returnObject.html + '</div>';
+ } else {
+ return returnObject.html;
+ }
+
+ }
+ })
+ };
+ }
+ return this.schemaCollection.constructor.getTableCols(col, this.schemaCollection);
}
- return this.schemaCollection.constructor.getTableCols(col, this.schemaCollection);
+
},
checkedValue: function(e) {
if (e) {
@@ -395,11 +337,8 @@ define(['require',
that.fetchCollection();
that.arr = [];
},
- showLoader: function() {
- that.$('.fontLoader').show();
- that.$('.searchTable').hide();
- },
- hideLoader: that.hideLoader.bind(that)
+ hideLoader: that.hideLoader.bind(that),
+ showLoader: that.showLoader.bind(that)
});
// view.saveTagData = function() {
//override saveTagData function
@@ -419,10 +358,8 @@ define(['require',
that.fetchCollection();
that.arr = [];
},
- showLoader: function() {
- that.$('.fontLoader').show();
- that.$('.searchTable').hide();
- }
+ hideLoader: that.hideLoader.bind(that),
+ showLoader: that.showLoader.bind(that)
});
});
},
@@ -462,6 +399,8 @@ define(['require',
'tagName': tagName,
'guid': guid,
'tagOrTerm': tagOrTerm,
+ showLoader: that.showLoader.bind(that),
+ hideLoader: that.hideLoader.bind(that),
callback: function() {
that.fetchCollection();
}
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/dd744765/dashboardv2/public/js/views/search/SearchLayoutView.js
----------------------------------------------------------------------
diff --git a/dashboardv2/public/js/views/search/SearchLayoutView.js b/dashboardv2/public/js/views/search/SearchLayoutView.js
index 958b23b..d1f0591 100644
--- a/dashboardv2/public/js/views/search/SearchLayoutView.js
+++ b/dashboardv2/public/js/views/search/SearchLayoutView.js
@@ -72,7 +72,7 @@ define(['require',
* @constructs
*/
initialize: function(options) {
- _.extend(this, _.pick(options, 'globalVent', 'value'));
+ _.extend(this, _.pick(options, 'value'));
this.typecollection = new VTagList([], {});
this.typecollection.url = UrlLinks.typesApiUrl();
this.type = "fulltext";
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/dd744765/dashboardv2/public/js/views/tag/TagAttributeDetailLayoutView.js
----------------------------------------------------------------------
diff --git a/dashboardv2/public/js/views/tag/TagAttributeDetailLayoutView.js b/dashboardv2/public/js/views/tag/TagAttributeDetailLayoutView.js
index 3cba566..fb74e2f 100644
--- a/dashboardv2/public/js/views/tag/TagAttributeDetailLayoutView.js
+++ b/dashboardv2/public/js/views/tag/TagAttributeDetailLayoutView.js
@@ -59,7 +59,7 @@ define(['require',
* @constructs
*/
initialize: function(options) {
- _.extend(this, _.pick(options, 'globalVent', 'tag', 'collection'));
+ _.extend(this, _.pick(options, 'tag', 'collection'));
},
bindEvents: function() {
this.listenTo(this.collection, 'reset', function() {
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/dd744765/dashboardv2/public/js/views/tag/TagDetailLayoutView.js
----------------------------------------------------------------------
diff --git a/dashboardv2/public/js/views/tag/TagDetailLayoutView.js b/dashboardv2/public/js/views/tag/TagDetailLayoutView.js
index 3e98755..6bdaf39 100644
--- a/dashboardv2/public/js/views/tag/TagDetailLayoutView.js
+++ b/dashboardv2/public/js/views/tag/TagDetailLayoutView.js
@@ -44,7 +44,7 @@ define(['require',
* @constructs
*/
initialize: function(options) {
- _.extend(this, _.pick(options, 'globalVent', 'tag', 'collection'));
+ _.extend(this, _.pick(options, 'tag', 'collection'));
},
bindEvents: function() {},
onRender: function() {
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/dd744765/dashboardv2/public/js/views/tag/TagDetailTableLayoutView.js
----------------------------------------------------------------------
diff --git a/dashboardv2/public/js/views/tag/TagDetailTableLayoutView.js b/dashboardv2/public/js/views/tag/TagDetailTableLayoutView.js
index c02600e..db6f338 100644
--- a/dashboardv2/public/js/views/tag/TagDetailTableLayoutView.js
+++ b/dashboardv2/public/js/views/tag/TagDetailTableLayoutView.js
@@ -60,8 +60,8 @@ define(['require',
* @constructs
*/
initialize: function(options) {
- _.extend(this, _.pick(options, 'globalVent', 'collection', 'guid', 'term', 'assetName'));
- this.collectionObject = this.collection.first().toJSON();
+ _.extend(this, _.pick(options, 'entity', 'guid', 'term', 'assetName'));
+ this.collectionObject = this.entity;
this.tagTermCollection = new VTagList();
var tagorterm = _.toArray(this.collectionObject.classifications),
tagTermList = [],
@@ -102,7 +102,6 @@ define(['require',
require(['utils/TableLayout'], function(TableLayout) {
var cols = new Backgrid.Columns(that.getSchemaTableColumns());
that.RTagTermTableLayoutView.show(new TableLayout(_.extend({}, that.commonTableOptions, {
- globalVent: that.globalVent,
columns: cols
})));
});
@@ -164,7 +163,6 @@ define(['require',
var that = this;
require(['views/tag/addTagModalView'], function(AddTagModalView) {
var view = new AddTagModalView({
- vent: that.vent,
guid: that.guid,
modalCollection: that.collection
});
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/dd744765/dashboardv2/public/js/views/tag/TagLayoutView.js
----------------------------------------------------------------------
diff --git a/dashboardv2/public/js/views/tag/TagLayoutView.js b/dashboardv2/public/js/views/tag/TagLayoutView.js
index 450866c..76dccd7 100644
--- a/dashboardv2/public/js/views/tag/TagLayoutView.js
+++ b/dashboardv2/public/js/views/tag/TagLayoutView.js
@@ -58,7 +58,7 @@ define(['require',
* @constructs
*/
initialize: function(options) {
- _.extend(this, _.pick(options, 'globalVent', 'tag', 'collection'));
+ _.extend(this, _.pick(options, 'tag', 'collection'));
},
bindEvents: function() {
var that = this;
@@ -143,7 +143,10 @@ define(['require',
return model.get('name').toLowerCase();
};
that.collection.fullCollection.sort().each(function(model) {
- var name = _.escape(model.get('name'))
+ var name = _.escape(model.get('name'));
+ if (name.indexOf(".") > -1) {
+ return;
+ }
if (searchString) {
if (name.search(new RegExp(searchString, "i")) != -1) {
// data-name="<space>'<tagName>'" Space is required for DSL search Input
@@ -165,7 +168,7 @@ define(['require',
},
onClickCreateTag: function(e) {
var that = this;
- $(e.currentTarget).blur();
+ $(e.currentTarget).attr("disabled", "true");
require([
'views/tag/CreateTagLayoutView',
'modules/Modal'
@@ -184,7 +187,7 @@ define(['require',
modal.$el.find('button.ok').removeAttr("disabled");
});
view.ui.tagName.on('keyup', function(e) {
- if ((e.keyCode == 8 || e.keyCode == 32 || e.keyCode == 46) && e.currentTarget.value == "") {
+ if ((e.keyCode == 8 || e.keyCode == 32 || e.keyCode == 46) && e.currentTarget.value.trim() == "") {
modal.$el.find('button.ok').attr("disabled", "true");
}
});
@@ -196,10 +199,12 @@ define(['require',
});
});
modal.on('ok', function() {
+ modal.$el.find('button.ok').attr("disabled", "true");
that.onCreateButton(view, modal);
});
modal.on('closeModal', function() {
modal.trigger('cancel');
+ that.ui.createTag.removeAttr("disabled");
});
});
},
@@ -243,6 +248,7 @@ define(['require',
};
new this.collection.model().set(this.json).save(null, {
success: function(model, response) {
+ that.ui.createTag.removeAttr("disabled");
that.createTag = true;
that.fetchCollections();
that.collection.add(model)
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/dd744765/dashboardv2/public/js/views/tag/addTagModalView.js
----------------------------------------------------------------------
diff --git a/dashboardv2/public/js/views/tag/addTagModalView.js b/dashboardv2/public/js/views/tag/addTagModalView.js
index 3d00caf..f2e19fe 100644
--- a/dashboardv2/public/js/views/tag/addTagModalView.js
+++ b/dashboardv2/public/js/views/tag/addTagModalView.js
@@ -48,7 +48,7 @@ define(['require',
*/
initialize: function(options) {
var that = this;
- _.extend(this, _.pick(options, 'vent', 'modalCollection', 'guid', 'callback', 'multiple', 'showLoader', 'hideLoader', 'tagList'));
+ _.extend(this, _.pick(options, 'modalCollection', 'guid', 'callback', 'multiple', 'showLoader', 'hideLoader', 'tagList'));
this.collection = new VTagList();
this.commonCollection = new VTagList();
this.asyncAttrFetchCounter = 0;
@@ -81,7 +81,7 @@ define(['require',
if (Enums.entityStateReadOnly[entity.model.status]) {
obj.deletedEntity.push(name);
} else {
- if (_.indexOf(entity.model.classificationNames, tagName) === -1) {
+ if (_.indexOf((entity.model.classificationNames || _.pluck(entity.model.classifications, 'typeName')), tagName) === -1) {
obj.guid.push(entity.model.guid)
} else {
obj.skipEntity.push(name);