1
|
package eu.dnetlib.data.information.oai.publisher.conf;
|
2
|
|
3
|
import java.util.Collection;
|
4
|
import java.util.List;
|
5
|
import java.util.Map;
|
6
|
import java.util.Set;
|
7
|
import javax.annotation.Nullable;
|
8
|
|
9
|
import com.google.common.base.Function;
|
10
|
import com.google.common.base.Joiner;
|
11
|
import com.google.common.collect.Collections2;
|
12
|
import com.google.common.collect.Multimap;
|
13
|
import com.google.common.collect.Multimaps;
|
14
|
import com.google.common.collect.Sets;
|
15
|
import eu.dnetlib.data.information.oai.publisher.PublisherField;
|
16
|
import eu.dnetlib.data.information.oai.publisher.info.MDFInfo;
|
17
|
import eu.dnetlib.data.information.oai.publisher.info.SetInfo;
|
18
|
|
19
|
/**
|
20
|
* An instance of this class represents an OAI Configuration profile.
|
21
|
*
|
22
|
* @author alessia
|
23
|
*
|
24
|
*/
|
25
|
public class OAIConfiguration {
|
26
|
|
27
|
/**
|
28
|
* Map for OAI sets. Keys: setSpec, values: SetInfo instances.
|
29
|
*/
|
30
|
private Map<String, SetInfo> setsMap;
|
31
|
|
32
|
/**
|
33
|
* Map for metadata formats. Keys: metadata prefix, values: MDFInfo instances.
|
34
|
*/
|
35
|
private Map<String, MDFInfo> mdFormatsMap;
|
36
|
|
37
|
private List<PublisherField> fields;
|
38
|
|
39
|
private List<String> fieldNames;
|
40
|
|
41
|
/**
|
42
|
* Used to generate the OAI identifiers compliant to the protocol. See
|
43
|
* http://www.openarchives.org/OAI/openarchivesprotocol.html#UniqueIdentifier. See property services.oai.publisher.id.scheme.
|
44
|
*/
|
45
|
private String idScheme;
|
46
|
/**
|
47
|
* Used to generate the OAI identifiers compliant to the protocol. See
|
48
|
* http://www.openarchives.org/OAI/openarchivesprotocol.html#UniqueIdentifier. See property services.oai.publisher.id.namespace.
|
49
|
*/
|
50
|
private String idNamespace;
|
51
|
|
52
|
private Set<MDFInfo> sourcesMDF = Sets.newHashSet();
|
53
|
|
54
|
public Collection<PublisherField> getFieldsFor(final String format, final String layout, final String interpretation) {
|
55
|
final String mdRef = Joiner.on("-").join(format, layout, interpretation);
|
56
|
Collection<PublisherField> filtered = Collections2.filter(this.getFields(), theField -> {
|
57
|
if (theField.getSources() == null) return false;
|
58
|
return theField.getSources().containsKey(mdRef);
|
59
|
});
|
60
|
return Collections2.transform(filtered, new Function<PublisherField, PublisherField>() {
|
61
|
@Nullable
|
62
|
@Override
|
63
|
public PublisherField apply(@Nullable final PublisherField publisherField) {
|
64
|
Multimap<String, String> filtered = Multimaps.filterKeys(publisherField.getSources(), k -> k.equalsIgnoreCase(mdRef));
|
65
|
return new PublisherField(publisherField.getFieldName(), publisherField.isRepeatable(), filtered);
|
66
|
}
|
67
|
});
|
68
|
}
|
69
|
|
70
|
public Map<String, SetInfo> getSetsMap() {
|
71
|
return setsMap;
|
72
|
}
|
73
|
|
74
|
public void setSetsMap(final Map<String, SetInfo> setsMap) {
|
75
|
this.setsMap = setsMap;
|
76
|
}
|
77
|
|
78
|
public Map<String, MDFInfo> getMdFormatsMap() {
|
79
|
return mdFormatsMap;
|
80
|
}
|
81
|
|
82
|
public void setMdFormatsMap(final Map<String, MDFInfo> mdFormatsMap) {
|
83
|
this.mdFormatsMap = mdFormatsMap;
|
84
|
}
|
85
|
|
86
|
public List<PublisherField> getFields() {
|
87
|
return fields;
|
88
|
}
|
89
|
|
90
|
public void setFields(final List<PublisherField> fields) {
|
91
|
this.fields = fields;
|
92
|
}
|
93
|
|
94
|
public List<String> getFieldNames() {
|
95
|
return fieldNames;
|
96
|
}
|
97
|
|
98
|
public void setFieldNames(final List<String> fieldNames) {
|
99
|
this.fieldNames = fieldNames;
|
100
|
}
|
101
|
|
102
|
public Set<MDFInfo> getSourcesMDF() {
|
103
|
return sourcesMDF;
|
104
|
}
|
105
|
|
106
|
public void setSourcesMDF(final Set<MDFInfo> sourcesMDF) {
|
107
|
this.sourcesMDF = sourcesMDF;
|
108
|
}
|
109
|
|
110
|
public String getIdScheme() {
|
111
|
return idScheme;
|
112
|
}
|
113
|
|
114
|
public void setIdScheme(final String idScheme) {
|
115
|
this.idScheme = idScheme;
|
116
|
}
|
117
|
|
118
|
public String getIdNamespace() {
|
119
|
return idNamespace;
|
120
|
}
|
121
|
|
122
|
public void setIdNamespace(final String idNamespace) {
|
123
|
this.idNamespace = idNamespace;
|
124
|
}
|
125
|
|
126
|
}
|