Project

General

Profile

« Previous | Next » 

Revision 43245

moved MetadataReference class in common package, it will be used by both index service and oai store service

View differences:

SyncAction.java
8 8
import eu.dnetlib.oai.sync.OAIStoreSynchronizer;
9 9
import eu.dnetlib.rmi.common.ResultSet;
10 10
import eu.dnetlib.rmi.provision.MDFInfo;
11
import eu.dnetlib.utils.MetadataReference;
12
import eu.dnetlib.utils.MetadataReferenceFactory;
11 13
import org.apache.commons.logging.Log;
12 14
import org.apache.commons.logging.LogFactory;
13 15
import org.dom4j.io.SAXReader;
......
28 30
	public void execute(final BlackboardServerHandler handler, final BlackboardJob job) throws Exception {
29 31
		String epr = job.getParameters().get("oai_syncEpr");
30 32
		String recordSource = job.getParameters().get("oai_recordSource");
31
		String formatName = job.getParameters().get("oai_formatName");
32
		String formatLayout = job.getParameters().get("oai_formatLayout");
33
		String formatInterpretation = job.getParameters().get("oai_formatInterpretation");
34 33
		boolean alwaysNewRecord = Boolean.valueOf(job.getParameters().get("oai_alwaysNewRecord"));
35 34
		final String dbName = job.getParameters().get("oai_dbName");
36
		MDFInfo mdf = new MDFInfo("", "", "", formatName, formatLayout, formatInterpretation, "", true);
37 35

  
38
		ResultSet<?> resutlSet = ResultSet.fromJson(epr);
39
		log.info("Syncronizing content for oai on db " + dbName + "for metadata format: " + mdf);
40
		Iterable<String> records = resultSetClient.iter(resutlSet, String.class);
36
		final String collectionName = job.getParameters().get("oai_collectionName");
37
		final MetadataReference mdRef = MetadataReferenceFactory.decode(collectionName, MDREF_SEPARATOR);
38

  
39
		final ResultSet<?> rs = ResultSet.fromJson(epr);
40
		log.info("Syncronizing content for oai on db " + dbName + "for metadata format: " + mdRef);
41
		Iterable<String> records = resultSetClient.iter(rs, String.class);
41 42
		// in case of DMF there is no "hat element" after oai:metadata: we must add it or the OAI-PMH export will only contain the first
42 43
		// element inside oai:metadata.
43
		if (formatName.equalsIgnoreCase("DMF")) {
44
		if (mdRef.getFormat().equalsIgnoreCase("DMF")) {
44 45
			records = addDMFBlock(records);
45 46
		}
46
		this.synchronizer.synchronize(records, mdf, recordSource, dbName, alwaysNewRecord, () -> {
47
		this.synchronizer.synchronize(records, mdRef, recordSource, dbName, alwaysNewRecord, () -> {
47 48
			handler.done(job);
48 49
			return null;
49 50
		}, () -> {

Also available in: Unified diff