Revision 9e57c1e9
Added by Niels Hoffmann about 16 years ago
app-import/src/main/java/eu/etaxonomy/cdm/app/berlinModelImport/CichorieaeActivator.java | ||
---|---|---|
9 | 9 |
|
10 | 10 |
package eu.etaxonomy.cdm.app.berlinModelImport; |
11 | 11 |
|
12 |
import java.io.File; |
|
13 |
import java.net.URL; |
|
12 | 14 |
import java.util.UUID; |
13 | 15 |
|
14 | 16 |
import org.apache.log4j.Logger; |
15 | 17 |
|
18 |
import eu.etaxonomy.cdm.api.application.CdmApplicationController; |
|
16 | 19 |
import eu.etaxonomy.cdm.app.common.CdmDestinations; |
17 | 20 |
import eu.etaxonomy.cdm.database.DbSchemaValidation; |
18 | 21 |
import eu.etaxonomy.cdm.database.ICdmDataSource; |
19 | 22 |
import eu.etaxonomy.cdm.io.berlinModel.BerlinModelImportConfigurator; |
20 |
import eu.etaxonomy.cdm.io.common.IImportConfigurator.CHECK; |
|
21 |
import eu.etaxonomy.cdm.io.common.IImportConfigurator.DO_REFERENCES; |
|
22 | 23 |
import eu.etaxonomy.cdm.io.common.CdmDefaultImport; |
23 | 24 |
import eu.etaxonomy.cdm.io.common.Source; |
25 |
import eu.etaxonomy.cdm.io.common.IImportConfigurator.CHECK; |
|
26 |
import eu.etaxonomy.cdm.io.common.IImportConfigurator.DO_REFERENCES; |
|
24 | 27 |
import eu.etaxonomy.cdm.io.tcs.TcsImportConfigurator; |
28 |
import eu.etaxonomy.cdm.model.common.ISourceable; |
|
29 |
import eu.etaxonomy.cdm.model.description.FeatureTree; |
|
25 | 30 |
import eu.etaxonomy.cdm.model.name.NomenclaturalCode; |
31 |
import eu.etaxonomy.cdm.model.name.ZoologicalName; |
|
26 | 32 |
|
27 | 33 |
|
28 | 34 |
/** |
... | ... | |
40 | 46 |
//database validation status (create, update, validate ...) |
41 | 47 |
static DbSchemaValidation hbm2dll = DbSchemaValidation.CREATE; |
42 | 48 |
static final Source berlinModelSource = BerlinModelSources.EDIT_CICHORIEAE(); |
43 |
static final ICdmDataSource cdmDestination = CdmDestinations.cdm_test_anahit(); |
|
44 |
|
|
49 |
static final ICdmDataSource cdmDestination = CdmDestinations.cdm_test_niels2(); |
|
45 | 50 |
static final UUID secUuid = UUID.fromString("6924c75d-e0d0-4a6d-afb7-3dd8c71195ca"); |
46 | 51 |
static final int sourceSecId = 7800000; |
47 | 52 |
|
53 |
static final UUID featureTreeUuid = UUID.fromString("ae9615b8-bc60-4ed0-ad96-897f9226d568"); |
|
54 |
static final Object[] featureKeyList = new Integer[]{5,10,11,12}; |
|
55 |
|
|
56 |
static final String mediaUrlString = "http://wp5.e-taxonomy.eu/dataportal/cichorieae/media/protolog/"; |
|
57 |
static final File mediaPath = new File("/Volumes/protolog/protolog/"); |
|
58 |
|
|
48 | 59 |
//check - import |
49 |
static final CHECK check = CHECK.CHECK_AND_IMPORT;
|
|
60 |
static final CHECK check = CHECK.IMPORT_WITHOUT_CHECK;
|
|
50 | 61 |
|
51 | 62 |
|
52 | 63 |
//NomeclaturalCode |
... | ... | |
55 | 66 |
//ignore null |
56 | 67 |
static final boolean ignoreNull = true; |
57 | 68 |
|
58 |
//// **************** ALL ********************* |
|
59 |
|
|
69 |
// **************** ALL ********************* |
|
60 | 70 |
//authors |
61 | 71 |
static final boolean doAuthors = true; |
62 | 72 |
//references |
... | ... | |
66 | 76 |
static final boolean doRelNames = true; |
67 | 77 |
static final boolean doNameStatus = true; |
68 | 78 |
static final boolean doTypes = true; |
69 |
static final boolean doNameFacts = false;
|
|
79 |
static final boolean doNameFacts = true;
|
|
70 | 80 |
|
71 | 81 |
//taxa |
72 | 82 |
static final boolean doTaxa = true; |
... | ... | |
75 | 85 |
static final boolean doOccurences = false; |
76 | 86 |
|
77 | 87 |
|
78 |
// **************** SELECTED ********************* |
|
88 |
// **************** SELECTED *********************
|
|
79 | 89 |
// //authors |
80 | 90 |
// static final boolean doAuthors = false; |
81 | 91 |
// //references |
... | ... | |
125 | 135 |
bmImportConfigurator.setDoOccurrence(doOccurences); |
126 | 136 |
bmImportConfigurator.setDbSchemaValidation(hbm2dll); |
127 | 137 |
|
138 |
// mediaResourceLocations |
|
139 |
if ( mediaPath.exists() && mediaPath.isDirectory()){ |
|
140 |
bmImportConfigurator.setMediaUrl(mediaUrlString); |
|
141 |
bmImportConfigurator.setMediaPath(mediaPath); |
|
142 |
}else{ |
|
143 |
logger.warn("Could not configure mediaResourceLocations"); |
|
144 |
} |
|
145 |
|
|
146 |
|
|
128 | 147 |
bmImportConfigurator.setCheck(check); |
129 | 148 |
|
130 | 149 |
// invoke import |
131 | 150 |
CdmDefaultImport<TcsImportConfigurator> bmImport = new CdmDefaultImport<TcsImportConfigurator>(); |
132 | 151 |
bmImport.invoke(bmImportConfigurator); |
133 | 152 |
|
153 |
if (bmImportConfigurator.getCheck().equals(CHECK.CHECK_AND_IMPORT) || bmImportConfigurator.getCheck().equals(CHECK.IMPORT_WITHOUT_CHECK) ){ |
|
154 |
CdmApplicationController app = bmImportConfigurator.getCdmAppController(); |
|
155 |
ISourceable obj = app.getCommonService().getSourcedObjectByIdInSource(ZoologicalName.class, "1000027", null); |
|
156 |
logger.info(obj); |
|
157 |
|
|
158 |
//make feature tree |
|
159 |
FeatureTree tree = TreeCreator.flatTree(featureTreeUuid, bmImportConfigurator.getFeatureMap(), featureKeyList); |
|
160 |
app.getDescriptionService().saveFeatureTree(tree); |
|
161 |
} |
|
162 |
|
|
134 | 163 |
System.out.println("End import from BerlinModel ("+ source.getDatabase() + ")..."); |
135 | 164 |
} |
136 | 165 |
|
Also available in: Unified diff
Default feature tree added. Parameterized mediaPaths.