Revision 4a5ee6fe
Added by Andreas Müller almost 9 years ago
app-import/src/main/java/eu/etaxonomy/cdm/app/berlinModelImport/EuroMedActivator.java | ||
---|---|---|
38 | 38 |
import eu.etaxonomy.cdm.io.berlinModel.BerlinModelTransformer; |
39 | 39 |
import eu.etaxonomy.cdm.io.berlinModel.in.BerlinModelImportConfigurator; |
40 | 40 |
import eu.etaxonomy.cdm.io.common.CdmDefaultImport; |
41 |
import eu.etaxonomy.cdm.io.common.CdmImportBase; |
|
42 | 41 |
import eu.etaxonomy.cdm.io.common.IImportConfigurator.CHECK; |
43 | 42 |
import eu.etaxonomy.cdm.io.common.IImportConfigurator.DO_REFERENCES; |
44 | 43 |
import eu.etaxonomy.cdm.io.common.IImportConfigurator.EDITOR; |
... | ... | |
48 | 47 |
import eu.etaxonomy.cdm.model.common.GrantedAuthorityImpl; |
49 | 48 |
import eu.etaxonomy.cdm.model.common.Group; |
50 | 49 |
import eu.etaxonomy.cdm.model.common.Language; |
51 |
import eu.etaxonomy.cdm.model.common.Marker; |
|
52 |
import eu.etaxonomy.cdm.model.common.MarkerType; |
|
53 | 50 |
import eu.etaxonomy.cdm.model.common.Representation; |
54 |
import eu.etaxonomy.cdm.model.common.TermVocabulary; |
|
55 | 51 |
import eu.etaxonomy.cdm.model.common.User; |
56 | 52 |
import eu.etaxonomy.cdm.model.description.Feature; |
57 | 53 |
import eu.etaxonomy.cdm.model.description.FeatureNode; |
... | ... | |
174 | 170 |
static final boolean doCommonNames = true; |
175 | 171 |
static final boolean doOccurences = true; |
176 | 172 |
static final boolean doRelTaxa = false; |
177 |
static final boolean doRunTransmissionEngine = true;// (hbm2dll == DbSchemaValidation.VALIDATE);
|
|
173 |
static final boolean doRunTransmissionEngine = false;// (hbm2dll == DbSchemaValidation.VALIDATE);
|
|
178 | 174 |
|
179 | 175 |
//etc. |
180 | 176 |
static final boolean doMarker = true; |
... | ... | |
263 | 259 |
|
264 | 260 |
importShapefile(config, bmImport); |
265 | 261 |
|
266 |
markAreasAsHidden(config, bmImport);
|
|
262 |
// markAreasAsHidden(config, bmImport); //has been moved to BM occurrence import
|
|
267 | 263 |
|
268 | 264 |
System.out.println("End import from BerlinModel ("+ source.getDatabase() + ")..."); |
269 | 265 |
} |
... | ... | |
382 | 378 |
} |
383 | 379 |
} |
384 | 380 |
|
385 |
//5.Mark areas to be hidden #3979 .5 |
|
386 |
private void markAreasAsHidden(BerlinModelImportConfigurator config, |
|
387 |
CdmDefaultImport<BerlinModelImportConfigurator> bmImport) { |
|
388 |
|
|
389 |
if (config.isDoOccurrence() && (config.getCheck().isImport())){ |
|
390 |
try { |
|
391 |
ICdmApplicationConfiguration app = bmImport.getCdmAppController(); |
|
392 |
TransactionStatus tx = app.startTransaction(); |
|
393 |
|
|
394 |
MarkerType hiddenAreaMarkerType = MarkerType.NewInstance("Used to hide distributions for the named areas in publications", "Hidden Area", null); |
|
395 |
hiddenAreaMarkerType.setUuid(BerlinModelTransformer.uuidHiddenArea); |
|
396 |
@SuppressWarnings("unchecked") |
|
397 |
TermVocabulary<MarkerType> vocUserDefinedMarkerTypes = app.getVocabularyService().find(CdmImportBase.uuidUserDefinedMarkerTypeVocabulary); |
|
398 |
if (vocUserDefinedMarkerTypes == null){ |
|
399 |
String message = "Marker type vocabulary could not be found. Hidden areas not added."; |
|
400 |
logger.error(message); |
|
401 |
System.out.println(message); |
|
402 |
}else{ |
|
403 |
vocUserDefinedMarkerTypes.addTerm(hiddenAreaMarkerType); |
|
404 |
app.getVocabularyService().saveOrUpdate(vocUserDefinedMarkerTypes); |
|
405 |
|
|
406 |
//Add hidden area marker to Rs(C) and Rs(N) |
|
407 |
hideArea(app, hiddenAreaMarkerType, BerlinModelTransformer.uuidRs); |
|
408 |
hideArea(app, hiddenAreaMarkerType, BerlinModelTransformer.uuidRs_B); |
|
409 |
hideArea(app, hiddenAreaMarkerType, BerlinModelTransformer.uuidRs_C); |
|
410 |
hideArea(app, hiddenAreaMarkerType, BerlinModelTransformer.uuidRs_E); |
|
411 |
hideArea(app, hiddenAreaMarkerType, BerlinModelTransformer.uuidRs_N); |
|
412 |
hideArea(app, hiddenAreaMarkerType, BerlinModelTransformer.uuidRs_K); |
|
413 |
hideArea(app, hiddenAreaMarkerType, BerlinModelTransformer.uuidRs_W); |
|
414 |
} |
|
415 |
app.commitTransaction(tx); |
|
416 |
} catch (Exception e) { |
|
417 |
e.printStackTrace(); |
|
418 |
logger.error("Exception in markAreasAsHidden: " + e.getMessage()); |
|
419 |
} |
|
420 |
} |
|
421 |
} |
|
422 |
|
|
423 |
private void hideArea(ICdmApplicationConfiguration app, MarkerType hiddenAreaMarkerType, UUID areaUuid) { |
|
424 |
NamedArea area = (NamedArea)app.getTermService().find(areaUuid); |
|
425 |
area.addMarker(Marker.NewInstance(hiddenAreaMarkerType, true)); |
|
426 |
app.getTermService().saveOrUpdate(area); |
|
427 |
} |
|
381 |
// //5.Mark areas to be hidden #3979 .5
|
|
382 |
// private void markAreasAsHidden(BerlinModelImportConfigurator config,
|
|
383 |
// CdmDefaultImport<BerlinModelImportConfigurator> bmImport) {
|
|
384 |
// |
|
385 |
// if (config.isDoOccurrence() && (config.getCheck().isImport())){
|
|
386 |
// try {
|
|
387 |
// ICdmApplicationConfiguration app = bmImport.getCdmAppController();
|
|
388 |
// TransactionStatus tx = app.startTransaction();
|
|
389 |
// |
|
390 |
// MarkerType hiddenAreaMarkerType = MarkerType.NewInstance("Used to hide distributions for the named areas in publications", "Hidden Area", null);
|
|
391 |
// hiddenAreaMarkerType.setUuid(BerlinModelTransformer.uuidHiddenArea);
|
|
392 |
// @SuppressWarnings("unchecked")
|
|
393 |
// TermVocabulary<MarkerType> vocUserDefinedMarkerTypes = app.getVocabularyService().find(CdmImportBase.uuidUserDefinedMarkerTypeVocabulary);
|
|
394 |
// if (vocUserDefinedMarkerTypes == null){
|
|
395 |
// String message = "Marker type vocabulary could not be found. Hidden areas not added.";
|
|
396 |
// logger.error(message);
|
|
397 |
// System.out.println(message);
|
|
398 |
// }else{
|
|
399 |
// vocUserDefinedMarkerTypes.addTerm(hiddenAreaMarkerType);
|
|
400 |
// app.getVocabularyService().saveOrUpdate(vocUserDefinedMarkerTypes);
|
|
401 |
// |
|
402 |
// //Add hidden area marker to Rs(C) and Rs(N)
|
|
403 |
// hideArea(app, hiddenAreaMarkerType, BerlinModelTransformer.uuidRs);
|
|
404 |
// hideArea(app, hiddenAreaMarkerType, BerlinModelTransformer.uuidRs_B);
|
|
405 |
// hideArea(app, hiddenAreaMarkerType, BerlinModelTransformer.uuidRs_C);
|
|
406 |
// hideArea(app, hiddenAreaMarkerType, BerlinModelTransformer.uuidRs_E);
|
|
407 |
// hideArea(app, hiddenAreaMarkerType, BerlinModelTransformer.uuidRs_N);
|
|
408 |
// hideArea(app, hiddenAreaMarkerType, BerlinModelTransformer.uuidRs_K);
|
|
409 |
// hideArea(app, hiddenAreaMarkerType, BerlinModelTransformer.uuidRs_W);
|
|
410 |
// }
|
|
411 |
// app.commitTransaction(tx);
|
|
412 |
// } catch (Exception e) {
|
|
413 |
// e.printStackTrace();
|
|
414 |
// logger.error("Exception in markAreasAsHidden: " + e.getMessage());
|
|
415 |
// }
|
|
416 |
// }
|
|
417 |
// }
|
|
418 |
// |
|
419 |
// private void hideArea(ICdmApplicationConfiguration app, MarkerType hiddenAreaMarkerType, UUID areaUuid) {
|
|
420 |
// NamedArea area = (NamedArea)app.getTermService().find(areaUuid);
|
|
421 |
// area.addMarker(Marker.NewInstance(hiddenAreaMarkerType, true));
|
|
422 |
// app.getTermService().saveOrUpdate(area);
|
|
423 |
// }
|
|
428 | 424 |
|
429 | 425 |
//2. import shapefile attributes #3979 .2 |
430 | 426 |
private void importShapefile(BerlinModelImportConfigurator config, |
Also available in: Unified diff
Adapt EM area hierarchy to filtering rules #3904
Also moving hidden area functionality from activator to occurrence
import class.