Commit be93da8b by Sarath Subramanian Committed by Madhan Neethiraj

ATLAS-1710: added entity-lookup API for entity create/update UI (#2)

parent 5dfe2023
...@@ -47,11 +47,11 @@ public interface AtlasDiscoveryService { ...@@ -47,11 +47,11 @@ public interface AtlasDiscoveryService {
* @param type entity type. * @param type entity type.
* @param classification classification name. * @param classification classification name.
* @param attrName attribute name. * @param attrName attribute name.
* @param attrValue attribute value. * @param attrValuePrefix attribute value prefix.
* @param limit number of resultant rows (for pagination). [ limit > 0 ] and [ limit < maxlimit ]. -1 maps to atlas.search.defaultlimit property. * @param limit number of resultant rows (for pagination). [ limit > 0 ] and [ limit < maxlimit ]. -1 maps to atlas.search.defaultlimit property.
* @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 searchUsingBasicQuery(String query, String type, String classification, String attrName, AtlasSearchResult searchUsingBasicQuery(String query, String type, String classification, String attrName,
String attrValue, int limit, int offset) throws AtlasBaseException; String attrValuePrefix, int limit, int offset) throws AtlasBaseException;
} }
...@@ -160,7 +160,7 @@ public class EntityDiscoveryService implements AtlasDiscoveryService { ...@@ -160,7 +160,7 @@ public class EntityDiscoveryService implements AtlasDiscoveryService {
@Override @Override
public AtlasSearchResult searchUsingBasicQuery(String query, String typeName, String classification, String attrName, public AtlasSearchResult searchUsingBasicQuery(String query, String typeName, String classification, String attrName,
String attrValue, int limit, int offset) throws AtlasBaseException { String attrValuePrefix, int limit, int offset) throws AtlasBaseException {
AtlasSearchResult ret = new AtlasSearchResult(AtlasQueryType.BASIC); AtlasSearchResult ret = new AtlasSearchResult(AtlasQueryType.BASIC);
if (LOG.isDebugEnabled()) { if (LOG.isDebugEnabled()) {
...@@ -196,11 +196,11 @@ public class EntityDiscoveryService implements AtlasDiscoveryService { ...@@ -196,11 +196,11 @@ public class EntityDiscoveryService implements AtlasDiscoveryService {
ret.setClassification(classification); ret.setClassification(classification);
} }
boolean isAttributeSearch = StringUtils.isNotEmpty(attrName) && StringUtils.isNotEmpty(attrValue); boolean isAttributeSearch = StringUtils.isNotEmpty(attrName) && StringUtils.isNotEmpty(attrValuePrefix);
if (isAttributeSearch) { if (isAttributeSearch) {
if (LOG.isDebugEnabled()) { if (LOG.isDebugEnabled()) {
LOG.debug("Executing attribute search attrName: {} and attrValue: {}", attrName, attrValue); LOG.debug("Executing attribute search attrName: {} and attrValue: {}", attrName, attrValuePrefix);
} }
AtlasEntityType entityType = typeRegistry.getEntityTypeByName(typeName); AtlasEntityType entityType = typeRegistry.getEntityTypeByName(typeName);
...@@ -215,7 +215,7 @@ public class EntityDiscoveryService implements AtlasDiscoveryService { ...@@ -215,7 +215,7 @@ public class EntityDiscoveryService implements AtlasDiscoveryService {
attrQualifiedName = entityType.getAttribute(attrName).getQualifiedName(); attrQualifiedName = entityType.getAttribute(attrName).getQualifiedName();
} }
String attrQuery = String.format("%s AND (%s *)", attrName, attrValue.replaceAll("\\.", " ")); String attrQuery = String.format("%s AND (%s *)", attrName, attrValuePrefix.replaceAll("\\.", " "));
if (StringUtils.isEmpty(query)) { if (StringUtils.isEmpty(query)) {
query = attrQuery; query = attrQuery;
...@@ -262,7 +262,7 @@ public class EntityDiscoveryService implements AtlasDiscoveryService { ...@@ -262,7 +262,7 @@ public class EntityDiscoveryService implements AtlasDiscoveryService {
if (isAttributeSearch) { if (isAttributeSearch) {
String vertexAttrValue = vertex.getProperty(attrQualifiedName, String.class); String vertexAttrValue = vertex.getProperty(attrQualifiedName, String.class);
if (StringUtils.isNotEmpty(vertexAttrValue) && !vertexAttrValue.startsWith(attrValue)) { if (StringUtils.isNotEmpty(vertexAttrValue) && !vertexAttrValue.startsWith(attrValuePrefix)) {
continue; continue;
} }
} }
......
...@@ -169,7 +169,7 @@ public class DiscoveryREST { ...@@ -169,7 +169,7 @@ public class DiscoveryREST {
/** /**
* Retrieve data for the specified attribute search query * Retrieve data for the specified attribute search query
* @param attrName Attribute name * @param attrName Attribute name
* @param attrValue Attibute value to search on * @param attrValuePrefix Attibute value to search on
* @param typeName limit the result to only entities of specified type or its sub-types * @param typeName limit the result to only entities of specified type or its sub-types
* @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
* @param offset start offset of the result set (useful for pagination) * @param offset start offset of the result set (useful for pagination)
...@@ -183,8 +183,8 @@ public class DiscoveryREST { ...@@ -183,8 +183,8 @@ public class DiscoveryREST {
@Path("/attribute") @Path("/attribute")
@Consumes(Servlets.JSON_MEDIA_TYPE) @Consumes(Servlets.JSON_MEDIA_TYPE)
@Produces(Servlets.JSON_MEDIA_TYPE) @Produces(Servlets.JSON_MEDIA_TYPE)
public AtlasSearchResult searchUsingAttribute(@QueryParam("stringName") String attrName, public AtlasSearchResult searchUsingAttribute(@QueryParam("attrName") String attrName,
@QueryParam("stringValue") String attrValue, @QueryParam("attrValuePrefix") String attrValuePrefix,
@QueryParam("typeName") String typeName, @QueryParam("typeName") String typeName,
@QueryParam("limit") int limit, @QueryParam("limit") int limit,
@QueryParam("offset") int offset) throws AtlasBaseException { @QueryParam("offset") int offset) throws AtlasBaseException {
...@@ -193,15 +193,15 @@ public class DiscoveryREST { ...@@ -193,15 +193,15 @@ public class DiscoveryREST {
try { try {
if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) { if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "DiscoveryREST.searchUsingAttribute(" + attrName + "," + perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "DiscoveryREST.searchUsingAttribute(" + attrName + "," +
attrValue + "," + typeName + "," + limit + "," + offset + ")"); attrValuePrefix + "," + typeName + "," + limit + "," + offset + ")");
} }
if (StringUtils.isEmpty(attrName) || StringUtils.isEmpty(attrValue)) { if (StringUtils.isEmpty(attrName) || StringUtils.isEmpty(attrValuePrefix)) {
throw new AtlasBaseException(AtlasErrorCode.INVALID_PARAMETERS, throw new AtlasBaseException(AtlasErrorCode.INVALID_PARAMETERS,
String.format("attrName : {0}, attrValue: {1} for attribute search.", attrName, attrValue)); String.format("attrName : {0}, attrValue: {1} for attribute search.", attrName, attrValuePrefix));
} }
return atlasDiscoveryService.searchUsingBasicQuery(null, typeName, null, attrName, attrValue, limit, offset); return atlasDiscoveryService.searchUsingBasicQuery(null, typeName, null, attrName, attrValuePrefix, 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