\r
import org.apache.log4j.Logger;\r
\r
+import eu.etaxonomy.cdm.api.application.ICdmApplicationConfiguration;\r
import eu.etaxonomy.cdm.app.common.CdmDestinations;\r
import eu.etaxonomy.cdm.database.DbSchemaValidation;\r
import eu.etaxonomy.cdm.database.ICdmDataSource;\r
+import eu.etaxonomy.cdm.io.algaterra.AlgaTerraImportConfigurator;\r
import eu.etaxonomy.cdm.io.berlinModel.in.BerlinModelImportConfigurator;\r
import eu.etaxonomy.cdm.io.common.CdmDefaultImport;\r
-import eu.etaxonomy.cdm.io.common.Source;\r
import eu.etaxonomy.cdm.io.common.IImportConfigurator.CHECK;\r
import eu.etaxonomy.cdm.io.common.IImportConfigurator.DO_REFERENCES;\r
+import eu.etaxonomy.cdm.io.common.IImportConfigurator.EDITOR;\r
+import eu.etaxonomy.cdm.io.common.Source;\r
+import eu.etaxonomy.cdm.model.description.Feature;\r
+import eu.etaxonomy.cdm.model.description.FeatureNode;\r
+import eu.etaxonomy.cdm.model.description.FeatureTree;\r
import eu.etaxonomy.cdm.model.name.NomenclaturalCode;\r
\r
\r
//database validation status (create, update, validate ...)\r
static DbSchemaValidation hbm2dll = DbSchemaValidation.CREATE;\r
static final Source berlinModelSource = BerlinModelSources.AlgaTerra();\r
- static final ICdmDataSource cdmDestination = CdmDestinations.localH2();\r
- static final UUID treeUuid = UUID.fromString("d03ef02a-f226-4cb1-bdb4-f6c154f08a34");\r
+// static final ICdmDataSource cdmDestination = CdmDestinations.localH2();\r
+// static final ICdmDataSource cdmDestination = CdmDestinations.cdm_algaterra_preview();\r
+ static final ICdmDataSource cdmDestination = CdmDestinations.cdm_test_local_mysql();\r
+ \r
+ \r
+ static final UUID treeUuid = UUID.fromString("1f617402-78dc-4bf1-ac77-d260600a8879");\r
static final int sourceSecId = 7331;\r
+ static final UUID sourceRefUuid = UUID.fromString("7e1a2500-93a5-40c2-ba34-0213d7822379");\r
\r
- static final UUID featureTreeUuid = UUID.fromString("ae9615b8-bc60-4ed0-ad96-897f9226d568");\r
+ static final UUID featureTreeUuid = UUID.fromString("a970168a-36fd-4c7c-931e-87214a965c14");\r
static final Object[] featureKeyList = new Integer[]{7,201,202,203,204,205,206,207}; \r
\r
//check - import\r
- static final CHECK check = CHECK.CHECK_AND_IMPORT;\r
+ static final CHECK check = CHECK.IMPORT_WITHOUT_CHECK;\r
\r
+ private boolean ignoreNull = true;\r
+ \r
+ private boolean includeFlatClassifications = true;\r
+ \r
+ private EDITOR editor = EDITOR.EDITOR_AS_EDITOR;\r
\r
//NomeclaturalCode\r
static final NomenclaturalCode nomenclaturalCode = NomenclaturalCode.ICBN;\r
-\r
+ \r
+ static String factFilter = " factCategoryFk NOT IN (7, 202 ) ";\r
+ \r
+ \r
// ****************** ALL *****************************************\r
\r
//authors\r
static final boolean doTaxonNames = true;\r
static final boolean doRelNames = true;\r
static final boolean doNameStatus = true;\r
- static final boolean doTypes = false; \r
- static final boolean doNameFacts = false; \r
+ static final boolean doTypes = true; \r
\r
//taxa\r
static final boolean doTaxa = true;\r
static final boolean doRelTaxa = true;\r
static final boolean doFacts = true;\r
- static final boolean doOccurences = false;\r
- static final boolean doCommonNames = false;\r
+ \r
+ //alga terra specific\r
+ static final boolean ecoFacts = true;\r
+ static final boolean doImages = true;\r
\r
// ************************ NONE **************************************** //\r
\r
// //references\r
// static final DO_REFERENCES doReferences = DO_REFERENCES.NONE;\r
// //names\r
-// static final boolean doTaxonNames = true;\r
+// static final boolean doTaxonNames = false;\r
// static final boolean doRelNames = false;\r
// static final boolean doNameStatus = false;\r
-// static final boolean doTypes = false;\r
+// static final boolean doTypes = true;\r
// static final boolean doNameFacts = false;\r
// \r
// //taxa\r
// static final boolean doTaxa = false;\r
// static final boolean doRelTaxa = false;\r
-// static final boolean doFacts = true;\r
-// static final boolean doOccurences = false;\r
- \r
+// static final boolean doFacts = false;\r
+// \r
+// //alga terra specific\r
+// static final boolean ecoFacts = true;\r
+// static final boolean doImages = true;\r
\r
\r
- /**\r
- * @param args\r
- */\r
- public static void main(String[] args) {\r
+ public void invoke(String[] args){\r
System.out.println("Start import from BerlinModel("+ berlinModelSource.getDatabase() + ") ...");\r
logger.debug("Start");\r
//make BerlinModel Source\r
Source source = berlinModelSource;\r
ICdmDataSource destination = CdmDestinations.chooseDestination(args) != null ? CdmDestinations.chooseDestination(args) : cdmDestination;\r
\r
- BerlinModelImportConfigurator bmImportConfigurator = BerlinModelImportConfigurator.NewInstance(source, destination);\r
+ AlgaTerraImportConfigurator config = AlgaTerraImportConfigurator.NewInstance(source, destination);\r
\r
- bmImportConfigurator.setTaxonomicTreeUuid(treeUuid);\r
- bmImportConfigurator.setSourceSecId(sourceSecId);\r
- bmImportConfigurator.setNomenclaturalCode(nomenclaturalCode);\r
+ config.setClassificationUuid(treeUuid);\r
+ config.setSourceSecId(sourceSecId);\r
+ config.setNomenclaturalCode(nomenclaturalCode);\r
\r
- bmImportConfigurator.setDoAuthors(doAuthors);\r
- bmImportConfigurator.setDoReferences(doReferences);\r
- bmImportConfigurator.setDoTaxonNames(doTaxonNames);\r
- bmImportConfigurator.setDoRelNames(doRelNames);\r
- bmImportConfigurator.setDoNameStatus(doNameStatus);\r
- bmImportConfigurator.setDoTypes(doTypes);\r
- bmImportConfigurator.setDoNameFacts(doNameFacts);\r
+ config.setDoAuthors(doAuthors);\r
+ config.setDoReferences(doReferences);\r
+ config.setDoTaxonNames(doTaxonNames);\r
+ config.setDoRelNames(doRelNames);\r
+ config.setDoNameStatus(doNameStatus);\r
+ config.setDoTypes(doTypes);\r
+ \r
+ config.setDoTaxa(doTaxa);\r
+ config.setDoRelTaxa(doRelTaxa);\r
+ config.setDoFacts(doFacts);\r
+ config.setDoEcoFacts(ecoFacts);\r
+ config.setDoImages(doImages);\r
\r
- bmImportConfigurator.setDoTaxa(doTaxa);\r
- bmImportConfigurator.setDoRelTaxa(doRelTaxa);\r
- bmImportConfigurator.setDoFacts(doFacts);\r
- bmImportConfigurator.setDoOccurrence(doOccurences);\r
- bmImportConfigurator.setDoCommonNames(doCommonNames);\r
+ config.setSourceRefUuid(sourceRefUuid);\r
+ config.setIgnoreNull(ignoreNull);\r
\r
- bmImportConfigurator.setDbSchemaValidation(hbm2dll);\r
+ config.setIncludeFlatClassifications(includeFlatClassifications);\r
+ config.setFactFilter(factFilter);\r
+ \r
+ config.setDbSchemaValidation(hbm2dll);\r
\r
- bmImportConfigurator.setCheck(check);\r
+ config.setCheck(check);\r
+ config.setEditor(editor);\r
\r
// invoke import\r
CdmDefaultImport<BerlinModelImportConfigurator> bmImport = new CdmDefaultImport<BerlinModelImportConfigurator>();\r
- bmImport.invoke(bmImportConfigurator);\r
+ bmImport.invoke(config);\r
\r
+ if (doFacts && (config.getCheck().equals(CHECK.CHECK_AND_IMPORT) || config.getCheck().equals(CHECK.IMPORT_WITHOUT_CHECK) ) ){\r
+ ICdmApplicationConfiguration app = bmImport.getCdmAppController();\r
+ \r
+ //make feature tree\r
+ FeatureTree tree = TreeCreator.flatTree(featureTreeUuid, config.getFeatureMap(), featureKeyList);\r
+ FeatureNode imageNode = FeatureNode.NewInstance(Feature.IMAGE());\r
+ tree.getRoot().addChild(imageNode);\r
+ FeatureNode distributionNode = FeatureNode.NewInstance(Feature.DISTRIBUTION());\r
+ tree.getRoot().addChild(distributionNode, 2); \r
+ app.getFeatureTreeService().saveOrUpdate(tree);\r
+ }\r
+ \r
\r
System.out.println("End import from BerlinModel ("+ source.getDatabase() + ")...");\r
}\r
+ \r
+ \r
+ /**\r
+ * @param args\r
+ */\r
+ public static void main(String[] args) {\r
+ AlgaTerraActivator activator = new AlgaTerraActivator();\r
+ activator.invoke(args);\r
+ }\r
\r
}\r