Revision 51171c9d
Added by Andreas Müller almost 13 years ago
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() { |
Also available in: Unified diff
last updates for Taxon Excel Import and moving all success variables to state