Revision a399b702
Added by U-BGBM\k.luther over 8 years ago
cdm-pesi/src/main/java/eu/etaxonomy/cdm/app/common/CdmDestinations.java | ||
---|---|---|
34 | 34 |
public static ICdmDataSource cdm_test_local_faunaEu_mysql(){ |
35 | 35 |
DatabaseTypeEnum dbType = DatabaseTypeEnum.MySQL; |
36 | 36 |
String cdmServer = "127.0.0.1"; |
37 |
String cdmDB = "cdm_faunaeu_2015_11";
|
|
37 |
String cdmDB = "cdm_faunaeu_2015_09";
|
|
38 | 38 |
String cdmUserName = "root"; |
39 | 39 |
return makeDestination(dbType, cdmServer, cdmDB, -1, cdmUserName, null); |
40 | 40 |
} |
cdm-pesi/src/main/java/eu/etaxonomy/cdm/app/pesi/FaunaEuropaeaActivator.java | ||
---|---|---|
17 | 17 |
import eu.etaxonomy.cdm.app.common.CdmDestinations; |
18 | 18 |
import eu.etaxonomy.cdm.database.DbSchemaValidation; |
19 | 19 |
import eu.etaxonomy.cdm.database.ICdmDataSource; |
20 |
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper; |
|
20 | 21 |
import eu.etaxonomy.cdm.io.common.CdmDefaultImport; |
21 | 22 |
import eu.etaxonomy.cdm.io.common.IImportConfigurator.CHECK; |
22 | 23 |
import eu.etaxonomy.cdm.io.common.IImportConfigurator.DO_REFERENCES; |
... | ... | |
49 | 50 |
static DbSchemaValidation dbSchemaValidation = DbSchemaValidation.CREATE; |
50 | 51 |
// static DbSchemaValidation dbSchemaValidation = DbSchemaValidation.UPDATE; |
51 | 52 |
// static DbSchemaValidation dbSchemaValidation = DbSchemaValidation.VALIDATE; |
53 |
|
|
54 |
|
|
55 |
|
|
52 | 56 |
static final NomenclaturalCode nomenclaturalCode = NomenclaturalCode.ICZN; |
53 | 57 |
|
54 | 58 |
// ****************** ALL ***************************************** |
... | ... | |
64 | 68 |
static final boolean doDistributions = true; |
65 | 69 |
static final boolean makeFeatureTree = true; |
66 | 70 |
static final boolean doVernacularNames = true; |
71 |
static final boolean doAssociatedSpecialists = true; |
|
72 |
static final boolean addCommonNameFeature = true; |
|
67 | 73 |
// CDM to CDM import |
68 | 74 |
static final boolean doHeterotypicSynonymsForBasionyms = true; |
69 |
|
|
75 |
|
|
70 | 76 |
// ************************ NONE **************************************** // |
71 | 77 |
|
72 | 78 |
// Fauna Europaea to CDM import |
... | ... | |
110 | 116 |
fauEuImportConfigurator.setDoHeterotypicSynonyms(doHeterotypicSynonyms); |
111 | 117 |
fauEuImportConfigurator.setDoHeterotypicSynonymsForBasionyms(doHeterotypicSynonymsForBasionyms); |
112 | 118 |
fauEuImportConfigurator.setSourceRefUuid(PesiTransformer.uuidSourceRefFaunaEuropaea); |
113 |
|
|
119 |
fauEuImportConfigurator.setDoAssociatedSpecialists(doAssociatedSpecialists); |
|
120 |
fauEuImportConfigurator.setDoVernacularNames(doVernacularNames); |
|
114 | 121 |
CdmDefaultImport<FaunaEuropaeaImportConfigurator> fauEuImport = |
115 | 122 |
new CdmDefaultImport<FaunaEuropaeaImportConfigurator>(); |
116 | 123 |
try { |
... | ... | |
164 | 171 |
FeatureNode commonNameFeatureNode = FeatureNode.NewInstance(commonNameFeature); |
165 | 172 |
app.getFeatureTreeService().saveOrUpdate(featureTree); |
166 | 173 |
} |
167 |
|
|
174 |
|
|
168 | 175 |
System.out.println("End importing Fauna Europaea data"); |
169 | 176 |
} |
170 | 177 |
|
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/faunaEuropaea/FaunaEuropaeaDistributionImport.java | ||
---|---|---|
22 | 22 |
import org.springframework.stereotype.Component; |
23 | 23 |
import org.springframework.transaction.TransactionStatus; |
24 | 24 |
|
25 |
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper; |
|
25 | 26 |
import eu.etaxonomy.cdm.io.common.Source; |
26 | 27 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
28 |
import eu.etaxonomy.cdm.model.common.OrderedTermVocabulary; |
|
27 | 29 |
import eu.etaxonomy.cdm.model.common.TermVocabulary; |
28 | 30 |
import eu.etaxonomy.cdm.model.description.Distribution; |
29 | 31 |
import eu.etaxonomy.cdm.model.description.PresenceAbsenceTerm; |
... | ... | |
72 | 74 |
logger.warn("Start distribution doInvoke"); |
73 | 75 |
ProfilerController.memorySnapshot(); |
74 | 76 |
*/ |
77 |
|
|
78 |
if (!state.getConfig().isDoOccurrence()){ |
|
79 |
return; |
|
80 |
} |
|
81 |
|
|
75 | 82 |
int limit = state.getConfig().getLimitSave(); |
76 | 83 |
UUID noDataUuid; |
77 | 84 |
/* Taxon store for retrieving taxa from and saving taxa to CDM */ |
... | ... | |
87 | 94 |
//txStatus = startTransaction(); |
88 | 95 |
PresenceAbsenceTerm noDataStatusTerm = PresenceAbsenceTerm.NewPresenceInstance("no data", "no data", "nod"); |
89 | 96 |
noDataUuid = noDataStatusTerm.getUuid(); |
90 |
TermVocabulary voc = getVocabularyService().find(30); |
|
91 |
voc.addTerm(noDataStatusTerm); |
|
92 |
getVocabularyService().saveOrUpdate(voc); |
|
93 |
// getTermService().save(noDataStatusTerm); |
|
97 |
TermVocabulary<PresenceAbsenceTerm> voc = getVocabularyService().find(30); |
|
98 |
HibernateProxyHelper.deproxy(voc, OrderedTermVocabulary.class); |
|
99 |
//voc.addTerm(noDataStatusTerm); |
|
100 |
// getVocabularyService().saveOrUpdate(voc); |
|
101 |
getTermService().save(noDataStatusTerm); |
|
94 | 102 |
//commitTransaction(txStatus); |
95 | 103 |
|
96 | 104 |
FaunaEuropaeaTransformer.setUUIDs(noDataUuid); |
... | ... | |
224 | 232 |
|
225 | 233 |
if(logger.isInfoEnabled()) { logger.info("End making distributions..."); } |
226 | 234 |
|
235 |
|
|
227 | 236 |
return; |
228 | 237 |
} |
229 | 238 |
|
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/faunaEuropaea/FaunaEuropaeaHeterotypicSynonymImport.java | ||
---|---|---|
68 | 68 |
if (logger.isInfoEnabled()) { |
69 | 69 |
logger.info("Number of synonyms = " + nbrOfSynonyms); |
70 | 70 |
} |
71 |
|
|
71 |
if(state.getConfig().isDoHeterotypicSynonyms()){ |
|
72 | 72 |
while (i < nbrOfSynonyms) { |
73 | 73 |
|
74 | 74 |
try { |
... | ... | |
137 | 137 |
e.printStackTrace(); |
138 | 138 |
} |
139 | 139 |
} |
140 |
} |
|
140 | 141 |
return; |
141 | 142 |
} |
142 | 143 |
|
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/faunaEuropaea/FaunaEuropaeaImportConfigurator.java | ||
---|---|---|
38 | 38 |
private boolean doHeterotypicSynonymsForBasionyms ; |
39 | 39 |
private boolean doOccurrence = true; |
40 | 40 |
private boolean doVernacularNames = true; |
41 |
private boolean doAssociatedSpecialists = true; |
|
42 |
|
|
43 |
public boolean isDoVernacularNames() { |
|
44 |
return doVernacularNames; |
|
45 |
} |
|
46 |
|
|
47 |
public void setDoVernacularNames(boolean doVernacularNames) { |
|
48 |
this.doVernacularNames = doVernacularNames; |
|
49 |
} |
|
50 |
|
|
51 |
public boolean isDoTypes() { |
|
52 |
return doTypes; |
|
53 |
} |
|
54 |
|
|
55 |
|
|
56 |
|
|
41 | 57 |
|
42 | 58 |
/* Max number of taxa to be saved with one service call */ |
43 | 59 |
private int limitSave = 5000; |
... | ... | |
288 | 304 |
this.doRelTaxa = doRelTaxa; |
289 | 305 |
} |
290 | 306 |
|
307 |
public boolean isDoAssociatedSpecialists() { |
|
308 |
|
|
309 |
return this.doAssociatedSpecialists; |
|
310 |
} |
|
311 |
|
|
312 |
public void setDoAssociatedSpecialists(boolean doAssociatedSpecialists){ |
|
313 |
this.doAssociatedSpecialists = doAssociatedSpecialists; |
|
314 |
} |
|
315 |
|
|
291 | 316 |
|
292 | 317 |
} |
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/faunaEuropaea/FaunaEuropaeaImportState.java | ||
---|---|---|
32 | 32 |
super(config); |
33 | 33 |
} |
34 | 34 |
|
35 |
private Map<Integer, FaunaEuropaeaTaxon> fauEuTaxonMap = new HashMap(); |
|
36 |
private Map<UUID, UUID> childParentMap = new HashMap(); |
|
37 |
private Map<Integer, UUID> agentUUIDMap = new HashMap(); |
|
35 |
private Map<Integer, FaunaEuropaeaTaxon> fauEuTaxonMap = new HashMap<Integer, FaunaEuropaeaTaxon>();
|
|
36 |
private Map<UUID, UUID> childParentMap = new HashMap<UUID, UUID>();
|
|
37 |
private Map<Integer, UUID> agentUUIDMap = new HashMap<Integer, UUID>();
|
|
38 | 38 |
|
39 | 39 |
/* Highest taxon index in the FauEu database */ |
40 | 40 |
// private int highestTaxonIndex = 305755; |
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/faunaEuropaea/FaunaEuropaeaRefImport.java | ||
---|---|---|
26 | 26 |
import org.springframework.transaction.TransactionStatus; |
27 | 27 |
|
28 | 28 |
import eu.etaxonomy.cdm.io.common.IImportConfigurator; |
29 |
import eu.etaxonomy.cdm.io.common.IImportConfigurator.DO_REFERENCES; |
|
29 | 30 |
import eu.etaxonomy.cdm.io.common.ImportHelper; |
30 | 31 |
import eu.etaxonomy.cdm.io.common.Source; |
31 | 32 |
import eu.etaxonomy.cdm.model.agent.Team; |
... | ... | |
71 | 72 |
logger.warn("Start RefImport doInvoke"); |
72 | 73 |
ProfilerController.memorySnapshot(); |
73 | 74 |
*/ |
74 |
|
|
75 |
if (state.getConfig().getDoReferences().equals(DO_REFERENCES.NONE)){ |
|
76 |
return; |
|
77 |
} |
|
75 | 78 |
Set<UUID> taxonUuids = null; |
76 | 79 |
Map<Integer, Reference<?>> references = null; |
77 | 80 |
Map<String,TeamOrPersonBase<?>> authors = null; |
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/faunaEuropaea/FaunaEuropaeaRelTaxonIncludeImport.java | ||
---|---|---|
20 | 20 |
import java.util.Set; |
21 | 21 |
import java.util.UUID; |
22 | 22 |
|
23 |
import org.apache.commons.lang.StringUtils; |
|
23 | 24 |
import org.apache.log4j.Logger; |
24 | 25 |
import org.springframework.stereotype.Component; |
25 | 26 |
import org.springframework.transaction.TransactionStatus; |
... | ... | |
29 | 30 |
import eu.etaxonomy.cdm.io.common.MapWrapper; |
30 | 31 |
import eu.etaxonomy.cdm.io.common.Source; |
31 | 32 |
import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase; |
33 |
import eu.etaxonomy.cdm.model.common.Annotation; |
|
32 | 34 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
35 |
import eu.etaxonomy.cdm.model.common.Language; |
|
33 | 36 |
import eu.etaxonomy.cdm.model.reference.Reference; |
34 | 37 |
import eu.etaxonomy.cdm.model.taxon.Classification; |
35 | 38 |
import eu.etaxonomy.cdm.model.taxon.Synonym; |
... | ... | |
38 | 41 |
import eu.etaxonomy.cdm.model.taxon.TaxonBase; |
39 | 42 |
import eu.etaxonomy.cdm.model.taxon.TaxonNode; |
40 | 43 |
//import eu.etaxonomy.cdm.profiler.ProfilerController; |
44 |
import eu.etaxonomy.cdm.model.taxon.TaxonNodeAgentRelation; |
|
41 | 45 |
|
42 | 46 |
|
43 | 47 |
|
... | ... | |
97 | 101 |
/*logger.warn("Start RelTaxon doInvoke"); |
98 | 102 |
ProfilerController.memorySnapshot(); |
99 | 103 |
*/ |
104 |
|
|
105 |
if (!state.getConfig().isDoTaxonomicallyIncluded()){ |
|
106 |
return; |
|
107 |
} |
|
100 | 108 |
Map<String, MapWrapper<? extends CdmBase>> stores = state.getStores(); |
101 | 109 |
|
102 | 110 |
MapWrapper<TeamOrPersonBase> authorStore = (MapWrapper<TeamOrPersonBase>)stores.get(ICdmIO.TEAM_STORE); |
... | ... | |
119 | 127 |
|
120 | 128 |
if (state.getConfig().isDoTaxonomicallyIncluded()) { |
121 | 129 |
processParentsChildren(state); |
130 |
|
|
131 |
} |
|
132 |
if (state.getConfig().isDoAssociatedSpecialists()){ |
|
133 |
processAssociatedSpecialists(state); |
|
122 | 134 |
} |
123 | 135 |
|
124 | 136 |
logger.warn("Before processMissappliedNames" + state.getConfig().isDoMisappliedNames()); |
... | ... | |
881 | 893 |
|
882 | 894 |
return; |
883 | 895 |
} |
896 |
|
|
897 |
private void processAssociatedSpecialists(FaunaEuropaeaImportState state){ |
|
898 |
int limit = state.getConfig().getLimitSave(); |
|
899 |
|
|
900 |
TransactionStatus txStatus = null; |
|
901 |
|
|
902 |
Map<UUID, UUID> childParentMap = null; |
|
903 |
|
|
904 |
|
|
905 |
TaxonNode taxonNode = null; |
|
906 |
TeamOrPersonBase associatedSpecialist = null; |
|
907 |
TaxonNodeAgentRelation agentRel = null; |
|
908 |
UUID agentUuid = null; |
|
909 |
FaunaEuropaeaImportConfigurator fauEuConfig = state.getConfig(); |
|
910 |
Source source = fauEuConfig.getSource(); |
|
911 |
int i = 0; |
|
912 |
|
|
913 |
String selectCount = |
|
914 |
" SELECT count(*) "; |
|
915 |
|
|
916 |
|
|
917 |
|
|
918 |
String selectColumns = "SELECT u.USR_GROUPNAME as groupName, u.USR_GROUPNOTE groupNote, u.USR_USR_ID as user_user_id, " |
|
919 |
+ " u.usr_id user_id, user2.USR_ID as user2_id, taxon.UUID as tax_uuid "; |
|
920 |
|
|
921 |
String fromClause = " FROM USERROLE as userrole left join USERS u on userrole.URL_USR_ID = u.USR_ID left join USERS user2 on user2.USR_ID = u.USR_USR_ID " |
|
922 |
+ " left join TAXON taxon on (taxon.TAX_USR_IDSP= user2.USR_ID or taxon.TAX_USR_IDGC= user2.USR_ID) " |
|
923 |
+ " where USERROLE.URL_ROL_ID = 7 order by taxon.TAX_ID"; |
|
924 |
String orderClause = " ORDER BY taxon.TAX_ID"; |
|
925 |
|
|
926 |
String countQuery = |
|
927 |
selectCount + fromClause; |
|
928 |
|
|
929 |
String selectQuery = |
|
930 |
selectColumns + fromClause + orderClause; |
|
931 |
|
|
932 |
if(logger.isInfoEnabled()) { logger.info("Start making associated specialists..."); } |
|
933 |
|
|
934 |
try { |
|
935 |
|
|
936 |
ResultSet rs = source.getResultSet(countQuery); |
|
937 |
rs.next(); |
|
938 |
int count = rs.getInt(1); |
|
939 |
|
|
940 |
rs = source.getResultSet(selectQuery); |
|
941 |
|
|
942 |
if (logger.isInfoEnabled()) { |
|
943 |
logger.info("Number of rows: " + count); |
|
944 |
logger.info("Count Query: " + countQuery); |
|
945 |
logger.info("Select Query: " + selectQuery); |
|
946 |
} |
|
947 |
|
|
948 |
while (rs.next()) { |
|
949 |
String taxonUUID = rs.getString("taxUuid"); |
|
950 |
String oldTaxonUuidString = null; |
|
951 |
int userId = rs.getInt("user_id"); |
|
952 |
int user2Id = rs.getInt("user2_id"); |
|
953 |
String groupName = rs.getString("groupName"); |
|
954 |
Taxon taxon = null; |
|
955 |
if (!taxonUUID.equals(oldTaxonUuidString)){ |
|
956 |
if (taxonNode != null){ |
|
957 |
getTaxonNodeService().saveOrUpdate(taxonNode); |
|
958 |
} |
|
959 |
commitTransaction(txStatus); |
|
960 |
txStatus = startTransaction(); |
|
961 |
taxon = HibernateProxyHelper.deproxy(getTaxonService().find(UUID.fromString(taxonUUID)), Taxon.class); |
|
962 |
oldTaxonUuidString = taxonUUID; |
|
963 |
if (!taxon.getTaxonNodes().isEmpty()){ |
|
964 |
taxonNode = taxon.getTaxonNodes().iterator().next(); |
|
965 |
} else { |
|
966 |
taxonNode = null; |
|
967 |
logger.info("There is an associated specialist for a taxon which has no taxonnode."); |
|
968 |
} |
|
969 |
} |
|
970 |
|
|
971 |
agentUuid = state.getAgentMap().get(userId); |
|
972 |
|
|
973 |
|
|
974 |
associatedSpecialist = (TeamOrPersonBase) getAgentService().find(agentUuid); |
|
975 |
if (associatedSpecialist != null && taxonNode != null){ |
|
976 |
agentRel =taxonNode.addAgentRelation(FaunaEuropaeaTransformer.getAssociateSpecialistType(getTermService()), associatedSpecialist); |
|
977 |
if (!StringUtils.isBlank(groupName)) |
|
978 |
agentRel.addAnnotation(Annotation.NewInstance(groupName, Language.DEFAULT())); |
|
979 |
} |
|
980 |
|
|
981 |
|
|
982 |
} |
|
983 |
getTaxonNodeService().saveOrUpdate(taxonNode); |
|
984 |
commitTransaction(txStatus); |
|
985 |
}catch(SQLException e){ |
|
986 |
logger.info("Problems during creating associated specialists.", e); |
|
987 |
} |
|
988 |
} |
|
989 |
|
|
884 | 990 |
|
885 | 991 |
} |
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/faunaEuropaea/FaunaEuropaeaTaxonNameImport.java | ||
---|---|---|
98 | 98 |
@Override |
99 | 99 |
protected void doInvoke(FaunaEuropaeaImportState state) { |
100 | 100 |
if(logger.isInfoEnabled()) { logger.info("Start making taxa..."); } |
101 |
|
|
101 |
if (state.getConfig().isDoTaxa()){ |
|
102 |
return; |
|
103 |
} |
|
102 | 104 |
processTaxa(state); |
103 | 105 |
logger.info("End making taxa..."); |
104 | 106 |
return; |
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/faunaEuropaea/FaunaEuropaeaTransformer.java | ||
---|---|---|
16 | 16 |
|
17 | 17 |
import org.apache.log4j.Logger; |
18 | 18 |
|
19 |
import eu.etaxonomy.cdm.api.application.CdmApplicationUtils; |
|
19 | 20 |
import eu.etaxonomy.cdm.api.service.ITermService; |
20 | 21 |
import eu.etaxonomy.cdm.io.common.TdwgAreaProvider; |
21 | 22 |
import eu.etaxonomy.cdm.model.common.DefinedTerm; |
23 |
import eu.etaxonomy.cdm.model.common.LSID; |
|
22 | 24 |
import eu.etaxonomy.cdm.model.common.Language; |
23 | 25 |
import eu.etaxonomy.cdm.model.common.Representation; |
24 | 26 |
import eu.etaxonomy.cdm.model.common.TermType; |
... | ... | |
334 | 336 |
tdwgArea = TdwgAreaProvider.getAreaByTdwgAbbreviation("ITA-SM"); |
335 | 337 |
} else if (areaCode.equals("TR-TUE")) { |
336 | 338 |
tdwgArea = TdwgAreaProvider.getAreaByTdwgAbbreviation("TUE-OO"); |
337 |
//else if (areaCode.equals("UA")) tdwgArea = TdwgAreaProvider.getAreaByTdwgAbbreviation("UKR-UK"); //UKraine including Crimea |
|
339 |
}else if (areaCode.equals("UA")) { |
|
340 |
tdwgArea = TdwgAreaProvider.getAreaByTdwgAbbreviation("UKR-UK"); //UKraine including Crimea |
|
338 | 341 |
} else if (areaCode.equals("VA")) { |
339 | 342 |
tdwgArea = TdwgAreaProvider.getAreaByTdwgAbbreviation("ITA-VC"); |
340 | 343 |
} else if (areaCode.equals("YU")) { |
... | ... | |
400 | 403 |
public final static HashMap<Integer, Language> languageFK2Language = new HashMap<Integer,Language>(); |
401 | 404 |
static |
402 | 405 |
{ |
406 |
languageFK2Language.put(1, Language.ALBANIAN()); |
|
407 |
languageFK2Language.put(4, Language.AZERBAIJANI()); |
|
408 |
languageFK2Language.put(6, Language.BULGARIAN()); |
|
403 | 409 |
languageFK2Language.put(10, Language.DANISH()); |
404 |
languageFK2Language.put(19, Language.GREEK_MODERN()); |
|
410 |
languageFK2Language.put(11, Language.DUTCH_MIDDLE()); |
|
411 |
languageFK2Language.put(12, Language.ENGLISH()); |
|
412 |
languageFK2Language.put(16, Language.FRENCH()); |
|
413 |
|
|
405 | 414 |
languageFK2Language.put(18, Language.GERMAN()); |
406 |
languageFK2Language.put(59, Language.UKRAINIAN());
|
|
407 |
languageFK2Language.put(83, Language.ENGLISH());
|
|
408 |
languageFK2Language.put(58, Language.TURKISH());
|
|
415 |
languageFK2Language.put(19, Language.GREEK_MODERN());
|
|
416 |
languageFK2Language.put(23, Language.HEBREW());
|
|
417 |
languageFK2Language.put(24, Language.ITALIAN());
|
|
409 | 418 |
languageFK2Language.put(26, Language.LITHUANIAN()); |
419 |
languageFK2Language.put(30, Language.NORWEGIAN()); |
|
420 |
languageFK2Language.put(31, Language.POLISH()); |
|
410 | 421 |
languageFK2Language.put(34, Language.RUSSIAN()); |
422 |
languageFK2Language.put(54, Language.SLOVAK()); |
|
411 | 423 |
languageFK2Language.put(55, Language.SLOVENIAN()); |
412 | 424 |
languageFK2Language.put(57, Language.SWEDISH()); |
413 |
languageFK2Language.put(11, Language.DUTCH_MIDDLE()); |
|
425 |
languageFK2Language.put(58, Language.TURKISH()); |
|
426 |
|
|
427 |
languageFK2Language.put(59, Language.UKRAINIAN()); |
|
428 |
languageFK2Language.put(60, Language.WELSH()); |
|
429 |
languageFK2Language.put(62, Language.GALICIAN()); |
|
430 |
//languageFK2Language.put(83, getEnglishUS()); |
|
431 |
languageFK2Language.put(97, Language.IRISH()); |
|
432 |
|
|
433 |
|
|
414 | 434 |
languageFK2Language.put(100, Language.NORWEGIAN_BOKMOL()); |
415 | 435 |
languageFK2Language.put(101, Language.NORWEGIAN_NYNORSK()); |
436 |
|
|
437 |
languageFK2Language.put(102, Language.ARABIC()); |
|
438 |
languageFK2Language.put(103, Language.ARMENIAN()); |
|
439 |
|
|
440 |
languageFK2Language.put(104, Language.CATALAN_VALENCIAN()); |
|
441 |
languageFK2Language.put(105, Language.CHINESE()); |
|
442 |
languageFK2Language.put(106, Language.ESTONIAN()); |
|
443 |
languageFK2Language.put(107, Language.FINNISH()); |
|
444 |
|
|
445 |
languageFK2Language.put(108, Language.GAELIC_SCOTTISH_GAELIC()); |
|
446 |
languageFK2Language.put(109, Language.JAPANESE()); |
|
447 |
languageFK2Language.put(110, Language.KOREAN()); |
|
448 |
languageFK2Language.put(111, Language.LATIN()); |
|
449 |
languageFK2Language.put(112, Language.LATVIAN()); |
|
450 |
languageFK2Language.put(113, Language.PERSIAN()); |
|
451 |
languageFK2Language.put(114, Language.PORTUGUESE()); |
|
452 |
languageFK2Language.put(115, Language.ROMANIAN()); |
|
453 |
languageFK2Language.put(117, Language.SWAHILI()); |
|
454 |
languageFK2Language.put(118, Language.SPANISH_CASTILIAN()); |
|
455 |
|
|
456 |
|
|
416 | 457 |
|
417 | 458 |
|
418 | 459 |
|
... | ... | |
437 | 478 |
|
438 | 479 |
private static UUID uuidAssociateSpecialistType = UUID.fromString("8258f73c-e0ad-4f87-a88c-53c58c08bba9"); |
439 | 480 |
|
481 |
private static Language langEnglishUS; |
|
482 |
|
|
483 |
private static UUID uuidEnglishUS; |
|
484 |
|
|
485 |
|
|
486 |
|
|
440 | 487 |
public static NomenclaturalStatusType getNomStatusTempNamed(ITermService termService){ |
441 | 488 |
if (nomStatusTempNamed == null){ |
442 | 489 |
nomStatusTempNamed = (NomenclaturalStatusType)termService.find(uuidNomStatusTempNamed); |
... | ... | |
451 | 498 |
} |
452 | 499 |
return nomStatusTempNamed; |
453 | 500 |
} |
501 |
|
|
502 |
public static Language getEnglishUS(ITermService termService){ |
|
503 |
if (langEnglishUS == null){ |
|
504 |
langEnglishUS = (Language)termService.find(uuidEnglishUS); |
|
505 |
if (langEnglishUS == null){ |
|
506 |
logger.info("create language english-us"); |
|
507 |
langEnglishUS = Language.NewInstance("english-United States", "english-US", "eng-US"); |
|
508 |
langEnglishUS.setUuid(uuidEnglishUS); |
|
509 |
|
|
510 |
langEnglishUS = (Language)termService.save(langEnglishUS); |
|
511 |
languageFK2Language.put(83, langEnglishUS); |
|
512 |
} |
|
513 |
} |
|
514 |
return langEnglishUS; |
|
515 |
} |
|
454 | 516 |
/** |
455 | 517 |
* @return |
456 | 518 |
*/ |
... | ... | |
458 | 520 |
if (taxonomicSpecialistType == null){ |
459 | 521 |
taxonomicSpecialistType = (DefinedTerm)termService.find(uuidTaxonomicSpecialistType); |
460 | 522 |
if (taxonomicSpecialistType == null){ |
523 |
logger.info("create associated specialist type"); |
|
461 | 524 |
taxonomicSpecialistType = DefinedTerm.NewInstance(TermType.TaxonNodeAgentRelationType, "taxonomic specialist", "taxonomic specialist", "TS"); |
462 | 525 |
|
463 | 526 |
taxonomicSpecialistType.setUuid(uuidTaxonomicSpecialistType); |
... | ... | |
467 | 530 |
} |
468 | 531 |
return taxonomicSpecialistType; |
469 | 532 |
} |
533 |
|
|
534 |
|
|
535 |
|
|
536 |
|
|
470 | 537 |
/** |
471 | 538 |
* @return |
472 | 539 |
*/ |
... | ... | |
484 | 551 |
return groupCoordinatorType; |
485 | 552 |
} |
486 | 553 |
|
554 |
|
|
555 |
|
|
487 | 556 |
/** |
488 | 557 |
* @return |
489 | 558 |
*/ |
... | ... | |
501 | 570 |
return associateSpecialistType; |
502 | 571 |
} |
503 | 572 |
public static Language langFK2Language( |
504 |
int languageFk) { |
|
573 |
Integer languageFk) { |
|
574 |
|
|
575 |
Language result = languageFK2Language.get(languageFk); |
|
505 | 576 |
|
506 |
return null;
|
|
577 |
return result;
|
|
507 | 578 |
} |
508 | 579 |
|
509 | 580 |
|
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/faunaEuropaea/FaunaEuropaeaUsersImport.java | ||
---|---|---|
85 | 85 |
logger.warn("Start User doInvoke"); |
86 | 86 |
ProfilerController.memorySnapshot(); |
87 | 87 |
*/ |
88 |
|
|
88 |
if (state.getConfig().isDoAuthors()){ |
|
89 |
return; |
|
90 |
} |
|
89 | 91 |
TransactionStatus txStatus = null; |
90 | 92 |
Map<String, Person> persons = null; |
91 | 93 |
Map<String, User> users= null; |
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/faunaEuropaea/FaunaEuropaeaVernacularName.java | ||
---|---|---|
10 | 10 |
UUID taxonUuid; |
11 | 11 |
String guid; |
12 | 12 |
String source; |
13 |
String area = ""; |
|
13 | 14 |
|
15 |
public String getArea() { |
|
16 |
return area; |
|
17 |
} |
|
18 |
|
|
19 |
public void setArea(String area) { |
|
20 |
this.area = area; |
|
21 |
} |
|
22 |
|
|
14 | 23 |
public String getVernacularName() { |
15 | 24 |
return vernacularName; |
16 | 25 |
} |
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/faunaEuropaea/FaunaEuropaeaVernacularNamesImport.java | ||
---|---|---|
14 | 14 |
import java.util.Map.Entry; |
15 | 15 |
|
16 | 16 |
import org.apache.log4j.Logger; |
17 |
import org.springframework.stereotype.Component; |
|
17 | 18 |
import org.springframework.transaction.TransactionStatus; |
18 | 19 |
|
19 | 20 |
import eu.etaxonomy.cdm.io.common.Source; |
21 |
import eu.etaxonomy.cdm.jaxb.TDWGNamespacePrefixMapper; |
|
20 | 22 |
import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase; |
21 | 23 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
22 | 24 |
import eu.etaxonomy.cdm.model.common.Language; |
23 | 25 |
import eu.etaxonomy.cdm.model.common.OriginalSourceType; |
26 |
import eu.etaxonomy.cdm.model.common.TermType; |
|
24 | 27 |
import eu.etaxonomy.cdm.model.common.TermVocabulary; |
25 | 28 |
import eu.etaxonomy.cdm.model.description.CommonTaxonName; |
26 | 29 |
import eu.etaxonomy.cdm.model.description.DescriptionElementSource; |
... | ... | |
30 | 33 |
import eu.etaxonomy.cdm.model.location.NamedArea; |
31 | 34 |
import eu.etaxonomy.cdm.model.reference.Reference; |
32 | 35 |
import eu.etaxonomy.cdm.model.reference.ReferenceFactory; |
36 |
import eu.etaxonomy.cdm.model.taxon.Synonym; |
|
33 | 37 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
34 | 38 |
import eu.etaxonomy.cdm.model.taxon.TaxonBase; |
35 | 39 |
|
40 |
@Component |
|
36 | 41 |
public class FaunaEuropaeaVernacularNamesImport extends FaunaEuropaeaImportBase { |
37 | 42 |
private static final Logger logger = Logger.getLogger(FaunaEuropaeaVernacularNamesImport.class); |
38 | 43 |
|
... | ... | |
42 | 47 |
protected void doInvoke(FaunaEuropaeaImportState state) { |
43 | 48 |
int limit = state.getConfig().getLimitSave(); |
44 | 49 |
|
45 |
/* Taxon store for retrieving taxa from and saving taxa to CDM */ |
|
46 |
List<TaxonBase> taxonList = null; |
|
47 |
/* UUID store as input for retrieving taxa from CDM */ |
|
48 |
Set<UUID> taxonUuids = null; |
|
49 |
/* Store to hold helper objects */ |
|
50 |
Map<UUID, FaunaEuropaeaVernacularNamesTaxon> fauEuVernacularNamesMap = null; |
|
51 |
|
|
52 |
|
|
53 |
TransactionStatus txStatus = null; |
|
54 |
|
|
55 |
createSourceMap(state); |
|
56 |
|
|
57 |
FaunaEuropaeaImportConfigurator fauEuConfig = state.getConfig(); |
|
58 |
Source source = fauEuConfig.getSource(); |
|
59 |
|
|
60 |
int i = 0; |
|
61 |
|
|
62 |
String selectCount = |
|
63 |
" SELECT count(*) "; |
|
64 |
|
|
65 |
String selectColumns = |
|
66 |
" SELECT vernacularName.*, Taxon.UUID "; |
|
67 |
|
|
68 |
String fromClause = |
|
69 |
" FROM vernacularName INNER JOIN " + |
|
70 |
" Taxon ON vernacularname.taxon_UUID = Taxon.UUID "; |
|
71 |
String orderBy = " ORDER BY vernacularName.taxon_UUID"; |
|
72 |
|
|
73 |
String countQuery = |
|
74 |
selectCount + fromClause; |
|
75 |
|
|
76 |
String selectQuery = |
|
77 |
selectColumns + fromClause + orderBy; |
|
78 |
|
|
79 |
|
|
80 |
|
|
81 |
if(logger.isInfoEnabled()) { logger.info("Start making distributions..."); } |
|
82 |
|
|
83 |
try { |
|
84 |
ResultSet rs = source.getResultSet(countQuery); |
|
85 |
rs.next(); |
|
86 |
int count = rs.getInt(1); |
|
87 |
|
|
88 |
rs = source.getResultSet(selectQuery); |
|
89 |
|
|
90 |
if (logger.isInfoEnabled()) { |
|
91 |
logger.info("Number of rows: " + count); |
|
92 |
logger.info("Count Query: " + countQuery); |
|
93 |
logger.info("Select Query: " + selectQuery); |
|
94 |
} |
|
95 |
|
|
96 |
//int taxonId; |
|
97 |
|
|
98 |
while (rs.next()) { |
|
99 |
if ((i++ % limit) == 0) { |
|
100 |
|
|
101 |
txStatus = startTransaction(); |
|
102 |
taxonUuids = new HashSet<UUID>(limit); |
|
103 |
fauEuVernacularNamesMap = new HashMap<UUID, FaunaEuropaeaVernacularNamesTaxon>(limit); |
|
104 |
|
|
105 |
if(logger.isInfoEnabled()) { |
|
106 |
logger.info("i = " + i + " - Distribution import transaction started"); |
|
107 |
} |
|
50 |
if (state.getConfig().isDoVernacularNames()){ |
|
51 |
/* Taxon store for retrieving taxa from and saving taxa to CDM */ |
|
52 |
List<TaxonBase> taxonList = null; |
|
53 |
/* UUID store as input for retrieving taxa from CDM */ |
|
54 |
Set<UUID> taxonUuids = null; |
|
55 |
/* Store to hold helper objects */ |
|
56 |
Map<UUID, FaunaEuropaeaVernacularNamesTaxon> fauEuVernacularNamesMap = null; |
|
57 |
|
|
58 |
|
|
59 |
TransactionStatus txStatus = null; |
|
60 |
|
|
61 |
createSourceMap(state); |
|
62 |
|
|
63 |
FaunaEuropaeaImportConfigurator fauEuConfig = state.getConfig(); |
|
64 |
Source source = fauEuConfig.getSource(); |
|
65 |
|
|
66 |
int i = 0; |
|
67 |
|
|
68 |
String selectCount = |
|
69 |
" SELECT count(*) "; |
|
70 |
|
|
71 |
String selectColumns = |
|
72 |
" SELECT vernacularNames.*, Taxon.UUID "; |
|
73 |
|
|
74 |
String fromClause = |
|
75 |
" FROM vernacularNames INNER JOIN " + |
|
76 |
" Taxon ON vernacularnames.UUID = Taxon.UUID "; |
|
77 |
String orderBy = " ORDER BY vernacularNames.UUID"; |
|
78 |
|
|
79 |
String countQuery = |
|
80 |
selectCount + fromClause; |
|
81 |
|
|
82 |
String selectQuery = |
|
83 |
selectColumns + fromClause + orderBy; |
|
84 |
|
|
85 |
|
|
86 |
|
|
87 |
if(logger.isInfoEnabled()) { logger.info("Start making vernacular names..."); } |
|
88 |
|
|
89 |
try { |
|
90 |
ResultSet rs = source.getResultSet(countQuery); |
|
91 |
rs.next(); |
|
92 |
int count = rs.getInt(1); |
|
93 |
|
|
94 |
rs = source.getResultSet(selectQuery); |
|
95 |
|
|
96 |
if (logger.isInfoEnabled()) { |
|
97 |
logger.info("Number of rows: " + count); |
|
98 |
logger.info("Count Query: " + countQuery); |
|
99 |
logger.info("Select Query: " + selectQuery); |
|
108 | 100 |
} |
109 |
|
|
110 |
//taxonId = rs.getInt("dis_tax_id"); |
|
111 |
String vernameGUID = rs.getString("GUID"); |
|
112 |
String vernacularNameString = rs.getString("verName"); |
|
113 |
int taxonFk = rs.getInt("taxonFK"); |
|
114 |
int languageFK= rs.getInt("languageFK"); |
|
115 |
String languageCache = rs.getString("languageCache"); |
|
116 |
String taxonUUID= rs.getString("taxonUUID"); |
|
117 |
String verSource = rs.getString("VerSource"); |
|
118 |
UUID currentTaxonUuid = null; |
|
119 |
|
|
120 |
|
|
121 |
FaunaEuropaeaVernacularName fauEuVernacularName = new FaunaEuropaeaVernacularName(); |
|
122 |
fauEuVernacularName.setGuid(vernameGUID); |
|
123 |
fauEuVernacularName.setLanguageCache(languageCache); |
|
124 |
fauEuVernacularName.setLanguageFk(languageFK); |
|
125 |
fauEuVernacularName.setVernacularName(vernacularNameString); |
|
126 |
fauEuVernacularName.setSource(verSource); |
|
127 |
|
|
128 |
if (!taxonUuids.contains(currentTaxonUuid)) { |
|
129 |
taxonUuids.add(currentTaxonUuid); |
|
130 |
FaunaEuropaeaVernacularNamesTaxon fauEuVernacularNameTaxon = |
|
131 |
new FaunaEuropaeaVernacularNamesTaxon(currentTaxonUuid); |
|
132 |
fauEuVernacularNamesMap.put(currentTaxonUuid, fauEuVernacularNameTaxon); |
|
133 |
fauEuVernacularNameTaxon = null; |
|
134 |
} else { |
|
135 |
if (logger.isTraceEnabled()) { |
|
136 |
logger.trace("Taxon (" + currentTaxonUuid + ") already stored."); |
|
137 |
continue; |
|
101 |
|
|
102 |
//int taxonId; |
|
103 |
|
|
104 |
while (rs.next()) { |
|
105 |
if ((i++ % limit) == 0) { |
|
106 |
|
|
107 |
txStatus = startTransaction(); |
|
108 |
taxonUuids = new HashSet<UUID>(limit); |
|
109 |
fauEuVernacularNamesMap = new HashMap<UUID, FaunaEuropaeaVernacularNamesTaxon>(limit); |
|
110 |
|
|
111 |
if(logger.isInfoEnabled()) { |
|
112 |
logger.info("i = " + i + " - vernacular names import transaction started"); |
|
113 |
} |
|
114 |
} |
|
115 |
|
|
116 |
//taxonId = rs.getInt("dis_tax_id"); |
|
117 |
String vernameGUID = rs.getString("GUID"); |
|
118 |
String vernacularNameString = rs.getString("verName"); |
|
119 |
//int taxonFk = rs.getInt("taxonFK"); |
|
120 |
int languageFK= rs.getInt("languageFK"); |
|
121 |
String languageCache = rs.getString("languageCache"); |
|
122 |
String taxonUUID= rs.getString("UUID"); |
|
123 |
String verSource = rs.getString("VerSource"); |
|
124 |
UUID currentTaxonUuid = null; |
|
125 |
|
|
126 |
|
|
127 |
FaunaEuropaeaVernacularName fauEuVernacularName = new FaunaEuropaeaVernacularName(); |
|
128 |
fauEuVernacularName.setGuid(vernameGUID); |
|
129 |
fauEuVernacularName.setLanguageCache(languageCache); |
|
130 |
fauEuVernacularName.setLanguageFk(languageFK); |
|
131 |
fauEuVernacularName.setVernacularName(vernacularNameString); |
|
132 |
fauEuVernacularName.setSource(verSource); |
|
133 |
fauEuVernacularName.setTaxonUuid(UUID.fromString(taxonUUID)); |
|
134 |
currentTaxonUuid =UUID.fromString(taxonUUID); |
|
135 |
if (!taxonUuids.contains(currentTaxonUuid)) { |
|
136 |
taxonUuids.add(currentTaxonUuid); |
|
137 |
FaunaEuropaeaVernacularNamesTaxon fauEuVernacularNameTaxon = |
|
138 |
new FaunaEuropaeaVernacularNamesTaxon(currentTaxonUuid); |
|
139 |
fauEuVernacularNamesMap.put(currentTaxonUuid, fauEuVernacularNameTaxon); |
|
140 |
fauEuVernacularNameTaxon = null; |
|
141 |
} else { |
|
142 |
if (logger.isTraceEnabled()) { |
|
143 |
logger.trace("Taxon (" + currentTaxonUuid + ") already stored."); |
|
144 |
continue; |
|
145 |
} |
|
146 |
} |
|
147 |
|
|
148 |
fauEuVernacularNamesMap.get(currentTaxonUuid).addVernacularName(fauEuVernacularName); |
|
149 |
|
|
150 |
if (((i % limit) == 0 && i != 1 ) || i == count ) { |
|
151 |
|
|
152 |
try { |
|
153 |
commitTaxaAndVernacularNames(state, taxonUuids, fauEuVernacularNamesMap, txStatus); |
|
154 |
taxonUuids = null; |
|
155 |
taxonList = null; |
|
156 |
fauEuVernacularNamesMap = null; |
|
157 |
|
|
158 |
} catch (Exception e) { |
|
159 |
logger.error("Commit of taxa and distributions failed" + e.getMessage()); |
|
160 |
e.printStackTrace(); |
|
161 |
} |
|
162 |
|
|
163 |
if(logger.isInfoEnabled()) { logger.info("i = " + i + " - Transaction committed");} |
|
138 | 164 |
} |
165 |
|
|
166 |
|
|
139 | 167 |
} |
140 |
|
|
141 |
fauEuVernacularNamesMap.get(currentTaxonUuid).addVernacularName(fauEuVernacularName); |
|
142 |
|
|
143 |
if (((i % limit) == 0 && i != 1 ) || i == count ) { |
|
144 |
|
|
168 |
if (taxonUuids != null){ |
|
145 | 169 |
try { |
146 |
commitTaxaAndVernacularNames(state, taxonUuids, fauEuVernacularNamesMap, txStatus);
|
|
170 |
commitTaxaAndVernacularNames(state, taxonUuids, fauEuVernacularNamesMap, txStatus); |
|
147 | 171 |
taxonUuids = null; |
148 | 172 |
taxonList = null; |
149 | 173 |
fauEuVernacularNamesMap = null; |
150 |
|
|
151 | 174 |
} catch (Exception e) { |
152 |
logger.error("Commit of taxa and distributions failed" + e.getMessage()); |
|
175 |
logger.error("Commit of taxa and vernacular names failed"); |
|
176 |
logger.error(e.getMessage()); |
|
153 | 177 |
e.printStackTrace(); |
154 | 178 |
} |
155 |
|
|
156 |
if(logger.isInfoEnabled()) { logger.info("i = " + i + " - Transaction committed");} |
|
157 |
} |
|
158 |
|
|
159 |
|
|
160 |
} |
|
161 |
if (taxonUuids != null){ |
|
162 |
try { |
|
163 |
commitTaxaAndVernacularNames(state, taxonUuids, fauEuVernacularNamesMap, txStatus); |
|
164 |
taxonUuids = null; |
|
165 |
taxonList = null; |
|
166 |
fauEuVernacularNamesMap = null; |
|
167 |
} catch (Exception e) { |
|
168 |
logger.error("Commit of taxa and distributions failed"); |
|
169 |
logger.error(e.getMessage()); |
|
170 |
e.printStackTrace(); |
|
171 | 179 |
} |
180 |
rs = null; |
|
181 |
} catch (SQLException e) { |
|
182 |
logger.error("SQLException:" + e); |
|
183 |
state.setUnsuccessfull(); |
|
172 | 184 |
} |
173 |
rs = null; |
|
174 |
} catch (SQLException e) {
|
|
175 |
logger.error("SQLException:" + e); |
|
176 |
state.setUnsuccessfull();
|
|
185 |
|
|
186 |
if(logger.isInfoEnabled()) { logger.info("End making vernacular names..."); }
|
|
187 |
|
|
188 |
return;
|
|
177 | 189 |
} |
178 | 190 |
|
179 |
if(logger.isInfoEnabled()) { logger.info("End making distributions..."); } |
|
180 |
|
|
181 |
return; |
|
182 |
|
|
183 | 191 |
} |
184 | 192 |
|
185 | 193 |
@Override |
... | ... | |
198 | 206 |
Set<UUID> taxonUuids, |
199 | 207 |
Map<UUID, FaunaEuropaeaVernacularNamesTaxon> fauEuTaxonMap, |
200 | 208 |
TransactionStatus txStatus) throws Exception { |
201 |
List<TaxonBase> taxonList = prepareTaxaAndVernacularNames(getTaxonService().find(taxonUuids), fauEuTaxonMap, state);
|
|
209 |
List<TaxonBase> taxonList = prepareTaxaAndVernacularNames(getTaxonService().find(taxonUuids), fauEuTaxonMap, state); |
|
202 | 210 |
|
203 |
getTaxonService().save(taxonList); |
|
211 |
getTaxonService().saveOrUpdate(taxonList);
|
|
204 | 212 |
taxonList = null; |
205 | 213 |
taxonUuids = null; |
206 | 214 |
fauEuTaxonMap = null; |
... | ... | |
224 | 232 |
if (taxonBase instanceof Taxon) { |
225 | 233 |
taxon = CdmBase.deproxy(taxonBase, Taxon.class); |
226 | 234 |
} else { |
235 |
Synonym syn = CdmBase.deproxy(taxonBase, Synonym.class); |
|
236 |
if (syn.getAcceptedTaxa().size()>0){ |
|
237 |
taxon = syn.getAcceptedTaxa().iterator().next(); |
|
238 |
} |
|
227 | 239 |
logger.warn("TaxonBase (" + taxonBase.getId() + " is not of type Taxon but: " |
228 |
+ taxonBase.getClass().getSimpleName()); |
|
240 |
+ taxonBase.getClass().getSimpleName() + " using accepted Taxon for vernacular name");
|
|
229 | 241 |
continue; |
230 | 242 |
} |
231 | 243 |
|
232 | 244 |
|
233 | 245 |
Set<TaxonDescription> descriptionSet = taxon.getDescriptions(); |
234 |
if (descriptionSet.size() > 0) { |
|
235 |
taxonDescription = descriptionSet.iterator().next(); |
|
236 |
} else { |
|
237 |
taxonDescription = TaxonDescription.NewInstance(); |
|
238 |
taxon.addDescription(taxonDescription); |
|
239 |
} |
|
246 |
taxonDescription = TaxonDescription.NewInstance(); |
|
247 |
taxon.addDescription(taxonDescription); |
|
248 |
|
|
240 | 249 |
|
241 | 250 |
taxonUuid = taxonBase.getUuid(); |
242 | 251 |
fauEuHelperTaxon= fauEuTaxonMap.get(taxonUuid); |
... | ... | |
244 | 253 |
for (FaunaEuropaeaVernacularName fauEuHelperVernacularName: fauEuHelperTaxon.getVernacularNames()) { |
245 | 254 |
|
246 | 255 |
verName = null; |
256 |
|
|
257 |
/* |
|
258 |
* UUID uuid = state.getTransformer().getLanguageUuid(languageKey); |
|
259 |
result = (Language)getTermService().find(uuid); |
|
260 |
} |
|
261 |
if (result == null){ |
|
262 |
result = state.getTransformer().getLanguageByKey(languageKey); |
|
263 |
if (result == null){ |
|
264 |
UUID uuidLanguage; |
|
265 |
uuidLanguage = state.getTransformer().getLanguageUuid(languageKey); |
|
266 |
if (uuidLanguage == null){ |
|
267 |
logger.warn("Language not defined: " + languageKey) ; |
|
268 |
} |
|
269 |
result = getLanguage(state, uuidLanguage, languageKey, languageKey, null); |
|
270 |
if (result == null){ |
|
271 |
logger.warn("Language not defined: " + languageKey) ; |
|
272 |
} |
|
273 |
}else if (result.getId() == 0){ |
|
274 |
// UUID uuidLanguageVoc = UUID.fromString("45ac7043-7f5e-4f37-92f2-3874aaaef2de"); |
|
275 |
UUID uuidLanguageVoc = UUID.fromString("434cea89-9052-4567-b2db-ff77f42e9084"); |
|
276 |
TermVocabulary<Language> voc = getVocabulary(TermType.Language, uuidLanguageVoc, "User Defined Languages", "User Defined Languages", null, null, false, result); |
|
277 |
// TermVocabulary<Language> voc = getVocabularyService().find(uuidLanguageVoc); |
|
278 |
voc.addTerm(result); |
|
279 |
getTermService().saveOrUpdate(result); |
|
280 |
state.putLanguage(result); |
|
281 |
} |
|
282 |
* |
|
283 |
*/ |
|
247 | 284 |
Language lang = FaunaEuropaeaTransformer.langFK2Language(fauEuHelperVernacularName.getLanguageFk()); |
285 |
if (lang == null && fauEuHelperVernacularName.getLanguageFk() == 83){ |
|
286 |
lang = Language.ENGLISH(); |
|
287 |
fauEuHelperVernacularName.setArea("USA"); |
|
288 |
} |
|
289 |
|
|
290 |
if (lang == null){ |
|
291 |
UUID uuidLanguageVoc = UUID.fromString("434cea89-9052-4567-b2db-ff77f42e9084"); |
|
292 |
logger.info("languageFk = " + fauEuHelperVernacularName.getLanguageFk()); |
|
293 |
TermVocabulary<Language> voc = getVocabulary(TermType.Language, uuidLanguageVoc, "User Defined Languages", "User Defined Languages", null, null, false, lang); |
|
294 |
lang = Language.NewInstance("Dummy", "", ""); |
|
295 |
voc.addTerm(lang); |
|
296 |
lang =(Language)getTermService().save(lang); |
|
297 |
FaunaEuropaeaTransformer.languageFK2Language.put(fauEuHelperVernacularName.getLanguageFk(), lang); |
|
298 |
} |
|
299 |
// if (lang.getId() == 0){ |
|
300 |
// UUID uuidLanguageVoc = UUID.fromString("434cea89-9052-4567-b2db-ff77f42e9084"); |
|
301 |
// TermVocabulary<Language> voc = getVocabulary(TermType.Language, uuidLanguageVoc, "User Defined Languages", "User Defined Languages", null, null, false, lang); |
|
302 |
// voc.addTerm(lang); |
|
303 |
// lang =(Language)getTermService().save(lang); |
|
304 |
// //FaunaEuropaeaTransformer.languageFK2Language.put(fauEuHelperVernacularName.getLanguageFk(), lang); |
|
305 |
// } |
|
306 |
|
|
248 | 307 |
verName = CommonTaxonName.NewInstance(fauEuHelperVernacularName.getVernacularName(), lang); |
308 |
if (fauEuHelperVernacularName.getArea()!= null && fauEuHelperVernacularName.getArea().equals("USA")){ |
|
309 |
verName.setArea(NamedArea.NORTH_AMERICA()); |
|
310 |
} |
|
249 | 311 |
verName.setCreated(null); |
250 | 312 |
addOriginalSource(verName, null, null, sourceMap.get(fauEuHelperVernacularName.getSource())); |
251 | 313 |
taxonDescription.addElement(verName); |
... | ... | |
260 | 322 |
FaunaEuropaeaImportConfigurator fauEuConfig = state.getConfig(); |
261 | 323 |
Source source = fauEuConfig.getSource(); |
262 | 324 |
TransactionStatus txStatus = null; |
263 |
String sourceSelect = "SELECT DISTINCT PESI_FaEu_vernaculars_export.VerSource FROM PESI_FaEu_vernaculars_export group by PESI_FaEu_vernaculars_export.VerSource";
|
|
325 |
String sourceSelect = "SELECT DISTINCT vernacularNames.VerSource FROM vernacularNames group by vernacularNames.VerSource";
|
|
264 | 326 |
try { |
265 | 327 |
txStatus =startTransaction(); |
266 | 328 |
ResultSet rs = source.getResultSet(sourceSelect); |
... | ... | |
291 | 353 |
String refID = ref.getTitle(); |
292 | 354 |
sourceMap.put(refID, ref); |
293 | 355 |
} |
356 |
|
|
294 | 357 |
commitTransaction(txStatus); |
295 | 358 |
} |
296 | 359 |
} |
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/faunaEuropaea/FaunaEuropaeaVernacularNamesTaxon.java | ||
---|---|---|
1 | 1 |
package eu.etaxonomy.cdm.io.pesi.faunaEuropaea; |
2 | 2 |
|
3 |
import java.util.HashSet; |
|
3 | 4 |
import java.util.Set; |
4 | 5 |
import java.util.UUID; |
5 | 6 |
|
... | ... | |
7 | 8 |
|
8 | 9 |
private UUID taxonUuid; |
9 | 10 |
private int taxonId; |
10 |
private Set<FaunaEuropaeaVernacularName> vernacularNames; |
|
11 |
private Set<FaunaEuropaeaVernacularName> vernacularNames = new HashSet<FaunaEuropaeaVernacularName>();
|
|
11 | 12 |
|
12 | 13 |
public FaunaEuropaeaVernacularNamesTaxon(UUID currentTaxonUuid) { |
13 | 14 |
this.taxonUuid = currentTaxonUuid; |
Also available in: Unified diff
changes for fauna europaea import