Revision 2cab5074
Added by Andreas Müller almost 7 years ago
app-import/src/main/java/eu/etaxonomy/cdm/app/cyprus/CyprusImagesActivator.java | ||
---|---|---|
65 | 65 |
|
66 | 66 |
/** |
67 | 67 |
* @author a.mueller |
68 |
* @created 16.12.2010
|
|
68 |
* @created 05.2017
|
|
69 | 69 |
*/ |
70 | 70 |
public class CyprusImagesActivator { |
71 | 71 |
private static final Logger logger = Logger.getLogger(CyprusImagesActivator.class); |
72 | 72 |
|
73 |
//database validation status (create, update, validate ...) |
|
74 |
static DbSchemaValidation hbm2dll = DbSchemaValidation.VALIDATE; |
|
75 | 73 |
|
76 | 74 |
// static final ICdmDataSource cdmDestination = CdmDestinations.cdm_cyprus_dev(); |
77 | 75 |
static final ICdmDataSource cdmDestination = CdmDestinations.cdm_cyprus_production(); |
78 | 76 |
|
79 |
static boolean testOnly = false;
|
|
77 |
static boolean testOnly = true;
|
|
80 | 78 |
static boolean update_notCreate = true; |
79 |
//if true, data will always be updated, if false, only missing data will be updated |
|
81 | 80 |
static boolean forceUpdate = false; |
82 | 81 |
|
83 | 82 |
private static final String path = "//media/digitalimages/EditWP6/Zypern/photos/"; |
... | ... | |
88 | 87 |
|
89 | 88 |
private void doImport(ICdmDataSource cdmDestination){ |
90 | 89 |
|
91 |
CdmApplicationController app = CdmIoApplicationController.NewInstance(cdmDestination, hbm2dll);
|
|
90 |
CdmApplicationController app = CdmIoApplicationController.NewInstance(cdmDestination, DbSchemaValidation.VALIDATE);
|
|
92 | 91 |
TransactionStatus tx = app.startTransaction(); |
93 | 92 |
|
94 |
deduplicationHelper = (ImportDeduplicationHelper<SimpleExcelTaxonImportState<?>>)ImportDeduplicationHelper.NewInstance(app);
|
|
93 |
deduplicationHelper = (ImportDeduplicationHelper)ImportDeduplicationHelper.NewInstance(app); |
|
95 | 94 |
|
96 | 95 |
File file = new File(path); |
97 | 96 |
String[] fileList = file.list(); |
... | ... | |
447 | 446 |
List<TaxonBase> list = app.getTaxonService().findTaxaByName(config); |
448 | 447 |
if (list.isEmpty()){ |
449 | 448 |
// logger.warn("Taxon not found for media: " + taxonNameStr); |
450 |
taxonNameStr = taxonNameStr.replaceFirst(" ", UTF8.HYBRID.toString() + " "); |
|
449 |
taxonNameStr = taxonNameStr.replaceFirst(" ", " " + UTF8.HYBRID.toString()); |
|
450 |
config.setTaxonNameTitle(taxonNameStr); |
|
451 | 451 |
list = app.getTaxonService().findTaxaByName(config); |
452 | 452 |
if (list.isEmpty()){ |
453 | 453 |
return null; |
... | ... | |
517 | 517 |
} |
518 | 518 |
|
519 | 519 |
private void updateMetadata(ICdmDataSource cdmDestination){ |
520 |
CdmApplicationController app = CdmIoApplicationController.NewInstance(cdmDestination, hbm2dll);
|
|
520 |
CdmApplicationController app = CdmIoApplicationController.NewInstance(cdmDestination, DbSchemaValidation.VALIDATE);
|
|
521 | 521 |
TransactionStatus tx = app.startTransaction(); |
522 | 522 |
|
523 | 523 |
deduplicationHelper = (ImportDeduplicationHelper<SimpleExcelTaxonImportState<?>>)ImportDeduplicationHelper.NewInstance(app); |
... | ... | |
527 | 527 |
String fileName = getUrlStringForMedia(media); |
528 | 528 |
if (fileName.startsWith(urlPath)){ |
529 | 529 |
fileName = fileName.replace(urlPath, ""); |
530 |
// System.out.println(fileName); |
|
531 |
// makeMetaData(media, fileName, true); |
|
532 |
makeTitle(media, fileName, true); |
|
530 |
if (fileName.equals("Acinos_exiguus_C1.jpg")){ //for debugging only |
|
531 |
// System.out.println(fileName); |
|
532 |
makeMetaData(media, fileName, true); |
|
533 |
makeTitle(media, fileName, true); |
|
534 |
} |
|
533 | 535 |
}else{ |
534 | 536 |
logger.warn("Filename does not start with standard url path: " + fileName); |
535 | 537 |
} |
app-import/src/main/java/eu/etaxonomy/cdm/io/greece/FloraHellenicaExcludedTaxonImport.java | ||
---|---|---|
17 | 17 |
import org.springframework.stereotype.Component; |
18 | 18 |
|
19 | 19 |
import eu.etaxonomy.cdm.io.mexico.SimpleExcelTaxonImportState; |
20 |
import eu.etaxonomy.cdm.model.agent.Person; |
|
21 |
import eu.etaxonomy.cdm.model.common.TimePeriod; |
|
20 | 22 |
import eu.etaxonomy.cdm.model.name.IBotanicalName; |
21 | 23 |
import eu.etaxonomy.cdm.model.name.INonViralName; |
22 | 24 |
import eu.etaxonomy.cdm.model.name.NomenclaturalCode; |
... | ... | |
24 | 26 |
import eu.etaxonomy.cdm.model.name.TaxonNameBase; |
25 | 27 |
import eu.etaxonomy.cdm.model.name.TaxonNameFactory; |
26 | 28 |
import eu.etaxonomy.cdm.model.reference.Reference; |
29 |
import eu.etaxonomy.cdm.model.reference.ReferenceFactory; |
|
27 | 30 |
import eu.etaxonomy.cdm.model.taxon.Classification; |
28 | 31 |
import eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode; |
29 | 32 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
... | ... | |
108 | 111 |
} |
109 | 112 |
|
110 | 113 |
String taxonStr = getValue(record, TAXON); |
114 |
Reference sec = getSecReference(state); |
|
115 |
if (taxonStr.endsWith(" sec. Hayek 1929")){ |
|
116 |
sec = makeHayek1929(); |
|
117 |
taxonStr = taxonStr.substring(0, taxonStr.length() - " sec. Hayek 1929".length()).trim(); |
|
118 |
} |
|
119 |
boolean isSensuStrictu = false; |
|
120 |
if (taxonStr.endsWith("s.str.")){ |
|
121 |
isSensuStrictu = true; |
|
122 |
taxonStr = taxonStr.substring(0, taxonStr.length() - "s.str.".length() ).trim(); |
|
123 |
} |
|
111 | 124 |
INonViralName name = parser.parseFullName(taxonStr, NomenclaturalCode.ICNAFP, null); |
112 | 125 |
name = replaceNameAuthorsAndReferences(state, name); |
113 | 126 |
if (name.isProtectedTitleCache()){ |
114 | 127 |
logger.warn(line + "Name could not be parsed: " + taxonStr); |
115 | 128 |
} |
116 | 129 |
|
117 |
Taxon taxon = Taxon.NewInstance(name, getSecReference(state)); |
|
130 |
Taxon taxon = Taxon.NewInstance(name, sec); |
|
131 |
if (isSensuStrictu){ |
|
132 |
taxon.setAppendedPhrase("s.str."); |
|
133 |
} |
|
118 | 134 |
taxon.addImportSource(noStr, getWorksheetName(), getSourceCitation(state), null); |
119 | 135 |
TaxonNode excludedNode = familyTaxonNode.addChildTaxon(taxon, getSecReference(state), null); |
120 | 136 |
excludedNode.setExcluded(true); |
... | ... | |
125 | 141 |
|
126 | 142 |
|
127 | 143 |
/** |
144 |
* @return |
|
145 |
*/ |
|
146 |
private Reference makeHayek1929() { |
|
147 |
Reference ref = ReferenceFactory.newGeneric(); |
|
148 |
Person hayek = Person.NewInstance(); |
|
149 |
hayek.setLastname("Hayek"); |
|
150 |
ref.setAuthorship(hayek); |
|
151 |
ref.setDatePublished(TimePeriod.NewInstance(1929)); |
|
152 |
return ref; |
|
153 |
} |
|
154 |
|
|
155 |
|
|
156 |
/** |
|
128 | 157 |
* @param record |
129 | 158 |
* @param state |
130 | 159 |
* @return |
app-import/src/main/java/eu/etaxonomy/cdm/io/greece/FloraHellenicaImageImport.java | ||
---|---|---|
37 | 37 |
import eu.etaxonomy.cdm.model.description.TaxonDescription; |
38 | 38 |
import eu.etaxonomy.cdm.model.description.TextData; |
39 | 39 |
import eu.etaxonomy.cdm.model.media.Media; |
40 |
import eu.etaxonomy.cdm.model.media.Rights; |
|
41 |
import eu.etaxonomy.cdm.model.media.RightsType; |
|
40 | 42 |
import eu.etaxonomy.cdm.model.reference.Reference; |
41 | 43 |
import eu.etaxonomy.cdm.model.taxon.Synonym; |
42 | 44 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
... | ... | |
168 | 170 |
person = (Person)deduplicationHelper.getExistingAuthor(state, person); |
169 | 171 |
|
170 | 172 |
media.setArtist(person); |
173 |
//copyright |
|
174 |
Rights right = Rights.NewInstance(); |
|
175 |
right.setType(RightsType.COPYRIGHT()); |
|
176 |
right.setAgent(person); |
|
177 |
right = deduplicationHelper.getExistingCopyright(state, right); |
|
178 |
media.addRights(right); |
|
171 | 179 |
} |
172 | 180 |
|
173 | 181 |
String detail = "p. " + FloraHellenicaImageCaptionImport.startPage + 1 + plate *2; |
app-import/src/main/java/eu/etaxonomy/cdm/io/greece/FloraHellenicaSynonymImport.java | ||
---|---|---|
146 | 146 |
|
147 | 147 |
TaxonBase<?> result; |
148 | 148 |
if (isMisapplied){ |
149 |
result = Taxon.NewInstance(name, getMisappliedRef(state, parsedSynStr[1])); |
|
149 |
Reference sec = null;// getMisappliedRef(state, parsedSynStr[1]); |
|
150 |
result = Taxon.NewInstance(name, sec); |
|
151 |
result.setAppendedPhrase(getMisappliedRef(state, parsedSynStr[1])); |
|
150 | 152 |
acceptedTaxon.addMisappliedName((Taxon)result, getSecReference(state), null); |
151 | 153 |
if (isNec){ |
152 | 154 |
logger.warn(line + "nec for misapplied names still needs to be checked: " + synonymStr); |
... | ... | |
228 | 230 |
* @param string |
229 | 231 |
* @return |
230 | 232 |
*/ |
231 |
private Reference getMisappliedRef(SimpleExcelTaxonImportState<CONFIG> state, String refString) { |
|
233 |
private String getMisappliedRef(SimpleExcelTaxonImportState<CONFIG> state, String refString) { |
|
234 |
// if ("fl. graec.".equals(refString)){ |
|
235 |
// return flGraecReference; |
|
236 |
// }else if ("balc.".equals(refString)){ |
|
237 |
// return balkanReference; |
|
232 | 238 |
if ("fl. graec.".equals(refString)){ |
233 |
return flGraecReference;
|
|
239 |
return "auct. fl. graec.";
|
|
234 | 240 |
}else if ("balc.".equals(refString)){ |
235 |
return balkanReference;
|
|
241 |
return "auct. balc.";
|
|
236 | 242 |
}else{ |
237 | 243 |
logger.warn("Auct. reference not recognized: " + refString); |
238 | 244 |
return null; |
app-import/src/main/java/eu/etaxonomy/cdm/io/greece/FloraHellenicaTaxonImport.java | ||
---|---|---|
387 | 387 |
} |
388 | 388 |
|
389 | 389 |
String nameStr = CdmUtils.concat(" ", nameParts); |
390 |
boolean isSensuStrictu = false; |
|
391 |
if (nameStr.endsWith("s.str.")){ |
|
392 |
isSensuStrictu = true; |
|
393 |
nameStr = nameStr.substring(0, nameStr.length() - "s.str.".length() ).trim(); |
|
394 |
} |
|
390 | 395 |
Rank rank = isSubSpecies ? Rank.SUBSPECIES() : Rank.SPECIES(); |
391 | 396 |
BotanicalName name = (BotanicalName)parser.parseFullName(nameStr, state.getConfig().getNomenclaturalCode(), rank); |
392 | 397 |
if (name.isProtectedTitleCache()){ |
... | ... | |
396 | 401 |
|
397 | 402 |
Taxon taxon = Taxon.NewInstance(name, getSecReference(state)); |
398 | 403 |
taxon.addImportSource(noStr, getWorksheetName(), getSourceCitation(state), null); |
404 |
if (isSensuStrictu){ |
|
405 |
taxon.setAppendedPhrase("s.str."); |
|
406 |
} |
|
399 | 407 |
String parentStr = isSubSpecies ? |
400 | 408 |
makeSpeciesKey(genusStr, speciesStr, speciesAuthorStr) : genusStr; |
401 | 409 |
taxon.setUuid(uuid); |
app-import/src/main/java/eu/etaxonomy/cdm/io/greece/FloraHellenicaTermImport.java | ||
---|---|---|
326 | 326 |
*/ |
327 | 327 |
private void addLifeform(SimpleExcelTaxonImportState<FloraHellenicaImportConfigurator> state, |
328 | 328 |
OrderedTermVocabulary<State> lifeformVoc, String abbrevLabel, String label, UUID uuidlifeform) { |
329 |
State lifeForm = addState(state, abbrevLabel, label, label, uuidlifeform, lifeformVoc);
|
|
329 |
addState(state, abbrevLabel, label, label, uuidlifeform, lifeformVoc); |
|
330 | 330 |
} |
331 | 331 |
|
332 | 332 |
|
Also available in: Unified diff
latest FloraHellenica changes and CyprusImage import