Revision 46345
Added by Alessia Bardi about 7 years ago
modules/dnet-data-provision-services/branches/saxonHE/src/main/java/eu/dnetlib/oai/mongo/MongoPublisherStoreDAO.java | ||
---|---|---|
98 | 98 |
} else { |
99 | 99 |
final MDFInfo info = this.configuration.getMetadataFormatInfo(targetMetadataPrefix); |
100 | 100 |
final MongoPublisherStore store = |
101 |
this.getStore(info.getSourceFormatName(), info.getSourceFormatInterpretation(), info.getSourceFormatLayout(), dbName);
|
|
101 |
this.getStore(info.getSourceFormat(), info.getSourceInterpretation(), info.getSourceLayout(), dbName);
|
|
102 | 102 |
this.mongoOaistoreCacheByMdPrefix.put(new Element(targetMetadataPrefix, store)); |
103 | 103 |
return store; |
104 | 104 |
} |
modules/dnet-data-provision-services/branches/saxonHE/src/main/java/eu/dnetlib/oai/conf/OAIConfiguration.java | ||
---|---|---|
7 | 7 |
import eu.dnetlib.oai.PublisherField; |
8 | 8 |
import eu.dnetlib.oai.info.SetInfo; |
9 | 9 |
import eu.dnetlib.rmi.provision.MDFInfo; |
10 |
import eu.dnetlib.utils.MetadataReference; |
|
10 | 11 |
|
11 | 12 |
/** |
12 | 13 |
* An instance of this class represents an OAI Configuration profile. |
... | ... | |
40 | 41 |
*/ |
41 | 42 |
private String idNamespace; |
42 | 43 |
|
43 |
private Set<MDFInfo> sourcesMDF = new HashSet<>();
|
|
44 |
private Set<MetadataReference> sourcesMDF = new HashSet<>();
|
|
44 | 45 |
|
45 | 46 |
public Collection<PublisherField> getFieldsFor(final String format, final String layout, final String interpretation) { |
46 | 47 |
final String mdRef = Joiner.on("-").join(format, layout, interpretation); |
... | ... | |
83 | 84 |
this.fieldNames = fieldNames; |
84 | 85 |
} |
85 | 86 |
|
86 |
public Set<MDFInfo> getSourcesMDF() {
|
|
87 |
public Set<MetadataReference> getSourcesMDF() {
|
|
87 | 88 |
return sourcesMDF; |
88 | 89 |
} |
89 | 90 |
|
90 |
public void setSourcesMDF(final Set<MDFInfo> sourcesMDF) {
|
|
91 |
public void setSourcesMDF(final Set<MetadataReference> sourcesMDF) {
|
|
91 | 92 |
this.sourcesMDF = sourcesMDF; |
92 | 93 |
} |
93 | 94 |
|
modules/dnet-data-provision-services/branches/saxonHE/src/main/java/eu/dnetlib/oai/conf/OAIConfigurationExistReader.java | ||
---|---|---|
15 | 15 |
import eu.dnetlib.rmi.enabling.ISLookUpException; |
16 | 16 |
import eu.dnetlib.rmi.provision.MDFInfo; |
17 | 17 |
import eu.dnetlib.rmi.provision.OaiPublisherRuntimeException; |
18 |
import eu.dnetlib.utils.MetadataReference; |
|
18 | 19 |
import org.springframework.beans.factory.annotation.Autowired; |
19 | 20 |
|
20 | 21 |
/** |
... | ... | |
107 | 108 |
} |
108 | 109 |
|
109 | 110 |
@Override |
110 |
public List<MDFInfo> getSourceMetadataFormats() {
|
|
111 |
public List<MetadataReference> getSourceMetadataFormats() {
|
|
111 | 112 |
final String query = |
112 | 113 |
"for $x in collection('/db/DRIVER/OAIPublisherConfigurationDSResources/OAIPublisherConfigurationDSResourceType')//CONFIGURATION//METADATAFORMAT " |
113 | 114 |
+ "return concat($x//SOURCE_METADATA_FORMAT/@name/string(), ':-:', $x//SOURCE_METADATA_FORMAT/@layout/string(), ':-:', $x//SOURCE_METADATA_FORMAT/@interpretation/string())"; |
... | ... | |
118 | 119 |
} catch (final ISLookUpException e) { |
119 | 120 |
throw new OaiPublisherRuntimeException(e); |
120 | 121 |
} |
121 |
final Set<MDFInfo> sources = new HashSet<>();
|
|
122 |
final Set<MetadataReference> sources = new HashSet<>();
|
|
122 | 123 |
|
123 | 124 |
res.forEach(src -> { |
124 | 125 |
final String[] splitted = src.split(":-:"); |
125 |
final MDFInfo mdfInfo = new MDFInfo(); |
|
126 |
mdfInfo.setSourceFormatName(splitted[0]); |
|
127 |
mdfInfo.setSourceFormatLayout(splitted[1]); |
|
128 |
mdfInfo.setSourceFormatInterpretation(splitted[2]); |
|
129 |
sources.add(mdfInfo); |
|
126 |
MetadataReference mdref = new MetadataReference(splitted[0],splitted[1],splitted[2] ); |
|
127 |
sources.add(mdref); |
|
130 | 128 |
}); |
131 | 129 |
return sources.stream().collect(Collectors.toList()); |
132 | 130 |
} |
modules/dnet-data-provision-services/branches/saxonHE/src/main/java/eu/dnetlib/oai/conf/OAIConfigurationReader.java | ||
---|---|---|
5 | 5 |
import eu.dnetlib.oai.PublisherField; |
6 | 6 |
import eu.dnetlib.oai.info.SetInfo; |
7 | 7 |
import eu.dnetlib.rmi.provision.MDFInfo; |
8 |
import eu.dnetlib.utils.MetadataReference; |
|
8 | 9 |
|
9 | 10 |
public interface OAIConfigurationReader { |
10 | 11 |
|
... | ... | |
60 | 61 |
*/ |
61 | 62 |
String getIdNamespace(); |
62 | 63 |
|
63 |
List<MDFInfo> getSourceMetadataFormats();
|
|
64 |
List<MetadataReference> getSourceMetadataFormats();
|
|
64 | 65 |
|
65 | 66 |
List<MDFInfo> getFormatsServedBy(String sourceFormatName, String sourceFormatLayout, String sourceFormatInterpretation); |
66 | 67 |
|
modules/dnet-data-provision-services/branches/saxonHE/src/main/java/eu/dnetlib/oai/conf/OAIConfigurationStringReader.java | ||
---|---|---|
9 | 9 |
import eu.dnetlib.oai.info.SetInfo; |
10 | 10 |
import eu.dnetlib.rmi.provision.MDFInfo; |
11 | 11 |
import eu.dnetlib.rmi.provision.OaiPublisherRuntimeException; |
12 |
import eu.dnetlib.utils.MetadataReference; |
|
12 | 13 |
import org.apache.commons.logging.Log; |
13 | 14 |
import org.apache.commons.logging.LogFactory; |
14 | 15 |
import org.springframework.beans.factory.annotation.Autowired; |
... | ... | |
89 | 90 |
} |
90 | 91 |
|
91 | 92 |
@Override |
92 |
public List<MDFInfo> getSourceMetadataFormats() {
|
|
93 |
public List<MetadataReference> getSourceMetadataFormats() {
|
|
93 | 94 |
if (isConfigurationLoaded()) { |
94 | 95 |
return this.oaiConfiguration.getSourcesMDF().stream().collect(Collectors.toList()); |
95 | 96 |
} else { |
... | ... | |
169 | 170 |
public List<MDFInfo> getFormatsServedBy(final String sourceFormatName, final String sourceFormatLayout, final String sourceFormatInterpretation) { |
170 | 171 |
if (isConfigurationLoaded()) { |
171 | 172 |
return this.oaiConfiguration.getMdFormatsMap().values().stream() |
172 |
.filter(mdf -> (mdf.getSourceFormatName() == sourceFormatName) && (mdf.getSourceFormatLayout() == sourceFormatLayout)
|
|
173 |
&& (mdf.getSourceFormatInterpretation() == sourceFormatInterpretation))
|
|
173 |
.filter(mdf -> (mdf.getSourceFormat() == sourceFormatName) && (mdf.getSourceLayout() == sourceFormatLayout)
|
|
174 |
&& (mdf.getSourceInterpretation() == sourceFormatInterpretation)) |
|
174 | 175 |
.collect(Collectors.toList()); |
175 | 176 |
} else { |
176 | 177 |
throw new OaiPublisherRuntimeException("Configuration is not loaded"); |
modules/dnet-data-provision-services/branches/saxonHE/src/main/java/eu/dnetlib/oai/conf/OAIConfigurationParser.java | ||
---|---|---|
6 | 6 |
import java.util.HashMap; |
7 | 7 |
import java.util.List; |
8 | 8 |
import java.util.Map; |
9 |
|
|
10 | 9 |
import javax.xml.stream.XMLInputFactory; |
11 | 10 |
import javax.xml.stream.XMLStreamConstants; |
12 | 11 |
import javax.xml.stream.XMLStreamException; |
13 | 12 |
import javax.xml.stream.XMLStreamReader; |
14 | 13 |
import javax.xml.transform.stream.StreamSource; |
15 | 14 |
|
16 |
import org.apache.commons.logging.Log; |
|
17 |
import org.apache.commons.logging.LogFactory; |
|
18 |
|
|
19 | 15 |
import com.google.common.collect.ArrayListMultimap; |
20 | 16 |
import com.google.common.collect.Multimap; |
21 |
|
|
22 | 17 |
import eu.dnetlib.oai.PublisherField; |
23 | 18 |
import eu.dnetlib.oai.info.SetInfo; |
24 | 19 |
import eu.dnetlib.rmi.provision.MDFInfo; |
25 | 20 |
import eu.dnetlib.rmi.provision.OaiPublisherRuntimeException; |
21 |
import eu.dnetlib.utils.MetadataReference; |
|
22 |
import org.apache.commons.logging.Log; |
|
23 |
import org.apache.commons.logging.LogFactory; |
|
26 | 24 |
|
27 | 25 |
/** |
28 | 26 |
* Parses an XML document representing the OAI configuration profile and creates the corresponding OAIConfiguration object. |
... | ... | |
89 | 87 |
final String mdfElementName = parser.getLocalName(); |
90 | 88 |
if (mdfElementName.equals("SOURCE_METADATA_FORMAT")) { |
91 | 89 |
this.handleSourceMDF(mdfInfo, parser); |
92 |
config.getSourcesMDF().add(mdfInfo); |
|
90 |
config.getSourcesMDF().add(mdfInfo.getSourceMetadataReference());
|
|
93 | 91 |
} else { |
94 | 92 |
final String mdfElementValue = parser.getElementText(); |
95 | 93 |
this.handleMDFInfo(mdfInfo, mdfElementName, mdfElementValue); |
... | ... | |
155 | 153 |
final MDFInfo indexSource = new MDFInfo(); |
156 | 154 |
this.handleSourceMDF(indexSource, parser); |
157 | 155 |
final String key = |
158 |
indexSource.getSourceFormatName() + "-" + indexSource.getSourceFormatLayout() + "-" + indexSource.getSourceFormatInterpretation();
|
|
156 |
indexSource.getSourceFormat() + "-" + indexSource.getSourceLayout() + "-" + indexSource.getSourceInterpretation();
|
|
159 | 157 |
fieldSources.put(key, parser.getAttributeValue(null, "path")); |
160 | 158 |
} else { |
161 | 159 |
log.warn("I do not know how to handle INDEX element with name " + currentLocalName); |
... | ... | |
172 | 170 |
final String interpretation = parser.getAttributeValue(null, "interpretation"); |
173 | 171 |
final String layout = parser.getAttributeValue(null, "layout"); |
174 | 172 |
final String name = parser.getAttributeValue(null, "name"); |
175 |
mdfInfo.setSourceFormatInterpretation(interpretation); |
|
176 |
mdfInfo.setSourceFormatLayout(layout); |
|
177 |
mdfInfo.setSourceFormatName(name); |
|
173 |
MetadataReference mdref = new MetadataReference(name, layout, interpretation); |
|
174 |
mdfInfo.setSourceMetadataReference(mdref); |
|
178 | 175 |
} |
179 | 176 |
|
180 | 177 |
/** |
modules/dnet-data-provision-services/branches/saxonHE/src/main/java/eu/dnetlib/oai/conf/OAIConfigurationWriter.java | ||
---|---|---|
40 | 40 |
final String xUpdate = "update replace //RESOURCE_PROFILE[.//RESOURCE_TYPE/@value='OAIPublisherConfigurationDSResourceType']" |
41 | 41 |
+ "//CONFIGURATION//METADATAFORMAT[./@metadataPrefix/string()='" + mdPrefix + "'] with <METADATAFORMAT exportable=\"" + newInfo.isEnabled() |
42 | 42 |
+ "\" metadataPrefix=\"" + newInfo.getPrefix() + "\">" + "<NAMESPACE>" + newInfo.getNamespace() + "</NAMESPACE><SCHEMA>" + newInfo.getSchema() |
43 |
+ "</SCHEMA><SOURCE_METADATA_FORMAT interpretation=\"" + newInfo.getSourceFormatInterpretation() + "\" layout=\""
|
|
44 |
+ newInfo.getSourceFormatLayout() + "\" name=\"" + newInfo.getSourceFormatName() + "\"/><TRANSFORMATION_RULE>"
|
|
43 |
+ "</SCHEMA><SOURCE_METADATA_FORMAT interpretation=\"" + newInfo.getSourceInterpretation() + "\" layout=\"" |
|
44 |
+ newInfo.getSourceLayout() + "\" name=\"" + newInfo.getSourceFormat() + "\"/><TRANSFORMATION_RULE>"
|
|
45 | 45 |
+ newInfo.getTransformationRuleID() + "</TRANSFORMATION_RULE><BASE_QUERY>" + StringEscapeUtils.escapeXml11(newInfo.getBaseQuery()) |
46 | 46 |
+ "</BASE_QUERY></METADATAFORMAT>"; |
47 | 47 |
return this.execute(xUpdate); |
... | ... | |
52 | 52 |
String action = "update insert "; |
53 | 53 |
String newNode = "<METADATAFORMAT metadataPrefix='" + newInfo.getPrefix() + "' exportable='" + newInfo.isEnabled() + "' ><NAMESPACE>" |
54 | 54 |
+ newInfo.getNamespace() + "</NAMESPACE><SCHEMA>" + newInfo.getSchema() + "</SCHEMA>" + "<SOURCE_METADATA_FORMAT interpretation='" |
55 |
+ newInfo.getSourceFormatInterpretation() + "' layout='" + newInfo.getSourceFormatLayout() + "' name='" + newInfo.getSourceFormatName()
|
|
55 |
+ newInfo.getSourceInterpretation() + "' layout='" + newInfo.getSourceLayout() + "' name='" + newInfo.getSourceFormat()
|
|
56 | 56 |
+ "' /><TRANSFORMATION_RULE>" + newInfo.getTransformationRuleID() + "</TRANSFORMATION_RULE><BASE_QUERY>" |
57 | 57 |
+ StringEscapeUtils.escapeXml11(newInfo.getBaseQuery()) + "</BASE_QUERY></METADATAFORMAT>"; |
58 | 58 |
String targetNode = "//RESOURCE_PROFILE[.//RESOURCE_TYPE/@value='OAIPublisherConfigurationDSResourceType']//CONFIGURATION/METADATAFORMATS"; |
modules/dnet-data-provision-services/branches/saxonHE/src/main/java/eu/dnetlib/oai/core/DNetOAICore.java | ||
---|---|---|
140 | 140 |
} |
141 | 141 |
|
142 | 142 |
protected Cursor getCursor(final String query, final boolean onlyIdentifiers, final MDFInfo mdfInfo) { |
143 |
final PublisherStore<Cursor> store = this.publisherStoreDAO.getStore(mdfInfo.getSourceFormatName(), mdfInfo.getSourceFormatInterpretation(),
|
|
144 |
mdfInfo.getSourceFormatLayout(), getCurrentDBName());
|
|
143 |
final PublisherStore<Cursor> store = this.publisherStoreDAO.getStore(mdfInfo.getSourceFormat(), mdfInfo.getSourceInterpretation(),
|
|
144 |
mdfInfo.getSourceLayout(), getCurrentDBName()); |
|
145 | 145 |
if (store == null) { throw new OaiPublisherRuntimeException( |
146 | 146 |
"Missing store for metadata prefix " + mdfInfo.getPrefix() + ". Please check OAI publisher configuration."); } |
147 | 147 |
Cursor results = null; |
modules/dnet-data-provision-services/branches/saxonHE/src/main/java/eu/dnetlib/oai/utils/OAIHelper.java | ||
---|---|---|
102 | 102 |
} |
103 | 103 |
|
104 | 104 |
private MongoPublisherStore getStore(final MDFInfo mdFormat, final String dbName) { |
105 |
String format = mdFormat.getSourceFormatName();
|
|
106 |
String layout = mdFormat.getSourceFormatLayout();
|
|
107 |
String interpretation = mdFormat.getSourceFormatInterpretation();
|
|
105 |
String format = mdFormat.getSourceFormat(); |
|
106 |
String layout = mdFormat.getSourceLayout(); |
|
107 |
String interpretation = mdFormat.getSourceInterpretation(); |
|
108 | 108 |
String sourceKey = format + "-" + layout + "-" + interpretation; |
109 | 109 |
MongoPublisherStore store = this.mongoPublisherStoreDAO.getStore(format, interpretation, layout, dbName); |
110 | 110 |
log.info("Got OAI store " + sourceKey + " via metadata prefix " + mdFormat.getPrefix() + " on db " + dbName); |
modules/dnet-data-provision-services/branches/saxonHE/src/main/java/eu/dnetlib/oai/OAIStoreServiceImpl.java | ||
---|---|---|
68 | 68 |
|
69 | 69 |
@Override |
70 | 70 |
public void ensureIndexes(final MDFInfo mdfInfo, final String dbName) { |
71 |
final MongoPublisherStore s = this.mongoPublisherStoreDAO.getStore(mdfInfo.getSourceFormatName(), mdfInfo.getSourceFormatInterpretation(),
|
|
72 |
mdfInfo.getSourceFormatLayout(), dbName);
|
|
71 |
final MongoPublisherStore s = this.mongoPublisherStoreDAO.getStore(mdfInfo.getSourceFormat(), mdfInfo.getSourceInterpretation(),
|
|
72 |
mdfInfo.getSourceLayout(), dbName); |
|
73 | 73 |
s.ensureIndices(); |
74 | 74 |
} |
75 | 75 |
|
Also available in: Unified diff
refactoring: let's reuse class MetadataReference