\r
package eu.etaxonomy.cdm.app.common;\r
\r
-import java.util.HashSet;\r
-import java.util.List;\r
-import java.util.Set;\r
+import java.net.URI;\r
+import java.util.UUID;\r
\r
import org.apache.log4j.Logger;\r
+import org.springframework.core.io.ClassPathResource;\r
+import org.springframework.transaction.TransactionStatus;\r
\r
import eu.etaxonomy.cdm.api.application.CdmApplicationController;\r
-import eu.etaxonomy.cdm.api.service.config.ITaxonServiceConfigurator;\r
-import eu.etaxonomy.cdm.api.service.config.TaxonServiceConfiguratorImpl;\r
-import eu.etaxonomy.cdm.api.service.pager.Pager;\r
+import eu.etaxonomy.cdm.common.monitor.DefaultProgressMonitor;\r
+import eu.etaxonomy.cdm.common.monitor.IProgressMonitor;\r
import eu.etaxonomy.cdm.database.DbSchemaValidation;\r
import eu.etaxonomy.cdm.database.ICdmDataSource;\r
+import eu.etaxonomy.cdm.io.common.CdmDefaultImport;\r
import eu.etaxonomy.cdm.io.common.IImportConfigurator.CHECK;\r
-import eu.etaxonomy.cdm.model.common.IdentifiableEntity;\r
-import eu.etaxonomy.cdm.model.location.NamedArea;\r
-import eu.etaxonomy.cdm.model.location.TdwgArea;\r
+import eu.etaxonomy.cdm.io.sdd.in.SDDImportConfigurator;\r
+import eu.etaxonomy.cdm.model.description.CategoricalData;\r
+import eu.etaxonomy.cdm.model.description.Modifier;\r
+import eu.etaxonomy.cdm.model.description.State;\r
+import eu.etaxonomy.cdm.model.description.StateData;\r
import eu.etaxonomy.cdm.model.name.NomenclaturalCode;\r
-import eu.etaxonomy.cdm.persistence.query.MatchMode;\r
\r
/**\r
* @author a.babadshanjan\r
* @created 12.05.2009\r
*/\r
public class TestActivator {\r
+ @SuppressWarnings("unused")\r
private static final Logger logger = Logger.getLogger(TestActivator.class);\r
\r
//static final Source faunaEuropaeaSource = FaunaEuropaeaSources.faunEu();\r
- static final ICdmDataSource cdmDestination = CdmDestinations.cdm_edit_cichorieae_preview_B();\r
+ static final ICdmDataSource cdmDestination = CdmDestinations.cdm_test_local_mysql();\r
+// static final ICdmDataSource cdmDestination = CdmDestinations.localH2();\r
+// static final ICdmDataSource cdmDestination = CdmDestinations.cdm_flora_central_africa_production();\r
+// static final ICdmDataSource cdmDestination = CdmDestinations.cdm_edit_cichorieae_preview();\r
+ \r
\r
static final int limitSave = 2000;\r
\r
-// static final CHECK check = CHECK.CHECK_AND_IMPORT;\r
static final CHECK check = CHECK.IMPORT_WITHOUT_CHECK;\r
- static DbSchemaValidation dbSchemaValidation = DbSchemaValidation.VALIDATE;\r
+// static final CHECK check = CHECK.CHECK_ONLY;\r
+// static DbSchemaValidation dbSchemaValidation = DbSchemaValidation.NONE;\r
// static DbSchemaValidation dbSchemaValidation = DbSchemaValidation.UPDATE;\r
-// static DbSchemaValidation dbSchemaValidation = DbSchemaValidation.VALIDATE;\r
- static final NomenclaturalCode nomenclaturalCode = NomenclaturalCode.ICZN;\r
+ static DbSchemaValidation dbSchemaValidation = DbSchemaValidation.VALIDATE;\r
+ static final NomenclaturalCode nomenclaturalCode = NomenclaturalCode.ICBN;\r
\r
\r
\r
ICdmDataSource destination = cdmDestination;\r
\r
CdmApplicationController app;\r
- app = CdmApplicationController.NewInstance(destination, dbSchemaValidation);\r
\r
+// applicationEventMulticaster\r
+// app = CdmIoApplicationController.NewInstance(destination, dbSchemaValidation);\r
+ \r
+ IProgressMonitor progressMonitor = DefaultProgressMonitor.NewInstance();\r
+ String resourcePath= "/eu/etaxonomy/cdm/appimportTestApplicationContext.xml";\r
+ ClassPathResource resource = new ClassPathResource(resourcePath);\r
+// ApplicationListener<?> listener = new AppImportApplicationListener();\r
+// List<ApplicationListener> listeners = new ArrayList<ApplicationListener>();\r
+// listeners.add(listener);\r
+// app = CdmApplicationController.NewInstance(resource, destination, dbSchemaValidation, false, progressMonitor, listeners);\r
+ app = CdmApplicationController.NewInstance(resource, destination, dbSchemaValidation, false, progressMonitor);\r
+ \r
+ TransactionStatus tx = app.startTransaction();\r
+ State state = (State)app.getTermService().find(UUID.fromString("881b9c80-626d-47a6-b308-a63ee5f4178f"));\r
+ Modifier modifier = (Modifier)app.getTermService().find(UUID.fromString("efc38dad-205c-4028-ad9d-ae509a14b37a"));\r
+ CategoricalData cd = CategoricalData.NewInstance();\r
+ StateData stateData = StateData.NewInstance();\r
+ stateData.setState(state);\r
+ stateData.addModifier(modifier);\r
+ \r
+ StateData stateData2 = StateData.NewInstance();\r
+ stateData2.setState(state);\r
+ stateData2.addModifier(modifier);\r
\r
- app.changeDataSource(destination);\r
- ICdmDataSource cdmDestination = CdmDestinations.cdm_edit_cichorieae_preview_B();\r
- app.changeDataSource(cdmDestination);\r
- ITaxonServiceConfigurator<?> conf = TaxonServiceConfiguratorImpl.NewInstance();\r
- conf.setDoSynonyms(true);\r
- conf.setDoTaxa(true);\r
- conf.setMatchMode(MatchMode.BEGINNING);\r
- conf.setTitleSearchString("L*");\r
- conf.setPageNumber(0);\r
- conf.setPageSize(50);\r
- Set<NamedArea> areas = new HashSet<NamedArea>();\r
- areas.add(TdwgArea.getAreaByTdwgAbbreviation("GER"));\r
- //conf.setNamedAreas(areas);\r
+ cd.addState(stateData2);\r
\r
- Pager<IdentifiableEntity> taxaAndSyn = app.getTaxonService().findTaxaAndNames(conf);\r
- List<IdentifiableEntity> taxList = taxaAndSyn.getRecords();\r
+ app.getDescriptionService().saveDescriptionElement(cd);\r
+ System.out.println("Saved");\r
\r
- for (IdentifiableEntity<?> ent: taxList){\r
- \r
- System.err.println(ent.getTitleCache());\r
+ app.commitTransaction(tx);\r
+ \r
+ URI uri = URI.create("file:///C:/localCopy/Data/xper/Cichorieae-DA2.sdd.xml");\r
+ SDDImportConfigurator configurator = SDDImportConfigurator.NewInstance(uri, destination);\r
+ CdmDefaultImport<SDDImportConfigurator> myImport = new CdmDefaultImport<SDDImportConfigurator>();\r
+\r
+ myImport.setCdmAppController(app);\r
+ \r
+ boolean r = myImport.invoke(configurator);\r
+ System.out.println(r);\r
+\r
+ if (true){\r
+ return;\r
}\r
\r
+// app.changeDataSource(destination);\r
+// ICdmDataSource cdmDestination = CdmDestinations.cdm_edit_cichorieae_preview();\r
+// app.changeDataSource(cdmDestination);\r
+// ITaxonServiceConfigurator<?> conf = TaxonServiceConfiguratorImpl.NewInstance();\r
+// conf.setDoSynonyms(true);\r
+// conf.setDoTaxa(true);\r
+// conf.setMatchMode(MatchMode.BEGINNING);\r
+// conf.setTitleSearchString("L*");\r
+// conf.setPageNumber(0);\r
+// conf.setPageSize(50);\r
+// Set<NamedArea> areas = new HashSet<NamedArea>();\r
+// areas.add(TdwgArea.getAreaByTdwgAbbreviation("GER"));\r
+// //conf.setNamedAreas(areas);\r
+// \r
+// Pager<IdentifiableEntity> taxaAndSyn = app.getTaxonService().findTaxaAndNames(conf);\r
+// List<IdentifiableEntity> taxList = taxaAndSyn.getRecords();\r
+// \r
+// for (IdentifiableEntity<?> ent: taxList){\r
+// \r
+// System.err.println(ent.getTitleCache());\r
+// }\r
+ \r
\r
\r
System.out.println("End importing Fauna Europaea data");\r