Project

General

Profile

« Previous | Next » 

Revision 48139

integrated (hopefully) all required changes from dnet40

View differences:

ContextDesc.java
1 1
package eu.dnetlib.msro.openaireplus.workflows.nodes.contexts;
2 2

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

  
7
import com.google.common.collect.Lists;
8
import com.google.common.collect.Maps;
5 9
import org.dom4j.DocumentHelper;
6 10
import org.dom4j.Element;
7 11

  
8
import com.google.common.collect.Maps;
9

  
10 12
public class ContextDesc {
11 13

  
12 14
	private String id;
......
15 17
	private String xml;
16 18
	private Map<String, ContextPart> categories = Maps.newLinkedHashMap();
17 19
	private Map<String, String> dbEntries = Maps.newLinkedHashMap();
20
	private Map<String, String> params;
18 21

  
19
	public ContextDesc(final String id, final String label, final String type) {
22
	public ContextDesc(final String id, final String label, final String type, final Map<String, String> params) {
20 23
		this.id = id;
21 24
		this.label = label;
22 25
		this.type = type;
26
		this.params = params;
23 27
	}
24 28

  
25 29
	public String getId() {
......
75 79
		ctxElem.addAttribute("id", getId());
76 80
		ctxElem.addAttribute("label", getLabel());
77 81
		ctxElem.addAttribute("type", getType());
78

  
82
		for (Element param : getParamsAsElements()) {
83
			ctxElem.add(param);
84
		}
79 85
		for (ContextPart part : getCategories().values()) {
80 86
			ctxElem.add(part.asDomElement("category"));
81 87
		}
......
83 89
		return ctxElem;
84 90
	}
85 91

  
92
	public List<Element> getParamsAsElements() {
93
		List<Element> elements = Lists.newArrayList();
94
		for (Entry<String, String> e : params.entrySet()) {
95
			Element param = DocumentHelper.createElement("param");
96
			param.addAttribute("name", e.getKey());
97
			param.setText(e.getValue());
98
			elements.add(param);
99
		}
100
		return elements;
101
	}
102

  
103
	public Map<String, String> getParams() {
104
		return params;
105
	}
106

  
107
	public void setParams(final Map<String, String> params) {
108
		this.params = params;
109
	}
86 110
}

Also available in: Unified diff