Project

General

Profile

« Previous | Next » 

Revision 47185

View differences:

modules/dnet-springboot-apps/trunk/dnet-msro-application/src/main/java/eu/dnetlib/msro/workflows/util/logger/WorkflowLog.java
1
package eu.dnetlib.msro.workflows.util.logger;
2

  
3
import java.util.LinkedHashMap;
4
import java.util.Map;
5

  
6
import org.springframework.data.annotation.Id;
7
import org.springframework.data.mongodb.core.mapping.Document;
8

  
9
@Document(collection = "wf_logs")
10
public class WorkflowLog {
11

  
12
	@Id
13
	public String procId;
14

  
15
	public String name;
16
	public String family;
17
	public int priority;
18
	public boolean success;
19
	public long startDate = 0;
20
	public long endDate = 0;
21
	public boolean template = false;
22
	public String profileId;
23
	public String parent;
24
	public String datasourceId;
25
	public String datasourceName;
26
	public String datasourceApi;
27
	public String error;
28
	public String stacktrace;
29
	public String workerUrl;
30
	public Map<String, String> outputParams = new LinkedHashMap<>();
31

  
32
	public String getProcId() {
33
		return procId;
34
	}
35

  
36
	public void setProcId(final String procId) {
37
		this.procId = procId;
38
	}
39

  
40
	public String getName() {
41
		return name;
42
	}
43

  
44
	public void setName(final String name) {
45
		this.name = name;
46
	}
47

  
48
	public String getFamily() {
49
		return family;
50
	}
51

  
52
	public void setFamily(final String family) {
53
		this.family = family;
54
	}
55

  
56
	public int getPriority() {
57
		return priority;
58
	}
59

  
60
	public void setPriority(final int priority) {
61
		this.priority = priority;
62
	}
63

  
64
	public boolean isSuccess() {
65
		return success;
66
	}
67

  
68
	public void setSuccess(final boolean success) {
69
		this.success = success;
70
	}
71

  
72
	public long getStartDate() {
73
		return startDate;
74
	}
75

  
76
	public void setStartDate(final long startDate) {
77
		this.startDate = startDate;
78
	}
79

  
80
	public long getEndDate() {
81
		return endDate;
82
	}
83

  
84
	public void setEndDate(final long endDate) {
85
		this.endDate = endDate;
86
	}
87

  
88
	public boolean isTemplate() {
89
		return template;
90
	}
91

  
92
	public void setTemplate(final boolean template) {
93
		this.template = template;
94
	}
95

  
96
	public String getProfileId() {
97
		return profileId;
98
	}
99

  
100
	public void setProfileId(final String profileId) {
101
		this.profileId = profileId;
102
	}
103

  
104
	public String getParent() {
105
		return parent;
106
	}
107

  
108
	public void setParent(final String parent) {
109
		this.parent = parent;
110
	}
111

  
112
	public String getDatasourceId() {
113
		return datasourceId;
114
	}
115

  
116
	public void setDatasourceId(final String datasourceId) {
117
		this.datasourceId = datasourceId;
118
	}
119

  
120
	public String getDatasourceName() {
121
		return datasourceName;
122
	}
123

  
124
	public void setDatasourceName(final String datasourceName) {
125
		this.datasourceName = datasourceName;
126
	}
127

  
128
	public String getDatasourceApi() {
129
		return datasourceApi;
130
	}
131

  
132
	public void setDatasourceApi(final String datasourceApi) {
133
		this.datasourceApi = datasourceApi;
134
	}
135

  
136
	public String getError() {
137
		return error;
138
	}
139

  
140
	public void setError(final String error) {
141
		this.error = error;
142
	}
143

  
144
	public String getStacktrace() {
145
		return stacktrace;
146
	}
147

  
148
	public void setStacktrace(final String stacktrace) {
149
		this.stacktrace = stacktrace;
150
	}
151

  
152
	public String getWorkerUrl() {
153
		return workerUrl;
154
	}
155

  
156
	public void setWorkerUrl(final String workerUrl) {
157
		this.workerUrl = workerUrl;
158
	}
159

  
160
	public Map<String, String> getOutputParams() {
161
		return outputParams;
162
	}
163

  
164
	public void setOutputParams(final Map<String, String> outputParams) {
165
		this.outputParams = outputParams;
166
	}
167

  
168
	@Override
169
	public String toString() {
170
		return String.format("[procId=%s, name='%s', profile='%s']", procId, name, profileId);
171
	}
172
}
modules/dnet-springboot-apps/trunk/dnet-msro-application/src/main/java/eu/dnetlib/msro/workflows/util/logger/WorkflowLogRepository.java
1
package eu.dnetlib.msro.workflows.util.logger;
2

  
3
import java.util.List;
4

  
5
import org.springframework.data.mongodb.repository.MongoRepository;
6

  
7
public interface WorkflowLogRepository extends MongoRepository<WorkflowLog, String> {
8

  
9
	public List<WorkflowLog> findByName(String name);
10

  
11
}
modules/dnet-springboot-apps/trunk/dnet-msro-application/src/main/java/eu/dnetlib/msro/controllers/MsroController.java
1 1
package eu.dnetlib.msro.controllers;
2 2

  
3 3
import java.util.HashMap;
4
import java.util.List;
4 5
import java.util.Map;
5 6

  
6 7
import org.apache.commons.logging.Log;
......
19 20
import eu.dnetlib.msro.exceptions.MSROException;
20 21
import eu.dnetlib.msro.workflows.WorkflowRef;
21 22
import eu.dnetlib.msro.workflows.util.WorkflowDispatcher;
23
import eu.dnetlib.msro.workflows.util.logs.WorkflowLog;
24
import eu.dnetlib.msro.workflows.util.logs.WorkflowLogRepository;
22 25
import eu.dnetlib.services.BaseService;
23 26
import eu.dnetlib.services.async.AsyncMethodException;
24 27
import eu.dnetlib.services.async.AsyncRunnable;
......
35 38
	@Autowired
