Revision 79de4982
Added by Andreas Müller about 7 years ago
app-import/src/main/java/eu/etaxonomy/cdm/io/berlinModel/out/BerlinModelTaxonExport.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 |
*/ |
... | ... | |
50 | 50 |
public BerlinModelTaxonExport(){ |
51 | 51 |
super(); |
52 | 52 |
} |
53 |
|
|
53 |
|
|
54 | 54 |
/* (non-Javadoc) |
55 | 55 |
* @see eu.etaxonomy.cdm.io.common.CdmIoBase#doCheck(eu.etaxonomy.cdm.io.common.IImportConfigurator) |
56 | 56 |
*/ |
... | ... | |
60 | 60 |
logger.warn("Checking for " + pluralString + " not yet implemented"); |
61 | 61 |
//result &= checkArticlesWithoutJournal(bmiConfig); |
62 | 62 |
//result &= checkPartOfJournal(bmiConfig); |
63 |
|
|
63 |
|
|
64 | 64 |
return result; |
65 | 65 |
} |
66 |
|
|
66 |
|
|
67 | 67 |
private CdmDbExportMapping<BerlinModelExportState, BerlinModelExportConfigurator, IExportTransformer> getMapping(){ |
68 | 68 |
String tableName = dbTableName; |
69 | 69 |
CdmDbExportMapping<BerlinModelExportState, BerlinModelExportConfigurator, IExportTransformer> mapping = new CdmDbExportMapping<BerlinModelExportState, BerlinModelExportConfigurator, IExportTransformer>(tableName); |
... | ... | |
73 | 73 |
mapping.addMapper(MethodMapper.NewInstance("DoubtfulFlag", this) ); |
74 | 74 |
mapping.addMapper(DbBooleanMapper.NewInstance("useNameCache", "UseNameCacheFlag", false)); |
75 | 75 |
mapping.addMapper(DbStringMapper.NewFacultativeInstance("appendedPhrase", "NamePhrase")); |
76 |
|
|
76 |
|
|
77 | 77 |
//detail |
78 | 78 |
ExtensionType detailExtensionType = (ExtensionType)getTermService().find(BerlinModelTransformer.DETAIL_EXT_UUID); |
79 | 79 |
if (detailExtensionType != null){ |
... | ... | |
96 | 96 |
// } |
97 | 97 |
//publisheFlag |
98 | 98 |
mapping.addMapper(DbMarkerMapper.NewInstance(MarkerType.PUBLISH(), "PublishFlag", true)); |
99 |
|
|
99 |
|
|
100 | 100 |
//notes |
101 | 101 |
mapping.addMapper(CreatedAndNotesMapper.NewInstance()); |
102 | 102 |
|
... | ... | |
106 | 106 |
|
107 | 107 |
return mapping; |
108 | 108 |
} |
109 |
|
|
110 |
protected void doInvoke(BerlinModelExportState state){ |
|
109 |
|
|
110 |
@Override |
|
111 |
protected void doInvoke(BerlinModelExportState state){ |
|
111 | 112 |
try{ |
112 | 113 |
logger.info("start make " + pluralString + " ..."); |
113 | 114 |
boolean success = true ; |
114 | 115 |
doDelete(state); |
115 |
|
|
116 |
|
|
116 | 117 |
TransactionStatus txStatus = startTransaction(true); |
117 |
|
|
118 |
|
|
118 | 119 |
List<TaxonBase> list = getTaxonService().list(null,100000000, 0, null, null); |
119 |
|
|
120 |
|
|
120 | 121 |
CdmDbExportMapping<BerlinModelExportState, BerlinModelExportConfigurator, IExportTransformer> mapping = getMapping(); |
121 | 122 |
mapping.initialize(state); |
122 |
|
|
123 |
|
|
123 | 124 |
int count = 0; |
124 | 125 |
for (TaxonBase<?> taxon : list){ |
125 | 126 |
doCount(count++, modCount, pluralString); |
... | ... | |
128 | 129 |
commitTransaction(txStatus); |
129 | 130 |
logger.info("end make " + pluralString + " ..." + getSuccessString(success)); |
130 | 131 |
if (!success){ |
131 |
state.setUnsuccessfull(); |
|
132 |
String message = "An undefined error occurred during Taxon export"; |
|
133 |
state.getResult().addError(message); |
|
132 | 134 |
} |
133 | 135 |
return; |
134 | 136 |
}catch(SQLException e){ |
135 | 137 |
e.printStackTrace(); |
136 | 138 |
logger.error(e.getMessage()); |
137 |
state.setUnsuccessfull();
|
|
139 |
state.getResult().addException(e);
|
|
138 | 140 |
return; |
139 | 141 |
} |
140 | 142 |
} |
141 | 143 |
|
142 |
|
|
143 | 144 |
|
144 |
|
|
145 |
|
|
146 |
|
|
145 | 147 |
protected boolean doDelete(BerlinModelExportState state){ |
146 | 148 |
BerlinModelExportConfigurator bmeConfig = state.getConfig(); |
147 |
|
|
149 |
|
|
148 | 150 |
String sql; |
149 | 151 |
Source destination = bmeConfig.getDestination(); |
150 | 152 |
//RelPTaxon |
... | ... | |
162 | 164 |
|
163 | 165 |
return true; |
164 | 166 |
} |
165 |
|
|
166 |
|
|
167 |
|
|
168 |
|
|
167 | 169 |
/* (non-Javadoc) |
168 | 170 |
* @see eu.etaxonomy.cdm.io.common.CdmIoBase#isIgnore(eu.etaxonomy.cdm.io.common.IImportConfigurator) |
169 | 171 |
*/ |
170 |
protected boolean isIgnore(BerlinModelExportState state){ |
|
172 |
@Override |
|
173 |
protected boolean isIgnore(BerlinModelExportState state){ |
|
171 | 174 |
return ! state.getConfig().isDoTaxa(); |
172 | 175 |
} |
173 |
|
|
176 |
|
|
174 | 177 |
//called by MethodMapper |
175 | 178 |
@SuppressWarnings("unused") |
176 | 179 |
private static Integer getStatusFk(TaxonBase<?> taxon){ |
177 | 180 |
return BerlinModelTransformer.taxonBase2statusFk(taxon); |
178 | 181 |
} |
179 |
|
|
182 |
|
|
180 | 183 |
@SuppressWarnings("unused") |
181 | 184 |
private static String getDoubtfulFlag(TaxonBase<?> taxon){ |
182 | 185 |
if (taxon.isDoubtful()){ |
... | ... | |
185 | 188 |
return "a"; |
186 | 189 |
} |
187 | 190 |
} |
188 |
|
|
191 |
|
|
189 | 192 |
/* (non-Javadoc) |
190 | 193 |
* @see eu.etaxonomy.cdm.io.berlinModel.out.BerlinModelExportBase#getStandardMethodParameter() |
191 | 194 |
*/ |
Also available in: Unified diff
ref #6519 adapt app-import to ExportResult