1
|
/**
|
2
|
* Copyright (C) 2007 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.tcsxml;
|
11
|
|
12
|
import org.apache.log4j.Logger;
|
13
|
import org.jdom.Element;
|
14
|
import org.jdom.Namespace;
|
15
|
|
16
|
import eu.etaxonomy.cdm.common.ResultWrapper;
|
17
|
import eu.etaxonomy.cdm.common.XmlHelp;
|
18
|
import eu.etaxonomy.cdm.io.tcsxml.in.TcsXmlImportConfigurator;
|
19
|
import eu.etaxonomy.cdm.model.common.TimePeriod;
|
20
|
import eu.etaxonomy.cdm.model.reference.ReferenceBase;
|
21
|
|
22
|
/**
|
23
|
* @author a.mueller
|
24
|
* @created 30.10.2008
|
25
|
* @version 1.0
|
26
|
*/
|
27
|
public class DefaultTcsXmlPlaceholders implements ITcsXmlPlaceholderClass {
|
28
|
private static final Logger logger = Logger.getLogger(DefaultTcsXmlPlaceholders.class);
|
29
|
|
30
|
/* (non-Javadoc)
|
31
|
* @see tcsxml.ITcsXmlPlaceholderClass#makeMetaDataDetailed(tcsxml.TcsXmlImportConfigurator, org.jdom.Element)
|
32
|
*/
|
33
|
public boolean makeMetaDataDetailed(TcsXmlImportConfigurator tcsConfig, Element elMetaDataDetailed){
|
34
|
if (tcsConfig == null){
|
35
|
return false;
|
36
|
}
|
37
|
if (elMetaDataDetailed == null){
|
38
|
return true;
|
39
|
}
|
40
|
|
41
|
//Do nothing
|
42
|
//TODO implement EDIT TcsMetaData extension
|
43
|
logger.info("MetaDataElement found: " + elMetaDataDetailed.getName());
|
44
|
return true;
|
45
|
}
|
46
|
|
47
|
/* (non-Javadoc)
|
48
|
* @see tcsxml.ITcsXmlPlaceholderClass#makePublicationDetailed(tcsxml.TcsXmlImportConfigurator, org.jdom.Element, eu.etaxonomy.cdm.model.reference.ReferenceBase)
|
49
|
*/
|
50
|
public boolean makePublicationDetailed(TcsXmlImportConfigurator config, Element elPublicationDetailed, ReferenceBase publication){
|
51
|
ResultWrapper<Boolean> success = ResultWrapper.NewInstance(true);
|
52
|
if (config == null){
|
53
|
return false;
|
54
|
}
|
55
|
if (elPublicationDetailed == null){
|
56
|
return true;
|
57
|
}else{
|
58
|
publication.setProtectedTitleCache(false);
|
59
|
}
|
60
|
|
61
|
String childName;
|
62
|
Namespace tcsNs = config.getTcsXmlNamespace();
|
63
|
for (Object o : elPublicationDetailed.getChildren()){
|
64
|
Element element = (Element)o;
|
65
|
String value = element.getTextNormalize();
|
66
|
|
67
|
childName = "Title";
|
68
|
if (element.getName().equalsIgnoreCase(childName) && element.getNamespace().equals(tcsNs)){
|
69
|
publication.setTitle(value);
|
70
|
continue;
|
71
|
}
|
72
|
|
73
|
childName = "DatePublished";
|
74
|
if (element.getName().equalsIgnoreCase(childName) && element.getNamespace().equals(tcsNs)){
|
75
|
TimePeriod datePublished = TimePeriod.parseString(value);
|
76
|
publication.setDatePublished(datePublished);
|
77
|
continue;
|
78
|
}
|
79
|
|
80
|
logger.warn("Unhandled Publication Detailed child element: " + element.getName());
|
81
|
|
82
|
}
|
83
|
// String childName = "Title";
|
84
|
// boolean obligatory = false;
|
85
|
// Element elTitle = XmlHelp.getSingleChildElement(success, elPublicationDetailed, childName, ns, obligatory);
|
86
|
// if (elTitle != null){
|
87
|
// String strTitle = elTitle.getTextNormalize();
|
88
|
// publication.setTitle(strTitle);
|
89
|
// }
|
90
|
|
91
|
// childName = "DatePublished";
|
92
|
// obligatory = false;
|
93
|
// ns = config.getTcsXmlNamespace();
|
94
|
// Element elDatePublished = XmlHelp.getSingleChildElement(success, elPublicationDetailed, childName, ns, obligatory);
|
95
|
// if (elDatePublished != null){
|
96
|
// String strDatePublished = elDatePublished.getTextNormalize();
|
97
|
// TimePeriod datePublished = TimePeriod.parseString(strDatePublished);
|
98
|
// publication.setDatePublished(datePublished);
|
99
|
// }
|
100
|
|
101
|
//Do nothing
|
102
|
//TODO implement EDIT TcsMetaData extension
|
103
|
if (logger.isDebugEnabled()){logger.debug("PublicationDetailed element found: " + elPublicationDetailed.getName());}
|
104
|
return success.getValue();
|
105
|
}
|
106
|
|
107
|
|
108
|
|
109
|
|
110
|
|
111
|
}
|