Revision b9cdcc88
Added by Andreas Müller about 8 years ago
app-import/src/main/java/eu/etaxonomy/cdm/app/cuba/CubaActivator.java | ||
---|---|---|
14 | 14 |
|
15 | 15 |
import org.apache.log4j.Logger; |
16 | 16 |
|
17 |
import eu.etaxonomy.cdm.api.application.CdmApplicationController; |
|
17 | 18 |
import eu.etaxonomy.cdm.api.application.ICdmApplicationConfiguration; |
18 | 19 |
import eu.etaxonomy.cdm.api.service.ITermService; |
19 | 20 |
import eu.etaxonomy.cdm.app.common.CdmDestinations; |
... | ... | |
24 | 25 |
import eu.etaxonomy.cdm.io.cuba.CubaImportConfigurator; |
25 | 26 |
import eu.etaxonomy.cdm.io.cuba.CubaTransformer; |
26 | 27 |
import eu.etaxonomy.cdm.model.agent.Person; |
28 |
import eu.etaxonomy.cdm.model.agent.Team; |
|
27 | 29 |
import eu.etaxonomy.cdm.model.description.Feature; |
28 | 30 |
import eu.etaxonomy.cdm.model.description.FeatureNode; |
29 | 31 |
import eu.etaxonomy.cdm.model.description.FeatureTree; |
... | ... | |
41 | 43 |
static DbSchemaValidation hbm2dll = DbSchemaValidation.CREATE; |
42 | 44 |
|
43 | 45 |
// static final ICdmDataSource cdmDestination = CdmDestinations.localH2(); |
44 |
// static final ICdmDataSource cdmDestination = CdmDestinations.cdm_test_local_mysql_test();
|
|
45 |
static final ICdmDataSource cdmDestination = CdmDestinations.cdm_cuba_production(); |
|
46 |
static final ICdmDataSource cdmDestination = CdmDestinations.cdm_test_local_mysql_test(); |
|
47 |
// static final ICdmDataSource cdmDestination = CdmDestinations.cdm_cuba_production();
|
|
46 | 48 |
|
47 | 49 |
static boolean invers = false; |
48 | 50 |
|
... | ... | |
67 | 69 |
static boolean include = !invers; |
68 | 70 |
|
69 | 71 |
|
70 |
|
|
71 |
|
|
72 | 72 |
//feature tree uuid |
73 | 73 |
public static final UUID featureTreeUuid = UUID.fromString("dad6b9b5-693f-4367-a7aa-076cc9c99476"); |
74 | 74 |
|
75 | 75 |
//classification |
76 | 76 |
static final UUID classificationUuid = UUID.fromString("5de394de-9c76-4b97-b04d-71be31c7f44b"); |
77 |
private static final String classificationName = "Flora of Cuba";
|
|
77 |
private static final String classificationName = "Cuba Checklist";
|
|
78 | 78 |
|
79 |
static final String sourceReferenceTitle = "Cuba import";
|
|
79 |
static final String sourceReferenceTitle = "Cuba Checklist Word Documents";
|
|
80 | 80 |
|
81 | 81 |
//check - import |
82 | 82 |
static final CHECK check = CHECK.IMPORT_WITHOUT_CHECK; |
... | ... | |
106 | 106 |
|
107 | 107 |
//... |
108 | 108 |
if (doAsteraceae){ |
109 |
doSource(asteraceae(), config, myImport, doVocabularies); |
|
109 |
doSingleSource(asteraceae(), config, myImport, doVocabularies);
|
|
110 | 110 |
} |
111 | 111 |
if (doConvolvulaceae){ |
112 |
doSource(convolvulaceae(), config, myImport, doVocabularies); |
|
112 |
doSingleSource(convolvulaceae(), config, myImport, doVocabularies);
|
|
113 | 113 |
} |
114 | 114 |
if (doCyperaceae){ |
115 |
doSource(cyperaceae(), config, myImport, doVocabularies); |
|
115 |
doSingleSource(cyperaceae(), config, myImport, doVocabularies);
|
|
116 | 116 |
} |
117 | 117 |
if (doDicotA_C){ |
118 |
doSource(dicotA_C(), config, myImport, doVocabularies); |
|
118 |
doSingleSource(dicotA_C(), config, myImport, doVocabularies);
|
|
119 | 119 |
} |
120 | 120 |
if (doDicotD_M){ |
121 |
doSource(dicotD_M(), config, myImport, doVocabularies); |
|
121 |
doSingleSource(dicotD_M(), config, myImport, doVocabularies);
|
|
122 | 122 |
} |
123 | 123 |
if (doDicotN_Z){ |
124 |
doSource(dicotN_Z(), config, myImport, doVocabularies); |
|
124 |
doSingleSource(dicotN_Z(), config, myImport, doVocabularies);
|
|
125 | 125 |
} |
126 | 126 |
if (doEuphorbiaceae){ |
127 |
doSource(euphorbiaceae(), config, myImport, doVocabularies); |
|
127 |
doSingleSource(euphorbiaceae(), config, myImport, doVocabularies);
|
|
128 | 128 |
} |
129 | 129 |
if (doFabaceae){ |
130 |
doSource(fabaceae(), config, myImport, doVocabularies); |
|
130 |
doSingleSource(fabaceae(), config, myImport, doVocabularies);
|
|
131 | 131 |
} |
132 | 132 |
if (doGymnospermae){ |
133 |
doSource(gymnospermae(), config, myImport, doVocabularies); |
|
133 |
doSingleSource(gymnospermae(), config, myImport, doVocabularies);
|
|
134 | 134 |
} |
135 | 135 |
if (doLamVerbenaceae){ |
136 |
doSource(lamVerbenaceae(), config, myImport, doVocabularies); |
|
136 |
doSingleSource(lamVerbenaceae(), config, myImport, doVocabularies);
|
|
137 | 137 |
} |
138 | 138 |
if (doMalpighiaceae){ |
139 |
doSource(malpighiaceae(), config, myImport, doVocabularies); |
|
139 |
doSingleSource(malpighiaceae(), config, myImport, doVocabularies);
|
|
140 | 140 |
} |
141 | 141 |
if (doMelastomataceae){ |
142 |
doSource(melastomataceae(), config, myImport, doVocabularies); |
|
142 |
doSingleSource(melastomataceae(), config, myImport, doVocabularies);
|
|
143 | 143 |
} |
144 | 144 |
if (doMonocots){ |
145 |
doSource(monocots(), config, myImport, doVocabularies); |
|
145 |
doSingleSource(monocots(), config, myImport, doVocabularies);
|
|
146 | 146 |
} |
147 | 147 |
if (doMyrtaceae){ |
148 |
doSource(myrtaceae(), config, myImport, doVocabularies); |
|
148 |
doSingleSource(myrtaceae(), config, myImport, doVocabularies);
|
|
149 | 149 |
} |
150 | 150 |
if (doOrchidaceae){ |
151 |
doSource(orchidaceae(), config, myImport, doVocabularies); |
|
151 |
doSingleSource(orchidaceae(), config, myImport, doVocabularies);
|
|
152 | 152 |
} |
153 | 153 |
if (doRubiaceae){ |
154 |
doSource(rubiaceae(), config, myImport, doVocabularies); |
|
154 |
doSingleSource(rubiaceae(), config, myImport, doVocabularies);
|
|
155 | 155 |
} |
156 | 156 |
if (doUrticaceae){ |
157 |
doSource(urticaceae(), config, myImport, doVocabularies); |
|
157 |
doSingleSource(urticaceae(), config, myImport, doVocabularies);
|
|
158 | 158 |
} |
159 | 159 |
|
160 | 160 |
|
161 | 161 |
|
162 | 162 |
//deduplicate |
163 | 163 |
if (doDeduplicate){ |
164 |
ICdmApplicationConfiguration app = myImport.getCdmAppController(); |
|
164 |
logger.warn("Start deduplication ..."); |
|
165 |
|
|
166 |
ICdmApplicationConfiguration app = myImport.getCdmAppController(); |
|
167 |
if (app == null){ |
|
168 |
app = CdmApplicationController.NewInstance(cdmDestination, hbm2dll, false); |
|
169 |
} |
|
165 | 170 |
int count = app.getAgentService().deduplicate(Person.class, null, null); |
166 | 171 |
logger.warn("Deduplicated " + count + " persons."); |
167 |
// count = app.getAgentService().deduplicate(Team.class, null, null);
|
|
168 |
// logger.warn("Deduplicated " + count + " teams.");
|
|
172 |
count = app.getAgentService().deduplicate(Team.class, null, null); |
|
173 |
logger.warn("Deduplicated " + count + " teams."); |
|
169 | 174 |
count = app.getReferenceService().deduplicate(Reference.class, null, null); |
170 | 175 |
logger.warn("Deduplicated " + count + " references."); |
171 | 176 |
} |
172 | 177 |
|
173 |
|
|
174 | 178 |
System.exit(0); |
175 | 179 |
|
176 | 180 |
} |
... | ... | |
180 | 184 |
* @param config |
181 | 185 |
* @param myImport |
182 | 186 |
*/ |
183 |
private void doSource(URI source, CubaImportConfigurator config, |
|
187 |
private void doSingleSource(URI source, CubaImportConfigurator config,
|
|
184 | 188 |
CdmDefaultImport<CubaImportConfigurator> myImport, boolean doVocabularies) { |
185 | 189 |
config.setSource(source); |
186 |
String message = "Start import from ("+ source.toString() + ") ..."; |
|
190 |
String fileName = source.toString(); |
|
191 |
fileName = fileName.substring(fileName.lastIndexOf("/") + 1 ); |
|
192 |
|
|
193 |
String message = "Start import from ("+ fileName + ") ..."; |
|
187 | 194 |
System.out.println(message); |
188 | 195 |
logger.warn(message); |
189 |
config.setSourceReference(getSourceReference(sourceReferenceTitle));
|
|
196 |
config.setSourceReference(getSourceReference(fileName));
|
|
190 | 197 |
config.setDoVocabularies(doVocabularies); |
191 | 198 |
myImport.invoke(config); |
192 | 199 |
|
... | ... | |
198 | 205 |
System.out.println("End import from ("+ source.toString() + ")..."); |
199 | 206 |
} |
200 | 207 |
|
208 |
private final Reference<?> inRef = ReferenceFactory.newGeneric(); |
|
201 | 209 |
private Reference<?> getSourceReference(String string) { |
202 | 210 |
Reference<?> result = ReferenceFactory.newGeneric(); |
203 | 211 |
result.setTitleCache(string, true); |
212 |
result.setInReference(inRef); |
|
213 |
inRef.setTitleCache(sourceReferenceTitle, true); |
|
204 | 214 |
return result; |
205 | 215 |
} |
206 | 216 |
|
Also available in: Unified diff
Latest changes to Cuba import