Revision 59ef8f07
Added by Andreas Müller about 8 years ago
app-import/src/main/java/eu/etaxonomy/cdm/io/edaphobase/EdaphobaseClassificationImport.java | ||
---|---|---|
23 | 23 |
import eu.etaxonomy.cdm.io.common.IPartitionedIO; |
24 | 24 |
import eu.etaxonomy.cdm.io.common.ResultSetPartitioner; |
25 | 25 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
26 |
import eu.etaxonomy.cdm.model.name.TaxonNameBase; |
|
26 | 27 |
import eu.etaxonomy.cdm.model.reference.Reference; |
27 | 28 |
import eu.etaxonomy.cdm.model.taxon.Classification; |
28 | 29 |
import eu.etaxonomy.cdm.model.taxon.Synonym; |
29 |
import eu.etaxonomy.cdm.model.taxon.SynonymRelationshipType; |
|
30 | 30 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
31 | 31 |
import eu.etaxonomy.cdm.model.taxon.TaxonBase; |
32 | 32 |
|
... | ... | |
87 | 87 |
Set<TaxonBase> taxaToSave = new HashSet<>(); |
88 | 88 |
try { |
89 | 89 |
while (rs.next()){ |
90 |
Integer id = rs.getInt("taxon_id");
|
|
90 |
int id = rs.getInt("taxon_id");
|
|
91 | 91 |
//parentTaxonFk |
92 | 92 |
boolean isValid = rs.getBoolean("valid"); |
93 | 93 |
// boolean idDeleted = rs.getBoolean("deleted"); |
... | ... | |
97 | 97 |
// boolean isGroup = rs.getBoolean("taxonomic_group"); |
98 | 98 |
Integer parentTaxonFk = nullSafeInt(rs, "parent_taxon_fk"); |
99 | 99 |
|
100 |
if (id != null && parentTaxonFk != null){ |
|
101 |
if (isValid){ |
|
102 |
Taxon child = state.getRelatedObject(TAXON_NAMESPACE, id.toString(), Taxon.class); |
|
103 |
Taxon parent = state.getRelatedObject(TAXON_NAMESPACE, parentTaxonFk.toString(), Taxon.class); |
|
104 |
if (parent != null){ |
|
105 |
classification.addParentChild(parent, child, sourceReference, null); |
|
106 |
}else{ |
|
107 |
logger.warn("Parent taxon " + parentTaxonFk + " not found for taxon " + id ); |
|
108 |
} |
|
100 |
if (parentTaxonFk != null){ |
|
101 |
TaxonBase<?> parent = state.getRelatedObject(TAXON_NAMESPACE, parentTaxonFk.toString(), TaxonBase.class); |
|
102 |
if (parent == null){ |
|
103 |
logger.warn("Parent taxon " + parentTaxonFk + " not found for taxon " + id ); |
|
109 | 104 |
}else{ |
110 |
Synonym synonym = state.getRelatedObject(TAXON_NAMESPACE, id.toString(), Synonym.class); |
|
111 |
if (synonym == null){ |
|
112 |
logger.warn("Synonym " + id + " not found for taxon "); |
|
113 |
} |
|
114 |
Taxon accepted = state.getRelatedObject(TAXON_NAMESPACE, parentTaxonFk.toString(), Taxon.class); |
|
115 |
if (accepted != null){ |
|
116 |
accepted.addSynonym(synonym, SynonymRelationshipType.SYNONYM_OF()); |
|
105 |
|
|
106 |
TaxonNameBase<?,?> parentName = parent.getName(); |
|
107 |
|
|
108 |
TaxonBase<?> child = state.getRelatedObject(TAXON_NAMESPACE, String.valueOf(id), TaxonBase.class); |
|
109 |
// TaxonNameBase<?,?> childName = child.getName(); |
|
110 |
|
|
111 |
// handleMissingNameParts(CdmBase.deproxy(childName, NonViralName.class), CdmBase.deproxy(parentName, NonViralName.class)); |
|
112 |
|
|
113 |
if (isValid){ |
|
114 |
if (parent.isInstanceOf(Synonym.class)){ |
|
115 |
logger.warn("Parent taxon (" + parentTaxonFk + " is not valid for valid child " + id); |
|
116 |
}else{ |
|
117 |
Taxon accParent = CdmBase.deproxy(parent, Taxon.class); |
|
118 |
classification.addParentChild(accParent, (Taxon)child, sourceReference, null); |
|
119 |
taxaToSave.add(accParent); |
|
120 |
} |
|
117 | 121 |
}else{ |
118 |
logger.warn("Accepted(parent) taxon " + parentTaxonFk + " not found for taxon " + id ); |
|
122 |
// Synonym synonym = CdmBase.deproxy(child, Synonym.class); |
|
123 |
// if (synonym == null){ |
|
124 |
// logger.warn("Synonym " + id + " not found for taxon "); |
|
125 |
// } |
|
126 |
// if(parent.isInstanceOf(Synonym.class)){ |
|
127 |
// String message = "Taxon ("+parentTaxonFk+") is not accepted but synonym. Can't add synonym ("+id+")"; |
|
128 |
// logger.warn(message); |
|
129 |
// }else{ |
|
130 |
// Taxon accepted = CdmBase.deproxy(parent, Taxon.class); |
|
131 |
//// accepted.addSynonym(synonym, SynonymRelationshipType.SYNONYM_OF()); |
|
132 |
// taxaToSave.add(accepted); |
|
133 |
// } |
|
119 | 134 |
} |
120 | 135 |
} |
121 |
|
|
122 | 136 |
} |
123 | 137 |
|
124 | 138 |
// //id |
... | ... | |
129 | 143 |
|
130 | 144 |
} |
131 | 145 |
} catch (SQLException e) { |
132 |
// TODO Auto-generated catch block |
|
133 | 146 |
e.printStackTrace(); |
134 | 147 |
} |
135 | 148 |
|
... | ... | |
137 | 150 |
return true; |
138 | 151 |
} |
139 | 152 |
|
153 |
// /** |
|
154 |
// * @param childName |
|
155 |
// * @param parentName |
|
156 |
// */ |
|
157 |
// private void handleMissingNameParts(NonViralName<?> childName, NonViralName<?> parentName) { |
|
158 |
// if (childName.getGenusOrUninomial()) |
|
159 |
// } |
|
160 |
|
|
140 | 161 |
@Override |
141 | 162 |
public Map<Object, Map<String, ? extends CdmBase>> getRelatedObjectsForPartition(ResultSet rs, |
142 | 163 |
EdaphobaseImportState state) { |
Also available in: Unified diff
Latest changes to Edaphobase import