Project

General

Profile

« Previous | Next » 

Revision 45479

More logs for debug

View differences:

PublisherRecordParser.java
8 8
import com.google.common.collect.Iterables;
9 9
import com.google.common.collect.Multimap;
10 10
import eu.dnetlib.oai.PublisherField;
11
import eu.dnetlib.oai.conf.OAIConfigurationExistReader;
12
import org.apache.commons.lang3.StringUtils;
11 13
import org.apache.commons.logging.Log;
12 14
import org.apache.commons.logging.LogFactory;
13 15
import org.dom4j.Document;
......
37 39
	 *
38 40
	 * @param record
39 41
	 *            the XML string to parse.
42
	 * @param source
43
	 *             String identifying the source of the record. Can be null.
40 44
	 * @return a Multimap describing the values to be indexed for this record.
41 45
	 */
42 46
	@SuppressWarnings({ "unchecked", "rawtypes" })
43
	public Multimap<String, String> parseRecord(final String record) {
47
	public Multimap<String, String> parseRecord(final String record, final String source) {
44 48
		Multimap<String, String> recordProps = ArrayListMultimap.create();
45 49
		try {
46 50
			Document doc = this.saxReader.read(new StringReader(record));
51
			if(StringUtils.isNotBlank(source)) recordProps.put(OAIConfigurationExistReader.SET_FIELD, source);
47 52
			for (PublisherField field : this.storeIndices) {
48 53
				for (Entry<String, String> indexEntry : field.getSources().entries()) {
49 54
					// each xpath can return a list of nodes or strings, depending on the xpath
......
53 58
							recordProps.putAll(field.getFieldName(), xPathResult);
54 59
						} else {
55 60
							if (containsNodes(xPathResult)) {
61

  
56 62
								recordProps.putAll(field.getFieldName(), Iterables.transform(xPathResult, obj -> {
57 63
									if (obj == null) return "";
58 64
									Node node = (Node) obj;
......
69 75
			recordProps = null;
70 76
		}
71 77
		return recordProps;
72

  
73 78
	}
74 79

  
75 80
	@SuppressWarnings("rawtypes")
......
97 102
	}
98 103

  
99 104
	public PublisherRecordParser(final List<PublisherField> storeIndices) {
100
		super();
101 105
		this.storeIndices = storeIndices;
102 106
	}
103 107

  

Also available in: Unified diff