2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
10 package eu
.etaxonomy
.taxeditor
.datasource
;
12 import java
.util
.ArrayList
;
13 import java
.util
.List
;
15 import org
.apache
.log4j
.Logger
;
16 import org
.springframework
.transaction
.TransactionStatus
;
18 import eu
.etaxonomy
.cdm
.api
.application
.CdmApplicationController
;
19 import eu
.etaxonomy
.cdm
.model
.name
.NomenclaturalStatusType
;
20 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
21 import eu
.etaxonomy
.taxeditor
.model
.CdmSessionDataRepository
;
22 import eu
.etaxonomy
.taxeditor
.model
.CdmUtil
;
29 public class CdmTransactionController
{
30 private static final Logger logger
= Logger
31 .getLogger(CdmTransactionController
.class);
33 private static CdmApplicationController applicationController
;
34 private static TransactionStatus txStatus
;
35 private CdmTransactionController controller
;
37 public static void startTransaction() {
39 txStatus
= getCdmAppController().startTransaction();
41 // Workaround - nom statii were causing a lazy loading error
42 List
<NomenclaturalStatusType
> list
= new ArrayList
<NomenclaturalStatusType
>();
43 list
.add(NomenclaturalStatusType
.SUPERFLUOUS());
44 list
.add(NomenclaturalStatusType
.NUDUM());
45 list
.add(NomenclaturalStatusType
.ILLEGITIMATE());
46 list
.add(NomenclaturalStatusType
.INVALID());
47 list
.add(NomenclaturalStatusType
.CONSERVED());
48 list
.add(NomenclaturalStatusType
.ALTERNATIVE());
49 list
.add(NomenclaturalStatusType
.REJECTED());
50 list
.add(NomenclaturalStatusType
.REJECTED_PROP());
51 list
.add(NomenclaturalStatusType
.PROVISIONAL());
52 list
.add(NomenclaturalStatusType
.SUBNUDUM());
53 list
.add(NomenclaturalStatusType
.OPUS_UTIQUE_OPPR());
54 list
.add(NomenclaturalStatusType
.AMBIGUOUS());
55 list
.add(NomenclaturalStatusType
.DOUBTFUL());
56 list
.add(NomenclaturalStatusType
.CONFUSUM());
57 list
.add(NomenclaturalStatusType
.UTIQUE_REJECTED());
58 list
.add(NomenclaturalStatusType
.CONSERVED_PROP());
59 list
.add(NomenclaturalStatusType
.LEGITIMATE());
60 list
.add(NomenclaturalStatusType
.NOVUM());
61 list
.add(NomenclaturalStatusType
.ORTHOGRAPHY_CONSERVED());
62 list
.add(NomenclaturalStatusType
.SANCTIONED());
63 list
.add(NomenclaturalStatusType
.COMBINATION_INVALID());
64 list
.add(NomenclaturalStatusType
.VALID());
65 for (NomenclaturalStatusType status
: list
){
66 //applicationController.getTermService().saveTerm(status);
70 public static void commitTransaction() {
72 // Make sure transaction exists
73 if (txStatus
== null) {
74 throw new IllegalStateException("Transaction was NULL - be sure to call startTransaction first.");
77 getCdmAppController().commitTransaction(txStatus
);
81 public static void setApplicationController(CdmApplicationController applicationController
) {
82 CdmTransactionController
.applicationController
= applicationController
;
85 private static CdmApplicationController
getCdmAppController() {
87 // Make sure the app controller has been set
88 if (applicationController
== null) {
89 throw new IllegalStateException("CdmApplicationController not yet set.");
91 return applicationController
;
94 public static void addTaxonToTransaction(Taxon taxon
) {
95 CdmUtil
.getTaxonService().saveTaxon(taxon
);
98 public static void addSessionTaxaToTransaction() {
99 CdmUtil
.getTaxonService().saveTaxonAll(
100 CdmSessionDataRepository
.getDefault().getAllTaxa());