Project

General

Profile

1
package eu.dnetlib.clients.msro;
2

    
3
import java.util.Map;
4

    
5
import org.springframework.beans.factory.annotation.Autowired;
6
import org.springframework.context.annotation.Scope;
7
import org.springframework.stereotype.Component;
8
import org.springframework.web.client.RestTemplate;
9

    
10
import eu.dnetlib.clients.BaseServiceClient;
11
import eu.dnetlib.enabling.annotations.DnetServiceClient;
12
import eu.dnetlib.enabling.annotations.DnetServiceType;
13
import eu.dnetlib.msro.workflows.WorkflowInstance;
14
import eu.dnetlib.msro.workflows.WorkflowRef;
15
import eu.dnetlib.services.async.AsyncClientCallback;
16
import eu.dnetlib.services.async.AsyncClientUtils;
17

    
18
@Component
19
@Scope("prototype")
20
@DnetServiceClient(DnetServiceType.msroWorker)
21
public class MsroWorkerClient extends BaseServiceClient {
22

    
23
	@Autowired
24
	private AsyncClientUtils asyncClientUtils;
25

    
26
	public MsroWorkerRunningInstance getStatus() {
27
		return (new RestTemplate()).getForObject(getBaseUrl(), MsroWorkerRunningInstance.class);
28
	}
29

    
30
	public WorkflowRef execute(final WorkflowInstance wf, final String localBaseUrl, final AsyncClientCallback callback) {
31
		final Map<String, String> info = asyncClientUtils.invokeRemoteMethod(getBaseUrl(), "startWorkflow", localBaseUrl, wf, callback);
32

    
33
		return new WorkflowRef(info.get("procId"), getBaseUrl());
34
	}
35

    
36
}
(2-2/6)