Revision 84e9ddba
Added by Andreas Müller over 9 years ago
app-import/src/main/java/eu/etaxonomy/cdm/app/berlinModelImport/EuroMedActivator.java | ||
---|---|---|
12 | 12 |
import java.util.UUID; |
13 | 13 |
|
14 | 14 |
import org.apache.log4j.Logger; |
15 |
import org.springframework.transaction.TransactionStatus; |
|
15 | 16 |
|
16 | 17 |
import eu.etaxonomy.cdm.api.application.ICdmApplicationConfiguration; |
17 | 18 |
import eu.etaxonomy.cdm.app.common.CdmDestinations; |
... | ... | |
53 | 54 |
static final Source berlinModelSource = BerlinModelSources.euroMed_PESI3(); |
54 | 55 |
|
55 | 56 |
// static final ICdmDataSource cdmDestination = CdmDestinations.cdm_pesi_euroMed(); |
56 |
static final ICdmDataSource cdmDestination = CdmDestinations.cdm_test_local_euromed(); |
|
57 |
static final ICdmDataSource cdmDestination = CdmDestinations.cdm_test_local_euromed3();
|
|
57 | 58 |
// static final ICdmDataSource cdmDestination = CdmDestinations.localH2(); |
58 | 59 |
|
59 | 60 |
static final boolean includePesiExport = false; |
... | ... | |
115 | 116 |
|
116 | 117 |
// **************** ALL ********************* |
117 | 118 |
|
118 |
// static final boolean doUser = true; |
|
119 |
// //authors |
|
120 |
// static final boolean doAuthors = true; |
|
121 |
// //references |
|
122 |
// static final DO_REFERENCES doReferences = DO_REFERENCES.ALL; |
|
123 |
// //names |
|
124 |
// static final boolean doTaxonNames = true; |
|
125 |
// static final boolean doRelNames = true; |
|
126 |
// static final boolean doNameStatus = true; |
|
127 |
// static final boolean doTypes = false; //serious types do not exist in E+M |
|
128 |
// static final boolean doNameFacts = true; |
|
129 |
// |
|
130 |
// //taxa |
|
131 |
// static final boolean doTaxa = true; |
|
132 |
// static final boolean doRelTaxa = false; |
|
133 |
// static final boolean doFacts = true; |
|
134 |
// static final boolean doOccurences = true; |
|
135 |
// static final boolean doCommonNames = true; |
|
136 |
// |
|
137 |
// //etc. |
|
138 |
// static final boolean doMarker = true; |
|
139 |
|
|
119 |
boolean invers = true; |
|
140 | 120 |
|
141 |
// **************** SELECTED ********************* |
|
142 |
|
|
143 |
static final boolean doUser = false; |
|
144 |
//authors |
|
145 |
static final boolean doAuthors = false; |
|
121 |
static final boolean doUser = true; |
|
122 |
// //authors |
|
123 |
static final boolean doAuthors = true; |
|
146 | 124 |
//references |
147 |
static final DO_REFERENCES doReferences = DO_REFERENCES.NONE;
|
|
125 |
static final DO_REFERENCES doReferences = DO_REFERENCES.ALL;
|
|
148 | 126 |
//names |
149 |
static final boolean doTaxonNames = false; |
|
150 |
static final boolean doRelNames = false; |
|
151 |
static final boolean doNameStatus = false; |
|
152 |
static final boolean doTypes = false; |
|
153 |
static final boolean doNameFacts = false; |
|
154 |
|
|
155 |
//taxa |
|
156 |
static final boolean doTaxa = false; |
|
157 |
static final boolean doRelTaxa = true; |
|
158 |
static final boolean doFacts = false; |
|
159 |
static final boolean doOccurences = false; |
|
160 |
static final boolean doCommonNames = false; |
|
127 |
static final boolean doTaxonNames = true; |
|
128 |
static final boolean doRelNames = true; |
|
129 |
static final boolean doNameStatus = true; |
|
130 |
static final boolean doTypes = false; //serious types do not exist in E+M |
|
131 |
static final boolean doNameFacts = true; |
|
161 | 132 |
|
133 |
//taxa |
|
134 |
static final boolean doTaxa = true; |
|
135 |
static final boolean doRelTaxa = false; |
|
136 |
static final boolean doFacts = true; |
|
137 |
static final boolean doOccurences = true; |
|
138 |
static final boolean doCommonNames = true; |
|
139 |
|
|
162 | 140 |
//etc. |
163 |
static final boolean doMarker = false;
|
|
164 |
|
|
141 |
static final boolean doMarker = true;
|
|
142 |
|
|
165 | 143 |
|
166 | 144 |
public void importEm2CDM (Source source, ICdmDataSource destination, DbSchemaValidation hbm2dll){ |
167 | 145 |
System.out.println("Start import from BerlinModel("+ berlinModelSource.getDatabase() + ") to " + cdmDestination.getDatabase() + " ..."); |
... | ... | |
171 | 149 |
|
172 | 150 |
config.setClassificationUuid(classificationUuid); |
173 | 151 |
config.setSourceSecId(sourceSecId); |
174 |
|
|
175 | 152 |
config.setNomenclaturalCode(nomenclaturalCode); |
176 |
|
|
177 | 153 |
config.setIgnoreNull(ignoreNull); |
178 |
config.setDoAuthors(doAuthors); |
|
179 |
config.setDoReferences(doReferences); |
|
180 |
config.setDoTaxonNames(doTaxonNames); |
|
181 |
config.setDoRelNames(doRelNames); |
|
182 |
config.setDoNameStatus(doNameStatus); |
|
183 |
config.setDoTypes(doTypes); |
|
184 |
config.setDoNameFacts(doNameFacts); |
|
185 |
config.setUseClassification(useClassification); |
|
186 |
config.setSourceRefUuid(BerlinModelTransformer.uuidSourceRefEuroMed); |
|
187 | 154 |
|
188 |
config.setDoTaxa(doTaxa); |
|
189 |
config.setDoRelTaxa(doRelTaxa); |
|
190 |
config.setDoFacts(doFacts); |
|
191 |
config.setDoOccurrence(doOccurences); |
|
192 |
config.setDoCommonNames(doCommonNames); |
|
155 |
config.setDoAuthors(doAuthors ^ invers); |
|
156 |
config.setDoReferences(invers ? doReferences.invers() : doReferences); |
|
157 |
config.setDoTaxonNames(doTaxonNames ^ invers); |
|
158 |
config.setDoRelNames(doRelNames ^ invers); |
|
159 |
config.setDoNameStatus(doNameStatus ^ invers); |
|
160 |
config.setDoTypes(doTypes); //always false |
|
161 |
config.setDoNameFacts(doNameFacts ^ invers); |
|
162 |
config.setDoTaxa(doTaxa ^ invers); |
|
163 |
config.setDoRelTaxa(doRelTaxa ^ invers); |
|
164 |
config.setDoFacts(doFacts ^ invers); |
|
165 |
config.setDoOccurrence(doOccurences ^ invers); |
|
166 |
config.setDoCommonNames(doCommonNames ^ invers); |
|
193 | 167 |
|
194 |
config.setDoMarker(doMarker); |
|
195 |
config.setDoUser(doUser); |
|
168 |
config.setDoMarker(doMarker ^ invers); |
|
169 |
config.setDoUser(doUser ^ invers); |
|
170 |
|
|
171 |
config.setUseClassification(useClassification); |
|
172 |
config.setSourceRefUuid(BerlinModelTransformer.uuidSourceRefEuroMed); |
|
196 | 173 |
config.setEditor(editor); |
197 | 174 |
config.setDbSchemaValidation(hbm2dll); |
198 | 175 |
|
... | ... | |
232 | 209 |
CdmDefaultImport<BerlinModelImportConfigurator> bmImport = new CdmDefaultImport<BerlinModelImportConfigurator>(); |
233 | 210 |
bmImport.invoke(config); |
234 | 211 |
|
235 |
if (doTaxonNames && (config.getCheck().equals(CHECK.CHECK_AND_IMPORT) || config.getCheck().equals(CHECK.IMPORT_WITHOUT_CHECK) ) ){
|
|
212 |
if (config.isDoTaxonNames() && (config.getCheck().equals(CHECK.CHECK_AND_IMPORT) || config.getCheck().equals(CHECK.IMPORT_WITHOUT_CHECK) ) ){
|
|
236 | 213 |
ICdmApplicationConfiguration app = bmImport.getCdmAppController(); |
237 |
Rank sectBot = (Rank)app.getTermService().find(Rank.SECTION_BOTANY().getUuid()); |
|
238 |
Representation repr = sectBot.getRepresentation(Language.ENGLISH()); |
|
239 |
repr.setAbbreviatedLabel(repr.getAbbreviatedLabel().replace("(bot.)", "").trim()); |
|
240 |
repr.setLabel(repr.getLabel().replace("(Botany)", "").trim()); |
|
241 |
sectBot.setTitleCache(null, false); //to definetely update the titleCache also |
|
242 |
app.getTermService().saveOrUpdate(sectBot); |
|
243 |
|
|
244 |
Rank subSectBot = (Rank)app.getTermService().find(Rank.SECTION_BOTANY().getUuid()); |
|
245 |
repr = subSectBot.getRepresentation(Language.ENGLISH()); |
|
246 |
repr.setAbbreviatedLabel(repr.getAbbreviatedLabel().replace("(bot.)", "").trim()); |
|
247 |
repr.setLabel(repr.getLabel().replace("(Botany)", "").trim()); |
|
248 |
subSectBot.setTitleCache(null, false); //to definetely update the titleCache also |
|
249 |
app.getTermService().saveOrUpdate(subSectBot); |
|
250 |
|
|
214 |
TransactionStatus tx = app.startTransaction(); |
|
215 |
try { |
|
216 |
Rank sectBot = (Rank)app.getTermService().find(Rank.SECTION_BOTANY().getUuid()); |
|
217 |
Representation repr = sectBot.getRepresentation(Language.ENGLISH()); |
|
218 |
repr.setAbbreviatedLabel(repr.getAbbreviatedLabel().replace("(bot.)", "").trim()); |
|
219 |
repr.setLabel(repr.getLabel().replace("(Botany)", "").trim()); |
|
220 |
sectBot.setTitleCache(null, false); //to definetely update the titleCache also |
|
221 |
app.getTermService().saveOrUpdate(sectBot); |
|
222 |
|
|
223 |
Rank subSectBot = (Rank)app.getTermService().find(Rank.SECTION_BOTANY().getUuid()); |
|
224 |
repr = subSectBot.getRepresentation(Language.ENGLISH()); |
|
225 |
repr.setAbbreviatedLabel(repr.getAbbreviatedLabel().replace("(bot.)", "").trim()); |
|
226 |
repr.setLabel(repr.getLabel().replace("(Botany)", "").trim()); |
|
227 |
subSectBot.setTitleCache(null, false); //to definetely update the titleCache also |
|
228 |
app.getTermService().saveOrUpdate(subSectBot); |
|
229 |
app.commitTransaction(tx); |
|
230 |
} catch (Exception e) { |
|
231 |
e.printStackTrace(); |
|
232 |
} |
|
251 | 233 |
} |
252 | 234 |
|
253 |
if (doFacts && (config.getCheck().equals(CHECK.CHECK_AND_IMPORT) || config.getCheck().equals(CHECK.IMPORT_WITHOUT_CHECK) ) ){
|
|
235 |
if (config.isDoFacts() && (config.getCheck().equals(CHECK.CHECK_AND_IMPORT) || config.getCheck().equals(CHECK.IMPORT_WITHOUT_CHECK) ) ){
|
|
254 | 236 |
ICdmApplicationConfiguration app = bmImport.getCdmAppController(); |
237 |
TransactionStatus tx = app.startTransaction(); |
|
255 | 238 |
|
256 | 239 |
//make feature tree |
257 | 240 |
FeatureTree tree = TreeCreator.flatTree(featureTreeUuid, config.getFeatureMap(), featureKeyList); |
258 | 241 |
FeatureNode imageNode = FeatureNode.NewInstance(Feature.IMAGE()); |
259 | 242 |
tree.getRoot().addChild(imageNode); |
260 | 243 |
FeatureNode distributionNode = FeatureNode.NewInstance(Feature.DISTRIBUTION()); |
261 |
tree.getRoot().addChild(distributionNode, 2);
|
|
244 |
tree.getRoot().addChild(distributionNode, 1);
|
|
262 | 245 |
FeatureNode commonNameNode = FeatureNode.NewInstance(Feature.COMMON_NAME()); |
263 |
tree.getRoot().addChild(commonNameNode, 3);
|
|
246 |
tree.getRoot().addChild(commonNameNode, 2);
|
|
264 | 247 |
app.getFeatureTreeService().saveOrUpdate(tree); |
265 | 248 |
|
266 | 249 |
//Change common name label |
... | ... | |
268 | 251 |
commonNameFeature.setLabel("Common Names", Language.ENGLISH()); |
269 | 252 |
commonNameFeature.setTitleCache(null, false); //to definetely update the titleCache also |
270 | 253 |
app.getTermService().saveOrUpdate(commonNameFeature); |
254 |
app.commitTransaction(tx); |
|
271 | 255 |
} |
272 | 256 |
|
273 | 257 |
System.out.println("End import from BerlinModel ("+ source.getDatabase() + ")..."); |
Also available in: Unified diff
refactor EMActivator