Revision 01146fd8
Added by Andreas Müller over 3 years ago
app-import/src/main/java/eu/etaxonomy/cdm/app/cyprus/CyprusImagesActivator.java | ||
---|---|---|
254 | 254 |
// IImageMetadata metadata = Sanselan.getMetadata(file); |
255 | 255 |
ImageMetadata metadata = Imaging.getMetadata(file); |
256 | 256 |
List<? extends ImageMetadataItem> items = metadata.getItems(); |
257 |
for (Object object : items){ |
|
258 |
ImageMetadataItem metadataItem = (ImageMetadataItem) object; |
|
257 |
for (ImageMetadataItem metadataItem : items){ |
|
259 | 258 |
// System.out.println(item.getKeyword() + ": " + item.getText()); |
260 | 259 |
if (metadataItem instanceof GenericImageMetadataItem){ |
261 | 260 |
GenericImageMetadataItem item = (GenericImageMetadataItem) metadataItem; |
app-import/src/main/java/eu/etaxonomy/cdm/app/proibiosphere/TaxonXImportLauncher.java | ||
---|---|---|
227 | 227 |
|
228 | 228 |
//System.out.println(documents); |
229 | 229 |
for (String docId : docs.keySet()){ |
230 |
List<String> treatments = new ArrayList<String>(new HashSet<String>(docs.get(docId)));
|
|
230 |
List<String> treatments = new ArrayList<>(new HashSet<>(docs.get(docId)));
|
|
231 | 231 |
|
232 |
Map<Integer, List<String>> startPages = new HashMap<Integer, List<String>>();
|
|
232 |
Map<Integer, List<String>> startPages = new HashMap<>(); |
|
233 | 233 |
for (String treatment:treatments) { |
234 | 234 |
List<String>tmplist = startPages.get(Integer.valueOf(treatment.split("---")[0])); |
235 | 235 |
if (tmplist == null) { |
236 |
tmplist = new ArrayList<String>();
|
|
236 |
tmplist = new ArrayList<>(); |
|
237 | 237 |
} |
238 | 238 |
tmplist.add(treatment.split("---")[3]); |
239 | 239 |
startPages.put(Integer.valueOf(treatment.split("---")[0]),tmplist); |
240 | 240 |
} |
241 |
List<Integer> pages = new ArrayList<Integer>();
|
|
241 |
List<Integer> pages = new ArrayList<>(); |
|
242 | 242 |
pages.addAll(startPages.keySet()); |
243 | 243 |
|
244 | 244 |
Collections.sort(pages); |
... | ... | |
247 | 247 |
log.info("Document "+docId+" should have "+treatments.size()+" treatments"); |
248 | 248 |
List<URI> uritmp = documentMap.get(docId); |
249 | 249 |
if (uritmp == null) { |
250 |
uritmp = new ArrayList<URI>();
|
|
250 |
uritmp = new ArrayList<>(); |
|
251 | 251 |
} |
252 | 252 |
for (int page:pages) { |
253 | 253 |
for (String treatment: startPages.get(page)) { |
... | ... | |
265 | 265 |
documentMap.put(docId, uritmp); |
266 | 266 |
} |
267 | 267 |
|
268 |
|
|
269 |
|
|
270 |
|
|
271 |
|
|
272 |
|
|
273 | 268 |
return documentMap; |
274 | 269 |
|
275 | 270 |
} |
... | ... | |
303 | 298 |
String[] filterList, String urlstr) |
304 | 299 |
throws MalformedURLException, IOException { |
305 | 300 |
|
306 |
Map<String, List<String>> documents = new HashMap<String, List<String>>();
|
|
301 |
Map<String, List<String>> documents = new HashMap<>(); |
|
307 | 302 |
List<String> docList; |
308 | 303 |
String inputLine; |
309 | 304 |
for(String filter : filterList){ |
... | ... | |
318 | 313 |
URL plaziURL = new URL(urlstr); |
319 | 314 |
BufferedReader in = new BufferedReader(new InputStreamReader(plaziURL.openStream())); |
320 | 315 |
|
321 |
|
|
322 | 316 |
//TODO lastUpdate field |
323 | 317 |
// if(!plaziNotServer){ |
324 | 318 |
while ((inputLine = in.readLine()) != null) { |
... | ... | |
345 | 339 |
return documents; |
346 | 340 |
} |
347 | 341 |
|
348 |
/** |
|
349 |
* @param document |
|
350 |
* @return |
|
351 |
*/ |
|
352 | 342 |
private static boolean doImportDocument(String document, int nbtreatments) { |
353 | 343 |
|
354 | 344 |
if (nbtreatments>400) { |
... | ... | |
390 | 380 |
*/ |
391 | 381 |
} |
392 | 382 |
|
393 |
/** |
|
394 |
* @return |
|
395 |
*/ |
|
396 | 383 |
private static boolean askIfReuseSecundum() { |
397 | 384 |
// logger.info("getFullReference for "+ name); |
398 | 385 |
JTextArea textArea = new JTextArea("Reuse the secundum present in the current classification? " + |
... | ... | |
412 | 399 |
} |
413 | 400 |
} |
414 | 401 |
|
415 |
/** |
|
416 |
* @return |
|
417 |
*/ |
|
418 | 402 |
private static Reference askForSecundum() { |
419 | 403 |
// logger.info("getFullReference for "+ name); |
420 | 404 |
JTextArea textArea = new JTextArea("Enter the secundum name"); |
... | ... | |
437 | 421 |
ref.setTitle(s); |
438 | 422 |
return ref; |
439 | 423 |
} |
440 |
|
|
441 |
|
|
442 | 424 |
} |
app-import/src/main/java/eu/etaxonomy/cdm/app/wp6/diptera/DipteraDistributionParser.java | ||
---|---|---|
47 | 47 |
/** |
48 | 48 |
* @author a.mueller |
49 | 49 |
* @since 17.10.2008 |
50 |
* @version 1.0 |
|
51 | 50 |
*/ |
52 | 51 |
public class DipteraDistributionParser { |
53 | 52 |
private static final Logger logger = Logger.getLogger(DipteraDistributionParser.class); |
... | ... | |
90 | 89 |
app.commitTransaction(txStatus); |
91 | 90 |
} |
92 | 91 |
|
93 |
static Set<String> unrekognizedStrings = new HashSet<String>();
|
|
92 |
static Set<String> unrekognizedStrings = new HashSet<>(); |
|
94 | 93 |
static int countNot = 0; |
95 | 94 |
static int countYes = 0; |
96 | 95 |
|
... | ... | |
218 | 217 |
} |
219 | 218 |
|
220 | 219 |
|
221 |
static List<String> stopWords = new ArrayList<String>();
|
|
222 |
static List<String> unknownAreas = new ArrayList<String>();
|
|
223 |
static List<String> higherAreas = new ArrayList<String>();
|
|
220 |
static List<String> stopWords = new ArrayList<>(); |
|
221 |
static List<String> unknownAreas = new ArrayList<>(); |
|
222 |
static List<String> higherAreas = new ArrayList<>(); |
|
224 | 223 |
|
225 | 224 |
private String adaptWordsToTdwg(String word){ |
226 | 225 |
word = word.replace(",", "").replace(";", ""); |
... | ... | |
409 | 408 |
higherAreas.add("NT"); |
410 | 409 |
} |
411 | 410 |
|
412 |
|
|
413 |
/** |
|
414 |
* @param args |
|
415 |
*/ |
|
416 | 411 |
public static void main(String[] args) { |
417 | 412 |
CdmApplicationController app = null; |
418 | 413 |
DbSchemaValidation val = DbSchemaValidation.UPDATE; |
app-import/src/main/java/eu/etaxonomy/cdm/io/PalmaeImageImport.java | ||
---|---|---|
218 | 218 |
String mimeType = imageinfo.getMimeType(); |
219 | 219 |
String suffix = "jpg"; |
220 | 220 |
|
221 |
|
|
222 | 221 |
// URL for this image |
223 | 222 |
URL url = null; |
224 | 223 |
try { |
... | ... | |
227 | 226 |
logger.warn("URL is malformed: "+ url); |
228 | 227 |
} |
229 | 228 |
|
230 |
|
|
231 | 229 |
ImageFile imageFile = ImageFile.NewInstance(url.toURI(),null, imageinfo.getHeight(), imageinfo.getWidth()); |
232 | 230 |
|
233 |
|
|
234 | 231 |
MediaRepresentation representation = MediaRepresentation.NewInstance(mimeType, suffix); |
235 | 232 |
representation.addRepresentationPart(imageFile); |
236 | 233 |
|
app-import/src/main/java/eu/etaxonomy/cdm/io/algaterra/AlgaTerraPictureImport.java | ||
---|---|---|
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 |
*/ |
9 |
|
|
10 | 9 |
package eu.etaxonomy.cdm.io.algaterra; |
11 | 10 |
|
12 | 11 |
import java.sql.ResultSet; |
... | ... | |
34 | 33 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
35 | 34 |
import eu.etaxonomy.cdm.model.taxon.TaxonBase; |
36 | 35 |
|
37 |
|
|
38 | 36 |
/** |
39 | 37 |
* Import for AlgaTerra images from table |
40 | 38 |
* @author a.mueller |
... | ... | |
42 | 40 |
*/ |
43 | 41 |
@Component |
44 | 42 |
public class AlgaTerraPictureImport extends AlgaTerraImageImportBase { |
45 |
private static final Logger logger = Logger.getLogger(AlgaTerraPictureImport.class); |
|
46 | 43 |
|
44 |
private static final long serialVersionUID = 3910940848080132170L; |
|
45 |
private static final Logger logger = Logger.getLogger(AlgaTerraPictureImport.class); |
|
47 | 46 |
|
48 | 47 |
private static int modCount = 5000; |
49 | 48 |
private static final String pluralString = "pictures"; |
... | ... | |
53 | 52 |
super(dbTableName, pluralString); |
54 | 53 |
} |
55 | 54 |
|
56 |
|
|
57 |
/* (non-Javadoc) |
|
58 |
* @see eu.etaxonomy.cdm.io.berlinModel.in.BerlinModelImportBase#getIdQuery() |
|
59 |
*/ |
|
60 | 55 |
@Override |
61 | 56 |
protected String getIdQuery(BerlinModelImportState state) { |
62 | 57 |
String result = " SELECT p.PictureId " |
... | ... | |
66 | 61 |
return result; |
67 | 62 |
} |
68 | 63 |
|
69 |
/* (non-Javadoc) |
|
70 |
* @see eu.etaxonomy.cdm.io.berlinModel.in.BerlinModelImportBase#getRecordQuery(eu.etaxonomy.cdm.io.berlinModel.in.BerlinModelImportConfigurator) |
|
71 |
*/ |
|
72 | 64 |
@Override |
73 | 65 |
protected String getRecordQuery(BerlinModelImportConfigurator config) { |
74 | 66 |
String strQuery = |
... | ... | |
77 | 69 |
" FROM Picture p INNER JOIN Fact f ON p.PictureId = f.ExtensionFk LEFT OUTER JOIN PTaxon pt ON f.PTNameFk = pt.PTNameFk AND f.PTRefFk = pt.PTRefFk " |
78 | 70 |
+ " WHERE f.FactCategoryFk = 205 AND ( p.PictureID IN (" + ID_LIST_TOKEN + ") )" |
79 | 71 |
+ " ORDER BY p.PictureId, f.factId, pt.RIdentifier "; |
80 |
; |
|
81 | 72 |
return strQuery; |
82 | 73 |
} |
83 | 74 |
|
84 |
/* (non-Javadoc) |
|
85 |
* @see eu.etaxonomy.cdm.io.berlinModel.in.IPartitionedIO#doPartition(eu.etaxonomy.cdm.io.berlinModel.in.ResultSetPartitioner, eu.etaxonomy.cdm.io.berlinModel.in.BerlinModelImportState) |
|
86 |
*/ |
|
87 | 75 |
@Override |
88 | 76 |
public boolean doPartition(ResultSetPartitioner partitioner, BerlinModelImportState bmState) { |
89 | 77 |
boolean success = true; |
90 | 78 |
|
91 | 79 |
AlgaTerraImportState state = (AlgaTerraImportState)bmState; |
92 | 80 |
|
93 |
// Set<SpecimenOrObservationBase> specimenToSave = new HashSet<SpecimenOrObservationBase>(); |
|
94 |
Set<TaxonBase> taxaToSave = new HashSet<TaxonBase>(); |
|
81 |
Set<TaxonBase> taxaToSave = new HashSet<>(); |
|
95 | 82 |
|
96 |
// Map<String, DerivedUnitBase> ecoFactMap = (Map<String, DerivedUnitBase>) partitioner.getObjectMap(AlgaTerraSpecimenImportBase.ECO_FACT_DERIVED_UNIT_NAMESPACE); |
|
97 | 83 |
Map<String, TaxonBase> taxonMap = partitioner.getObjectMap(BerlinModelTaxonImport.NAMESPACE); |
98 | 84 |
Map<String, DerivedUnit> specimenMap = partitioner.getObjectMap(AlgaTerraFactEcologyImport.FACT_ECOLOGY_NAMESPACE); |
99 | 85 |
|
100 | 86 |
ResultSet rs = partitioner.getResultSet(); |
101 | 87 |
|
102 | 88 |
try { |
103 |
|
|
104 | 89 |
int i = 0; |
105 |
|
|
106 | 90 |
//for each reference |
107 | 91 |
while (rs.next()){ |
108 | 92 |
|
... | ... | |
111 | 95 |
int pictureId = rs.getInt("PictureID"); |
112 | 96 |
int taxonId = rs.getInt("RIdentifier"); |
113 | 97 |
int factId = rs.getInt("FactId"); |
114 |
|
|
115 |
|
|
116 | 98 |
//TODO etc. Created, Notes, Copyright, TermsOfUse etc. |
117 |
|
|
118 | 99 |
try { |
119 | 100 |
|
120 | 101 |
TaxonBase<?> taxonBase = taxonMap.get(String.valueOf(taxonId)); |
... | ... | |
132 | 113 |
|
133 | 114 |
taxaToSave.add(taxon); |
134 | 115 |
} |
135 |
|
|
136 |
|
|
137 | 116 |
} catch (Exception e) { |
138 | 117 |
logger.warn("Exception in " + getTableName() + ": PictureId " + pictureId + ". " + e.getMessage()); |
139 | 118 |
e.printStackTrace(); |
140 | 119 |
} |
141 |
|
|
142 | 120 |
} |
143 | 121 |
|
144 |
// logger.warn("Specimen: " + countSpecimen + ", Descriptions: " + countDescriptions ); |
|
145 |
|
|
146 | 122 |
logger.warn(pluralString + " to save: " + taxaToSave.size()); |
147 |
// getOccurrenceService().save(taxaToSave); |
|
148 | 123 |
getTaxonService().save(taxaToSave); |
149 | 124 |
|
150 | 125 |
return success; |
... | ... | |
154 | 129 |
} |
155 | 130 |
} |
156 | 131 |
|
157 |
|
|
158 |
|
|
159 | 132 |
private void handlePictureSpecificFields(ResultSet rs, Media media, AlgaTerraImportState state, Map<String, DerivedUnit> specimenMap) throws SQLException { |
160 | 133 |
Integer specimenFactId = nullSafeInt(rs, "FactFk"); |
161 | 134 |
if (specimenFactId != null){ |
... | ... | |
173 | 146 |
} |
174 | 147 |
} |
175 | 148 |
} |
176 |
|
|
177 | 149 |
} |
178 | 150 |
|
179 |
|
|
180 | 151 |
@Override |
181 | 152 |
public Map<Object, Map<String, ? extends CdmBase>> getRelatedObjectsForPartition(ResultSet rs, BerlinModelImportState state) { |
182 | 153 |
|
183 | 154 |
String nameSpace; |
184 | 155 |
Set<String> idSet; |
185 |
Map<Object, Map<String, ? extends CdmBase>> result = new HashMap<Object, Map<String, ? extends CdmBase>>();
|
|
156 |
Map<Object, Map<String, ? extends CdmBase>> result = new HashMap<>(); |
|
186 | 157 |
|
187 | 158 |
try{ |
188 |
Set<String> taxonIdSet = new HashSet<String>();
|
|
189 |
Set<String> specimenIdSet = new HashSet<String>();
|
|
159 |
Set<String> taxonIdSet = new HashSet<>(); |
|
160 |
Set<String> specimenIdSet = new HashSet<>(); |
|
190 | 161 |
|
191 | 162 |
while (rs.next()){ |
192 | 163 |
handleForeignKey(rs, taxonIdSet, "RIdentifier"); |
... | ... | |
214 | 185 |
return result; |
215 | 186 |
} |
216 | 187 |
|
217 |
|
|
218 | 188 |
@Override |
219 | 189 |
protected boolean doCheck(BerlinModelImportState state){ |
220 | 190 |
IOValidator<BerlinModelImportState> validator = new AlgaTerraTypeImportValidator(); |
... | ... | |
226 | 196 |
AlgaTerraImportConfigurator config = ((AlgaTerraImportState) bmState).getAlgaTerraConfigurator(); |
227 | 197 |
return ! ( config.isDoTypes() && config.isDoImages()) ; |
228 | 198 |
} |
229 |
|
|
230 | 199 |
} |
app-import/src/main/java/eu/etaxonomy/cdm/io/berlinModel/in/BerlinModelAuthorTeamImport.java | ||
---|---|---|
34 | 34 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
35 | 35 |
import eu.etaxonomy.cdm.strategy.cache.agent.INomenclaturalAuthorCacheStrategy; |
36 | 36 |
|
37 |
|
|
38 | 37 |
/** |
39 | 38 |
* @author a.mueller |
40 | 39 |
* @since 20.03.2008 |
... | ... | |
225 | 224 |
return success; |
226 | 225 |
} |
227 | 226 |
|
228 |
|
|
229 |
/** |
|
230 |
* @param state |
|
231 |
* @param team |
|
232 |
* @param authorTeamCache |
|
233 |
* @param fullAuthorTeamCache |
|
234 |
* @param preliminaryFlag |
|
235 |
* @return |
|
236 |
*/ |
|
237 | 227 |
private TeamOrPersonBase<?> handleTeam(BerlinModelImportState state, Team team, String authorTeamCache, |
238 | 228 |
String fullAuthorTeamCache, boolean preliminaryFlag, int authorTeamId) { |
239 | 229 |
|
... | ... | |
308 | 298 |
return result; |
309 | 299 |
} |
310 | 300 |
|
311 |
|
|
312 |
/** |
|
313 |
* @param team |
|
314 |
* @param authorTeamCache |
|
315 |
* @param authorTeamId |
|
316 |
*/ |
|
317 | 301 |
protected void checkTeamNomenclaturalTitle(Team team, String authorTeamCache, int authorTeamId) { |
318 | 302 |
if (team.getCacheStrategy().getNomenclaturalTitle(team).equals(authorTeamCache)){ |
319 | 303 |
team.setProtectedNomenclaturalTitleCache(false); |
... | ... | |
326 | 310 |
} |
327 | 311 |
} |
328 | 312 |
|
329 |
|
|
330 |
/** |
|
331 |
* @param team |
|
332 |
* @param fullAuthorTeamCache |
|
333 |
* @param authorTeamId |
|
334 |
* @param formatter |
|
335 |
*/ |
|
336 | 313 |
protected void checkTeamTitleCache(Team team, String fullAuthorTeamCache, int authorTeamId) { |
337 | 314 |
INomenclaturalAuthorCacheStrategy<Team> formatter = team.getCacheStrategy(); |
338 | 315 |
if (team.generateTitle().equals(fullAuthorTeamCache)){ |
... | ... | |
428 | 405 |
|
429 | 406 |
private static final String TEAM_SPLITTER = "(,|&)"; |
430 | 407 |
|
431 |
/** |
|
432 |
* @param fullAuthorTeamCache |
|
433 |
* @param TEAM_SPLITTER |
|
434 |
* @return |
|
435 |
*/ |
|
436 | 408 |
protected static String[] splitTeam(String teamCache) { |
437 | 409 |
if (teamCache == null){ |
438 | 410 |
return new String[0]; |
... | ... | |
440 | 412 |
return teamCache.split(TEAM_SPLITTER); |
441 | 413 |
} |
442 | 414 |
|
443 |
|
|
444 |
/** |
|
445 |
* @param authorTeamCache |
|
446 |
* @return |
|
447 |
*/ |
|
448 | 415 |
protected static boolean hasTeamSeparator(String teamCache) { |
449 | 416 |
if (isBlank(teamCache)){ |
450 | 417 |
return false; |
... | ... | |
455 | 422 |
} |
456 | 423 |
} |
457 | 424 |
|
458 |
|
|
459 | 425 |
@Override |
460 | 426 |
public Map<Object, Map<String, ? extends CdmBase>> getRelatedObjectsForPartition(ResultSet rs, BerlinModelImportState state) { |
461 | 427 |
|
... | ... | |
471 | 437 |
return result; |
472 | 438 |
} |
473 | 439 |
|
474 |
/** |
|
475 |
* @param rs |
|
476 |
* @return |
|
477 |
* @throws SQLException |
|
478 |
* @throws SQLException |
|
479 |
*/ |
|
480 | 440 |
private Set<String> makeAuthorIdList(ResultSet rs) { |
481 |
Set<String> result = new HashSet<String>();
|
|
441 |
Set<String> result = new HashSet<>(); |
|
482 | 442 |
|
483 | 443 |
String authorTeamIdList = ""; |
484 | 444 |
try { |
app-import/src/main/java/eu/etaxonomy/cdm/io/berlinModel/in/BerlinModelOccurrenceImport.java | ||
---|---|---|
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 |
*/ |
9 |
|
|
10 | 9 |
package eu.etaxonomy.cdm.io.berlinModel.in; |
11 | 10 |
|
12 | 11 |
import java.sql.ResultSet; |
... | ... | |
45 | 44 |
import eu.etaxonomy.cdm.model.term.OrderedTermVocabulary; |
46 | 45 |
import eu.etaxonomy.cdm.strategy.exceptions.UnknownCdmTypeException; |
47 | 46 |
|
48 |
|
|
49 | 47 |
/** |
50 | 48 |
* @author a.mueller |
51 | 49 |
* @since 20.03.2008 |
... | ... | |
343 | 341 |
|
344 | 342 |
try{ |
345 | 343 |
Map<Object, Map<String, ? extends CdmBase>> result = new HashMap<>(); |
346 |
Set<String> taxonIdSet = new HashSet<String>();
|
|
344 |
Set<String> taxonIdSet = new HashSet<>(); |
|
347 | 345 |
while (rs.next()){ |
348 | 346 |
handleForeignKey(rs, taxonIdSet, "taxonId"); |
349 | 347 |
} |
app-import/src/main/java/eu/etaxonomy/cdm/io/berlinModel/in/BerlinModelTaxonRelationImport.java | ||
---|---|---|
74 | 74 |
private static final Logger logger = Logger.getLogger(BerlinModelTaxonRelationImport.class); |
75 | 75 |
|
76 | 76 |
public static final String TREE_NAMESPACE = "PTRefFk"; |
77 |
private static final Integer AUCT_REF_ID = 5959; |
|
78 | 77 |
|
79 | 78 |
private static int modCount = 30000; |
80 | 79 |
private static final String pluralString = "taxon relations"; |
... | ... | |
154 | 153 |
return; |
155 | 154 |
} |
156 | 155 |
|
157 |
/** |
|
158 |
* @return |
|
159 |
* @throws SQLException |
|
160 |
*/ |
|
161 | 156 |
private Set<String> getTreeReferenceIdSet(BerlinModelImportState state) throws SQLException { |
162 | 157 |
Source source = state.getConfig().getSource(); |
163 |
Set<String> result = new HashSet<String>();
|
|
158 |
Set<String> result = new HashSet<>(); |
|
164 | 159 |
ResultSet rs = source.getResultSet(getClassificationQuery(state)) ; |
165 | 160 |
while (rs.next()){ |
166 | 161 |
Object id = rs.getObject("PTRefFk"); |
app-import/src/main/java/eu/etaxonomy/cdm/io/berlinModel/in/BerlinModelTypesImport.java | ||
---|---|---|
177 | 177 |
Map<Object, Map<String, ? extends CdmBase>> result = new HashMap<>(); |
178 | 178 |
|
179 | 179 |
try{ |
180 |
Set<String> nameIdSet = new HashSet<String>();
|
|
181 |
Set<String> referenceIdSet = new HashSet<String>();
|
|
180 |
Set<String> nameIdSet = new HashSet<>(); |
|
181 |
Set<String> referenceIdSet = new HashSet<>(); |
|
182 | 182 |
while (rs.next()){ |
183 | 183 |
handleForeignKey(rs, nameIdSet, "NameFk"); |
184 | 184 |
handleForeignKey(rs, referenceIdSet, "RefFk"); |
app-import/src/main/java/eu/etaxonomy/cdm/io/berlinModel/in/validation/BerlinModelReferenceImportValidator.java | ||
---|---|---|
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 |
*/ |
9 |
|
|
10 | 9 |
package eu.etaxonomy.cdm.io.berlinModel.in.validation; |
11 | 10 |
|
12 | 11 |
import java.sql.ResultSet; |
... | ... | |
46 | 45 |
if (result == false ){System.out.println("========================================================");} |
47 | 46 |
|
48 | 47 |
return result; |
49 |
|
|
50 | 48 |
} |
51 | 49 |
|
52 |
|
|
53 | 50 |
//******************************** CHECK ************************************************* |
54 | 51 |
|
55 | 52 |
private static boolean checkArticlesWithoutJournal(BerlinModelImportConfigurator config){ |
... | ... | |
110 | 107 |
" (SELECT refId FROM %s ))" , config.getReferenceIdTable()) ; |
111 | 108 |
} |
112 | 109 |
|
113 |
|
|
114 | 110 |
ResultSet rs = source.getResultSet(strQuery); |
115 | 111 |
boolean firstRow = true; |
116 | 112 |
while (rs.next()){ |
... | ... | |
144 | 140 |
} |
145 | 141 |
} |
146 | 142 |
|
147 |
|
|
148 | 143 |
private static boolean checkPartOfUnresolved(BerlinModelImportConfigurator config){ |
149 | 144 |
try { |
150 | 145 |
boolean result = true; |
... | ... | |
489 | 484 |
Source source = config.getSource(); |
490 | 485 |
ResultSet rs = source.getResultSet(strQuery); |
491 | 486 |
int colCount = rs.getMetaData().getColumnCount(); |
492 |
Set<String> existingAttributes = new HashSet<String>();
|
|
487 |
Set<String> existingAttributes = new HashSet<>(); |
|
493 | 488 |
for (int c = 0; c < colCount ; c++){ |
494 | 489 |
existingAttributes.add(rs.getMetaData().getColumnLabel(c+1).toLowerCase()); |
495 | 490 |
} |
... | ... | |
557 | 552 |
return result; |
558 | 553 |
} |
559 | 554 |
|
560 |
|
|
561 |
/* (non-Javadoc) |
|
562 |
* @see eu.etaxonomy.cdm.io.common.IOValidator#validate(eu.etaxonomy.cdm.io.common.IoStateBase) |
|
563 |
*/ |
|
564 | 555 |
@Override |
565 | 556 |
@Deprecated //use validate(state, import) instead |
566 | 557 |
public boolean validate(BerlinModelImportState state) { |
567 | 558 |
logger.warn("BerlinModelReferenceImport uses wrong validation method"); |
568 | 559 |
return false; |
569 | 560 |
} |
570 |
|
|
571 |
|
|
572 |
|
|
573 | 561 |
} |
app-import/src/main/java/eu/etaxonomy/cdm/io/caryo/CaryoTaxonImport.java | ||
---|---|---|
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 |
*/ |
9 |
|
|
10 | 9 |
package eu.etaxonomy.cdm.io.caryo; |
11 | 10 |
|
12 | 11 |
import java.sql.ResultSet; |
... | ... | |
52 | 51 |
import eu.etaxonomy.cdm.model.taxon.TaxonBase; |
53 | 52 |
import eu.etaxonomy.cdm.strategy.exceptions.UnknownCdmTypeException; |
54 | 53 |
|
55 |
|
|
56 | 54 |
/** |
57 | 55 |
* @author a.mueller |
58 | 56 |
* @since 20.02.2010 |
59 | 57 |
*/ |
60 | 58 |
@Component |
61 | 59 |
public class CaryoTaxonImport extends DbImportBase<CaryoImportState, CaryoImportConfigurator> { |
62 |
private static final Logger logger = Logger.getLogger(CaryoTaxonImport.class); |
|
60 |
|
|
61 |
private static final long serialVersionUID = 5369739490456155285L; |
|
62 |
private static final Logger logger = Logger.getLogger(CaryoTaxonImport.class); |
|
63 | 63 |
|
64 | 64 |
private final int modCount = 10000; |
65 | 65 |
private static final String pluralString = "taxa"; |
66 | 66 |
private static final String dbTableName = "CARYOPHYLLALES"; |
67 | 67 |
|
68 |
|
|
69 |
|
|
70 |
private final Map<String, Taxon> familyMap = new HashMap<String, Taxon>(); |
|
71 |
private final Map<String, Person> personMap = new HashMap<String, Person>(); |
|
72 |
private final Map<String, Team> teamMap = new HashMap<String, Team>(); |
|
73 |
private final Map<String, TeamOrPersonBase> inAuthorMap = new HashMap<String, TeamOrPersonBase>(); |
|
74 |
private final Map<String, IJournal> journalMap = new HashMap<String, IJournal>(); |
|
75 |
private final Map<String, IBook> bookMap = new HashMap<String, IBook>(); |
|
76 |
|
|
68 |
private final Map<String, Taxon> familyMap = new HashMap<>(); |
|
69 |
private final Map<String, Person> personMap = new HashMap<>(); |
|
70 |
private final Map<String, Team> teamMap = new HashMap<>(); |
|
71 |
private final Map<String, TeamOrPersonBase> inAuthorMap = new HashMap<>(); |
|
72 |
private final Map<String, IJournal> journalMap = new HashMap<>(); |
|
73 |
private final Map<String, IBook> bookMap = new HashMap<>(); |
|
77 | 74 |
|
78 | 75 |
private Classification classification; |
79 | 76 |
|
80 |
|
|
81 |
|
|
82 | 77 |
public CaryoTaxonImport(){ |
83 | 78 |
super(dbTableName, pluralString); |
84 | 79 |
} |
85 | 80 |
|
86 |
|
|
87 |
|
|
88 |
|
|
89 |
/* (non-Javadoc) |
|
90 |
* @see eu.etaxonomy.cdm.io.common.DbImportBase#getIdQuery(eu.etaxonomy.cdm.io.common.DbImportStateBase) |
|
91 |
*/ |
|
92 | 81 |
@Override |
93 | 82 |
protected String getIdQuery(CaryoImportState state) { |
94 | 83 |
String strRecordQuery = |
... | ... | |
98 | 87 |
return strRecordQuery; |
99 | 88 |
} |
100 | 89 |
|
101 |
|
|
102 |
/* (non-Javadoc) |
|
103 |
* @see eu.etaxonomy.cdm.io.common.DbImportBase#getRecordQuery(eu.etaxonomy.cdm.io.common.DbImportConfiguratorBase) |
|
104 |
*/ |
|
105 | 90 |
@Override |
106 | 91 |
protected String getRecordQuery(CaryoImportConfigurator config) { |
107 | 92 |
String strRecordQuery = |
... | ... | |
111 | 96 |
return strRecordQuery; |
112 | 97 |
} |
113 | 98 |
|
114 |
|
|
115 |
|
|
116 |
/* (non-Javadoc) |
|
117 |
* @see eu.etaxonomy.cdm.io.globis.GlobisImportBase#doPartition(eu.etaxonomy.cdm.io.common.ResultSetPartitioner, eu.etaxonomy.cdm.io.globis.GlobisImportState) |
|
118 |
*/ |
|
119 | 99 |
@Override |
120 | 100 |
public boolean doPartition(ResultSetPartitioner partitioner, CaryoImportState state) { |
121 | 101 |
boolean success = true; |
122 | 102 |
|
123 |
Set<TaxonBase> objectsToSave = new HashSet<TaxonBase>(); |
|
124 |
|
|
125 |
// Map<String, Taxon> taxonMap = (Map<String, Taxon>) partitioner.getObjectMap(TAXON_NAMESPACE); |
|
126 |
|
|
103 |
Set<TaxonBase> objectsToSave = new HashSet<>(); |
|
127 | 104 |
|
128 | 105 |
classification = getClassification(state); |
129 | 106 |
|
... | ... | |
160 | 137 |
// ,[Basionym] |
161 | 138 |
// ,[OriginalCitation] |
162 | 139 |
|
163 |
|
|
164 | 140 |
IBotanicalName name = TaxonNameFactory.NewBotanicalInstance(Rank.GENUS()); |
165 | 141 |
name.setGenusOrUninomial(genus); |
166 | 142 |
makeAuthors(name, autoren, id); |
... | ... | |
169 | 145 |
name.setNomenclaturalMicroReference(pages); |
170 | 146 |
makeStatus(name, nomStatusStr, id); |
171 | 147 |
|
172 |
|
|
173 | 148 |
Taxon taxon = Taxon.NewInstance(name, state.getTransactionalSourceReference()); |
174 | 149 |
handleTypes(state, rs, taxon, typeStr, id); |
175 | 150 |
handleBasionym(state, rs, taxon, basioStr, id); |
... | ... | |
180 | 155 |
|
181 | 156 |
taxon.addSource(OriginalSourceType.Import, String.valueOf(taxonId), "NCUGenID", sec, null); |
182 | 157 |
|
183 |
|
|
184 |
|
|
185 | 158 |
objectsToSave.add(taxon); |
186 | 159 |
|
187 | 160 |
} |
... | ... | |
208 | 181 |
taxon.addSynonym(syn, SynonymType.HOMOTYPIC_SYNONYM_OF()); |
209 | 182 |
getTaxonService().save(syn); |
210 | 183 |
} |
211 |
|
|
212 | 184 |
} |
213 | 185 |
|
214 |
|
|
215 |
|
|
216 |
|
|
217 | 186 |
private void handleTypes(CaryoImportState state, ResultSet rs, Taxon taxon, String origType, Integer id) { |
218 | 187 |
NameTypeDesignation desig = NameTypeDesignation.NewInstance(); |
219 | 188 |
String type = origType; |
... | ... | |
264 | 233 |
} |
265 | 234 |
name.addTypeDesignation(desig, true); |
266 | 235 |
} |
267 |
|
|
268 |
|
|
269 | 236 |
} |
270 | 237 |
|
271 |
|
|
272 |
|
|
273 |
|
|
274 | 238 |
private String makeTypeNomStatus(IBotanicalName typeName, String type) { |
275 | 239 |
if (type.endsWith(", nom. illeg.")){ |
276 | 240 |
type = type.replaceAll(", nom. illeg.", ""); |
... | ... | |
279 | 243 |
return type; |
280 | 244 |
} |
281 | 245 |
|
282 |
|
|
283 |
|
|
284 |
|
|
285 | 246 |
private void makeStatus(IBotanicalName name, String nomStatusStr, Integer id) throws SQLException { |
286 |
// ,[NomenclaturalStatus] |
|
287 | 247 |
|
288 | 248 |
if (StringUtils.isNotBlank(nomStatusStr)){ |
289 | 249 |
NomenclaturalStatusType nomStatusType; |
... | ... | |
311 | 271 |
NomenclaturalStatus status = NomenclaturalStatus.NewInstance(nomStatusType); |
312 | 272 |
name.addStatus(status); |
313 | 273 |
} |
314 |
|
|
315 | 274 |
} |
316 | 275 |
|
317 |
|
|
318 |
|
|
319 |
|
|
320 | 276 |
private INomenclaturalReference makeNomRef(CaryoImportState state, ResultSet rs, Integer id) throws SQLException { |
321 | 277 |
INomenclaturalReference result; |
322 | 278 |
String periodicalTitle = rs.getString("PeriodicalTitle"); |
... | ... | |
387 | 343 |
ref.setDatePublished(tp); |
388 | 344 |
} |
389 | 345 |
|
390 |
|
|
391 |
|
|
392 |
|
|
393 | 346 |
private Integer[] getDay(String pre, Integer id) { |
394 | 347 |
Integer[] result = new Integer[2]; |
395 | 348 |
if (! StringUtils.isBlank(pre)){ |
... | ... | |
442 | 395 |
return result; |
443 | 396 |
} |
444 | 397 |
|
445 |
|
|
446 | 398 |
private TeamOrPersonBase<?> getInAuthor(String inAutorStr) { |
447 | 399 |
if (StringUtils.isBlank(inAutorStr)){ |
448 | 400 |
return null; |
... | ... | |
454 | 406 |
return inAuthor; |
455 | 407 |
} |
456 | 408 |
|
457 |
|
|
458 |
|
|
459 | 409 |
private void makeAuthors(IBotanicalName name, String autoren, Integer id) { |
460 | 410 |
String[] parsedAuthorTeams = getParsedAuthors(autoren); |
461 | 411 |
name.setBasionymAuthorship(getTeam(parsedAuthorTeams[0], id)); |
462 | 412 |
name.setExBasionymAuthorship(getTeam(parsedAuthorTeams[1], id)); |
463 | 413 |
name.setCombinationAuthorship(getTeam(parsedAuthorTeams[2], id)); |
464 | 414 |
name.setExCombinationAuthorship(getTeam(parsedAuthorTeams[3], id)); |
465 |
|
|
466 | 415 |
} |
467 | 416 |
|
468 | 417 |
private TeamOrPersonBase<?> getNomRefAuthor(String authorStr, Integer id) { |
... | ... | |
471 | 420 |
return team; |
472 | 421 |
} |
473 | 422 |
|
474 |
|
|
475 | 423 |
private TeamOrPersonBase<?> getTeam(String author, Integer id) { |
476 | 424 |
if (StringUtils.isBlank(author)){ |
477 | 425 |
return null; |
... | ... | |
488 | 436 |
return result; |
489 | 437 |
} |
490 | 438 |
|
491 |
|
|
492 | 439 |
private void doInAuthors(CaryoImportState state) throws SQLException { |
493 | 440 |
Source source = state.getConfig().getSource(); |
494 | 441 |
String sql = "SELECT DISTINCT inAutor FROM " + getTableName() + " WHERE inAutor IS NOT NULL AND inAutor <> '' "; |
... | ... | |
502 | 449 |
getAgentService().save(team); |
503 | 450 |
} |
504 | 451 |
} |
505 |
|
|
506 | 452 |
} |
507 | 453 |
|
508 |
|
|
509 | 454 |
private void doAuthors(CaryoImportState state) throws SQLException { |
510 | 455 |
Source source = state.getConfig().getSource(); |
511 | 456 |
String sql = "SELECT DISTINCT Autoren FROM " + getTableName() + " WHERE Autoren IS NOT NULL AND Autoren <> '' "; |
... | ... | |
520 | 465 |
} |
521 | 466 |
} |
522 | 467 |
|
523 |
|
|
524 |
|
|
525 |
|
|
526 | 468 |
private void doTypeAuthors(CaryoImportState state) { |
527 | 469 |
doTeam("Dinter & Derenb."); |
528 | 470 |
doTeam("Marloth"); |
... | ... | |
604 | 546 |
doTeam("Maerkl."); |
605 | 547 |
doTeam("Vierh."); |
606 | 548 |
doTeam("Exell"); |
607 |
|
|
608 | 549 |
} |
609 | 550 |
|
610 |
|
|
611 |
|
|
612 |
|
|
613 |
/** |
|
614 |
* @param teamStr |
|
615 |
* @return |
|
616 |
*/ |
|
617 | 551 |
protected void doTeam(String teamStr) { |
618 | 552 |
if (StringUtils.isBlank(teamStr)){ |
619 | 553 |
return; |
... | ... | |
655 | 589 |
return result; |
656 | 590 |
} |
657 | 591 |
|
658 |
|
|
659 |
|
|
660 |
|
|
661 | 592 |
private String[] getParsedAuthors(String autorenStr) { |
662 | 593 |
String[] result = new String[4]; |
663 | 594 |
String basioFull = null; |
... | ... | |
680 | 611 |
return result; |
681 | 612 |
} |
682 | 613 |
|
683 |
|
|
684 |
|
|
685 |
|
|
686 | 614 |
private String[] splitExAuthors(String author) { |
687 | 615 |
String[] result = new String[2]; |
688 | 616 |
if (author != null){ |
... | ... | |
697 | 625 |
return result; |
698 | 626 |
} |
699 | 627 |
|
700 |
|
|
701 |
|
|
702 |
|
|
703 | 628 |
private void doBooks(CaryoImportState state) throws SQLException { |
704 | 629 |
Source source = state.getConfig().getSource(); |
705 | 630 |
String sql = "SELECT DISTINCT BookTitle FROM " + getTableName() + " WHERE BookTitle IS NOT NULL AND BookTitle <> '' "; |
... | ... | |
718 | 643 |
} |
719 | 644 |
} |
720 | 645 |
|
721 |
|
|
722 |
|
|
723 |
|
|
724 | 646 |
private void doJournals(CaryoImportState state) throws SQLException { |
725 | 647 |
Source source = state.getConfig().getSource(); |
726 | 648 |
String sqlPeriodical = "SELECT DISTINCT PeriodicalTitle FROM " + getTableName() + " WHERE PeriodicalTitle IS NOT NULL AND PeriodicalTitle <> '' "; |
... | ... | |
739 | 661 |
} |
740 | 662 |
} |
741 | 663 |
|
742 |
|
|
743 |
|
|
744 |
|
|
745 | 664 |
private void doFamilies(CaryoImportState state) throws SQLException { |
746 | 665 |
Source source = state.getConfig().getSource(); |
747 | 666 |
String sqlFamily = "SELECT DISTINCT Family FROM " + getTableName() + " WHERE Family IS NOT NULL"; |
... | ... | |
760 | 679 |
getTaxonService().save(taxon); |
761 | 680 |
} |
762 | 681 |
} |
763 |
|
|
764 | 682 |
} |
765 | 683 |
|
766 | 684 |
private Classification getClassification(CaryoImportState state) { |
... | ... | |
776 | 694 |
return this.classification; |
777 | 695 |
} |
778 | 696 |
|
779 |
|
|
780 |
|
|
781 |
|
|
782 |
|
|
783 | 697 |
@Override |
784 | 698 |
public Map<Object, Map<String, ? extends CdmBase>> getRelatedObjectsForPartition(ResultSet rs, CaryoImportState state) { |
785 | 699 |
// String nameSpace; |
786 | 700 |
// Class cdmClass; |
787 | 701 |
// Set<String> idSet; |
788 |
Map<Object, Map<String, ? extends CdmBase>> result = new HashMap<Object, Map<String, ? extends CdmBase>>();
|
|
702 |
Map<Object, Map<String, ? extends CdmBase>> result = new HashMap<>(); |
|
789 | 703 |
// try{ |
790 |
// Set<String> taxonIdSet = new HashSet<String>();
|
|
704 |
// Set<String> taxonIdSet = new HashSet<>(); |
|
791 | 705 |
// |
792 | 706 |
// while (rs.next()){ |
793 | 707 |
//// handleForeignKey(rs, taxonIdSet, "taxonId"); |
... | ... | |
807 | 721 |
return result; |
808 | 722 |
} |
809 | 723 |
|
810 |
/* (non-Javadoc) |
|
811 |
* @see eu.etaxonomy.cdm.io.common.CdmIoBase#doCheck(eu.etaxonomy.cdm.io.common.IImportConfigurator) |
|
812 |
*/ |
|
813 | 724 |
@Override |
814 | 725 |
protected boolean doCheck(CaryoImportState state){ |
815 | 726 |
return true; |
816 | 727 |
} |
817 | 728 |
|
818 |
|
|
819 |
/* (non-Javadoc) |
|
820 |
* @see eu.etaxonomy.cdm.io.common.CdmIoBase#isIgnore(eu.etaxonomy.cdm.io.common.IImportConfigurator) |
|
821 |
*/ |
|
822 | 729 |
@Override |
823 | 730 |
protected boolean isIgnore(CaryoImportState state){ |
824 | 731 |
return ! state.getConfig().isDoTaxa(); |
825 | 732 |
} |
826 |
|
|
827 |
|
|
828 |
|
|
829 |
|
|
830 |
|
|
831 |
|
|
832 |
|
|
833 | 733 |
} |
app-import/src/main/java/eu/etaxonomy/cdm/io/cyprus/CyprusExcelImport.java | ||
---|---|---|
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 |
*/ |
9 |
|
|
10 | 9 |
package eu.etaxonomy.cdm.io.cyprus; |
11 | 10 |
|
12 | 11 |
import java.util.Arrays; |
... | ... | |
49 | 48 |
* @author a.babadshanjan |
50 | 49 |
* @since 08.01.2009 |
51 | 50 |
*/ |
52 |
|
|
53 | 51 |
@Component |
54 | 52 |
public class CyprusExcelImport |
55 | 53 |
extends ExcelImportBase<CyprusImportState, CyprusImportConfigurator, ExcelRowBase> { |
... | ... | |
58 | 56 |
|
59 | 57 |
private static final Logger logger = Logger.getLogger(CyprusExcelImport.class); |
60 | 58 |
|
61 |
public static Set<String> validMarkers = new HashSet<String>(Arrays.asList(new String[]{"", "valid", "accepted", "a", "v", "t"}));
|
|
62 |
public static Set<String> synonymMarkers = new HashSet<String>(Arrays.asList(new String[]{"", "invalid", "synonym", "s", "i"}));
|
|
59 |
public static Set<String> validMarkers = new HashSet<>(Arrays.asList(new String[]{"", "valid", "accepted", "a", "v", "t"})); |
|
60 |
public static Set<String> synonymMarkers = new HashSet<>(Arrays.asList(new String[]{"", "invalid", "synonym", "s", "i"})); |
|
63 | 61 |
|
64 | 62 |
|
65 | 63 |
@Override |
... | ... | |
67 | 65 |
return ! state.getConfig().isDoTaxa(); |
68 | 66 |
} |
69 | 67 |
|
70 |
|
|
71 |
/* (non-Javadoc) |
|
72 |
* @see eu.etaxonomy.cdm.io.common.CdmIoBase#doCheck(eu.etaxonomy.cdm.io.common.IoStateBase) |
|
73 |
*/ |
|
74 | 68 |
@Override |
75 | 69 |
protected boolean doCheck(CyprusImportState state) { |
76 | 70 |
logger.warn("DoCheck not yet implemented for CyprusExcelImport"); |
... | ... | |
91 | 85 |
protected static final String RED_DATA_BOOK_CATEGORY_COLUMN = "red data book category"; |
92 | 86 |
protected static final String SYSTEMATICS_COLUMN = "systematics"; |
93 | 87 |
|
94 |
|
|
95 |
|
|
96 | 88 |
// TODO: This enum is for future use (perhaps). |
97 | 89 |
protected enum Columns { |
98 | 90 |
// Id("Id"), |
... | ... | |
122 | 114 |
} |
123 | 115 |
} |
124 | 116 |
|
125 |
|
|
126 | 117 |
@Override |
127 | 118 |
protected void analyzeRecord(Map<String, String> record, CyprusImportState state) { |
128 | 119 |
|
... | ... | |
154 | 145 |
continue; |
155 | 146 |
} |
156 | 147 |
|
157 |
|
|
158 | 148 |
if (key.equalsIgnoreCase(SPECIES_COLUMN)) { |
159 | 149 |
// int ivalue = floatString2IntValue(value); |
160 | 150 |
cyprusRow.setSpecies(value); |
... | ... | |
231 | 221 |
getTermService().save(endemism); |
232 | 222 |
|
233 | 223 |
//status |
234 |
|
|
235 | 224 |
UUID indigenousUuid = transformer.getPresenceTermUuid("IN"); |
236 | 225 |
indigenous = this.getPresenceTerm(state, indigenousUuid, "indigenous", "Indigenous", "IN", false); |
237 | 226 |
getTermService().save(indigenous); |
... | ... | |
243 | 232 |
cultivatedDoubtful = this.getPresenceTerm(state, cultivatedDoubtfulUuid, "cultivated?", "Cultivated?", "CU?", false); |
244 | 233 |
getTermService().save(cultivatedDoubtful); |
245 | 234 |
|
246 |
|
|
247 | 235 |
UUID casualUuid = transformer.getPresenceTermUuid("CA"); |
248 | 236 |
casual = this.getPresenceTerm(state, casualUuid, "casual", "Casual", "CA", false); |
249 | 237 |
getTermService().save(casual); |
... | ... | |
251 | 239 |
casualDoubtful = this.getPresenceTerm(state, casualDoubtfulUuid, "casual?", "Casual?", "CA?", false); |
252 | 240 |
getTermService().save(casualDoubtful); |
253 | 241 |
|
254 |
|
|
255 | 242 |
UUID nonInvasiveUuid = transformer.getPresenceTermUuid("NN"); |
256 | 243 |
nonInvasive = this.getPresenceTerm(state, nonInvasiveUuid, "naturalized non-invasive", "Naturalized non-invasive", "NN", false); |
257 | 244 |
getTermService().save(nonInvasive); |
... | ... | |
349 | 336 |
return; |
350 | 337 |
} |
351 | 338 |
|
352 |
|
|
353 | 339 |
private void makeHigherTaxa(CyprusImportState state, CyprusRow taxonLight, Taxon speciesTaxon, Reference citation, String microCitation) { |
354 | 340 |
String divisionStr = taxonLight.getDivision(); |
355 | 341 |
String genusStr = taxonLight.getGenus(); |
... | ... | |
434 | 420 |
} |
435 | 421 |
} |
436 | 422 |
|
437 |
|
|
438 | 423 |
private void makeStatus(String statusString, Taxon mainTaxon) { |
439 | 424 |
//status |
440 | 425 |
if (StringUtils.isNotBlank(statusString)){ |
... | ... | |
483 | 468 |
} |
484 | 469 |
} |
485 | 470 |
|
486 |
|
|
487 | 471 |
private void makeRedBookCategory(String redBookCategory, Taxon mainTaxon) { |
488 | 472 |
//red data book category |
489 | 473 |
if (StringUtils.isNotBlank(redBookCategory)){ |
... | ... | |
494 | 478 |
} |
495 | 479 |
} |
496 | 480 |
|
497 |
|
|
498 |
|
|
499 |
|
|
500 | 481 |
/** |
501 | 482 |
* Stores parent-child, synonym and common name relationships |
502 | 483 |
*/ |
... | ... | |
506 | 487 |
return; |
507 | 488 |
} |
508 | 489 |
|
509 |
|
|
510 |
|
|
511 |
/** |
|
512 |
* @param state |
|
513 |
* @param rank |
|
514 |
* @param taxonNameStr |
|
515 |
* @param authorStr |
|
516 |
* @param nameStatus |
|
517 |
* @param nc |
|
518 |
* @return |
|
519 |
*/ |
|
520 | 490 |
private TaxonBase<?> createTaxon(CyprusImportState state, Rank rank, String taxonNameStr, |
521 | 491 |
Class<?> statusClass, NomenclaturalCode nc) { |
522 | 492 |
TaxonBase<?> taxonBase; |
... | ... | |
530 | 500 |
taxonNameBase = parser.parseFullName(taxonNameStr, nc, rank); |
531 | 501 |
|
532 | 502 |
//taxonNameBase.setNameCache(taxonNameStr); |
533 |
|
|
534 | 503 |
} |
535 | 504 |
|
536 | 505 |
//Create the taxon |
... | ... | |
565 | 534 |
} |
566 | 535 |
return success; |
567 | 536 |
} |
568 |
|
|
569 |
|
|
570 |
|
|
571 | 537 |
} |
app-import/src/main/java/eu/etaxonomy/cdm/io/globis/GlobisTransformer.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 |
*/ |
9 |
|
|
10 | 9 |
package eu.etaxonomy.cdm.io.globis; |
11 | 10 |
|
12 | 11 |
import java.util.HashSet; |
... | ... | |
21 | 20 |
import eu.etaxonomy.cdm.io.common.mapping.UndefinedTransformerMethodException; |
22 | 21 |
import eu.etaxonomy.cdm.model.common.ExtensionType; |
23 | 22 |
import eu.etaxonomy.cdm.model.description.Feature; |
24 |
import eu.etaxonomy.cdm.model.location.NamedArea; |
|
25 | 23 |
import eu.etaxonomy.cdm.model.location.Country; |
24 |
import eu.etaxonomy.cdm.model.location.NamedArea; |
|
26 | 25 |
|
27 | 26 |
/** |
28 | 27 |
* @author a.mueller |
29 | 28 |
* @since 01.03.2010 |
30 |
* @version 1.0 |
|
31 | 29 |
*/ |
32 | 30 |
public final class GlobisTransformer extends InputTransformerBase { |
33 |
private static final Logger logger = Logger.getLogger(GlobisTransformer.class); |
|
34 |
|
|
31 |
|
|
32 |
private static final long serialVersionUID = 8353340999086630728L; |
|
33 |
private static final Logger logger = Logger.getLogger(GlobisTransformer.class); |
|
35 | 34 |
|
36 | 35 |
//marker types |
37 | 36 |
public static final UUID uuidCheckedMarkerType = UUID.fromString("f2a7926f-def1-49a6-b642-9b81e6b1e35c"); |
38 | 37 |
public static final UUID uuidOldRecordMarkerType = UUID.fromString("8616edc5-00d4-40ca-aca4-d48ec32231e9"); |
39 | 38 |
public static final UUID uuidNotAvailableMarkerType = UUID.fromString("6931e584-6fc2-44ab-9084-e6452f8cd5d1"); |
40 |
|
|
39 |
|
|
41 | 40 |
//extension types |
42 | 41 |
public static final UUID uuidExtTypeNotAvailableReason = UUID.fromString("d7dd5632-8c65-4058-b804-d1291560ac4c"); |
43 |
|
|
44 |
public NamedArea getNamedAreaByKey(String area) { |
|
45 |
Set<String> unhandledCountries = new HashSet<String>(); |
|
46 |
|
|
42 |
|
|
43 |
@Override |
|
44 |
public NamedArea getNamedAreaByKey(String area) { |
|
45 |
Set<String> unhandledCountries = new HashSet<>(); |
|
46 |
|
|
47 | 47 |
if (StringUtils.isBlank(area)){return null; |
48 | 48 |
}else if (area.equals("Argentina")){return Country.ARGENTINAARGENTINEREPUBLIC(); |
49 | 49 |
}else if (area.equals("Bolivia")){return Country.BOLIVIAREPUBLICOF(); |
... | ... | |
60 | 60 |
}else if (area.equals("France")){return Country.FRANCEFRENCHREPUBLIC(); |
61 | 61 |
}else if (area.equals("Poland")){return Country.POLANDPOLISHPEOPLESREPUBLIC(); |
62 | 62 |
}else if (area.equals("Brazil")){return Country.BRAZILFEDERATIVEREPUBLICOF(); |
63 |
|
|
63 |
|
|
64 | 64 |
}else if (area.equals("Cuba")){return Country.BRAZILFEDERATIVEREPUBLICOF(); |
65 | 65 |
}else if (area.equals("Guatemala")){return Country.GUATEMALAREPUBLICOF(); |
66 | 66 |
}else if (area.equals("Colombia")){return Country.COLOMBIAREPUBLICOF(); |
67 | 67 |
}else if (area.equals("India")){return Country.INDIAREPUBLICOF(); |
68 |
|
|
68 |
|
|
69 | 69 |
}else if (area.equals("Mexico")){return Country.MEXICOUNITEDMEXICANSTATES(); |
70 | 70 |
}else if (area.equals("Peru")){return Country.PERUREPUBLICOF(); |
71 | 71 |
}else if (area.equals("Ecuador")){return Country.ECUADORREPUBLICOF(); |
... | ... | |
87 | 87 |
}else if (area.equals("Botswana")){return Country.BOTSWANAREPUBLICOF(); |
88 | 88 |
}else if (area.equals("Burundi")){return Country.BURUNDIREPUBLICOF(); |
89 | 89 |
}else if (area.equals("Cameroon")){return Country.CAMEROONUNITEDREPUBLICOF(); |
90 |
|
|
90 |
|
|
91 | 91 |
}else if (area.equals("Congo")){return Country.CONGOPEOPLESREPUBLICOF(); |
92 | 92 |
}else if (area.equals("Zaire")){return Country.CONGODEMOCRATICREPUBLICOF(); |
93 | 93 |
}else if (area.equals("Equatorial Guinea")){return Country.EQUATORIALGUINEAREPUBLICOF(); |
94 | 94 |
}else if (area.equals("Gabon")){return Country.GABONGABONESEREPUBLIC(); |
95 | 95 |
}else if (area.equals("Liberia")){return Country.LIBERIAREPUBLICOF(); |
96 |
|
|
96 |
|
|
97 | 97 |
}else if (area.equals("Togo")){return Country.TOGOTOGOLESEREPUBLIC(); |
98 | 98 |
}else if (area.equals("Guinea")){return Country.GUINEAREVOLUTIONARYPEOPLESREPCOF(); |
99 | 99 |
}else if (area.equals("Guinea-Bissau")){return Country.GUINEABISSAUREPUBLICOF(); |
100 |
|
|
100 |
|
|
101 | 101 |
}else if (area.equals("Malawi")){return Country.MALAWIREPUBLICOF(); |
102 | 102 |
}else if (area.equals("Mozambique")){return Country.MOZAMBIQUEPEOPLESREPUBLICOF(); |
103 | 103 |
}else if (area.equals("Nigeria")){return Country.NIGERIAFEDERALREPUBLICOF(); |
... | ... | |
106 | 106 |
}else if (area.equals("Sudan")){return Country.SUDANDEMOCRATICREPUBLICOFTHE(); |
107 | 107 |
}else if (area.equals("Madagascar")){return Country.MADAGASCARREPUBLICOF(); |
108 | 108 |
}else if (area.equals("Comoros")){return Country.COMOROSUNIONOFTHE(); |
109 |
|
|
109 |
|
|
110 | 110 |
}else if (area.equals("Vietnam")){return Country.VIETNAMSOCIALISTREPUBLICOF(); |
111 | 111 |
}else if (area.equals("Thailand")){return Country.THAILANDKINGDOMOF(); |
112 | 112 |
}else if (area.equals("Bhutan")){return Country.BHUTANKINGDOMOF(); |
... | ... | |
115 | 115 |
}else if (area.equals("Nepal")){return Country.NEPALKINGDOMOF(); |
116 | 116 |
}else if (area.equals("Pakistan")){return Country.PAKISTANISLAMICREPUBLICOF(); |
117 | 117 |
}else if (area.equals("Singapore")){return Country.SINGAPOREREPUBLICOF(); |
118 |
|
|
118 |
|
|
119 | 119 |
}else if (area.equals("Honduras")){return Country.HONDURASREPUBLICOF(); |
120 | 120 |
}else if (area.equals("Nicaragua")){return Country.NICARAGUAREPUBLICOF(); |
121 | 121 |
}else if (area.equals("Trinidad and Tobago")){return Country.TRINIDADANDTOBAGOREPUBLICOF(); |
... | ... | |
125 | 125 |
}else if (area.equals("North Korea")){return Country.KOREADEMOCRATICPEOPLESREPUBLICOF(); |
126 | 126 |
}else if (area.equals("South Korea")){return Country.KOREAREPUBLICOF(); |
127 | 127 |
}else if (area.equals("Taiwan")){return Country.TAIWANPROVINCEOFCHINA(); |
128 |
|
|
128 |
|
|
129 | 129 |
}else if (area.equals("Somalia")){return Country.SOMALIASOMALIREPUBLIC(); |
130 | 130 |
}else if (area.equals("Albania")){return Country.ALBANIAPEOPLESSOCIALISTREPUBLICOF(); |
131 | 131 |
}else if (area.equals("Algeria")){return Country.ALGERIAPEOPLESDEMOCRATICREPUBLICOF(); |
132 |
|
|
132 |
|
|
133 | 133 |
}else if (area.equals("Andorra")){return Country.ANDORRAPRINCIPALITYOF(); |
134 | 134 |
}else if (area.equals("Austria")){return Country.AUSTRIAREPUBLICOF(); |
135 | 135 |
}else if (area.equals("Azerbaijan")){return Country.AZERBAIJANREPUBLICOF(); |
... | ... | |
137 | 137 |
}else if (area.equals("Croatia")){return Country.HRVATSKA(); |
138 | 138 |
}else if (area.equals("Greece")){return Country.GREECEHELLENICREPUBLIC(); |
139 | 139 |
}else if (area.equals("Hungary")){return Country.HUNGARYHUNGARIANPEOPLESREPUBLIC(); |
140 |
|
|
140 |
|
|
141 | 141 |
}else if (area.equals("Iran")){return Country.IRANISLAMICREPUBLICOF(); |
142 | 142 |
}else if (area.equals("Iraq")){return Country.IRAQREPUBLICOF(); |
143 | 143 |
}else if (area.equals("Israel")){return Country.ISRAELSTATEOF(); |
... | ... | |
145 | 145 |
}else if (area.equals("Kazakhstan")){return Country.KAZAKHSTANREPUBLICOF(); |
146 | 146 |
}else if (area.equals("Kyrgyzstan")){return Country.KYRGYZREPUBLIC(); |
147 | 147 |
}else if (area.equals("Lebanon")){return Country.LEBANONLEBANESEREPUBLIC(); |
148 |
|
|
148 |
|
|
149 | 149 |
}else if (area.equals("Luxembourg")){return Country.LUXEMBOURGGRANDDUCHYOF(); |
150 | 150 |
}else if (area.equals("Macedonia")){return Country.MACEDONIATHEFORMERYUGOSLAVREPUBLICOF(); |
151 | 151 |
}else if (area.equals("Moldova")){return Country.MOLDOVAREPUBLICOF(); |
... | ... | |
154 | 154 |
}else if (area.equals("Serbia")){return Country.SERBIAANDMONTENEGRO(); |
155 | 155 |
}else if (area.equals("Slovakia")){return Country.SLOVAKIA(); |
156 | 156 |
}else if (area.equals("Spain")){return Country.SPAINSPANISHSTATE(); |
157 |
|
|
157 |
|
|
158 | 158 |
}else if (area.equals("Switzerland")){return Country.SWITZERLANDSWISSCONFEDERATION(); |
159 | 159 |
}else if (area.equals("Syria")){return Country.SYRIANARABREPUBLIC(); |
160 | 160 |
}else if (area.equals("Turkey")){return Country.TURKEYREPUBLICOF(); |
161 | 161 |
}else if (area.equals("Cambodia")){return Country.CAMBODIAKINGDOMOF(); |
162 | 162 |
}else if (area.equals("Bangladesh")){return Country.BANGLADESHPEOPLESREPUBLICOF(); |
163 |
|
|
163 |
|
|
164 | 164 |
}else if (area.equals("Sri Lanka")){return Country.SRILANKADEMOCRATICSOCIALISTREPUBLICOF(); |
165 | 165 |
}else if (area.equals("Bahamas")){return Country.BAHAMASCOMMONWEALTHOFTHE(); |
166 | 166 |
}else if (area.equals("Western Samoa")){return Country.SAMOAINDEPENDENTSTATEOF(); |
... | ... | |
188 | 188 |
}else if (area.matches("B(y)?elarus")){return Country.BELARUS(); |
189 | 189 |
}else if (area.equals("Turkey")){return Country.TURKEYREPUBLICOF(); |
190 | 190 |
}else if (area.equals("Turkmenistan")){return Country.TURKMENISTAN(); |
191 |
|
|
191 |
|
|
192 | 192 |
}else if (area.matches("United States: Alaska")){ return TdwgAreaProvider.getAreaByTdwgAbbreviation("ASK"); |
193 |
|
|
194 |
|
|
195 |
}else{ |
|
193 |
|
|
194 |
}else{ |
|
196 | 195 |
if (unhandledCountries.contains(area)){ |
197 | 196 |
logger.warn("Unhandled country '" + area + "' replaced by null" ); |
198 | 197 |
return null; |
199 | 198 |
} |
200 | 199 |
return null; |
201 |
|
|
202 | 200 |
} |
203 |
|
|
204 | 201 |
} |
205 |
|
|
206 |
/* (non-Javadoc) |
|
207 |
* @see eu.etaxonomy.cdm.io.common.mapping.InputTransformerBase#getLanguageUuid(java.lang.String) |
|
208 |
*/ |
|
202 |
|
|
209 | 203 |
@Override |
210 | 204 |
public UUID getLanguageUuid(String key) |
211 | 205 |
throws UndefinedTransformerMethodException { |
212 | 206 |
return super.getLanguageUuid(key); |
213 | 207 |
} |
214 |
|
|
215 |
|
|
216 |
|
|
217 |
|
|
218 |
|
|
219 |
|
|
220 |
/* (non-Javadoc) |
|
221 |
* @see eu.etaxonomy.cdm.io.common.mapping.InputTransformerBase#getExtensionTypeByKey(java.lang.String) |
|
222 |
*/ |
|
208 |
|
|
223 | 209 |
@Override |
224 | 210 |
public ExtensionType getExtensionTypeByKey(String key) throws UndefinedTransformerMethodException { |
225 | 211 |
if (key == null){return null; |
... | ... | |
227 | 213 |
return null; |
228 | 214 |
} |
229 | 215 |
|
230 |
/* (non-Javadoc) |
|
231 |
* @see eu.etaxonomy.cdm.io.common.mapping.InputTransformerBase#getExtensionTypeUuid(java.lang.String) |
|
232 |
*/ |
|
233 | 216 |
@Override |
234 | 217 |
public UUID getExtensionTypeUuid(String key) |
235 | 218 |
throws UndefinedTransformerMethodException { |
... | ... | |
240 | 223 |
} |
241 | 224 |
return null; |
242 | 225 |
} |
243 |
|
|
244 |
/* (non-Javadoc) |
|
245 |
* @see eu.etaxonomy.cdm.io.common.mapping.InputTransformerBase#getExtensionTypeUuid(java.lang.String) |
|
246 |
*/ |
|
226 |
|
|
247 | 227 |
@Override |
248 | 228 |
public UUID getMarkerTypeUuid(String key) |
249 | 229 |
throws UndefinedTransformerMethodException { |
... | ... | |
251 | 231 |
}else if (key.equalsIgnoreCase("old record")){return uuidOldRecordMarkerType; |
252 | 232 |
}else if (key.equalsIgnoreCase("checked")){return uuidCheckedMarkerType; |
253 | 233 |
}else if (key.equalsIgnoreCase("not available")){return uuidNotAvailableMarkerType; |
254 |
|
|
234 |
|
|
255 | 235 |
} |
256 | 236 |
return null; |
257 | 237 |
} |
258 | 238 |
|
259 |
|
|
260 |
|
|
261 |
/* (non-Javadoc) |
|
262 |
* @see eu.etaxonomy.cdm.io.common.mapping.InputTransformerBase#getFeatureByKey(java.lang.String) |
|
263 |
*/ |
|
264 | 239 |
@Override |
265 | 240 |
public Feature getFeatureByKey(String key) throws UndefinedTransformerMethodException { |
266 | 241 |
if (StringUtils.isBlank(key)){return null; |
... | ... | |
273 | 248 |
return null; |
274 | 249 |
} |
275 | 250 |
} |
276 |
|
|
277 |
|
|
278 |
|
|
279 |
|
|
280 | 251 |
} |
app-import/src/main/java/eu/etaxonomy/cdm/io/redlist/gefaesspflanzen/RedListGefaesspflanzenImportClassification.java | ||
---|---|---|
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 |
*/ |
9 |
|
|
10 | 9 |
package eu.etaxonomy.cdm.io.redlist.gefaesspflanzen; |
11 | 10 |
|
12 | 11 |
import java.sql.ResultSet; |
... | ... | |
89 | 88 |
super.doInvoke(state); |
90 | 89 |
} |
91 | 90 |
|
92 |
|
|
93 | 91 |
private void importFamilies(Classification gesamtListe, Classification checkliste, RedListGefaesspflanzenImportState state) { |
94 | 92 |
for(UUID uuid:state.getFamilyMap().values()){ |
95 | 93 |
Taxon family = HibernateProxyHelper.deproxy(getTaxonService().load(uuid, true, Arrays.asList(new String[]{"*"})), Taxon.class); |
... | ... | |
229 | 227 |
addTaxonToClassification(classificationS, RedListUtil.CLASSIFICATION_NAMESPACE_S, relationS, taxonBase, id, state); |
230 | 228 |
} |
231 | 229 |
|
232 |
|
|
233 |
|
|
234 | 230 |
private void addTaxonToClassification(Classification classification, String classificationNamespace, String relationString, final TaxonBase<?> gesamtListeTaxon, long id, RedListGefaesspflanzenImportState state){ |
235 | 231 |
Taxon taxon = HibernateProxyHelper.deproxy(state.getRelatedObject(classificationNamespace, String.valueOf(id), TaxonBase.class), Taxon.class); |
236 | 232 |
//add concept relation to gesamtliste/checkliste |
... | ... | |
338 | 334 |
RedListGefaesspflanzenImportState state) { |
339 | 335 |
Map<Object, Map<String, ? extends CdmBase>> result = new HashMap<>(); |
340 | 336 |
|
341 |
Set<String> idSet = new HashSet<String>();
|
|
337 |
Set<String> idSet = new HashSet<>(); |
|
342 | 338 |
try { |
343 | 339 |
while (rs.next()){ |
344 | 340 |
idSet.add(String.valueOf(rs.getLong(RedListUtil.NAMNR))); |
Also available in: Unified diff
cleanup