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; ...@@ -24,6 +24,7 @@ import org.codehaus.jettison.json.JSONObject;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set;
/** /**
* Metadata discovery service. * Metadata discovery service.
...@@ -54,4 +55,9 @@ public interface DiscoveryService { ...@@ -54,4 +55,9 @@ public interface DiscoveryService {
*/ */
Map<String, HashMap<String,JSONObject>> relationshipWalk(String guid, int depth, String edgesToFollow); 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; ...@@ -29,6 +29,7 @@ import javax.inject.Inject;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set;
public class GraphBackedDiscoveryService implements DiscoveryService { public class GraphBackedDiscoveryService implements DiscoveryService {
...@@ -81,5 +82,14 @@ 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; ...@@ -28,6 +28,7 @@ import org.codehaus.jettison.json.JSONObject;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set;
/** /**
* An interface for persisting metadata into a blueprints enabled graph db. * An interface for persisting metadata into a blueprints enabled graph db.
...@@ -64,4 +65,10 @@ public interface MetadataRepository extends Service { ...@@ -64,4 +65,10 @@ public interface MetadataRepository extends Service {
* @param edgesToFollow is a comma-separated-list of edges to follow. * @param edgesToFollow is a comma-separated-list of edges to follow.
*/ */
Map<String, HashMap<String,JSONObject>> relationshipWalk(String guid, int depth, String edgesToFollow); 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; ...@@ -65,6 +65,7 @@ import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
/** /**
...@@ -141,6 +142,15 @@ public class GraphBackedMetadataRepository implements MetadataRepository { ...@@ -141,6 +142,15 @@ public class GraphBackedMetadataRepository implements MetadataRepository {
throw new RepositoryException(e); throw new RepositoryException(e);
} }
} }
/**
* Return a Set of indexed properties in the graph.
* No parameters.
*/
@Override
public Set<String> getGraphIndexedFields() {
return graphService.getIndexableGraph().getIndexedKeys(Vertex.class);
}
@Override @Override
public ITypedReferenceableInstance getEntityDefinition(String guid) throws RepositoryException { public ITypedReferenceableInstance getEntityDefinition(String guid) throws RepositoryException {
......
...@@ -189,5 +189,32 @@ public class MetadataDiscoveryResource { ...@@ -189,5 +189,32 @@ public class MetadataDiscoveryResource {
return Response.ok(response).build(); return Response.ok(response).build();
} }
/**
* 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 { ...@@ -46,6 +46,19 @@ public class MetadataDiscoveryResourceIT extends BaseResourceIT {
} }
@Test @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 { public void testLineageUriExists() throws Exception {
WebResource resource = service WebResource resource = service
.path("api/metadata/discovery/search/relationships/1") .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