Project

General

Profile

« Previous | Next » 

Revision 58431

added 2 methods in ProcessUtils

View differences:

modules/dnet-msro-service/trunk/src/main/java/eu/dnetlib/msro/workflows/util/ProcessUtils.java
10 10
import com.googlecode.sarasvati.NodeToken;
11 11

  
12 12
public class ProcessUtils {
13
	
14
	private static String oldGeneratedId = "";	
15
	
16
	private static final Log log = LogFactory.getLog(ProcessUtils.class); 
17
	
13

  
14
	private static String oldGeneratedId = "";
15

  
16
	private static final Log log = LogFactory.getLog(ProcessUtils.class);
17

  
18 18
	public static String calculateName(final GraphProcess process) {
19 19
		return process.getGraph().getName();
20 20
	}
......
22 22
	public static String calculateFamily(final GraphProcess process) {
23 23
		return process.getEnv().getAttribute(WorkflowsConstants.SYSTEM_WF_PROFILE_FAMILY);
24 24
	}
25
	
25

  
26 26
	public static String calculateWfId(final GraphProcess process) {
27
		return  process.getEnv().getAttribute(WorkflowsConstants.SYSTEM_WF_PROFILE_ID);
27
		return process.getEnv().getAttribute(WorkflowsConstants.SYSTEM_WF_PROFILE_ID);
28 28
	}
29
	
29

  
30 30
	public static String calculateStatus(final GraphProcess process) {
31 31
		if (!process.isComplete()) {
32 32
			return process.getState().toString().toUpperCase();
......
36 36
			return "FAILURE";
37 37
		}
38 38
	}
39
	
39

  
40 40
	public static Date calculateLastActivityDate(final GraphProcess process) {
41 41
		Date date = null;
42 42
		for (final NodeToken token : process.getNodeTokens()) {
43 43
			Date activity = token.getCompleteDate();
44
			if (activity == null)
44
			if (activity == null) {
45 45
				activity = token.getCreateDate();
46
			}
46 47

  
47
			if (date == null)
48
			if (date == null) {
48 49
				date = activity;
50
			}
49 51

  
50
			if (activity != null && date != null && activity.compareTo(date) > 0)
52
			if (activity != null && date != null && activity.compareTo(date) > 0) {
51 53
				date = activity;
54
			}
52 55
		}
53 56
		return date;
54 57
	}
55 58

  
56 59
	public static String calculateRepo(final GraphProcess process) {
57
		if (process.getEnv().hasAttribute(WorkflowsConstants.DATAPROVIDER_NAME)) {
58
			return process.getEnv().getAttribute(WorkflowsConstants.DATAPROVIDER_NAME);
60
		if (process.getEnv().hasAttribute(WorkflowsConstants.DATAPROVIDER_NAME)) { return process.getEnv().getAttribute(WorkflowsConstants.DATAPROVIDER_NAME); }
61
		return "";
62
	}
63

  
64
	public static String calculateRepoId(final GraphProcess process) {
65
		if (process.getEnv().hasAttribute(WorkflowsConstants.DATAPROVIDER_ORIGINALID)) {
66
			return process.getEnv().getAttribute(WorkflowsConstants.DATAPROVIDER_ORIGINALID);
59 67
		}
60 68
		return "";
61 69
	}
62 70

  
63
	
71
	public static String calculateApiId(final GraphProcess process) {
72
		if (process.getEnv().hasAttribute(WorkflowsConstants.DATAPROVIDER_INTERFACE)) {
73
			return process.getEnv().getAttribute(WorkflowsConstants.DATAPROVIDER_INTERFACE);
74
		}
75
		return "";
76
	}
77

  
64 78
	public static synchronized String generateProcessId() {
65 79
		String id = "";
66 80
		do {
67
			id = "wf_" + (new SimpleDateFormat("yyyyMMdd_HHmmss_S")).format(new Date());
81
			id = "wf_" + new SimpleDateFormat("yyyyMMdd_HHmmss_S").format(new Date());
68 82
			log.info("Generated processID " + id);
69 83
		} while (id.equals(oldGeneratedId));
70
		
84

  
71 85
		oldGeneratedId = id;
72
		
86

  
73 87
		return id;
74 88
	}
75 89

  

Also available in: Unified diff