Project

General

Profile

« Previous | Next » 

Revision 46729

async methods

View differences:

WorkflowsModule.java
45 45
import eu.dnetlib.administration.uis.modules.workflows.objects.WorkflowUpdateInfo;
46 46
import eu.dnetlib.clients.dsManager.DsManagerClient;
47 47
import eu.dnetlib.clients.is.InformationServiceClient;
48
import eu.dnetlib.clients.locators.ServiceClientFactory;
49
import eu.dnetlib.clients.msro.MsroClient;
48 50
import eu.dnetlib.msro.workflows.NotificationCondition;
49 51
import eu.dnetlib.msro.workflows.StartMode;
50 52
import eu.dnetlib.msro.workflows.WorkflowsConstants;
53
import eu.dnetlib.services.async.AsyncClientCallback;
54
import eu.dnetlib.services.async.AsyncResponse;
51 55

  
52 56
@RestController
53 57
@RequestMapping("/ajax/wfs")
......
66 70
	@Autowired
67 71
	private WorkflowsUIUtils wfUtils;
68 72

  
73
	@Autowired
74
	private ServiceClientFactory clientFactory;
75

  
69 76
	@Autowired(required = false)
70 77
	private List<ParamValuesFunction> paramValuesFunctions = new ArrayList<>();
71 78

  
......
178 185

  
179 186
	}
180 187

  
188
	@RequestMapping("startWorkflow")
189
	public boolean startWorkflow(@RequestParam final String wfId) throws Exception {
190

  
191
		final MsroClient msro = clientFactory.getClient(MsroClient.class);
192

  
193
		msro.startWorkflow(wfId, null, null, new AsyncClientCallback() {
194

  
195
			@Override
196
			public void onGoing(final AsyncResponse res) {
197
				log.info("ONGOING - " + res.getResponseJson());
198
			}
199

  
200
			@Override
201
			public void onFailed(final AsyncResponse res) {
202
				log.info("FAILED - " + res.getResponseJson());
203
			}
204

  
205
			@Override
206
			public void onDone(final AsyncResponse res) {
207
				log.info("DONE - " + res.getResponseJson());
208
			}
209
		});
210

  
211
		return true;
212
	}
213

  
214
	@RequestMapping("startWorkflowTemplate")
215
	public @ResponseBody boolean startWorkflowTemplate(
216
			@RequestParam final String node,
217
			@RequestParam final String parentWf) throws Exception {
218

  
219
		// TODO
220

  
221
		/*
222
		 * final String profile = isClient.getProfile(parentWf); final Document doc = (new SAXReader()).read(new StringReader(profile));
223
		 * final String family = doc.valueOf("//WORKFLOW_FAMILY"); final int priority =
224
		 * NumberUtils.toInt(doc.valueOf("//WORKFLOW_PRIORITY"), WorkflowsConstants.DEFAULT_WF_PRIORITY); final String dsId =
225
		 * doc.valueOf("//DATASOURCE/@id"); final String iface = doc.valueOf("//DATASOURCE/@interface");
226
		 *
227
		 * final Map<String, String> globalParams = new HashMap<String, String>(); for (final Object o :
228
		 * doc.selectNodes("//CONFIGURATION/PARAMETERS/PARAM")) { final Element p = (Element) o; globalParams.put(p.valueOf("@name"),
229
		 * p.getTextTrim()); }
230
		 *
231
		 * final Node n = doc.selectSingleNode("//NODE[@name='" + node + "']"); final Map<String, Object> params = GraphNode.newNode(node,
232
		 * n.valueOf("@type"), graphLoader.calculateParamsForNode(node, globalParams)) .resolveParamsWithNoEnv();
233
		 *
234
		 * if (!params.containsKey("wfTemplateId") || !(params.get("wfTemplateId") instanceof String) || StringUtils.isBlank((String)
235
		 * params.get("wfTemplateId"))) { log.error("wfTemplateId is invalid or missing in profile " + parentWf); throw new
236
		 * DnetGenericException("wfTemplateId is invalid or missing in profile " + parentWf); }
237
		 *
238
		 * if (params.containsKey("wfTemplateParams") && !(params.get("wfTemplateParams") instanceof Map)) { log.error(
239
		 * "wfTemplateParams is invalid in profile " + parentWf); throw new DnetGenericException("wfTemplateParams is invalid in profile " +
240
		 * parentWf); }
241
		 *
242
		 * final String wfTtemplateId = (String) params.get("wfTemplateId");
243
		 *
244
		 * @SuppressWarnings("unchecked") final Map<String, String> wfTtemplateParams = (Map<String, String>)
245
		 * params.get("wfTemplateParams");
246
		 *
247
		 * final MsroClient msro = clientFactory.getClient(MsroClient.class);
248
		 *
249
		 * msro.startWorkflowTemplate(wfTtemplateId, parentWf, node, family, wfTtemplateParams, dsId, iface, null);
250
		 */
251
		return true;
252
	}
253

  
181 254
	@RequestMapping(value = "validValues/{param}", method = RequestMethod.POST)
182 255
	public List<Value> obtainValidValues(@PathVariable final String param, @RequestBody final Map<String, String> params) throws IOException {
183 256

  

Also available in: Unified diff