Project

General

Profile

« Previous | Next » 

Revision 29609

Blackboard inspector

View differences:

modules/dnet-modular-is-ui/trunk/src/main/java/eu/dnetlib/functionality/modular/ui/is/InformationServiceInternalController.java
11 11
import javax.servlet.ServletResponse;
12 12

  
13 13
import org.apache.commons.io.IOUtils;
14
import org.apache.commons.lang.StringUtils;
14 15
import org.apache.commons.lang.math.NumberUtils;
15 16
import org.apache.commons.logging.Log;
16 17
import org.apache.commons.logging.LogFactory;
18
import org.dom4j.Document;
19
import org.dom4j.io.SAXReader;
17 20
import org.springframework.stereotype.Controller;
18 21
import org.springframework.web.bind.annotation.RequestMapping;
19 22
import org.springframework.web.bind.annotation.RequestParam;
......
23 26
import com.google.common.collect.Maps;
24 27

  
25 28
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService;
29
import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
26 30
import eu.dnetlib.enabling.tools.ServiceLocator;
31
import eu.dnetlib.functionality.modular.ui.is.objects.BlackboardMessage;
27 32
import eu.dnetlib.functionality.modular.ui.is.objects.CollectionDesc;
28 33

  
29 34
@Controller
......
31 36
	
32 37
	@Resource(name="lookupLocator")
33 38
	private ServiceLocator<ISLookUpService> lookupLocator;
39
	
40
	@Resource(name="registryLocator")
41
	private ServiceLocator<ISRegistryService> registryLocator;
34 42
		
35 43
	private static final Log log = LogFactory.getLog(InformationServiceInternalController.class);
36 44

  
......
94 102
		return lookupLocator.getService().getResourceProfile(id);
95 103
	}
96 104
	
105
	@RequestMapping("/ui/is/registerProfile.do")
106
	public @ResponseBody String registerProfile(@RequestParam(value = "profile", required = true) final String profile) throws Exception {
107
		return registryLocator.getService().registerProfile(profile);
108
	}
109

  
110
	@RequestMapping("/ui/is/updateProfile.do")
111
	public @ResponseBody String updateProfile(@RequestParam(value = "profile", required = true) final String profile) throws Exception {
112
		final SAXReader reader = new SAXReader();
113
		final Document doc = reader.read(new StringReader(profile));
114
		
115
		final String id = doc.valueOf("//RESOURCE_IDENTIFIER/@value");
116
		final String type = doc.valueOf("//RESOURCE_TYPE/@value");
117
		
118
		if (StringUtils.isEmpty(id)) {
119
			throw new Exception("RESOURCE_IDENTIFIER is empty");
120
		} else if (StringUtils.isEmpty(type)) {
121
			throw new Exception("RESOURCE_TYPE is empty");
122
		} else if (registryLocator.getService().updateProfile(id, profile, type)) {
123
			return id;
124
		} else {
125
			throw new Exception("Profile not updated");
126
		}
127
	}
97 128
	
129
	@RequestMapping("/ui/is/deleteProfile.do")
130
	public @ResponseBody boolean deleteProfile(@RequestParam(value = "id", required = true) final String id) throws Exception {
131
		return registryLocator.getService().deleteProfile(id);
132
	}
133
	
134
	@RequestMapping("/ui/is/listBlackboards.do")
135
	public @ResponseBody List<BlackboardMessage> listBlackboards() throws Exception {
136
		final List<BlackboardMessage> list = Lists.newArrayList();
137
		
138
		final SAXReader reader = new SAXReader();
139

  
140
		for (String xml : lookupLocator.getService().quickSearchProfile("for $x in collection('/db/DRIVER/ServiceResources')//MESSAGE return <message>{$x/../../..//RESOURCE_TYPE}{$x/../../..//RESOURCE_IDENTIFIER}{$x}</message>")) {
141
			final BlackboardMessage info = new BlackboardMessage();
142
			final Document doc = reader.read(new StringReader(xml));
143
			info.setProfId(doc.valueOf(".//RESOURCE_IDENTIFIER/@value"));
144
			info.setMessageId(doc.valueOf(".//@id"));
145
			info.setResourceType(doc.valueOf(".//RESOURCE_TYPE/@value"));
146
			info.setAction(doc.valueOf(".//ACTION"));
147
			info.setDate(doc.valueOf(".//@date"));
148
			info.setActionStatus(doc.valueOf(".//ACTION_STATUS"));
149
			info.setError(doc.valueOf(".//PARAMETER[@name='error']/@value"));
150
			list.add(info);
151
		}
152
		return list;
153
	}
