Skip to content
This repository was archived by the owner on Apr 22, 2022. It is now read-only.

Commit 0567296

Browse files
committed
add component configuration functionality
1 parent 9b98827 commit 0567296

21 files changed

+404
-297
lines changed

src/main/java/com/ontos/ldiw/vocabulary/LDIS.java

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
/**
77
* Vocabulary definitions from ldis-0.1.12.ttl
8-
* @author Auto-generated by schemagen on 27 Apr 2015 14:47
8+
* @author Auto-generated by schemagen on 10 Jun 2015 15:00
99
*/
1010
public class LDIS {
1111
/** <p>The RDF model that holds the vocabulary terms</p> */
@@ -56,15 +56,18 @@ public class LDIS {
5656
+ ": a owl:Ontology ; \n"
5757
+ " dcterms:contributor \"Alejandra Garcia Rojas\"^^xsd:string ; \n"
5858
+ " dcterms:descripton \"Schema for integrating Software components from the Linked Data Stack\"@en ; \n"
59-
+ " owl:versionInfo \"0.1.1\"^^xsd:string . \n"
59+
+ " owl:versionInfo \"0.1.2\"^^xsd:string . \n"
6060
+ ":providesService a owl:ObjectProperty ; \n"
61-
+ " rdfs:comment \"A component in the stack provides a service of a givent type\"@en ; \n"
61+
+ " rdfs:comment \"A component in the stack provides a service of a given type\"@en ; \n"
6262
+ " rdfs:domain :StackComponent ; \n"
6363
+ " rdfs:label \"Provides Service\"@en ; \n"
6464
+ " rdfs:range :ComponentService . \n"
6565
+ ":StackComponent a owl:Class ; \n"
6666
+ " rdfs:label \"Stack Component\"@en ; \n"
6767
+ " rdfs:subClassOf owl:Thing . \n"
68+
+ ":requires a owl:ObjectProperty ; \n"
69+
+ " rdfs:comment \"A component depends on another component to work\"@en ; \n"
70+
+ " rdfs:label \"requires\"@en . \n"
6871
+ ":PublicationService a owl:Class ; \n"
6972
+ " rdfs:comment \"Represents the agent responsible for quality analysis.\"@en ; \n"
7073
+ " rdfs:label \"Publication Service\"@en ; \n"
@@ -132,8 +135,9 @@ public class LDIS {
132135
+ " rdfs:comment \"Represents the agent responsible for storage.\"@en ; \n"
133136
+ " rdfs:label \"Cleaning Service\"@en ; \n"
134137
+ " rdfs:subClassOf :ComponentService . \n"
135-
+ ":integrates a owl:ObjectProperty ; \n"
136-
+ " rdfs:label \"integrates\"@en . \n"
138+
+ ":integrates a owl:ObjectProperty ; \n"
139+
+ " rdfs:comment \"A component integrates another component\"@en ; \n"
140+
+ " rdfs:label \"integrates\"@en . \n"
137141
+ ":SecuredSPARQLEndPointService \n"
138142
+ " a owl:Class ; \n"
139143
+ " rdfs:label \"Secured SPARQL Endpoint Service\"@en ; \n"
@@ -156,7 +160,7 @@ public class LDIS {
156160
public static final Resource NAMESPACE = m_model.createResource( NS );
157161

158162
/** <p>The ontology's owl:versionInfo as a string</p> */
159-
public static final String VERSION_INFO = "0.1.1";
163+
public static final String VERSION_INFO = "0.1.2";
160164

161165

162166
public static Model getModel() {return m_model;}
@@ -165,13 +169,17 @@ public class LDIS {
165169

166170
public static final Property connectionString = m_model.createProperty( "http://stack.linkeddata.org/ldis-schema/connectionString" );
167171

172+
/** <p>A component integrates another component</p> */
168173
public static final Property integrates = m_model.createProperty( "http://stack.linkeddata.org/ldis-schema/integrates" );
169174

170175
public static final Property password = m_model.createProperty( "http://stack.linkeddata.org/ldis-schema/password" );
171176

172-
/** <p>A component in the stack provides a service of a givent type</p> */
177+
/** <p>A component in the stack provides a service of a given type</p> */
173178
public static final Property providesService = m_model.createProperty( "http://stack.linkeddata.org/ldis-schema/providesService" );
174179

180+
/** <p>A component depends on another component to work</p> */
181+
public static final Property requires = m_model.createProperty( "http://stack.linkeddata.org/ldis-schema/requires" );
182+
175183
public static final Property serviceUrl = m_model.createProperty( "http://stack.linkeddata.org/ldis-schema/serviceUrl" );
176184

177185
public static final Property user = m_model.createProperty( "http://stack.linkeddata.org/ldis-schema/user" );

src/main/java/eu/geoknow/generator/configuration/FrameworkManager.java

Lines changed: 44 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212

1313
import com.fasterxml.jackson.databind.JsonNode;
1414
import com.fasterxml.jackson.databind.ObjectMapper;
15+
import com.hp.hpl.jena.vocabulary.RDFS;
1516
import com.ontos.ldiw.vocabulary.LDIS;
17+
import com.ontos.ldiw.vocabulary.LDIWO;
1618

1719
import eu.geoknow.generator.common.MediaType;
1820
import eu.geoknow.generator.component.ComponentManager;
@@ -105,11 +107,46 @@ public Service getFrameworkService(String uri) throws Exception {
105107
* @return List<String> compoments uris
106108
* @throws Exception
107109
*/
108-
public List<String> getIntegratedComponents() throws Exception {
110+
public List<Map<String, String>> getIntegratedComponents() throws Exception {
109111

110112
String query =
111-
"SELECT ?component FROM <" + config.getSettingsGraph() + "> WHERE { ?workbench <"
112-
+ LDIS.integrates.getURI() + "> ?component }";
113+
"SELECT ?component ?route ?type ?label FROM <" + config.getSettingsGraph() + "> FROM <"
114+
+ config.getComponentsGraph() + "> WHERE { <" + config.getFrameworkUri() + "> <"
115+
+ LDIS.integrates.getURI() + "> ?component . ?component <"
116+
+ LDIS.providesService.getURI() + "> ?service. ?service a ?type . ?service <"
117+
+ RDFS.label.getURI() + "> ?label . ?restriction <" + LDIWO.requiresService.getURI()
118+
+ "> ?service . ?restriction <" + LDIWO.route.getURI() + "> ?route }";
119+
120+
log.debug(query);
121+
String result = storeManager.execute(query, MediaType.SPARQL_JSON_RESPONSE_FORMAT);
122+
123+
List<Map<String, String>> components = new ArrayList<Map<String, String>>();
124+
ObjectMapper mapper = new ObjectMapper();
125+
JsonNode rootNode = mapper.readTree(result);
126+
Iterator<JsonNode> bindingsIter = rootNode.path("results").path("bindings").elements();
127+
while (bindingsIter.hasNext()) {
128+
JsonNode bindingNode = bindingsIter.next();
129+
Map<String, String> component = new HashMap<String, String>();
130+
component.put("uri", bindingNode.get("component").path("value").textValue());
131+
component.put("route", bindingNode.get("route").path("value").textValue());
132+
component.put("type", bindingNode.get("type").path("value").textValue());
133+
component.put("label", bindingNode.get("label").path("value").textValue());
134+
components.add(component);
135+
}
136+
return components;
137+
}
138+
139+
/**
140+
* Get the list of required components
141+
*
142+
* @return List<String> compoments uris
143+
* @throws Exception
144+
*/
145+
public List<String> getRequiredComponents() throws Exception {
146+
147+
String query =
148+
"SELECT ?component FROM <" + config.getSettingsGraph() + "> WHERE { <"
149+
+ config.getFrameworkUri() + "> <" + LDIS.requires.getURI() + "> ?component }";
113150

114151
String result = storeManager.execute(query, MediaType.SPARQL_JSON_RESPONSE_FORMAT);
115152

@@ -133,8 +170,8 @@ public List<String> getIntegratedComponents() throws Exception {
133170
*/
134171
public void setComponentsIntegration(String uri) throws Exception {
135172
String query =
136-
"INSERT DATA INTO <" + config.getSettingsGraph() + "> { ?workbench <"
137-
+ LDIS.integrates.getURI() + "> <" + uri + "> }";
173+
"INSERT DATA INTO <" + config.getSettingsGraph() + "> { <" + config.getFrameworkUri()
174+
+ "> <" + LDIS.integrates.getURI() + "> <" + uri + "> }";
138175

139176
log.debug(query);
140177
String result = storeManager.execute(query, MediaType.SPARQL_JSON_RESPONSE_FORMAT);
@@ -150,9 +187,8 @@ public void setComponentsIntegration(String uri) throws Exception {
150187
*/
151188
public void removeComponentsIntegration(String uri) throws Exception {
152189
String query =
153-
"DELETE FROM <" + config.getSettingsGraph() + "> { ?workbench <" + LDIS.integrates.getURI()
154-
+ "> ?component } WHERE { ?workbench <" + LDIS.integrates.getURI() + "> <" + uri
155-
+ "> }";
190+
"DELETE DATA FROM <" + config.getSettingsGraph() + "> { <" + config.getFrameworkUri()
191+
+ "> <" + LDIS.integrates.getURI() + "> <" + uri + "> } ";
156192
log.debug(query);
157193
String result = storeManager.execute(query, MediaType.SPARQL_JSON_RESPONSE_FORMAT);
158194
log.debug(result);

src/main/java/eu/geoknow/generator/rest/Components.java

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,62 @@ public Response updateComponent(@CookieParam(value = "user") Cookie userc, @Cook
151151
}
152152
}
153153

154+
155+
/**
156+
* Updates the data of a service
157+
*
158+
* @param userc
159+
* @param token
160+
* @param component {@link Component} in JSON format
161+
* @return {@link Component} in JSON format object
162+
*/
163+
@PUT
164+
@Path("/services")
165+
@Produces(MediaType.APPLICATION_JSON)
166+
@Consumes(MediaType.APPLICATION_JSON)
167+
public Response updateService(@CookieParam(value = "user") Cookie userc, @CookieParam(
168+
value = "token") String token, Service service) {
169+
170+
FrameworkUserManager frameworkUserManager;
171+
UserProfile user;
172+
try {
173+
frameworkUserManager = FrameworkConfiguration.getInstance().getFrameworkUserManager();
174+
// authenticates the user, throw exception if fail
175+
user = frameworkUserManager.validate(userc, token);
176+
if (user == null) {
177+
return Response.status(Response.Status.UNAUTHORIZED).entity("Invalid credentials").build();
178+
}
179+
// check that the user is admin so he can update the component
180+
if (!frameworkUserManager.isAdmin(user.getAccountURI())) {
181+
return Response.status(Response.Status.UNAUTHORIZED).entity("Admin role required").build();
182+
}
183+
184+
} catch (Exception e) {
185+
log.error(e);
186+
e.printStackTrace();
187+
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(e.getMessage()).build();
188+
}
189+
190+
try {
191+
// the system user will perform the changes to the Store
192+
ComponentManager manager =
193+
new ComponentManager(FrameworkConfiguration.getInstance().getSystemRdfStoreManager());
194+
Service s = manager.updateService(service);
195+
Gson gson = new Gson();
196+
String json = "{\"service\" : " + gson.toJson(s) + "}";
197+
log.info(json);
198+
return Response.status(Response.Status.OK).entity(json).type(MediaType.APPLICATION_JSON)
199+
.build();
200+
201+
} catch (ResourceNotFoundException e) {
202+
log.error(e);
203+
return Response.status(Response.Status.CONFLICT).entity(e.getMessage()).build();
204+
} catch (SPARQLEndpointException | IOException | InformationMissingException e) {
205+
log.error(e);
206+
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(e.getMessage()).build();
207+
}
208+
}
209+
154210
/**
155211
* Get the components integrated in the system. Any registered user can read this data.
156212
*

src/main/java/eu/geoknow/generator/rest/Configuration.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import java.io.IOException;
44
import java.util.Collection;
55
import java.util.List;
6+
import java.util.Map;
67

78
import javax.servlet.ServletContext;
89
import javax.ws.rs.CookieParam;
@@ -221,9 +222,12 @@ public Response getIntegratedComponents(@CookieParam(value = "user") Cookie user
221222

222223
try {
223224
FrameworkManager manager = new FrameworkManager();
224-
List<String> components = manager.getIntegratedComponents();
225+
List<Map<String, String>> integrated = manager.getIntegratedComponents();
226+
List<String> required = manager.getRequiredComponents();
225227
Gson gson = new Gson();
226-
String json = "{ \"components\" : " + gson.toJson(components) + "}";
228+
String json =
229+
"{ \"integrated\" : " + gson.toJson(integrated) + ", \"required\" : "
230+
+ gson.toJson(required) + "}";
227231
return Response.status(Response.Status.OK).entity(json).type(MediaType.APPLICATION_JSON)
228232
.build();
229233
} catch (Exception e) {

src/main/resources/framework-components-template.ttl

Lines changed: 9 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -134,60 +134,14 @@
134134
a lds:ExplorationService ;
135135
lds:serviceUrl <http://cstadler.aksw.org/mappify2/> .
136136

137+
:Coevolution
138+
a lds:StackComponent ;
139+
rdfs:label "Public-Private Data Coevolution"^^xsd:string ;
140+
lds:providesService :CoevolutionService ;
141+
dcterms:hasVersion "1.0.0"^^xsd:string ;
142+
foaf:homepage <http://geoknow-generator.aws.semweb.unister.de:8080/coevolution-service/> .
137143

138-
139-
########### ROUTES RESTRICTIONS DESCRIPTION #######################################################
140-
# Following triples describe required services for routes. It is used in conditional routing.
141-
# #######################################################################################
142-
144+
:CoevolutionService
145+
a lds:PublicationService ;
146+
lds:serviceUrl <http://geoknow-generator.aws.semweb.unister.de:8080/coevolution-service/> .
143147

144-
:RolesRouteRestriction
145-
a ontos:RouteRestriction;
146-
ontos:partialUrl "/settings/roles"^^xsd:string;
147-
ontos:requiredService :UserManagerService .
148-
149-
:SparqlifyRouteRestriction
150-
a ontos:RouteRestriction;
151-
ontos:partialUrl "/workbench/extraction-and-loading/sparqlify"^^xsd:string;
152-
ontos:requiredService :SparqlifyService .
153-
154-
:TripleGeoRouteRestriction
155-
a ontos:RouteRestriction;
156-
ontos:partialUrl "/workbench/extraction-and-loading/triplegeo"^^xsd:string;
157-
ontos:requiredService :TripleGeoService .
158-
159-
:D2RQGeoRouteRestriction
160-
a ontos:RouteRestriction;
161-
ontos:partialUrl "/workbench/extraction-and-loading/d2rq"^^xsd:string;
162-
ontos:requiredService :D2RQService .
163-
164-
:FaceteRouteRestriction
165-
a ontos:RouteRestriction;
166-
ontos:partialUrl "/workbench/search-querying-and-exploration/facete"^^xsd:string;
167-
ontos:requiredService :FaceteService .
168-
169-
:MappifyRouteRestriction
170-
a ontos:RouteRestriction;
171-
ontos:partialUrl "/workbench/search-querying-and-exploration/mappify"^^xsd:string;
172-
ontos:requiredService :MappifyService .
173-
174-
:OntoWikiRouteRestriction
175-
a ontos:RouteRestriction;
176-
ontos:partialUrl "/workbench/manual-revision-and-authoring/ontowiki"^^xsd:string;
177-
ontos:requiredService :OntoWikiService .
178-
179-
:LIMESRouteRestriction
180-
a ontos:RouteRestriction;
181-
ontos:partialUrl "/workbench/linking-and-fusing/limes"^^xsd:string;
182-
ontos:requiredService :LimesService .
183-
184-
:DEERRouteRestriction
185-
a ontos:RouteRestriction;
186-
ontos:partialUrl "/workbench/classification-and-enrichment/deer"^^xsd:string;
187-
ontos:requiredService :DEERService .
188-
189-
:DashboardRestriction
190-
a ontos:RouteRestriction;
191-
ontos:partialUrl "/workbench"^^xsd:string;
192-
ontos:requiredService :SpringBatchAdminService .
193-

0 commit comments

Comments
 (0)