Skip to content

Commit

Permalink
inject application name
Browse files Browse the repository at this point in the history
  • Loading branch information
heinpa committed Aug 9, 2020
1 parent 82e90cc commit e11874c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package eu.wdaqua.qanary.component;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
Expand All @@ -26,8 +27,8 @@ public class Application {
* @return
*/
@Bean
public QanaryComponent qanaryComponent() {
return new Monolitic();
public QanaryComponent qanaryComponent(@Value("${spring.application.name}") final String applicationName) {
return new Monolitic(applicationName);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,19 @@
import org.apache.jena.query.ResultSetFormatter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Component
public class Monolitic extends QanaryComponent {
private static final Logger logger = LoggerFactory.getLogger(Monolitic.class);

private final String applicationName;

public Monolitic(@Value("${spring.application.name}") final String applicationName) {
this.applicationName = applicationName;
}

/**
* implement this method encapsulating the functionality of your Qanary
* component
Expand Down Expand Up @@ -67,12 +74,12 @@ public QanaryMessage process(QanaryMessage myQanaryMessage) throws Exception {
+ " ?a a qa:AnnotationOfAnswerSPARQL . "
+ " ?a oa:hasTarget <URIAnswer> . "
+ " ?a oa:hasBody \"" + sparqlAnswer.replace("\n", " ") + "\" ;"
+ " oa:annotatedBy <http://monolitic-component.org> ; "
+ " oa:annotatedBy <urn:qanary:"+this.applicationName+"> ; "
+ " oa:AnnotatedAt ?time . "
+ " ?b a qa:AnnotationOfAnswerJSON . "
+ " ?b oa:hasTarget <URIAnswer> . "
+ " ?b oa:hasBody \"" + json.replace("\n", " ").replace("\"", "\\\"") + "\" ;"
+ " oa:annotatedBy <http://monolitic-component.org> ; "
+ " oa:annotatedBy <urn:qanary:"+this.applicationName+"> ; "
+ " oa:annotatedAt ?time "
+ "}} "
+ "WHERE { "
Expand Down

0 comments on commit e11874c

Please sign in to comment.