|
17 | 17 | import org.humanbrainproject.knowledgegraph.commons.propertyGraph.arango.exceptions.StoredQueryNotFoundException;
|
18 | 18 | import org.humanbrainproject.knowledgegraph.commons.vocabulary.ArangoVocabulary;
|
19 | 19 | import org.humanbrainproject.knowledgegraph.commons.vocabulary.HBPVocabulary;
|
| 20 | +import org.humanbrainproject.knowledgegraph.commons.vocabulary.SchemaOrgVocabulary; |
20 | 21 | import org.humanbrainproject.knowledgegraph.indexing.entity.nexus.NexusInstanceReference;
|
21 | 22 | import org.humanbrainproject.knowledgegraph.indexing.entity.nexus.NexusSchemaReference;
|
22 | 23 | import org.humanbrainproject.knowledgegraph.query.control.FreemarkerTemplating;
|
@@ -161,10 +162,20 @@ public List<Map> getStoredQueriesBySchema(NexusSchemaReference schemaReference){
|
161 | 162 | List<Map> internalDocuments = arangoInternalRepository.getInternalDocuments(SPECIFICATION_QUERIES);
|
162 | 163 | List<Map> result = new ArrayList<>();
|
163 | 164 | for (Map internalDocument : internalDocuments) {
|
164 |
| - String rootSchema = (String)((Map) internalDocument.get(GraphQueryKeys.GRAPH_QUERY_ROOT_SCHEMA)).get(JsonLdConsts.ID); |
165 |
| - NexusSchemaReference fromUrl = NexusSchemaReference.createFromUrl(rootSchema); |
166 |
| - if(schemaReference.getRelativeUrl().getUrl().equals(fromUrl.getRelativeUrl().getUrl())){ |
167 |
| - result.add(internalDocument); |
| 165 | + if(internalDocument.containsKey(GraphQueryKeys.GRAPH_QUERY_ROOT_SCHEMA.getFieldName())){ |
| 166 | + String rootSchema = (String)((Map) internalDocument.get(GraphQueryKeys.GRAPH_QUERY_ROOT_SCHEMA.getFieldName())).get(JsonLdConsts.ID); |
| 167 | + NexusSchemaReference fromUrl = NexusSchemaReference.createFromUrl(rootSchema); |
| 168 | + if(schemaReference.getRelativeUrl().getUrl().equals(fromUrl.getRelativeUrl().getUrl())){ |
| 169 | + JsonDocument doc = new JsonDocument(internalDocument); |
| 170 | + if(doc.containsKey(SchemaOrgVocabulary.IDENTIFIER)){ |
| 171 | + JsonDocument r = new JsonDocument(); |
| 172 | + r.addToProperty(SchemaOrgVocabulary.IDENTIFIER, doc.get(SchemaOrgVocabulary.IDENTIFIER)); |
| 173 | + r.addToProperty(HBPVocabulary.PROVENANCE_CREATED_BY, doc.get(ArangoVocabulary.CREATED_BY_USER)); |
| 174 | + r.addToProperty(SchemaOrgVocabulary.NAME, doc.getOrDefault(SchemaOrgVocabulary.NAME, "")); |
| 175 | + r.addToProperty(SchemaOrgVocabulary.DESCRIPTION, doc.getOrDefault(SchemaOrgVocabulary.DESCRIPTION, "")); |
| 176 | + result.add(r); |
| 177 | + } |
| 178 | + } |
168 | 179 | }
|
169 | 180 | }
|
170 | 181 | return result;
|
@@ -215,6 +226,7 @@ public void storeSpecificationInDb(String specification, StoredQueryReference qu
|
215 | 226 | String id = queryReference.getName();
|
216 | 227 | jsonObject.put(ArangoVocabulary.KEY, id);
|
217 | 228 | jsonObject.put(ArangoVocabulary.ID, id);
|
| 229 | + jsonObject.put(SchemaOrgVocabulary.IDENTIFIER, queryReference.getSchemaReference().toString() + "/" +queryReference.getAlias()); |
218 | 230 | ArangoDocumentReference document = new ArangoDocumentReference(SPECIFICATION_QUERIES, id);
|
219 | 231 | arangoInternalRepository.insertOrUpdateDocument(document, jsonObject.toString());
|
220 | 232 | }
|
|
0 commit comments