Revision 548a9ae0
Added by Andreas Müller almost 7 years ago
app-import/src/main/java/eu/etaxonomy/cdm/app/abcdImport/SpecimenImport.java | ||
---|---|---|
32 | 32 |
final static String xmlSource = "/home/pkelbert/Documents/Proibiosphere/Presentations/Demo/ABCD/calvum.xml"; |
33 | 33 |
|
34 | 34 |
|
35 |
static final ICdmDataSource cdmDestination = CdmDestinations.mon_cdm();
|
|
35 |
static final ICdmDataSource cdmDestination = CdmDestinations.localH2();
|
|
36 | 36 |
// static final ICdmDataSource cdmDestination = CdmDestinations.makeDestination(DatabaseTypeEnum.H2, "localhost", "abcd_import_test", 8082, "root", "root"); |
37 | 37 |
static final CHECK check = CHECK.IMPORT_WITHOUT_CHECK; |
38 | 38 |
|
app-import/src/main/java/eu/etaxonomy/cdm/app/common/CdmDestinations.java | ||
---|---|---|
616 | 616 |
return makeDestination(dbType, cdmServer, cdmDB, -1, cdmUserName, null); |
617 | 617 |
} |
618 | 618 |
|
619 |
/** |
|
620 |
* patricia |
|
621 |
*/ |
|
622 |
public static ICdmDataSource mon_cdm() { |
|
623 |
DatabaseTypeEnum dbType = DatabaseTypeEnum.MySQL; |
|
624 |
String cdmServer = "localhost"; |
|
625 |
String cdmDB = "cdm_local"; |
|
626 |
String cdmUserName = "root"; |
|
627 |
return makeDestination(dbType, cdmServer, cdmDB, -1, cdmUserName, null); |
|
628 |
} |
|
629 |
|
|
630 | 619 |
public static ICdmDataSource proibiosphere_chenopodium_local() { |
631 | 620 |
DatabaseTypeEnum dbType = DatabaseTypeEnum.MySQL; |
632 | 621 |
String cdmServer = "localhost"; |
... | ... | |
643 | 632 |
return makeDestination(dbType, cdmServer, cdmDB, -1, cdmUserName, null); |
644 | 633 |
} |
645 | 634 |
|
646 |
public static ICdmDataSource proibiosphere_fungi_local() { |
|
647 |
DatabaseTypeEnum dbType = DatabaseTypeEnum.MySQL; |
|
648 |
String cdmServer = "localhost"; |
|
649 |
String cdmDB = "cdm_production_proibiosphere_fungi_pilot"; |
|
650 |
String cdmUserName = "root"; |
|
651 |
return makeDestination(dbType, cdmServer, cdmDB, -1, cdmUserName, null); |
|
652 |
} |
|
653 |
|
|
654 |
public static ICdmDataSource proibiosphere_campylopus_local() { |
|
655 |
DatabaseTypeEnum dbType = DatabaseTypeEnum.MySQL; |
|
656 |
String cdmServer = "localhost"; |
|
657 |
String cdmDB = "cdm_production_proibiosphere_campylopus_pilot"; |
|
658 |
String cdmUserName = "root"; |
|
659 |
return makeDestination(dbType, cdmServer, cdmDB, -1, cdmUserName, null); |
|
660 |
} |
|
661 |
|
|
662 |
|
|
663 | 635 |
public static ICdmDataSource proibiosphere_eupolybothrus_local() { |
664 | 636 |
DatabaseTypeEnum dbType = DatabaseTypeEnum.MySQL; |
665 | 637 |
String cdmServer = "localhost"; |
app-import/src/main/java/eu/etaxonomy/cdm/app/excelImport/taxa/NormalExplicitActivator.java | ||
---|---|---|
38 | 38 |
private static DbSchemaValidation dbSchemaValidation = DbSchemaValidation.CREATE; |
39 | 39 |
|
40 | 40 |
// private static final ICdmDataSource destinationDb = CdmDestinations.cdm_test_jaxb(); |
41 |
private static final ICdmDataSource destinationDb = CdmDestinations.mon_cdm();
|
|
41 |
private static final ICdmDataSource destinationDb = CdmDestinations.localH2();
|
|
42 | 42 |
|
43 | 43 |
public static void main(String[] args) { |
44 | 44 |
|
app-import/src/main/java/eu/etaxonomy/cdm/app/proibiosphere/SynthesysCacheActivator.java | ||
---|---|---|
26 | 26 |
import eu.etaxonomy.cdm.model.reference.ReferenceFactory; |
27 | 27 |
|
28 | 28 |
|
29 |
|
|
30 |
|
|
31 | 29 |
/** |
32 | 30 |
* @author PK |
33 | 31 |
* @created 19.09.2008 |
34 |
* @version 1.0 |
|
35 | 32 |
*/ |
36 | 33 |
public class SynthesysCacheActivator { |
37 | 34 |
@SuppressWarnings("unused") |
... | ... | |
43 | 40 |
final static String xmlSource = "/home/pkelbert/Documents/Proibiosphere/ChenopodiumQuentin/dca UK records.xls"; |
44 | 41 |
|
45 | 42 |
|
46 |
static final ICdmDataSource cdmDestination = CdmDestinations.mon_cdm();
|
|
47 |
static DbSchemaValidation hbm2dll = DbSchemaValidation.CREATE;
|
|
43 |
static final ICdmDataSource cdmDestination = CdmDestinations.proibiosphere_spiders_local();
|
|
44 |
static DbSchemaValidation hbm2dll = DbSchemaValidation.VALIDATE;
|
|
48 | 45 |
// static final ICdmDataSource cdmDestination = CdmDestinations.proibiosphere_local(); |
49 | 46 |
// static DbSchemaValidation hbm2dll = DbSchemaValidation.VALIDATE; |
50 | 47 |
static final CHECK check = CHECK.IMPORT_WITHOUT_CHECK; |
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/faunaEuropaea/FaunaEuropaeaAdditionalTaxonDataImport.java | ||
---|---|---|
22 | 22 |
|
23 | 23 |
import eu.etaxonomy.cdm.database.ICdmDataSource; |
24 | 24 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
25 |
import eu.etaxonomy.cdm.model.name.INonViralName; |
|
26 |
import eu.etaxonomy.cdm.model.name.ITaxonNameBase; |
|
25 | 27 |
import eu.etaxonomy.cdm.model.name.NonViralName; |
26 | 28 |
import eu.etaxonomy.cdm.model.name.TaxonNameBase; |
27 | 29 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
... | ... | |
31 | 33 |
/** |
32 | 34 |
* @author a.babadshanjan |
33 | 35 |
* @created 21.08.2010 |
34 |
* @version 1.0 |
|
35 | 36 |
*/ |
36 | 37 |
@Component |
37 | 38 |
public class FaunaEuropaeaAdditionalTaxonDataImport extends FaunaEuropaeaImportBase { |
39 |
private static final long serialVersionUID = -6734273038256432559L; |
|
38 | 40 |
|
39 |
private static final Logger logger = Logger.getLogger(FaunaEuropaeaAdditionalTaxonDataImport.class);
|
|
41 |
private static final Logger logger = Logger.getLogger(FaunaEuropaeaAdditionalTaxonDataImport.class);
|
|
40 | 42 |
// private static final String parentPluralString = "Synonyms"; |
41 | 43 |
private static final String pluralString = "InfraGenericEpithets"; |
42 | 44 |
//private static final String acceptedTaxonUUID = "A9C24E42-69F5-4681-9399-041E652CF338"; // any accepted taxon uuid, taken from original fauna europaea database |
43 | 45 |
|
44 |
/* (non-Javadoc) |
|
45 |
* @see eu.etaxonomy.cdm.io.common.CdmIoBase#doCheck(eu.etaxonomy.cdm.io.common.IImportConfigurator) |
|
46 |
*/ |
|
47 | 46 |
@Override |
48 | 47 |
protected boolean doCheck(FaunaEuropaeaImportState state) { |
49 | 48 |
boolean result = true; |
50 |
FaunaEuropaeaImportConfigurator fauEuConfig = state.getConfig(); |
|
51 | 49 |
logger.warn("Checking for Taxa not yet fully implemented"); |
52 |
// result &= checkTaxonStatus(fauEuConfig); |
|
53 |
|
|
54 | 50 |
return result; |
55 | 51 |
} |
56 | 52 |
|
... | ... | |
77 | 73 |
* @return |
78 | 74 |
*/ |
79 | 75 |
private void processAdditionalInfraGenericEpithets(FaunaEuropaeaImportState state) { |
80 |
int count = 0; |
|
81 | 76 |
int pageSize = 1000; |
82 | 77 |
Set<UUID> uuidSet = new HashSet<UUID>(); |
83 | 78 |
FaunaEuropaeaImportConfigurator fauEuConfig = state.getConfig(); |
... | ... | |
108 | 103 |
if (!uuidSet.isEmpty()){ |
109 | 104 |
taxonNames = getNameService().find(uuidSet); |
110 | 105 |
|
111 |
for (TaxonNameBase taxonName : taxonNames) { |
|
106 |
for (TaxonNameBase<?,?> taxonName : taxonNames) {
|
|
112 | 107 |
|
113 | 108 |
// Check whether its taxonName has an infraGenericEpithet |
114 | 109 |
if (taxonName != null && (taxonName.isInstanceOf(NonViralName.class))) { |
115 |
NonViralName targetNonViralName = CdmBase.deproxy(taxonName, NonViralName.class); |
|
110 |
INonViralName targetNonViralName = CdmBase.deproxy(taxonName, NonViralName.class);
|
|
116 | 111 |
String infraGenericEpithet = targetNonViralName.getInfraGenericEpithet(); |
117 | 112 |
if (infraGenericEpithet == null) { |
118 | 113 |
String genusOrUninomial = targetNonViralName.getGenusOrUninomial(); |
... | ... | |
121 | 116 |
"*", "*", null, pageSize, 1); |
122 | 117 |
if (foundTaxa.size() == 1) { |
123 | 118 |
// one matching Taxon found |
124 |
TaxonBase taxon = foundTaxa.iterator().next(); |
|
119 |
TaxonBase<?> taxon = foundTaxa.iterator().next();
|
|
125 | 120 |
if (taxon != null) { |
126 |
TaxonNameBase name = taxon.getName(); |
|
121 |
ITaxonNameBase name = taxon.getName();
|
|
127 | 122 |
if (name != null && name.isInstanceOf(NonViralName.class)) { |
128 |
NonViralName nonViralName = CdmBase.deproxy(name, NonViralName.class); |
|
123 |
INonViralName nonViralName = CdmBase.deproxy(name, NonViralName.class);
|
|
129 | 124 |
infraGenericEpithet = nonViralName.getInfraGenericEpithet(); |
130 | 125 |
|
131 | 126 |
// set infraGenericEpithet |
132 | 127 |
// targetNonViralName.setInfraGenericEpithet(infraGenericEpithet); |
133 | 128 |
logger.debug("Added an InfraGenericEpithet to this TaxonName: " + taxonName.getUuid() + " (" + taxonName.getTitleCache() + ")"); |
134 |
count++; |
|
135 | 129 |
} |
136 | 130 |
} |
137 | 131 |
} else if (foundTaxa.size() > 1) { |
138 | 132 |
logger.warn("Multiple taxa match search criteria: " + taxonName.getUuid() + " (" + taxonName.getTitleCache() + ")"); |
139 |
for (TaxonBase foundTaxon : foundTaxa) { |
|
133 |
for (TaxonBase<?> foundTaxon : foundTaxa) {
|
|
140 | 134 |
logger.warn(foundTaxon.getUuid() + ", " + foundTaxon.getTitleCache()); |
141 | 135 |
} |
142 | 136 |
} else if (foundTaxa.size() == 0) { |
... | ... | |
157 | 151 |
return; |
158 | 152 |
} |
159 | 153 |
|
160 |
|
|
161 |
/* (non-Javadoc) |
|
162 |
* @see eu.etaxonomy.cdm.io.common.CdmIoBase#isIgnore(eu.etaxonomy.cdm.io.common.IoStateBase) |
|
163 |
*/ |
|
164 | 154 |
@Override |
165 | 155 |
protected boolean isIgnore(FaunaEuropaeaImportState state) { |
166 | 156 |
return ! state.getConfig().isDoTaxa(); |
167 | 157 |
} |
168 |
|
|
169 | 158 |
} |
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/faunaEuropaea/FaunaEuropaeaDistribution.java | ||
---|---|---|
1 | 1 |
/** |
2 | 2 |
* Copyright (C) 2009 EDIT |
3 |
* European Distributed Institute of Taxonomy
|
|
3 |
* European Distributed Institute of Taxonomy |
|
4 | 4 |
* http://www.e-taxonomy.eu |
5 |
*
|
|
5 |
* |
|
6 | 6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
7 | 7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
8 | 8 |
*/ |
9 | 9 |
|
10 | 10 |
package eu.etaxonomy.cdm.io.pesi.faunaEuropaea; |
11 | 11 |
|
12 |
import java.util.UUID; |
|
13 |
|
|
14 |
import org.joda.time.DateTime; |
|
15 |
|
|
16 | 12 |
/** |
17 | 13 |
* @author a.babadshanjan |
18 | 14 |
* @created 11.09.2009 |
19 |
* @version 1.0 |
|
20 | 15 |
*/ |
21 | 16 |
public class FaunaEuropaeaDistribution { |
22 |
|
|
23 |
private UUID taxonUuid; |
|
24 |
private int taxonId; |
|
17 |
|
|
25 | 18 |
private int distributionId; |
26 | 19 |
private int occurrenceStatusId; |
27 | 20 |
private int areaId; |
28 | 21 |
private String areaName; |
29 | 22 |
private String areaCode; |
30 | 23 |
private int extraLimital; |
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
|
35 |
// /** |
|
36 |
// * @return the taxonUuid |
|
37 |
// */ |
|
38 |
// public UUID getTaxonUuid() { |
|
39 |
// return taxonUuid; |
|
40 |
// } |
|
41 |
// /** |
|
42 |
// * @param taxonUuid the taxonUuid to set |
|
43 |
// */ |
|
44 |
// public void setTaxonUuid(UUID taxonUuid) { |
|
45 |
// this.taxonUuid = taxonUuid; |
|
46 |
// } |
|
47 |
// /** |
|
48 |
// * @return the taxonId |
|
49 |
// */ |
|
50 |
// public int getTaxonId() { |
|
51 |
// return taxonId; |
|
52 |
// } |
|
53 |
// /** |
|
54 |
// * @param taxonId the taxonId to set |
|
55 |
// */ |
|
56 |
// public void setTaxonId(int taxonId) { |
|
57 |
// this.taxonId = taxonId; |
|
58 |
// } |
|
24 |
|
|
59 | 25 |
/** |
60 | 26 |
* @return the distributionId |
61 | 27 |
*/ |
... | ... | |
128 | 94 |
public void setExtraLimital(int extraLimital) { |
129 | 95 |
this.extraLimital = extraLimital; |
130 | 96 |
} |
131 |
|
|
97 |
|
|
132 | 98 |
|
133 | 99 |
} |
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/faunaEuropaea/FaunaEuropaeaDistributionImport.java | ||
---|---|---|
37 | 37 |
/** |
38 | 38 |
* @author a.babadshanjan |
39 | 39 |
* @created 12.05.2009 |
40 |
* @version 1.0 |
|
41 | 40 |
*/ |
42 | 41 |
@Component |
43 | 42 |
public class FaunaEuropaeaDistributionImport extends FaunaEuropaeaImportBase { |
44 |
private static final Logger logger = Logger.getLogger(FaunaEuropaeaDistributionImport.class); |
|
43 |
private static final long serialVersionUID = 746146902707885655L; |
|
44 |
private static final Logger logger = Logger.getLogger(FaunaEuropaeaDistributionImport.class); |
|
45 | 45 |
|
46 | 46 |
|
47 | 47 |
@Override |
48 | 48 |
protected boolean doCheck(FaunaEuropaeaImportState state) { |
49 | 49 |
boolean result = true; |
50 |
FaunaEuropaeaImportConfigurator fauEuConfig = state.getConfig(); |
|
51 |
logger.warn("Checking for Distributions not yet fully implemented"); |
|
52 |
result &= checkReferenceStatus(fauEuConfig); |
|
53 |
|
|
50 |
logger.warn("Checking for Distributions not yet implemented"); |
|
54 | 51 |
return result; |
55 | 52 |
} |
56 | 53 |
|
57 |
private boolean checkReferenceStatus(FaunaEuropaeaImportConfigurator fauEuConfig) { |
|
58 |
boolean result = true; |
|
59 |
// try { |
|
60 |
// Source source = fauEuConfig.getSource(); |
|
61 |
// String sqlStr = ""; |
|
62 |
// ResultSet rs = source.getResultSet(sqlStr); |
|
63 |
return result; |
|
64 |
// } catch (SQLException e) { |
|
65 |
// e.printStackTrace(); |
|
66 |
// return false; |
|
67 |
// } |
|
68 |
} |
|
69 |
|
|
70 | 54 |
@Override |
71 | 55 |
protected void doInvoke(FaunaEuropaeaImportState state) { |
72 | 56 |
/* |
... | ... | |
127 | 111 |
String selectQuery = |
128 | 112 |
selectColumns + fromClause + orderBy; |
129 | 113 |
|
130 |
|
|
131 |
|
|
132 | 114 |
if(logger.isInfoEnabled()) { logger.info("Start making distributions..."); } |
133 | 115 |
|
134 | 116 |
try { |
... | ... | |
150 | 132 |
if ((i++ % limit) == 0) { |
151 | 133 |
|
152 | 134 |
txStatus = startTransaction(); |
153 |
taxonUuids = new HashSet<UUID>(limit);
|
|
154 |
fauEuTaxonMap = new HashMap<UUID, FaunaEuropaeaDistributionTaxon>(limit);
|
|
135 |
taxonUuids = new HashSet<>(limit); |
|
136 |
fauEuTaxonMap = new HashMap<>(limit); |
|
155 | 137 |
|
156 | 138 |
if(logger.isInfoEnabled()) { |
157 | 139 |
logger.info("i = " + i + " - Distribution import transaction started"); |
... | ... | |
241 | 223 |
* |
242 | 224 |
*/ |
243 | 225 |
private void createTermVocabulary(TransactionStatus txStatus, FaunaEuropaeaImportState state) { |
244 |
TermVocabulary<NamedArea> faunaEuAreaVocabulary = TermVocabulary.NewInstance(TermType.NamedArea, "Areas for Fauna Europaea distribution data", "FE areas", "FE", null); |
|
245 |
|
|
246 |
NamedArea area; |
|
226 |
TermVocabulary<NamedArea> faunaEuAreaVocabulary = TermVocabulary.NewInstance(TermType.NamedArea, "Areas for Fauna Europaea distribution data", "FE areas", "FE", null); |
|
227 |
faunaEuAreaVocabulary.setUuid(FaunaEuropaeaTransformer.uuidFauEuArea); |
|
247 | 228 |
|
248 |
area =NamedArea.NewInstance(null, "Andorra", "AD"); |
|
229 |
NamedArea area =NamedArea.NewInstance(null, "Andorra", "AD");
|
|
249 | 230 |
area.setUuid(UUID.randomUUID()); |
250 | 231 |
area.setIdInVocabulary("AD"); |
251 | 232 |
state.putNamedArea(area); |
... | ... | |
652 | 633 |
logger.info("save voc"); |
653 | 634 |
commitTransaction(txStatus); |
654 | 635 |
state.setAreaVoc(faunaEuAreaVocabulary); |
655 |
|
|
656 |
|
|
657 | 636 |
} |
658 | 637 |
|
659 | 638 |
private void commitTaxaAndDistribution( |
... | ... | |
661 | 640 |
Set<UUID> taxonUuids, |
662 | 641 |
Map<UUID, FaunaEuropaeaDistributionTaxon> fauEuTaxonMap, |
663 | 642 |
TransactionStatus txStatus) throws Exception { |
664 |
List<TaxonBase> taxonList = prepareTaxaAndDistribution(getTaxonService().find(taxonUuids), fauEuTaxonMap, state); |
|
643 |
|
|
644 |
List<TaxonBase> taxonList = prepareTaxaAndDistribution(getTaxonService().find(taxonUuids), fauEuTaxonMap, state); |
|
665 | 645 |
|
666 | 646 |
getTaxonService().save(taxonList); |
667 | 647 |
taxonList = null; |
... | ... | |
692 | 672 |
continue; |
693 | 673 |
} |
694 | 674 |
|
695 |
|
|
696 | 675 |
Set<TaxonDescription> descriptionSet = taxon.getDescriptions(); |
697 | 676 |
if (descriptionSet.size() > 0) { |
698 | 677 |
taxonDescription = descriptionSet.iterator().next(); |
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/faunaEuropaea/FaunaEuropaeaTransformer.java | ||
---|---|---|
29 | 29 |
/** |
30 | 30 |
* @author a.babadshanjan |
31 | 31 |
* @created 12.05.2009 |
32 |
* @version 1.0 |
|
33 | 32 |
*/ |
34 | 33 |
|
35 | 34 |
public final class FaunaEuropaeaTransformer { |
36 | 35 |
private static final Logger logger = Logger.getLogger(FaunaEuropaeaTransformer.class); |
37 | 36 |
|
37 |
public static final UUID uuidFauEuArea = UUID.fromString("16325043-e7da-4742-b012-9ce03362a124"); |
|
38 |
|
|
38 | 39 |
// Query |
39 | 40 |
public static final int Q_NO_RESTRICTION = -1; |
40 | 41 |
|
... | ... | |
79 | 80 |
public static final int R_SPECIES = 21; |
80 | 81 |
public static final int R_SUBSPECIES = 22; |
81 | 82 |
|
82 |
public static PresenceAbsenceTerm occStatus2PresenceAbsence(int occStatusId) throws UnknownCdmTypeException{
|
|
83 |
public static PresenceAbsenceTerm occStatus2PresenceAbsence(int occStatusId){ |
|
83 | 84 |
|
84 | 85 |
if (Integer.valueOf(occStatusId) == null) { |
85 | 86 |
return PresenceAbsenceTerm.PRESENT(); |
86 | 87 |
} |
87 | 88 |
switch (occStatusId){ |
88 |
case 0: return PresenceAbsenceTerm.PRESENT(); |
|
89 |
case 2: return PresenceAbsenceTerm.ABSENT(); |
|
90 |
case 1: return PresenceAbsenceTerm.PRESENT_DOUBTFULLY(); |
|
91 |
|
|
92 |
default: { |
|
93 |
|
|
94 |
return null; |
|
95 |
|
|
96 |
|
|
89 |
case 0: return PresenceAbsenceTerm.PRESENT(); |
|
90 |
case 2: return PresenceAbsenceTerm.ABSENT(); |
|
91 |
case 1: return PresenceAbsenceTerm.PRESENT_DOUBTFULLY(); |
|
92 |
default: { |
|
93 |
return null; |
|
94 |
} |
|
97 | 95 |
} |
98 |
|
|
99 |
} |
|
100 | 96 |
} |
101 | 97 |
|
102 | 98 |
|
... | ... | |
391 | 387 |
// } |
392 | 388 |
|
393 | 389 |
|
390 |
public final static HashMap<Integer, Language> languageFK2Language = new HashMap<>(); |
|
394 | 391 |
|
395 |
public final static HashMap<Integer, Language> languageFK2Language = new HashMap<Integer,Language>(); |
|
396 |
static |
|
392 |
static |
|
397 | 393 |
{ |
398 | 394 |
languageFK2Language.put(1, Language.ALBANIAN()); |
399 | 395 |
languageFK2Language.put(4, Language.AZERBAIJANI()); |
Also available in: Unified diff
Cleanup