Revision 3f9687fa
Added by Andreas Müller over 12 years ago
.gitattributes | ||
---|---|---|
66 | 66 |
app-import/src/main/java/eu/etaxonomy/cdm/app/tcs/TcsRdfTestActivator.java -text |
67 | 67 |
app-import/src/main/java/eu/etaxonomy/cdm/app/tcs/TcsSources.java -text |
68 | 68 |
app-import/src/main/java/eu/etaxonomy/cdm/app/tcs/TcsXmlTestActivator.java -text |
69 |
app-import/src/main/java/eu/etaxonomy/cdm/app/testUpdate/EricaceaeTestUpdateActivator.java -text |
|
70 | 69 |
app-import/src/main/java/eu/etaxonomy/cdm/app/util/TestDatabase.java -text |
71 | 70 |
app-import/src/main/java/eu/etaxonomy/cdm/app/util/TestTransaction.java -text |
72 | 71 |
app-import/src/main/java/eu/etaxonomy/cdm/app/viennaImport/ViennaActivator.java -text |
... | ... | |
1197 | 1196 |
cdm-eflora/src/main/java/eu/etaxonomy/cdm/app/eflora/EfloraSources.java -text |
1198 | 1197 |
cdm-eflora/src/main/java/eu/etaxonomy/cdm/app/eflora/FloraMalesianaActivator.java -text |
1199 | 1198 |
cdm-eflora/src/main/java/eu/etaxonomy/cdm/app/eflora/FloraMalesianaVol13Activator.java -text |
1199 |
cdm-eflora/src/main/java/eu/etaxonomy/cdm/app/testUpdate/EricaceaeTestUpdateActivator.java -text |
|
1200 | 1200 |
cdm-eflora/src/main/java/eu/etaxonomy/cdm/io/eflora/EfloraImportBase.java -text |
1201 | 1201 |
cdm-eflora/src/main/java/eu/etaxonomy/cdm/io/eflora/EfloraImportConfigurator.java -text |
1202 | 1202 |
cdm-eflora/src/main/java/eu/etaxonomy/cdm/io/eflora/EfloraImportState.java -text |
app-import/src/main/java/eu/etaxonomy/cdm/app/testUpdate/EricaceaeTestUpdateActivator.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2007 EDIT |
|
3 |
* European Distributed Institute of Taxonomy |
|
4 |
* http://www.e-taxonomy.eu |
|
5 |
* |
|
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. |
|
8 |
*/ |
|
9 |
|
|
10 |
package eu.etaxonomy.cdm.app.testUpdate; |
|
11 |
|
|
12 |
import java.net.URI; |
|
13 |
import java.util.List; |
|
14 |
import java.util.UUID; |
|
15 |
|
|
16 |
import org.apache.log4j.Logger; |
|
17 |
import org.springframework.transaction.TransactionStatus; |
|
18 |
|
|
19 |
import eu.etaxonomy.cdm.api.application.ICdmApplicationConfiguration; |
|
20 |
import eu.etaxonomy.cdm.app.common.CdmDestinations; |
|
21 |
import eu.etaxonomy.cdm.app.eflora.EfloraSources; |
|
22 |
import eu.etaxonomy.cdm.common.monitor.DefaultProgressMonitor; |
|
23 |
import eu.etaxonomy.cdm.database.DbSchemaValidation; |
|
24 |
import eu.etaxonomy.cdm.database.ICdmDataSource; |
|
25 |
import eu.etaxonomy.cdm.database.update.CdmUpdater; |
|
26 |
import eu.etaxonomy.cdm.io.common.CdmDefaultImport; |
|
27 |
import eu.etaxonomy.cdm.io.common.IImportConfigurator.CHECK; |
|
28 |
import eu.etaxonomy.cdm.io.eflora.EfloraImportConfigurator; |
|
29 |
import eu.etaxonomy.cdm.io.eflora.centralAfrica.ericaceae.CentralAfricaEricaceaeImportConfigurator; |
|
30 |
import eu.etaxonomy.cdm.model.common.Language; |
|
31 |
import eu.etaxonomy.cdm.model.description.FeatureNode; |
|
32 |
import eu.etaxonomy.cdm.model.description.FeatureTree; |
|
33 |
import eu.etaxonomy.cdm.model.reference.Reference; |
|
34 |
import eu.etaxonomy.cdm.model.reference.ReferenceFactory; |
|
35 |
|
|
36 |
/** |
|
37 |
* @author a.mueller |
|
38 |
* @created 20.06.2008 |
|
39 |
* @version 1.0 |
|
40 |
*/ |
|
41 |
public class EricaceaeTestUpdateActivator { |
|
42 |
@SuppressWarnings("unused") |
|
43 |
private static final Logger logger = Logger.getLogger(EricaceaeTestUpdateActivator.class); |
|
44 |
|
|
45 |
//database validation status (create, update, validate ...) |
|
46 |
static DbSchemaValidation hbm2dll = DbSchemaValidation.VALIDATE; |
|
47 |
static final URI source = EfloraSources.ericacea_local(); |
|
48 |
|
|
49 |
|
|
50 |
// static final ICdmDataSource cdmDestination = CdmDestinations.cdm_test_andreasM2(); |
|
51 |
// static final ICdmDataSource cdmDestination = CdmDestinations.cdm_flora_central_africa_preview(); |
|
52 |
// static final ICdmDataSource cdmDestination = CdmDestinations.cdm_flora_central_africa_production(); |
|
53 |
static final ICdmDataSource cdmDestination = CdmDestinations.localH2(); |
|
54 |
// static final ICdmDataSource cdmDestination = CdmDestinations.cdm_local_postgres_CdmTest(); |
|
55 |
|
|
56 |
|
|
57 |
//feature tree uuid |
|
58 |
public static final UUID featureTreeUuid = UUID.fromString("051d35ee-22f1-42d8-be07-9e9bfec5bcf7"); |
|
59 |
|
|
60 |
public static UUID defaultLanguageUuid = Language.uuidEnglish; |
|
61 |
|
|
62 |
//classification |
|
63 |
static final UUID classificationUuid = UUID.fromString("10e5efcc-6e13-4abc-ad42-e0b46e50cbe7"); |
|
64 |
|
|
65 |
//check - import |
|
66 |
static final CHECK check = CHECK.IMPORT_WITHOUT_CHECK; |
|
67 |
|
|
68 |
static boolean doPrintKeys = false; |
|
69 |
|
|
70 |
//taxa |
|
71 |
static final boolean doTaxa = false; |
|
72 |
|
|
73 |
private boolean includeEricaceae = true; |
|
74 |
|
|
75 |
|
|
76 |
|
|
77 |
private void doImport(ICdmDataSource cdmDestination){ |
|
78 |
|
|
79 |
CdmUpdater updater = new CdmUpdater(); |
|
80 |
updater.updateToCurrentVersion(cdmDestination, DefaultProgressMonitor.NewInstance()); |
|
81 |
|
|
82 |
//make Source |
|
83 |
CentralAfricaEricaceaeImportConfigurator config= CentralAfricaEricaceaeImportConfigurator.NewInstance(source, cdmDestination); |
|
84 |
config.setClassificationUuid(classificationUuid); |
|
85 |
config.setDoTaxa(doTaxa); |
|
86 |
config.setCheck(check); |
|
87 |
config.setDefaultLanguageUuid(defaultLanguageUuid); |
|
88 |
config.setDoPrintKeys(doPrintKeys); |
|
89 |
config.setDbSchemaValidation(hbm2dll); |
|
90 |
|
|
91 |
|
|
92 |
CdmDefaultImport<EfloraImportConfigurator> myImport = new CdmDefaultImport<EfloraImportConfigurator>(); |
|
93 |
|
|
94 |
ICdmApplicationConfiguration app = myImport.getCdmAppController(); |
|
95 |
|
|
96 |
|
|
97 |
// |
|
98 |
if (includeEricaceae){ |
|
99 |
System.out.println("Start import from ("+ source.toString() + ") ..."); |
|
100 |
config.setSourceReference(getSourceReference(config.getSourceReferenceTitle())); |
|
101 |
myImport.invoke(config); |
|
102 |
System.out.println("End import from ("+ source.toString() + ")..."); |
|
103 |
} |
|
104 |
|
|
105 |
app = myImport.getCdmAppController(); |
|
106 |
|
|
107 |
TransactionStatus tx = app.startTransaction(); |
|
108 |
List<FeatureTree> featureTrees = app.getFeatureTreeService().list(null, null, null, null, null); |
|
109 |
for (FeatureTree tree :featureTrees){ |
|
110 |
if (tree.getClass().getSimpleName().equalsIgnoreCase("FeatureTree")){ |
|
111 |
moveChild(app, tree); |
|
112 |
} |
|
113 |
} |
|
114 |
app.commitTransaction(tx); |
|
115 |
|
|
116 |
|
|
117 |
|
|
118 |
} |
|
119 |
|
|
120 |
/** |
|
121 |
* @param app |
|
122 |
* @param tree |
|
123 |
*/ |
|
124 |
private void moveChild(ICdmApplicationConfiguration app, FeatureTree tree) { |
|
125 |
FeatureNode root = tree.getRoot(); |
|
126 |
int count = root.getChildCount(); |
|
127 |
FeatureNode lastChild = root.getChildAt(count - 1); |
|
128 |
root.removeChild(lastChild); |
|
129 |
root.addChild(lastChild, 1); |
|
130 |
app.getFeatureTreeService().saveOrUpdate(tree); |
|
131 |
} |
|
132 |
|
|
133 |
private Reference getSourceReference(String string) { |
|
134 |
Reference result = ReferenceFactory.newGeneric(); |
|
135 |
result.setTitleCache(string); |
|
136 |
return result; |
|
137 |
} |
|
138 |
|
|
139 |
|
|
140 |
|
|
141 |
/** |
|
142 |
* @param args |
|
143 |
*/ |
|
144 |
public static void main(String[] args) { |
|
145 |
EricaceaeTestUpdateActivator me = new EricaceaeTestUpdateActivator(); |
|
146 |
me.doImport(cdmDestination); |
|
147 |
} |
|
148 |
|
|
149 |
} |
cdm-eflora/src/main/java/eu/etaxonomy/cdm/app/testUpdate/EricaceaeTestUpdateActivator.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2007 EDIT |
|
3 |
* European Distributed Institute of Taxonomy |
|
4 |
* http://www.e-taxonomy.eu |
|
5 |
* |
|
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. |
|
8 |
*/ |
|
9 |
|
|
10 |
package eu.etaxonomy.cdm.app.testUpdate; |
|
11 |
|
|
12 |
import java.net.URI; |
|
13 |
import java.util.List; |
|
14 |
import java.util.UUID; |
|
15 |
|
|
16 |
import org.apache.log4j.Logger; |
|
17 |
import org.springframework.transaction.TransactionStatus; |
|
18 |
|
|
19 |
import eu.etaxonomy.cdm.api.application.ICdmApplicationConfiguration; |
|
20 |
import eu.etaxonomy.cdm.app.eflora.CdmDestinations; |
|
21 |
import eu.etaxonomy.cdm.app.eflora.EfloraSources; |
|
22 |
import eu.etaxonomy.cdm.common.monitor.DefaultProgressMonitor; |
|
23 |
import eu.etaxonomy.cdm.database.DbSchemaValidation; |
|
24 |
import eu.etaxonomy.cdm.database.ICdmDataSource; |
|
25 |
import eu.etaxonomy.cdm.database.update.CdmUpdater; |
|
26 |
import eu.etaxonomy.cdm.io.common.CdmDefaultImport; |
|
27 |
import eu.etaxonomy.cdm.io.common.IImportConfigurator.CHECK; |
|
28 |
import eu.etaxonomy.cdm.io.eflora.EfloraImportConfigurator; |
|
29 |
import eu.etaxonomy.cdm.io.eflora.centralAfrica.ericaceae.CentralAfricaEricaceaeImportConfigurator; |
|
30 |
import eu.etaxonomy.cdm.model.common.Language; |
|
31 |
import eu.etaxonomy.cdm.model.description.FeatureNode; |
|
32 |
import eu.etaxonomy.cdm.model.description.FeatureTree; |
|
33 |
import eu.etaxonomy.cdm.model.reference.Reference; |
|
34 |
import eu.etaxonomy.cdm.model.reference.ReferenceFactory; |
|
35 |
|
|
36 |
/** |
|
37 |
* @author a.mueller |
|
38 |
* @created 20.06.2008 |
|
39 |
* @version 1.0 |
|
40 |
*/ |
|
41 |
public class EricaceaeTestUpdateActivator { |
|
42 |
@SuppressWarnings("unused") |
|
43 |
private static final Logger logger = Logger.getLogger(EricaceaeTestUpdateActivator.class); |
|
44 |
|
|
45 |
//database validation status (create, update, validate ...) |
|
46 |
static DbSchemaValidation hbm2dll = DbSchemaValidation.VALIDATE; |
|
47 |
static final URI source = EfloraSources.ericacea_local(); |
|
48 |
|
|
49 |
|
|
50 |
// static final ICdmDataSource cdmDestination = CdmDestinations.cdm_test_andreasM2(); |
|
51 |
// static final ICdmDataSource cdmDestination = CdmDestinations.cdm_flora_central_africa_preview(); |
|
52 |
// static final ICdmDataSource cdmDestination = CdmDestinations.cdm_flora_central_africa_production(); |
|
53 |
static final ICdmDataSource cdmDestination = CdmDestinations.localH2(); |
|
54 |
// static final ICdmDataSource cdmDestination = CdmDestinations.cdm_local_postgres_CdmTest(); |
|
55 |
|
|
56 |
|
|
57 |
//feature tree uuid |
|
58 |
public static final UUID featureTreeUuid = UUID.fromString("051d35ee-22f1-42d8-be07-9e9bfec5bcf7"); |
|
59 |
|
|
60 |
public static UUID defaultLanguageUuid = Language.uuidEnglish; |
|
61 |
|
|
62 |
//classification |
|
63 |
static final UUID classificationUuid = UUID.fromString("10e5efcc-6e13-4abc-ad42-e0b46e50cbe7"); |
|
64 |
|
|
65 |
//check - import |
|
66 |
static final CHECK check = CHECK.IMPORT_WITHOUT_CHECK; |
|
67 |
|
|
68 |
static boolean doPrintKeys = false; |
|
69 |
|
|
70 |
//taxa |
|
71 |
static final boolean doTaxa = false; |
|
72 |
|
|
73 |
private boolean includeEricaceae = true; |
|
74 |
|
|
75 |
|
|
76 |
|
|
77 |
private void doImport(ICdmDataSource cdmDestination){ |
|
78 |
|
|
79 |
CdmUpdater updater = new CdmUpdater(); |
|
80 |
updater.updateToCurrentVersion(cdmDestination, DefaultProgressMonitor.NewInstance()); |
|
81 |
|
|
82 |
//make Source |
|
83 |
CentralAfricaEricaceaeImportConfigurator config= CentralAfricaEricaceaeImportConfigurator.NewInstance(source, cdmDestination); |
|
84 |
config.setClassificationUuid(classificationUuid); |
|
85 |
config.setDoTaxa(doTaxa); |
|
86 |
config.setCheck(check); |
|
87 |
config.setDefaultLanguageUuid(defaultLanguageUuid); |
|
88 |
config.setDoPrintKeys(doPrintKeys); |
|
89 |
config.setDbSchemaValidation(hbm2dll); |
|
90 |
|
|
91 |
|
|
92 |
CdmDefaultImport<EfloraImportConfigurator> myImport = new CdmDefaultImport<EfloraImportConfigurator>(); |
|
93 |
|
|
94 |
ICdmApplicationConfiguration app = myImport.getCdmAppController(); |
|
95 |
|
|
96 |
|
|
97 |
// |
|
98 |
if (includeEricaceae){ |
|
99 |
System.out.println("Start import from ("+ source.toString() + ") ..."); |
|
100 |
config.setSourceReference(getSourceReference(config.getSourceReferenceTitle())); |
|
101 |
myImport.invoke(config); |
|
102 |
System.out.println("End import from ("+ source.toString() + ")..."); |
|
103 |
} |
|
104 |
|
|
105 |
app = myImport.getCdmAppController(); |
|
106 |
|
|
107 |
TransactionStatus tx = app.startTransaction(); |
|
108 |
List<FeatureTree> featureTrees = app.getFeatureTreeService().list(null, null, null, null, null); |
|
109 |
for (FeatureTree tree :featureTrees){ |
|
110 |
if (tree.getClass().getSimpleName().equalsIgnoreCase("FeatureTree")){ |
|
111 |
moveChild(app, tree); |
|
112 |
} |
|
113 |
} |
|
114 |
app.commitTransaction(tx); |
|
115 |
|
|
116 |
|
|
117 |
|
|
118 |
} |
|
119 |
|
|
120 |
/** |
|
121 |
* @param app |
|
122 |
* @param tree |
|
123 |
*/ |
|
124 |
private void moveChild(ICdmApplicationConfiguration app, FeatureTree tree) { |
|
125 |
FeatureNode root = tree.getRoot(); |
|
126 |
int count = root.getChildCount(); |
|
127 |
FeatureNode lastChild = root.getChildAt(count - 1); |
|
128 |
root.removeChild(lastChild); |
|
129 |
root.addChild(lastChild, 1); |
|
130 |
app.getFeatureTreeService().saveOrUpdate(tree); |
|
131 |
} |
|
132 |
|
|
133 |
private Reference getSourceReference(String string) { |
|
134 |
Reference result = ReferenceFactory.newGeneric(); |
|
135 |
result.setTitleCache(string); |
|
136 |
return result; |
|
137 |
} |
|
138 |
|
|
139 |
|
|
140 |
|
|
141 |
/** |
|
142 |
* @param args |
|
143 |
*/ |
|
144 |
public static void main(String[] args) { |
|
145 |
EricaceaeTestUpdateActivator me = new EricaceaeTestUpdateActivator(); |
|
146 |
me.doImport(cdmDestination); |
|
147 |
} |
|
148 |
|
|
149 |
} |
Also available in: Unified diff
move EricaceaeTestUpdateActivator to cdm-eflora