36 39
	private WorkflowDispatcher dispatcher;
37 40

  
41
	@Autowired
42
	private WorkflowLogRepository wfLogRepository;
43

  
38 44
	@RequestMapping("startWorkflow")
39 45
	public WorkflowRef startWorkflow(
40 46
			@RequestParam final String wfId,
......
46 52

  
47 53
	}
48 54

  
55
	@RequestMapping("logs")
56
	public List<WorkflowLog> startWorkflow(@RequestParam final String wfId) {
57

  
58
		return wfLogRepository.findByProfileId(wfId);
59

  
60
	}
61

  
49 62
	@Override
50 63
	public AsyncRunnable createAsyncJob(final String method, final String jsonParams, final AsyncServerCallback callback) throws AsyncMethodException {
51 64
		final ObjectMapper mapper = new ObjectMapper();
modules/dnet-springboot-apps/trunk/dnet-msro-application/src/main/java/eu/dnetlib/msro/workflows/util/WorkflowDispatcher.java
31 31
import eu.dnetlib.msro.exceptions.MSROException;
32 32
import eu.dnetlib.msro.workflows.WorkflowInstance;
33 33
import eu.dnetlib.msro.workflows.WorkflowRef;
34
import eu.dnetlib.msro.workflows.util.logger.WorkflowLog;
35
import eu.dnetlib.msro.workflows.util.logger.WorkflowLogRepository;
34
import eu.dnetlib.msro.workflows.util.logs.WorkflowLog;
35
import eu.dnetlib.msro.workflows.util.logs.WorkflowLogRepository;
36 36
import eu.dnetlib.services.async.AsyncClientCallback;
37 37
import eu.dnetlib.services.async.AsyncResponse;
38 38
import eu.dnetlib.services.async.AsyncServerCallback;
......
256 256
		wfLog.setWorkerUrl(workerUrl);
257 257

  
258 258
		for (final Pair<String, String> p : res) {
259

  
260
			// TODO: molti dei parametri seguenti sono assenti: controllare la risposta
261
			log.info("*********** " + p.getKey() + "->" + p.getValue());
262

  
259 263
			if (p.getKey().equals(WorkflowsConstants.LOG_WF_PROCESS_ID)) {
260 264
				wfLog.setProcId(p.getValue());
261 265
			} else if (p.getKey().equals(WorkflowsConstants.LOG_DATASOURCE_NAME)) {
modules/dnet-springboot-apps/trunk/dnet-msro-application/src/main/java/eu/dnetlib/msro/workflows/util/logs/WorkflowLogRepository.java
1
package eu.dnetlib.msro.workflows.util.logs;
2

  
3
import java.util.List;
4

  
5
import org.springframework.data.mongodb.repository.MongoRepository;
6

  
7
public interface WorkflowLogRepository extends MongoRepository<WorkflowLog, String> {
8

  
9
	public List<WorkflowLog> findByName(String name);
10

  
11
	public List<WorkflowLog> findByProfileId(String wfId);
12

  
13
}
modules/dnet-springboot-apps/trunk/dnet-msro-application/src/main/java/eu/dnetlib/msro/workflows/util/logs/WorkflowLog.java
1
package eu.dnetlib.msro.workflows.util.logs;
2

  
3
import org.springframework.data.annotation.Id;
4
import org.springframework.data.mongodb.core.mapping.Document;
5

  
6
import eu.dnetlib.msro.workflows.logs.WfLogEntry;
7

  
8
@Document(collection = "wf_logs")
9
public class WorkflowLog extends WfLogEntry {
10

  
11
	@Id
12
	private String id;
13

  
14
	public String getId() {
15
		return id;
16
	}
17

  
18
	public void setId(final String id) {
19
		this.id = id;
20
		super.setProcId(id);
21
	}
22

  
23
	@Override
24
	public void setProcId(final String procId) {
25
		setId(procId);
26
	}
27

  
28
}
modules/dnet-springboot-apps/trunk/dnet-administration-uis/src/main/java/eu/dnetlib/administration/uis/modules/workflows/WorkflowsModule.java
54 54
import eu.dnetlib.msro.workflows.WorkflowRef;
55 55
import eu.dnetlib.msro.workflows.WorkflowStatus;
56 56
import eu.dnetlib.msro.workflows.WorkflowsConstants;
57
import eu.dnetlib.msro.workflows.logs.WfLogEntry;
57 58

  
58 59
@RestController
59 60
@RequestMapping("/ajax/wfs")
......
390 391
		return list;
391 392
	}
392 393

  
394
	@RequestMapping("logs")
395
	public List<WfLogEntry> getWorkflowLogs(@RequestParam final String wf) throws Exception {
396
		return clientFactory.getClient(MsroClient.class).listWfLogs(wf);
397
	}
398

  
393 399
}
modules/dnet-springboot-apps/trunk/dnet-administration-uis/src/main/resources/static/js/wfs/wfs.js
256 256
	};
