Project

General

Profile

1
package eu.dnetlib.data.mapreduce.hbase.oai.utils;
2

    
3
import java.util.Map.Entry;
4

    
5
import com.google.common.collect.Multimap;
6

    
7
/**
8
 * Instances of this class represent fields to be explicitely managed by the OAI Publisher, for example for indexing purposes.
9
 * 
10
 * @author alessia
11
 * 
12
 */
13
public class PublisherField {
14

    
15
	/**
16
	 * Name of the field.
17
	 */
18
	private String fieldName;
19
	/**
20
	 * True if the value of the field is a list (i.e. repeatable values). False otherwise.
21
	 **/
22
	private boolean repeatable;
23
	/**
24
	 * Information about where to take values for this field.
25
	 * <p>
26
	 * Keys are metadata format: name-layout-interpretation; values are xpaths.
27
	 * </p>
28
	 */
29
	private Multimap<String, String> sources;
30

    
31
	public String getFieldName() {
32
		return fieldName;
33
	}
34

    
35
	public void setFieldName(final String fieldName) {
36
		this.fieldName = fieldName;
37
	}
38

    
39
	public boolean isRepeatable() {
40
		return repeatable;
41
	}
42

    
43
	public void setRepeatable(final boolean repeatable) {
44
		this.repeatable = repeatable;
45
	}
46

    
47
	public Multimap<String, String> getSources() {
48
		return sources;
49
	}
50

    
51
	public void setSources(final Multimap<String, String> sources) {
52
		this.sources = sources;
53
	}
54

    
55
	public PublisherField() {
56
		super();
57
		// TODO Auto-generated constructor stub
58
	}
59

    
60
	public PublisherField(final String fieldName, final boolean repeatable, final Multimap<String, String> sources) {
61
		super();
62
		this.fieldName = fieldName;
63
		this.repeatable = repeatable;
64
		this.sources = sources;
65
	}
66

    
67
	@Override
68
	public String toString() {
69
		StringBuilder sb = new StringBuilder();
70
		sb.append("fieldname: " + getFieldName() + "\n");
71
		sb.append("repeatible: " + isRepeatable() + "\n");
72
		sb.append("sources { ");
73
		for (Entry<String, String> e : getSources().entries()) {
74
			sb.append("\n\t" + e.getKey() + ":" + e.getValue() + "\n");
75
		}
76
		sb.append("}");
77
		return sb.toString();
78
		// Gson gson = new GsonBuilder().setPrettyPrinting().create();
79
		// return gson.toJson(this);
80
	}
81
}
(4-4/7)