Commit 18981168 by TJBChris

Added API to return a list of indexed fields. Output is JSON.

parent 7aece73b
......@@ -24,6 +24,7 @@ import org.codehaus.jettison.json.JSONObject;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* Metadata discovery service.
......@@ -54,4 +55,9 @@ public interface DiscoveryService {
*/
Map<String, HashMap<String,JSONObject>> relationshipWalk(String guid, int depth, String edgesToFollow);
/**
* Return a Set of indexed properties in the graph.
* No parameters.
*/
Set<String> getGraphIndexedFields();
}
......@@ -29,6 +29,7 @@ import javax.inject.Inject;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
public class GraphBackedDiscoveryService implements DiscoveryService {
......@@ -81,5 +82,14 @@ public class GraphBackedDiscoveryService implements DiscoveryService {
}
/**
* Return a Set of indexed properties in the graph.
* No parameters.
*/
@Override
public Set<String> getGraphIndexedFields() {
return repository.getGraphIndexedFields();
}
}
......@@ -28,6 +28,7 @@ import org.codehaus.jettison.json.JSONObject;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* An interface for persisting metadata into a blueprints enabled graph db.
......@@ -64,4 +65,10 @@ public interface MetadataRepository extends Service {
* @param edgesToFollow is a comma-separated-list of edges to follow.
*/
Map<String, HashMap<String,JSONObject>> relationshipWalk(String guid, int depth, String edgesToFollow);
/**
* Return a Set of indexed properties in the graph.
* No parameters.
*/
Set<String> getGraphIndexedFields();
}
......@@ -65,6 +65,7 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
/**
......@@ -142,6 +143,15 @@ public class GraphBackedMetadataRepository implements MetadataRepository {
}
}
/**
* Return a Set of indexed properties in the graph.
* No parameters.
*/
@Override
public Set<String> getGraphIndexedFields() {
return graphService.getIndexableGraph().getIndexedKeys(Vertex.class);
}
@Override
public ITypedReferenceableInstance getEntityDefinition(String guid) throws RepositoryException {
LOG.info("Retrieving entity with guid={}", guid);
......
......@@ -190,4 +190,31 @@ public class MetadataDiscoveryResource {
}
/**
* Return a list Vertices and Edges in the index.
*
* GET http://host/api/metadata/discovery/getIndexedFields
*
* No parameters taken.
*/
@GET
@Path("/getIndexedFields")
@Produces({MediaType.APPLICATION_JSON})
public Response getLineageResults() {
JSONObject response = new JSONObject();
try {
response.put("indexed_fields:",discoveryService.getGraphIndexedFields());
} catch (JSONException e) {
throw new WebApplicationException(
Servlets.getErrorResponse("Search: Error building JSON result set.", Response.Status.INTERNAL_SERVER_ERROR));
}
LOG.debug("JSON result:" + response.toString());
return Response.ok(response).build();
}
}
......@@ -46,6 +46,19 @@ public class MetadataDiscoveryResourceIT extends BaseResourceIT {
}
@Test
public void testGetIndexedProperties() throws Exception {
WebResource resource = service
.path("api/metadata/discovery/getIndexedFields");
ClientResponse clientResponse = resource
.accept(MediaType.APPLICATION_JSON)
.type(MediaType.APPLICATION_JSON)
.method(HttpMethod.GET, ClientResponse.class);
Assert.assertNotEquals(clientResponse.getStatus(), Response.Status.NOT_FOUND.getStatusCode());
}
@Test
public void testLineageUriExists() throws Exception {
WebResource resource = service
.path("api/metadata/discovery/search/relationships/1")
......
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