Revision a897c436
Added by Andreas Müller almost 6 years ago
cdmlib-ext/src/main/java/eu/etaxonomy/cdm/ext/bci/BciSchemaAdapter.java | ||
---|---|---|
1 | 1 |
/** |
2 | 2 |
* Copyright (C) 2009 EDIT |
3 |
* European Distributed Institute of Taxonomy
|
|
3 |
* European Distributed Institute of Taxonomy |
|
4 | 4 |
* http://www.e-taxonomy.eu |
5 |
*
|
|
5 |
* |
|
6 | 6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
7 | 7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
8 | 8 |
*/ |
... | ... | |
37 | 37 |
* @since 25.08.2010 |
38 | 38 |
*/ |
39 | 39 |
public class BciSchemaAdapter extends SchemaAdapterBase<Reference>{ |
40 |
|
|
40 |
|
|
41 | 41 |
|
42 | 42 |
|
43 | 43 |
static URI identifier = null; |
44 |
|
|
44 |
|
|
45 | 45 |
static String nameSpace = "http://purl.org/dc/elements/1.1/"; |
46 |
|
|
46 |
|
|
47 | 47 |
static { |
48 | 48 |
try { |
49 | 49 |
identifier = new URI("info:srw/schema/1/dc-v1.1"); |
... | ... | |
67 | 67 |
public String getShortName() { |
68 | 68 |
return "dc"; |
69 | 69 |
} |
70 |
|
|
70 |
|
|
71 | 71 |
/* (non-Javadoc) |
72 | 72 |
* @see eu.etaxonomy.cdm.ext.schema.SchemaAdapter#getCmdEntities(java.io.Reader) |
73 | 73 |
*/ |
... | ... | |
85 | 85 |
logger.error(e); |
86 | 86 |
} |
87 | 87 |
|
88 |
|
|
88 |
|
|
89 | 89 |
DcSaxHandler handler = new DcSaxHandler(); |
90 |
|
|
90 |
|
|
91 | 91 |
try { |
92 | 92 |
if(parser != null){ |
93 | 93 |
parser.parse(inputStream, handler); |
... | ... | |
100 | 100 |
logger.error(e); |
101 | 101 |
} |
102 | 102 |
|
103 |
|
|
103 |
|
|
104 | 104 |
return handler.referenceList; |
105 | 105 |
} |
106 |
|
|
106 |
|
|
107 | 107 |
class DcSaxHandler extends DefaultHandler { |
108 |
|
|
108 |
|
|
109 | 109 |
private static final String DC_DC = "dc:dc"; |
110 |
|
|
110 |
|
|
111 | 111 |
private static final String DC_TITLE = "dc:title"; |
112 | 112 |
private static final String DC_CREATOR = "dc:creator"; |
113 | 113 |
private static final String DC_PUBLISHER = "dc:publisher"; |
114 | 114 |
private static final String DC_DATE = "dc:date"; |
115 |
|
|
115 |
|
|
116 | 116 |
List<Reference> referenceList = new ArrayList<Reference>(); |
117 | 117 |
|
118 | 118 |
Reference reference = null; |
119 |
|
|
119 |
|
|
120 | 120 |
String dcFieldName = null; |
121 |
|
|
122 |
|
|
121 |
|
|
122 |
|
|
123 | 123 |
|
124 | 124 |
@Override |
125 |
public void startElement(String uri, String localName,
|
|
125 |
public void startElement(String uri, String localName, |
|
126 | 126 |
String qName, Attributes attributes) throws SAXException { |
127 | 127 |
|
128 | 128 |
if (uri.equals(nameSpace)) { |
129 | 129 |
logger.debug("Start Element :" + qName + "; " + uri); |
130 |
|
|
130 |
|
|
131 | 131 |
if (qName.equals(DC_DC)) { |
132 | 132 |
reference = ReferenceFactory.newGeneric(); |
133 | 133 |
} else { |
... | ... | |
143 | 143 |
if (uri.equals(nameSpace)) { |
144 | 144 |
if(reference != null) { |
145 | 145 |
logger.debug("End Element :" + qName + "; " + uri); |
146 |
|
|
146 |
|
|
147 | 147 |
if (qName.equals(DC_DC)) { |
148 | 148 |
referenceList.add(reference); |
149 | 149 |
reference = null; |
150 | 150 |
} else { |
151 | 151 |
dcFieldName = null; |
152 | 152 |
} |
153 |
}
|
|
153 |
} |
|
154 | 154 |
} |
155 | 155 |
|
156 | 156 |
} |
... | ... | |
176 | 176 |
authorship.setTitleCache(text, true); |
177 | 177 |
reference.setAuthorship(authorship); |
178 | 178 |
} |
179 |
|
|
179 |
|
|
180 | 180 |
} |
181 | 181 |
} |
182 |
|
|
182 |
|
|
183 | 183 |
} |
184 |
|
|
184 |
|
|
185 | 185 |
} |
cdmlib-ext/src/main/java/eu/etaxonomy/cdm/ext/dc/DublinCoreSchemaAdapter.java | ||
---|---|---|
1 | 1 |
/** |
2 | 2 |
* Copyright (C) 2009 EDIT |
3 |
* European Distributed Institute of Taxonomy
|
|
3 |
* European Distributed Institute of Taxonomy |
|
4 | 4 |
* http://www.e-taxonomy.eu |
5 |
*
|
|
5 |
* |
|
6 | 6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
7 | 7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
8 | 8 |
*/ |
... | ... | |
37 | 37 |
* @since 25.08.2010 |
38 | 38 |
*/ |
39 | 39 |
public class DublinCoreSchemaAdapter extends SchemaAdapterBase<Reference>{ |
40 |
|
|
40 |
|
|
41 | 41 |
|
42 | 42 |
|
43 | 43 |
static URI identifier = null; |
44 |
|
|
44 |
|
|
45 | 45 |
static String nameSpace = "http://purl.org/dc/elements/1.1/"; |
46 |
|
|
46 |
|
|
47 | 47 |
static { |
48 | 48 |
try { |
49 | 49 |
identifier = new URI("info:srw/schema/1/dc-v1.1"); |
... | ... | |
67 | 67 |
public String getShortName() { |
68 | 68 |
return "dc"; |
69 | 69 |
} |
70 |
|
|
70 |
|
|
71 | 71 |
/* (non-Javadoc) |
72 | 72 |
* @see eu.etaxonomy.cdm.ext.schema.SchemaAdapter#getCmdEntities(java.io.Reader) |
73 | 73 |
*/ |
... | ... | |
85 | 85 |
logger.error(e); |
86 | 86 |
} |
87 | 87 |
|
88 |
|
|
88 |
|
|
89 | 89 |
DcSaxHandler handler = new DcSaxHandler(); |
90 |
|
|
90 |
|
|
91 | 91 |
try { |
92 | 92 |
if(parser != null){ |
93 | 93 |
parser.parse(inputStream, handler); |
... | ... | |
100 | 100 |
logger.error(e); |
101 | 101 |
} |
102 | 102 |
|
103 |
|
|
103 |
|
|
104 | 104 |
return handler.referenceList; |
105 | 105 |
} |
106 |
|
|
106 |
|
|
107 | 107 |
class DcSaxHandler extends DefaultHandler { |
108 |
|
|
108 |
|
|
109 | 109 |
private static final String DC_DC = "dc:dc"; |
110 |
|
|
110 |
|
|
111 | 111 |
private static final String DC_TITLE = "dc:title"; |
112 | 112 |
private static final String DC_CREATOR = "dc:creator"; |
113 | 113 |
private static final String DC_PUBLISHER = "dc:publisher"; |
114 | 114 |
private static final String DC_DATE = "dc:date"; |
115 | 115 |
private static final String DC_IDENTIFIER = "dc:identifier"; //TODO map this |
116 |
|
|
116 |
|
|
117 | 117 |
List<Reference> referenceList = new ArrayList<Reference>(); |
118 | 118 |
|
119 | 119 |
Reference reference = null; |
120 |
|
|
120 |
|
|
121 | 121 |
String dcFieldName = null; |
122 |
|
|
123 |
|
|
122 |
|
|
123 |
|
|
124 | 124 |
|
125 | 125 |
@Override |
126 |
public void startElement(String uri, String localName,
|
|
126 |
public void startElement(String uri, String localName, |
|
127 | 127 |
String qName, Attributes attributes) throws SAXException { |
128 | 128 |
|
129 | 129 |
if (uri.equals(nameSpace)) { |
130 | 130 |
logger.debug("Start Element :" + qName + "; " + uri); |
131 |
|
|
131 |
|
|
132 | 132 |
if (qName.equals(DC_DC)) { |
133 | 133 |
reference = ReferenceFactory.newGeneric(); |
134 | 134 |
} else { |
... | ... | |
144 | 144 |
if (uri.equals(nameSpace)) { |
145 | 145 |
if(reference != null) { |
146 | 146 |
logger.debug("End Element :" + qName + "; " + uri); |
147 |
|
|
147 |
|
|
148 | 148 |
if (qName.equals(DC_DC)) { |
149 | 149 |
referenceList.add(reference); |
150 | 150 |
reference = null; |
151 | 151 |
} else { |
152 | 152 |
dcFieldName = null; |
153 | 153 |
} |
154 |
}
|
|
154 |
} |
|
155 | 155 |
} |
156 | 156 |
|
157 | 157 |
} |
... | ... | |
177 | 177 |
authorship.setTitleCache(text, true); |
178 | 178 |
reference.setAuthorship(authorship); |
179 | 179 |
} |
180 |
|
|
180 |
|
|
181 | 181 |
} |
182 | 182 |
} |
183 |
|
|
183 |
|
|
184 | 184 |
} |
185 |
|
|
185 |
|
|
186 | 186 |
} |
cdmlib-ext/src/main/java/eu/etaxonomy/cdm/ext/openurl/MobotOpenUrlResponseSchemaAdapter.java | ||
---|---|---|
1 | 1 |
/** |
2 | 2 |
* Copyright (C) 2009 EDIT |
3 |
* European Distributed Institute of Taxonomy
|
|
3 |
* European Distributed Institute of Taxonomy |
|
4 | 4 |
* http://www.e-taxonomy.eu |
5 |
*
|
|
5 |
* |
|
6 | 6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
7 | 7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
8 | 8 |
*/ |
... | ... | |
49 | 49 |
public URI getIdentifier() { |
50 | 50 |
return identifier; |
51 | 51 |
} |
52 |
|
|
52 |
|
|
53 | 53 |
/* (non-Javadoc) |
54 | 54 |
* @see eu.etaxonomy.cdm.ext.schema.SchemaAdapter#getShortName() |
55 | 55 |
*/ |
... | ... | |
57 | 57 |
public String getShortName() { |
58 | 58 |
return "MOBOT.OpenUrl.Utilities.OpenUrlResponse"; |
59 | 59 |
} |
60 |
|
|
60 |
|
|
61 | 61 |
/* (non-Javadoc) |
62 | 62 |
* @see eu.etaxonomy.cdm.ext.schema.SchemaAdapter#getCmdEntities(java.io.Reader) |
63 | 63 |
*/ |
... | ... | |
75 | 75 |
logger.error(e); |
76 | 76 |
} |
77 | 77 |
|
78 |
|
|
78 |
|
|
79 | 79 |
OpenUrlResponseHandler handler = new OpenUrlResponseHandler(); |
80 |
|
|
80 |
|
|
81 | 81 |
try { |
82 | 82 |
if(parser != null){ |
83 | 83 |
Reader reader = new InputStreamReader(inputStream, "UTF-8"); |
... | ... | |
91 | 91 |
} |
92 | 92 |
} catch (SAXException e) { |
93 | 93 |
logger.error(e); |
94 |
} |
|
94 |
} |
|
95 |
|
|
95 | 96 |
|
96 |
|
|
97 | 97 |
return handler.referenceList; |
98 | 98 |
} |
99 |
|
|
99 |
|
|
100 | 100 |
class OpenUrlResponseHandler extends DefaultHandler { |
101 |
|
|
101 |
|
|
102 | 102 |
/* |
103 | 103 |
* Fields of OpenUrlResponse |
104 | 104 |
* see http://code.google.com/p/bhl-bits/source/browse/trunk/portal/OpenUrlUtilities/OpenUrlResponse.cs |
... | ... | |
108 | 108 |
private static final String MESSAGE = "Message"; |
109 | 109 |
private static final String CITATIONS = "citations"; |
110 | 110 |
private static final String OPENURL_RESPONSE_CITATION = "OpenUrlResponseCitation"; |
111 |
|
|
111 |
|
|
112 | 112 |
/* |
113 | 113 |
* Fields of OpenUrlResponseCitation |
114 | 114 |
* see http://code.google.com/p/bhl-bits/source/browse/trunk/portal/OpenUrlUtilities/OpenUrlResponseCitation.cs |
115 | 115 |
*/ |
116 |
|
|
116 |
|
|
117 | 117 |
/** |
118 | 118 |
* references the specific page in the title |
119 | 119 |
*/ |
... | ... | |
149 | 149 |
private static final String SPAGE = "SPage"; |
150 | 150 |
private static final String EPAGE = "EPage"; |
151 | 151 |
private static final String PAGES = "Pages"; |
152 |
|
|
153 |
|
|
152 |
|
|
153 |
|
|
154 | 154 |
List<Reference> referenceList = new ArrayList<Reference>(); |
155 | 155 |
|
156 | 156 |
OpenUrlReference reference = null; |
157 |
|
|
157 |
|
|
158 | 158 |
ResponseStatus status = null; |
159 | 159 |
Team authorship = null; |
160 | 160 |
String message = null; |
161 |
|
|
161 |
|
|
162 | 162 |
String elementName = null; |
163 | 163 |
private String elementNameToStore; |
164 | 164 |
private StringBuilder textBuffer = new StringBuilder(); |
165 |
|
|
165 |
|
|
166 | 166 |
|
167 | 167 |
@Override |
168 |
public void startElement(String uri, String localName,
|
|
168 |
public void startElement(String uri, String localName, |
|
169 | 169 |
String qName, Attributes attributes) throws SAXException { |
170 | 170 |
|
171 | 171 |
if (qName.equals(OPENURL_RESPONSE)) { |
... | ... | |
176 | 176 |
} else if (reference != null && qName.equals(AUTHORS)) { |
177 | 177 |
authorship = Team.NewInstance(); |
178 | 178 |
} else if (reference != null && qName.equals(SUBJECTS)) { |
179 |
//TODO implement, but no equivalent in the cdm model
|
|
179 |
//TODO implement, but no equivalent in the cdm model |
|
180 | 180 |
} else { |
181 | 181 |
elementName = qName; |
182 | 182 |
} |
... | ... | |
186 | 186 |
public void endElement(String uri, String localName, String qName) throws SAXException { |
187 | 187 |
|
188 | 188 |
if (qName.equals(OPENURL_RESPONSE)) { |
189 |
|
|
189 |
|
|
190 | 190 |
} else if (qName.equals(OPENURL_RESPONSE_CITATION)) { |
191 | 191 |
referenceList.add(reference); |
192 | 192 |
reference = null; |
... | ... | |
194 | 194 |
reference.setAuthorship(authorship); |
195 | 195 |
authorship = null; |
196 | 196 |
} else if (reference != null && qName.equals(SUBJECTS)) { |
197 |
//TODO implement, but no equivalent in the cdm model
|
|
197 |
//TODO implement, but no equivalent in the cdm model |
|
198 | 198 |
}else { |
199 | 199 |
elementNameToStore = elementName; |
200 | 200 |
elementName = null; |
... | ... | |
205 | 205 |
@Override |
206 | 206 |
public void characters(char ch[], int start, int length) |
207 | 207 |
throws SAXException { |
208 |
|
|
208 |
|
|
209 | 209 |
if(elementNameToStore == null){ |
210 |
|
|
210 |
|
|
211 | 211 |
textBuffer.append(new String(ch, start, length)); |
212 |
|
|
212 |
|
|
213 | 213 |
} else { |
214 |
|
|
214 |
|
|
215 | 215 |
logger.debug("Characters [" + elementNameToStore + "]: " + textBuffer); |
216 | 216 |
String trimmedText = textBuffer.toString().trim(); |
217 | 217 |
// empty the text buffer |
218 | 218 |
textBuffer.delete(0, textBuffer.length()); |
219 |
|
|
220 |
// --- Reference --- //
|
|
219 |
|
|
220 |
// --- Reference --- // |
|
221 | 221 |
if(reference != null){ |
222 |
|
|
222 |
|
|
223 | 223 |
if(elementNameToStore.equals(URL)){ |
224 | 224 |
try { |
225 | 225 |
reference.setUri(new URI(trimmedText)); |
... | ... | |
308 | 308 |
reference.setIssn(trimmedText); |
309 | 309 |
} |
310 | 310 |
} |
311 |
|
|
311 |
|
|
312 | 312 |
// --- Reference.authorship --- // |
313 | 313 |
if(authorship != null && reference != null){ |
314 | 314 |
if(elementNameToStore.equals("String")){ |
315 | 315 |
authorship.addTeamMember(Person.NewTitledInstance(trimmedText)); |
316 | 316 |
} |
317 | 317 |
} |
318 |
|
|
319 |
// openUrlResponse //
|
|
318 |
|
|
319 |
// openUrlResponse // |
|
320 | 320 |
if(reference == null){ |
321 | 321 |
if(elementNameToStore.equals(STATUS)){ |
322 | 322 |
status = ResponseStatus.valueOf(trimmedText); |
... | ... | |
326 | 326 |
elementNameToStore = null; |
327 | 327 |
} |
328 | 328 |
} |
329 |
|
|
329 |
|
|
330 | 330 |
} |
331 |
|
|
331 |
|
|
332 | 332 |
/** |
333 | 333 |
* @see http://code.google.com/p/bhl-bits/source/browse/trunk/portal/OpenUrlUtilities/IOpenUrlResponse.cs |
334 | 334 |
*/ |
... | ... | |
337 | 337 |
Success, Error |
338 | 338 |
} |
339 | 339 |
|
340 |
|
|
340 |
|
|
341 | 341 |
} |
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/dwca/in/GbifReferenceCsv2CdmConverter.java | ||
---|---|---|
103 | 103 |
Reference inRef = handleInRef(strSource); |
104 | 104 |
if (inRef != null){ |
105 | 105 |
reference.setInReference(inRef); |
106 |
resultList.add(new MappedCdmBase<CdmBase>(inRef));
|
|
106 |
resultList.add(new MappedCdmBase<>(inRef)); |
|
107 | 107 |
} |
108 | 108 |
|
109 | 109 |
//URI |
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/tcsxml/DefaultTcsXmlPlaceholders.java | ||
---|---|---|
1 | 1 |
/** |
2 | 2 |
* Copyright (C) 2007 EDIT |
3 |
* European Distributed Institute of Taxonomy
|
|
3 |
* European Distributed Institute of Taxonomy |
|
4 | 4 |
* http://www.e-taxonomy.eu |
5 |
*
|
|
5 |
* |
|
6 | 6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
7 | 7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
8 | 8 |
*/ |
... | ... | |
26 | 26 |
*/ |
27 | 27 |
public class DefaultTcsXmlPlaceholders implements ITcsXmlPlaceholderClass { |
28 | 28 |
private static final Logger logger = Logger.getLogger(DefaultTcsXmlPlaceholders.class); |
29 |
|
|
29 |
|
|
30 | 30 |
/* (non-Javadoc) |
31 | 31 |
* @see tcsxml.ITcsXmlPlaceholderClass#makeMetaDataDetailed(tcsxml.TcsXmlImportConfigurator, org.jdom.Element) |
32 | 32 |
*/ |
33 |
public boolean makeMetaDataDetailed(TcsXmlImportConfigurator tcsConfig, Element elMetaDataDetailed){ |
|
33 |
@Override |
|
34 |
public boolean makeMetaDataDetailed(TcsXmlImportConfigurator tcsConfig, Element elMetaDataDetailed){ |
|
34 | 35 |
if (tcsConfig == null){ |
35 | 36 |
return false; |
36 | 37 |
} |
37 | 38 |
if (elMetaDataDetailed == null){ |
38 | 39 |
return true; |
39 | 40 |
} |
40 |
|
|
41 |
|
|
41 | 42 |
//Do nothing |
42 | 43 |
//TODO implement EDIT TcsMetaData extension |
43 | 44 |
logger.info("MetaDataElement found: " + elMetaDataDetailed.getName()); |
... | ... | |
47 | 48 |
/* (non-Javadoc) |
48 | 49 |
* @see tcsxml.ITcsXmlPlaceholderClass#makePublicationDetailed(tcsxml.TcsXmlImportConfigurator, org.jdom.Element, eu.etaxonomy.cdm.model.reference.Reference) |
49 | 50 |
*/ |
50 |
public boolean makePublicationDetailed(TcsXmlImportConfigurator config, Element elPublicationDetailed, Reference publication){ |
|
51 |
@Override |
|
52 |
public boolean makePublicationDetailed(TcsXmlImportConfigurator config, Element elPublicationDetailed, Reference publication){ |
|
51 | 53 |
ResultWrapper<Boolean> success = ResultWrapper.NewInstance(true); |
52 | 54 |
if (config == null){ |
53 | 55 |
return false; |
... | ... | |
57 | 59 |
}else{ |
58 | 60 |
publication.setProtectedTitleCache(false); |
59 | 61 |
} |
60 |
|
|
62 |
|
|
61 | 63 |
String childName; |
62 | 64 |
Namespace tcsNs = config.getTcsXmlNamespace(); |
63 | 65 |
for (Object o : elPublicationDetailed.getChildren()){ |
64 | 66 |
Element element = (Element)o; |
65 | 67 |
String value = element.getTextNormalize(); |
66 |
|
|
68 |
|
|
67 | 69 |
childName = "Title"; |
68 | 70 |
if (element.getName().equalsIgnoreCase(childName) && element.getNamespace().equals(tcsNs)){ |
69 | 71 |
publication.setTitle(value); |
... | ... | |
76 | 78 |
publication.setDatePublished(datePublished); |
77 | 79 |
continue; |
78 | 80 |
} |
79 |
|
|
81 |
|
|
80 | 82 |
logger.warn("Unhandled Publication Detailed child element: " + element.getName()); |
81 |
|
|
83 |
|
|
82 | 84 |
} |
83 | 85 |
// String childName = "Title"; |
84 | 86 |
// boolean obligatory = false; |
... | ... | |
97 | 99 |
// TimePeriod datePublished = TimePeriodParser.parseString(strDatePublished); |
98 | 100 |
// publication.setDatePublished(datePublished); |
99 | 101 |
// } |
100 |
|
|
102 |
|
|
101 | 103 |
//Do nothing |
102 | 104 |
//TODO implement EDIT TcsMetaData extension |
103 | 105 |
if (logger.isDebugEnabled()){logger.debug("PublicationDetailed element found: " + elPublicationDetailed.getName());} |
104 | 106 |
return success.getValue(); |
105 | 107 |
} |
106 |
|
|
107 |
|
|
108 |
|
|
109 |
|
|
108 |
|
|
109 |
|
|
110 |
|
|
111 |
|
|
110 | 112 |
|
111 | 113 |
} |
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/taxon/Taxon.java | ||
---|---|---|
810 | 810 |
} |
811 | 811 |
|
812 | 812 |
/** |
813 |
* Counts the number of misapplied name relationships (including pro parte misapplied
|
|
814 |
* names) where this taxon represents the |
|
813 |
* Counts the number of misapplied name relationships (including pro parte and partial
|
|
814 |
* misapplied names) where this taxon represents the
|
|
815 | 815 |
* misapplied name for another taxon. |
816 | 816 |
* @return |
817 | 817 |
*/ |
Also available in: Unified diff
cleanup