Revision 379eb203
Added by Andreas Müller over 3 years ago
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/common/mapping/MultipleAttributeMapperBase.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.common.mapping; |
11 | 10 |
|
12 | 11 |
import java.sql.ResultSet; |
... | ... | |
19 | 18 |
import org.apache.commons.lang3.StringUtils; |
20 | 19 |
import org.apache.log4j.Logger; |
21 | 20 |
|
22 |
|
|
23 |
|
|
24 | 21 |
/** |
25 | 22 |
* @author a.mueller |
26 | 23 |
* @since 12.05.2009 |
27 |
* @version 1.0 |
|
28 | 24 |
*/ |
29 | 25 |
public abstract class MultipleAttributeMapperBase<SINGLE_MAPPER extends CdmSingleAttributeMapperBase> extends CdmAttributeMapperBase { |
30 | 26 |
@SuppressWarnings("unused") |
... | ... | |
33 | 29 |
|
34 | 30 |
//******************************* ATTRIBUTES ***************************************/ |
35 | 31 |
|
36 |
protected List<SINGLE_MAPPER> singleMappers = new ArrayList<SINGLE_MAPPER>(); |
|
37 |
|
|
38 |
|
|
32 |
protected List<SINGLE_MAPPER> singleMappers = new ArrayList<>(); |
|
39 | 33 |
|
40 | 34 |
//********************************* CONSTRUCTOR ****************************************/ |
41 | 35 |
|
42 |
/** |
|
43 |
* |
|
44 |
*/ |
|
45 | 36 |
public MultipleAttributeMapperBase() { |
46 | 37 |
singleMappers = new ArrayList<SINGLE_MAPPER>(); |
47 | 38 |
} |
48 | 39 |
|
49 |
|
|
50 | 40 |
//************************************ METHODS *******************************************/ |
51 | 41 |
|
52 |
/* (non-Javadoc) |
|
53 |
* @see eu.etaxonomy.cdm.io.common.CdmAttributeMapperBase#getDestinationAttributeList() |
|
54 |
*/ |
|
55 | 42 |
@Override |
56 | 43 |
public List<String> getDestinationAttributeList() { |
57 |
List<String> result = new ArrayList<String>();
|
|
44 |
List<String> result = new ArrayList<>(); |
|
58 | 45 |
for (SINGLE_MAPPER singleMapper : singleMappers){ |
59 | 46 |
result.addAll(singleMapper.getDestinationAttributeList()); |
60 | 47 |
} |
61 | 48 |
return result; |
62 | 49 |
} |
63 | 50 |
|
64 |
/* (non-Javadoc) |
|
65 |
* @see eu.etaxonomy.cdm.io.common.CdmAttributeMapperBase#getDestinationAttributes() |
|
66 |
*/ |
|
67 | 51 |
@Override |
68 | 52 |
public Set<String> getDestinationAttributes() { |
69 |
Set<String> result = new HashSet<String>();
|
|
53 |
Set<String> result = new HashSet<>(); |
|
70 | 54 |
result.addAll(getDestinationAttributeList()); |
71 | 55 |
return result; |
72 | 56 |
} |
73 | 57 |
|
74 |
/* (non-Javadoc) |
|
75 |
* @see eu.etaxonomy.cdm.io.common.CdmAttributeMapperBase#getSourceAttributeList() |
|
76 |
*/ |
|
77 | 58 |
@Override |
78 | 59 |
public List<String> getSourceAttributeList() { |
79 |
List<String> result = new ArrayList<String>();
|
|
60 |
List<String> result = new ArrayList<>(); |
|
80 | 61 |
for (SINGLE_MAPPER singleMapper : singleMappers){ |
81 | 62 |
result.addAll(singleMapper.getSourceAttributeList()); |
82 | 63 |
} |
83 | 64 |
return result; |
84 | 65 |
} |
85 | 66 |
|
86 |
/* (non-Javadoc) |
|
87 |
* @see eu.etaxonomy.cdm.io.common.CdmAttributeMapperBase#getSourceAttributes() |
|
88 |
*/ |
|
89 | 67 |
@Override |
90 | 68 |
public Set<String> getSourceAttributes() { |
91 |
Set<String> result = new HashSet<String>();
|
|
69 |
Set<String> result = new HashSet<>(); |
|
92 | 70 |
result.addAll(getSourceAttributeList()); |
93 | 71 |
return result; |
94 | 72 |
} |
95 | 73 |
|
96 |
|
|
97 |
/** |
|
74 |
/** |
|
98 | 75 |
* Returns the value of a result set attribute in its String representation. |
99 | 76 |
* Better move this to a subclass for DbImportMappers (does not exist yet) |
100 | 77 |
*/ |
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/common/mapping/berlinModel/CdmOneToManyMapper.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 |
*/ |
... | ... | |
42 | 42 |
this.oneClass = oneClass; |
43 | 43 |
this.singleAttributeName = singleAttributeName; |
44 | 44 |
} |
45 |
|
|
45 |
|
|
46 | 46 |
// @Override |
47 | 47 |
// public Set<String> getSourceAttributes(){ |
48 |
// Set<String> result = new HashSet<String>();
|
|
48 |
// Set<String> result = new HashSet<>(); |
|
49 | 49 |
// result.addAll(getSourceAttributeList()); |
50 | 50 |
// return result; |
51 | 51 |
// } |
52 |
|
|
52 |
|
|
53 | 53 |
@Override |
54 | 54 |
public List<String> getSourceAttributeList(){ |
55 | 55 |
List<String> result = new ArrayList<String>(); |
... | ... | |
58 | 58 |
} |
59 | 59 |
return result; |
60 | 60 |
} |
61 |
|
|
61 |
|
|
62 | 62 |
// @Override |
63 | 63 |
// public Set<String> getDestinationAttributes(){ |
64 |
// Set<String> result = new HashSet<String>();
|
|
64 |
// Set<String> result = new HashSet<>(); |
|
65 | 65 |
// result.addAll(getDestinationAttributeList()); |
66 | 66 |
// return result; |
67 | 67 |
// } |
68 |
|
|
68 |
|
|
69 | 69 |
@Override |
70 | 70 |
public List<String> getDestinationAttributeList(){ |
71 | 71 |
List<String> result = new ArrayList<String>(); |
... | ... | |
75 | 75 |
return result; |
76 | 76 |
} |
77 | 77 |
|
78 |
|
|
78 |
|
|
79 | 79 |
public Class<MANY> getManyClass(){ |
80 | 80 |
return manyClass; |
81 | 81 |
} |
82 |
|
|
82 |
|
|
83 | 83 |
public Class<ONE> getOneClass(){ |
84 | 84 |
return oneClass; |
85 | 85 |
} |
86 |
|
|
86 |
|
|
87 | 87 |
public String getDestinationAttribute(String sourceAttribute){ |
88 | 88 |
if (sourceAttribute == null){ |
89 | 89 |
return null; |
... | ... | |
95 | 95 |
} |
96 | 96 |
return null; |
97 | 97 |
} |
98 |
|
|
98 |
|
|
99 | 99 |
public List<SINGLE_MAPPER> getSingleMappers(){ |
100 | 100 |
return singleMappers; |
101 | 101 |
} |
... | ... | |
106 | 106 |
public String getSingleAttributeName() { |
107 | 107 |
return singleAttributeName; |
108 | 108 |
} |
109 |
|
|
109 |
|
|
110 | 110 |
} |
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/common/mapping/out/ObjectChangeMapper.java | ||
---|---|---|
85 | 85 |
|
86 | 86 |
@Override |
87 | 87 |
public Set<String> getSourceAttributes() { |
88 |
Set<String> result = new HashSet<String>();
|
|
88 |
Set<String> result = new HashSet<>(); |
|
89 | 89 |
if (cdmAttribute != null){ |
90 | 90 |
result.add(cdmAttribute); |
91 | 91 |
} |
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/dwca/in/DwcTaxonCsv2CdmTaxonRelationConverter.java | ||
---|---|---|
52 | 52 |
|
53 | 53 |
private static final String ID = "id"; |
54 | 54 |
|
55 |
/** |
|
56 |
* @param state |
|
57 |
*/ |
|
58 | 55 |
public DwcTaxonCsv2CdmTaxonRelationConverter(DwcaDataImportStateBase state) { |
59 | 56 |
super(state); |
60 | 57 |
} |
... | ... | |
68 | 65 |
} |
69 | 66 |
} |
70 | 67 |
|
71 |
|
|
72 | 68 |
@Override |
73 | 69 |
public IReader<MappedCdmBase<? extends CdmBase>> map(StreamItem item){ |
74 | 70 |
List<MappedCdmBase<? extends CdmBase>> resultList = new ArrayList<>(); |
... | ... | |
137 | 133 |
return new ListReader<>(resultList); |
138 | 134 |
} |
139 | 135 |
|
140 |
|
|
141 | 136 |
@Override |
142 | 137 |
public String getSourceId(StreamItem item) { |
143 | 138 |
String id = item.get(ID); |
144 | 139 |
return id; |
145 | 140 |
} |
146 | 141 |
|
147 |
|
|
148 | 142 |
private void handleSubGenus(StreamItem item, DwcaDataImportStateBase<DwcaDataImportConfiguratorBase> state) { |
149 | 143 |
// TODO Auto-generated method stub |
150 | 144 |
} |
... | ... | |
173 | 167 |
// TODO Auto-generated method stub |
174 | 168 |
} |
175 | 169 |
|
176 |
|
|
177 | 170 |
private void handleParentNameUsage(StreamItem item, DwcaDataImportStateBase<DwcaDataImportConfiguratorBase> state, |
178 | 171 |
TaxonBase<?> taxonBase, String id, List<MappedCdmBase<? extends CdmBase>> resultList) { |
179 | 172 |
|
... | ... | |
222 | 215 |
} |
223 | 216 |
} |
224 | 217 |
|
225 |
|
|
226 | 218 |
private Classification getClassification(StreamItem item, List<MappedCdmBase<? extends CdmBase>> resultList) { |
227 | 219 |
Set<Classification> resultSet = new HashSet<>(); |
228 | 220 |
// |
... | ... | |
260 | 252 |
return resultSet.iterator().next(); |
261 | 253 |
} |
262 | 254 |
|
263 |
|
|
264 | 255 |
private void handleAcceptedNameUsage(StreamItem item, DwcaDataImportStateBase<DwcaDataImportConfiguratorBase> state, TaxonBase<?> taxonBase, String id) { |
265 | 256 |
if (acceptedNameUsageExists(item)){ |
266 | 257 |
String accId = item.get(TermUri.DWC_ACCEPTED_NAME_USAGE_ID); |
... | ... | |
270 | 261 |
} |
271 | 262 |
} |
272 | 263 |
|
273 |
|
|
274 |
/** |
|
275 |
* @param item |
|
276 |
* @param state |
|
277 |
* @param taxonBase |
|
278 |
* @param id |
|
279 |
* @param accId |
|
280 |
* @param taxStatus |
|
281 |
*/ |
|
282 | 264 |
private void handleAcceptedNameUsageParam(StreamItem item, |
283 | 265 |
DwcaDataImportStateBase<DwcaDataImportConfiguratorBase> state, TaxonBase<?> taxonBase, String id, String accId) { |
284 | 266 |
if (id.equals(accId)){ |
... | ... | |
313 | 295 |
} |
314 | 296 |
} |
315 | 297 |
|
316 |
|
|
317 |
/** |
|
318 |
* @param item |
|
319 |
* @return |
|
320 |
*/ |
|
321 | 298 |
private boolean acceptedNameUsageExists(StreamItem item) { |
322 | 299 |
return exists(TermUri.DWC_ACCEPTED_NAME_USAGE_ID, item) || exists(TermUri.DWC_ACCEPTED_NAME_USAGE, item); |
323 | 300 |
} |
324 | 301 |
|
325 |
|
|
326 |
|
|
327 | 302 |
//**************************** PARTITIONABLE ************************************************ |
328 | 303 |
|
329 | 304 |
@Override |
... | ... | |
381 | 356 |
|
382 | 357 |
@Override |
383 | 358 |
public Set<String> requiredSourceNamespaces() { |
384 |
Set<String> result = new HashSet<String>();
|
|
359 |
Set<String> result = new HashSet<>(); |
|
385 | 360 |
|
386 | 361 |
result.add(TermUri.DWC_TAXON.toString()); |
387 | 362 |
|
... | ... | |
400 | 375 |
return result; |
401 | 376 |
} |
402 | 377 |
|
403 |
|
|
404 | 378 |
//************************************* TO STRING ******************************************** |
405 | 379 |
|
406 | 380 |
@Override |
407 | 381 |
public String toString(){ |
408 | 382 |
return this.getClass().getName(); |
409 | 383 |
} |
410 |
|
|
411 |
|
|
412 |
|
|
413 | 384 |
} |
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/dwca/in/GbifDescriptionCsv2CdmConverter.java | ||
---|---|---|
37 | 37 |
/** |
38 | 38 |
* @author a.mueller |
39 | 39 |
* @since 22.11.2011 |
40 |
* |
|
41 | 40 |
*/ |
42 | 41 |
public class GbifDescriptionCsv2CdmConverter extends PartitionableConverterBase<DwcaDataImportConfiguratorBase, DwcaDataImportStateBase<DwcaDataImportConfiguratorBase>> |
43 | 42 |
implements IPartitionableConverter<StreamItem, IReader<CdmBase>, String>{ |
... | ... | |
47 | 46 |
|
48 | 47 |
private static final String CORE_ID = "coreId"; |
49 | 48 |
|
50 |
/** |
|
51 |
* @param state |
|
52 |
*/ |
|
53 | 49 |
public GbifDescriptionCsv2CdmConverter(DwcaDataImportStateBase state) { |
54 | 50 |
super(state); |
55 | 51 |
} |
... | ... | |
115 | 111 |
return new ListReader<>(resultList); |
116 | 112 |
} |
117 | 113 |
|
118 |
|
|
119 | 114 |
/** |
120 | 115 |
* Determines the feature by the dc:type attribute. Tries to reuse existing |
121 | 116 |
* features. |
117 |
* |
|
122 | 118 |
* @param item |
123 | 119 |
* @param resultList |
124 | 120 |
* @return |
... | ... | |
155 | 151 |
fireWarningEvent(message, item, 8); |
156 | 152 |
return null; |
157 | 153 |
} |
158 |
|
|
159 | 154 |
} |
160 | 155 |
|
161 | 156 |
@Override |
... | ... | |
164 | 159 |
return id; |
165 | 160 |
} |
166 | 161 |
|
167 |
|
|
168 | 162 |
//********************** PARTITIONABLE **************************************/ |
169 | 163 |
|
170 | 164 |
@Override |
... | ... | |
178 | 172 |
} |
179 | 173 |
} |
180 | 174 |
|
181 |
|
|
182 | 175 |
@Override |
183 | 176 |
public Set<String> requiredSourceNamespaces() { |
184 |
Set<String> result = new HashSet<String>();
|
|
177 |
Set<String> result = new HashSet<>(); |
|
185 | 178 |
result.add(TermUri.DWC_TAXON.toString()); |
186 | 179 |
result.add(TermUri.DC_LANGUAGE.toString()); |
187 | 180 |
return result; |
... | ... | |
193 | 186 |
public String toString(){ |
194 | 187 |
return this.getClass().getName(); |
195 | 188 |
} |
196 |
|
|
197 |
|
|
198 | 189 |
} |
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/dwca/in/GbifReferenceCsv2CdmConverter.java | ||
---|---|---|
49 | 49 |
/** |
50 | 50 |
* @author a.mueller |
51 | 51 |
* @since 22.11.2011 |
52 |
* |
|
53 | 52 |
*/ |
54 | 53 |
public class GbifReferenceCsv2CdmConverter extends PartitionableConverterBase<DwcaDataImportConfiguratorBase, DwcaDataImportStateBase<DwcaDataImportConfiguratorBase>> |
55 | 54 |
implements IPartitionableConverter<StreamItem, IReader<CdmBase>, String>{ |
... | ... | |
58 | 57 |
|
59 | 58 |
private static final String CORE_ID = "coreId"; |
60 | 59 |
|
61 |
/** |
|
62 |
* @param state |
|
63 |
*/ |
|
64 | 60 |
public GbifReferenceCsv2CdmConverter(DwcaDataImportStateBase state) { |
65 | 61 |
super(state); |
66 | 62 |
} |
... | ... | |
112 | 108 |
//type |
113 | 109 |
handleType(reference, strType, taxon, resultList, item); |
114 | 110 |
|
115 |
|
|
116 | 111 |
return new ListReader<>(resultList); |
117 | 112 |
} |
118 | 113 |
|
119 |
|
|
120 | 114 |
private void handleType(Reference reference, String strType, TaxonBase<?> taxon, |
121 | 115 |
List<MappedCdmBase<? extends CdmBase>> resultList, StreamItem item) { |
122 | 116 |
// TODO handleType not yet implemented |
... | ... | |
166 | 160 |
//TODO not yet handled by CDM |
167 | 161 |
} |
168 | 162 |
} |
169 |
|
|
170 | 163 |
} |
171 | 164 |
} |
172 | 165 |
if (config.isHandleAllRefsAsCitation()){ |
... | ... | |
183 | 176 |
resultList.add(new MappedCdmBase<CdmBase>(desc)); |
184 | 177 |
} |
185 | 178 |
} |
186 |
|
|
187 | 179 |
} |
188 |
|
|
189 | 180 |
} |
190 |
|
|
191 |
|
|
192 | 181 |
} |
193 | 182 |
|
194 | 183 |
private void createCitation(TaxonDescription desc, Reference ref, TaxonName nameUsedInSource) { |
... | ... | |
219 | 208 |
logger.debug("Reference is not an URI"); |
220 | 209 |
} |
221 | 210 |
//TODO further identifier types |
222 |
|
|
223 | 211 |
} |
224 | 212 |
|
225 | 213 |
private Reference handleInRef(String strSource) { |
... | ... | |
231 | 219 |
} |
232 | 220 |
} |
233 | 221 |
|
234 |
|
|
235 | 222 |
private VerbatimTimePeriod handleDate(String strDate) { |
236 | 223 |
VerbatimTimePeriod tp = TimePeriodParser.parseStringVerbatim(strDate); |
237 | 224 |
return tp; |
... | ... | |
248 | 235 |
return id; |
249 | 236 |
} |
250 | 237 |
|
251 |
|
|
252 | 238 |
//********************** PARTITIONABLE **************************************/ |
253 | 239 |
|
254 | 240 |
@Override |
... | ... | |
262 | 248 |
} |
263 | 249 |
} |
264 | 250 |
|
265 |
|
|
266 | 251 |
@Override |
267 | 252 |
public Set<String> requiredSourceNamespaces() { |
268 |
Set<String> result = new HashSet<String>();
|
|
253 |
Set<String> result = new HashSet<>(); |
|
269 | 254 |
result.add(TermUri.DWC_TAXON.toString()); |
270 | 255 |
return result; |
271 | 256 |
} |
... | ... | |
276 | 261 |
public String toString(){ |
277 | 262 |
return this.getClass().getName(); |
278 | 263 |
} |
279 |
|
|
280 |
|
|
281 | 264 |
} |
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/excel/taxa/TaxonExcelImportState.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.excel.taxa; |
11 | 10 |
|
12 | 11 |
import java.util.HashMap; |
... | ... | |
37 | 36 |
private static final Logger logger = Logger.getLogger(TaxonExcelImportState.class); |
38 | 37 |
|
39 | 38 |
/** Already processed authors */ |
40 |
private Set<String> authors = new HashSet<String>();
|
|
39 |
private Set<String> authors = new HashSet<>(); |
|
41 | 40 |
|
42 | 41 |
private Map<String, TaxonBase> taxonMap= new HashMap<String, TaxonBase>(); |
43 | 42 |
/** |
... | ... | |
60 | 59 |
private Taxon parent; |
61 | 60 |
private Classification classification; |
62 | 61 |
|
63 |
|
|
64 |
|
|
65 | 62 |
public TaxonExcelImportState(ExcelImportConfiguratorBase config) { |
66 | 63 |
super(config); |
67 | 64 |
} |
68 | 65 |
|
69 |
/** |
|
70 |
* @return the author |
|
71 |
*/ |
|
72 | 66 |
public Set<String> getAuthors() { |
73 | 67 |
return authors; |
74 | 68 |
} |
75 |
|
|
76 |
/** |
|
77 |
* @param author the author to set |
|
78 |
*/ |
|
79 | 69 |
public void setAuthors(Set<String> authors) { |
80 | 70 |
this.authors = authors; |
81 | 71 |
} |
... | ... | |
83 | 73 |
public Taxon getParent(){ |
84 | 74 |
return parent; |
85 | 75 |
} |
86 |
|
|
87 | 76 |
public void setParent(Taxon parent){ |
88 | 77 |
this.parent = parent; |
89 | 78 |
} |
90 | 79 |
|
91 |
/** |
|
92 |
* @param parentId |
|
93 |
* @return |
|
94 |
*/ |
|
95 | 80 |
public TaxonBase getTaxonBase(String taxonId) { |
96 | 81 |
return taxonMap.get(taxonId); |
97 | 82 |
} |
98 | 83 |
|
99 |
|
|
100 |
/** |
|
101 |
* @param parentId |
|
102 |
* @param taxon |
|
103 |
*/ |
|
104 | 84 |
public void putTaxon(String taxonId, TaxonBase taxonBase) { |
105 |
|
|
106 |
|
|
107 | 85 |
taxonMap.put(taxonId, taxonBase); |
108 | 86 |
} |
109 | 87 |
|
110 |
/** |
|
111 |
* @return the classification |
|
112 |
*/ |
|
113 | 88 |
public Classification getClassification() { |
114 | 89 |
return classification; |
115 | 90 |
} |
116 |
|
|
117 |
/** |
|
118 |
* @param classification the classification to set |
|
119 |
*/ |
|
120 | 91 |
public void setClassification(Classification classification) { |
121 | 92 |
this.classification = classification; |
122 | 93 |
} |
... | ... | |
137 | 108 |
this.nameMap = nameMap; |
138 | 109 |
} |
139 | 110 |
|
140 |
/** |
|
141 |
* @param name |
|
142 |
* @param name2 |
|
143 |
*/ |
|
144 | 111 |
public void putName(String titleCache, TaxonName name) { |
145 | 112 |
if (nameMap == null){ |
146 |
nameMap = new HashMap<String, TaxonName>();
|
|
113 |
nameMap = new HashMap<>(); |
|
147 | 114 |
} |
148 |
|
|
149 | 115 |
nameMap.put(titleCache, name); |
150 | 116 |
} |
151 |
|
|
152 |
|
|
153 |
|
|
154 | 117 |
} |
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/markup/FeatureSorter.java | ||
---|---|---|
1 | 1 |
/** |
2 |
*
|
|
2 |
* |
|
3 | 3 |
*/ |
4 | 4 |
package eu.etaxonomy.cdm.io.markup; |
5 | 5 |
|
... | ... | |
16 | 16 |
/** |
17 | 17 |
* This class is supposed to find the best sorting order for features (descriptive and other). |
18 | 18 |
* Currently it is not yet very sophisticated. |
19 |
* |
|
20 |
* @author a.mueller |
|
21 | 19 |
* |
20 |
* @author a.mueller |
|
22 | 21 |
*/ |
23 | 22 |
public class FeatureSorter { |
24 | 23 |
|
25 |
|
|
26 | 24 |
class FeatureStatistic{ |
27 | 25 |
|
28 | 26 |
private UUID uuid; |
... | ... | |
30 | 28 |
private int before = 0; //number of features before this feature |
31 | 29 |
private int after = 0; //number of features after this feature |
32 | 30 |
private int n = 0; //number of occurrences of this feature |
33 |
|
|
31 |
|
|
34 | 32 |
public FeatureStatistic(UUID uuid) { |
35 | 33 |
this.uuid = uuid; |
36 | 34 |
} |
... | ... | |
46 | 44 |
public String toString(){ |
47 | 45 |
return uuid != null? uuid.toString(): super.toString(); |
48 | 46 |
} |
49 |
|
|
50 | 47 |
} |
51 |
|
|
52 |
|
|
48 |
|
|
53 | 49 |
/** |
54 | 50 |
* Compute the order of features. |
55 | 51 |
* @param orderLists |
... | ... | |
72 | 68 |
|
73 | 69 |
|
74 | 70 |
private void removeEmptyLists(Map<String, List<FeatureSorterInfo>> listMap) { |
75 |
Set<String> keysToRemove = new HashSet<String>();
|
|
71 |
Set<String> keysToRemove = new HashSet<>(); |
|
76 | 72 |
for(String key : listMap.keySet()){ |
77 | 73 |
List<FeatureSorterInfo> list = listMap.get(key); |
78 | 74 |
if (list.isEmpty()){ |
... | ... | |
82 | 78 |
for (String key : keysToRemove){ |
83 | 79 |
listMap.remove(key); |
84 | 80 |
} |
85 |
|
|
81 |
|
|
86 | 82 |
} |
87 | 83 |
|
88 | 84 |
|
... | ... | |
92 | 88 |
* @param uuid |
93 | 89 |
*/ |
94 | 90 |
private Map<String, List<FeatureSorterInfo>> removeFromLists(Map<String, List<FeatureSorterInfo>> orderListsMap, UUID uuid) { |
95 |
Map<String, List<FeatureSorterInfo>> childLists = new HashMap<String, List<FeatureSorterInfo>>();
|
|
96 |
|
|
91 |
Map<String, List<FeatureSorterInfo>> childLists = new HashMap<>(); |
|
92 |
|
|
97 | 93 |
Set<String> keySet = orderListsMap.keySet(); |
98 | 94 |
Iterator<String> keySetIterator = keySet.iterator(); |
99 | 95 |
while (keySetIterator.hasNext()){ |
100 | 96 |
String key = keySetIterator.next(); |
101 |
List<FeatureSorterInfo> list = orderListsMap.get(key);
|
|
97 |
List<FeatureSorterInfo> list = orderListsMap.get(key); |
|
102 | 98 |
Iterator<FeatureSorterInfo> it = list.listIterator(); |
103 | 99 |
while (it.hasNext()){ |
104 | 100 |
FeatureSorterInfo info = it.next(); |
... | ... | |
116 | 112 |
return childLists; |
117 | 113 |
} |
118 | 114 |
|
119 |
|
|
120 | 115 |
private FeatureStatistic findBest(Map<UUID, FeatureStatistic> statisticMap) { |
121 | 116 |
FeatureStatistic result; |
122 | 117 |
Set<FeatureStatistic> highest = getOnlyHighestFeatures(statisticMap); |
... | ... | |
150 | 145 |
return result; |
151 | 146 |
} |
152 | 147 |
|
153 |
|
|
154 | 148 |
/** |
155 | 149 |
* If no feature is always highest this method can be called to use an alternative criteria |
156 |
* to find the "highest" feature.
|
|
157 |
*
|
|
150 |
* to find the "highest" feature. |
|
151 |
* |
|
158 | 152 |
* @param statisticMap |
159 | 153 |
* @return |
160 | 154 |
*/ |
... | ... | |
173 | 167 |
return result; |
174 | 168 |
} |
175 | 169 |
|
176 |
|
|
177 | 170 |
private Set<FeatureStatistic> getOnlyHighestFeatures(Map<UUID, FeatureStatistic> statisticMap) { |
178 |
Set<FeatureStatistic> result = new HashSet<FeatureStatistic>();
|
|
171 |
Set<FeatureStatistic> result = new HashSet<>(); |
|
179 | 172 |
for (FeatureStatistic statistic : statisticMap.values()){ |
180 | 173 |
if (statistic.isAlwaysHighest){ |
181 | 174 |
result.add(statistic); |
... | ... | |
186 | 179 |
|
187 | 180 |
|
188 | 181 |
private Map<UUID, FeatureStatistic> computeStatistic(Map<String,List<FeatureSorterInfo>> orderLists) { |
189 |
Map<UUID, FeatureStatistic> result = new HashMap<UUID, FeatureStatistic>();
|
|
182 |
Map<UUID, FeatureStatistic> result = new HashMap<>(); |
|
190 | 183 |
for (String key : orderLists.keySet()){ |
191 | 184 |
List<FeatureSorterInfo> list = orderLists.get(key); |
192 | 185 |
int n = list.size(); |
... | ... | |
199 | 192 |
return result; |
200 | 193 |
} |
201 | 194 |
|
202 |
|
|
203 | 195 |
private FeatureStatistic getFeatureStatistic(FeatureSorterInfo info, Map<UUID, FeatureStatistic> statisticMap) { |
204 | 196 |
UUID uuid = info.getUuid(); |
205 | 197 |
FeatureStatistic result = statisticMap.get(uuid); |
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/specimen/SpecimenUserInteraction.java | ||
---|---|---|
50 | 50 |
/** |
51 | 51 |
* @author pkelbert |
52 | 52 |
* @since 21 juin 2013 |
53 |
* |
|
54 | 53 |
*/ |
55 | 54 |
public class SpecimenUserInteraction implements ItemListener, Serializable { |
56 | 55 |
|
56 |
private static final long serialVersionUID = 6384263183459028523L; |
|
57 |
@SuppressWarnings("unused") |
|
57 | 58 |
private static Logger log = Logger.getLogger(SpecimenUserInteraction.class); |
58 | 59 |
|
59 | 60 |
public Classification askForClassification(Map<String, Classification> classMap){ |
... | ... | |
87 | 88 |
return classMap.get(s); |
88 | 89 |
} |
89 | 90 |
|
90 |
|
|
91 |
|
|
92 | 91 |
/** |
93 | 92 |
* @return the name for the new Classification |
94 | 93 |
*/ |
... | ... | |
113 | 112 |
return s; |
114 | 113 |
} |
115 | 114 |
|
116 |
|
|
117 | 115 |
/** |
118 | 116 |
* @param refMap |
119 | 117 |
* @return |
120 | 118 |
*/ |
121 |
@SuppressWarnings("rawtypes") |
|
122 | 119 |
public Reference askForReference(Map<String, Reference> refMap) { |
123 |
List<String> possibilities = new ArrayList<String> (refMap.keySet());
|
|
120 |
List<String> possibilities = new ArrayList<>(refMap.keySet());
|
|
124 | 121 |
Collections.sort(possibilities); |
125 | 122 |
if (refMap.keySet().size()>0) { |
126 | 123 |
refMap.put("Nothing matches, create a new reference",null); |
... | ... | |
149 | 146 |
return refMap.get(s); |
150 | 147 |
} |
151 | 148 |
|
152 |
|
|
153 |
|
|
154 |
|
|
155 |
|
|
156 | 149 |
/** |
157 | 150 |
* @param refMap |
158 | 151 |
* @param iReferenceService |
159 | 152 |
* @param docSources |
160 | 153 |
* @return |
161 | 154 |
*/ |
162 |
@SuppressWarnings("rawtypes") |
|
163 | 155 |
public List<OriginalSourceBase<?>> askForSource(Map<String, OriginalSourceBase<?>> refMap, String currentElement, String blabla, |
164 | 156 |
IReferenceService iReferenceService, List<String> docSources) { |
165 | 157 |
|
166 | 158 |
// System.out.println(refMap); |
167 |
List<String> possibilities = new ArrayList<String> (refMap.keySet());
|
|
159 |
List<String> possibilities = new ArrayList<> (refMap.keySet()); |
|
168 | 160 |
|
169 |
Set<String> all = new HashSet<String>();
|
|
161 |
Set<String> all = new HashSet<>(); |
|
170 | 162 |
all.addAll(possibilities); |
171 | 163 |
|
172 | 164 |
List<String> allList = new ArrayList<String>(); |
... | ... | |
233 | 225 |
sources.add(a); |
234 | 226 |
} |
235 | 227 |
} |
236 |
|
|
237 | 228 |
} |
238 | 229 |
|
239 |
|
|
240 |
|
|
241 |
List<OriginalSourceBase<?>> dess = new ArrayList<OriginalSourceBase<?>>(); |
|
230 |
List<OriginalSourceBase<?>> dess = new ArrayList<>(); |
|
242 | 231 |
for (String src:sources){ |
243 | 232 |
if (refMap.get(src) !=null) { |
244 | 233 |
dess.add(refMap.get(src)); |
... | ... | |
273 | 262 |
return dess; |
274 | 263 |
} |
275 | 264 |
|
276 |
|
|
277 |
/** |
|
278 |
* @return |
|
279 |
*/ |
|
280 | 265 |
public String createNewReference() { |
281 | 266 |
JTextArea textArea = new JTextArea("How should the reference be named ?"); |
282 | 267 |
JScrollPane scrollPane = new JScrollPane(textArea); |
... | ... | |
298 | 283 |
return s; |
299 | 284 |
} |
300 | 285 |
|
301 |
/** |
|
302 |
* @return |
|
303 |
*/ |
|
304 | 286 |
public String createNewSource() { |
305 | 287 |
JTextArea textArea = new JTextArea("How should the source be named? If there is a citation detail, prefix it with 3 minus signs ('---')."); |
306 | 288 |
JScrollPane scrollPane = new JScrollPane(textArea); |
... | ... | |
322 | 304 |
return s; |
323 | 305 |
} |
324 | 306 |
|
325 |
|
|
326 |
/** |
|
327 |
* @param descriptions |
|
328 |
*/ |
|
329 | 307 |
public TaxonDescription askForDescriptionGroup(Set<TaxonDescription> descriptions) { |
330 | 308 |
JTextArea textArea = new JTextArea("One or several description group(s) does already exist for this taxon."); |
331 | 309 |
JScrollPane scrollPane = new JScrollPane(textArea); |
... | ... | |
344 | 322 |
for (IdentifiableSource s:sources) { |
345 | 323 |
src.add(s.getCitation().getTitleCache()); |
346 | 324 |
} |
347 |
List<String> srcb = new ArrayList<String>(new HashSet<String>(src));
|
|
325 |
List<String> srcb = new ArrayList<String>(new HashSet<>(src)); |
|
348 | 326 |
if (srcb.size()>0) { |
349 | 327 |
if(descrMap.containsKey(descCnt+": "+description.getTitleCache()+"("+StringUtils.join(srcb,";")+")")) { |
350 | 328 |
descCnt+=1; |
... | ... | |
363 | 341 |
// } |
364 | 342 |
} |
365 | 343 |
} |
366 |
List<String> possibilities = new ArrayList<String> (descrMap.keySet());
|
|
344 |
List<String> possibilities = new ArrayList<>(descrMap.keySet());
|
|
367 | 345 |
if (possibilities.size()==0) { |
368 | 346 |
return null; |
369 | 347 |
} |
... | ... | |
389 | 367 |
} else { |
390 | 368 |
return null; |
391 | 369 |
} |
392 |
|
|
393 | 370 |
} |
394 | 371 |
|
395 |
|
|
396 | 372 |
/** |
397 | 373 |
* Look if the same name already exists in the ALL classifications and ask the user to select one or none. |
398 | 374 |
* @param scientificName |
... | ... | |
401 | 377 |
*/ |
402 | 378 |
@SuppressWarnings("rawtypes") |
403 | 379 |
public Taxon askWhereToFixData(String scientificName, List<TaxonBase> taxonList, Classification classification) { |
404 |
Map<String,TaxonNode> classMap = new HashMap<String, TaxonNode>();
|
|
380 |
Map<String,TaxonNode> classMap = new HashMap<>(); |
|
405 | 381 |
boolean sameClassification=false; |
406 | 382 |
Taxon n = null; |
407 | 383 |
for (TaxonBase taxonBase: taxonList){ |
... | ... | |
476 | 452 |
return taxonFound; |
477 | 453 |
} |
478 | 454 |
|
479 |
|
|
480 |
List<String> sources = new ArrayList<String>(); |
|
455 |
List<String> sources = new ArrayList<>(); |
|
481 | 456 |
String currentSource = ""; |
482 |
/* (non-Javadoc) |
|
483 |
* @see java.awt.event.ItemListener#itemStateChanged(java.awt.event.ItemEvent) |
|
484 |
*/ |
|
457 |
|
|
485 | 458 |
@Override |
486 | 459 |
public void itemStateChanged(ItemEvent e) { |
487 | 460 |
JRadioButton cb = (JRadioButton) e.getItem(); |
... | ... | |
493 | 466 |
currentSource=""; |
494 | 467 |
} |
495 | 468 |
} |
496 |
|
|
497 |
|
|
498 |
|
|
499 | 469 |
} |
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/specimen/excel/in/SpecimenSythesysExcelImport.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.specimen.excel.in; |
11 | 10 |
|
12 | 11 |
import java.io.FileNotFoundException; |
... | ... | |
71 | 70 |
* @author p.kelbert |
72 | 71 |
* @since 29.10.2008 |
73 | 72 |
* @since 13 mars 2013 |
74 |
* |
|
75 | 73 |
*/ |
76 | 74 |
@Component |
77 | 75 |
public class SpecimenSythesysExcelImport extends CdmImportBase<SpecimenSynthesysExcelImportConfigurator, SpecimenSynthesysExcelImportState> |
78 | 76 |
implements ICdmIO<SpecimenSynthesysExcelImportState> { |
79 | 77 |
|
78 |
private static final long serialVersionUID = -1145031415387024364L; |
|
79 |
|
|
80 | 80 |
private static final Logger logger = Logger.getLogger(SpecimenSythesysExcelImport.class); |
81 | 81 |
|
82 | 82 |
protected String fullScientificNameString; |
... | ... | |
126 | 126 |
* return empty string instead of null |
127 | 127 |
* */ |
128 | 128 |
public class MyHashMap<K,V> extends HashMap<K,V> { |
129 |
/** |
|
130 |
* |
|
131 |
*/ |
|
129 |
|
|
132 | 130 |
private static final long serialVersionUID = -6230407405666753405L; |
133 | 131 |
|
134 | 132 |
@SuppressWarnings("unchecked") |
... | ... | |
212 | 210 |
} |
213 | 211 |
getClassificationService().saveOrUpdate(classification); |
214 | 212 |
} |
215 |
|
|
216 | 213 |
} |
217 | 214 |
} |
218 | 215 |
|
... | ... | |
317 | 314 |
identifier = unit.get("identifier"); |
318 | 315 |
} |
319 | 316 |
|
320 |
|
|
321 | 317 |
private Institution getInstitution(SpecimenSynthesysExcelImportConfigurator config){ |
322 | 318 |
Institution institution; |
323 | 319 |
List<Institution> institutions; |
... | ... | |
385 | 381 |
return collection; |
386 | 382 |
} |
387 | 383 |
|
388 |
/* |
|
389 |
* |
|
390 |
* @param app |
|
391 |
* @param derivedThing |
|
392 |
* @param sec |
|
393 |
*/ |
|
394 | 384 |
private void setTaxonName(SpecimenSynthesysExcelImportConfigurator config){ |
395 | 385 |
TaxonName taxonName = null; |
396 | 386 |
Taxon taxon = null; |
... | ... | |
462 | 452 |
taxon = addTaxonNode(taxon, config); |
463 | 453 |
} |
464 | 454 |
|
465 |
|
|
466 |
|
|
467 | 455 |
DeterminationEvent determinationEvent = DeterminationEvent.NewInstance(); |
468 | 456 |
determinationEvent.setTaxon(getTaxonService().find(taxon.getUuid())); |
469 | 457 |
determinationEvent.setPreferredFlag(preferredFlag); |
... | ... | |
480 | 468 |
|
481 | 469 |
getOccurrenceService().saveOrUpdate(derivedUnitBase); |
482 | 470 |
} |
483 |
|
|
484 | 471 |
} |
485 | 472 |
|
486 |
/** |
|
487 |
* @param taxon |
|
488 |
* @param taxonName |
|
489 |
* @param config |
|
490 |
* @return |
|
491 |
*/ |
|
492 | 473 |
private Taxon addTaxonNode(Taxon taxon, SpecimenSynthesysExcelImportConfigurator config) { |
493 | 474 |
if (DEBUG) { |
494 | 475 |
logger.info("link taxon to a taxonNode"); |
... | ... | |
969 | 950 |
} |
970 | 951 |
} |
971 | 952 |
if (collteam.size()>0) { |
972 |
collectorinteams.add(new ArrayList<String>(new HashSet<String>(collteam)));
|
|
953 |
collectorinteams.add(new ArrayList<String>(new HashSet<>(collteam))); |
|
973 | 954 |
} |
974 | 955 |
} |
975 | 956 |
else |
... | ... | |
980 | 961 |
} |
981 | 962 |
} |
982 | 963 |
|
983 |
List<String> collectorsU = new ArrayList<String>(new HashSet<String>(collectors));
|
|
984 |
List<String> teamsU = new ArrayList<String>(new HashSet<String>(teams));
|
|
964 |
List<String> collectorsU = new ArrayList<String>(new HashSet<>(collectors)); |
|
965 |
List<String> teamsU = new ArrayList<String>(new HashSet<>(teams)); |
|
985 | 966 |
|
986 | 967 |
|
987 | 968 |
//existing teams in DB |
988 | 969 |
Map<String,Team> titleCacheTeam = new HashMap<String, Team>(); |
989 | 970 |
List<UuidAndTitleCache<Team>> hiberTeam = getAgentService().getTeamUuidAndTitleCache(); |
990 | 971 |
|
991 |
Set<UUID> uuids = new HashSet<UUID>();
|
|
972 |
Set<UUID> uuids = new HashSet<>(); |
|
992 | 973 |
for (UuidAndTitleCache<Team> hibernateT:hiberTeam){ |
993 | 974 |
uuids.add(hibernateT.getUuid()); |
994 | 975 |
} |
... | ... | |
1000 | 981 |
} |
1001 | 982 |
|
1002 | 983 |
|
1003 |
Map<String,UUID> teamMap = new HashMap<String, UUID>();
|
|
984 |
Map<String,UUID> teamMap = new HashMap<>(); |
|
1004 | 985 |
for (UuidAndTitleCache<Team> uuidt:hiberTeam){ |
1005 | 986 |
teamMap.put(uuidt.getTitleCache(), uuidt.getUuid()); |
1006 | 987 |
} |
1007 | 988 |
|
1008 | 989 |
//existing persons in DB |
1009 | 990 |
List<UuidAndTitleCache<Person>> hiberPersons = getAgentService().getPersonUuidAndTitleCache(); |
1010 |
Map<String,Person> titleCachePerson = new HashMap<String, Person>();
|
|
991 |
Map<String,Person> titleCachePerson = new HashMap<>(); |
|
1011 | 992 |
uuids = new HashSet<UUID>(); |
1012 | 993 |
for (UuidAndTitleCache<Person> hibernateP:hiberPersons){ |
1013 | 994 |
uuids.add(hibernateP.getUuid()); |
... | ... | |
1025 | 1006 |
personMap.put(person.getTitleCache(), person.getUuid()); |
1026 | 1007 |
} |
1027 | 1008 |
|
1028 |
java.util.Collection<AgentBase> personsToAdd = new ArrayList<AgentBase>();
|
|
1029 |
java.util.Collection<AgentBase> teamsToAdd = new ArrayList<AgentBase>();
|
|
1009 |
java.util.Collection<AgentBase> personsToAdd = new ArrayList<>(); |
|
1010 |
java.util.Collection<AgentBase> teamsToAdd = new ArrayList<>(); |
|
1030 | 1011 |
|
1031 | 1012 |
for (String collector:collectorsU){ |
1032 | 1013 |
Person p = Person.NewInstance(); |
... | ... | |
1047 | 1028 |
titleCachePerson.put(uuuidPerson.get(u).getTitleCache(),CdmBase.deproxy(uuuidPerson.get(u), Person.class) ); |
1048 | 1029 |
} |
1049 | 1030 |
|
1050 |
|
|
1051 | 1031 |
Person ptmp ; |
1052 | 1032 |
Map <String,Integer>teamdone = new HashMap<String, Integer>(); |
1053 | 1033 |
for (List<String> collteam: collectorinteams){ |
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/stream/PartitionableConverterBase.java | ||
---|---|---|
161 | 161 |
protected Set<String> getKeySet(String key, Map<String, Set<String>> fkMap) { |
162 | 162 |
Set<String> keySet = fkMap.get(key); |
163 | 163 |
if (keySet == null){ |
164 |
keySet = new HashSet<String>();
|
|
164 |
keySet = new HashSet<>(); |
|
165 | 165 |
fkMap.put(key, keySet); |
166 | 166 |
} |
167 | 167 |
return keySet; |
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/taxonx2013/TaxonXExtractor.java | ||
---|---|---|
75 | 75 |
import eu.etaxonomy.cdm.strategy.exceptions.UnknownCdmTypeException; |
76 | 76 |
import eu.etaxonomy.cdm.strategy.parser.ParserProblem; |
77 | 77 |
|
78 |
|
|
79 | 78 |
/** |
80 | 79 |
* @author pkelbert |
81 | 80 |
* @since 2 avr. 2013 |
82 |
* |
|
83 | 81 |
*/ |
84 | 82 |
public class TaxonXExtractor { |
85 | 83 |
|
86 | 84 |
protected TaxonXImport importer; |
87 | 85 |
protected TaxonXImportState state2; |
88 |
private final Map<String,String> namesAsked = new HashMap<String, String>();
|
|
89 |
private final Map<String,Rank>ranksAsked = new HashMap<String, Rank>();
|
|
86 |
private final Map<String,String> namesAsked = new HashMap<>(); |
|
87 |
private final Map<String,Rank>ranksAsked = new HashMap<>(); |
|
90 | 88 |
|
91 | 89 |
Logger logger = Logger.getLogger(TaxonXExtractor.class); |
92 | 90 |
|
... | ... | |
95 | 93 |
private boolean foundBibref=false; |
96 | 94 |
private final TaxonXAddSources sourceHandler; |
97 | 95 |
|
98 |
/** |
|
99 |
* @param sourceHandler |
|
100 |
*/ |
|
96 |
|
|
101 | 97 |
public ReferenceBuilder(TaxonXAddSources sourceHandler) { |
102 | 98 |
this.sourceHandler=sourceHandler; |
103 | 99 |
} |
104 | 100 |
|
105 |
/** |
|
106 |
* @return the foundBibref |
|
107 |
*/ |
|
108 | 101 |
public boolean isFoundBibref() { |
109 | 102 |
return foundBibref; |
110 | 103 |
} |
111 |
|
|
112 |
/** |
|
113 |
* @param foundBibref the foundBibref to set |
|
114 |
*/ |
|
115 | 104 |
public void setFoundBibref(boolean foundBibref) { |
116 | 105 |
this.foundBibref = foundBibref; |
117 | 106 |
} |
118 | 107 |
|
119 |
|
|
120 |
/** |
|
121 |
* @param ref |
|
122 |
* @param refMods |
|
123 |
*/ |
|
124 | 108 |
public void builReference(String mref, String treatmentMainName, NomenclaturalCode nomenclaturalCode, |
125 | 109 |
Taxon acceptedTaxon, Reference refMods) { |
126 | 110 |
// System.out.println("builReference "+mref); |
... | ... | |
167 | 151 |
nbRef++; |
168 | 152 |
|
169 | 153 |
} |
170 |
|
|
171 | 154 |
} |
172 | 155 |
|
173 | 156 |
public class MySpecimenOrObservation{ |
... | ... | |
186 | 169 |
public void setDerivedUnitBase(DerivedUnit derivedUnitBase) { |
187 | 170 |
this.derivedUnitBase = derivedUnitBase; |
188 | 171 |
} |
189 |
|
|
190 |
|
|
191 |
|
|
192 |
|
|
193 | 172 |
} |
194 | 173 |
|
195 |
/** |
|
196 |
* @param item |
|
197 |
* @return |
|
198 |
*/ |
|
199 | 174 |
@SuppressWarnings({ "unused", "rawtypes" }) |
200 | 175 |
protected MySpecimenOrObservation extractSpecimenOrObservation(Node specimenObservationNode, DerivedUnit derivedUnitBase, |
201 | 176 |
SpecimenOrObservationType defaultAssociation, TaxonName typifiableName) { |
... | ... | |
356 | 331 |
unitsGatheringArea.setParams(null, country, state2.getConfig(), importer.getTermService(), importer.getOccurrenceService(), importer.getVocabularyService()); |
357 | 332 |
//TODO other areas |
358 | 333 |
if (StringUtils.isNotBlank(stateprov)){ |
359 |
Map<String, String> namedAreas = new HashMap<String, String>();
|
|
334 |
Map<String, String> namedAreas = new HashMap<>(); |
|
360 | 335 |
namedAreas.put(stateprov, null); |
361 | 336 |
unitsGatheringArea.setAreaNames(namedAreas, state2.getConfig(), importer.getTermService(), importer.getVocabularyService()); |
362 | 337 |
} |
... | ... | |
392 | 367 |
return specimenOrObservation; |
393 | 368 |
} |
394 | 369 |
|
395 |
|
|
396 | 370 |
private SpecimenTypeDesignationStatus getSpecimenTypeDesignationStatusByKey( |
397 | 371 |
String key) { |
398 | 372 |
if (key == null) { |
... | ... | |
474 | 448 |
return derivedUnitFacade; |
475 | 449 |
} |
476 | 450 |
|
477 |
|
|
478 |
|
|
479 | 451 |
@SuppressWarnings("rawtypes") |
480 | 452 |
protected Feature makeFeature(SpecimenOrObservationBase unit) { |
481 | 453 |
if (unit == null){ |
... | ... | |
500 | 472 |
return null; |
501 | 473 |
} |
502 | 474 |
|
503 |
|
|
504 | 475 |
protected final static String SPLITTER = ","; |
505 | 476 |
|
506 |
|
|
507 | 477 |
protected int askQuestion(String question){ |
508 | 478 |
Scanner scan = new Scanner(System.in); |
509 | 479 |
logger.info(question); |
... | ... | |
511 | 481 |
return index; |
512 | 482 |
} |
513 | 483 |
|
514 |
|
|
515 |
/** |
|
516 |
* @param reftype |
|
517 |
* @return |
|
518 |
*/ |
|
519 | 484 |
protected Reference getReferenceWithType(int reftype) { |
520 | 485 |
Reference ref = null; |
521 | 486 |
switch (reftype) { |
... | ... | |
547 | 512 |
} |
548 | 513 |
return ref; |
549 | 514 |
} |
550 |
/** |
|
551 |
* @param unitsList |
|
552 |
* @param state |
|
553 |
*/ |
|
515 |
|
|
554 | 516 |
protected void prepareCollectors(TaxonXImportState state,IAgentService agentService) { |
555 | 517 |
// logger.info("PREPARE COLLECTORS"); |
556 |
List<String> collectors = new ArrayList<String>();
|
|
518 |
List<String> collectors = new ArrayList<>(); |
|
557 | 519 |
String tmp; |
558 |
List<String> collectorsU = new ArrayList<String>(new HashSet<String>(collectors));
|
|
520 |
List<String> collectorsU = new ArrayList<>(new HashSet<>(collectors));
|
|
559 | 521 |
Set<UUID> uuids = new HashSet<UUID>(); |
560 | 522 |
|
561 | 523 |
//existing persons in DB |
562 | 524 |
List<UuidAndTitleCache<Person>> hiberPersons = agentService.getPersonUuidAndTitleCache(); |
563 |
Map<String,Person> titleCachePerson = new HashMap<String, Person>();
|
|
525 |
Map<String,Person> titleCachePerson = new HashMap<>(); |
|
564 | 526 |
uuids = new HashSet<UUID>(); |
565 | 527 |
for (UuidAndTitleCache<Person> hibernateP:hiberPersons){ |
566 | 528 |
uuids.add(hibernateP.getUuid()); |
... | ... | |
1182 | 1144 |
} |
1183 | 1145 |
|
1184 | 1146 |
protected boolean containsDistinctLetters(String word){ |
1185 |
Set<Character> dl = new HashSet<Character>();
|
|
1147 |
Set<Character> dl = new HashSet<>(); |
|
1186 | 1148 |
for (char a: word.toCharArray()) { |
1187 | 1149 |
dl.add(a); |
1188 | 1150 |
} |
... | ... | |
1214 | 1176 |
} |
1215 | 1177 |
} |
1216 | 1178 |
|
1217 |
|
|
1218 | 1179 |
/** Creates an cdm-NomenclaturalCode by the tcs NomenclaturalCode |
1219 | 1180 |
*/ |
1220 | 1181 |
protected NomenclaturalStatusType nomStatusString2NomStatus (String nomStatus) throws UnknownCdmTypeException{ |
... | ... | |
1278 | 1239 |
} |
1279 | 1240 |
} |
1280 | 1241 |
|
1281 |
|
|
1282 | 1242 |
//TypeDesignation |
1283 | 1243 |
protected SpecimenTypeDesignationStatus typeStatusId2TypeStatus (int typeStatusId) throws UnknownCdmTypeException{ |
1284 | 1244 |
switch (typeStatusId){ |
... | ... | |
1302 | 1262 |
} |
1303 | 1263 |
} |
1304 | 1264 |
} |
1305 |
|
|
1306 |
|
|
1307 |
} |
|
1308 |
|
|
1309 |
|
|
1265 |
} |
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/tcsrdf/TcsRdfImportBase.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.tcsrdf; |
11 | 10 |
|
12 | 11 |
import static eu.etaxonomy.cdm.io.common.ImportHelper.OBLIGATORY; |
... | ... | |
48 | 47 |
protected static String nsTm = "http://rs.tdwg.org/ontology/voc/Team"; |
49 | 48 |
protected static String nsTpalm = "http://wp5.e-taxonomy.eu/import/palmae/common"; |
50 | 49 |
|
51 |
|
|
52 | 50 |
@Override |
53 | 51 |
protected abstract void doInvoke(TcsRdfImportState state); |
54 | 52 |
|
55 |
// /* (non-Javadoc) |
|
56 |
// * @see eu.etaxonomy.cdm.io.common.CdmIoBase#doInvoke(eu.etaxonomy.cdm.io.common.IImportConfigurator, eu.etaxonomy.cdm.api.application.CdmApplicationController, java.util.Map) |
|
57 |
// */ |
|
58 | 53 |
// @Override |
59 | 54 |
// protected boolean doInvoke(IImportConfigurator config, |
60 | 55 |
// Map<String, MapWrapper<? extends CdmBase>> stores){ |
... | ... | |
65 | 60 |
|
66 | 61 |
protected boolean makeStandardMapper(Statement resource, CdmBase ref, Set<String> omitAttributes, CdmSingleAttributeRDFMapperBase[] classMappers){ |
67 | 62 |
if (omitAttributes == null){ |
68 |
omitAttributes = new HashSet<String>();
|
|
63 |
omitAttributes = new HashSet<>(); |
|
69 | 64 |
} |
70 | 65 |
boolean result = true; |
71 | 66 |
for (CdmSingleAttributeRDFMapperBase mapper : classMappers){ |
... | ... | |
108 | 103 |
break; |
109 | 104 |
} |
110 | 105 |
} |
111 |
|
|
112 | 106 |
}else if (content instanceof Text){ |
113 | 107 |
//empty Text |
114 | 108 |
if (((Text)content).getTextNormalize().equals("")){ |
... | ... | |
127 | 121 |
} |
128 | 122 |
return (additionalContentList.size() == 0); |
129 | 123 |
} |
130 |
|
|
131 | 124 |
} |
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/tcsrdf/TcsRdfReferenceImport.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.tcsrdf; |
11 | 10 |
|
12 | 11 |
import static eu.etaxonomy.cdm.io.common.ImportHelper.NO_OVERWRITE; |
... | ... | |
102 | 101 |
// "created_When", "updated_When", "created_Who", "updated_Who", "notes" |
103 | 102 |
// }; |
104 | 103 |
|
105 |
protected static CdmSingleAttributeXmlMapperBase[] unclearMappers = new CdmSingleAttributeXmlMapperBase[]{ |
|
106 |
|
|
107 |
}; |
|
108 |
|
|
109 |
|
|
104 |
protected static CdmSingleAttributeXmlMapperBase[] unclearMappers = new CdmSingleAttributeXmlMapperBase[]{}; |
|
110 | 105 |
|
111 | 106 |
private boolean makeStandardMapper(Statement resource, Reference ref, Set<String> omitAttributes){ |
112 | 107 |
if (omitAttributes == null){ |
113 |
omitAttributes = new HashSet<String>();
|
|
108 |
omitAttributes = new HashSet<>(); |
|
114 | 109 |
} |
115 |
boolean result = true; |
|
110 |
|
|
116 | 111 |
for (IRdfMapper mapper : standardMappers){ |
117 | 112 |
if (mapper instanceof CdmSingleAttributeMapperBase){ |
118 | 113 |
makeSingleAttributeMapper((CdmSingleAttributeRDFMapperBase)mapper, resource, ref, omitAttributes); |
... | ... | |
143 | 138 |
|
144 | 139 |
private boolean makeMultipleAttributeMapper(CdmOneToManyMapper<?,?,CdmTextElementMapper> mapper, Statement parentElement, Reference ref, Set<String> omitAttributes){ |
145 | 140 |
if (omitAttributes == null){ |
146 |
omitAttributes = new HashSet<String>();
|
|
141 |
omitAttributes = new HashSet<>(); |
|
147 | 142 |
} |
148 | 143 |
boolean result = true; |
149 | 144 |
String destinationAttribute = mapper.getSingleAttributeName(); |
150 |
List<Object> sourceValues = new ArrayList<Object>();
|
|
151 |
List<Class> classes = new ArrayList<Class>();
|
|
145 |
List<Object> sourceValues = new ArrayList<>(); |
|
146 |
List<Class> classes = new ArrayList<>(); |
|
152 | 147 |
for (CdmTextElementMapper singleMapper : mapper.getSingleMappers()){ |
153 | 148 |
String sourceAttribute = singleMapper.getSourceAttribute(); |
154 | 149 |
Object value = getValue(singleMapper, parentElement); |
... | ... | |
316 | 311 |
//referenceService.saveReferenceAll(referenceMap.objects()); |
317 | 312 |
logger.info("end makeReferences ...");*/ |
318 | 313 |
return; |
319 |
|
|
320 | 314 |
} |
321 | 315 |
|
322 |
/* (non-Javadoc) |
|
323 |
* @see eu.etaxonomy.cdm.io.common.CdmIoBase#isIgnore(eu.etaxonomy.cdm.io.common.IImportConfigurator) |
|
324 |
*/ |
|
325 | 316 |
@Override |
326 | 317 |
protected boolean isIgnore(TcsRdfImportState state){ |
327 | 318 |
return (state.getConfig().getDoReferences() == IImportConfigurator.DO_REFERENCES.NONE); |
328 | 319 |
} |
329 |
|
|
330 | 320 |
} |
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/tcsxml/in/TcsXmlImportBase.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.tcsxml.in; |
11 | 10 |
|
12 | 11 |
import static eu.etaxonomy.cdm.io.common.ImportHelper.OBLIGATORY; |
... | ... | |
66 | 65 |
@Override |
67 | 66 |
protected abstract void doInvoke(TcsXmlImportState state); |
68 | 67 |
|
69 |
// /* (non-Javadoc) |
|
70 |
// * @see eu.etaxonomy.cdm.io.common.CdmIoBase#doInvoke(eu.etaxonomy.cdm.io.common.IImportConfigurator, eu.etaxonomy.cdm.api.application.CdmApplicationController, java.util.Map) |
|
71 |
// */ |
|
72 | 68 |
// @Override |
73 | 69 |
// protected boolean doInvoke(IImportConfigurator config, |
74 | 70 |
// Map<String, MapWrapper<? extends CdmBase>> stores){ |
... | ... | |
77 | 73 |
// return doInvoke(state); |
78 | 74 |
// } |
79 | 75 |
|
80 |
|
|
81 | 76 |
protected boolean makeStandardMapper(Element parentElement, CdmBase ref, Set<String> omitAttributes, CdmSingleAttributeXmlMapperBase[] classMappers){ |
82 | 77 |
if (omitAttributes == null){ |
83 |
omitAttributes = new HashSet<String>();
|
|
78 |
omitAttributes = new HashSet<>(); |
|
84 | 79 |
} |
85 | 80 |
boolean result = true; |
86 | 81 |
for (CdmSingleAttributeXmlMapperBase mapper : classMappers){ |
... | ... | |
128 | 123 |
break; |
129 | 124 |
} |
130 | 125 |
} |
131 |
|
|
132 | 126 |
}else if (content instanceof Text){ |
133 | 127 |
//empty Text |
134 | 128 |
if (((Text)content).getTextNormalize().equals("")){ |
... | ... | |
180 | 174 |
// return true; |
181 | 175 |
// } |
182 | 176 |
|
183 |
|
|
184 | 177 |
protected boolean testAdditionalElements(Element parentElement, List<String> excludeList){ |
185 | 178 |
boolean result = true; |
186 | 179 |
List<Element> list = parentElement.getChildren(); |
... | ... | |
193 | 186 |
return result; |
194 | 187 |
} |
195 | 188 |
|
196 |
|
|
197 | 189 |
protected <T extends IdentifiableEntity> T makeReferenceType(Element element, Class<? extends T> clazz, MapWrapper<? extends T> objectMap, ResultWrapper<Boolean> success){ |
198 | 190 |
T result = null; |
199 | 191 |
String linkType = element.getAttributeValue("linkType"); |
... | ... | |
232 | 224 |
return result; |
233 | 225 |
} |
234 | 226 |
|
235 |
|
|
236 | 227 |
protected Reference makeAccordingTo(Element elAccordingTo, MapWrapper<Reference> referenceMap, ResultWrapper<Boolean> success){ |
237 | 228 |
Reference result = null; |
238 | 229 |
if (elAccordingTo != null){ |
... | ... | |
255 | 246 |
return result; |
256 | 247 |
} |
257 | 248 |
|
258 |
|
|
259 | 249 |
private Reference makeAccordingToDetailed(Element elAccordingToDetailed, MapWrapper<Reference> referenceMap, ResultWrapper<Boolean> success){ |
260 | 250 |
Reference result = null; |
261 | 251 |
Namespace tcsNamespace = elAccordingToDetailed.getNamespace(); |
... | ... | |
296 | 286 |
return result; |
297 | 287 |
} |
298 | 288 |
|
299 |
|
|
300 |
|
|
301 |
|
|
302 |
|
|
303 | 289 |
protected void testNoMoreElements(){ |
304 | 290 |
//TODO |
305 | 291 |
//logger.info("testNoMoreElements Not yet implemented"); |
306 | 292 |
} |
307 | 293 |
|
308 |
|
|
309 |
|
|
310 |
|
|
311 |
|
|
312 | 294 |
@SuppressWarnings("unchecked") |
313 | 295 |
protected TeamOrPersonBase<?> makeNameCitation(Element elNameCitation, MapWrapper<Person> authorMap, ResultWrapper<Boolean> success){ |
314 | 296 |
TeamOrPersonBase<?> result = null; |
... | ... | |
360 | 342 |
} |
361 | 343 |
} |
362 | 344 |
|
363 |
|
|
364 |
|
|
365 |
|
|
366 |
|
|
367 |
|
|
368 |
|
|
369 |
|
|
370 |
|
|
371 | 345 |
protected Integer getIntegerYear(String year){ |
372 | 346 |
try { |
373 | 347 |
Integer result = Integer.valueOf(year); |
... | ... | |
384 | 358 |
} else { |
385 | 359 |
return ref; |
386 | 360 |
} |
387 |
|
|
388 | 361 |
} |
389 | 362 |
|
390 |
|
|
391 |
|
|
392 | 363 |
protected void makeTypification(TaxonName name, Element elTypifiacation, ResultWrapper<Boolean> success){ |
393 | 364 |
if (elTypifiacation != null){ |
Also available in: Unified diff
cleanup