Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

/selectQuery endpoint added #97

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import de.fraunhofer.iais.eis.ids.component.interaction.multipart.MultipartComponentInteractor;
import de.fraunhofer.iais.eis.ids.component.interaction.validation.ShaclValidator;
import de.fraunhofer.iais.eis.ids.connector.commons.broker.QueryHandler;
import de.fraunhofer.iais.eis.ids.index.common.endpoint.FrontendEndpoints;
import de.fraunhofer.iais.eis.ids.index.common.main.AppConfigTemplate;
import de.fraunhofer.iais.eis.ids.index.common.persistence.ConstructQueryResultHandler;
import de.fraunhofer.iais.eis.ids.index.common.persistence.DescriptionProvider;
Expand Down Expand Up @@ -58,6 +59,7 @@ public MultipartComponentInteractor build() {
//Repository facade is our bridge to the triple store backend
RepositoryFacade repositoryFacade = new RepositoryFacade(sparqlEndpointUrl);

FrontendEndpoints.repositoryFacade = repositoryFacade;
//Object taking care of storing connectors and their resources in a triple store with optional indexing
SelfDescriptionPersistenceAndIndexing selfDescriptionPersistence = new SelfDescriptionPersistenceAndIndexing(
repositoryFacade, catalogUri, indexing, maxNumberOfIndexedConnectorResources);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
*/
@Configuration
@EnableAutoConfiguration(exclude = SolrAutoConfiguration.class)
@ComponentScan(basePackages = { "de.fraunhofer.iais.eis.ids.component.protocol.http.server"} )
@ComponentScan(basePackages = { "de.fraunhofer.iais.eis.ids.component.protocol.http.server","de.fraunhofer.iais.eis.ids.index.common.endpoint"} )
public class Main extends MainTemplate implements ComponentInteractorProvider {

Logger logger = LoggerFactory.getLogger(Main.class);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package de.fraunhofer.iais.eis.ids.index.common.endpoint;


import de.fraunhofer.iais.eis.ids.index.common.persistence.RepositoryFacade;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.core.env.Environment;


/**
* This class adds endpoints to send SPARQL (update) queries to the triplestore
*/
@RestController
public class FrontendEndpoints {

public static RepositoryFacade repositoryFacade;
//private String sparqlUrl = "http://broker-core:3030/connectorData";

@PostMapping("/updateQuery")
public String updateQuery(@RequestBody String queryMessage) {
repositoryFacade.getNewWritableConnection().update(queryMessage);
return "Query ran successfully";
}

/**
* This function provides read access to the triplestore by executing a SPARQL SELECT query
* @param queryMessage The SELECT query to be executed
* @return Query binding in TSV format
*/
@PostMapping("/selectQuery")
public String readQuery(@RequestBody String queryMessage) {
return repositoryFacade.selectQueryReturnTSV(queryMessage);
}
}