-// $Id$\r
/**\r
* Copyright (C) 2009 EDIT\r
-* European Distributed Institute of Taxonomy \r
+* European Distributed Institute of Taxonomy\r
* http://www.e-taxonomy.eu\r
-* \r
+*\r
* The contents of this file are subject to the Mozilla Public License Version 1.1\r
* See LICENSE.TXT at the top of this package for the full license terms.\r
*/\r
\r
import org.apache.log4j.Logger;\r
\r
-import eu.etaxonomy.cdm.api.application.ICdmApplicationDefaultConfiguration;\r
+import eu.etaxonomy.cdm.api.application.ICdmRepository;\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.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.ImportResult;\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
+import eu.etaxonomy.cdm.model.term.TermTree;\r
\r
/**\r
* @author a.mueller\r
- * @date 03.12.2010\r
+ * @since 03.12.2010\r
*\r
*/\r
public class IldisActivator {\r
static DbSchemaValidation hbm2dll = DbSchemaValidation.CREATE;\r
static final Source berlinModelSource = BerlinModelSources.ILDIS();\r
// static final ICdmDataSource cdmDestination = CdmDestinations.cdm_ildis_dev();\r
- static final ICdmDataSource cdmDestination = CdmDestinations.cdm_test_local_mysql();\r
- \r
+ static final ICdmDataSource cdmDestination = CdmDestinations.cdm_local_test_mysql();\r
+\r
\r
static final UUID secUuid = UUID.fromString("a7f29364-ce98-4c1d-ad2e-3d889cc5885c");\r
static final UUID classificationUuid = UUID.fromString("c7a4e447-ca1e-46e9-adb9-037dab039ccc");\r
static final int sourceSecId = 8500000;\r
- \r
+\r
static final UUID featureTreeUuid = UUID.fromString("9703afa5-3104-4b3b-b498-f549c0df2d2a");\r
- static final Object[] featureKeyList = new Integer[]{1, 43, 31, 4, 12, 98, 253, 301, 302, 303}; \r
- \r
+ static final Object[] featureKeyList = new Integer[]{1, 43, 31, 4, 12, 98, 253, 301, 302, 303};\r
+\r
// set to zero for unlimited nameFacts\r
static final int recordsPerTransaction = 2000;\r
- \r
+\r
//check - import\r
static final CHECK check = CHECK.CHECK_AND_IMPORT;\r
\r
//editor - import\r
static final EDITOR editor = EDITOR.EDITOR_AS_EDITOR;\r
- \r
- //NomeclaturalCode\r
+\r
+ //NomenclaturalCode\r
static final NomenclaturalCode nomenclaturalCode = NomenclaturalCode.ICNAFP;\r
\r
//ignore null\r
static final boolean ignoreNull = true;\r
- \r
-// **************** ALL ********************* \r
+\r
+// **************** ALL *********************\r
\r
static final boolean doUser = true;\r
//authors\r
static final boolean doNameStatus = true;\r
static final boolean doTypes = true;\r
static final boolean doNameFacts = true;\r
- \r
+\r
//taxa\r
static final boolean doTaxa = true;\r
static final boolean doRelTaxa = true;\r
//etc.\r
static final boolean doMarker = true;\r
\r
- \r
+\r
// **************** SELECTED *********************\r
//\r
// static final boolean doUser = false;\r
// static final boolean doNameStatus = false;\r
// static final boolean doTypes = false;\r
// static final boolean doNameFacts = false;\r
-// \r
-// //taxa \r
+//\r
+// //taxa\r
// static final boolean doTaxa = false;\r
// static final boolean doRelTaxa = false;\r
// static final boolean doCommonNames = false;\r
// static final boolean doFacts = false;\r
// static final boolean doOccurences = false;\r
-// \r
+//\r
// //etc.\r
// static final boolean doMarker = false;\r
- \r
- \r
- private boolean doInvoke(ICdmDataSource destination){\r
- boolean success = true;\r
+\r
+\r
+ private ImportResult doInvoke(ICdmDataSource destination){\r
+ ImportResult success;\r
Source source = berlinModelSource;\r
- \r
+\r
BerlinModelImportConfigurator bmImportConfigurator = BerlinModelImportConfigurator.NewInstance(source, destination);\r
- \r
+\r
bmImportConfigurator.setClassificationUuid(classificationUuid);\r
bmImportConfigurator.setSourceSecId(sourceSecId);\r
- \r
+\r
bmImportConfigurator.setNomenclaturalCode(nomenclaturalCode);\r
\r
bmImportConfigurator.setIgnoreNull(ignoreNull);\r
bmImportConfigurator.setDoNameStatus(doNameStatus);\r
bmImportConfigurator.setDoTypes(doTypes);\r
bmImportConfigurator.setDoNameFacts(doNameFacts);\r
- \r
+\r
bmImportConfigurator.setDoTaxa(doTaxa);\r
bmImportConfigurator.setDoRelTaxa(doRelTaxa);\r
bmImportConfigurator.setDoFacts(doFacts);\r
bmImportConfigurator.setDoOccurrence(doOccurences);\r
bmImportConfigurator.setDoCommonNames(doCommonNames);\r
- \r
+\r
bmImportConfigurator.setDoMarker(doMarker);\r
bmImportConfigurator.setDoUser(doUser);\r
bmImportConfigurator.setEditor(editor);\r
bmImportConfigurator.setDbSchemaValidation(hbm2dll);\r
bmImportConfigurator.setRecordsPerTransaction(recordsPerTransaction);\r
- \r
+\r
bmImportConfigurator.setCheck(check);\r
bmImportConfigurator.setEditor(editor);\r
- \r
+\r
// invoke import\r
CdmDefaultImport<BerlinModelImportConfigurator> bmImport = new CdmDefaultImport<BerlinModelImportConfigurator>();\r
- success &= bmImport.invoke(bmImportConfigurator);\r
- \r
+ success = bmImport.invoke(bmImportConfigurator);\r
+\r
if (doFacts && (bmImportConfigurator.getCheck().equals(CHECK.CHECK_AND_IMPORT) || bmImportConfigurator.getCheck().equals(CHECK.IMPORT_WITHOUT_CHECK) ) ){\r
- ICdmApplicationDefaultConfiguration app = bmImport.getCdmAppController();\r
- \r
+ ICdmRepository app = bmImport.getCdmAppController();\r
+\r
//make feature tree\r
- FeatureTree tree = TreeCreator.flatTree(featureTreeUuid, bmImportConfigurator.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
+ TermTree<Feature> tree = TreeCreator.flatTree(featureTreeUuid, bmImportConfigurator.getFeatureMap(), featureKeyList);\r
+ tree.getRoot().addChild(Feature.IMAGE());\r
+ tree.getRoot().addChild(Feature.DISTRIBUTION(), 2);\r
app.getFeatureTreeService().saveOrUpdate(tree);\r
}\r
- \r
+\r
System.out.println("End import from BerlinModel ("+ source.getDatabase() + ")...");\r
\r
return success;\r
- \r
+\r
}\r
- \r
+\r
/**\r
* @param args\r
*/\r
public static void main(String[] args) {\r
ICdmDataSource destination = CdmDestinations.chooseDestination(args) != null ? CdmDestinations.chooseDestination(args) : cdmDestination;\r
- \r
+\r
System.out.println("Start import from BerlinModel("+ berlinModelSource.getDatabase() + ") to " + destination.getDatabase() + " ...");\r
IldisActivator me = new IldisActivator();\r
me.doInvoke(destination);\r
- \r
+\r
}\r
}\r