Project

General

Profile

1
package eu.dnetlib.functionality.modular.ui.workflows.objects;
2

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

    
7
import org.apache.commons.lang3.math.NumberUtils;
8

    
9
import eu.dnetlib.msro.logging.LogMessage;
10
import eu.dnetlib.msro.workflows.procs.Token;
11
import eu.dnetlib.msro.workflows.procs.WorkflowProcess;
12
import eu.dnetlib.msro.workflows.util.WorkflowsConstants;
13

    
14
/**
15
 * Created by michele on 09/11/15.
16
 */
17
public class ProcessInfo {
18

    
19
	public class ProcessNode {
20

    
21
		private final String id;
22
		private final String name;
23
		private final long startDate;
24
		private final long endDate;
25

    
26
		public ProcessNode(final Token t) {
27
			this.id = t.getId();
28
			this.name = t.getNodeName();
29
			this.startDate = t.getStartDate();
30
			this.endDate = t.getEndDate();
31
		}
32

    
33
		public String getId() {
34
			return this.id;
35
		}
36

    
37
		public String getName() {
38
			return this.name;
39
		}
40

    
41
		public long getStartDate() {
42
			return this.startDate;
43
		}
44

    
45
		public long getEndDate() {
46
			return this.endDate;
47
		}
48

    
49
	}
50

    
51
	private String procId;
52
	private String wfId;
53
	private String name;
54
	private String family;
55
	private String status = "CREATED";
56
	private String datasource;
57
	private long date = Long.MAX_VALUE;
58
	private long startDate = 0;
59
	private long endDate = 0;
60
	private List<EnvParam> outputParams = new ArrayList<>();
61
	private List<ProcessNode> processNodes = new ArrayList<>();
62

    
63
	public ProcessInfo() {}
64

    
65
	public ProcessInfo(final String procId) {
66
		this.procId = procId;
67
	}
68

    
69
	public ProcessInfo(final WorkflowProcess process) {
70
		this.procId = process.getId();
71
		this.wfId = process.getProfileId();
72
		this.name = process.getName();
73
		this.family = process.getFamily();
74
		this.status = process.getStatus().toString();
75
		this.datasource = process.getDsName();
76
		this.date = process.getLastActivityDate();
77
		this.startDate = process.getStartDate();
78
		this.endDate = process.getEndDate();
79

    
80
		process.getTokens().stream().map(t -> new ProcessNode(t)).forEach(this.processNodes::add);
81
	}
82

    
83
	public ProcessInfo(final Map<String, String> logs) {
84
		if (logs == null || logs.isEmpty()) { return; }
85

    
86
		this.procId = logs.get(WorkflowsConstants.LOG_WF_PROCESS_ID);
87
		this.wfId = logs.containsKey(WorkflowsConstants.LOG_WF_PROFILE_ID)
88
				? logs.get(WorkflowsConstants.LOG_WF_PROFILE_ID)
89
				: logs.get(WorkflowsConstants.LOG_WF_PROFILE_TEMPLATE_ID);
90
		this.name = logs.get(WorkflowsConstants.LOG_WF_NAME);
91
		this.family = logs.get(WorkflowsConstants.LOG_WF_FAMILY);
92
		this.status = logs.get(WorkflowsConstants.LOG_WF_PROCESS_STATUS);
93
		this.datasource = logs.get(WorkflowsConstants.LOG_DATASOURCE_NAME);
94
		this.date = NumberUtils.toLong(logs.get(LogMessage.LOG_DATE_FIELD), Long.MAX_VALUE);
95
		this.startDate = NumberUtils.toLong(logs.get(WorkflowsConstants.LOG_WF_PROCESS_START_DATE), Long.MAX_VALUE);
96
		this.endDate = NumberUtils.toLong(logs.get(WorkflowsConstants.LOG_WF_PROCESS_END_DATE), Long.MAX_VALUE);
97

    
98
	}
99

    
100
	public String getProcId() {
101
		return this.procId;
102
	}
103

    
104
	public void setProcId(final String processId) {
105
		this.procId = processId;
106
	}
107

    
108
	public String getWfId() {
109
		return this.wfId;
110
	}
111

    
112
	public void setWfId(final String wfId) {
113
		this.wfId = wfId;
114
	}
115

    
116
	public String getName() {
117
		return this.name;
118
	}
119

    
120
	public void setName(final String name) {
121
		this.name = name;
122
	}
123

    
124
	public String getFamily() {
125
		return this.family;
126
	}
127

    
128
	public void setFamily(final String family) {
129
		this.family = family;
130
	}
131

    
132
	public String getStatus() {
133
		return this.status;
134
	}
135

    
136
	public void setStatus(final String status) {
137
		this.status = status;
138
	}
139

    
140
	public long getStartDate() {
141
		return this.startDate;
142
	}
143

    
144
	public void setStartDate(final long startDate) {
145
		this.startDate = startDate;
146
	}
147

    
148
	public long getEndDate() {
149
		return this.endDate;
150
	}
151

    
152
	public void setEndDate(final long endDate) {
153
		this.endDate = endDate;
154
	}
155

    
156
	public String getDatasource() {
157
		return this.datasource;
158
	}
159

    
160
	public void setDatasource(final String datasource) {
161
		this.datasource = datasource;
162
	}
163

    
164
	public long getDate() {
165
		return this.date;
166
	}
167

    
168
	public void setDate(final long date) {
169
		this.date = date;
170
	}
171

    
172
	public List<EnvParam> getOutputParams() {
173
		return this.outputParams;
174
	}
175

    
176
	public void setOutputParams(final List<EnvParam> outputParams) {
177
		this.outputParams = outputParams;
178
	}
179

    
180
	public List<ProcessNode> getProcessNodes() {
181
		return this.processNodes;
182
	}
183

    
184
	public void setProcessNodes(final List<ProcessNode> processNodes) {
185
		this.processNodes = processNodes;
186
	}
187

    
188
}
(5-5/9)