1 |
26600
|
sandro.lab
|
package eu.dnetlib.functionality.modular.ui.workflows.objects;
|
2 |
|
|
|
3 |
|
|
import java.util.Comparator;
|
4 |
|
|
import java.util.Date;
|
5 |
|
|
import java.util.List;
|
6 |
|
|
import java.util.Map;
|
7 |
|
|
|
8 |
|
|
import com.google.common.collect.Lists;
|
9 |
|
|
import com.google.common.collect.Maps;
|
10 |
|
|
import com.googlecode.sarasvati.NodeToken;
|
11 |
|
|
|
12 |
|
|
import java.util.Collections;
|
13 |
|
|
|
14 |
|
|
public class NodeTokenInfo {
|
15 |
|
|
|
16 |
|
|
public class EnvParam {
|
17 |
|
|
private String name;
|
18 |
|
|
private String value;
|
19 |
|
|
|
20 |
|
|
public EnvParam(String name, String value) {
|
21 |
|
|
this.name = name;
|
22 |
|
|
this.value = value;
|
23 |
|
|
}
|
24 |
|
|
|
25 |
|
|
public String getName() {
|
26 |
|
|
return name;
|
27 |
|
|
}
|
28 |
|
|
public String getValue() {
|
29 |
|
|
return value;
|
30 |
|
|
}
|
31 |
|
|
}
|
32 |
|
|
|
33 |
|
|
private String name;
|
34 |
|
|
private String start;
|
35 |
|
|
private String end;
|
36 |
|
|
private List<EnvParam> params;
|
37 |
|
|
|
38 |
|
|
public NodeTokenInfo(final String name) {
|
39 |
|
|
super();
|
40 |
|
|
this.name = name;
|
41 |
|
|
this.start = "-";
|
42 |
|
|
this.end = "-";
|
43 |
|
|
this.params = Lists.newArrayList();
|
44 |
|
|
}
|
45 |
|
|
|
46 |
|
|
public NodeTokenInfo(final NodeToken token) {
|
47 |
|
|
super();
|
48 |
|
|
|
49 |
|
|
final Date start = token.getCreateDate();
|
50 |
|
|
final Date end = token.getCompleteDate();
|
51 |
|
|
|
52 |
|
|
this.name = token.getNode().getName();
|
53 |
|
|
this.start = (start == null) ? "-" : start.toString();
|
54 |
|
|
this.end = (end == null) ? "-" : end.toString();
|
55 |
|
|
|
56 |
|
|
|
57 |
|
|
|
58 |
|
|
final Map<String, EnvParam> map = Maps.newHashMap();
|
59 |
|
|
for (String name : token.getFullEnv().getAttributeNames()) {
|
60 |
|
|
map.put(name, new EnvParam(name, token.getFullEnv().getAttribute(name)));
|
61 |
|
|
}
|
62 |
|
|
for (String name : token.getEnv().getAttributeNames()) {
|
63 |
|
|
map.put(name, new EnvParam(name, token.getEnv().getAttribute(name)));
|
64 |
|
|
}
|
65 |
|
|
|
66 |
|
|
this.params = Lists.newArrayList(map.values());
|
67 |
|
|
|
68 |
|
|
Collections.sort(this.params, new Comparator<EnvParam>() {
|
69 |
|
|
@Override
|
70 |
|
|
public int compare(EnvParam o1, EnvParam o2) {
|
71 |
|
|
return o1.getName().compareTo(o2.getName());
|
72 |
|
|
}
|
73 |
|
|
});
|
74 |
|
|
}
|
75 |
|
|
|
76 |
|
|
public String getName() {
|
77 |
|
|
return name;
|
78 |
|
|
}
|
79 |
|
|
public String getStart() {
|
80 |
|
|
return start;
|
81 |
|
|
}
|
82 |
|
|
public String getEnd() {
|
83 |
|
|
return end;
|
84 |
|
|
}
|
85 |
|
|
public List<EnvParam> getParams() {
|
86 |
|
|
return params;
|
87 |
|
|
}
|
88 |
|
|
}
|