diff --git a/fuse-domain/fuse-domain-dragons/fuse-domain-dragons-assembly/resources/assembly/Dragons/public/assets/swagger/swagger.json b/fuse-domain/fuse-domain-dragons/fuse-domain-dragons-assembly/resources/assembly/Dragons/public/assets/swagger/swagger.json index f2634d07f..0b09bbbb7 100644 --- a/fuse-domain/fuse-domain-dragons/fuse-domain-dragons-assembly/resources/assembly/Dragons/public/assets/swagger/swagger.json +++ b/fuse-domain/fuse-domain-dragons/fuse-domain-dragons-assembly/resources/assembly/Dragons/public/assets/swagger/swagger.json @@ -22,7 +22,6 @@ "application/xml", "image/*", "text/csv" - ], "paths": { "/": { @@ -65,7 +64,6 @@ } } }, - "/internal/version": { "get": { "tags": [ @@ -96,7 +94,6 @@ } } }, - "/catalog/ontology": { "post": { "tags": [ @@ -229,14 +226,13 @@ } } }, - "/graphql/ontology/{id}": { "post": { "tags": [ "catalog" ], "summary": "graphQL IDL into Ontology", - "description": "Transform a graphQL IDL into V1 Ontology - see https://graphql.org/learn/schema/" , + "description": "Transform a graphQL IDL into V1 Ontology - see https://graphql.org/learn/schema/", "parameters": [ { "name": "id", @@ -270,7 +266,7 @@ "catalog" ], "summary": "OWL IDL into Ontology", - "description": "Transform a OWL IDL into V1 Ontology - see https://www.w3.org/TR/owl-features/" , + "description": "Transform a OWL IDL into V1 Ontology - see https://www.w3.org/TR/owl-features/", "parameters": [ { "name": "id", @@ -304,7 +300,7 @@ "catalog" ], "summary": "SQL DDL into Ontology", - "description": "Transform a SQL DDL into V1 Ontology " , + "description": "Transform a SQL DDL into V1 Ontology ", "parameters": [ { "name": "id", @@ -332,7 +328,6 @@ } } }, - "/query/graph/api/getVertex": { "get": { "tags": [ @@ -413,7 +408,6 @@ } } }, - "/query/graph/api/findPath": { "get": { "tags": [ @@ -468,7 +462,6 @@ "required": true, "type": "integer" } - ], "responses": { "200": { @@ -480,7 +473,6 @@ } } }, - "/query/cypher": { "post": { "tags": [ @@ -529,7 +521,13 @@ "in": "query", "description": "cursorType", "required": false, - "enum": ["graph","csv","forwardPaths","projection","count"] + "enum": [ + "graph", + "csv", + "forwardPaths", + "projection", + "count" + ] }, { "name": "cypher", @@ -557,7 +555,6 @@ } } }, - "/query/graphQL": { "post": { "tags": [ @@ -606,7 +603,11 @@ "in": "query", "description": "cursorType", "required": false, - "enum": ["graph","csv","forwardPaths"] + "enum": [ + "graph", + "csv", + "forwardPaths" + ] }, { "name": "graphQL", @@ -634,7 +635,6 @@ } } }, - "/query/sparql": { "post": { "tags": [ @@ -683,7 +683,11 @@ "in": "query", "description": "cursorType", "required": false, - "enum": ["graph","csv","forwardPaths"] + "enum": [ + "graph", + "csv", + "forwardPaths" + ] }, { "name": "sparql", @@ -711,7 +715,6 @@ } } }, - "/query/v1": { "post": { "tags": [ @@ -844,7 +847,11 @@ "in": "query", "description": "cursorType", "required": false, - "enum": ["graph","csv","forwardPaths"] + "enum": [ + "graph", + "csv", + "forwardPaths" + ] }, { "in": "body", @@ -887,7 +894,6 @@ } } }, - "/query/{id}": { "get": { "tags": [ @@ -1144,41 +1150,41 @@ } }, "/query/{id}/cursor/{cursorId}": { - "get": { - "tags": [ - "cursor" - ], - "summary": "Fetch cursor info by ID", - "description": "Fetch cursor info by ID", - "parameters": [ - { - "name": "id", - "in": "path", - "description": "query ID.", - "required": true, - "type": "string" - }, - { - "name": "cursorId", - "in": "path", - "description": "cursor ID.", - "required": true, - "type": "string" - } - ], - "responses": { - "200": { - "description": "Returns 200 with a single query info or 404", - "schema": { - "$ref": "#/definitions/QueryInfo" - } - }, - "404": { - "description": "Not Found" + "get": { + "tags": [ + "cursor" + ], + "summary": "Fetch cursor info by ID", + "description": "Fetch cursor info by ID", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "query ID.", + "required": true, + "type": "string" + }, + { + "name": "cursorId", + "in": "path", + "description": "cursor ID.", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "Returns 200 with a single query info or 404", + "schema": { + "$ref": "#/definitions/QueryInfo" } + }, + "404": { + "description": "Not Found" } - }, - "delete": { + } + }, + "delete": { "tags": [ "cursor" ], @@ -1459,14 +1465,22 @@ } } }, - - "/dashboard/entities": { + "/dashboard/entities/{ontology}": { "get": { "tags": [ "dashboard" ], "summary": "Show summery of DB existing entities", "description": "summery of DB entities", + "parameters": [ + { + "name": "ontology", + "in": "path", + "description": "ontology.", + "required": true, + "type": "string" + } + ], "responses": { "200": { "description": "Returns 200 summery of db elements created (entities / properties) or 404" @@ -1494,13 +1508,22 @@ } } }, - "/dashboard/created": { + "/dashboard/created/{ontology}": { "get": { "tags": [ "dashboard" ], "summary": "Show summery of created DB elements by creation time ", "description": "summery of time bases created DB elements ", + "parameters": [ + { + "name": "ontology", + "in": "path", + "description": "ontology.", + "required": true, + "type": "string" + } + ], "responses": { "200": { "description": "Returns 200 Show summery of created DB elements by creation time or 404" @@ -1528,7 +1551,6 @@ } } }, - "/load/ontology/{id}/indices": { "get": { "tags": [ @@ -1729,7 +1751,6 @@ } } }, - "/load/ontology/{id}/graph/upload": { "post": { "tags": [ @@ -1833,7 +1854,6 @@ } } }, - "definitions": { "SequenceNames": { "type": "string", @@ -1951,8 +1971,8 @@ "id": "1", "name": "Q1", "ontology": "Dragons", - "query": "Match (p1:Person)-[o:Own]->(d2:Dragon ) return *", - "type":"cypher" + "query": "Match (p1:Person)-[o:Own]->(d2:Dragon ) return *", + "type": "cypher" } }, "SparqlQueryRequest": { diff --git a/fuse-service/src/main/java/com/yangdb/fuse/services/appRegistrars/DashboardControllerRegistrar.java b/fuse-service/src/main/java/com/yangdb/fuse/services/appRegistrars/DashboardControllerRegistrar.java index f65eb306c..0c1e414e2 100644 --- a/fuse-service/src/main/java/com/yangdb/fuse/services/appRegistrars/DashboardControllerRegistrar.java +++ b/fuse-service/src/main/java/com/yangdb/fuse/services/appRegistrars/DashboardControllerRegistrar.java @@ -35,10 +35,10 @@ public DashboardControllerRegistrar() { //region AppControllerRegistrarBase Implementation @Override public void register(Jooby app, AppUrlSupplier appUrlSupplier) { - app.get("/fuse/dashboard/entities/:id", - req -> Results.with(this.getController(app).graphElementCount(req.param("id").value()))); - app.get("/fuse/dashboard/created/:id", - req -> Results.with(this.getController(app).graphElementCreatedOverTime(req.param("id").value()))); + app.get("/fuse/dashboard/entities/:ontology", + req -> Results.with(this.getController(app).graphElementCount(req.param("ontology").value()))); + app.get("/fuse/dashboard/created/:ontology", + req -> Results.with(this.getController(app).graphElementCreatedOverTime(req.param("ontology").value()))); app.get("/fuse/dashboard/count", req -> Results.with(this.getController(app).cursorCount())); } diff --git a/fuse-service/src/main/java/com/yangdb/fuse/services/controllers/StandardDashboardDriver.java b/fuse-service/src/main/java/com/yangdb/fuse/services/controllers/StandardDashboardDriver.java index 1c1153cfd..4d7f3b7cf 100644 --- a/fuse-service/src/main/java/com/yangdb/fuse/services/controllers/StandardDashboardDriver.java +++ b/fuse-service/src/main/java/com/yangdb/fuse/services/controllers/StandardDashboardDriver.java @@ -140,11 +140,11 @@ public ObjectNode graphElementCount(String ontologyId) { return root; } - private ObjectNode collectIndexMetadata(ObjectNode statistics,boolean vertex, IndexPartitions indexPartitions) { + private ObjectNode collectIndexMetadata(ObjectNode statistics, boolean vertex, IndexPartitions indexPartitions) { final SearchRequestBuilder builder = client.prepareSearch(); builder.setSize(0); builder.setIndices(IteratorUtils.toList(indexPartitions.getIndices().iterator()).toArray(new String[0])); - if(vertex) { + if (vertex) { builder.addAggregation(new TermsAggregationBuilder("graphElementCount").field(TYPE)); } else { builder.setQuery(QueryBuilders.boolQuery().filter(QueryBuilders.termQuery(DIRECTION, IN)));//only outgoing edges @@ -153,20 +153,35 @@ private ObjectNode collectIndexMetadata(ObjectNode statistics,boolean vertex, In } try { final SearchResponse response = builder.get(); + Map elementCount = Collections.EMPTY_MAP; + Map edgeSourceCount = Collections.EMPTY_MAP; + Map edgeDestCount = Collections.EMPTY_MAP; //calculate cardinality for every entity type - final Map elementCount = Objects.isNull(response.getAggregations().get("graphElementCount")) ? Collections.EMPTY_MAP : - ((StringTerms) response.getAggregations().get("graphElementCount")).getBuckets().stream() - .collect(Collectors.toMap(StringTerms.Bucket::getKey, StringTerms.Bucket::getDocCount)); + try { + elementCount = Objects.isNull(response.getAggregations().get("graphElementCount")) ? Collections.EMPTY_MAP : + ((StringTerms) response.getAggregations().get("graphElementCount")).getBuckets().stream() + .collect(Collectors.toMap(StringTerms.Bucket::getKey, StringTerms.Bucket::getDocCount)); + } catch (Throwable graphElementCountErr) { + logger.warn(graphElementCountErr.getMessage()); + } //calculate cardinality for every relationship type - final Map edgeSourceCount = Objects.isNull(response.getAggregations().get("edgeSourceCount")) ? Collections.EMPTY_MAP : - ((StringTerms) response.getAggregations().get("edgeSourceCount")).getBuckets().stream() - .collect(Collectors.toMap(StringTerms.Bucket::getKey, StringTerms.Bucket::getDocCount)); + try { + edgeSourceCount = Objects.isNull(response.getAggregations().get("edgeSourceCount")) ? Collections.EMPTY_MAP : + ((StringTerms) response.getAggregations().get("edgeSourceCount")).getBuckets().stream() + .collect(Collectors.toMap(StringTerms.Bucket::getKey, StringTerms.Bucket::getDocCount)); + }catch (Throwable edgeSourceCountErr) { + logger.warn(edgeSourceCountErr.getMessage()); + } - final Map edgeDestCount = Objects.isNull(response.getAggregations().get("edgeDestCount")) ? Collections.EMPTY_MAP : - ((StringTerms) response.getAggregations().get("edgeDestCount")).getBuckets().stream() - .collect(Collectors.toMap(StringTerms.Bucket::getKey, StringTerms.Bucket::getDocCount)); + try { + edgeDestCount = Objects.isNull(response.getAggregations().get("edgeDestCount")) ? Collections.EMPTY_MAP : + ((StringTerms) response.getAggregations().get("edgeDestCount")).getBuckets().stream() + .collect(Collectors.toMap(StringTerms.Bucket::getKey, StringTerms.Bucket::getDocCount)); + }catch (Throwable edgeDestCountErr) { + logger.warn(edgeDestCountErr.getMessage()); + } if (!elementCount.isEmpty()) { elementCount.forEach((key, value) -> statistics.put(key.toString(), value)); @@ -188,7 +203,6 @@ private ObjectNode collectIndexMetadata(ObjectNode statistics,boolean vertex, In } @Override - //todo - fix this to be Ontology depended public ObjectNode graphElementCreated(String ontologyId) { Ontology ontology = ontologyProvider.get(ontologyId) .orElseThrow(() -> new FuseError.FuseErrorException(new FuseError("No Ontology present for Id ", "No Ontology present for id[" + ontologyId + "]")));