\r
package eu.etaxonomy.cdm.app.cyprus;\r
\r
-import java.io.File;\r
-import java.net.MalformedURLException;\r
import java.net.URI;\r
import java.net.URISyntaxException;\r
-import java.net.URL;\r
-import java.util.List;\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.ICdmApplicationConfiguration;\r
import eu.etaxonomy.cdm.api.service.ITermService;\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.database.update.CdmUpdater;\r
import eu.etaxonomy.cdm.io.common.CdmDefaultImport;\r
import eu.etaxonomy.cdm.io.common.IImportConfigurator.CHECK;\r
import eu.etaxonomy.cdm.io.common.mapping.IInputTransformer;\r
import eu.etaxonomy.cdm.io.common.mapping.UndefinedTransformerMethodException;\r
import eu.etaxonomy.cdm.io.cyprus.CyprusImportConfigurator;\r
-import eu.etaxonomy.cdm.io.eflora.EfloraImportConfigurator;\r
-import eu.etaxonomy.cdm.io.eflora.centralAfrica.ericaceae.CentralAfricaEricaceaeImportConfigurator;\r
-import eu.etaxonomy.cdm.io.eflora.centralAfrica.ericaceae.CentralAfricaEricaceaeTransformer;\r
+import eu.etaxonomy.cdm.io.cyprus.CyprusTransformer;\r
import eu.etaxonomy.cdm.model.agent.Person;\r
-import eu.etaxonomy.cdm.model.agent.Team;\r
-import eu.etaxonomy.cdm.model.common.Language;\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.description.PolytomousKey;\r
import eu.etaxonomy.cdm.model.reference.Reference;\r
import eu.etaxonomy.cdm.model.reference.ReferenceFactory;\r
\r
\r
//database validation status (create, update, validate ...)\r
static DbSchemaValidation hbm2dll = DbSchemaValidation.CREATE;\r
+// static final URI source = cyprus_distribution();\r
static final URI source = cyprus_local();\r
\r
\r
-// static final ICdmDataSource cdmDestination = CdmDestinations.localH2();\r
+ static final ICdmDataSource cdmDestination = CdmDestinations.localH2();\r
// static final ICdmDataSource cdmDestination = CdmDestinations.cdm_local_postgres_CdmTest();\r
- static final ICdmDataSource cdmDestination = CdmDestinations.cdm_test_local_mysql();\r
+// static final ICdmDataSource cdmDestination = CdmDestinations.cdm_test_local_mysql();\r
// static final ICdmDataSource cdmDestination = CdmDestinations.cdm_cyprus_dev();\r
// static final ICdmDataSource cdmDestination = CdmDestinations.cdm_cyprus_production();\r
\r
//taxa\r
static final boolean doTaxa = true;\r
static final boolean doDeduplicate = false;\r
+ static final boolean doDistribution = false;\r
\r
\r
private void doImport(ICdmDataSource cdmDestination){\r
//make Source\r
CyprusImportConfigurator config= CyprusImportConfigurator.NewInstance(source, cdmDestination);\r
config.setClassificationUuid(classificationUuid);\r
- config.setDoTaxa(doTaxa);\r
config.setCheck(check);\r
-// config.setDefaultLanguageUuid(defaultLanguageUuid);\r
-// config.setDoPrintKeys(doPrintKeys);\r
+ config.setDoDistribution(doDistribution);\r
+ config.setDoTaxa(doTaxa);\r
config.setDbSchemaValidation(hbm2dll);\r
\r
CdmDefaultImport myImport = new CdmDefaultImport();\r
System.out.println("Start import from ("+ source.toString() + ") ...");\r
config.setSourceReference(getSourceReference(config.getSourceReferenceTitle()));\r
myImport.invoke(config);\r
+ if (doTaxa){\r
+ FeatureTree tree = makeFeatureNodes(myImport.getCdmAppController().getTermService());\r
+ myImport.getCdmAppController().getFeatureTreeService().saveOrUpdate(tree);\r
+ }\r
+\r
System.out.println("End import from ("+ source.toString() + ")...");\r
}\r
\r
- FeatureTree tree = makeFeatureNode(myImport.getCdmAppController().getTermService());\r
- myImport.getCdmAppController().getFeatureTreeService().saveOrUpdate(tree);\r
\r
\r
//deduplicate\r
if (doDeduplicate){\r
- CdmApplicationController app = myImport.getCdmAppController();\r
+ ICdmApplicationConfiguration app = myImport.getCdmAppController();\r
int count = app.getAgentService().deduplicate(Person.class, null, null);\r
logger.warn("Deduplicated " + count + " persons.");\r
- count = app.getAgentService().deduplicate(Team.class, null, null);\r
- logger.warn("Deduplicated " + count + " teams.");\r
+// count = app.getAgentService().deduplicate(Team.class, null, null);\r
+// logger.warn("Deduplicated " + count + " teams.");\r
count = app.getReferenceService().deduplicate(Reference.class, null, null);\r
logger.warn("Deduplicated " + count + " references.");\r
}\r
return result;\r
}\r
\r
- private FeatureTree makeFeatureNode(ITermService service){\r
- CentralAfricaEricaceaeTransformer transformer = new CentralAfricaEricaceaeTransformer();\r
+ private FeatureTree makeFeatureNodes(ITermService service){\r
+ CyprusTransformer transformer = new CyprusTransformer();\r
\r
FeatureTree result = FeatureTree.NewInstance(featureTreeUuid);\r
- result.setTitleCache("Central Africa Ericaceae Feature Tree");\r
+ result.setTitleCache("Cyprus Feature Tree");\r
FeatureNode root = result.getRoot();\r
FeatureNode newNode;\r
- \r
- newNode = FeatureNode.NewInstance(Feature.DESCRIPTION());\r
- root.addChild(newNode);\r
- \r
- addFeataureNodesByStringList(descriptionFeatureList, newNode, transformer, service);\r
-\r
- addFeataureNodesByStringList(generellDescriptionsList, root, transformer, service);\r
\r
+ newNode = FeatureNode.NewInstance(Feature.STATUS());\r
+ root.addChild(newNode);\r
\r
newNode = FeatureNode.NewInstance(Feature.DISTRIBUTION());\r
root.addChild(newNode);\r
\r
- newNode = FeatureNode.NewInstance(Feature.ECOLOGY());\r
- root.addChild(newNode);\r
- addFeataureNodesByStringList(habitatEcologyList, root, transformer, service);\r
- \r
- newNode = FeatureNode.NewInstance(Feature.USES());\r
+ newNode = FeatureNode.NewInstance(Feature.SYSTEMATICS());\r
root.addChild(newNode);\r
- \r
- addFeataureNodesByStringList(chomosomesList, root, transformer, service);\r
\r
- newNode = FeatureNode.NewInstance(Feature.COMMON_NAME());\r
- root.addChild(newNode);\r
- \r
- newNode = FeatureNode.NewInstance(Feature.CITATION());\r
- root.addChild(newNode);\r
+ //user defined features\r
+ String [] featureList = new String[]{"Red Book", "Endemism"};\r
+ addFeataureNodesByStringList(featureList, root, transformer, service);\r
\r
return result;\r
}\r
\r
- private static String [] chomosomesList = new String[]{\r
- "Chromosomes", \r
- };\r
-\r
- \r
- private static String [] habitatEcologyList = new String[]{\r
- "Habitat",\r
- "Habitat & Ecology"\r
- };\r
- \r
- \r
- private static String [] generellDescriptionsList = new String[]{\r
- "Fossils",\r
- "Morphology and anatomy",\r
- "Morphology", \r
- "Vegetative morphology and anatomy",\r
- "Flower morphology",\r
- "Palynology", \r
- "Pollination", \r
- "Pollen morphology",\r
- "Life cycle",\r
- "Fruits and embryology",\r
- "Dispersal",\r
- "Wood anatomy", \r
- "Leaf anatomy", \r
- "Chromosome numbers", \r
- "Phytochemistry and Chemotaxonomy",\r
- "Phytochemistry",\r
- "Taxonomy", \r
- };\r
-\r
- private static String [] descriptionFeatureList = new String[]{\r
- "lifeform", \r
- "Bark", \r
- "Indumentum", \r
- "endophytic body", \r
- "flowering buds", \r
- "Branchlets", \r
- "Branches", \r
- "Branch", \r
- "Flowering branchlets",\r
- "Trees", \r
- "Twigs", \r
- "stem", \r
- "Stems", \r
- "stem leaves", \r
- "Leaves",\r
- "flower-bearing stems", \r
- "Petiole", \r
- "Petiolules", \r
- "Leaflets", \r
- "Thyrsus", \r
- "Thyrses", \r
- "Inflorescences", \r
- "Inflorescence",\r
- "Young inflorescences", \r
- "Bracts", \r
- "Pedicels", \r
- "flowering buds", \r
- "scales", \r
- "Buds", \r
- "Flowers", \r
- "Flower", \r
- "Flowering",\r
- "Stigma", \r
- "perianth", \r
- "Sepals", \r
- "Sepal", \r
- "Outer Sepals", \r
- "Axillary", \r
- "cymes", \r
- "Calyx", \r
- "Petal", \r
- "Petals", \r
- "perigone tube",\r
- "Disc", \r
- "corolla", \r
- "Stamens", \r
- "Staminodes", \r
- "Ovary", \r
- "Anthers",\r
- "anther", \r
- "Pistil", \r
- "Pistillode", \r
- "Ovules", \r
- "androecium", \r
- "gynoecium", \r
- "Filaments", \r
- "Style", \r
- "annulus", \r
- "female flowers", \r
- "Male flowers", \r
- "Female", \r
- "Infructescences", //order not consistent (sometimes before "Flowers") \r
- "Fruit", \r
- "Fruits", \r
- "fruiting axes", \r
- "drupes", \r
- "Arillode", \r
- "seed", \r
- "Seeds", \r
- "Seedling", \r
- "flower tube", \r
- "nutlets", \r
- "pollen", \r
- "secondary xylem", \r
- "chromosome number", \r
- \r
- "figure", \r
- "fig", \r
- "figs", \r
\r
-\r
-\r
- \r
- };\r
+ //Cyprus\r
+ public static URI cyprus_local() {\r
+ URI sourceUrl;\r
+ try {\r
+ sourceUrl = new URI("file:/C:/localCopy/Data/zypern/Zypern.xls");\r
+ return sourceUrl;\r
+ } catch (URISyntaxException e) {\r
+ e.printStackTrace();\r
+ return null;\r
+ }\r
+ }\r
+ //Cyprus distriution\r
+ public static URI cyprus_distribution() {\r
+ URI sourceUrl;\r
+ try {\r
+ sourceUrl = new URI("file:/C:/localCopy/Data/zypern/Zypern_distribution_RH_corr.xls");\r
+ return sourceUrl;\r
+ } catch (URISyntaxException e) {\r
+ e.printStackTrace();\r
+ return null;\r
+ }\r
+ }\r
\r
public void addFeataureNodesByStringList(String[] featureStringList, FeatureNode root, IInputTransformer transformer, ITermService termService){\r
try {\r
}\r
\r
\r
- //Cyprus\r
- public static URI cyprus_local() {\r
- URI sourceUrl;\r
- try {\r
- sourceUrl = new URI("file:/C:/localCopy/Data/zypern/Zypern.xls");\r
- return sourceUrl;\r
- } catch (URISyntaxException e) {\r
- e.printStackTrace();\r
- return null;\r
- }\r
- }\r
- \r
-\r
/**\r
* @param args\r
*/\r