Revision 02153b5c
Added by Andreas Müller over 11 years ago
app-import/src/main/java/eu/etaxonomy/cdm/io/globis/GlobisCurrentSpeciesImport.java | ||
---|---|---|
304 | 304 |
} |
305 | 305 |
|
306 | 306 |
private void handleCommonNames(GlobisImportState state, ResultSet rs, Taxon species) throws SQLException { |
307 |
String commonNamesStr = rs.getString("vernacularnames"); |
|
308 |
if (isBlank(commonNamesStr)){ |
|
309 |
return; |
|
310 |
} |
|
311 |
String[] commonNamesSplit = commonNamesStr.split(";"); |
|
312 |
for (String commonNameStr : commonNamesSplit){ |
|
313 |
if (isBlank(commonNameStr)){ |
|
314 |
continue; |
|
315 |
} |
|
316 |
Language language = null; //TODO |
|
317 |
CommonTaxonName commonName = CommonTaxonName.NewInstance(commonNameStr, language); |
|
318 |
TaxonDescription desc = getTaxonDescription(species, state.getTransactionalSourceReference(), false, true); |
|
319 |
desc.addElement(commonName); |
|
320 |
} |
|
307 |
//DON't use, use seperate common name tables instead |
|
308 |
|
|
309 |
// String commonNamesStr = rs.getString("vernacularnames"); |
|
310 |
// if (isBlank(commonNamesStr)){ |
|
311 |
// return; |
|
312 |
// } |
|
313 |
// String[] commonNamesSplit = commonNamesStr.split(";"); |
|
314 |
// for (String commonNameStr : commonNamesSplit){ |
|
315 |
// if (isBlank(commonNameStr)){ |
|
316 |
// continue; |
|
317 |
// } |
|
318 |
// Language language = null; //TODO |
|
319 |
// CommonTaxonName commonName = CommonTaxonName.NewInstance(commonNameStr, language); |
|
320 |
// TaxonDescription desc = getTaxonDescription(species, state.getTransactionalSourceReference(), false, true); |
|
321 |
// desc.addElement(commonName); |
|
322 |
// } |
|
321 | 323 |
} |
322 | 324 |
|
323 | 325 |
|
app-import/src/main/java/eu/etaxonomy/cdm/io/globis/GlobisImageImport.java | ||
---|---|---|
9 | 9 |
|
10 | 10 |
package eu.etaxonomy.cdm.io.globis; |
11 | 11 |
|
12 |
import java.net.MalformedURLException; |
|
13 |
import java.net.URI; |
|
12 | 14 |
import java.sql.ResultSet; |
13 | 15 |
import java.sql.SQLException; |
14 | 16 |
import java.util.HashMap; |
... | ... | |
20 | 22 |
import org.apache.log4j.Logger; |
21 | 23 |
import org.springframework.stereotype.Component; |
22 | 24 |
|
25 |
import eu.etaxonomy.cdm.common.media.ImageInfo; |
|
23 | 26 |
import eu.etaxonomy.cdm.io.common.IOValidator; |
24 | 27 |
import eu.etaxonomy.cdm.io.common.ResultSetPartitioner; |
25 | 28 |
import eu.etaxonomy.cdm.io.globis.validation.GlobisCurrentSpeciesImportValidator; |
... | ... | |
97 | 100 |
public boolean doPartition(ResultSetPartitioner partitioner, GlobisImportState state) { |
98 | 101 |
boolean success = true; |
99 | 102 |
|
100 |
Set<TaxonBase> objectsToSave = new HashSet<TaxonBase>();
|
|
103 |
Set<Media> objectsToSave = new HashSet<Media>();
|
|
101 | 104 |
|
102 |
Map<String, Taxon> taxonMap = (Map<String, Taxon>) partitioner.getObjectMap(TAXON_NAMESPACE); |
|
105 |
// Map<String, Taxon> taxonMap = (Map<String, Taxon>) partitioner.getObjectMap(TAXON_NAMESPACE);
|
|
103 | 106 |
// Map<String, DerivedUnit> ecoFactDerivedUnitMap = (Map<String, DerivedUnit>) partitioner.getObjectMap(ECO_FACT_DERIVED_UNIT_NAMESPACE); |
104 | 107 |
|
105 | 108 |
ResultSet rs = partitioner.getResultSet(); |
106 |
|
|
107 |
Classification classification = getClassification(state); |
|
108 | 109 |
|
109 | 110 |
try { |
110 | 111 |
|
... | ... | |
115 | 116 |
|
116 | 117 |
if ((i++ % modCount) == 0 && i!= 1 ){ logger.info(pluralString + " handled: " + (i-1));} |
117 | 118 |
|
118 |
Integer taxonId = rs.getInt("IDcurrentspec"); |
|
119 |
Integer bildID = rs.getInt("BildID"); |
|
120 |
|
|
121 |
Integer spectaxID = nullSafeInt(rs, "spectaxID"); |
|
119 | 122 |
|
123 |
//ignore: [file lab2], same as Dateiname04 but less data |
|
120 | 124 |
|
121 |
//TODO |
|
122 |
//String dtSpcJahr, |
|
123 |
//dtSpcFamakt,dtSpcSubfamakt,dtSpcTribakt, |
|
124 |
//fiSpcLiteratur, fiSpcspcgrptax, dtSpcCountries,vernacularnames |
|
125 | 125 |
|
126 |
try { |
|
126 |
|
|
127 |
try { |
|
127 | 128 |
|
128 |
//source ref
|
|
129 |
//source ref
|
|
129 | 130 |
Reference<?> sourceRef = state.getTransactionalSourceReference(); |
130 |
Taxon nextHigherTaxon = null; |
|
131 | 131 |
|
132 |
Taxon species = createObject(rs, state); |
|
132 |
//make image path |
|
133 |
String pathShort = rs.getString("Dateipfad_kurz"); |
|
134 |
String fileOS = rs.getString("file OS"); |
|
135 |
pathShort.replace(fileOS, ""); |
|
136 |
//TODO move to config |
|
137 |
String newPath = "http://globis-images.insects-online.de/images/"; |
|
138 |
String path = pathShort.replace("image:Webversionen", newPath); |
|
139 |
|
|
133 | 140 |
|
134 |
//subgenus |
|
135 |
String subGenusStr = rs.getString("dtSpcSubgenakt"); |
|
136 |
String subGenusAuthorStr = rs.getString("dtSpcSubgenaktauthor"); |
|
137 |
boolean hasSubgenus = StringUtils.isNotBlank(subGenusStr) || StringUtils.isNotBlank(subGenusAuthorStr); |
|
138 |
if (hasSubgenus){ |
|
139 |
Taxon subGenus = getTaxon(state, rs, subGenusStr, Rank.SUBGENUS(), subGenusAuthorStr, taxonMap); |
|
140 |
classification.addParentChild(subGenus, species, sourceRef, null); |
|
141 |
nextHigherTaxon = getParent(subGenus, classification); |
|
142 |
} |
|
143 | 141 |
|
144 |
//genus |
|
145 |
String genusStr = rs.getString("dtSpcGenusakt"); |
|
146 |
String genusAuthorStr = rs.getString("dtSpcGenusaktauthor"); |
|
147 |
Taxon genus = getTaxon(state, rs, genusStr, Rank.GENUS(), genusAuthorStr, taxonMap); |
|
148 |
if (nextHigherTaxon != null){ |
|
149 |
if (! compareTaxa(genus, nextHigherTaxon)){ |
|
150 |
logger.warn("Current genus and parent of subgenus are not equal: " + taxonId); |
|
151 |
} |
|
152 |
}else{ |
|
153 |
classification.addParentChild(genus, species, sourceRef, null); |
|
154 |
nextHigherTaxon = getParent(genus, classification); |
|
155 |
} |
|
142 |
Media media1 = makeMedia(state, rs, "file OS", "Legende 1", path ); |
|
143 |
Media media2 = makeMedia(state, rs, "Dateiname02", "Legende 2", path ); |
|
144 |
Media media3 = makeMedia(state, rs, "Dateiname03", "Legende 3", path ); |
|
145 |
Media media4 = makeMedia(state, rs, "Dateiname04", "Legende 4", path ); |
|
146 |
|
|
156 | 147 |
|
157 |
this.doIdCreatedUpdatedNotes(state, species, rs, taxonId, REFERENCE_NAMESPACE); |
|
148 |
//TODO |
|
149 |
this.doIdCreatedUpdatedNotes(state, media1, rs, bildID, IMAGE_NAMESPACE); |
|
158 | 150 |
|
159 |
objectsToSave.add(species);
|
|
151 |
save(objectsToSave, media1);
|
|
160 | 152 |
|
153 |
|
|
161 | 154 |
|
162 | 155 |
} catch (Exception e) { |
163 |
logger.warn("Exception in current_species: IDcurrentspec " + taxonId + ". " + e.getMessage());
|
|
156 |
logger.warn("Exception in Einzelbilder: bildID " + bildID + ". " + e.getMessage());
|
|
164 | 157 |
// e.printStackTrace(); |
165 | 158 |
} |
166 | 159 |
|
... | ... | |
169 | 162 |
// logger.warn("Specimen: " + countSpecimen + ", Descriptions: " + countDescriptions ); |
170 | 163 |
|
171 | 164 |
logger.warn(pluralString + " to save: " + objectsToSave.size()); |
172 |
getTaxonService().save(objectsToSave);
|
|
165 |
getMediaService().save(objectsToSave);
|
|
173 | 166 |
|
174 | 167 |
return success; |
175 | 168 |
} catch (SQLException e) { |
... | ... | |
178 | 171 |
} |
179 | 172 |
} |
180 | 173 |
|
181 |
/** |
|
182 |
* Compares 2 taxa, returns true of both taxa look similar |
|
183 |
* @param genus |
|
184 |
* @param nextHigherTaxon |
|
185 |
* @return |
|
186 |
*/ |
|
187 |
private boolean compareTaxa(Taxon taxon1, Taxon taxon2) { |
|
188 |
ZoologicalName name1 = CdmBase.deproxy(taxon1.getName(), ZoologicalName.class); |
|
189 |
ZoologicalName name2 = CdmBase.deproxy(taxon2.getName(), ZoologicalName.class); |
|
190 |
if (!name1.getRank().equals(name2.getRank())){ |
|
191 |
return false; |
|
192 |
} |
|
193 |
if (! name1.getTitleCache().equals(name2.getTitleCache())){ |
|
194 |
return false; |
|
174 |
private void save(Set<Media> objectsToSave, Media media) { |
|
175 |
if (media != null){ |
|
176 |
objectsToSave.add(media); |
|
195 | 177 |
} |
196 |
return true; |
|
197 | 178 |
} |
198 | 179 |
|
199 | 180 |
|
200 | 181 |
|
201 | 182 |
|
202 |
private Taxon getParent(Taxon subgenus, Classification classification) { |
|
203 |
for (TaxonNode node : subgenus.getTaxonNodes()){ |
|
204 |
if (node.getClassification().equals(classification)){ |
|
205 |
return node.getParent().getTaxon(); |
|
206 |
} |
|
183 |
private Media makeMedia(GlobisImportState state, ResultSet rs, String fileNameAttr, String legendAttr, String path) throws SQLException { |
|
184 |
Media media = null; |
|
185 |
String fileName = rs.getString(fileNameAttr); |
|
186 |
String legend = rs.getString(legendAttr); |
|
187 |
|
|
188 |
URI uri = URI.create(path+fileName); |
|
189 |
|
|
190 |
// Media media = ImageInfo.NewInstanceWithMetaData(uri, null); |
|
191 |
|
|
192 |
try { |
|
193 |
media = this.getImageMedia(uri.toString(), true, false); |
|
194 |
media.putTitle(Language.ENGLISH(), legend); |
|
195 |
} catch (MalformedURLException e) { |
|
196 |
e.printStackTrace(); |
|
207 | 197 |
} |
208 |
return null; |
|
198 |
|
|
199 |
return media; |
|
209 | 200 |
} |
210 | 201 |
|
211 | 202 |
|
... | ... | |
225 | 216 |
} |
226 | 217 |
|
227 | 218 |
|
228 |
//fast and dirty is enough here |
|
229 |
private Classification classification; |
|
230 |
|
|
231 |
private Classification getClassification(GlobisImportState state) { |
|
232 |
if (this.classification == null){ |
|
233 |
String name = state.getConfig().getClassificationName(); |
|
234 |
Reference<?> reference = state.getTransactionalSourceReference(); |
|
235 |
this.classification = Classification.NewInstance(name, reference, Language.DEFAULT()); |
|
236 |
classification.setUuid(state.getConfig().getClassificationUuid()); |
|
237 |
getClassificationService().save(classification); |
|
238 |
} |
|
239 |
return this.classification; |
|
240 |
|
|
241 |
} |
|
242 |
|
|
243 |
private INonViralNameParser parser = NonViralNameParserImpl.NewInstance(); |
|
244 |
|
|
245 | 219 |
|
246 |
/* (non-Javadoc) |
|
247 |
* @see eu.etaxonomy.cdm.io.common.mapping.IMappingImport#createObject(java.sql.ResultSet, eu.etaxonomy.cdm.io.common.ImportStateBase) |
|
248 |
*/ |
|
249 |
public Taxon createObject(ResultSet rs, GlobisImportState state) |
|
250 |
throws SQLException { |
|
251 |
String speciesEpi = rs.getString("dtSpcSpcakt"); |
|
252 |
String subGenusEpi = rs.getString("dtSpcSubgenakt"); |
|
253 |
String genusEpi = rs.getString("dtSpcGenusakt"); |
|
254 |
String author = rs.getString("dtSpcAutor"); |
|
255 |
|
|
256 |
|
|
257 |
ZoologicalName zooName = ZoologicalName.NewInstance(Rank.SPECIES()); |
|
258 |
zooName.setSpecificEpithet(speciesEpi); |
|
259 |
if (StringUtils.isNotBlank(subGenusEpi)){ |
|
260 |
zooName.setInfraSpecificEpithet(subGenusEpi); |
|
261 |
} |
|
262 |
zooName.setGenusOrUninomial(genusEpi); |
|
263 |
handleAuthorAndYear(author, zooName); |
|
264 |
|
|
265 |
Taxon taxon = Taxon.NewInstance(zooName, state.getTransactionalSourceReference()); |
|
266 |
|
|
267 |
return taxon; |
|
268 |
} |
|
269 | 220 |
|
270 | 221 |
|
271 | 222 |
/* (non-Javadoc) |
app-import/src/main/java/eu/etaxonomy/cdm/io/globis/GlobisReferenceImport.java | ||
---|---|---|
20 | 20 |
import org.apache.log4j.Logger; |
21 | 21 |
import org.springframework.stereotype.Component; |
22 | 22 |
|
23 |
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade; |
|
24 |
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade.DerivedUnitType; |
|
25 |
import eu.etaxonomy.cdm.io.algaterra.AlgaTerraImportState; |
|
26 |
import eu.etaxonomy.cdm.io.berlinModel.in.BerlinModelTaxonImport; |
|
27 | 23 |
import eu.etaxonomy.cdm.io.common.IImportConfigurator; |
28 | 24 |
import eu.etaxonomy.cdm.io.common.IOValidator; |
29 | 25 |
import eu.etaxonomy.cdm.io.common.ResultSetPartitioner; |
30 |
import eu.etaxonomy.cdm.io.common.mapping.DbIgnoreMapper; |
|
31 |
import eu.etaxonomy.cdm.io.common.mapping.DbImportExtensionMapper; |
|
32 |
import eu.etaxonomy.cdm.io.common.mapping.DbImportMapping; |
|
33 |
import eu.etaxonomy.cdm.io.common.mapping.DbImportObjectCreationMapper; |
|
34 |
import eu.etaxonomy.cdm.io.common.mapping.DbImportStringMapper; |
|
35 |
import eu.etaxonomy.cdm.io.common.mapping.DbNotYetImplementedMapper; |
|
36 | 26 |
import eu.etaxonomy.cdm.io.common.mapping.IMappingImport; |
37 | 27 |
import eu.etaxonomy.cdm.io.globis.validation.GlobisReferenceImportValidator; |
38 | 28 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
39 |
import eu.etaxonomy.cdm.model.description.Feature; |
|
40 |
import eu.etaxonomy.cdm.model.description.IndividualsAssociation; |
|
41 |
import eu.etaxonomy.cdm.model.description.TaxonDescription; |
|
42 |
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit; |
|
43 | 29 |
import eu.etaxonomy.cdm.model.reference.Reference; |
44 | 30 |
import eu.etaxonomy.cdm.model.reference.ReferenceFactory; |
45 | 31 |
import eu.etaxonomy.cdm.model.reference.ReferenceType; |
46 |
import eu.etaxonomy.cdm.model.taxon.TaxonBase; |
|
47 | 32 |
|
48 | 33 |
|
49 | 34 |
/** |
... | ... | |
212 | 197 |
*/ |
213 | 198 |
public Reference<?> createObject(ResultSet rs, GlobisImportState state) |
214 | 199 |
throws SQLException { |
200 |
String refJournal = rs.getString("RefJournal"); |
|
201 |
boolean isInJournal =isNotBlank(refJournal); |
|
202 |
String refBookTitle = rs.getString("RefBookTitle"); |
|
203 |
boolean isInBook =isNotBlank(refBookTitle); |
|
204 |
|
|
205 |
|
|
206 |
|
|
215 | 207 |
Reference<?> ref; |
216 | 208 |
String refType = rs.getString("RefType"); |
217 | 209 |
if (refType == null){ |
218 |
ref = ReferenceFactory.newGeneric(); |
|
210 |
if (isInJournal && ! isInBook){ |
|
211 |
ref = ReferenceFactory.newArticle(); |
|
212 |
}else{ |
|
213 |
ref = ReferenceFactory.newGeneric(); |
|
214 |
} |
|
219 | 215 |
}else if (refType.equals("book")){ |
220 | 216 |
ref = ReferenceFactory.newBook(); |
221 | 217 |
}else if (refType.equals("paper in journal")){ |
... | ... | |
226 | 222 |
ref = ReferenceFactory.newArticle(); |
227 | 223 |
}else if (refType.equals("paper in book")){ |
228 | 224 |
ref = ReferenceFactory.newBookSection(); |
229 |
}else if (refType.equals("paper in journalwebsite")){
|
|
225 |
}else if (refType.matches("paper in journal.*website.*")){
|
|
230 | 226 |
ref = ReferenceFactory.newArticle(); |
231 | 227 |
}else{ |
232 | 228 |
logger.warn("Unknown reference type: " + refType); |
app-import/src/main/java/eu/etaxonomy/cdm/io/globis/GlobisSpecTaxImport.java | ||
---|---|---|
148 | 148 |
}else if (specSystaxRank.equals("synonym")){ |
149 | 149 |
Synonym synonym = getSynonym(state, rs); |
150 | 150 |
if (acceptedTaxon == null){ |
151 |
//TODO |
|
152 |
logger.warn("Accepted taxon (" + acceptedTaxonId + ") not found for synonym "+ specTaxId); |
|
151 |
if (acceptedTaxonId == null){ |
|
152 |
logger.warn("Synonym has no accepted taxon defined. SpecTaxId: "+ specTaxId); |
|
153 |
}else{ |
|
154 |
logger.warn("Accepted taxon (" + acceptedTaxonId + ") not found for synonym "+ specTaxId); |
|
155 |
} |
|
153 | 156 |
}else{ |
154 | 157 |
acceptedTaxon.addSynonym(synonym, SynonymRelationshipType.SYNONYM_OF()); |
155 | 158 |
thisTaxon = synonym; |
... | ... | |
200 | 203 |
|
201 | 204 |
private void handleTypeInformation(GlobisImportState state, ResultSet rs, ZoologicalName name, Integer specTaxId) throws SQLException { |
202 | 205 |
|
203 |
String specTypeDepositoriesStr = rs.getString("SpecTypeDepository"); |
|
204 |
String countryString = rs.getString("SpecTypeCountry"); |
|
205 | 206 |
|
206 |
if (! hasTypeInformation(specTypeDepositoriesStr, countryString)){
|
|
207 |
if (! hasTypeInformation(rs)){
|
|
207 | 208 |
return; |
208 | 209 |
} |
209 | 210 |
|
210 |
FieldObservation fieldObservation = makeTypeFieldObservation(state, countryString);
|
|
211 |
FieldObservation fieldObservation = makeTypeFieldObservation(state, rs);
|
|
211 | 212 |
|
213 |
//typeDepository |
|
214 |
String specTypeDepositoriesStr = rs.getString("SpecTypeDepository"); |
|
212 | 215 |
String[] specTypeDepositories; |
213 | 216 |
if (isNotBlank(specTypeDepositoriesStr) ){ |
214 |
specTypeDepositories = specTypeDepositoriesStr.split(";"); |
|
217 |
specTypeDepositories = specTypeDepositoriesStr.trim().split(";");
|
|
215 | 218 |
}else{ |
216 | 219 |
specTypeDepositories = new String[0]; |
217 | 220 |
} |
218 |
//TODO different issues |
|
221 |
|
|
222 |
//TODO several issues |
|
219 | 223 |
if (specTypeDepositories.length == 0){ |
220 |
logger.warn("SpecTax has type information but no SpecTypeDepository. specTaxId: " + specTaxId); |
|
224 |
Specimen specimen = makeSingleTypeSpecimen(fieldObservation); |
|
225 |
makeTypeDesignation(name, rs, specimen); |
|
221 | 226 |
} |
222 | 227 |
for (String specTypeDepositoryStr : specTypeDepositories){ |
223 | 228 |
specTypeDepositoryStr = specTypeDepositoryStr.trim(); |
... | ... | |
227 | 232 |
|
228 | 233 |
if (specTypeDepositoryStr.equals("??")){ |
229 | 234 |
//unknown |
230 |
//TODO |
|
231 | 235 |
specimen.setTitleCache("??", true); |
232 | 236 |
}else{ |
233 | 237 |
specTypeDepositoryStr = makeAdditionalSpecimenInformation( |
234 |
specTypeDepositoryStr, specimen); |
|
238 |
specTypeDepositoryStr, specimen, specTaxId);
|
|
235 | 239 |
|
236 |
makeCollection(specTypeDepositoryStr, specimen); |
|
240 |
makeCollection(specTypeDepositoryStr, specimen, specTaxId);
|
|
237 | 241 |
} |
238 | 242 |
|
239 | 243 |
//type Designation |
... | ... | |
246 | 250 |
|
247 | 251 |
|
248 | 252 |
|
249 |
private boolean hasTypeInformation(String specTypeDepositoriesStr, String countryString) { |
|
253 |
private boolean hasTypeInformation(ResultSet rs) throws SQLException { |
|
254 |
String specTypeDepositoriesStr = rs.getString("SpecTypeDepository"); |
|
255 |
String countryString = rs.getString("SpecTypeCountry"); |
|
256 |
String specType = rs.getString("SpecType"); |
|
250 | 257 |
boolean result = false; |
251 |
result |= isNotBlank(specTypeDepositoriesStr) || isNotBlank(countryString); |
|
258 |
result |= isNotBlank(specTypeDepositoriesStr) || isNotBlank(countryString) |
|
259 |
|| isNotBlank(specType); |
|
252 | 260 |
return result; |
253 | 261 |
} |
254 | 262 |
|
... | ... | |
257 | 265 |
/** |
258 | 266 |
* @param specTypeDepositoryStr |
259 | 267 |
* @param specimen |
268 |
* @param specTaxId |
|
260 | 269 |
*/ |
261 |
protected void makeCollection(String specTypeDepositoryStr, Specimen specimen) { |
|
270 |
protected void makeCollection(String specTypeDepositoryStr, Specimen specimen, Integer specTaxId) {
|
|
262 | 271 |
//TODO deduplicate |
263 | 272 |
Map<String, Collection> collectionMap = new HashMap<String, Collection>(); |
264 | 273 |
|
265 | 274 |
|
266 | 275 |
//Collection |
267 |
String[] split = specTypeDepositoryStr.split(","); |
|
268 |
if (split.length != 2){ |
|
269 |
if (split.length == 1 && split[0].startsWith("coll.")){ |
|
270 |
Collection collection = Collection.NewInstance(); |
|
271 |
collection.setName(split[0]); |
|
272 |
}else{ |
|
273 |
logger.warn("Split size is not 2: " + specTypeDepositoryStr); |
|
274 |
} |
|
275 |
|
|
276 |
specTypeDepositoryStr = specTypeDepositoryStr.replace("Washington, D.C.", "Washington@ D.C."); |
|
277 |
|
|
278 |
if (specTypeDepositoryStr.equals("BMNH, London and/or MNHN, Paris")){ |
|
279 |
//TODO deduplicate |
|
280 |
Collection collection = Collection.NewInstance(); |
|
281 |
collection.setName(specTypeDepositoryStr); |
|
282 |
specimen.setCollection(collection); |
|
283 |
}else if (specTypeDepositoryStr.equals("coll. L. V. Kaabak, A .V. Sotshivko & V. V. Titov, Moscow")){ |
|
284 |
Collection collection = Collection.NewInstance(); |
|
285 |
collection.setName("coll. L. V. Kaabak, A .V. Sotshivko & V. V. Titov"); |
|
286 |
collection.setTownOrLocation("Moscow"); |
|
287 |
specimen.setCollection(collection); |
|
288 |
}else if (specTypeDepositoryStr.matches("coll. R. E. Parrott?, Port Hope, Ontario")){ |
|
289 |
//TODO deduplicate |
|
290 |
Collection collection = Collection.NewInstance(); |
|
291 |
collection.setName("coll. R. E. Parrott"); |
|
292 |
collection.setTownOrLocation("Port Hope, Ontario"); |
|
293 |
specimen.setCollection(collection); |
|
276 | 294 |
}else{ |
277 |
String collectionStr = split[0]; |
|
278 |
String location = split[1]; |
|
279 | 295 |
|
280 |
|
|
281 |
Collection collection = collectionMap.get(collectionStr); |
|
282 |
if (collection == null){ |
|
283 |
collection = Collection.NewInstance(); |
|
284 |
collection.setCode(collectionStr); |
|
285 |
collection.setTownOrLocation(split[1]); |
|
286 |
}else if (CdmUtils.nullSafeEqual(location, collection.getTownOrLocation())){ |
|
287 |
String message = "Location (%s) is not equal to location (%s) of existing collection"; |
|
288 |
logger.warn(String.format(message, location, collection.getTownOrLocation(), collection.getCode())); |
|
296 |
String[] split = specTypeDepositoryStr.split(","); |
|
297 |
if (split.length != 2){ |
|
298 |
if (split.length == 1 && split[0].startsWith("coll.")){ |
|
299 |
Collection collection = Collection.NewInstance(); |
|
300 |
collection.setName(split[0]); |
|
301 |
specimen.setCollection(collection); |
|
302 |
}else{ |
|
303 |
logger.warn("Split size is not 2: " + specTypeDepositoryStr + " (specTaxID:" + specTaxId + ")"); |
|
304 |
} |
|
305 |
|
|
306 |
}else{ |
|
307 |
String collectionStr = split[0]; |
|
308 |
String location = split[1].replace("Washington@ D.C.", "Washington, D.C."); |
|
309 |
|
|
310 |
Collection collection = collectionMap.get(collectionStr); |
|
311 |
if (collection == null){ |
|
312 |
collection = Collection.NewInstance(); |
|
313 |
collection.setCode(collectionStr); |
|
314 |
collection.setTownOrLocation(split[1]); |
|
315 |
}else if (CdmUtils.nullSafeEqual(location, collection.getTownOrLocation())){ |
|
316 |
String message = "Location (%s) is not equal to location (%s) of existing collection"; |
|
317 |
logger.warn(String.format(message, location, collection.getTownOrLocation(), collection.getCode())); |
|
318 |
} |
|
319 |
|
|
320 |
specimen.setCollection(collection); |
|
321 |
|
|
289 | 322 |
} |
290 |
|
|
291 |
specimen.setCollection(collection); |
|
292 |
|
|
293 | 323 |
} |
294 | 324 |
} |
295 | 325 |
|
... | ... | |
300 | 330 |
* @param specTypeDepositoriesStr |
301 | 331 |
* @param specTypeDepositoryStr |
302 | 332 |
* @param specimen |
333 |
* @param specTaxId |
|
303 | 334 |
* @return |
304 | 335 |
*/ |
305 |
protected String makeAdditionalSpecimenInformation( String specTypeDepositoryStr, |
|
306 |
Specimen specimen) { |
|
336 |
protected String makeAdditionalSpecimenInformation( String specTypeDepositoryStr, Specimen specimen, Integer specTaxId) { |
|
307 | 337 |
//doubful |
308 | 338 |
if (specTypeDepositoryStr.endsWith("?")){ |
309 | 339 |
Marker.NewInstance(specimen, true, MarkerType.IS_DOUBTFUL()); |
... | ... | |
321 | 351 |
brackets = brackets.replace("[m]", "\u2642"); |
322 | 352 |
brackets = brackets.replace("[ff]", "\u2640\u2640"); |
323 | 353 |
brackets = brackets.replace("[f]", "\u2640"); |
354 |
brackets = brackets.replace("[m/f]", "\u26a5"); |
|
324 | 355 |
|
325 | 356 |
if (brackets.contains("[") || brackets.contains("]")){ |
326 |
logger.warn ("There are still '[', ']' in the bracket part: " + brackets); |
|
357 |
logger.warn ("There are still '[', ']' in the bracket part: " + brackets + "; specTaxId: " + specTaxId);
|
|
327 | 358 |
} |
328 | 359 |
|
329 | 360 |
//TODO replace mm/ff by Unicode male |
... | ... | |
358 | 389 |
* @throws SQLException |
359 | 390 |
*/ |
360 | 391 |
protected FieldObservation makeTypeFieldObservation(GlobisImportState state, |
361 |
String countryString) throws SQLException { |
|
392 |
ResultSet rs) throws SQLException { |
|
393 |
|
|
394 |
String countryString = rs.getString("SpecTypeCountry"); |
|
362 | 395 |
|
363 | 396 |
DerivedUnitType unitType = DerivedUnitType.Specimen; |
364 | 397 |
DerivedUnitFacade facade = DerivedUnitFacade.NewInstance(unitType); |
... | ... | |
401 | 434 |
return SpecimenTypeDesignationStatus.HOLOTYPE(); |
402 | 435 |
}else if (specType.matches("Neotype")){ |
403 | 436 |
return SpecimenTypeDesignationStatus.NEOTYPE(); |
404 |
}else if (specType.matches("Syntype(\\(s\\))?")){ |
|
437 |
}else if (specType.matches("Syntype(\\(s\\))?") || specType.matches("Syntype.*Syntype\\(s\\)\\s*") ){
|
|
405 | 438 |
return SpecimenTypeDesignationStatus.SYNTYPE(); |
406 | 439 |
}else if (specType.matches("Lectotype")){ |
407 | 440 |
return SpecimenTypeDesignationStatus.LECTOTYPE(); |
app-import/src/main/java/eu/etaxonomy/cdm/io/globis/GlobisTransformer.java | ||
---|---|---|
221 | 221 |
}else if (area.equals("Gambia")){return WaterbodyOrCountry.GAMBIAREPUBLICOFTHE(); |
222 | 222 |
}else if (area.equals("Dominica")){return WaterbodyOrCountry.DOMINICACOMMONWEALTHOF(); |
223 | 223 |
}else if (area.equals("Liechtenstein")){return WaterbodyOrCountry.LIECHTENSTEINPRINCIPALITYOF(); |
224 |
}else if (area.matches("B(y)?elarus")){return WaterbodyOrCountry.BELARUS(); |
|
225 |
|
|
224 | 226 |
|
225 |
|
|
226 | 227 |
|
227 | 228 |
|
228 | 229 |
|
Also available in: Unified diff
update Globis import