\r
package eu.etaxonomy.cdm.app.common;\r
\r
-import java.util.ArrayList;\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.transaction.TransactionStatus;\r
\r
import eu.etaxonomy.cdm.api.application.CdmApplicationController;\r
-import eu.etaxonomy.cdm.api.application.CdmIoApplicationController;\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.description.Distribution;\r
-import eu.etaxonomy.cdm.model.description.PresenceTerm;\r
-import eu.etaxonomy.cdm.model.description.TaxonDescription;\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.model.taxon.Taxon;\r
-import eu.etaxonomy.cdm.model.taxon.TaxonBase;\r
-import eu.etaxonomy.cdm.model.taxon.TaxonNode;\r
-import eu.etaxonomy.cdm.persistence.query.MatchMode;\r
\r
/**\r
* @author a.babadshanjan\r
private static final Logger logger = Logger.getLogger(TestActivator.class);\r
\r
//static final Source faunaEuropaeaSource = FaunaEuropaeaSources.faunEu();\r
- static final ICdmDataSource cdmDestination = CdmDestinations.localH2();\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.CHECK_ONLY;\r
+ static final CHECK check = CHECK.IMPORT_WITHOUT_CHECK;\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
// app = CdmApplicationController.NewInstance(resource, destination, dbSchemaValidation, false, progressMonitor, listeners);\r
app = CdmApplicationController.NewInstance(resource, destination, dbSchemaValidation, false, progressMonitor);\r
\r
- TransactionStatus txStatus = app.startTransaction();\r
- List<TaxonNode> nodeList = app.getTaxonNodeService().list(null, null, null, null, null);\r
- List<TaxonBase> taxonList = new ArrayList<TaxonBase>();\r
-// UUID uuidArea = UUID.fromString("c6a2c418-1aee-448f-9836-44d85f9dd139");\r
- UUID uuidArea = UUID.fromString("1ca78cd4-7c24-46e9-a45a-ea96a2bb0ecd");\r
- NamedArea area = (NamedArea)app.getTermService().find(uuidArea);\r
- PresenceTerm status = (PresenceTerm)app.getTermService().find(UUID.fromString("cef81d25-501c-48d8-bbea-542ec50de2c2"));\r
- for (TaxonNode node:nodeList){\r
- if (node.getClassification() != null){\r
- Taxon taxon = node.getTaxon();\r
- TaxonDescription desc = TaxonDescription.NewInstance(taxon, false);\r
- desc.setTitleCache("Full area distribution", true);\r
- //only for test\r
- Distribution distr = Distribution.NewInstance(area, status);\r
- desc.addElement(distr);\r
- taxonList.add(taxon);\r
- }\r
- }\r
- app.getTaxonService().saveOrUpdate(taxonList);\r
- app.commitTransaction(txStatus);\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
+ cd.addState(stateData2);\r
+ \r
+ app.getDescriptionService().saveDescriptionElement(cd);\r
+ System.out.println("Saved");\r
+ \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
// 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
+// 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