Project

General

Profile

Revision 313a1ad8

ID313a1ad89fe64ff5a9ae565255ef8c0de9eaa515
Parent bba1df64
Child 7fae61bc

Added by Andreas Müller about 7 years ago

latest markup changes

View differences:

.gitattributes
424 424
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/markup/MarkupImportState.java -text
425 425
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/markup/MarkupInputStream.java -text
426 426
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/markup/MarkupKeyImport.java -text
427
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/markup/MarkupModsImport.java -text
427 428
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/markup/MarkupNomenclatureImport.java -text
428 429
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/markup/MarkupSpecimenImport.java -text
429 430
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/markup/MarkupTransformer.java -text
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/markup/MarkupDocumentImportNoComponent.java
79 79
	private MarkupSpecimenImport specimenImport;
80 80

  
81 81
	private MarkupNomenclatureImport nomenclatureImport;
82
	
82
	private MarkupModsImport modsImport;
83

  
83 84
	public MarkupDocumentImportNoComponent(MarkupDocumentImport docImport) {
84 85
		super(docImport);
85 86
		this.keyImport = new MarkupKeyImport(docImport);
86 87
		this.specimenImport = new MarkupSpecimenImport(docImport);
87
		nomenclatureImport = new MarkupNomenclatureImport(docImport, keyImport, specimenImport);
88
		this.nomenclatureImport = new MarkupNomenclatureImport(docImport, keyImport, specimenImport);
89
		this.modsImport = new MarkupModsImport(docImport);
88 90
	}
89 91

  
90 92
	public void doInvoke(MarkupImportState state) throws XMLStreamException { 
......
191 193
					message = String.format(message, baseUrl);
192 194
					fireWarningEvent(message, next, 8);
193 195
				}
194
			} else if (isStartingElement(next, MODS)){
195
				handleNotYetImplementedElement(next);
196
			} else if (isStartingElement(next, MODS)){	
197
				modsImport.handleMods(state, reader, next);
196 198
			} else {
197 199
				handleUnexpectedElement(next);
198 200
			}
......
456 458
		WriterDataHolder writer = handleWriter(state, reader, next);
457 459
		taxon.addExtension(writer.extension);
458 460
		// TODO what if taxonTitle comes later
459
		if (StringUtils.isNotBlank(taxonTitle)
460
				&& writer.extension != null) {
461
		if (StringUtils.isNotBlank(taxonTitle) && writer.extension != null) {
461 462
			Reference<?> sec = ReferenceFactory.newBookSection();
462 463
			sec.setTitle(taxonTitle);
463 464
			TeamOrPersonBase<?> author = createAuthor(writer.writer);
464 465
			sec.setAuthorTeam(author);
465
			sec.setInReference(state.getConfig()
466
					.getSourceReference());
466
			sec.setInReference(state.getConfig().getSourceReference());
467 467
			taxon.setSec(sec);
468 468
			registerFootnotes(state, sec, writer.footnotes);
469 469
		} else {
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/markup/MarkupImportConfigurator.java
38 38
	
39 39
	private boolean allowCapitalSpeciesEpithet = false;  //set to true if you want to allow specific epithets with capital letter at the beginning. This was allowed by the code for epithets referring to persons such as Beilschmiedia Zenkeri.
40 40

  
41
	private boolean handlePagesAsDetailWhereNeeded = true;  //often details in publications and citations are tagged as pages, not as details. If value is true, pages are handled as details where possible 
42

  
43
	private boolean useEditorAsInAuthorWhereNeeded = true;  //often the inAuthor is stored as "Editor" in citations, atleast in FM.
41 44
	
42 45
	//TODO
43 46
	private static IInputTransformer defaultTransformer = null;
......
217 220
		this.allowCapitalSpeciesEpithet = allowCapitalSpeciesEpithet;
218 221
	}
219 222

  
223
	public boolean isHandlePagesAsDetailWhereNeeded() {
224
		return this.handlePagesAsDetailWhereNeeded;
225
	}
226
	
227
	public void setHandlePagesAsDetailWhereNeeded(boolean handlePagesAsDetailWhereNeeded) {
228
		this.handlePagesAsDetailWhereNeeded = handlePagesAsDetailWhereNeeded;
229
	}
230

  
231
	public boolean isUseEditorAsInAuthorWhereNeeded() {
232
		return useEditorAsInAuthorWhereNeeded;
233
	}
234

  
235
	public void setUseEditorAsInAuthorWhereNeeded(boolean useEditorAsInAuthorWhereNeeded) {
236
		this.useEditorAsInAuthorWhereNeeded = useEditorAsInAuthorWhereNeeded;
237
	}
238

  
220 239
	
221 240
}
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/markup/MarkupModsImport.java
1
/**
2
 * Copyright (C) 2009 EDIT
3
 * European Distributed Institute of Taxonomy
4
 * http://www.e-taxonomy.eu
5
 *
6
 * The contents of this file are subject to the Mozilla Public License Version 1.1
7
 * See LICENSE.TXT at the top of this package for the full license terms.
8
 */
