Commit f932e52c by Pinal Shah Committed by nixonrodrigues

ATLAS-3867 : Relationship search API should have a provision to fetch custom…

ATLAS-3867 : Relationship search API should have a provision to fetch custom attributes in search results Signed-off-by: 's avatarnixonrodrigues <nixon@apache.org>
parent 8b50ac0c
...@@ -19,13 +19,13 @@ ...@@ -19,13 +19,13 @@
package org.apache.atlas.discovery; package org.apache.atlas.discovery;
import com.sun.xml.bind.v2.model.annotation.Quick;
import org.apache.atlas.SortOrder; import org.apache.atlas.SortOrder;
import org.apache.atlas.exception.AtlasBaseException; import org.apache.atlas.exception.AtlasBaseException;
import org.apache.atlas.model.discovery.*; import org.apache.atlas.model.discovery.*;
import org.apache.atlas.model.profile.AtlasUserSavedSearch; import org.apache.atlas.model.profile.AtlasUserSavedSearch;
import java.util.List; import java.util.List;
import java.util.Set;
public interface AtlasDiscoveryService { public interface AtlasDiscoveryService {
/** /**
...@@ -83,6 +83,7 @@ public interface AtlasDiscoveryService { ...@@ -83,6 +83,7 @@ public interface AtlasDiscoveryService {
* *
* @param guid unique ID of the entity. * @param guid unique ID of the entity.
* @param relation relation name. * @param relation relation name.
* @param attributes set of attributes in search result.
* @param sortByAttribute sort the result using this attribute name, default value is 'name' * @param sortByAttribute sort the result using this attribute name, default value is 'name'
* @param sortOrder sorting order * @param sortOrder sorting order
* @param excludeDeletedEntities exclude deleted entities in search result. * @param excludeDeletedEntities exclude deleted entities in search result.
...@@ -90,7 +91,7 @@ public interface AtlasDiscoveryService { ...@@ -90,7 +91,7 @@ public interface AtlasDiscoveryService {
* @param offset offset to the results returned (for pagination). [ offset >= 0 ]. -1 maps to offset 0. * @param offset offset to the results returned (for pagination). [ offset >= 0 ]. -1 maps to offset 0.
* @return AtlasSearchResult * @return AtlasSearchResult
*/ */
AtlasSearchResult searchRelatedEntities(String guid, String relation, String sortByAttribute, SortOrder sortOrder, boolean excludeDeletedEntities, int limit, int offset) throws AtlasBaseException; AtlasSearchResult searchRelatedEntities(String guid, String relation, Set<String> attributes, String sortByAttribute, SortOrder sortOrder, boolean excludeDeletedEntities, int limit, int offset) throws AtlasBaseException;
/** /**
* *
......
...@@ -563,7 +563,7 @@ public class EntityDiscoveryService implements AtlasDiscoveryService { ...@@ -563,7 +563,7 @@ public class EntityDiscoveryService implements AtlasDiscoveryService {
@Override @Override
@GraphTransaction @GraphTransaction
public AtlasSearchResult searchRelatedEntities(String guid, String relation, String sortBy, SortOrder sortOrder, public AtlasSearchResult searchRelatedEntities(String guid, String relation, Set<String> attributes, String sortBy, SortOrder sortOrder,
boolean excludeDeletedEntities, int limit, int offset) throws AtlasBaseException { boolean excludeDeletedEntities, int limit, int offset) throws AtlasBaseException {
AtlasSearchResult ret = new AtlasSearchResult(AtlasQueryType.RELATIONSHIP); AtlasSearchResult ret = new AtlasSearchResult(AtlasQueryType.RELATIONSHIP);
...@@ -685,7 +685,7 @@ public class EntityDiscoveryService implements AtlasDiscoveryService { ...@@ -685,7 +685,7 @@ public class EntityDiscoveryService implements AtlasDiscoveryService {
List<AtlasEntityHeader> resultList = new ArrayList<>(vertices.size()); List<AtlasEntityHeader> resultList = new ArrayList<>(vertices.size());
for (AtlasVertex vertex : vertices) { for (AtlasVertex vertex : vertices) {
resultList.add(entityRetriever.toAtlasEntityHeader(vertex)); resultList.add(entityRetriever.toAtlasEntityHeader(vertex, attributes));
} }
ret.setEntities(resultList); ret.setEntities(resultList);
......
...@@ -55,6 +55,7 @@ import javax.ws.rs.core.Context; ...@@ -55,6 +55,7 @@ import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
import java.util.Set;
/** /**
* REST interface for data discovery using dsl or full text search * REST interface for data discovery using dsl or full text search
...@@ -344,6 +345,7 @@ public class DiscoveryREST { ...@@ -344,6 +345,7 @@ public class DiscoveryREST {
* *
* @param guid Attribute name * @param guid Attribute name
* @param relation relationName * @param relation relationName
* @param attributes set of attributes in search result.
* @param sortByAttribute sort the result using this attribute name, default value is 'name' * @param sortByAttribute sort the result using this attribute name, default value is 'name'
* @param sortOrder sorting order * @param sortOrder sorting order
* @param limit limit the result set to only include the specified number of entries * @param limit limit the result set to only include the specified number of entries
...@@ -357,6 +359,7 @@ public class DiscoveryREST { ...@@ -357,6 +359,7 @@ public class DiscoveryREST {
@Path("relationship") @Path("relationship")
public AtlasSearchResult searchRelatedEntities(@QueryParam("guid") String guid, public AtlasSearchResult searchRelatedEntities(@QueryParam("guid") String guid,
@QueryParam("relation") String relation, @QueryParam("relation") String relation,
@QueryParam("attributes") Set<String> attributes,
@QueryParam("sortBy") String sortByAttribute, @QueryParam("sortBy") String sortByAttribute,
@QueryParam("sortOrder") SortOrder sortOrder, @QueryParam("sortOrder") SortOrder sortOrder,
@QueryParam("excludeDeletedEntities") boolean excludeDeletedEntities, @QueryParam("excludeDeletedEntities") boolean excludeDeletedEntities,
...@@ -374,7 +377,7 @@ public class DiscoveryREST { ...@@ -374,7 +377,7 @@ public class DiscoveryREST {
", " + relation + ", " + sortByAttribute + ", " + sortOrder + ", " + excludeDeletedEntities + ", " + ", " + limit + ", " + offset + ")"); ", " + relation + ", " + sortByAttribute + ", " + sortOrder + ", " + excludeDeletedEntities + ", " + ", " + limit + ", " + offset + ")");
} }
return discoveryService.searchRelatedEntities(guid, relation, sortByAttribute, sortOrder, excludeDeletedEntities, limit, offset); return discoveryService.searchRelatedEntities(guid, relation, attributes, sortByAttribute, sortOrder, excludeDeletedEntities, limit, offset);
} finally { } finally {
AtlasPerfTracer.log(perf); AtlasPerfTracer.log(perf);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment