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

Commit 9a716bf

Browse files
committed
change rest for getting components to use Ids
1 parent 0fb0f00 commit 9a716bf

File tree

19 files changed

+125
-127
lines changed

19 files changed

+125
-127
lines changed

pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@
213213
<artifactId>tomcat7-maven-plugin</artifactId>
214214
<version>2.2</version>
215215
<configuration>
216-
<server>generator</server>
216+
<server>localhost</server>
217217
<url>${tomcat.deploy.url}</url>
218218
<path>/${project.build.finalName}</path>
219219
<update>true</update>
@@ -234,9 +234,9 @@
234234
<configuration>
235235
<deb>${project.build.directory}/${project.artifactId}_${project.version}_all.deb</deb>
236236
<changesOut>${project.build.directory}/${project.artifactId}_${project.version}_all.changes</changesOut>
237-
<signPackage>true</signPackage>
237+
<!-- <signPackage>true</signPackage>
238238
<signMethod>dpkg-sig</signMethod>
239-
<signRole>builder</signRole>
239+
<signRole>builder</signRole> -->
240240
<dataSet>
241241
<data>
242242
<type>template</type>

src/main/java/eu/geoknow/generator/component/ComponentManager.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -145,16 +145,17 @@ public Collection<Component> getAllComponents() throws SPARQLEndpointException,
145145
/**
146146
* Get the component data
147147
*
148-
* @param uri
148+
* @param id
149149
* @return Component or null if not found
150150
* @throws SPARQLEndpointException
151151
* @throws IOException
152152
* @throws ResourceNotFoundException
153153
*/
154-
public Component getComponent(String uri) throws SPARQLEndpointException, IOException,
154+
public Component getComponent(String id) throws SPARQLEndpointException, IOException,
155155
ResourceNotFoundException {
156156
Component component = null;
157-
157+
String uri = config.getResourceNamespace() + id;
158+
log.debug(config.getResourceNamespace());
158159
try {
159160

160161
// get all components and the services list
@@ -497,8 +498,8 @@ public Collection<Service> getAllServices() throws SPARQLEndpointException, IOEx
497498
* @throws SPARQLEndpointException
498499
* @throws IOException
499500
*/
500-
public Service getService(String uri) throws SPARQLEndpointException, IOException {
501-
501+
public Service getService(String id) throws SPARQLEndpointException, IOException {
502+
String uri = config.getResourceNamespace() + id;
502503
Service service = new Service();
503504
service.setUri(uri);
504505
try {

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -264,9 +264,9 @@ public Response getComponents(@CookieParam(value = "user") Cookie userc, @Cookie
264264
* @return JSON
265265
*/
266266
@GET
267-
@Path("/{uri : .+}")
268-
@Produces(MediaType.APPLICATION_JSON)
269-
public Response getComponent(@PathParam("uri") String uri,
267+
@Path("/{id : .+}")
268+
@Produces({MediaType.APPLICATION_JSON, MediaType.TEXT_PLAIN})
269+
public Response getComponent(@PathParam("id") String id,
270270
@CookieParam(value = "user") Cookie userc, @CookieParam(value = "token") String token) {
271271

272272
FrameworkUserManager frameworkUserManager;
@@ -288,7 +288,7 @@ public Response getComponent(@PathParam("uri") String uri,
288288
try {
289289
ComponentManager manager =
290290
new ComponentManager(FrameworkConfiguration.getInstance().getSystemRdfStoreManager());
291-
Component component = manager.getComponent(uri);
291+
Component component = manager.getComponent(id);
292292
// in fact not all properties should be accessible by any user
293293
if (!frameworkUserManager.isAdmin(user.getAccountURI())) {
294294
for (Service s : component.getServices())
@@ -301,10 +301,12 @@ public Response getComponent(@PathParam("uri") String uri,
301301

302302
} catch (ResourceNotFoundException e) {
303303
log.error(e);
304-
return Response.status(Response.Status.NOT_FOUND).entity(e.getMessage()).build();
304+
return Response.status(Response.Status.NOT_FOUND).entity(e.getMessage())
305+
.type(MediaType.TEXT_PLAIN).build();
305306
} catch (Exception e) {
306307
log.error(e);
307-
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(e.getMessage()).build();
308+
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(e.getMessage())
309+
.type(MediaType.TEXT_PLAIN).build();
308310
}
309311

310312
}

src/main/webapp/js/directives.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,20 +49,26 @@ module.directive('targetGraph', ['$parse', 'GraphService', function($parse, Grap
4949
}]);
5050

5151
/**
52-
This requres that the parent scope defines in its scope:
53-
$scope.source = {label, graph}
54-
52+
* This directive requres that the parent scope defines in its scope:
53+
* $scope.source = {label, graph}
5554
*/
56-
module.directive('sourceGraph', ['$parse', 'GraphService', function($parse, GraphService){
55+
module.directive('sourceGraph', ['$parse', 'GraphService', 'GraphGroupService', function($parse, GraphService, GraphGroupService){
5756
return {
5857
restrict: 'E',
5958
templateUrl: 'js/workbench/partials/source-graph.html',
6059
scope: true,
6160
link : function ($scope, elem, attrs, ctrl) {
6261

6362
$scope.refreshReadableGraphs = function() {
63+
// return GraphService.getAccessibleGraphs(false, false, true).then(function(graphs) {
64+
// $scope.readableGraphs = graphs;
65+
// });
6466
return GraphService.getAccessibleGraphs(false, false, true).then(function(graphs) {
65-
$scope.readableGraphs = graphs;
67+
var ngraphs = graphs;
68+
GraphGroupService.getAllGraphGroups(true).then(function(groups) {
69+
ngraphs = ngraphs.concat(groups);
70+
$scope.readableGraphs = ngraphs;
71+
});
6672
});
6773
};
6874

src/main/webapp/js/services/co-evolution-service.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ var module = angular.module('app.co-evolution-service', []);
44

55
module.factory("CoevolutionService", function ($http, ComponentsService, Ns, Config) {
66

7-
var componentUri = "http://generator.geoknow.eu/resource/Coevolution";
8-
var serviceUri = "http://generator.geoknow.eu/resource/CoevolutionService";
7+
var componentId = "Coevolution";
8+
var serviceId = "CoevolutionService";
99
var serviceUrl = "";
1010

11-
var promise = ComponentsService.getService(serviceUri).then(
11+
var promise = ComponentsService.getService(serviceId).then(
1212
//success
1313
function(service){
1414
serviceUrl = service.serviceUrl;
@@ -44,7 +44,7 @@ module.factory("CoevolutionService", function ($http, ComponentsService, Ns, Con
4444

4545

4646
getComponent : function(){
47-
return ComponentsService.getComponent(componentUri).then(
47+
return ComponentsService.getComponent(componentId).then(
4848
function(response){
4949
return response;
5050
});

src/main/webapp/js/services/components-service.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
var module = angular.module('app.components-service', []);
44

5-
module.factory('ComponentsService', function ($http, $q) {
5+
module.factory('ComponentsService', function ($http, $q, ConfigurationService) {
6+
67

78
var service = {
89

@@ -15,14 +16,16 @@ module.factory('ComponentsService', function ($http, $q) {
1516
},
1617

1718
getComponent: function(id){
18-
return $http.get("rest/components/"+id).then(
19+
return $http.get("rest/components/" + id).then(
1920
// success
2021
function (response){
2122
return response.data.component;
2223
});
2324
},
2425
// parse the component data to find a service
25-
getComponentService : function(uri, component){
26+
getComponentService : function(id, component){
27+
var uri = ConfigurationService.getUriBase() + id;
28+
console.log(uri);
2629
for(var i in component.services){
2730
if (component.services[i].uri == uri)
2831
return component.services[i];
@@ -38,8 +41,8 @@ module.factory('ComponentsService', function ($http, $q) {
3841
});
3942
},
4043

41-
getService: function(uri){
42-
return $http.get("rest/services/"+uri).then(
44+
getService: function(id){
45+
return $http.get("rest/services/"+id).then(
4346
// success
4447
function (response){
4548
return response.data.service;

src/main/webapp/js/workbench/classification-and-enrichment/deer-controller.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@
88

99
var DeerCtrl = function($scope, $http, ConfigurationService, ComponentsService, flash, ServerErrorResponse, $window, AccountService, GraphService){
1010

11-
var componentUri ="http://generator.geoknow.eu/resource/DEER";
12-
var serviceUri = "http://generator.geoknow.eu/resource/DEERService";
11+
var componentId ="DEER";
12+
var serviceId = "DEERService";
1313

14-
ComponentsService.getComponent(componentUri).then(
14+
ComponentsService.getComponent(componentId).then(
1515
//success
1616
function(response){
1717
$scope.component = response;
18-
$scope.service = ComponentsService.getComponentService(serviceUri, $scope.component);
18+
$scope.service = ComponentsService.getComponentService(serviceId, $scope.component);
1919
if($scope.service== null)
20-
flash.error="Service not configured: " + serviceUri;
20+
flash.error="Service not configured: " + serviceId;
2121
},
2222
function(response){
2323
flash.error="Component not configured: " +ServerErrorResponse.getMessage(response);

src/main/webapp/js/workbench/dashboard-controller.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
'use strict';
22

3-
function DashboardCtrl($scope, JobService, ComponentsService, $http) {
3+
function DashboardCtrl($scope, JobService, ComponentsService, $http, flash, ServerErrorResponse) {
44

5-
var sbaUri ="http://generator.geoknow.eu/resource/SpringBatch";
6-
var serviceUri = "http://generator.geoknow.eu/resource/SpringBatchService";
5+
var sbaId ="SpringBatch";
6+
var serviceId = "SpringBatchService";
77

8-
ComponentsService.getComponent(sbaUri).then(
8+
ComponentsService.getComponent(sbaId).then(
99
//success
1010
function(response){
1111
$scope.sba = response;
12-
$scope.service = ComponentsService.getComponentService(serviceUri, $scope.sba);
12+
$scope.service = ComponentsService.getComponentService(serviceId, $scope.sba);
1313
if($scope.service== null)
14-
flash.error="Service not configured: " +serviceUri;
14+
flash.error="Service not configured: " +serviceId;
1515
},
1616
function(response){
1717
flash.error="Component not configured: " +ServerErrorResponse.getMessage(response);

src/main/webapp/js/workbench/evolution-and-repair/coevolution-controller.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
var CoevolutionCtrl = function($scope, $http, Ns, CoevolutionService, ComponentsService, flash, ServerErrorResponse, GraphService){
44

55

6-
var serviceUri = "http://generator.geoknow.eu/resource/CoevolutionService";
6+
var serviceId = "CoevolutionService";
77
CoevolutionService.getComponent().then(
88
//success
99
function(response){
1010
$scope.component = response;
11-
$scope.service = ComponentsService.getComponentService(serviceUri, $scope.component);
11+
$scope.service = ComponentsService.getComponentService(serviceId, $scope.component);
1212
if($scope.service== null)
13-
flash.error="Service not configured: " + serviceUri;
13+
flash.error="Service not configured: " + serviceId;
1414

1515
$scope.refreshGraphs();
1616
$scope.conflictResolutionStrategies = CoevolutionService.getConflictResolutionStrategies();

src/main/webapp/js/workbench/extraction-and-loading/sparqlify-controller.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@
88
app.controller('SparqlifyCtrl', function($scope, ComponentsService) {
99
//Settings for Sparqlilfy
1010

11-
var componentUri ="http://generator.geoknow.eu/resource/Sparqlify";
12-
var serviceUri = "http://generator.geoknow.eu/resource/SparqlifyService";
11+
var componentId ="Sparqlify";
12+
var serviceId = "SparqlifyService";
1313

14-
ComponentsService.getComponent(componentUri).then(
14+
ComponentsService.getComponent(componentId).then(
1515
//success
1616
function(response){
1717
$scope.component = response;
18-
$scope.service = ComponentsService.getComponentService(serviceUri, $scope.component);
18+
$scope.service = ComponentsService.getComponentService(serviceId, $scope.component);
1919
if($scope.service== null)
20-
flash.error="Service not configured: " +serviceUri;
20+
flash.error="Service not configured: " +serviceId;
2121
},
2222
function(response){
2323
flash.error="Component not configured: " +ServerErrorResponse.getMessage(response);

0 commit comments

Comments
 (0)