9

  
10
package eu.etaxonomy.cdm.io.markup;
11

  
12
import javax.xml.stream.XMLEventReader;
13
import javax.xml.stream.XMLStreamException;
14
import javax.xml.stream.events.XMLEvent;
15

  
16
import org.apache.log4j.Logger;
17

  
18
import eu.etaxonomy.cdm.common.CdmUtils;
19
import eu.etaxonomy.cdm.model.reference.Reference;
20
import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
21

  
22
/**
23
 * @author a.mueller
24
 * @created 30.05.2012
25
 * 
26
 */
27
public class MarkupModsImport extends MarkupImportBase {
28
	@SuppressWarnings("unused")
29
	private static final Logger logger = Logger.getLogger(MarkupModsImport.class);
30

  
31
	protected static final String MODS_TITLEINFO = "titleInfo";
32
	protected static final String MODS_ABSTRACT = "abstract";
33
	protected static final String MODS_TITLE = "title";
34
	protected static final String MODS_SUBTITLE = "subTitle";
35
	protected static final String MODS_PARTNUMBER = "partNumber";
36
	
37
	
38
	public MarkupModsImport(MarkupDocumentImport docImport) {
39
		super(docImport);
40
	}
41

  
42
	public void handleMods(MarkupImportState state, XMLEventReader reader, XMLEvent parentEvent)
43
			throws XMLStreamException {
44
		checkNoAttributes(parentEvent);
45
		
46
		Reference<?> modsRef = ReferenceFactory.newGeneric();
47
		while (reader.hasNext()) {
48
			XMLEvent next = readNoWhitespace(reader);
49
			if (isMyEndingElement(next, parentEvent)) {
50
				//set the source reference
51
				state.getConfig().setSourceReference(modsRef);
52
				return;
53
			}else if (isStartingElement(next, MODS_TITLEINFO)) {
54
				handleTitleInfo(state, reader, next, modsRef);
55
			}else if (isStartingElement(next, MODS_ABSTRACT)) {
56
				String abstractStr = getCData(state, reader, next, true).trim();
57
				if (abstractStr.startsWith("ABSTRACT")){
58
					abstractStr = abstractStr.replaceFirst("ABSTRACT", "").trim();
59
				}
60
				modsRef.setReferenceAbstract(abstractStr);
61
			} else {
62
				fireUnexpectedEvent(next, 0);
63
				state.setUnsuccessfull();
64
			}
65
		}
66
		return;
67
	}
68

  
69
	/**
70
	 * Reads all titleInfo information.
71
	 * ! Preliminary implementation !
72
	 */
73
	private void handleTitleInfo(MarkupImportState state, XMLEventReader reader, XMLEvent parentEvent, Reference<?> modsRef) 
74
			throws XMLStreamException {
75
		checkNoAttributes(parentEvent);
76

  
77
		
78
		String title = null;
79
		String subTitle = null;
80
		String partNumber = null;
81
		
82
		while (reader.hasNext()) {
83
			XMLEvent next = readNoWhitespace(reader);
84
			
85
			if (isMyEndingElement(next, parentEvent)) {
86
				String all = CdmUtils.concat(" - ", title, subTitle);
87
				all = CdmUtils.concat(", ", all, partNumber);
88
				modsRef.setTitle(all);
89
				return;
90
			}else if (isStartingElement(next, MODS_TITLE)) {
91
				title = this.getCData(state, reader, next);
92
			}else if (isStartingElement(next, MODS_SUBTITLE)) {
93
				subTitle = this.getCData(state, reader, next);
94
			}else if (isStartingElement(next, MODS_PARTNUMBER)) {
95
				partNumber = this.getCData(state, reader, next);
96
			} else {
97
				fireUnexpectedEvent(null, 0);
98
				state.setUnsuccessfull();
99
			}
100
		}
101
		return;
102
		
103
	}
104
}

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)