154
	
155
	
156
	
98 157
	public void sendXML(final ServletResponse response, final String xml) throws IOException {
99 158
		response.setContentType("text/xml");
100 159
		
modules/dnet-modular-is-ui/trunk/src/main/java/eu/dnetlib/functionality/modular/ui/is/objects/BlackboardMessage.java
1
package eu.dnetlib.functionality.modular.ui.is.objects;
2

  
3
public class BlackboardMessage {
4
	private String profId;
5
	private String messageId;
6
	private String resourceType; 
7
	private String action;
8
	private String date;
9
	private String actionStatus;
10
	private String error;
11
	
12
	public BlackboardMessage() {}
13
	
14
	public BlackboardMessage(String profId, String messageId, String resourceType,	String action, String date, String actionStatus, String error) {
15
		this.profId = profId;
16
		this.messageId = messageId;
17
		this.resourceType = resourceType;
18
		this.action = action;
19
		this.date = date;
20
		this.actionStatus = actionStatus;
21
		this.error = error;
22
	}
23

  
24
	public String getProfId() {
25
		return profId;
26
	}
27

  
28
	public void setProfId(String profId) {
29
		this.profId = profId;
30
	}
31

  
32
	public String getMessageId() {
33
		return messageId;
34
	}
35

  
36
	public void setMessageId(String messageId) {
37
		this.messageId = messageId;
38
	}
39

  
40
	public String getResourceType() {
41
		return resourceType;
42
	}
43

  
44
	public void setResourceType(String resourceType) {
45
		this.resourceType = resourceType;
46
	}
47

  
48
	public String getAction() {
49
		return action;
50
	}
51

  
52
	public void setAction(String action) {
53
		this.action = action;
54
	}
55

  
56
	public String getDate() {
57
		return date;
58
	}
59

  
60
	public void setDate(String date) {
61
		this.date = date;
62
	}
63

  
64
	public String getActionStatus() {
65
		return actionStatus;
66
	}
67

  
68
	public void setActionStatus(String actionStatus) {
69
		this.actionStatus = actionStatus;
70
	}
71

  
72
	public String getError() {
73
		return error;
74
	}
75

  
76
	public void setError(String error) {
77
		this.error = error;
78
	}
79
}
modules/dnet-modular-is-ui/trunk/src/main/resources/eu/dnetlib/web/resources/html/is/blackboard.html
1
Blackboard
1
<p>
2
	<button class="btn btn-sm btn-default" ng-click="refresh()"><span class="glyphicon glyphicon-refresh"></span> refresh</button>
3
</p>
4
<table class="table table-striped">
5
	<thead>
6
		<tr>
7
			<th>Message Id</th>
8
			<th>Resource Type</th>
9
			<th>Action</th>
10
			<th>Date</th>
11
			<th>Status</th>
12
			<th class="text-center">Error</th>
13
		</tr>
14
	</thead>
15
	<tbody>
16
		<tr ng-repeat="b in blackboards">
17
			<td><a href="#/profile/{{b.profId}}">{{b.messageId}}</a></td>
18
			<td>{{b.resourceType}}</td>
19
			<td>{{b.action}}</td>
20
			<td>{{b.date}}</td>
21
			<td><span class="label label-default" ng-class="{'label-primary': b.actionStatus=='ASSIGNED', 'label-success': b.actionStatus=='ONGOING', 'label-success': b.actionStatus=='DONE', 'label-danger': b.actionStatus=='FAILED'}">{{b.actionStatus}}</span></td>
22
			<td class="text-center"><span class="text-danger glyphicon glyphicon-warning-sign" title="{{b.error}}" ng-show="b.error"></span></td>	
23
		</tr>
24
	</tbody>
25
</table>
modules/dnet-modular-is-ui/trunk/src/main/resources/eu/dnetlib/web/resources/js/is_manager.js
14 14
			.when('/bulk',                 { templateUrl: '../resources/html/is/bulk.html',          controller: 'bulkImporterCtrl' })
15 15
			.when('/verify',               { templateUrl: '../resources/html/is/verify.html',        controller: 'validateProvilesCtrl' })
16 16
			.when('/subscriptions',        { templateUrl: '../resources/html/is/subscriptions.html', controller: 'subscriptionsCtrl' })
17
			.when('/blackboard',           { templateUrl: '../resources/html/is/blackboard.html',    controller: 'subscriptionsCtrl' })
18
			.when('/backup',               { templateUrl: '../resources/html/is/backup.html',        controller: 'blackboardCtrl' })
17
			.when('/blackboard',           { templateUrl: '../resources/html/is/blackboard.html',    controller: 'blackboardCtrl' })
18
			.when('/backup',               { templateUrl: '../resources/html/is/backup.html',        controller: 'backupCtrl' })
19 19
			.otherwise({ redirectTo: '/list' });
20 20
	}