257 257

  
258 258
	$scope.updateHistory = function (wfId) {
259
		$http.get('wf/journal.find?wfs=' + wfId).success(function (data) {
259
		$http.get('/ajax/wfs/logs?wf=' + wfId).success(function (data) {
260 260
			$scope.history = data;
261 261
		}).error(function (err) {
262 262
			show_notification('error', 'Error fetching history: ' + err.message);
modules/dnet-springboot-apps/trunk/dnet-common-utils/src/main/java/eu/dnetlib/msro/workflows/logs/WfLogEntry.java
1
package eu.dnetlib.msro.workflows.logs;
2

  
3
import java.util.LinkedHashMap;
4
import java.util.Map;
5

  
6
public class WfLogEntry {
7

  
8
	private String procId;
9
	private String name;
10
	private String family;
11
	private int priority;
12
	private boolean success;
13
	private long startDate = 0;
14
	private long endDate = 0;
15
	private boolean template = false;
16
	private String profileId;
17
	private String parent;
18
	private String datasourceId;
19
	private String datasourceName;
20
	private String datasourceApi;
21
	private String error;
22
	private String stacktrace;
23
	private String workerUrl;
24
	private Map<String, String> outputParams = new LinkedHashMap<>();
25

  
26
	public String getProcId() {
27
		return procId;
28
	}
29

  
30
	public void setProcId(final String procId) {
31
		this.procId = procId;
32
	}
33

  
34
	public String getName() {
35
		return name;
36
	}
37

  
38
	public void setName(final String name) {
39
		this.name = name;
40
	}
41

  
42
	public String getFamily() {
43
		return family;
44
	}
45

  
46
	public void setFamily(final String family) {
47
		this.family = family;
48
	}
49

  
50
	public int getPriority() {
51
		return priority;
52
	}
53

  
54
	public void setPriority(final int priority) {
55
		this.priority = priority;
56
	}
57

  
58
	public boolean isSuccess() {
59
		return success;
60
	}
61

  
62
	public void setSuccess(final boolean success) {
63
		this.success = success;
64
	}
65

  
66
	public long getStartDate() {
67
		return startDate;
68
	}
69

  
70
	public void setStartDate(final long startDate) {
71
		this.startDate = startDate;
72
	}
73

  
74
	public long getEndDate() {
75
		return endDate;
76
	}
77

  
78
	public void setEndDate(final long endDate) {
79
		this.endDate = endDate;
80
	}
81

  
82
	public boolean isTemplate() {
83
		return template;
84
	}
85

  
86
	public void setTemplate(final boolean template) {
87
		this.template = template;
88
	}
89

  
90
	public String getProfileId() {
91
		return profileId;
92
	}
93

  
94
	public void setProfileId(final String profileId) {
95
		this.profileId = profileId;
96
	}
97

  
98
	public String getParent() {
99
		return parent;
100
	}
101

  
102
	public void setParent(final String parent) {
103
		this.parent = parent;
104
	}
105

  
106
	public String getDatasourceId() {
107
		return datasourceId;
108
	}
109

  
110
	public void setDatasourceId(final String datasourceId) {
111
		this.datasourceId = datasourceId;
112
	}
113

  
114
	public String getDatasourceName() {
115
		return datasourceName;
116
	}
117

  
118
	public void setDatasourceName(final String datasourceName) {
119
		this.datasourceName = datasourceName;
120
	}
121

  
122
	public String getDatasourceApi() {
123
		return datasourceApi;
124
	}
125

  
126
	public void setDatasourceApi(final String datasourceApi) {
127
		this.datasourceApi = datasourceApi;
128
	}
129

  
130
	public String getError() {
131
		return error;
132
	}
133

  
134
	public void setError(final String error) {
135
		this.error = error;
136
	}
137

  
138
	public String getStacktrace() {
139
		return stacktrace;
140
	}
141

  
142
	public void setStacktrace(final String stacktrace) {
143
		this.stacktrace = stacktrace;
144
	}
145

  
146
	public String getWorkerUrl() {
147
		return workerUrl;
148
	}
149

  
150
	public void setWorkerUrl(final String workerUrl) {
151
		this.workerUrl = workerUrl;
152
	}
153

  
154
	public Map<String, String> getOutputParams() {
155
		return outputParams;
156
	}
157

  
158
	public void setOutputParams(final Map<String, String> outputParams) {
159
		this.outputParams = outputParams;
160
	}
161

  
162
	@Override
163
	public String toString() {
164
		return String.format("[procId=%s, name='%s', profile='%s']", procId, name, profileId);
165
	}
166
}
modules/dnet-springboot-apps/trunk/dnet-common-utils/src/main/java/eu/dnetlib/clients/msro/MsroClient.java
1 1
package eu.dnetlib.clients.msro;
2 2

  
3 3
import java.io.StringWriter;
4
import java.util.Arrays;
5
import java.util.List;
4 6
import java.util.Map;
5 7

  
6 8
import org.apache.commons.lang3.StringUtils;
......
13 15
import eu.dnetlib.enabling.annotations.DnetServiceClient;
14 16
import eu.dnetlib.enabling.annotations.DnetServiceType;
15 17
import eu.dnetlib.msro.workflows.WorkflowRef;
18
import eu.dnetlib.msro.workflows.logs.WfLogEntry;
16 19
import eu.dnetlib.services.async.AsyncClientCallback;
17 20
import eu.dnetlib.services.async.AsyncClientUtils;
18 21

  
......
94 97
		asyncClientUtils.invokeRemoteMethod(getBaseUrl(), "startWorkflow", localBaseUrl, wf, callback);
95 98
	}
96 99

  
100
	public List<WfLogEntry> listWfLogs(final String wfId) {
101
		final RestTemplate restTemplate = new RestTemplate();
102
		final String url = getBaseUrl() + "/logs?wfId=" + wfId;
103
		return Arrays.asList(restTemplate.getForObject(url, WfLogEntry[].class));
104
	}
105

  
97 106
}
modules/dnet-springboot-apps/trunk/dnet-common-utils/src/main/java/eu/dnetlib/miscutils/collections/Pair.java
44 44
		this.value = value;
45 45
	}
46 46

  
47
	@Override
48
	public String toString() {
49
		return String.format("[%s] -> [%s]", key, value);
50
	}
51

  
47 52
}

Also available in: Unified diff