Revision bac828e0
Added by Patrick Plitzner almost 8 years ago
app-import/src/main/java/eu/etaxonomy/cdm/io/redlist/gefaesspflanzen/RedListGefaesspflanzenImportClassification.java | ||
---|---|---|
21 | 21 |
import org.springframework.stereotype.Component; |
22 | 22 |
|
23 | 23 |
import eu.etaxonomy.cdm.common.CdmUtils; |
24 |
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper; |
|
24 | 25 |
import eu.etaxonomy.cdm.io.common.DbImportBase; |
25 | 26 |
import eu.etaxonomy.cdm.io.common.IPartitionedIO; |
26 | 27 |
import eu.etaxonomy.cdm.io.common.ResultSetPartitioner; |
... | ... | |
134 | 135 |
if(parentGL!=null && parentCL!=null && parentGL.getUuid().equals(parentCL.getUuid())){ |
135 | 136 |
RedListUtil.logMessage(id, "Same UUID for "+parentGL+ " (Gesamtliste) and "+parentCL+" (Checkliste)", logger); |
136 | 137 |
} |
138 |
|
|
139 |
//add taxa for concept relationships to E, W, K, AW, AO, R, O, S |
|
140 |
addTaxonToClassification(RedListUtil.uuidClassificationE, RedListUtil.CLASSIFICATION_NAMESPACE_E, id, state); |
|
141 |
addTaxonToClassification(RedListUtil.uuidClassificationW, RedListUtil.CLASSIFICATION_NAMESPACE_W, id, state); |
|
142 |
addTaxonToClassification(RedListUtil.uuidClassificationK, RedListUtil.CLASSIFICATION_NAMESPACE_K, id, state); |
|
143 |
addTaxonToClassification(RedListUtil.uuidClassificationAW, RedListUtil.CLASSIFICATION_NAMESPACE_AW, id, state); |
|
144 |
addTaxonToClassification(RedListUtil.uuidClassificationAO, RedListUtil.CLASSIFICATION_NAMESPACE_AO, id, state); |
|
145 |
addTaxonToClassification(RedListUtil.uuidClassificationR, RedListUtil.CLASSIFICATION_NAMESPACE_R, id, state); |
|
146 |
addTaxonToClassification(RedListUtil.uuidClassificationO, RedListUtil.CLASSIFICATION_NAMESPACE_O, id, state); |
|
147 |
addTaxonToClassification(RedListUtil.uuidClassificationS, RedListUtil.CLASSIFICATION_NAMESPACE_S, id, state); |
|
148 |
} |
|
149 |
|
|
150 |
private void addTaxonToClassification(UUID classificationUuid, String classificationNamespace, long id, RedListGefaesspflanzenImportState state){ |
|
151 |
Taxon taxon = HibernateProxyHelper.deproxy(state.getRelatedObject(classificationNamespace, String.valueOf(id), TaxonBase.class), Taxon.class); |
|
152 |
Classification classification = getClassificationService().load(classificationUuid); |
|
153 |
classification.addChildTaxon(taxon, null, null); |
|
137 | 154 |
} |
138 | 155 |
|
139 | 156 |
private void createParentChildNodes(Classification classification, long id, String gueltString, |
app-import/src/main/java/eu/etaxonomy/cdm/io/redlist/gefaesspflanzen/RedListGefaesspflanzenImportNames.java | ||
---|---|---|
103 | 103 |
|
104 | 104 |
private void makeSingleNameAndTaxon(RedListGefaesspflanzenImportState state, ResultSet rs, Set<TaxonNameBase> namesToSave, Set<TaxonBase> taxaToSave) |
105 | 105 |
throws SQLException { |
106 |
//cell values |
|
106 | 107 |
long id = rs.getLong(RedListUtil.NAMNR); |
107 | 108 |
String taxNameString = rs.getString(RedListUtil.TAXNAME); |
108 | 109 |
String gueltString = rs.getString(RedListUtil.GUELT); |
... | ... | |
118 | 119 |
String authorKombString = rs.getString(RedListUtil.AUTOR_KOMB); |
119 | 120 |
String authorBasiString = rs.getString(RedListUtil.AUTOR_BASI); |
120 | 121 |
String hybString = rs.getString(RedListUtil.HYB); |
122 |
String clTaxonString = rs.getString(RedListUtil.CL_TAXON); |
|
123 |
String relationE = rs.getString(RedListUtil.E); |
|
124 |
String relationW = rs.getString(RedListUtil.W); |
|
125 |
String relationK = rs.getString(RedListUtil.K); |
|
126 |
String relationAW = rs.getString(RedListUtil.AW); |
|
127 |
String relationAO = rs.getString(RedListUtil.AO); |
|
128 |
String relationR = rs.getString(RedListUtil.R); |
|
129 |
String relationO = rs.getString(RedListUtil.O); |
|
130 |
String relationS = rs.getString(RedListUtil.S); |
|
121 | 131 |
|
122 | 132 |
//---NAME--- |
123 | 133 |
BotanicalName name = importName(state, id, taxNameString, rangString, ep1String, ep2String, ep3String, |
... | ... | |
135 | 145 |
return; |
136 | 146 |
} |
137 | 147 |
|
138 |
/*check if taxon/synonym is also in checklist |
|
139 |
* 1. create new taxon with the same name (in the checklist classification) |
|
140 |
* 2. create congruent concept relationship between both |
|
148 |
//---CONCEPT RELATIONSHIPS--- |
|
149 |
/*check if taxon/synonym also exists in other classification |
|
150 |
* 1. create new taxon with the same name (in that classification) |
|
151 |
* 2. create concept relationship between both |
|
141 | 152 |
*/ |
142 |
String clTaxonString = rs.getString(RedListUtil.CL_TAXON);
|
|
153 |
//checklist
|
|
143 | 154 |
if(CdmUtils.isNotBlank(clTaxonString) && !clTaxonString.trim().equals("-")){ |
144 |
cloneToClassification(taxonBase, name, TaxonRelationshipType.CONGRUENT_TO(), taxaToSave, id, RedListUtil.TAXON_CHECKLISTE_NAMESPACE, state); |
|
145 |
} |
|
155 |
cloneTaxon(taxonBase, name, TaxonRelationshipType.CONGRUENT_TO(), taxaToSave, id, RedListUtil.TAXON_CHECKLISTE_NAMESPACE, state); |
|
156 |
} |
|
157 |
//E, W, K, AW, AO, R, O, S |
|
158 |
addConceptRelation(relationE, RedListUtil.CLASSIFICATION_NAMESPACE_E, taxonBase, name, taxaToSave, id, state); |
|
159 |
addConceptRelation(relationW, RedListUtil.CLASSIFICATION_NAMESPACE_W, taxonBase, name, taxaToSave, id, state); |
|
160 |
addConceptRelation(relationK, RedListUtil.CLASSIFICATION_NAMESPACE_K, taxonBase, name, taxaToSave, id, state); |
|
161 |
addConceptRelation(relationAW, RedListUtil.CLASSIFICATION_NAMESPACE_AW, taxonBase, name, taxaToSave, id, state); |
|
162 |
addConceptRelation(relationAO, RedListUtil.CLASSIFICATION_NAMESPACE_AO, taxonBase, name, taxaToSave, id, state); |
|
163 |
addConceptRelation(relationR, RedListUtil.CLASSIFICATION_NAMESPACE_R, taxonBase, name, taxaToSave, id, state); |
|
164 |
addConceptRelation(relationO, RedListUtil.CLASSIFICATION_NAMESPACE_O, taxonBase, name, taxaToSave, id, state); |
|
165 |
addConceptRelation(relationS, RedListUtil.CLASSIFICATION_NAMESPACE_S, taxonBase, name, taxaToSave, id, state); |
|
146 | 166 |
|
147 | 167 |
//NOTE: the source has to be added after cloning or otherwise the clone would also get the source |
148 | 168 |
ImportHelper.setOriginalSource(taxonBase, state.getTransactionalSourceReference(), id, RedListUtil.TAXON_GESAMTLISTE_NAMESPACE); |
149 | 169 |
taxaToSave.add(taxonBase); |
150 | 170 |
} |
151 | 171 |
|
152 |
private void cloneToClassification(TaxonBase taxonBase, TaxonNameBase name, TaxonRelationshipType taxonRelationshipType, Set<TaxonBase> taxaToSave, long id, String sourceNameSpace, RedListGefaesspflanzenImportState state){ |
|
172 |
private void addConceptRelation(String relationString, String classificationNamespace, TaxonBase taxonBase, TaxonNameBase name, Set<TaxonBase> taxaToSave, long id, RedListGefaesspflanzenImportState state){ |
|
173 |
if(CdmUtils.isNotBlank(relationString) && !relationString.equals(".")){ |
|
174 |
TaxonRelationshipType taxonRelationshipTypeByKey = new RedListGefaesspflanzenTransformer().getTaxonRelationshipTypeByKey(relationString); |
|
175 |
if(taxonRelationshipTypeByKey==null){ |
|
176 |
RedListUtil.logMessage(id, "Could not interpret relationship "+relationString+" for taxon "+taxonBase, logger); |
|
177 |
} |
|
178 |
cloneTaxon(taxonBase, name, taxonRelationshipTypeByKey, taxaToSave, id, classificationNamespace, state); |
|
179 |
} |
|
180 |
} |
|
181 |
|
|
182 |
private void cloneTaxon(TaxonBase taxonBase, TaxonNameBase name, TaxonRelationshipType taxonRelationshipType, Set<TaxonBase> taxaToSave, long id, String sourceNameSpace, RedListGefaesspflanzenImportState state){ |
|
153 | 183 |
TaxonBase clone = (TaxonBase) taxonBase.clone(); |
154 | 184 |
clone.setName(name); |
155 | 185 |
if(taxonBase.isInstanceOf(Taxon.class)){ |
app-import/src/main/java/eu/etaxonomy/cdm/io/redlist/gefaesspflanzen/RedListGefaesspflanzenTransformer.java | ||
---|---|---|
16 | 16 |
import eu.etaxonomy.cdm.io.common.mapping.UndefinedTransformerMethodException; |
17 | 17 |
import eu.etaxonomy.cdm.model.name.NomenclaturalStatusType; |
18 | 18 |
import eu.etaxonomy.cdm.model.name.Rank; |
19 |
import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType; |
|
19 | 20 |
|
20 | 21 |
/** |
21 | 22 |
* |
... | ... | |
68 | 69 |
return null; |
69 | 70 |
} |
70 | 71 |
|
72 |
public TaxonRelationshipType getTaxonRelationshipTypeByKey(String key) { |
|
73 |
if (key == null){return null;} |
|
74 |
else { |
|
75 |
String substring = key.substring(key.length()-1, key.length()); |
|
76 |
// if (key.equals("<")){return TaxonRelationshipType.();}//TODO: what to do here? |
|
77 |
if (substring.equals(">")){return TaxonRelationshipType.INCLUDES();} |
|
78 |
else if (substring.equals("!")){return TaxonRelationshipType.OVERLAPS();} |
|
79 |
else if (substring.equals("?")){return TaxonRelationshipType.ALL_RELATIONSHIPS();} |
|
80 |
// else if (key.equals("x")){return TaxonRelationshipType.();}//TODO: what to do here? |
|
81 |
} |
|
82 |
return null; |
|
83 |
} |
|
84 |
|
|
71 | 85 |
} |
app-import/src/main/java/eu/etaxonomy/cdm/io/redlist/gefaesspflanzen/RedListUtil.java | ||
---|---|---|
44 | 44 |
public static final UUID uuidClassificationS = UUID.fromString("53e81162-5c2d-425b-bbe6-6e8d12e85790"); |
45 | 45 |
|
46 | 46 |
public static final String NAME_NAMESPACE = "name"; |
47 |
public static final String AUTHOR_NAMESPACE = "author"; |
|
47 | 48 |
public static final String TAXON_GESAMTLISTE_NAMESPACE = "taxon_gesamt_liste"; |
48 | 49 |
public static final String TAXON_CHECKLISTE_NAMESPACE = "taxon_checkliste"; |
49 |
public static final String AUTHOR_NAMESPACE = "author"; |
|
50 |
public static final String CLASSIFICATION_NAMESPACE_E = "classification_namespace_e"; |
|
51 |
public static final String CLASSIFICATION_NAMESPACE_W = "classification_namespace_w"; |
|
52 |
public static final String CLASSIFICATION_NAMESPACE_K = "classification_namespace_k"; |
|
53 |
public static final String CLASSIFICATION_NAMESPACE_AW = "classification_namespace_aw"; |
|
54 |
public static final String CLASSIFICATION_NAMESPACE_AO = "classification_namespace_ao"; |
|
55 |
public static final String CLASSIFICATION_NAMESPACE_R = "classification_namespace_r"; |
|
56 |
public static final String CLASSIFICATION_NAMESPACE_O = "classification_namespace_o"; |
|
57 |
public static final String CLASSIFICATION_NAMESPACE_S = "classification_namespace_s"; |
|
50 | 58 |
|
51 | 59 |
|
52 | 60 |
//cell content |
... | ... | |
85 | 93 |
public static final String CL_TAXON = "CL_TAXON"; |
86 | 94 |
public static final String HYB = "HYB"; |
87 | 95 |
|
96 |
public static final String E = "E"; |
|
97 |
public static final String W = "W"; |
|
98 |
public static final String K = "K"; |
|
99 |
public static final String AW = "AW"; |
|
100 |
public static final String AO = "AO"; |
|
101 |
public static final String R = "R"; |
|
102 |
public static final String O = "O"; |
|
103 |
public static final String S = "S"; |
|
104 |
|
|
88 | 105 |
public static void logMessage(long id, String message, Logger logger){ |
89 | 106 |
logger.error(NAMNR+": "+id+" "+message); |
90 | 107 |
} |
Also available in: Unified diff
Import concept relations E, W, K, AW, AO, R, O, S #5448