Revision aea90ab7
Added by Andreas Müller almost 7 years ago
app-import/src/main/java/eu/etaxonomy/cdm/app/greece/FloraHellenicaActivator.java | ||
---|---|---|
14 | 14 |
import org.apache.log4j.Logger; |
15 | 15 |
|
16 | 16 |
import eu.etaxonomy.cdm.app.common.CdmDestinations; |
17 |
import eu.etaxonomy.cdm.common.DOI; |
|
17 | 18 |
import eu.etaxonomy.cdm.database.DbSchemaValidation; |
18 | 19 |
import eu.etaxonomy.cdm.database.ICdmDataSource; |
19 | 20 |
import eu.etaxonomy.cdm.io.common.CdmDefaultImport; |
20 | 21 |
import eu.etaxonomy.cdm.io.common.IImportConfigurator.CHECK; |
21 | 22 |
import eu.etaxonomy.cdm.io.greece.FloraHellenicaImportConfigurator; |
23 |
import eu.etaxonomy.cdm.model.agent.Person; |
|
24 |
import eu.etaxonomy.cdm.model.agent.Team; |
|
25 |
import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase; |
|
26 |
import eu.etaxonomy.cdm.model.reference.Reference; |
|
27 |
import eu.etaxonomy.cdm.model.reference.ReferenceFactory; |
|
28 |
import eu.etaxonomy.cdm.strategy.parser.TimePeriodParser; |
|
22 | 29 |
|
23 | 30 |
/** |
24 | 31 |
* |
... | ... | |
42 | 49 |
|
43 | 50 |
//feature tree uuid |
44 | 51 |
public static final UUID featureTreeUuid = UUID.fromString("9e1e0e81-7475-4b28-8619-b7f42cd760b6"); |
45 |
private static final String featureTreeTitle = "Flora Hellenica dataportal feature tree";
|
|
52 |
private static final String featureTreeTitle = "Flora of Greece dataportal feature tree";
|
|
46 | 53 |
|
47 | 54 |
//classification |
48 | 55 |
static final UUID classificationUuid = UUID.fromString("e537d69a-c2d9-4ac6-8f79-5b5e3dd5c154"); |
49 |
private static final String classificationName = "Greek Checklist";
|
|
56 |
private static final String classificationName = "Vascular plants of Greece";
|
|
50 | 57 |
|
51 | 58 |
|
52 | 59 |
//check - import |
... | ... | |
61 | 68 |
URI source = greekChecklist(); //just any |
62 | 69 |
|
63 | 70 |
//make Source |
64 |
FloraHellenicaImportConfigurator config= FloraHellenicaImportConfigurator.NewInstance(source, cdmDestination); |
|
71 |
FloraHellenicaImportConfigurator config = FloraHellenicaImportConfigurator.NewInstance(source, cdmDestination);
|
|
65 | 72 |
config.setClassificationUuid(classificationUuid); |
66 | 73 |
config.setClassificationName(classificationName); |
67 | 74 |
config.setCheck(check); |
68 |
// config.setDoDistribution(doDistribution); |
|
69 |
// config.setDoTaxa(doTaxa); |
|
70 | 75 |
config.setDbSchemaValidation(hbm2dll); |
71 |
// config.setSourceReferenceTitle(sourceReferenceTitle); |
|
72 |
// config.setDoVocabularies(doVocabularies); |
|
73 | 76 |
config.setUuidFeatureTree(featureTreeUuid); |
74 | 77 |
config.setFeatureTreeTitle(featureTreeTitle); |
75 | 78 |
config.setDoImages(doImages); |
79 |
config.setSecReference(getSecReference()); |
|
80 |
config.setSourceReference(getSourceReference()); |
|
81 |
config.setSecReference2(getSecReference2()); |
|
76 | 82 |
|
77 | 83 |
CdmDefaultImport<FloraHellenicaImportConfigurator> myImport = new CdmDefaultImport<>(); |
78 | 84 |
myImport.invoke(config); |
79 | 85 |
|
80 |
// FeatureTree tree = makeFeatureNodes(myImport.getCdmAppController().getTermService()); |
|
81 |
// myImport.getCdmAppController().getFeatureTreeService().saveOrUpdate(tree); |
|
82 | 86 |
} |
83 | 87 |
|
84 | 88 |
|
... | ... | |
86 | 90 |
return URI.create("file:////BGBM-PESIHPC/Greece/VPG_FINAL_WITH_SYNONYMS_21.01.2017.xlsx"); |
87 | 91 |
} |
88 | 92 |
|
93 |
private Reference secRef; |
|
94 |
private Reference getSecReference(){ |
|
95 |
if (secRef != null){ |
|
96 |
return secRef; |
|
97 |
} |
|
98 |
Reference result = ReferenceFactory.newBook(); |
|
99 |
result.setTitle("Vascular plants of Greece: An annotated checklist."); |
|
100 |
result.setDatePublished(TimePeriodParser.parseString("2013")); |
|
101 |
|
|
102 |
Team team = Team.NewInstance(); |
|
103 |
|
|
104 |
Person person = Person.NewInstance(); |
|
105 |
person.setFirstname("P."); |
|
106 |
person.setLastname("Dimopoulos"); |
|
107 |
team.addTeamMember(person); |
|
108 |
|
|
109 |
person = Person.NewInstance(); |
|
110 |
person.setFirstname("Th."); |
|
111 |
person.setLastname("Raus"); |
|
112 |
team.addTeamMember(person); |
|
113 |
|
|
114 |
person = Person.NewInstance(); |
|
115 |
person.setFirstname("E."); |
|
116 |
person.setLastname("Bergmeier"); |
|
117 |
team.addTeamMember(person); |
|
118 |
|
|
119 |
person = Person.NewInstance(); |
|
120 |
person.setFirstname("Th."); |
|
121 |
person.setLastname("Constantinidis"); |
|
122 |
team.addTeamMember(person); |
|
123 |
|
|
124 |
person = Person.NewInstance(); |
|
125 |
person.setFirstname("G."); |
|
126 |
person.setLastname("Iatrou"); |
|
127 |
team.addTeamMember(person); |
|
128 |
|
|
129 |
person = Person.NewInstance(); |
|
130 |
person.setFirstname("S."); |
|
131 |
person.setLastname("Kokkini"); |
|
132 |
team.addTeamMember(person); |
|
133 |
|
|
134 |
person = Person.NewInstance(); |
|
135 |
person.setFirstname("A."); |
|
136 |
person.setLastname("Strid"); |
|
137 |
team.addTeamMember(person); |
|
138 |
|
|
139 |
person = Person.NewInstance(); |
|
140 |
person.setFirstname("D."); |
|
141 |
person.setLastname("Tzanoudakis"); |
|
142 |
team.addTeamMember(person); |
|
143 |
|
|
144 |
result.setAuthorship(team); |
|
145 |
|
|
146 |
result.setPublisher("Berlin: Botanic Garden and Botanical Museum Berlin-Dahlem; Athens: Hellenic Botanical Society."); |
|
147 |
|
|
148 |
result.setVolume("31"); |
|
149 |
Reference englera = ReferenceFactory.newPrintSeries(); |
|
150 |
englera.setTitle("Englera"); |
|
151 |
result.setInReference(englera); |
|
152 |
secRef = result; |
|
153 |
return result; |
|
154 |
} |
|
155 |
|
|
156 |
private Reference getSecReference2(){ |
|
157 |
Reference result = ReferenceFactory.newArticle(); |
|
158 |
result.setTitle("Vascular plants of Greece: An annotated checklist. Supplement"); |
|
159 |
result.setDatePublished(TimePeriodParser.parseString("26.10.2016")); |
|
160 |
|
|
161 |
TeamOrPersonBase<?> team = getSecReference().getAuthorship(); |
|
162 |
result.setAuthorship(team); |
|
163 |
|
|
164 |
result.setPublisher("Berlin: Botanic Garden and Botanical Museum Berlin-Dahlem; Athens: Hellenic Botanical Society."); |
|
165 |
|
|
166 |
result.setVolume("46(3)"); |
|
167 |
result.setPages("301–347"); |
|
168 |
Reference journal = ReferenceFactory.newJournal(); |
|
169 |
journal.setTitle("Willdenowia"); |
|
170 |
result.setInReference(journal); |
|
171 |
result.setDoi(DOI.fromString("http://dx.doi.org/10.3372/wi.46.46303")); |
|
172 |
result.setReferenceAbstract("Supplementary information on taxonomy, nomenclature, distribution within Greece, total range, life form and ecological traits of vascular plants known to occur in Greece is presented and the revised data are quantitatively analysed. Floristic discrepancies between Vascular plants of Greece: An annotated checklist (Dimopoulos & al. 2013) and relevant influential datasets (Flora europaea, Med-Checklist, Euro+Med PlantBase, etc.) are explained and clarified. An additional quantity of synonyms and misapplied names used in previous Greek floristic literature is presented. Taxonomic and floristic novelties published after 31 October 2013 are not considered."); |
|
173 |
result.setUri(URI.create("http://www.bioone.org/doi/full/10.3372/wi.46.46303")); |
|
174 |
return result; |
|
175 |
} |
|
176 |
|
|
177 |
private Reference getSourceReference(){ |
|
178 |
Reference result = ReferenceFactory.newDatabase(); |
|
179 |
result.setTitle("Excelfile (VPG_FINAL_WITH_SYNONYMS_21.01.2017.xlsx) derived from "); |
|
180 |
result.setInReference(getSecReference()); |
|
181 |
return result; |
|
182 |
} |
|
183 |
|
|
89 | 184 |
/** |
90 | 185 |
* @param args |
91 | 186 |
*/ |
app-import/src/main/java/eu/etaxonomy/cdm/io/greece/FloraHellenicaCommentsImport.java | ||
---|---|---|
15 | 15 |
|
16 | 16 |
import org.apache.log4j.Logger; |
17 | 17 |
import org.springframework.stereotype.Component; |
18 |
import org.springframework.transaction.TransactionStatus; |
|
19 | 18 |
|
20 | 19 |
import eu.etaxonomy.cdm.io.mexico.SimpleExcelTaxonImportState; |
21 | 20 |
import eu.etaxonomy.cdm.model.common.Language; |
... | ... | |
54 | 53 |
return "comments"; |
55 | 54 |
} |
56 | 55 |
|
57 |
private boolean isFirst = true; |
|
58 |
private TransactionStatus tx = null; |
|
59 | 56 |
/** |
60 | 57 |
* {@inheritDoc} |
61 | 58 |
*/ |
62 | 59 |
@Override |
63 | 60 |
protected void firstPass(SimpleExcelTaxonImportState<CONFIG> state) { |
64 |
if (isFirst){ |
|
65 |
tx = this.startTransaction(); |
|
66 |
isFirst = false; |
|
67 |
} |
|
68 | 61 |
|
69 | 62 |
String line = state.getCurrentLine() + ": "; |
70 | 63 |
HashMap<String, String> record = state.getOriginalRecord(); |
... | ... | |
80 | 73 |
makeComment(state, line, record, noStr); |
81 | 74 |
} |
82 | 75 |
|
83 |
@Override |
|
84 |
protected void secondPass(SimpleExcelTaxonImportState<CONFIG> state) { |
|
85 |
if (tx != null){ |
|
86 |
this.commitTransaction(tx); |
|
87 |
tx = null; |
|
88 |
} |
|
89 |
} |
|
90 |
|
|
91 | 76 |
|
92 | 77 |
/** |
93 | 78 |
* @param state |
app-import/src/main/java/eu/etaxonomy/cdm/io/greece/FloraHellenicaExcludedTaxonImport.java | ||
---|---|---|
15 | 15 |
|
16 | 16 |
import org.apache.log4j.Logger; |
17 | 17 |
import org.springframework.stereotype.Component; |
18 |
import org.springframework.transaction.TransactionStatus; |
|
19 | 18 |
|
20 | 19 |
import eu.etaxonomy.cdm.io.mexico.SimpleExcelTaxonImportState; |
21 |
import eu.etaxonomy.cdm.model.name.BotanicalName; |
|
20 |
import eu.etaxonomy.cdm.model.name.IBotanicalName;
|
|
22 | 21 |
import eu.etaxonomy.cdm.model.name.INonViralName; |
23 | 22 |
import eu.etaxonomy.cdm.model.name.NomenclaturalCode; |
24 | 23 |
import eu.etaxonomy.cdm.model.name.Rank; |
... | ... | |
61 | 60 |
return "excluded taxa"; |
62 | 61 |
} |
63 | 62 |
|
64 |
private boolean isFirst = true; |
|
65 |
private TransactionStatus tx = null; |
|
66 | 63 |
/** |
67 | 64 |
* {@inheritDoc} |
68 | 65 |
*/ |
69 | 66 |
@Override |
70 | 67 |
protected void firstPass(SimpleExcelTaxonImportState<CONFIG> state) { |
71 |
if (isFirst){ |
|
72 |
tx = this.startTransaction(); |
|
73 |
isFirst = false; |
|
74 |
} |
|
75 | 68 |
|
76 | 69 |
String line = state.getCurrentLine() + ": "; |
77 | 70 |
HashMap<String, String> record = state.getOriginalRecord(); |
... | ... | |
90 | 83 |
} |
91 | 84 |
} |
92 | 85 |
|
93 |
@Override |
|
94 |
protected void secondPass(SimpleExcelTaxonImportState<CONFIG> state) { |
|
95 |
if (tx != null){ |
|
96 |
this.commitTransaction(tx); |
|
97 |
tx = null; |
|
98 |
} |
|
99 |
} |
|
100 |
|
|
101 | 86 |
|
102 | 87 |
/** |
103 | 88 |
* @param state |
... | ... | |
110 | 95 |
HashMap<String, String> record, |
111 | 96 |
String noStr) { |
112 | 97 |
|
113 |
TaxonNode familyTaxon = getFamilyTaxon(record, state); |
|
114 |
if (familyTaxon == null){ |
|
98 |
TaxonNode familyTaxonNode = getFamilyTaxon(record, state); |
|
99 |
familyTaxonNode = getTaxonNodeService().find(familyTaxonNode.getUuid()); |
|
100 |
if (familyTaxonNode == null){ |
|
115 | 101 |
logger.warn(line + "Family not created, can't add excluded taxon: " + record.get(FAMILY)); |
116 | 102 |
return null; |
117 | 103 |
} |
118 | 104 |
|
119 | 105 |
String taxonStr = getValue(record, TAXON); |
120 | 106 |
INonViralName name = parser.parseFullName(taxonStr, NomenclaturalCode.ICNAFP, null); |
107 |
name = replaceNameAuthorsAndReferences(state, name); |
|
121 | 108 |
if (name.isProtectedTitleCache()){ |
122 | 109 |
logger.warn(line + "Name could not be parsed: " + taxonStr); |
123 | 110 |
} |
124 | 111 |
|
125 | 112 |
Taxon taxon = Taxon.NewInstance(name, getSecReference(state)); |
126 | 113 |
taxon.addImportSource(noStr, getWorksheetName(), getSourceCitation(state), null); |
127 |
TaxonNode excludedNode = familyTaxon.addChildTaxon(taxon, getSecReference(state), null); |
|
114 |
TaxonNode excludedNode = familyTaxonNode.addChildTaxon(taxon, getSecReference(state), null);
|
|
128 | 115 |
excludedNode.setExcluded(true); |
129 | 116 |
getTaxonNodeService().saveOrUpdate(excludedNode); |
130 | 117 |
return excludedNode; |
131 | 118 |
} |
132 | 119 |
|
133 | 120 |
|
121 |
|
|
134 | 122 |
/** |
135 | 123 |
* @param record |
136 | 124 |
* @param state |
... | ... | |
145 | 133 |
} |
146 | 134 |
familyStr = familyStr.trim(); |
147 | 135 |
|
148 |
Taxon family = state.getHigherTaxon(familyStr); |
|
136 |
// Taxon family = state.getHigherTaxon(familyStr); |
|
137 |
Taxon family = this.getHigherTaxon(record, state, FAMILY); |
|
149 | 138 |
TaxonNode familyNode; |
150 | 139 |
if (family != null){ |
151 | 140 |
familyNode = family.getTaxonNodes().iterator().next(); |
152 | 141 |
}else{ |
153 |
BotanicalName name = makeFamilyName(state, familyStr); |
|
142 |
IBotanicalName name = makeFamilyName(state, familyStr); |
|
143 |
name = replaceNameAuthorsAndReferences(state, name); |
|
144 |
|
|
154 | 145 |
Reference sec = getSecReference(state); |
155 | 146 |
family = Taxon.NewInstance(name, sec); |
156 | 147 |
|
app-import/src/main/java/eu/etaxonomy/cdm/io/greece/FloraHellenicaImageImport.java | ||
---|---|---|
8 | 8 |
*/ |
9 | 9 |
package eu.etaxonomy.cdm.io.greece; |
10 | 10 |
|
11 |
import java.io.File; |
|
12 |
import java.io.IOException; |
|
13 |
import java.net.URI; |
|
14 |
import java.util.ArrayList; |
|
15 |
import java.util.List; |
|
16 |
|
|
11 | 17 |
import org.apache.log4j.Logger; |
18 |
import org.apache.sanselan.ImageReadException; |
|
19 |
import org.apache.sanselan.Sanselan; |
|
20 |
import org.apache.sanselan.common.IImageMetadata; |
|
21 |
import org.apache.sanselan.common.ImageMetadata.Item; |
|
12 | 22 |
import org.springframework.stereotype.Component; |
23 |
import org.springframework.transaction.TransactionStatus; |
|
13 | 24 |
|
25 |
import eu.etaxonomy.cdm.api.service.config.MatchingTaxonConfigurator; |
|
14 | 26 |
import eu.etaxonomy.cdm.io.common.CdmImportBase; |
15 | 27 |
import eu.etaxonomy.cdm.io.mexico.SimpleExcelTaxonImportState; |
16 |
|
|
28 |
import eu.etaxonomy.cdm.model.agent.Person; |
|
29 |
import eu.etaxonomy.cdm.model.common.Language; |
|
30 |
import eu.etaxonomy.cdm.model.description.Feature; |
|
31 |
import eu.etaxonomy.cdm.model.description.TaxonDescription; |
|
32 |
import eu.etaxonomy.cdm.model.description.TextData; |
|
33 |
import eu.etaxonomy.cdm.model.media.Media; |
|
34 |
import eu.etaxonomy.cdm.model.reference.Reference; |
|
35 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
|
17 | 36 |
/** |
18 | 37 |
* Import for the Flora Hellenica images. |
19 | 38 |
* |
... | ... | |
28 | 47 |
private static final long serialVersionUID = 7118028793298922703L; |
29 | 48 |
private static final Logger logger = Logger.getLogger(FloraHellenicaImageImport.class); |
30 | 49 |
|
50 |
private static final String BASE_URL = "https://media.e-taxonomy.eu/flora-greece/"; |
|
51 |
private static final String IMAGE_FOLDER = "////BGBM-PESIHPC/Greece/thumbs/"; |
|
52 |
|
|
31 | 53 |
/** |
32 | 54 |
* {@inheritDoc} |
33 | 55 |
*/ |
34 | 56 |
@Override |
35 | 57 |
protected void doInvoke(SimpleExcelTaxonImportState<CONFIG> state) { |
36 |
// String baseURI = |
|
58 |
TransactionStatus tx = this.startTransaction(); |
|
59 |
for (int plate = 1; plate < 22 ; plate++){ |
|
60 |
try { |
|
61 |
handleSinglePlate(state, plate); |
|
62 |
} catch (Exception e) { |
|
63 |
logger.error("Error when handling plate " + plate); |
|
64 |
e.printStackTrace(); |
|
65 |
} |
|
66 |
} |
|
67 |
this.commitTransaction(tx); |
|
68 |
} |
|
69 |
|
|
70 |
/** |
|
71 |
* @param state |
|
72 |
* @param plate |
|
73 |
*/ |
|
74 |
private void handleSinglePlate(SimpleExcelTaxonImportState<CONFIG> state, int plate) { |
|
75 |
String fill = plate < 10 ? "0" : ""; |
|
76 |
String plateStr = "Plate_" + fill + plate + "/"; |
|
77 |
String fullFolderUrl = BASE_URL + plateStr; |
|
78 |
String fullThumbUrl = BASE_URL + "thumbs/" + plateStr; |
|
79 |
String folderStr = IMAGE_FOLDER + plateStr; |
|
80 |
File file = new File(folderStr); |
|
81 |
String[] list = file.list(); |
|
82 |
for (String fileStr : list){ |
|
83 |
try { |
|
84 |
handleSingleFile(state, fullFolderUrl, fullThumbUrl, fileStr); |
|
85 |
} catch (Exception e) { |
|
86 |
logger.error("Error when handling file: " + fileStr + " in plate " + plate); |
|
87 |
e.printStackTrace(); |
|
88 |
} |
|
89 |
} |
|
90 |
} |
|
91 |
|
|
92 |
/** |
|
93 |
* @param state |
|
94 |
* @param fullFolderUrl |
|
95 |
* @param fullThumbUrl |
|
96 |
* @param fileStr |
|
97 |
*/ |
|
98 |
private void handleSingleFile(SimpleExcelTaxonImportState<CONFIG> state, String fullFolderUrl, String fullThumbUrl, String fileStr) { |
|
99 |
String[] taxonNameAndArtist = getTaxonName(fileStr); |
|
100 |
String taxonNameStr = taxonNameAndArtist[0]; |
|
101 |
String taxonNameStr2 = null; |
|
102 |
String artistStr = taxonNameAndArtist[1]; |
|
103 |
if (fileStr.equals("RamondaSerbica(L)+Nathaliae(R)1.jpg")){ |
|
104 |
taxonNameStr = "Ramonda serbica"; |
|
105 |
taxonNameStr2 = "Ramonda nathaliae"; |
|
106 |
} |
|
107 |
|
|
108 |
try { |
|
109 |
|
|
110 |
Media media = getImageMedia(fullFolderUrl + fileStr, fullThumbUrl + fileStr, true); |
|
111 |
|
|
112 |
//image metadata |
|
113 |
URI uri = URI.create(fullThumbUrl + fileStr); |
|
114 |
try{ |
|
115 |
IImageMetadata metadata = Sanselan.getMetadata(uri.toURL().openStream(), null); |
|
116 |
ArrayList<?> items = metadata.getItems(); |
|
117 |
for (Object object : items){ |
|
118 |
Item item = (Item) object; |
|
119 |
// System.out.println(item.getKeyword() + ": " + item.getText()); |
|
120 |
String keyword = item.getKeyword().toLowerCase(); |
|
121 |
String value = item.getText(); |
|
122 |
if("image description".equals(keyword)){ |
|
123 |
media.putDescription(Language.DEFAULT(), value); |
|
124 |
}else if ("artist".equals(item.getKeyword().toLowerCase())){ |
|
125 |
if (isNotBlank(artistStr) && ! value.contains(artistStr)){ |
|
126 |
logger.warn("Artist and artistStr are different: " + artistStr + "; " + value); |
|
127 |
} |
|
128 |
artistStr = value; |
|
129 |
} |
|
130 |
} |
|
131 |
} catch (ImageReadException | IOException e1) { |
|
132 |
e1.printStackTrace(); |
|
133 |
} |
|
134 |
if (isNotBlank(artistStr)){ |
|
135 |
Person person = Person.NewInstance(); |
|
136 |
person.setLastname(artistStr); |
|
137 |
media.setArtist(person); |
|
138 |
} |
|
139 |
|
|
140 |
media.addPrimaryMediaSource(getSecReference(state), null); |
|
141 |
|
|
142 |
|
|
143 |
Taxon taxon = getAcceptedTaxon(taxonNameStr); |
|
144 |
makeTextData(fileStr, media, taxon); |
|
145 |
if (taxonNameStr2 != null){ |
|
146 |
getAcceptedTaxon(taxonNameStr); |
|
147 |
makeTextData(fileStr, media, taxon); |
|
148 |
} |
|
149 |
|
|
150 |
|
|
151 |
if (taxonNameStr2 == null){ |
|
152 |
media.putTitle(Language.LATIN(), taxon == null ? "taxonNameStr" : |
|
153 |
taxon.getName().getTitleCache()); |
|
154 |
}else{ |
|
155 |
media.putTitle(Language.LATIN(), "Ramonda serbica(L) + R. nathaliae(R)"); |
|
156 |
} |
|
157 |
|
|
158 |
|
|
159 |
} catch (Exception e) { |
|
160 |
e.printStackTrace(); |
|
161 |
return; |
|
162 |
} |
|
163 |
} |
|
164 |
|
|
165 |
private Reference secReference; |
|
166 |
private Reference getSecReference(SimpleExcelTaxonImportState<CONFIG> state) { |
|
167 |
if (secReference != null){ |
|
168 |
secReference = getReferenceService().find(state.getConfig().getSecReference().getUuid()); |
|
169 |
} |
|
170 |
return secReference; |
|
171 |
} |
|
172 |
|
|
173 |
/** |
|
174 |
* @param fileStr |
|
175 |
* @param media |
|
176 |
* @param taxon |
|
177 |
* @return |
|
178 |
*/ |
|
179 |
private void makeTextData(String fileStr, Media media, Taxon taxon) { |
|
180 |
if (taxon == null){ |
|
181 |
logger.warn("Taxon not found for image " + fileStr + "." |
|
182 |
+ "Media could not be attached to taxon."); |
|
183 |
getMediaService().saveOrUpdate(media); |
|
184 |
return; |
|
185 |
} |
|
186 |
TaxonDescription imageGallery = taxon.getImageGallery(true); |
|
187 |
TextData textData = TextData.NewInstance(); |
|
188 |
textData.setFeature(Feature.IMAGE()); |
|
189 |
imageGallery.addElement(textData); |
|
190 |
textData.addMedia(media); |
|
37 | 191 |
} |
38 | 192 |
|
193 |
/** |
|
194 |
* @param taxonNameStr |
|
195 |
* @return |
|
196 |
*/ |
|
197 |
private Taxon getAcceptedTaxon(String taxonNameStr) { |
|
198 |
|
|
199 |
MatchingTaxonConfigurator config = new MatchingTaxonConfigurator(); |
|
200 |
config.setTaxonNameTitle(taxonNameStr); |
|
201 |
config.setIncludeSynonyms(false); |
|
202 |
List<Taxon> list = (List)getTaxonService().findTaxaByName(config); |
|
203 |
if (list.isEmpty()){ |
|
204 |
logger.warn("Taxon not found for media: " + taxonNameStr); |
|
205 |
return null; |
|
206 |
}else{ |
|
207 |
if (list.size()>1){ |
|
208 |
logger.warn("More than 1 taxon found for media: " + taxonNameStr); |
|
209 |
} |
|
210 |
return list.get(0); |
|
211 |
} |
|
212 |
} |
|
213 |
|
|
214 |
/** |
|
215 |
* @param fileStr |
|
216 |
* @return |
|
217 |
*/ |
|
218 |
private String[] getTaxonName(String fileStr) { |
|
219 |
String[] result = new String[2]; |
|
220 |
fileStr = fileStr.split("\\.")[0]; |
|
221 |
fileStr = fileStr.replaceAll("[0-9]", ""); |
|
222 |
String[] x = fileStr.split("_"); |
|
223 |
if (x.length == 2){ |
|
224 |
result[1] = x[1]; |
|
225 |
} |
|
226 |
|
|
227 |
fileStr = splitCamelCase(x[0]); |
|
228 |
String[] split = fileStr.split(" "); |
|
229 |
String name = split[0] + " " + split[1].toLowerCase() + |
|
230 |
(split.length > 2 ? " subsp. " + split[2].toLowerCase() : ""); |
|
231 |
result[0] = name; |
|
232 |
System.out.println(result[0] + (result[1] != null ? " Artist: " + result[1]: "")); |
|
233 |
return result; |
|
234 |
} |
|
235 |
|
|
236 |
//from http://stackoverflow.com/questions/2559759/how-do-i-convert-camelcase-into-human-readable-names-in-java |
|
237 |
static String splitCamelCase(String s) { |
|
238 |
return s.replaceAll( |
|
239 |
String.format("%s", |
|
240 |
// "(?<=[A-Z])(?=[A-Z][a-z])", |
|
241 |
"(?<=[^A-Z])(?=[A-Z])" |
|
242 |
// "(?<=[A-Za-z])(?=[^A-Za-z])" |
|
243 |
), |
|
244 |
" " |
|
245 |
); |
|
246 |
} |
|
247 |
|
|
39 | 248 |
/** |
40 | 249 |
* {@inheritDoc} |
41 | 250 |
*/ |
app-import/src/main/java/eu/etaxonomy/cdm/io/greece/FloraHellenicaImportBase.java | ||
---|---|---|
9 | 9 |
package eu.etaxonomy.cdm.io.greece; |
10 | 10 |
|
11 | 11 |
import java.util.HashMap; |
12 |
import java.util.List; |
|
13 |
import java.util.Map; |
|
14 |
import java.util.UUID; |
|
12 | 15 |
|
13 | 16 |
import org.apache.log4j.Logger; |
14 | 17 |
|
18 |
import eu.etaxonomy.cdm.io.common.utils.ImportDeduplicationHelper; |
|
15 | 19 |
import eu.etaxonomy.cdm.io.mexico.SimpleExcelTaxonImport; |
16 | 20 |
import eu.etaxonomy.cdm.io.mexico.SimpleExcelTaxonImportState; |
21 |
import eu.etaxonomy.cdm.model.common.IdentifiableSource; |
|
17 | 22 |
import eu.etaxonomy.cdm.model.description.TaxonDescription; |
18 | 23 |
import eu.etaxonomy.cdm.model.name.BotanicalName; |
24 |
import eu.etaxonomy.cdm.model.name.INonViralName; |
|
19 | 25 |
import eu.etaxonomy.cdm.model.name.Rank; |
20 | 26 |
import eu.etaxonomy.cdm.model.name.TaxonNameFactory; |
21 | 27 |
import eu.etaxonomy.cdm.model.reference.Reference; |
... | ... | |
32 | 38 |
private static final long serialVersionUID = 2593130403213346396L; |
33 | 39 |
private static final Logger logger = Logger.getLogger(FloraHellenicaImportBase.class); |
34 | 40 |
|
41 |
private Map<UUID, Taxon> acceptedTaxonMap = new HashMap<>(); |
|
42 |
private Reference sourceReference; |
|
43 |
private Reference secReference; |
|
44 |
private Reference secReference2; |
|
45 |
|
|
46 |
@SuppressWarnings("unchecked") |
|
47 |
private ImportDeduplicationHelper<SimpleExcelTaxonImportState<?>> deduplicationHelper = (ImportDeduplicationHelper<SimpleExcelTaxonImportState<?>>)ImportDeduplicationHelper.NewInstance(this); |
|
48 |
|
|
49 |
|
|
35 | 50 |
|
36 | 51 |
/** |
37 | 52 |
* @param taxon |
... | ... | |
53 | 68 |
* @return |
54 | 69 |
*/ |
55 | 70 |
protected Reference getSourceCitation(SimpleExcelTaxonImportState<CONFIG> state) { |
56 |
return state.getConfig().getSourceReference(); |
|
71 |
if (this.sourceReference == null){ |
|
72 |
this.sourceReference = getPersistentReference(state.getConfig().getSourceReference()); |
|
73 |
} |
|
74 |
return this.sourceReference; |
|
57 | 75 |
} |
58 | 76 |
|
59 | 77 |
|
60 | 78 |
protected Reference getSecReference(SimpleExcelTaxonImportState<CONFIG> state) { |
61 |
// TODO Auto-generated method stub |
|
62 |
return null; |
|
79 |
if (this.secReference == null){ |
|
80 |
this.secReference = getPersistentReference(state.getConfig().getSecReference()); |
|
81 |
} |
|
82 |
return this.secReference; |
|
83 |
} |
|
84 |
|
|
85 |
protected Reference getSecReference2(SimpleExcelTaxonImportState<CONFIG> state) { |
|
86 |
if (this.secReference2 == null){ |
|
87 |
this.secReference2 = getPersistentReference(state.getConfig().getSecReference2()); |
|
88 |
} |
|
89 |
return this.secReference2; |
|
90 |
} |
|
91 |
|
|
92 |
/** |
|
93 |
* @param reference |
|
94 |
* @return |
|
95 |
*/ |
|
96 |
private Reference getPersistentReference(Reference reference) { |
|
97 |
Reference result = getReferenceService().find(reference.getUuid()); |
|
98 |
if (result == null){ |
|
99 |
result = reference; |
|
100 |
} |
|
101 |
return result; |
|
63 | 102 |
} |
64 | 103 |
|
65 | 104 |
|
... | ... | |
70 | 109 |
*/ |
71 | 110 |
protected Taxon getAcceptedTaxon(HashMap<String, String> record, |
72 | 111 |
SimpleExcelTaxonImportState<CONFIG> state, String key) { |
112 |
|
|
73 | 113 |
String accStr = getValue(record, key); |
74 | 114 |
if (accStr == null){ |
75 | 115 |
return null; |
... | ... | |
82 | 122 |
logger.warn(message); |
83 | 123 |
return null; |
84 | 124 |
}else{ |
85 |
accTaxon = (Taxon)getTaxonService().find(accTaxon.getUuid()); |
|
125 |
initAcceptedTaxonMap(); |
|
126 |
// accTaxon = (Taxon)getTaxonService().find(accTaxon.getUuid()); |
|
127 |
accTaxon = acceptedTaxonMap.get(accTaxon.getUuid()); |
|
86 | 128 |
} |
87 | 129 |
return accTaxon; |
88 | 130 |
} |
89 | 131 |
|
132 |
private void initAcceptedTaxonMap() { |
|
133 |
if (acceptedTaxonMap.isEmpty()){ |
|
134 |
List<Taxon> list = getTaxonService().list(Taxon.class, null, null, null, null); |
|
135 |
for (Taxon taxon : list){ |
|
136 |
acceptedTaxonMap.put(taxon.getUuid(), taxon); |
|
137 |
} |
|
138 |
} |
|
139 |
} |
|
90 | 140 |
|
141 |
/** |
|
142 |
* @param record |
|
143 |
* @param state |
|
144 |
* @return |
|
145 |
*/ |
|
146 |
protected Taxon getHigherTaxon(HashMap<String, String> record, |
|
147 |
SimpleExcelTaxonImportState<CONFIG> state, String key) { |
|
91 | 148 |
|
92 |
protected BotanicalName makeFamilyName(SimpleExcelTaxonImportState<CONFIG> state, String famStr) { |
|
149 |
String accStr = getValue(record, key); |
|
150 |
if (accStr == null){ |
|
151 |
return null; |
|
152 |
} |
|
153 |
accStr = accStr.trim(); |
|
154 |
|
|
155 |
Taxon accTaxon = state.getHigherTaxon(accStr); |
|
156 |
if (accTaxon == null){ |
|
157 |
String message = state.getCurrentLine()+ ": Higher taxon could not be found: " + accStr; |
|
158 |
logger.info(message); //not critical |
|
159 |
return null; |
|
160 |
}else{ |
|
161 |
initAcceptedTaxonMap(); |
|
162 |
// accTaxon = (Taxon)getTaxonService().find(accTaxon.getUuid()); |
|
163 |
accTaxon = acceptedTaxonMap.get(accTaxon.getUuid()); |
|
164 |
} |
|
165 |
return accTaxon; |
|
166 |
} |
|
167 |
|
|
168 |
|
|
169 |
protected BotanicalName makeFamilyName(SimpleExcelTaxonImportState<CONFIG> state, |
|
170 |
String famStr) { |
|
93 | 171 |
BotanicalName name = TaxonNameFactory.NewBotanicalInstance(Rank.FAMILY()); |
172 |
famStr = famStr.substring(0,1).toUpperCase() + famStr.substring(1).toLowerCase(); |
|
94 | 173 |
name.setGenusOrUninomial(famStr); |
95 | 174 |
name.addSource(makeOriginalSource(state)); |
96 | 175 |
return name; |
97 | 176 |
} |
98 | 177 |
|
178 |
|
|
179 |
/** |
|
180 |
* @param state |
|
181 |
* @param name |
|
182 |
* @return |
|
183 |
*/ |
|
184 |
protected <NAME extends INonViralName> NAME replaceNameAuthorsAndReferences(SimpleExcelTaxonImportState<CONFIG> state, NAME name) { |
|
185 |
NAME result = deduplicationHelper.getExistingName(state, name); |
|
186 |
deduplicationHelper.replaceAuthorNamesAndNomRef(state, result); |
|
187 |
return result; |
|
188 |
} |
|
189 |
|
|
190 |
|
|
191 |
/** |
|
192 |
* @param state |
|
193 |
* @return |
|
194 |
*/ |
|
195 |
@Override |
|
196 |
protected IdentifiableSource makeOriginalSource(SimpleExcelTaxonImportState<CONFIG> state) { |
|
197 |
return IdentifiableSource.NewDataImportInstance("line: " + state.getCurrentLine(), null, getSourceCitation(state)); |
|
198 |
} |
|
199 |
|
|
99 | 200 |
} |
app-import/src/main/java/eu/etaxonomy/cdm/io/greece/FloraHellenicaImportConfigurator.java | ||
---|---|---|
21 | 21 |
/** |
22 | 22 |
* @author a.mueller |
23 | 23 |
* @date 14.12.2016 |
24 |
* |
|
25 | 24 |
*/ |
26 | 25 |
public class FloraHellenicaImportConfigurator extends ExcelImportConfiguratorBase{ |
27 | 26 |
|
28 | 27 |
private static final long serialVersionUID = 3782414424818991629L; |
29 | 28 |
private static IInputTransformer defaultTransformer = new FloraHellenicaTransformer(); |
30 | 29 |
private Reference secReference; |
30 |
private Reference secReference2; |
|
31 | 31 |
|
32 | 32 |
private boolean isDoImages = true; |
33 |
private boolean statusAsDistribution = false; |
|
33 | 34 |
|
34 | 35 |
|
35 | 36 |
|
... | ... | |
58 | 59 |
@Override |
59 | 60 |
protected void makeIoClassList() { |
60 | 61 |
ioClassList = new Class[]{ |
62 |
FloraHellenicaTermImport.class, |
|
61 | 63 |
FloraHellenicaTaxonImport.class, |
62 | 64 |
FloraHellenicaExcludedTaxonImport.class, |
63 | 65 |
FloraHellenicaSynonymImport.class, |
... | ... | |
70 | 72 |
public boolean isDoImages() { |
71 | 73 |
return isDoImages; |
72 | 74 |
} |
73 |
|
|
74 |
|
|
75 | 75 |
public void setDoImages(boolean isDoImages) { |
76 | 76 |
this.isDoImages = isDoImages; |
77 | 77 |
} |
78 |
|
|
79 |
|
|
80 |
public boolean isStatusAsDistribution() { |
|
81 |
return statusAsDistribution; |
|
82 |
} |
|
83 |
public void setStatusAsDistribution(boolean statusAsDistribution) { |
|
84 |
this.statusAsDistribution = statusAsDistribution; |
|
85 |
} |
|
86 |
|
|
87 |
|
|
88 |
public Reference getSecReference() { |
|
89 |
return secReference; |
|
90 |
} |
|
91 |
public void setSecReference(Reference secReference) { |
|
92 |
this.secReference = secReference; |
|
93 |
} |
|
94 |
|
|
95 |
|
|
96 |
public Reference getSecReference2() { |
|
97 |
return secReference2; |
|
98 |
} |
|
99 |
public void setSecReference2(Reference secReference2) { |
|
100 |
this.secReference2 = secReference2; |
|
101 |
} |
|
102 |
|
|
103 |
|
|
78 | 104 |
} |
app-import/src/main/java/eu/etaxonomy/cdm/io/greece/FloraHellenicaSynonymImport.java | ||
---|---|---|
17 | 17 |
|
18 | 18 |
import org.apache.log4j.Logger; |
19 | 19 |
import org.springframework.stereotype.Component; |
20 |
import org.springframework.transaction.TransactionStatus; |
|
21 | 20 |
|
22 | 21 |
import eu.etaxonomy.cdm.io.mexico.SimpleExcelTaxonImportState; |
23 | 22 |
import eu.etaxonomy.cdm.model.name.INonViralName; |
... | ... | |
60 | 59 |
return "synonyms"; |
61 | 60 |
} |
62 | 61 |
|
63 |
private boolean isFirst = true; |
|
64 |
private TransactionStatus tx = null; |
|
65 | 62 |
/** |
66 | 63 |
* {@inheritDoc} |
67 | 64 |
*/ |
68 | 65 |
@Override |
69 | 66 |
protected void firstPass(SimpleExcelTaxonImportState<CONFIG> state) { |
70 |
if (isFirst){ |
|
71 |
tx = this.startTransaction(); |
|
72 |
isFirst = false; |
|
73 |
} |
|
74 | 67 |
|
75 | 68 |
String line = state.getCurrentLine() + ": "; |
76 | 69 |
HashMap<String, String> record = state.getOriginalRecord(); |
... | ... | |
84 | 77 |
|
85 | 78 |
String row = "row" + state.getCurrentLine(); |
86 | 79 |
TaxonBase<?> relatedTaxon = makeSynonym(state, line, record, row); |
87 |
getTaxonService().saveOrUpdate(relatedTaxon); |
|
88 |
} |
|
89 |
|
|
90 |
@Override |
|
91 |
protected void secondPass(SimpleExcelTaxonImportState<CONFIG> state) { |
|
92 |
if (tx != null){ |
|
93 |
this.commitTransaction(tx); |
|
94 |
tx = null; |
|
80 |
if (relatedTaxon != null){ |
|
81 |
getTaxonService().saveOrUpdate(relatedTaxon); |
|
95 | 82 |
} |
96 | 83 |
} |
97 | 84 |
|
... | ... | |
141 | 128 |
logger.warn(line + "Nom. status not recognized: " + parsedSynStr[3]); |
142 | 129 |
} |
143 | 130 |
} |
131 |
name = replaceNameAuthorsAndReferences(state, name); |
|
132 |
|
|
144 | 133 |
|
145 | 134 |
TaxonBase<?> result; |
146 | 135 |
if (isMisapplied){ |
... | ... | |
188 | 177 |
split = split.replace("T.", "Taraxacum"); |
189 | 178 |
} |
190 | 179 |
nonName = TaxonNameBase.castAndDeproxy(this.parser.parseFullName(split)); |
180 |
nonName = replaceNameAuthorsAndReferences(state, nonName); |
|
191 | 181 |
name.addRelationshipFromName(nonName, NameRelationshipType.BLOCKING_NAME_FOR(), null); |
192 | 182 |
}else{ |
193 | 183 |
String nameStr = name.getNameCache() + " " + split; |
194 | 184 |
nonName = TaxonNameBase.castAndDeproxy(this.parser.parseFullName(nameStr)); |
185 |
nonName = replaceNameAuthorsAndReferences(state, nonName); |
|
195 | 186 |
name.addRelationshipToName(nonName, NameRelationshipType.LATER_HOMONYM(), null); |
196 | 187 |
} |
197 | 188 |
getNameService().saveOrUpdate(nonName); |
app-import/src/main/java/eu/etaxonomy/cdm/io/greece/FloraHellenicaTaxonImport.java | ||
---|---|---|
8 | 8 |
*/ |
9 | 9 |
package eu.etaxonomy.cdm.io.greece; |
10 | 10 |
|
11 |
import java.net.URI; |
|
12 | 11 |
import java.util.Arrays; |
13 | 12 |
import java.util.HashMap; |
14 | 13 |
import java.util.List; |
... | ... | |
18 | 17 |
|
19 | 18 |
import org.apache.log4j.Logger; |
20 | 19 |
import org.springframework.stereotype.Component; |
21 |
import org.springframework.transaction.TransactionStatus; |
|
22 | 20 |
|
23 |
import eu.etaxonomy.cdm.api.service.ITermService; |
|
24 | 21 |
import eu.etaxonomy.cdm.common.CdmUtils; |
25 |
import eu.etaxonomy.cdm.ext.geo.GeoServiceArea; |
|
26 |
import eu.etaxonomy.cdm.ext.geo.GeoServiceAreaAnnotatedMapping; |
|
27 | 22 |
import eu.etaxonomy.cdm.io.mexico.SimpleExcelTaxonImportState; |
28 | 23 |
import eu.etaxonomy.cdm.model.common.Language; |
29 | 24 |
import eu.etaxonomy.cdm.model.common.OrderedTermVocabulary; |
30 |
import eu.etaxonomy.cdm.model.common.TermType; |
|
31 | 25 |
import eu.etaxonomy.cdm.model.description.CategoricalData; |
26 |
import eu.etaxonomy.cdm.model.description.DescriptionElementBase; |
|
32 | 27 |
import eu.etaxonomy.cdm.model.description.Distribution; |
33 | 28 |
import eu.etaxonomy.cdm.model.description.Feature; |
34 |
import eu.etaxonomy.cdm.model.description.FeatureNode; |
|
35 |
import eu.etaxonomy.cdm.model.description.FeatureTree; |
|
36 | 29 |
import eu.etaxonomy.cdm.model.description.PresenceAbsenceTerm; |
37 | 30 |
import eu.etaxonomy.cdm.model.description.State; |
38 | 31 |
import eu.etaxonomy.cdm.model.description.TaxonDescription; |
39 | 32 |
import eu.etaxonomy.cdm.model.location.NamedArea; |
40 |
import eu.etaxonomy.cdm.model.location.NamedAreaType; |
|
41 | 33 |
import eu.etaxonomy.cdm.model.name.BotanicalName; |
42 | 34 |
import eu.etaxonomy.cdm.model.name.Rank; |
43 | 35 |
import eu.etaxonomy.cdm.model.name.TaxonNameFactory; |
... | ... | |
65 | 57 |
private static final String STATUS = "Status"; |
66 | 58 |
private static final String CHOROLOGICAL_CATEGOGY = "Chorological categogy"; |
67 | 59 |
|
68 |
|
|
69 | 60 |
private static UUID rootUuid = UUID.fromString("aa667b0b-b417-470e-a9b0-ef9409a3431e"); |
70 | 61 |
private static UUID plantaeUuid = UUID.fromString("4f151932-ab97-4d81-b88e-46fe82cd3e88"); |
71 | 62 |
|
72 |
private OrderedTermVocabulary<NamedArea> areasVoc; |
|
73 |
private NamedArea greece; |
|
74 |
private OrderedTermVocabulary<State> lifeformVoc; |
|
75 |
private OrderedTermVocabulary<State> habitatVoc; |
|
76 | 63 |
private Map<String, State> lifeformMap = new HashMap<>(); |
77 |
|
|
78 |
private OrderedTermVocabulary<PresenceAbsenceTerm> statusVoc; |
|
64 |
private Map<String, State> chorologyMap = new HashMap<>(); |
|
79 | 65 |
private PresenceAbsenceTerm rangeRestricted; |
80 | 66 |
private PresenceAbsenceTerm doubtfullyRangeRestricted; |
67 |
private OrderedTermVocabulary<State> habitatVoc; |
|
68 |
private OrderedTermVocabulary<State> statusVoc; |
|
81 | 69 |
|
82 | 70 |
|
83 |
private OrderedTermVocabulary<State> chorologicalVoc; |
|
84 |
private Map<String, State> chorologyMap = new HashMap<>(); |
|
85 |
|
|
86 | 71 |
|
87 | 72 |
private static List<String> expectedKeys= Arrays.asList(new String[]{ |
88 | 73 |
"Unique ID","uuid","Group","Family","Genus","Species","Species Author","Subspecies","Subspecies Author", |
... | ... | |
99 | 84 |
return "valid taxa names"; |
100 | 85 |
} |
101 | 86 |
|
102 |
|
|
103 |
private boolean isFirst = true; |
|
104 |
private TransactionStatus tx = null; |
|
105 | 87 |
/** |
106 | 88 |
* {@inheritDoc} |
107 | 89 |
*/ |
108 | 90 |
@Override |
109 | 91 |
protected void firstPass(SimpleExcelTaxonImportState<CONFIG> state) { |
110 |
if (isFirst){ |
|
111 |
tx = this.startTransaction(); |
|
112 |
isFirst = false; |
|
113 |
} |
|
114 |
initAreaVocabulary(state); |
|
115 |
initLifeformVocabulary(state); |
|
116 |
initHabitatVocabulary(state); |
|
117 |
initChorologicalVocabulary(state); |
|
118 |
initStatusVocabulary(state); |
|
119 |
makeFeatureTree(state); |
|
92 |
initLifeFormMap(); |
|
93 |
initChorologyMap(); |
|
94 |
initOtherTerms(state); |
|
120 | 95 |
|
121 | 96 |
String line = state.getCurrentLine() + ": "; |
122 | 97 |
HashMap<String, String> record = state.getOriginalRecord(); |
... | ... | |
144 | 119 |
makeHabitat(state, line, noStr, desc); |
145 | 120 |
|
146 | 121 |
state.putTaxon(noStr, taxon); |
147 |
} |
|
148 |
|
|
149 | 122 |
|
150 |
@Override |
|
151 |
protected void secondPass(SimpleExcelTaxonImportState<CONFIG> state) { |
|
152 |
if (tx != null){ |
|
153 |
this.commitTransaction(tx); |
|
154 |
tx = null; |
|
155 |
} |
|
156 | 123 |
} |
157 | 124 |
|
158 | 125 |
|
159 |
boolean hasFeatureTree = false; |
|
160 | 126 |
/** |
161 | 127 |
* @param state |
128 |
* |
|
162 | 129 |
*/ |
163 |
private void makeFeatureTree(SimpleExcelTaxonImportState<CONFIG> state) { |
|
164 |
if (hasFeatureTree ){ |
|
165 |
return; |
|
130 |
private void initOtherTerms(SimpleExcelTaxonImportState<CONFIG> state) { |
|
131 |
if (state.getConfig().isStatusAsDistribution()){ |
|
132 |
if (rangeRestricted == null){ |
|
133 |
rangeRestricted = (PresenceAbsenceTerm)getTermService().find(FloraHellenicaTransformer.uuidStatusRangeRestricted); |
|
134 |
} |
|
135 |
if (this.doubtfullyRangeRestricted == null){ |
|
136 |
doubtfullyRangeRestricted = (PresenceAbsenceTerm)getTermService().find(FloraHellenicaTransformer.uuidStatusRangeRestrictedDoubtfully); |
|
137 |
} |
|
138 |
}else{ |
|
139 |
if (this.statusVoc == null){ |
|
140 |
@SuppressWarnings("unchecked") |
|
141 |
OrderedTermVocabulary<State> voc = (OrderedTermVocabulary<State>) getVocabularyService().find( |
|
142 |
FloraHellenicaTransformer.uuidFloraHellenicaStatusVoc); |
|
143 |
statusVoc = voc; |
|
144 |
} |
|
166 | 145 |
} |
167 |
if (getFeatureTreeService().find(state.getConfig().getUuidFeatureTree()) != null){ |
|
168 |
hasFeatureTree = true; |
|
169 |
return; |
|
146 |
if (this.habitatVoc == null){ |
|
147 |
@SuppressWarnings("unchecked") |
|
148 |
OrderedTermVocabulary<State> voc = (OrderedTermVocabulary<State>) getVocabularyService().find( |
|
149 |
FloraHellenicaTransformer.uuidFloraHellenicaHabitatVoc); |
|
150 |
habitatVoc = voc; |
|
170 | 151 |
} |
171 |
FeatureTree result = FeatureTree.NewInstance(state.getConfig().getUuidFeatureTree()); |
|
172 |
result.setTitleCache(state.getConfig().getFeatureTreeTitle(), true); |
|
173 |
FeatureNode root = result.getRoot(); |
|
174 |
FeatureNode newNode; |
|
175 |
|
|
176 |
ITermService service = getTermService(); |
|
177 |
Feature newFeature = (Feature)service.find(Feature.DISTRIBUTION().getUuid()); |
|
178 |
newNode = FeatureNode.NewInstance(newFeature); |
|
179 |
root.addChild(newNode); |
|
180 |
|
|
181 |
newFeature = (Feature)service.find(FloraHellenicaTransformer.uuidFloraHellenicaChorologyFeature); |
|
182 |
newNode = FeatureNode.NewInstance(newFeature); |
|
183 |
root.addChild(newNode); |
|
184 |
|
|
185 |
newFeature = (Feature)service.find(Feature.LIFEFORM().getUuid()); |
|
186 |
newNode = FeatureNode.NewInstance(newFeature); |
|
187 |
root.addChild(newNode); |
|
152 |
} |
|
188 | 153 |
|
189 |
newFeature = (Feature)service.find(Feature.HABITAT().getUuid()); |
|
190 |
newNode = FeatureNode.NewInstance(newFeature); |
|
191 |
root.addChild(newNode); |
|
192 | 154 |
|
155 |
private void initLifeFormMap() { |
|
156 |
if (lifeformMap.isEmpty()){ |
|
157 |
UUID uuid = FloraHellenicaTransformer.uuidFloraHellenicaLifeformVoc; |
|
158 |
@SuppressWarnings("unchecked") |
|
159 |
OrderedTermVocabulary<State> lifeformVoc = (OrderedTermVocabulary<State>)this.getVocabularyService().find(uuid); |
|
160 |
for (State state : lifeformVoc.getTerms()){ |
|
161 |
lifeformMap.put(state.getIdInVocabulary(), state); |
|
162 |
} |
|
163 |
} |
|
164 |
} |
|
193 | 165 |
|
194 |
newFeature = (Feature)service.find(Feature.NOTES().getUuid()); |
|
195 |
newNode = FeatureNode.NewInstance(newFeature); |
|
196 |
root.addChild(newNode); |
|
166 |
private void initChorologyMap() { |
|
167 |
if (chorologyMap.isEmpty()){ |
|
168 |
UUID uuid = FloraHellenicaTransformer.uuidFloraHellenicaChorologicalVoc; |
|
169 |
@SuppressWarnings("unchecked") |
|
170 |
OrderedTermVocabulary<State> voc = (OrderedTermVocabulary<State>)this.getVocabularyService().find(uuid); |
|
171 |
for (State state : voc.getTerms()){ |
|
172 |
chorologyMap.put(state.getIdInVocabulary(), state); |
|
173 |
} |
|
174 |
} |
|
175 |
} |
|
197 | 176 |
|
198 |
getFeatureTreeService().saveOrUpdate(result); |
|
199 |
hasFeatureTree = true; |
|
200 | 177 |
|
201 |
} |
|
202 | 178 |
|
203 | 179 |
/** |
204 | 180 |
* @param state |
... | ... | |
416 | 392 |
if (name.isProtectedTitleCache()){ |
417 | 393 |
logger.warn(line + "Name could not be parsed: " + nameStr); |
418 | 394 |
} |
395 |
name = replaceNameAuthorsAndReferences(state, name); |
|
396 |
|
|
419 | 397 |
Taxon taxon = Taxon.NewInstance(name, getSecReference(state)); |
420 | 398 |
taxon.addImportSource(noStr, getWorksheetName(), getSourceCitation(state), null); |
421 | 399 |
// String parentStr = isSubSpecies ? makeSpeciesKey(genusStr, speciesStr, speciesAuthorStr) : genusStr; |
... | ... | |
475 | 453 |
HashMap<String, String> record, String genusStr) { |
476 | 454 |
BotanicalName name = TaxonNameFactory.NewBotanicalInstance(Rank.GENUS()); |
477 | 455 |
name.setGenusOrUninomial(genusStr); |
456 |
name = replaceNameAuthorsAndReferences(state, name); |
|
478 | 457 |
Taxon genus = Taxon.NewInstance(name, getSecReference(state)); |
479 | 458 |
TaxonNode family = getFamilyTaxon(record, state); |
480 | 459 |
TaxonNode genusNode = family.addChildTaxon(genus, getSecReference(state), null); |
... | ... | |
513 | 492 |
familyNode = family.getTaxonNodes().iterator().next(); |
514 | 493 |
}else{ |
515 | 494 |
BotanicalName name = makeFamilyName(state, familyStr); |
495 |
name = replaceNameAuthorsAndReferences(state, name); |
|
496 |
|
|
516 | 497 |
Reference sec = getSecReference(state); |
517 | 498 |
family = Taxon.NewInstance(name, sec); |
518 | 499 |
|
... | ... | |
543 | 524 |
groupNode = group.getTaxonNodes().iterator().next(); |
544 | 525 |
}else{ |
545 | 526 |
BotanicalName name = makeFamilyName(state, groupStr); |
527 |
name = replaceNameAuthorsAndReferences(state, name); |
|
528 |
|
|
546 | 529 |
Reference sec = getSecReference(state); |
547 | 530 |
group = Taxon.NewInstance(name, sec); |
548 | 531 |
ITaxonTreeNode rootNode = getClassification(state); |
... | ... | |
566 | 549 |
|
567 | 550 |
BotanicalName plantaeName = TaxonNameFactory.NewBotanicalInstance(Rank.KINGDOM()); |
568 | 551 |
plantaeName.setGenusOrUninomial("Plantae"); |
552 |
plantaeName = replaceNameAuthorsAndReferences(state, plantaeName); |
|
553 |
|
|
569 | 554 |
Taxon plantae = Taxon.NewInstance(plantaeName, sec); |
570 | 555 |
TaxonNode plantaeNode = classification.addChildTaxon(plantae, null, null); |
571 | 556 |
plantaeNode.setUuid(plantaeUuid); |
... | ... | |
613 | 598 |
TaxonDescription desc, String key, UUID uuid, String line, String id) { |
614 | 599 |
HashMap<String, String> record = state.getOriginalRecord(); |
615 | 600 |
String value = getValue(record, key); |
616 |
NamedArea area = getNamedArea(state, uuid, null, null, null, null, null); |
|
617 |
Distribution dist; |
|
618 |
if (value == null || ".".equals(value) ){ |
|
619 |
dist = Distribution.NewInstance(area, PresenceAbsenceTerm.NATIVE()); |
|
620 |
if (".".equals(value)){ |
|
621 |
logger.warn(line + "'.' Should not exist anmore as a distribution status: '" + value + "' for " + key); |
|
622 |
} |
|
623 |
}else if ("Range-restricted".equals(value)){ |
|
624 |
dist = Distribution.NewInstance(area, rangeRestricted); |
|
625 |
}else if ("?Range-restricted".equals(value)){ |
|
626 |
dist = Distribution.NewInstance(area, doubtfullyRangeRestricted); |
|
627 |
}else if ("Xenophyte".equals(value)){ |
|
628 |
dist = Distribution.NewInstance(area, PresenceAbsenceTerm.INTRODUCED()); |
|
629 |
}else if ("?Xenophyte".equals(value)){ |
|
630 |
dist = Distribution.NewInstance(area, PresenceAbsenceTerm.INTRODUCED_DOUBTFULLY_INTRODUCED()); |
|
631 |
}else { |
|
632 |
logger.warn(line + "Not matching status. This should not happpen '" + value + "' for " + key); |
|
633 |
return; |
|
634 |
} |
|
635 |
desc.addElement(dist); |
|
636 |
dist.addImportSource(id, getWorksheetName(), getSourceCitation(state), line); |
|
637 |
} |
|
638 |
|
|
639 |
@SuppressWarnings("unchecked") |
|
640 |
private void initAreaVocabulary(SimpleExcelTaxonImportState<CONFIG> state) { |
|
641 |
if (areasVoc == null){ |
|
642 |
areasVoc = (OrderedTermVocabulary<NamedArea>)this.getVocabularyService().find(FloraHellenicaTransformer.uuidFloraHellenicaAreasVoc); |
|
643 |
if (areasVoc == null){ |
|
644 |
createAreasVoc(state); |
|
645 |
} |
|
646 |
} |
|
647 |
} |
|
648 |
|
|
649 |
|
|
650 |
/** |
|
651 |
* @param state |
|
652 |
*/ |
|
653 |
private void initChorologicalVocabulary(SimpleExcelTaxonImportState<CONFIG> state) { |
|
654 |
if (chorologicalVoc == null){ |
|
655 |
UUID uuid = FloraHellenicaTransformer.uuidFloraHellenicaChorologicalVoc; |
|
656 |
chorologicalVoc = (OrderedTermVocabulary<State>)this.getVocabularyService().find(uuid); |
|
657 |
if (chorologicalVoc == null){ |
|
658 |
createChorologicalVoc(state, uuid); |
|
659 |
} |
|
660 |
} |
|
661 |
|
|
662 |
} |
|
663 |
|
|
664 |
|
|
665 |
@SuppressWarnings("unchecked") |
|
666 |
private void initLifeformVocabulary(SimpleExcelTaxonImportState<CONFIG> state) { |
|
667 |
if (lifeformVoc == null){ |
|
668 |
UUID uuid = FloraHellenicaTransformer.uuidFloraHellenicaLifeformVoc; |
|
669 |
lifeformVoc = (OrderedTermVocabulary<State>)this.getVocabularyService().find(uuid); |
|
670 |
if (lifeformVoc == null){ |
|
671 |
createLifeformVoc(state, uuid); |
|
672 |
} |
|
673 |
} |
|
674 |
} |
|
675 |
|
|
676 |
/** |
|
677 |
* @param state |
|
678 |
* @param vocUuid |
|
679 |
*/ |
|
680 |
private void createLifeformVoc(SimpleExcelTaxonImportState<CONFIG> state, UUID vocUuid) { |
|
681 |
//voc |
|
682 |
URI termSourceUri = null; |
|
683 |
String label = "Checklist of Greece Lifeforms"; |
|
684 |
String description = "Lifeforms as used in the Checklist of Greece"; |
|
685 |
lifeformVoc = OrderedTermVocabulary.NewInstance(TermType.State, |
|
686 |
description, label, null, termSourceUri); |
|
687 |
lifeformVoc.setUuid(vocUuid); |
|
688 |
|
|
689 |
addLifeform(state, "A", "Aquatic", FloraHellenicaTransformer.uuidLifeformA); |
|
690 |
addLifeform(state, "C", "Chamaephyte", FloraHellenicaTransformer.uuidLifeformC); |
|
691 |
addLifeform(state, "G", "Geophyte (Cryptophyte)", FloraHellenicaTransformer.uuidLifeformG); |
|
692 |
addLifeform(state, "H", "Hemicryptophyte", FloraHellenicaTransformer.uuidLifeformH); |
|
693 |
addLifeform(state, "P", "Phanerophyte", FloraHellenicaTransformer.uuidLifeformP); |
|
694 |
addLifeform(state, "T", "Therophyte", FloraHellenicaTransformer.uuidLifeformT); |
|
695 |
this.getVocabularyService().save(lifeformVoc); |
|
696 |
return; |
|
697 |
} |
|
698 |
|
|
699 |
|
|
700 |
/** |
|
701 |
* @param state |
|
702 |
* @param uuid |
|
703 |
*/ |
|
704 |
private void createChorologicalVoc(SimpleExcelTaxonImportState<CONFIG> state, UUID vocUuid) { |
|
705 |
//voc |
|
706 |
URI termSourceUri = null; |
|
707 |
String label = "Checklist of Greece Chorological Categories"; |
|
708 |
String description = "Chorological Categories as used in the Checklist of Greece"; |
|
709 |
chorologicalVoc = OrderedTermVocabulary.NewInstance(TermType.State, |
|
710 |
description, label, null, termSourceUri); |
|
711 |
chorologicalVoc.setUuid(vocUuid); |
|
712 |
|
|
713 |
addChorological(state, "*", "Greek endemic", "Greek endemics (incl. single-island and single-mountain endemics)", FloraHellenicaTransformer.uuidChorologicalStar); |
|
714 |
addChorological(state, "Bk", "Balkan", "Taxa restricted to Balkan countries, occasionally extending to adjacent parts of SE Europe", FloraHellenicaTransformer.uuidChorologicalBk); |
|
715 |
addChorological(state, "BI", "Balkan-Italy", "Taxa restricted to Balkan countries and Italy (amphi-Adreatic)", FloraHellenicaTransformer.uuidChorologicalBI); |
|
716 |
addChorological(state, "BA", "Balkan-Anatolia", "Taxa restricted to Balkan countries and to Asia minor (Anatolia), occasionally extending to S Ukraine (Crimea), adjacent Caucasian countries (Georgia, Armenia) or N Iraq", FloraHellenicaTransformer.uuidChorologicalBA); |
|
717 |
addChorological(state, "BC", "Balkan-Central Europe", "Taxa distributed in the Balkans, Carpathians, Alps and adjacent areas (mainly in the mountains)", FloraHellenicaTransformer.uuidChorologicalBC); |
|
718 |
addChorological(state, "EM", "East Mediterranean", "Taxa restricted to the E Mediterranean, occasionally extending to S Italy or adjacent Caucasian countries", FloraHellenicaTransformer.uuidChorologicalEM); |
|
719 |
addChorological(state, "Me", "Mediterranean", "Taxa with a circum-Mediterranean distribution including Portugal, occasionally extending to the Caucasus area and N Iran", FloraHellenicaTransformer.uuidChorologicalMe); |
|
720 |
addChorological(state, "MA", "Mediterranean-Atlantic", "Taxa restricted to maritime W Europe and the Mediterranean", FloraHellenicaTransformer.uuidChorologicalMA); |
|
721 |
addChorological(state, "ME", "Mediterranean-European", "Taxa restricted to the Mediterranean and temperate Europe, occasionally extending to NW Africa and the Caucasus area", FloraHellenicaTransformer.uuidChorologicalME); |
|
722 |
addChorological(state, "MS", "Mediterranean-SW Asian", "Taxa distributed in one or more Mediterranean countries and extending to SW and C Asia", FloraHellenicaTransformer.uuidChorologicalMS); |
|
723 |
addChorological(state, "EA", "European-SW Asian", "Eruopean taxa (occasionally reachin N Africa) with a distribution extending to SW Asia, occasionally reaching C Asia", FloraHellenicaTransformer.uuidChorologicalEA); |
|
724 |
addChorological(state, "ES", "Euro-Siberian", "Taxa with main distribution in temperate Eurasia (occasionally reaching the Caucasus area)", FloraHellenicaTransformer.uuidChorologicalES); |
|
725 |
addChorological(state, "Eu", "European", "Taxa with a distribution all over Europe. In S European countries this category in fact represents the C European element", FloraHellenicaTransformer.uuidChorologicalEu); |
|
726 |
addChorological(state, "Pt", "Paleotemperate", "Taxa of extratropical Eurasia including the Himalaya and E Asia, not (or at most marginally) extending to North America", FloraHellenicaTransformer.uuidChorologicalPt); |
|
727 |
addChorological(state, "Ct", "Circumtemperate", "Taxa of both extratropical Eurasia and North America", FloraHellenicaTransformer.uuidChorologicalCt); |
|
728 |
addChorological(state, "IT", "Irano-Turanian", "Taxa with main distribution in arid SW and C Asia, extrazonally extending to the Mediterranean", FloraHellenicaTransformer.uuidChorologicalIT); |
|
729 |
addChorological(state, "SS", "Saharo-Sindian", "Taxa with main distribution in arid N Africa and SQ Asia, extrazonally extending to the Mediterranean", FloraHellenicaTransformer.uuidChorologicalSS); |
|
730 |
addChorological(state, "ST", "Subtropical-tropical", "Taxa widespread in the warmer regions of both hemispheres", FloraHellenicaTransformer.uuidChorologicalST); |
|
731 |
addChorological(state, "Bo", "(Circum-)Boreal", "Taxa with main distribution in N and high-montane Eurasia (occasionally extending to North America)", FloraHellenicaTransformer.uuidChorologicalBo); |
|
732 |
addChorological(state, "AA", "Arctic-Alpine", "Taxa with main distribution beyound the N and aove the high-montane timerlines o fEurasia (occasionally extending to North America)", FloraHellenicaTransformer.uuidChorologicalAA); |
|
733 |
addChorological(state, "Co", "Cosmopolitan", "Taxa distributed in all continents, i.e. beyond the N hemisphere. This category may be given in brackets after the known or supposed native distribution in cases of taxa that have been spread worldwide by humans", FloraHellenicaTransformer.uuidChorologicalCo); |
|
734 |
|
|
735 |
addChorological(state, "[trop.]", "[tropical]", "", FloraHellenicaTransformer.uuidChorologicaltrop); |
|
736 |
addChorological(state, "[subtrop.]", "[subtropical]", "", FloraHellenicaTransformer.uuidChorologicalsubtrop); |
|
737 |
addChorological(state, "[paleotrop.]", "[paleotropical]", "", FloraHellenicaTransformer.uuidChorologicalpaleotrop); |
|
738 |
addChorological(state, "[neotrop.]", "[neotropical]", "", FloraHellenicaTransformer.uuidChorologicalneotrop); |
|
739 |
addChorological(state, "[pantrop.]", "[pantropical]", "", FloraHellenicaTransformer.uuidChorologicalpantrop); |
|
740 |
addChorological(state, "[N-Am.]", "[North American]", "", FloraHellenicaTransformer.uuidChorologicalN_Am); |
|
741 |
addChorological(state, "[S-Am.]", "[South American]", "", FloraHellenicaTransformer.uuidChorologicalS_Am); |
|
742 |
addChorological(state, "[E-As.]", "[East Asian]", "", FloraHellenicaTransformer.uuidChorologicalE_As); |
|
743 |
addChorological(state, "[SE-As.", "[South East Asian]", "", FloraHellenicaTransformer.uuidChorologicalSE_As); |
|
744 |
addChorological(state, "[S-Afr.]", "[South African]", "", FloraHellenicaTransformer.uuidChorologicalS_Afr); |
|
745 |
addChorological(state, "[Arab.]", "[Arabian]", "", FloraHellenicaTransformer.uuidChorologicalArab); |
|
746 |
addChorological(state, "[Arab. NE-Afr.]", "[Arabian and North East African]", "", FloraHellenicaTransformer.uuidChorologicalArab_NE_Afr); |
|
747 |
addChorological(state, "[Caucas.]", "[Caucasian]", "", FloraHellenicaTransformer.uuidChorologicalCaucas); |
|
748 |
addChorological(state, "[Pontic]", "[Pontic]", "", FloraHellenicaTransformer.uuidChorologicalPontic); |
|
749 |
addChorological(state, "[Europ.]", "[European]", "", FloraHellenicaTransformer.uuidChorologicalEurop); |
|
750 |
addChorological(state, "[Austr.]", "[Australian]", "", FloraHellenicaTransformer.uuidChorologicalAustral); |
|
751 |
|
|
752 |
addChorological(state, "[W-Med.]", "[West Mediterranean]", "", FloraHellenicaTransformer.uuidChorologicalW_Med); |
|
753 |
addChorological(state, "[C-Med.]", "[Central Mediterranean]", "", FloraHellenicaTransformer.uuidChorologicalC_Med); |
|
754 |
addChorological(state, "[W-Eur.]", "[West European]", "", FloraHellenicaTransformer.uuidChorologicalW_Eur); |
|
755 |
addChorological(state, "[S-Eur.]", "[South European]", "", FloraHellenicaTransformer.uuidChorologicalS_Eur); |
|
756 |
addChorological(state, "[C-Am.]", "[Central American]", "", FloraHellenicaTransformer.uuidChorologicalC_Am); |
|
757 |
addChorological(state, "[C-As.]", "[Central Asian]", "", FloraHellenicaTransformer.uuidChorologicalC_As); |
|
758 |
addChorological(state, "[SW-As.]", "[South West Asian]", "", FloraHellenicaTransformer.uuidChorologicalSW_As); |
|
759 |
addChorological(state, "[unknown]", "[unknown]", "", FloraHellenicaTransformer.uuidChorologicalUnknown); |
|
760 |
addChorological(state, "[N-Afr.]", "[North African]", "", FloraHellenicaTransformer.uuidChorologicalN_Afr); |
|
761 |
addChorological(state, "[Am.]", "[American]", "", FloraHellenicaTransformer.uuidChorologicalAm); |
|
762 |
addChorological(state, "[paleosubtrop.]", "[paleosubtropical]", "", FloraHellenicaTransformer.uuidChorologicalPaleosubtrop); |
|
763 |
addChorological(state, "[SW-Eur.]", "[South West European]", "", FloraHellenicaTransformer.uuidChorologicalSW_Eur); |
|
764 |
|
|
765 |
addChorological(state, "[S-As.]", "[South Asian]", "", FloraHellenicaTransformer.uuidChorologicalS_As); |
|
766 |
addChorological(state, "[NE-Afr.]", "[North East African]", "", FloraHellenicaTransformer.uuidChorologicalNE_Afr); |
|
767 |
addChorological(state, "[NW-Afr.]", "[North West African]", "", FloraHellenicaTransformer.uuidChorologicalNW_Afr); |
|
768 |
addChorological(state, "[trop. Afr.]", "[tropical African]", "", FloraHellenicaTransformer.uuidChorologicalTrop_Afr); |
|
769 |
addChorological(state, "[Afr.]", "[Arican]", "", FloraHellenicaTransformer.uuidChorologicalAfr); |
|
770 |
addChorological(state, "[As.]", "[Asian]", "", FloraHellenicaTransformer.uuidChorologicalAs); |
|
771 |
addChorological(state, "[W-As.]", "[West Asian]", "", FloraHellenicaTransformer.uuidChorologicalW_As); |
|
772 |
addChorological(state, "[C-Eur.]", "[Central European]", "", FloraHellenicaTransformer.uuidChorologicalC_Eur); |
|
773 |
addChorological(state, "[E-Afr.]", "[East African]", "", FloraHellenicaTransformer.uuidChorologicalE_Afr); |
|
774 |
addChorological(state, "[W-Austr.]", "[West Australian]", "", FloraHellenicaTransformer.uuidChorologicalW_Austr); |
|
775 |
addChorological(state, "[trop. As.]", "[tropical Asian]", "", FloraHellenicaTransformer.uuidChorologicaltrop_As); |
|
776 |
|
|
777 |
addChorological(state, "[Co]", "[Cosmopolitan]", "Taxa distributed in all continents, i.e. beyond the N hemisphere. This category may be given in brackets after the known or supposed native distribution in cases of taxa that have been spread worldwide by humans", FloraHellenicaTransformer.uuidChorological__Co_); |
|
778 |
|
|
779 |
this.getVocabularyService().save(chorologicalVoc); |
|
780 |
return; |
|
781 |
|
|
782 |
} |
|
783 |
|
|
784 |
|
|
785 |
/** |
|
786 |
* @param state |
|
787 |
* @param string |
|
788 |
* @param string2 |
|
789 |
* @param string3 |
|
790 |
* @param uuidchorologicalstar |
|
791 |
*/ |
|
792 |
private void addChorological(SimpleExcelTaxonImportState<CONFIG> state, String abbrevLabel, String label, |
|
793 |
String desc, UUID uuidChorological) { |
|
794 |
desc = isBlank(desc)? label : desc; |
|
795 |
State chorologyTerm = addState(state, abbrevLabel, label, desc, uuidChorological, chorologicalVoc); |
|
796 |
chorologyMap.put(abbrevLabel, chorologyTerm); |
|
797 |
} |
|
798 |
|
|
799 |
/** |
|
800 |
* @param state |
|
801 |
* @param string |
|
802 |
* @param uuidlifeformt |
|
803 |
*/ |
|
804 |
private void addLifeform(SimpleExcelTaxonImportState<CONFIG> state, String abbrevLabel, String label, UUID uuidlifeform) { |
|
805 |
State lifeForm = addState(state, abbrevLabel, label, label, uuidlifeform, lifeformVoc); |
|
806 |
lifeformMap.put(abbrevLabel, lifeForm); |
|
807 |
} |
|
808 |
|
|
809 |
private State addState(SimpleExcelTaxonImportState<CONFIG> state, |
|
810 |
String abbrev, String stateLabel, String description, UUID uuid, OrderedTermVocabulary<State> voc) { |
|
811 |
State newState = State.NewInstance( |
|
812 |
description, stateLabel, abbrev); |
|
813 |
newState.setUuid(uuid); |
|
814 |
newState.setIdInVocabulary(abbrev); |
|
815 |
voc.addTerm(newState); |
|
816 |
return newState; |
|
817 |
} |
|
818 |
|
|
819 |
private PresenceAbsenceTerm addStatus(SimpleExcelTaxonImportState<CONFIG> state, |
|
820 |
String abbrev, String stateLabel, String description, UUID uuid, OrderedTermVocabulary<PresenceAbsenceTerm> voc) { |
|
821 |
PresenceAbsenceTerm newStatus = PresenceAbsenceTerm.NewPresenceInstance( |
|
822 |
description, stateLabel, abbrev); |
|
823 |
newStatus.setUuid(uuid); |
|
824 |
newStatus.setIdInVocabulary(abbrev); |
|
825 |
newStatus.setSymbol(abbrev); |
|
826 |
voc.addTerm(newStatus); |
|
827 |
return newStatus; |
|
828 |
} |
|
829 |
|
|
830 |
private void initHabitatVocabulary(SimpleExcelTaxonImportState<CONFIG> state) { |
|
831 |
if (habitatVoc == null){ |
|
832 |
UUID uuid = FloraHellenicaTransformer.uuidFloraHellenicaHabitatVoc; |
|
833 |
habitatVoc = (OrderedTermVocabulary<State>)this.getVocabularyService().find(uuid); |
|
834 |
if (habitatVoc == null){ |
|
835 |
createHabitatVoc(state, uuid); |
|
601 |
DescriptionElementBase descEl; |
|
602 |
if (state.getConfig().isStatusAsDistribution()){ |
|
603 |
NamedArea area = getNamedArea(state, uuid, null, null, null, null, null); |
|
604 |
if (value == null || ".".equals(value) ){ |
|
605 |
descEl = Distribution.NewInstance(area, PresenceAbsenceTerm.NATIVE()); |
|
606 |
if (".".equals(value)){ |
|
607 |
logger.warn(line + "'.' Should not exist anymore as a distribution status: '" + value + "' for " + key); |
|
608 |
} |
|
609 |
}else if ("Range-restricted".equals(value)){ |
|
610 |
descEl = Distribution.NewInstance(area, rangeRestricted); |
|
611 |
}else if ("?Range-restricted".equals(value)){ |
|
612 |
descEl = Distribution.NewInstance(area, doubtfullyRangeRestricted); |
|
613 |
}else if ("Xenophyte".equals(value)){ |
|
614 |
descEl = Distribution.NewInstance(area, PresenceAbsenceTerm.INTRODUCED()); |
|
615 |
}else if ("?Xenophyte".equals(value)){ |
|
616 |
descEl = Distribution.NewInstance(area, PresenceAbsenceTerm.INTRODUCED_DOUBTFULLY_INTRODUCED()); |
|
617 |
}else { |
|
618 |
logger.warn(line + "Not matching status. This should not happpen '" + value + "' for " + key); |
|
619 |
return; |
|
836 | 620 |
} |
837 |
} |
|
838 |
} |
|
839 |
|
|
840 |
private void initStatusVocabulary(SimpleExcelTaxonImportState<CONFIG> state) { |
|
841 |
if (statusVoc == null){ |
|
842 |
UUID uuid = FloraHellenicaTransformer.uuidFloraHellenicaStatusVoc; |
|
843 |
statusVoc = (OrderedTermVocabulary<PresenceAbsenceTerm>)this.getVocabularyService().find(uuid); |
|
844 |
if (statusVoc == null){ |
|
845 |
createStatusVoc(state, uuid); |
|
621 |
}else{ |
|
622 |
CategoricalData catData = CategoricalData.NewInstance(Feature.STATUS()); |
|
623 |
descEl = catData; |
|
624 |
if (value == null || ".".equals(value) ){ |
|
625 |
handleSingleStatus(state, catData, FloraHellenicaTransformer.uuidStatusNative, line); |
|
626 |
if (".".equals(value)){ |
|
627 |
logger.warn(line + "'.' Should not exist anymore as a status: '" + value + "' for " + key); |
|
628 |
} |
|
629 |
}else if ("Range-restricted".equals(value)){ |
|
630 |
handleSingleStatus(state, catData, FloraHellenicaTransformer.uuidStatusRangeRestricted, line); |
|
631 |
}else if ("?Range-restricted".equals(value)){ |
|
632 |
handleSingleStatus(state, catData, FloraHellenicaTransformer.uuidStatusRangeRestricted, line); |
|
633 |
}else if ("Xenophyte".equals(value)){ |
|
634 |
handleSingleStatus(state, catData, FloraHellenicaTransformer.uuidStatusRangeRestricted, line); |
|
635 |
}else if ("?Xenophyte".equals(value)){ |
|
636 |
handleSingleStatus(state, catData, FloraHellenicaTransformer.uuidStatusRangeRestricted, line); |
|
637 |
}else { |
|
638 |
logger.warn(line + "Not matching status. This should not happpen '" + value + "' for " + key); |
|
639 |
return; |
|
846 | 640 |
} |
847 | 641 |
} |
848 |
} |
|
849 |
|
|
850 |
/** |
|
851 |
* @param state |
|
852 |
*/ |
|
853 |
private void createStatusVoc(SimpleExcelTaxonImportState<CONFIG> state, UUID vocUuid) { |
|
854 |
//voc |
|
855 |
URI termSourceUri = null; |
|
856 |
String label = "Checklist of Greece Status"; |
|
857 |
String description = "Status as used in the Checklist of Greece"; |
|
858 |
statusVoc = OrderedTermVocabulary.NewInstance(TermType.PresenceAbsenceTerm, |
|
859 |
description, label, null, termSourceUri); |
|
860 |
statusVoc.setUuid(vocUuid); |
|
861 |
|
|
862 |
rangeRestricted = addStatus(state, "RR", "Range-restricted", "", FloraHellenicaTransformer.uuidStatusRangeRestricted, statusVoc); |
|
863 |
doubtfullyRangeRestricted = addStatus(state, "?RR", "?Range-restricted", "", FloraHellenicaTransformer.uuidStatusRangeRestrictedDoubtfully, statusVoc); |
|
864 |
|
|
865 |
this.getVocabularyService().save(statusVoc); |
|
866 |
return; |
|
867 |
} |
|
868 |
|
|
869 |
|
|
870 |
/** |
|
871 |
* @param state |
|
872 |
*/ |
|
873 |
private void createHabitatVoc(SimpleExcelTaxonImportState<CONFIG> state, UUID vocUuid) { |
|
874 |
//voc |
|
875 |
URI termSourceUri = null; |
|
876 |
String label = "Checklist of Greece Habitats"; |
|
877 |
String description = "Habitats as used in the Checklist of Greece"; |
|
878 |
habitatVoc = OrderedTermVocabulary.NewInstance(TermType.State, |
|
879 |
description, label, null, termSourceUri); |
|
880 |
habitatVoc.setUuid(vocUuid); |
|
881 |
|
|
882 |
addHabitat(state, "A", "Freshwater habitats", "Freshwater habitats (Aquatic habitats, springs and fens, reedbeds and damp tall herb vegetation, seasonally flooded depressions, damp and seepage meadows, streambanks, river and lake shores)", FloraHellenicaTransformer.uuidHabitatA); |
|
883 |
addHabitat(state, "C", "Cliffs, rocks, walls, ravines, boulders", "Cliffs, rocks, walls, ravines, boulders", FloraHellenicaTransformer.uuidHabitatC); |
|
884 |
addHabitat(state, "G", "Temperate and submediterranean Grasslands", "Temperate and submediterranean Grasslands (lowland to montane dry and mesic meadows and pastures, rock outcrops and stony ground, grassy non-ruderal verges and forest edges)", FloraHellenicaTransformer.uuidHabitatG); |
|
885 |
addHabitat(state, "H", "High mountain vegetation", "High mountain vegetation (subalpine and alpine grasslands, screes and rocks, scrub above the treeline)", FloraHellenicaTransformer.uuidHabitatH); |
|
886 |
addHabitat(state, "M", "Coastal habitats", "Coastal habitats (Marine waters and mudflats, salt marshes, sand dunes, littoral rocks, halo-nitrophilous scrub)", FloraHellenicaTransformer.uuidHabitatM); |
|
887 |
addHabitat(state, "P", "Xeric Mediterranean Phrygana and grasslands", "Xeric Mediterranean Phrygana and grasslands (Mediterranean dwarf shrub formations, annual-rich pastures and lowland screes)", FloraHellenicaTransformer.uuidHabitatP); |
|
888 |
addHabitat(state, "R", "Agricultural and Ruderal habitats", "Agricultural and Ruderal habitats (fields, gardens and plantations, roadsides and trampled sites, frequently disturbed and pioneer habitats)", FloraHellenicaTransformer.uuidHabitatR); |
|
889 |
addHabitat(state, "W", "Woodlands and scrub", "Woodlands and scrub (broadleaved and coniferous forest, riparian and mountain forest and scrub, hedges, shady woodland margins)", FloraHellenicaTransformer.uuidHabitatW); |
|
890 |
|
|
891 |
this.getVocabularyService().save(habitatVoc); |
|
892 |
return; |
|
893 |
} |
|
894 |
|
|
895 |
/** |
|
896 |
* @param state |
|
897 |
* @param string |
|
898 |
* @param uuidlifeformt |
|
899 |
*/ |
|
900 |
private void addHabitat(SimpleExcelTaxonImportState<CONFIG> state, String abbrev, String label, String desc, UUID uuidHabitat) { |
|
901 |
addState(state, abbrev, label, desc, uuidHabitat, habitatVoc); |
|
902 |
} |
|
903 | 642 |
|
904 |
/** |
|
905 |
* @param state |
|
906 |
* @return |
|
907 |
*/ |
|
908 |
@SuppressWarnings("unchecked") |
|
909 |
private void createAreasVoc(SimpleExcelTaxonImportState<CONFIG> state) { |
|
910 |
//voc |
|
911 |
URI termSourceUri = null; |
|
912 |
String label = "Checklist of Greece Areas"; |
|
913 |
String description = "Areas as used in the Checklist of Greece"; |
|
914 |
areasVoc = OrderedTermVocabulary.NewInstance(TermType.NamedArea, |
|
915 |
description, label, null, termSourceUri); |
|
916 |
areasVoc.setUuid(FloraHellenicaTransformer.uuidFloraHellenicaAreasVoc); |
|
917 |
// Representation rep = Representation.NewInstance("Estados Méxicanos", "Estados Méxicanos", null, Language.SPANISH_CASTILIAN()); |
|
918 |
// areasVoc.addRepresentation(rep); |
|
919 |
|
|
920 |
//greece country |
|
921 |
String countryLabel = "Greece"; |
|
922 |
greece = NamedArea.NewInstance(countryLabel, countryLabel, "GR"); |
|
923 |
greece.setUuid(FloraHellenicaTransformer.uuidAreaGreece); |
|
924 |
greece.setIdInVocabulary("GR"); |
|
925 |
greece.setSymbol("GR"); |
|
926 |
areasVoc.addTerm(greece); |
|
927 |
//FIXME |
|
928 |
// addMapping(greece, xx "mex_adm0", "iso", "MEX"); |
|
929 |
|
|
930 |
addArea(state, "IoI", "Ionian Islands", 4, FloraHellenicaTransformer.uuidAreaIoI); |
|
931 |
addArea(state, "NPi", "North Pindos", 13, FloraHellenicaTransformer.uuidAreaNPi); |
|
932 |
addArea(state, "SPi", "South Pindos", 11, FloraHellenicaTransformer.uuidAreaSPi); |
|
933 |
addArea(state, "Pe", "Peloponnisos", 1, FloraHellenicaTransformer.uuidAreaPe); |
|
934 |
addArea(state, "StE", "Sterea Ellas", 12, FloraHellenicaTransformer.uuidAreaStE); |
|
935 |
addArea(state, "EC", "East Central Greece", 5, FloraHellenicaTransformer.uuidAreaEC); |
|
936 |
addArea(state, "NC", "North Central Greece", 2, FloraHellenicaTransformer.uuidAreaNC); |
|
937 |
addArea(state, "NE", "North-East Greece", 10, FloraHellenicaTransformer.uuidAreaNE); |
|
938 |
addArea(state, "NAe", "North Aegean islands", 7, FloraHellenicaTransformer.uuidAreaNAe); |
|
939 |
addArea(state, "WAe", "West Aegean islands", 9, FloraHellenicaTransformer.uuidAreaWAe); |
|
940 |
addArea(state, "Kik", "Kiklades", 8, FloraHellenicaTransformer.uuidAreaKik); |
|
941 |
addArea(state, "KK", "Kriti and Karpathos", 6, FloraHellenicaTransformer.uuidAreaKK); |
|
942 |
addArea(state, "EAe", "East Aegean islands", 3, FloraHellenicaTransformer.uuidAreaEAe); |
|
943 |
|
|
944 |
this.getVocabularyService().save(areasVoc); |
|
945 |
return; |
|
946 |
} |
|
947 |
|
|
948 |
private void addArea(SimpleExcelTaxonImportState<CONFIG> state, String abbrevLabel, String areaLabel, |
|
949 |
Integer id, UUID uuid) { |
|
950 |
addArea(state, abbrevLabel, areaLabel, uuid, String.valueOf(id)); //short cut if label and mapping label are equal |
|
643 |
desc.addElement(descEl); |
|
644 |
descEl.addImportSource(id, getWorksheetName(), getSourceCitation(state), line); |
|
951 | 645 |
} |
952 | 646 |
|
953 |
private void addArea(SimpleExcelTaxonImportState<CONFIG> state, String abbrevLabel, String areaLabel, |
|
954 |
UUID uuid, String mappingLabel) { |
|
955 |
addArea(state, abbrevLabel, areaLabel, uuid, mappingLabel, null); //short cut if label and mapping label are equal |
|
956 |
} |
|
647 |
private void handleSingleStatus(SimpleExcelTaxonImportState<CONFIG> state, CategoricalData catData, |
|
648 |
UUID uuidStatus, String line) { |
|
957 | 649 |
|
958 |
|
|
959 |
/** |
|
960 |
* @param state |
|
961 |
* @param string |
Also available in: Unified diff
ref #6286 updates for Flora Hellenica import (including new image import)