21 21
]);
modules/dnet-modular-is-ui/trunk/src/main/resources/eu/dnetlib/web/resources/js/is_manager_controllers.js
219 219
	}
220 220
]);
221 221

  
222

  
223 222
isManagerControllers.controller('subscriptionsCtrl', [
224 223
	'$scope', '$http', '$sce', '$location', '$routeParams',
225 224
	function ($scope, $http, $sce, $location, $routeParams) {
......
246 245
]);
247 246

  
248 247

  
249
isManagerControllers.controller('subscriptionsCtrl', [
250
	'$scope', '$http', '$sce', '$location', '$routeParams',
251
	function ($scope, $http, $sce, $location, $routeParams) {
252
		common_init($scope, $http, $sce, $location);
253

  
254
		$scope.results = [];
255

  
256
		$scope.XXXXXXX = function() {
257
			$scope.results = [];
258

  
259
			$scope.showSpinner();
260
			$http.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded";
261
			$http.post('is/XXXXXX.do', $.param({
262
				'query' : $scope.query
263
			})).success(function(data) {
264
				$scope.hideSpinner();
265
				$scope.results = data;
266
			}).error(function() {
267
				$scope.showError('Something really bad must have happened to our fellow hamster..');
268
				$scope.hideSpinner();
269
		    });
270
		}
271
	}
272
]);
273

  
274

  
275 248
isManagerControllers.controller('blackboardCtrl', [
276 249
	'$scope', '$http', '$sce', '$location', '$routeParams',
277 250
	function ($scope, $http, $sce, $location, $routeParams) {
278 251
		common_init($scope, $http, $sce, $location);
279

  
280
		$scope.results = [];
281

  
282
		$scope.XXXXXXX = function() {
283
			$scope.results = [];
284

  
285
			$scope.showSpinner();
286
			$http.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded";
287
			$http.post('is/XXXXXX.do', $.param({
288
				'query' : $scope.query
289
			})).success(function(data) {
252
		
253
		$scope.showSpinner();
254
	
255
		$scope.refresh = function() {
256
			$scope.blackboards = [];
257
			$http.get('is/listBlackboards.do').success(function(data) {
290 258
				$scope.hideSpinner();
291
				$scope.results = data;
259
				$scope.blackboards = data;
292 260
			}).error(function() {
293
				$scope.showError('Something really bad must have happened to our fellow hamster..');
261
				$scope.showError('Error retreiving schemas');
294 262
				$scope.hideSpinner();
295 263
		    });
296 264
		}
265
		$scope.refresh();
297 266
	}
298 267
]);
299 268

  

Also available in: Unified diff