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 {
* @param type entity type.
* @param classification classification 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 offset offset to the results returned (for pagination). [ offset >= 0 ]. -1 maps to offset 0.
* @return AtlasSearchResult
*/
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 {
@Override
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);
if (LOG.isDebugEnabled()) {
......@@ -196,11 +196,11 @@ public class EntityDiscoveryService implements AtlasDiscoveryService {
ret.setClassification(classification);
}
boolean isAttributeSearch = StringUtils.isNotEmpty(attrName) && StringUtils.isNotEmpty(attrValue);
boolean isAttributeSearch = StringUtils.isNotEmpty(attrName) && StringUtils.isNotEmpty(attrValuePrefix);
if (isAttributeSearch) {
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);
......@@ -215,7 +215,7 @@ public class EntityDiscoveryService implements AtlasDiscoveryService {
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)) {
query = attrQuery;
......@@ -262,7 +262,7 @@ public class EntityDiscoveryService implements AtlasDiscoveryService {
if (isAttributeSearch) {
String vertexAttrValue = vertex.getProperty(attrQualifiedName, String.class);
if (StringUtils.isNotEmpty(vertexAttrValue) && !vertexAttrValue.startsWith(attrValue)) {
if (StringUtils.isNotEmpty(vertexAttrValue) && !vertexAttrValue.startsWith(attrValuePrefix)) {
continue;
}
}
......
......@@ -169,7 +169,7 @@ public class DiscoveryREST {
/**
* Retrieve data for the specified attribute search query
* @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 limit limit the result set to only include the specified number of entries
* @param offset start offset of the result set (useful for pagination)
......@@ -183,8 +183,8 @@ public class DiscoveryREST {
@Path("/attribute")
@Consumes(Servlets.JSON_MEDIA_TYPE)
@Produces(Servlets.JSON_MEDIA_TYPE)
public AtlasSearchResult searchUsingAttribute(@QueryParam("stringName") String attrName,
@QueryParam("stringValue") String attrValue,
public AtlasSearchResult searchUsingAttribute(@QueryParam("attrName") String attrName,
@QueryParam("attrValuePrefix") String attrValuePrefix,
@QueryParam("typeName") String typeName,
@QueryParam("limit") int limit,
@QueryParam("offset") int offset) throws AtlasBaseException {
......@@ -193,15 +193,15 @@ public class DiscoveryREST {
try {
if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
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,
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 {
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