Revision 51171c9d
Added by Andreas Müller over 12 years ago
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/berlinModel/in/BerlinModelAuthorTeamImport.java | ||
---|---|---|
53 | 53 |
} |
54 | 54 |
|
55 | 55 |
|
56 |
protected boolean doInvoke(BerlinModelImportState state){
|
|
56 |
protected void doInvoke(BerlinModelImportState state){
|
|
57 | 57 |
BerlinModelImportConfigurator config = state.getConfig(); |
58 | 58 |
source = config.getSource(); |
59 | 59 |
|
60 | 60 |
logger.info("start make " + pluralString + " ..."); |
61 |
boolean success = true ; |
|
62 |
|
|
63 |
|
|
61 |
|
|
64 | 62 |
//queryStrings |
65 | 63 |
String strIdQuery = getIdQuery(); |
66 | 64 |
|
... | ... | |
79 | 77 |
} |
80 | 78 |
} catch (SQLException e) { |
81 | 79 |
logger.error("SQLException:" + e); |
82 |
return false; |
|
80 |
state.setUnsuccessfull(); |
|
81 |
return; |
|
83 | 82 |
} |
84 | 83 |
|
85 | 84 |
|
86 |
logger.info("end make " + pluralString + " ... " + getSuccessString(success));
|
|
87 |
return success;
|
|
85 |
logger.info("end make " + pluralString + " ... " + getSuccessString(true));
|
|
86 |
return; |
|
88 | 87 |
} |
89 | 88 |
|
90 | 89 |
protected String getIdQuery(){ |
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/berlinModel/in/BerlinModelCommonNamesImport.java | ||
---|---|---|
118 | 118 |
|
119 | 119 |
|
120 | 120 |
@Override |
121 |
protected boolean doInvoke(BerlinModelImportState state) { |
|
122 |
boolean result = true; |
|
121 |
protected void doInvoke(BerlinModelImportState state) { |
|
123 | 122 |
try { |
124 |
result &= makeRegions(state);
|
|
123 |
makeRegions(state); |
|
125 | 124 |
} catch (Exception e) { |
126 | 125 |
logger.error("Error when creating common name regions:" + e.getMessage()); |
127 |
result = false;
|
|
126 |
state.setUnsuccessfull();
|
|
128 | 127 |
} |
129 |
result &= super.doInvoke(state);
|
|
130 |
return result;
|
|
128 |
super.doInvoke(state); |
|
129 |
return; |
|
131 | 130 |
} |
132 | 131 |
|
133 | 132 |
/** |
134 | 133 |
* @param state |
135 | 134 |
* |
136 | 135 |
*/ |
137 |
private boolean makeRegions(BerlinModelImportState state) { |
|
138 |
boolean result = true; |
|
136 |
private void makeRegions(BerlinModelImportState state) { |
|
139 | 137 |
try { |
140 | 138 |
SortedSet<Integer> regionFks = new TreeSet<Integer>(); |
141 | 139 |
Source source = state.getConfig().getSource(); |
142 | 140 |
|
143 |
result = getRegionFks(result, regionFks, source);
|
|
141 |
getRegionFks(state, regionFks, source);
|
|
144 | 142 |
//concat filter string |
145 | 143 |
String sqlWhere = getSqlWhere(regionFks); |
146 | 144 |
|
... | ... | |
149 | 147 |
//fill regionMap |
150 | 148 |
fillRegionMap(source, sqlWhere, emTdwgMap); |
151 | 149 |
|
152 |
return result;
|
|
150 |
return; |
|
153 | 151 |
} catch (NumberFormatException e) { |
154 | 152 |
e.printStackTrace(); |
155 |
return false; |
|
153 |
state.setUnsuccessfull(); |
|
154 |
return; |
|
156 | 155 |
} catch (SQLException e) { |
157 | 156 |
e.printStackTrace(); |
158 |
return false; |
|
157 |
state.setUnsuccessfull(); |
|
158 |
return; |
|
159 | 159 |
} |
160 | 160 |
} |
161 | 161 |
|
... | ... | |
462 | 462 |
|
463 | 463 |
|
464 | 464 |
/** |
465 |
* @param result
|
|
465 |
* @param state
|
|
466 | 466 |
* @param regionFks |
467 | 467 |
* @param source |
468 | 468 |
* @return |
469 | 469 |
* @throws SQLException |
470 | 470 |
*/ |
471 |
private boolean getRegionFks(boolean result, SortedSet<Integer> regionFks,
|
|
471 |
private void getRegionFks(BerlinModelImportState state, SortedSet<Integer> regionFks,
|
|
472 | 472 |
Source source) throws SQLException { |
473 | 473 |
String sql = " SELECT DISTINCT RegionFks FROM emCommonName"; |
474 | 474 |
ResultSet rs = source.getResultSet(sql); |
... | ... | |
478 | 478 |
for (String regionFk: regionFkArray){ |
479 | 479 |
regionFk = regionFk.trim(); |
480 | 480 |
if (! StringUtils.isNumeric(regionFk) || "".equals(regionFk) ){ |
481 |
result = false;
|
|
481 |
state.setUnsuccessfull();
|
|
482 | 482 |
logger.warn("RegionFk is not numeric: " + regionFk); |
483 | 483 |
}else{ |
484 | 484 |
regionFks.add(Integer.valueOf(regionFk)); |
485 | 485 |
} |
486 | 486 |
} |
487 | 487 |
} |
488 |
return result;
|
|
488 |
return; |
|
489 | 489 |
} |
490 | 490 |
|
491 | 491 |
|
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/berlinModel/in/BerlinModelFactsImport.java | ||
---|---|---|
144 | 144 |
* @see eu.etaxonomy.cdm.io.berlinModel.in.BerlinModelImportBase#doInvoke(eu.etaxonomy.cdm.io.berlinModel.in.BerlinModelImportState) |
145 | 145 |
*/ |
146 | 146 |
@Override |
147 |
protected boolean doInvoke(BerlinModelImportState state) {
|
|
147 |
protected void doInvoke(BerlinModelImportState state) {
|
|
148 | 148 |
featureMap = invokeFactCategories(state.getConfig()); |
149 |
return super.doInvoke(state); |
|
149 |
super.doInvoke(state); |
|
150 |
return; |
|
150 | 151 |
} |
151 | 152 |
|
152 | 153 |
|
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/berlinModel/in/BerlinModelImportBase.java | ||
---|---|---|
53 | 53 |
super(); |
54 | 54 |
} |
55 | 55 |
|
56 |
protected boolean doInvoke(BerlinModelImportState state){
|
|
56 |
protected void doInvoke(BerlinModelImportState state){
|
|
57 | 57 |
// String strTeamStore = ICdmIO.TEAM_STORE; |
58 | 58 |
BerlinModelImportConfigurator config = state.getConfig(); |
59 | 59 |
Source source = config.getSource(); |
... | ... | |
77 | 77 |
} |
78 | 78 |
} catch (SQLException e) { |
79 | 79 |
logger.error("SQLException:" + e); |
80 |
return false;
|
|
80 |
state.setUnsuccessfull();
|
|
81 | 81 |
} |
82 | 82 |
|
83 | 83 |
logger.info("end make " + getPluralString() + " ... " + getSuccessString(success)); |
84 |
return success; |
|
84 |
if (success == false){ |
|
85 |
state.setUnsuccessfull(); |
|
86 |
} |
|
87 |
return; |
|
85 | 88 |
} |
86 | 89 |
|
87 | 90 |
|
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/berlinModel/in/BerlinModelOccurrenceSourceImport.java | ||
---|---|---|
22 | 22 |
import org.springframework.stereotype.Component; |
23 | 23 |
|
24 | 24 |
import eu.etaxonomy.cdm.common.CdmUtils; |
25 |
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper; |
|
26 |
import eu.etaxonomy.cdm.io.berlinModel.BerlinModelTransformer; |
|
27 |
import eu.etaxonomy.cdm.io.berlinModel.in.validation.BerlinModelOccurrenceImportValidator; |
|
28 | 25 |
import eu.etaxonomy.cdm.io.berlinModel.in.validation.BerlinModelOccurrenceSourceImportValidator; |
29 |
import eu.etaxonomy.cdm.io.common.ICdmIO; |
|
30 | 26 |
import eu.etaxonomy.cdm.io.common.IOValidator; |
31 |
import eu.etaxonomy.cdm.io.common.MapWrapper; |
|
32 | 27 |
import eu.etaxonomy.cdm.io.common.ResultSetPartitioner; |
33 | 28 |
import eu.etaxonomy.cdm.io.common.Source; |
34 | 29 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
35 | 30 |
import eu.etaxonomy.cdm.model.common.DescriptionElementSource; |
36 | 31 |
import eu.etaxonomy.cdm.model.description.DescriptionElementBase; |
37 | 32 |
import eu.etaxonomy.cdm.model.description.Distribution; |
38 |
import eu.etaxonomy.cdm.model.description.PresenceAbsenceTermBase; |
|
39 |
import eu.etaxonomy.cdm.model.description.TaxonDescription; |
|
40 |
import eu.etaxonomy.cdm.model.location.NamedArea; |
|
41 |
import eu.etaxonomy.cdm.model.location.TdwgArea; |
|
42 | 33 |
import eu.etaxonomy.cdm.model.name.NonViralName; |
43 | 34 |
import eu.etaxonomy.cdm.model.name.TaxonNameBase; |
44 | 35 |
import eu.etaxonomy.cdm.model.reference.Reference; |
45 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
|
46 |
import eu.etaxonomy.cdm.model.taxon.TaxonBase; |
|
47 |
import eu.etaxonomy.cdm.strategy.exceptions.UnknownCdmTypeException; |
|
48 |
import eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl; |
|
49 | 36 |
|
50 | 37 |
|
51 | 38 |
/** |
... | ... | |
92 | 79 |
|
93 | 80 |
|
94 | 81 |
@Override |
95 |
protected boolean doInvoke(BerlinModelImportState state) {
|
|
82 |
protected void doInvoke(BerlinModelImportState state) {
|
|
96 | 83 |
try { |
97 | 84 |
sourceNumberRefIdMap = makeSourceNameReferenceIdMap(state); |
98 | 85 |
} catch (SQLException e) { |
99 | 86 |
e.printStackTrace(); |
100 | 87 |
throw new RuntimeException(e); |
101 | 88 |
} |
102 |
boolean result = super.doInvoke(state);
|
|
89 |
super.doInvoke(state); |
|
103 | 90 |
sourceNumberRefIdMap = null; |
104 |
return result;
|
|
91 |
return; |
|
105 | 92 |
} |
106 | 93 |
|
107 | 94 |
/* (non-Javadoc) |
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/berlinModel/in/BerlinModelReferenceImport.java | ||
---|---|---|
96 | 96 |
super(); |
97 | 97 |
} |
98 | 98 |
|
99 |
protected boolean initializeMappers(BerlinModelImportState state){
|
|
99 |
protected void initializeMappers(BerlinModelImportState state){
|
|
100 | 100 |
for (CdmAttributeMapperBase mapper: classMappers){ |
101 | 101 |
if (mapper instanceof DbImportExtensionMapper){ |
102 | 102 |
((DbImportExtensionMapper)mapper).initialize(state, Reference.class); |
103 | 103 |
} |
104 | 104 |
} |
105 |
return true;
|
|
105 |
return; |
|
106 | 106 |
} |
107 | 107 |
|
108 | 108 |
protected static CdmAttributeMapperBase[] classMappers = new CdmAttributeMapperBase[]{ |
... | ... | |
161 | 161 |
|
162 | 162 |
|
163 | 163 |
@Override |
164 |
protected boolean doInvoke(BerlinModelImportState state){ |
|
165 |
boolean success = true; |
|
164 |
protected void doInvoke(BerlinModelImportState state){ |
|
166 | 165 |
logger.info("start make " + getPluralString() + " ..."); |
167 | 166 |
|
168 |
success &= initializeMappers(state); |
|
167 |
boolean success = true; |
|
168 |
initializeMappers(state); |
|
169 | 169 |
BerlinModelImportConfigurator config = state.getConfig(); |
170 | 170 |
Source source = config.getSource(); |
171 | 171 |
|
... | ... | |
188 | 188 |
try { |
189 | 189 |
if (testMaxRecursionResultSet.next() == true){ |
190 | 190 |
logger.error("Maximum allowed InReference recursions exceeded in Berlin Model. Maximum recursion level is 2."); |
191 |
return false; |
|
191 |
state.setUnsuccessfull(); |
|
192 |
return; |
|
192 | 193 |
} |
193 | 194 |
} catch (SQLException e1) { |
194 | 195 |
e1.printStackTrace(); |
... | ... | |
239 | 240 |
|
240 | 241 |
} catch (SQLException e) { |
241 | 242 |
logger.error("SQLException:" + e); |
242 |
return false; |
|
243 |
state.setUnsuccessfull(); |
|
244 |
return; |
|
243 | 245 |
} |
244 | 246 |
logger.info("end make " + getPluralString() + " ... " + getSuccessString(success)); |
245 |
return success; |
|
247 |
if (! success){ |
|
248 |
state.setUnsuccessfull(); |
|
249 |
} |
|
250 |
return; |
|
246 | 251 |
} |
247 | 252 |
|
248 | 253 |
|
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/berlinModel/in/BerlinModelTaxonRelationImport.java | ||
---|---|---|
80 | 80 |
* @return |
81 | 81 |
* @throws SQLException |
82 | 82 |
*/ |
83 |
private boolean makeClassifications(BerlinModelImportState state) throws SQLException{
|
|
83 |
private void makeClassifications(BerlinModelImportState state) throws SQLException{
|
|
84 | 84 |
logger.info("start make classification ..."); |
85 | 85 |
Source source = state.getConfig().getSource(); |
86 | 86 |
|
... | ... | |
136 | 136 |
} |
137 | 137 |
logger.info("end make classification ..."); |
138 | 138 |
|
139 |
return true;
|
|
139 |
return; |
|
140 | 140 |
} |
141 | 141 |
|
142 | 142 |
/** |
... | ... | |
316 | 316 |
* @see eu.etaxonomy.cdm.io.common.CdmIoBase#doInvoke(eu.etaxonomy.cdm.io.common.IImportConfigurator, eu.etaxonomy.cdm.api.application.CdmApplicationController, java.util.Map) |
317 | 317 |
*/ |
318 | 318 |
@Override |
319 |
protected boolean doInvoke(BerlinModelImportState state){
|
|
319 |
protected void doInvoke(BerlinModelImportState state){
|
|
320 | 320 |
try { |
321 |
boolean success = true; |
|
322 |
success &= makeClassifications(state); |
|
323 |
success &= super.doInvoke(state); |
|
324 |
return success; |
|
321 |
makeClassifications(state); |
|
322 |
super.doInvoke(state); |
|
323 |
return; |
|
325 | 324 |
} catch (SQLException e) { |
326 | 325 |
throw new RuntimeException(e); |
327 | 326 |
} |
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/berlinModel/in/BerlinModelUserImport.java | ||
---|---|---|
55 | 55 |
return validator.validate(state); |
56 | 56 |
} |
57 | 57 |
|
58 |
protected boolean doInvoke(BerlinModelImportState state){
|
|
59 |
|
|
58 |
protected void doInvoke(BerlinModelImportState state){
|
|
59 |
boolean success = true; |
|
60 | 60 |
MapWrapper<User> userMap = (MapWrapper<User>)state.getStore(ICdmIO.USER_STORE); |
61 | 61 |
|
62 | 62 |
BerlinModelImportConfigurator config = state.getConfig(); |
... | ... | |
65 | 65 |
String cdmAttrName; |
66 | 66 |
|
67 | 67 |
logger.info("start make "+pluralString+" ..."); |
68 |
boolean success = true ; |
|
69 |
|
|
70 |
|
|
71 | 68 |
|
72 | 69 |
//get data from database |
73 | 70 |
String strQuery = |
... | ... | |
112 | 109 |
}catch(Exception ex){ |
113 | 110 |
logger.error(ex.getMessage()); |
114 | 111 |
ex.printStackTrace(); |
112 |
state.setUnsuccessfull(); |
|
115 | 113 |
success = false; |
116 | 114 |
} |
117 | 115 |
} //while rs.hasNext() |
118 | 116 |
} catch (SQLException e) { |
119 | 117 |
logger.error("SQLException:" + e); |
120 |
return false; |
|
118 |
state.setUnsuccessfull(); |
|
119 |
return; |
|
121 | 120 |
} |
122 | 121 |
|
123 | 122 |
logger.info("save " + i + " "+pluralString + " ..."); |
124 | 123 |
getUserService().save(userMap.objects()); |
125 | 124 |
|
126 | 125 |
logger.info("end make "+pluralString+" ..." + getSuccessString(success));; |
127 |
return success; |
|
126 |
if (!success){ |
|
127 |
state.setUnsuccessfull(); |
|
128 |
} |
|
129 |
return; |
|
128 | 130 |
} |
129 | 131 |
|
130 | 132 |
|
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/berlinModel/in/BerlinModelWebMarkerCategoryImport.java | ||
---|---|---|
55 | 55 |
/* (non-Javadoc) |
56 | 56 |
* @see eu.etaxonomy.cdm.io.berlinModel.in.BerlinModelImportBase#doInvoke(eu.etaxonomy.cdm.io.berlinModel.in.BerlinModelImportState) |
57 | 57 |
*/ |
58 |
protected boolean doInvoke(BerlinModelImportState state){
|
|
59 |
boolean result = true;
|
|
60 |
|
|
58 |
protected void doInvoke(BerlinModelImportState state){
|
|
59 |
boolean success = true ;
|
|
60 |
|
|
61 | 61 |
BerlinModelImportConfigurator config = state.getConfig(); |
62 | 62 |
Source source = config.getSource(); |
63 | 63 |
|
64 | 64 |
logger.info("start make "+pluralString+" ..."); |
65 |
boolean success = true ; |
|
66 |
|
|
65 |
|
|
67 | 66 |
ResultSet rs = source.getResultSet(getRecordQuery(config)) ; |
68 | 67 |
|
69 | 68 |
int i = 0; |
... | ... | |
94 | 93 |
} //while rs.hasNext() |
95 | 94 |
} catch (SQLException e) { |
96 | 95 |
logger.error("SQLException:" + e); |
97 |
return false; |
|
96 |
state.setUnsuccessfull(); |
|
97 |
return; |
|
98 | 98 |
} |
99 | 99 |
|
100 | 100 |
|
101 | 101 |
logger.info("save " + i + " "+pluralString + " ..."); |
102 | 102 |
|
103 | 103 |
logger.info("end make "+pluralString+" ..." + getSuccessString(success));; |
104 |
return result; |
|
104 |
if (!success){ |
|
105 |
state.setUnsuccessfull(); |
|
106 |
} |
|
107 |
return; |
|
105 | 108 |
|
106 | 109 |
} |
107 | 110 |
|
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/berlinModel/in/validation/BerlinModelGeneralImportValidator.java | ||
---|---|---|
59 | 59 |
return result; |
60 | 60 |
} |
61 | 61 |
|
62 |
protected boolean doInvoke(BerlinModelImportState state){ |
|
63 |
boolean success = true; |
|
62 |
protected void doInvoke(BerlinModelImportState state){ |
|
64 | 63 |
//do nothing |
65 |
return success;
|
|
64 |
return; |
|
66 | 65 |
|
67 | 66 |
} |
68 | 67 |
|
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/berlinModel/out/BerlinModelAuthorExport.java | ||
---|---|---|
77 | 77 |
* @see eu.etaxonomy.cdm.io.berlinModel.out.BerlinModelExportBase#doInvoke(eu.etaxonomy.cdm.io.berlinModel.out.BerlinModelExportState) |
78 | 78 |
*/ |
79 | 79 |
@Override |
80 |
protected boolean doInvoke(BerlinModelExportState state) {
|
|
80 |
protected void doInvoke(BerlinModelExportState state) {
|
|
81 | 81 |
try{ |
82 |
boolean success = true; |
|
82 | 83 |
BerlinModelExportConfigurator bmeConfig = (BerlinModelExportConfigurator)state.getConfig(); |
83 | 84 |
|
84 | 85 |
logger.info("start make "+pluralString+" ..."); |
85 |
boolean success = true ; |
|
86 | 86 |
doDelete(bmeConfig); |
87 | 87 |
|
88 | 88 |
TransactionStatus txStatus = startTransaction(true); |
... | ... | |
103 | 103 |
|
104 | 104 |
commitTransaction(txStatus); |
105 | 105 |
logger.info("end make "+pluralString+" ..." + getSuccessString(success)); |
106 |
return success; |
|
106 |
if (!success){ |
|
107 |
state.setUnsuccessfull(); |
|
108 |
} |
|
109 |
return; |
|
107 | 110 |
}catch(SQLException e){ |
108 | 111 |
e.printStackTrace(); |
109 | 112 |
logger.error(e.getMessage()); |
110 |
return false; |
|
113 |
state.setUnsuccessfull(); |
|
114 |
return; |
|
111 | 115 |
} |
112 | 116 |
} |
113 | 117 |
|
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/berlinModel/out/BerlinModelAuthorTeamExport.java | ||
---|---|---|
79 | 79 |
} |
80 | 80 |
|
81 | 81 |
|
82 |
protected boolean doInvoke(BerlinModelExportState state){
|
|
82 |
protected void doInvoke(BerlinModelExportState state){
|
|
83 | 83 |
try{ |
84 | 84 |
BerlinModelExportConfigurator bmeConfig = (BerlinModelExportConfigurator)state.getConfig(); |
85 | 85 |
|
... | ... | |
106 | 106 |
commitTransaction(txStatus); |
107 | 107 |
|
108 | 108 |
logger.info("end make "+pluralString+" ..." + getSuccessString(success)); |
109 |
return success; |
|
109 |
if (!success){ |
|
110 |
state.setUnsuccessfull(); |
|
111 |
} |
|
112 |
return; |
|
110 | 113 |
}catch(SQLException e){ |
111 | 114 |
e.printStackTrace(); |
112 | 115 |
logger.error(e.getMessage()); |
113 |
return false; |
|
116 |
state.setUnsuccessfull(); |
|
117 |
return; |
|
114 | 118 |
} |
115 | 119 |
} |
116 | 120 |
|
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/berlinModel/out/BerlinModelClassificationExport.java | ||
---|---|---|
81 | 81 |
return mapping; |
82 | 82 |
} |
83 | 83 |
|
84 |
protected boolean doInvoke(BerlinModelExportState state){
|
|
84 |
protected void doInvoke(BerlinModelExportState state){
|
|
85 | 85 |
if (state.getConfig().isUseClassification() == false){ |
86 |
return true;
|
|
86 |
return; |
|
87 | 87 |
} |
88 | 88 |
|
89 | 89 |
try{ |
... | ... | |
111 | 111 |
} |
112 | 112 |
commitTransaction(txStatus); |
113 | 113 |
logger.info("end make " + pluralString + " ..." + getSuccessString(success)); |
114 |
return success; |
|
114 |
if (!success){ |
|
115 |
state.setUnsuccessfull(); |
|
116 |
} |
|
117 |
return; |
|
115 | 118 |
}catch(SQLException e){ |
116 | 119 |
e.printStackTrace(); |
117 | 120 |
logger.error(e.getMessage()); |
118 |
return false; |
|
121 |
state.setUnsuccessfull(); |
|
122 |
return; |
|
119 | 123 |
} |
120 | 124 |
} |
121 | 125 |
|
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/berlinModel/out/BerlinModelFactExport.java | ||
---|---|---|
98 | 98 |
return mapping; |
99 | 99 |
} |
100 | 100 |
|
101 |
protected boolean doInvoke(BerlinModelExportState state){
|
|
101 |
protected void doInvoke(BerlinModelExportState state){
|
|
102 | 102 |
try{ |
103 | 103 |
logger.info("start make " + pluralString + " ..."); |
104 | 104 |
boolean success = true ; |
... | ... | |
126 | 126 |
commitTransaction(txStatus); |
127 | 127 |
logger.info("end make " + pluralString + " ..." + getSuccessString(success)); |
128 | 128 |
|
129 |
return success; |
|
129 |
if (!success){ |
|
130 |
state.setUnsuccessfull(); |
|
131 |
} |
|
132 |
return; |
|
130 | 133 |
}catch(SQLException e){ |
131 | 134 |
e.printStackTrace(); |
132 | 135 |
logger.error(e.getMessage()); |
133 |
return false; |
|
136 |
state.setUnsuccessfull(); |
|
137 |
return; |
|
134 | 138 |
} |
135 | 139 |
} |
136 | 140 |
|
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/berlinModel/out/BerlinModelNameRelationExport.java | ||
---|---|---|
84 | 84 |
return mapping; |
85 | 85 |
} |
86 | 86 |
|
87 |
protected boolean doInvoke(BerlinModelExportState state){
|
|
87 |
protected void doInvoke(BerlinModelExportState state){
|
|
88 | 88 |
try{ |
89 | 89 |
logger.info("start make " + pluralString + " ..."); |
90 | 90 |
boolean success = true ; |
... | ... | |
109 | 109 |
success &= makeIsHomotypicRelation(state, mapping); |
110 | 110 |
|
111 | 111 |
logger.info("end make " + pluralString + " ..." + getSuccessString(success)); |
112 |
return success; |
|
112 |
if (!success){ |
|
113 |
state.setUnsuccessfull(); |
|
114 |
} |
|
115 |
return; |
|
113 | 116 |
}catch(SQLException e){ |
114 | 117 |
e.printStackTrace(); |
115 | 118 |
logger.error(e.getMessage()); |
116 |
return false; |
|
119 |
state.setUnsuccessfull(); |
|
120 |
return; |
|
117 | 121 |
} |
118 | 122 |
} |
119 | 123 |
|
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/berlinModel/out/BerlinModelReferenceExport.java | ||
---|---|---|
117 | 117 |
return mapping; |
118 | 118 |
} |
119 | 119 |
|
120 |
protected boolean doInvoke(BerlinModelExportState state){
|
|
120 |
protected void doInvoke(BerlinModelExportState state){
|
|
121 | 121 |
try{ |
122 | 122 |
logger.info("start make "+pluralString+" ..."); |
123 | 123 |
boolean success = true ; |
... | ... | |
149 | 149 |
|
150 | 150 |
commitTransaction(txStatus); |
151 | 151 |
logger.info("end make "+pluralString+" ..." + getSuccessString(success)); |
152 |
|
|
153 |
return success; |
|
152 |
if (!success){ |
|
153 |
state.setUnsuccessfull(); |
|
154 |
} |
|
155 |
return; |
|
154 | 156 |
}catch(SQLException e){ |
155 | 157 |
e.printStackTrace(); |
156 | 158 |
logger.error(e.getMessage()); |
157 |
return false; |
|
159 |
state.setUnsuccessfull(); |
|
160 |
return; |
|
158 | 161 |
} |
159 | 162 |
} |
160 | 163 |
|
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/berlinModel/out/BerlinModelTaxonExport.java | ||
---|---|---|
107 | 107 |
return mapping; |
108 | 108 |
} |
109 | 109 |
|
110 |
protected boolean doInvoke(BerlinModelExportState state){
|
|
110 |
protected void doInvoke(BerlinModelExportState state){
|
|
111 | 111 |
try{ |
112 | 112 |
logger.info("start make " + pluralString + " ..."); |
113 | 113 |
boolean success = true ; |
... | ... | |
127 | 127 |
} |
128 | 128 |
commitTransaction(txStatus); |
129 | 129 |
logger.info("end make " + pluralString + " ..." + getSuccessString(success)); |
130 |
|
|
131 |
return success; |
|
130 |
if (!success){ |
|
131 |
state.setUnsuccessfull(); |
|
132 |
} |
|
133 |
return; |
|
132 | 134 |
}catch(SQLException e){ |
133 | 135 |
e.printStackTrace(); |
134 | 136 |
logger.error(e.getMessage()); |
135 |
return false; |
|
137 |
state.setUnsuccessfull(); |
|
138 |
return; |
|
136 | 139 |
} |
137 | 140 |
} |
138 | 141 |
|
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/berlinModel/out/BerlinModelTaxonNameExport.java | ||
---|---|---|
152 | 152 |
return mapping; |
153 | 153 |
} |
154 | 154 |
|
155 |
protected boolean doInvoke(BerlinModelExportState state){
|
|
155 |
protected void doInvoke(BerlinModelExportState state){
|
|
156 | 156 |
try{ |
157 | 157 |
logger.info("start make "+pluralString+" ..."); |
158 | 158 |
boolean success = true ; |
... | ... | |
174 | 174 |
commitTransaction(txStatus); |
175 | 175 |
logger.info("end make " + pluralString+ " ..." + getSuccessString(success)); |
176 | 176 |
|
177 |
return success; |
|
177 |
if (!success){ |
|
178 |
state.setUnsuccessfull(); |
|
179 |
} |
|
180 |
return; |
|
178 | 181 |
}catch(SQLException e){ |
179 | 182 |
e.printStackTrace(); |
180 | 183 |
logger.error(e.getMessage()); |
181 |
return false; |
|
184 |
state.setUnsuccessfull(); |
|
185 |
return; |
|
182 | 186 |
} |
183 | 187 |
} |
184 | 188 |
|
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/berlinModel/out/BerlinModelTaxonRelationExport.java | ||
---|---|---|
80 | 80 |
return mapping; |
81 | 81 |
} |
82 | 82 |
|
83 |
protected boolean doInvoke(BerlinModelExportState state){
|
|
83 |
protected void doInvoke(BerlinModelExportState state){
|
|
84 | 84 |
try{ |
85 | 85 |
logger.info("start make " + pluralString + " ..."); |
86 | 86 |
boolean success = true ; |
... | ... | |
102 | 102 |
} |
103 | 103 |
commitTransaction(txStatus); |
104 | 104 |
logger.info("end make " + pluralString + " ..." + getSuccessString(success)); |
105 |
return success; |
|
105 |
if (!success){ |
|
106 |
state.setUnsuccessfull(); |
|
107 |
} |
|
108 |
return; |
|
106 | 109 |
}catch(SQLException e){ |
107 | 110 |
e.printStackTrace(); |
108 | 111 |
logger.error(e.getMessage()); |
109 |
return false; |
|
112 |
state.setUnsuccessfull(); |
|
113 |
return; |
|
110 | 114 |
} |
111 | 115 |
} |
112 | 116 |
|
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/common/CacheUpdater.java | ||
---|---|---|
29 | 29 |
private static final Logger logger = Logger.getLogger(CacheUpdater.class); |
30 | 30 |
|
31 | 31 |
@Override |
32 |
protected boolean doInvoke(DefaultImportState<CacheUpdaterConfigurator> state) {
|
|
32 |
protected void doInvoke(DefaultImportState<CacheUpdaterConfigurator> state) {
|
|
33 | 33 |
CacheUpdaterConfigurator config = state.getConfig(); |
34 | 34 |
if (config.getClassList() == null || config.getClassList().isEmpty()){ |
35 | 35 |
//!! not yet implemented |
... | ... | |
37 | 37 |
createClassListFromBoolean(); |
38 | 38 |
} |
39 | 39 |
handleClassList(config.getClassList()); |
40 |
return true;
|
|
40 |
return; |
|
41 | 41 |
} |
42 | 42 |
|
43 | 43 |
|
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/common/CdmImportBase.java | ||
---|---|---|
589 | 589 |
* @return |
590 | 590 |
*/ |
591 | 591 |
public TaxonDescription getTaxonDescription(Taxon taxon, boolean isImageGallery, boolean createNewIfNotExists) { |
592 |
Reference ref = null; |
|
593 |
return getTaxonDescription(taxon, ref, isImageGallery, createNewIfNotExists); |
|
594 |
} |
|
595 |
|
|
596 |
/** |
|
597 |
* Like {@link #getTaxonDescription(Taxon, boolean, boolean)} |
|
598 |
* Only matches a description if the given reference is a source of the description.<BR> |
|
599 |
* If a new description is created the given reference will be added as a source. |
|
600 |
* |
|
601 |
* @see #getTaxonDescription(Taxon, boolean, boolean) |
|
602 |
*/ |
|
603 |
public TaxonDescription getTaxonDescription(Taxon taxon, Reference ref, boolean isImageGallery, boolean createNewIfNotExists) { |
|
592 | 604 |
TaxonDescription result = null; |
593 | 605 |
Set<TaxonDescription> descriptions= taxon.getDescriptions(); |
594 | 606 |
for (TaxonDescription description : descriptions){ |
595 | 607 |
if (description.isImageGallery() == isImageGallery){ |
596 |
result = description; |
|
597 |
break; |
|
608 |
if (hasCorrespondingSource(ref, description)){ |
|
609 |
result = description; |
|
610 |
break; |
|
611 |
} |
|
598 | 612 |
} |
599 | 613 |
} |
600 | 614 |
if (result == null && createNewIfNotExists){ |
601 | 615 |
result = TaxonDescription.NewInstance(taxon); |
602 | 616 |
result.setImageGallery(isImageGallery); |
617 |
if (ref != null){ |
|
618 |
result.addSource(null, null, ref, null); |
|
619 |
} |
|
603 | 620 |
} |
604 | 621 |
return result; |
605 | 622 |
} |
623 |
|
|
624 |
|
|
625 |
/** |
|
626 |
* Returns true, if this description has a source with a citation equal to the given reference. |
|
627 |
* Returns true if the given reference is null. |
|
628 |
* @param ref |
|
629 |
* @param description |
|
630 |
*/ |
|
631 |
private boolean hasCorrespondingSource(Reference ref, TaxonDescription description) { |
|
632 |
if (ref != null){ |
|
633 |
for (IdentifiableSource source : description.getSources()){ |
|
634 |
if (ref.equals(source.getCitation())){ |
|
635 |
return true; |
|
636 |
} |
|
637 |
} |
|
638 |
return false; |
|
639 |
} |
|
640 |
return true; |
|
641 |
|
|
642 |
} |
|
606 | 643 |
|
607 | 644 |
|
608 | 645 |
/** |
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/common/CdmIoBase.java | ||
---|---|---|
102 | 102 |
return true; |
103 | 103 |
}else{ |
104 | 104 |
updateProgress(state, "Invoking " + ioName); |
105 |
return doInvoke(state); |
|
105 |
doInvoke(state); |
|
106 |
return state.isSuccess(); |
|
106 | 107 |
} |
107 | 108 |
} |
108 | 109 |
|
... | ... | |
111 | 112 |
* @param state |
112 | 113 |
* @return |
113 | 114 |
*/ |
114 |
protected abstract boolean doInvoke(STATE state);
|
|
115 |
protected abstract void doInvoke(STATE state);
|
|
115 | 116 |
|
116 | 117 |
|
117 | 118 |
@Autowired |
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/common/ImportStateBase.java | ||
---|---|---|
70 | 70 |
|
71 | 71 |
private Map<UUID, ReferenceSystem> referenceSystemMap = new HashMap<UUID, ReferenceSystem>(); |
72 | 72 |
|
73 |
|
|
74 |
|
|
75 | 73 |
protected ImportStateBase(CONFIG config){ |
76 | 74 |
this.config = config; |
77 | 75 |
stores.put(ICdmIO.USER_STORE, new MapWrapper<User>(service)); |
... | ... | |
286 | 284 |
this.isCheck = isCheck; |
287 | 285 |
} |
288 | 286 |
|
287 |
|
|
289 | 288 |
|
290 | 289 |
} |
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/common/IoStateBase.java | ||
---|---|---|
24 | 24 |
|
25 | 25 |
private IO currentIO; |
26 | 26 |
|
27 |
private boolean success; |
|
28 |
|
|
27 | 29 |
CONFIG config; |
28 | 30 |
|
29 | 31 |
/** |
... | ... | |
61 | 63 |
public IO getCurrentIO() { |
62 | 64 |
return currentIO; |
63 | 65 |
} |
66 |
|
|
67 |
public void setSuccess(boolean success) { |
|
68 |
this.success = success; |
|
69 |
} |
|
70 |
|
|
71 |
public void setUnsuccessfull(){ |
|
72 |
this.success = false; |
|
73 |
} |
|
74 |
|
|
75 |
public boolean isSuccess() { |
|
76 |
return success; |
|
77 |
} |
|
64 | 78 |
|
65 | 79 |
|
66 | 80 |
} |
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/dwca/out/DwcaDescriptionExport.java | ||
---|---|---|
59 | 59 |
* @param filename |
60 | 60 |
*/ |
61 | 61 |
@Override |
62 |
protected boolean doInvoke(DwcaTaxExportState state){
|
|
62 |
protected void doInvoke(DwcaTaxExportState state){
|
|
63 | 63 |
DwcaTaxExportConfigurator config = state.getConfig(); |
64 | 64 |
TransactionStatus txStatus = startTransaction(true); |
65 | 65 |
|
... | ... | |
106 | 106 |
closeWriter(writer, state); |
107 | 107 |
} |
108 | 108 |
commitTransaction(txStatus); |
109 |
return true;
|
|
109 |
return; |
|
110 | 110 |
} |
111 | 111 |
|
112 | 112 |
|
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/dwca/out/DwcaDistributionExport.java | ||
---|---|---|
56 | 56 |
* @param filename |
57 | 57 |
*/ |
58 | 58 |
@Override |
59 |
protected boolean doInvoke(DwcaTaxExportState state){
|
|
59 |
protected void doInvoke(DwcaTaxExportState state){
|
|
60 | 60 |
DwcaTaxExportConfigurator config = state.getConfig(); |
61 | 61 |
TransactionStatus txStatus = startTransaction(true); |
62 | 62 |
|
... | ... | |
103 | 103 |
closeWriter(writer, state); |
104 | 104 |
} |
105 | 105 |
commitTransaction(txStatus); |
106 |
return true;
|
|
106 |
return; |
|
107 | 107 |
} |
108 | 108 |
|
109 | 109 |
|
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/dwca/out/DwcaEmlExport.java | ||
---|---|---|
63 | 63 |
* @param filename |
64 | 64 |
*/ |
65 | 65 |
@Override |
66 |
protected boolean doInvoke(DwcaTaxExportState state){
|
|
66 |
protected void doInvoke(DwcaTaxExportState state){
|
|
67 | 67 |
DwcaTaxExportConfigurator config = state.getConfig(); |
68 | 68 |
|
69 | 69 |
DwcaMetaDataRecord metaRecord = new DwcaMetaDataRecord(! IS_CORE, fileName, null); |
... | ... | |
73 | 73 |
|
74 | 74 |
DwcaEmlRecord emlRecord = config.getEmlRecord(); |
75 | 75 |
if (emlRecord == null){ |
76 |
return true;
|
|
76 |
return; |
|
77 | 77 |
} |
78 | 78 |
|
79 | 79 |
XMLStreamWriter writer = null; |
... | ... | |
128 | 128 |
closeWriter(writer, state); |
129 | 129 |
} |
130 | 130 |
|
131 |
return true;
|
|
131 |
return; |
|
132 | 132 |
} |
133 | 133 |
|
134 | 134 |
|
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/dwca/out/DwcaImageExport.java | ||
---|---|---|
59 | 59 |
* @param filename |
60 | 60 |
*/ |
61 | 61 |
@Override |
62 |
protected boolean doInvoke(DwcaTaxExportState state){
|
|
62 |
protected void doInvoke(DwcaTaxExportState state){
|
|
63 | 63 |
DwcaTaxExportConfigurator config = state.getConfig(); |
64 | 64 |
TransactionStatus txStatus = startTransaction(true); |
65 | 65 |
|
... | ... | |
109 | 109 |
} |
110 | 110 |
|
111 | 111 |
commitTransaction(txStatus); |
112 |
return true;
|
|
112 |
return; |
|
113 | 113 |
} |
114 | 114 |
|
115 | 115 |
|
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/dwca/out/DwcaMetaDataExport.java | ||
---|---|---|
47 | 47 |
* @param filename |
48 | 48 |
*/ |
49 | 49 |
@Override |
50 |
protected boolean doInvoke(DwcaTaxExportState state){
|
|
50 |
protected void doInvoke(DwcaTaxExportState state){
|
|
51 | 51 |
DwcaTaxExportConfigurator config = state.getConfig(); |
52 | 52 |
|
53 | 53 |
DwcaMetaDataRecord metaDataRecord = new DwcaMetaDataRecord(! IS_CORE, fileName, null); |
... | ... | |
97 | 97 |
closeWriter(writer, state); |
98 | 98 |
} |
99 | 99 |
|
100 |
return true;
|
|
100 |
return; |
|
101 | 101 |
} |
102 | 102 |
|
103 | 103 |
private void writeMetaDataRecord(XMLStreamWriter writer, |
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/dwca/out/DwcaReferenceExport.java | ||
---|---|---|
54 | 54 |
* @param filename |
55 | 55 |
*/ |
56 | 56 |
@Override |
57 |
protected boolean doInvoke(DwcaTaxExportState state){
|
|
57 |
protected void doInvoke(DwcaTaxExportState state){
|
|
58 | 58 |
DwcaTaxExportConfigurator config = state.getConfig(); |
59 | 59 |
TransactionStatus txStatus = startTransaction(true); |
60 | 60 |
|
... | ... | |
100 | 100 |
closeWriter(writer, state); |
101 | 101 |
} |
102 | 102 |
commitTransaction(txStatus); |
103 |
return true;
|
|
103 |
return; |
|
104 | 104 |
} |
105 | 105 |
|
106 | 106 |
private void handleReference(DwcaReferenceRecord record, Reference<?> reference, Taxon taxon) { |
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/dwca/out/DwcaResourceRelationExport.java | ||
---|---|---|
68 | 68 |
* @param filename |
69 | 69 |
*/ |
70 | 70 |
@Override |
71 |
protected boolean doInvoke(DwcaTaxExportState state){
|
|
71 |
protected void doInvoke(DwcaTaxExportState state){
|
|
72 | 72 |
DwcaTaxExportConfigurator config = state.getConfig(); |
73 | 73 |
TransactionStatus txStatus = startTransaction(true); |
74 | 74 |
|
... | ... | |
169 | 169 |
closeWriter(writer, state); |
170 | 170 |
} |
171 | 171 |
commitTransaction(txStatus); |
172 |
return true;
|
|
172 |
return; |
|
173 | 173 |
} |
174 | 174 |
|
175 | 175 |
private void handleRelationship(DwcaResourceRelationRecord record, IdentifiableEntity<?> subject, IdentifiableEntity<?> object, |
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/dwca/out/DwcaTaxExport.java | ||
---|---|---|
68 | 68 |
* @param filename |
69 | 69 |
*/ |
70 | 70 |
@Override |
71 |
protected boolean doInvoke(DwcaTaxExportState state){
|
|
71 |
protected void doInvoke(DwcaTaxExportState state){
|
|
72 | 72 |
DwcaTaxExportConfigurator config = state.getConfig(); |
73 | 73 |
TransactionStatus txStatus = startTransaction(true); |
74 | 74 |
|
... | ... | |
120 | 120 |
closeWriter(writer, state); |
121 | 121 |
} |
122 | 122 |
commitTransaction(txStatus); |
123 |
return true;
|
|
123 |
return; |
|
124 | 124 |
|
125 | 125 |
} |
126 | 126 |
|
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/dwca/out/DwcaTypesExport.java | ||
---|---|---|
68 | 68 |
* @param filename |
69 | 69 |
*/ |
70 | 70 |
@Override |
71 |
protected boolean doInvoke(DwcaTaxExportState state){
|
|
71 |
protected void doInvoke(DwcaTaxExportState state){
|
|
72 | 72 |
DwcaTaxExportConfigurator config = state.getConfig(); |
73 | 73 |
TransactionStatus txStatus = startTransaction(true); |
74 | 74 |
|
... | ... | |
128 | 128 |
closeWriter(writer, state); |
129 | 129 |
} |
130 | 130 |
commitTransaction(txStatus); |
131 |
return true;
|
|
131 |
return; |
|
132 | 132 |
} |
133 | 133 |
|
134 | 134 |
/** |
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/dwca/out/DwcaVernacularExport.java | ||
---|---|---|
62 | 62 |
* @param filename |
63 | 63 |
*/ |
64 | 64 |
@Override |
65 |
protected boolean doInvoke(DwcaTaxExportState state){
|
|
65 |
protected void doInvoke(DwcaTaxExportState state){
|
|
66 | 66 |
DwcaTaxExportConfigurator config = state.getConfig(); |
67 | 67 |
TransactionStatus txStatus = startTransaction(true); |
68 | 68 |
|
... | ... | |
110 | 110 |
closeWriter(writer, state); |
111 | 111 |
} |
112 | 112 |
commitTransaction(txStatus); |
113 |
return true;
|
|
113 |
return; |
|
114 | 114 |
} |
115 | 115 |
|
116 | 116 |
|
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/dwca/out/DwcaZipExport.java | ||
---|---|---|
36 | 36 |
* @param filename |
37 | 37 |
*/ |
38 | 38 |
@Override |
39 |
protected boolean doInvoke(DwcaTaxExportState state){
|
|
39 |
protected void doInvoke(DwcaTaxExportState state){
|
|
40 | 40 |
if (state.isZip()){ |
41 | 41 |
try { |
42 | 42 |
state.closeZip(); |
... | ... | |
96 | 96 |
// } |
97 | 97 |
|
98 | 98 |
|
99 |
return true;
|
|
99 |
return; |
|
100 | 100 |
} |
101 | 101 |
|
102 | 102 |
|
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/excel/common/ExcelImporterBase.java | ||
---|---|---|
46 | 46 |
* @param stores (not used) |
47 | 47 |
*/ |
48 | 48 |
@Override |
49 |
protected boolean doInvoke(STATE state){
|
|
49 |
protected void doInvoke(STATE state){
|
|
50 | 50 |
|
51 |
boolean success = true; |
|
52 |
|
|
53 |
logger.debug("Importing excel data"); |
|
51 |
logger.debug("Importing excel data"); |
|
54 | 52 |
|
55 | 53 |
configurator = state.getConfig(); |
56 | 54 |
|
57 | 55 |
NomenclaturalCode nc = getConfigurator().getNomenclaturalCode(); |
58 | 56 |
if (nc == null && needsNomenclaturalCode()) { |
59 | 57 |
logger.error("Nomenclatural code could not be determined. Skip invoke."); |
60 |
return false; |
|
58 |
state.setUnsuccessfull(); |
|
59 |
return; |
|
61 | 60 |
} |
62 | 61 |
// read and save all rows of the excel worksheet |
63 | 62 |
URI source = state.getConfig().getSource(); |
... | ... | |
68 | 67 |
String message = "File not found: " + source; |
69 | 68 |
warnProgress(state, message, e); |
70 | 69 |
logger.error(message); |
71 |
return false; |
|
70 |
state.setUnsuccessfull(); |
|
71 |
return; |
|
72 | 72 |
} |
73 | 73 |
|
74 |
success &= handleRecordList(state, source); |
|
75 |
|
|
74 |
handleRecordList(state, source); |
|
76 | 75 |
logger.debug("End excel data import"); |
77 |
|
|
78 |
|
|
79 |
return success; |
|
76 |
return; |
|
80 | 77 |
} |
81 | 78 |
|
82 | 79 |
protected boolean needsNomenclaturalCode() { |
... | ... | |
89 | 86 |
* @param source |
90 | 87 |
* @return |
91 | 88 |
*/ |
92 |
private boolean handleRecordList(STATE state, URI source) { |
|
93 |
boolean success = true; |
|
89 |
private void handleRecordList(STATE state, URI source) { |
|
94 | 90 |
Integer startingLine = 2; |
95 | 91 |
if (recordList != null) { |
96 | 92 |
HashMap<String,String> record = null; |
... | ... | |
101 | 97 |
state.setCurrentLine(startingLine); |
102 | 98 |
for (int i = 0; i < recordList.size(); i++) { |
103 | 99 |
record = recordList.get(i); |
104 |
success &= analyzeRecord(record, state);
|
|
100 |
analyzeRecord(record, state); |
|
105 | 101 |
try { |
106 |
success &= firstPass(state);
|
|
102 |
firstPass(state); |
|
107 | 103 |
} catch (Exception e) { |
108 | 104 |
e.printStackTrace(); |
109 | 105 |
}finally{ |
... | ... | |
114 | 110 |
state.setCurrentLine(startingLine); |
115 | 111 |
for (int i = 0; i < recordList.size(); i++) { |
116 | 112 |
record = recordList.get(i); |
117 |
success &= analyzeRecord(record, state);
|
|
118 |
success &= secondPass(state);
|
|
113 |
analyzeRecord(record, state); |
|
114 |
secondPass(state); |
|
119 | 115 |
state.incCurrentLine(); |
120 | 116 |
} |
121 | 117 |
|
... | ... | |
123 | 119 |
}else{ |
124 | 120 |
logger.warn("No records found in " + source); |
125 | 121 |
} |
126 |
return success;
|
|
122 |
return; |
|
127 | 123 |
} |
128 | 124 |
|
129 | 125 |
/** |
... | ... | |
147 | 143 |
* @param record |
148 | 144 |
* @return |
149 | 145 |
*/ |
150 |
protected abstract boolean analyzeRecord(HashMap<String,String> record, STATE state);
|
|
146 |
protected abstract void analyzeRecord(HashMap<String,String> record, STATE state);
|
|
151 | 147 |
|
152 |
protected abstract boolean firstPass(STATE state);
|
|
153 |
protected abstract boolean secondPass(STATE state);
|
|
148 |
protected abstract void firstPass(STATE state);
|
|
149 |
protected abstract void secondPass(STATE state);
|
|
154 | 150 |
|
155 | 151 |
|
156 | 152 |
public ExcelImportConfiguratorBase getConfigurator() { |
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/excel/common/ExcelTaxonOrSpecimenImportBase.java | ||
---|---|---|
38 | 38 |
|
39 | 39 |
|
40 | 40 |
protected static final String CDM_UUID_COLUMN = "(?i)(CdmUuid)"; |
41 |
|
|
41 |
protected static final String IGNORE_COLUMN = "(?i)(Ignore|Not)"; |
|
42 |
|
|
42 | 43 |
|
43 | 44 |
protected static final String RANK_COLUMN = "(?i)(Rank)"; |
44 | 45 |
protected static final String FULL_NAME_COLUMN = "(?i)(FullName)"; |
... | ... | |
48 | 49 |
protected static final String INFRASPECIFIC_EPITHET_COLUMN = "(?i)(InfraSpecificEpi(thet)?)"; |
49 | 50 |
|
50 | 51 |
@Override |
51 |
protected boolean analyzeRecord(HashMap<String, String> record, STATE state) { |
|
52 |
boolean success = true; |
|
53 |
Set<String> keys = record.keySet(); |
|
52 |
protected void analyzeRecord(HashMap<String, String> record, STATE state) { |
|
53 |
Set<String> keys = record.keySet(); |
|
54 | 54 |
|
55 | 55 |
ROW row = createDataHolderRow(); |
56 | 56 |
state.setCurrentRow(row); |
... | ... | |
61 | 61 |
continue; |
62 | 62 |
} |
63 | 63 |
if (isBaseColumn(keyValue)){ |
64 |
success &= handleBaseColumn(keyValue, row);
|
|
64 |
handleBaseColumn(keyValue, row); |
|
65 | 65 |
}else{ |
66 |
success &= analyzeSingleValue(keyValue, state);
|
|
66 |
analyzeSingleValue(keyValue, state); |
|
67 | 67 |
} |
68 | 68 |
} |
69 |
return success;
|
|
69 |
return; |
|
70 | 70 |
} |
71 | 71 |
|
72 | 72 |
protected abstract ROW createDataHolderRow(); |
... | ... | |
77 | 77 |
* @param state |
78 | 78 |
* @return |
79 | 79 |
*/ |
80 |
protected abstract boolean analyzeSingleValue(KeyValue keyValue, STATE state);
|
|
80 |
protected abstract void analyzeSingleValue(KeyValue keyValue, STATE state);
|
|
81 | 81 |
|
82 | 82 |
/** |
83 | 83 |
* DataHolder class for all key and value information for a cell. |
... | ... | |
111 | 111 |
Author("RefAuthor"), |
112 | 112 |
Title("RefTitle"), |
113 | 113 |
Year("RefYear"), |
114 |
RefExtension("RefExt(ension)?"), |
|
114 | 115 |
Language("Lang") //strictly not a reference, so some refactoring/renaming is needed |
115 | 116 |
; |
116 | 117 |
|
... | ... | |
241 | 242 |
String key = keyValue.key; |
242 | 243 |
if (key.matches(CDM_UUID_COLUMN)){ |
243 | 244 |
return true; |
245 |
} else if(keyValue.key.matches(IGNORE_COLUMN)) { |
|
246 |
logger.debug("Ignored column" + keyValue.originalKey); |
|
247 |
return true; |
|
244 | 248 |
} |
245 | 249 |
return false; |
246 | 250 |
} |
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/excel/distribution/DistributionImport.java | ||
---|---|---|
70 | 70 |
Map<Taxon, TaxonDescription> myDescriptions = new HashMap<Taxon, TaxonDescription>(); |
71 | 71 |
|
72 | 72 |
@Override |
73 |
protected boolean doInvoke(ExcelImportState<ExcelImportConfiguratorBase, ExcelRowBase> state) {
|
|
73 |
protected void doInvoke(ExcelImportState<ExcelImportConfiguratorBase, ExcelRowBase> state) {
|
|
74 | 74 |
|
75 | 75 |
if (logger.isDebugEnabled()) { logger.debug("Importing distribution data"); } |
76 | 76 |
|
... | ... | |
83 | 83 |
String message = "File not found: " + source; |
84 | 84 |
warnProgress(state, message, e); |
85 | 85 |
logger.error(message); |
86 |
return false; |
|
86 |
state.setUnsuccessfull(); |
|
87 |
return; |
|
87 | 88 |
} |
88 | 89 |
if (recordList != null) { |
89 | 90 |
HashMap<String,String> record = null; |
... | ... | |
104 | 105 |
e.printStackTrace(); |
105 | 106 |
} |
106 | 107 |
|
107 |
return true;
|
|
108 |
return; |
|
108 | 109 |
} |
109 | 110 |
|
110 | 111 |
|
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/excel/taxa/NormalExplicitImport.java | ||
---|---|---|
27 | 27 |
import eu.etaxonomy.cdm.common.CdmUtils; |
28 | 28 |
import eu.etaxonomy.cdm.io.excel.common.ExcelRowBase.SourceDataHolder; |
29 | 29 |
import eu.etaxonomy.cdm.model.agent.Team; |
30 |
import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase; |
|
30 | 31 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
31 | 32 |
import eu.etaxonomy.cdm.model.common.DescriptionElementSource; |
33 |
import eu.etaxonomy.cdm.model.common.Extension; |
|
34 |
import eu.etaxonomy.cdm.model.common.ExtensionType; |
|
32 | 35 |
import eu.etaxonomy.cdm.model.common.Language; |
33 | 36 |
import eu.etaxonomy.cdm.model.common.TimePeriod; |
34 | 37 |
import eu.etaxonomy.cdm.model.description.CommonTaxonName; |
... | ... | |
68 | 71 |
|
69 | 72 |
public static Set<String> validMarkers = new HashSet<String>(Arrays.asList(new String[]{"", "valid", "accepted", "a", "v", "t"})); |
70 | 73 |
public static Set<String> synonymMarkers = new HashSet<String>(Arrays.asList(new String[]{"", "invalid", "synonym", "s", "i"})); |
71 |
|
|
74 |
public static final UUID uuidRefExtension = UUID.fromString("a46533df-7a78-448f-9b80-36d087fbdf2a"); |
|
72 | 75 |
|
73 | 76 |
/* (non-Javadoc) |
74 | 77 |
* @see eu.etaxonomy.cdm.io.excel.common.ExcelTaxonOrSpecimenImportBase#analyzeSingleValue(eu.etaxonomy.cdm.io.excel.common.ExcelTaxonOrSpecimenImportBase.KeyValue, eu.etaxonomy.cdm.io.excel.common.ExcelImportState) |
75 | 78 |
*/ |
76 | 79 |
@Override |
77 |
protected boolean analyzeSingleValue(KeyValue keyValue, TaxonExcelImportState state) { |
|
78 |
boolean success = true; |
|
80 |
protected void analyzeSingleValue(KeyValue keyValue, TaxonExcelImportState state) { |
|
79 | 81 |
|
80 | 82 |
NormalExplicitRow normalExplicitRow = state.getCurrentRow(); |
81 | 83 |
String key = keyValue.key; |
... | ... | |
124 | 126 |
}else{ |
125 | 127 |
String message = "Unexpected column header " + key; |
126 | 128 |
fireWarningEvent(message, state, 10); |
127 |
success = false;
|
|
129 |
state.setUnsuccessfull();
|
|
128 | 130 |
logger.error(message); |
129 | 131 |
} |
130 | 132 |
} |
131 |
return success;
|
|
133 |
return; |
|
132 | 134 |
} |
133 | 135 |
|
134 | 136 |
|
135 | 137 |
/** |
136 |
* Stores taxa records in DB
|
|
138 |
* Create base taxa and add all information attached to it's name.
|
|
137 | 139 |
*/ |
138 | 140 |
@Override |
139 |
protected boolean firstPass(TaxonExcelImportState state) { |
|
140 |
boolean success = true; |
|
141 |
protected void firstPass(TaxonExcelImportState state) { |
|
142 |
|
|
143 |
// if (1==1){ |
|
144 |
// return true; |
|
145 |
// } |
|
146 |
// System.out.println("FP:" + state.getCurrentLine()); |
|
141 | 147 |
Rank rank = null; |
142 | 148 |
NormalExplicitRow taxonDataHolder = state.getCurrentRow(); |
143 | 149 |
|
... | ... | |
161 | 167 |
try { |
162 | 168 |
rank = Rank.getRankByEnglishName(rankStr, state.getConfig().getNomenclaturalCode(), false); |
163 | 169 |
} catch (UnknownCdmTypeException e) { |
164 |
success = false;
|
|
170 |
state.setUnsuccessfull();
|
|
165 | 171 |
logger.error(rankStr + " is not a valid rank."); |
166 | 172 |
} |
167 | 173 |
} |
... | ... | |
169 | 175 |
//taxon |
170 | 176 |
taxonBase = createTaxon(state, rank, taxonNameStr, authorStr, nameStatus); |
171 | 177 |
}else{ |
172 |
return true;
|
|
178 |
return; |
|
173 | 179 |
} |
174 | 180 |
} |
175 | 181 |
if (taxonBase == null){ |
176 | 182 |
String message = "Taxon could not be created. Record will not be handled"; |
177 | 183 |
fireWarningEvent(message, "Record: " + state.getCurrentLine(), 6); |
178 | 184 |
logger.warn(message); |
179 |
return false; |
|
185 |
state.setUnsuccessfull(); |
|
186 |
return; |
|
180 | 187 |
} |
181 | 188 |
|
182 | 189 |
//protologue |
... | ... | |
190 | 197 |
} catch (URISyntaxException e) { |
191 | 198 |
String warning = "URISyntaxException when trying to convert to URI: " + protologue; |
192 | 199 |
logger.error(warning); |
200 |
state.setUnsuccessfull(); |
|
193 | 201 |
} |
194 | 202 |
} |
195 |
|
|
196 |
//media |
|
197 |
for (String imageUrl : taxonDataHolder.getImages()){ |
|
198 |
//TODO |
|
199 |
Taxon taxon = CdmBase.deproxy(taxonBase, Taxon.class); |
|
200 |
TaxonDescription td = taxon.getImageGallery(true); |
|
201 |
DescriptionElementBase mediaHolder; |
|
202 |
if (td.getElements().size() != 0){ |
|
203 |
mediaHolder = td.getElements().iterator().next(); |
|
204 |
}else{ |
|
205 |
mediaHolder = TextData.NewInstance(Feature.IMAGE()); |
|
206 |
td.addElement(mediaHolder); |
|
207 |
} |
|
208 |
try { |
|
209 |
Media media = getImageMedia(imageUrl, true); |
|
210 |
mediaHolder.addMedia(media); |
|
211 |
} catch (MalformedURLException e) { |
|
212 |
logger.warn("Can't add media: " + e.getMessage()); |
|
213 |
} |
|
214 |
} |
|
215 |
|
|
216 |
//tdwg label |
|
217 |
for (String tdwg : taxonDataHolder.getDistributions()){ |
|
218 |
//TODO |
|
219 |
Taxon taxon = CdmBase.deproxy(taxonBase, Taxon.class); |
|
220 |
TaxonDescription td = this.getTaxonDescription(taxon, false, true); |
|
221 |
NamedArea area = TdwgArea.getAreaByTdwgAbbreviation(tdwg); |
|
222 |
if (area == null){ |
|
223 |
area = TdwgArea.getAreaByTdwgLabel(tdwg); |
|
224 |
} |
|
225 |
if (area != null){ |
|
226 |
Distribution distribution = Distribution.NewInstance(area, PresenceTerm.PRESENT()); |
|
227 |
td.addElement(distribution); |
|
228 |
}else{ |
|
229 |
String message = "TDWG area could not be recognized: " + tdwg; |
|
230 |
logger.warn(message); |
|
231 |
} |
|
232 |
|
|
233 |
} |
|
234 |
|
|
235 |
|
|
236 | 203 |
|
237 | 204 |
state.putTaxon(id, taxonBase); |
238 | 205 |
getTaxonService().save(taxonBase); |
Also available in: Unified diff
last updates for Taxon Excel Import and moving all success variables to state