cleanup
[cdmlib.git] / cdmlib-io / src / main / java / eu / etaxonomy / cdm / io / cdm2cdm / Cdm2CdmImportBase.java
1 /**
2 * Copyright (C) 2019 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
5 *
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
8 */
9 package eu.etaxonomy.cdm.io.cdm2cdm;
10
11 import java.lang.reflect.Field;
12 import java.lang.reflect.InvocationTargetException;
13 import java.lang.reflect.Method;
14 import java.util.ArrayList;
15 import java.util.Collection;
16 import java.util.HashMap;
17 import java.util.HashSet;
18 import java.util.List;
19 import java.util.Map;
20 import java.util.Set;
21 import java.util.UUID;
22
23 import org.apache.logging.log4j.LogManager;
24 import org.apache.logging.log4j.Logger;
25
26 import eu.etaxonomy.cdm.api.application.CdmApplicationController;
27 import eu.etaxonomy.cdm.api.application.ICdmApplication;
28 import eu.etaxonomy.cdm.api.application.ICdmRepository;
29 import eu.etaxonomy.cdm.common.monitor.IProgressMonitor;
30 import eu.etaxonomy.cdm.database.DbSchemaValidation;
31 import eu.etaxonomy.cdm.database.ICdmDataSource;
32 import eu.etaxonomy.cdm.database.ICdmImportSource;
33 import eu.etaxonomy.cdm.io.common.CdmImportBase;
34 import eu.etaxonomy.cdm.io.common.ITaxonNodeOutStreamPartitioner;
35 import eu.etaxonomy.cdm.io.common.TaxonNodeOutStreamPartitioner;
36 import eu.etaxonomy.cdm.io.common.TaxonNodeOutStreamPartitionerConcurrent;
37 import eu.etaxonomy.cdm.model.agent.AgentBase;
38 import eu.etaxonomy.cdm.model.agent.Contact;
39 import eu.etaxonomy.cdm.model.agent.Institution;
40 import eu.etaxonomy.cdm.model.agent.InstitutionalMembership;
41 import eu.etaxonomy.cdm.model.agent.Person;
42 import eu.etaxonomy.cdm.model.agent.Team;
43 import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
44 import eu.etaxonomy.cdm.model.common.AnnotatableEntity;
45 import eu.etaxonomy.cdm.model.common.Annotation;
46 import eu.etaxonomy.cdm.model.common.CdmBase;
47 import eu.etaxonomy.cdm.model.common.Credit;
48 import eu.etaxonomy.cdm.model.common.Extension;
49 import eu.etaxonomy.cdm.model.common.ExtensionType;
50 import eu.etaxonomy.cdm.model.common.IIntextReferencable;
51 import eu.etaxonomy.cdm.model.common.IIntextReferenceTarget;
52 import eu.etaxonomy.cdm.model.common.IdentifiableEntity;
53 import eu.etaxonomy.cdm.model.common.IdentifiableSource;
54 import eu.etaxonomy.cdm.model.common.Identifier;
55 import eu.etaxonomy.cdm.model.common.IntextReference;
56 import eu.etaxonomy.cdm.model.common.Language;
57 import eu.etaxonomy.cdm.model.common.LanguageString;
58 import eu.etaxonomy.cdm.model.common.LanguageStringBase;
59 import eu.etaxonomy.cdm.model.common.Marker;
60 import eu.etaxonomy.cdm.model.common.MarkerType;
61 import eu.etaxonomy.cdm.model.common.RelationshipBase;
62 import eu.etaxonomy.cdm.model.common.SingleSourcedEntityBase;
63 import eu.etaxonomy.cdm.model.common.SourcedEntityBase;
64 import eu.etaxonomy.cdm.model.common.VersionableEntity;
65 import eu.etaxonomy.cdm.model.description.CommonTaxonName;
66 import eu.etaxonomy.cdm.model.description.DescriptionBase;
67 import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
68 import eu.etaxonomy.cdm.model.description.DescriptionElementSource;
69 import eu.etaxonomy.cdm.model.description.DescriptiveDataSet;
70 import eu.etaxonomy.cdm.model.description.Distribution;
71 import eu.etaxonomy.cdm.model.description.Feature;
72 import eu.etaxonomy.cdm.model.description.FeatureState;
73 import eu.etaxonomy.cdm.model.description.MeasurementUnit;
74 import eu.etaxonomy.cdm.model.description.SpecimenDescription;
75 import eu.etaxonomy.cdm.model.description.StatisticalMeasure;
76 import eu.etaxonomy.cdm.model.description.TaxonDescription;
77 import eu.etaxonomy.cdm.model.description.TaxonInteraction;
78 import eu.etaxonomy.cdm.model.description.TaxonNameDescription;
79 import eu.etaxonomy.cdm.model.description.TextData;
80 import eu.etaxonomy.cdm.model.location.Country;
81 import eu.etaxonomy.cdm.model.location.NamedArea;
82 import eu.etaxonomy.cdm.model.media.ExternalLink;
83 import eu.etaxonomy.cdm.model.media.IdentifiableMediaEntity;
84 import eu.etaxonomy.cdm.model.media.Media;
85 import eu.etaxonomy.cdm.model.media.Rights;
86 import eu.etaxonomy.cdm.model.name.HomotypicalGroup;
87 import eu.etaxonomy.cdm.model.name.HybridRelationship;
88 import eu.etaxonomy.cdm.model.name.NameRelationship;
89 import eu.etaxonomy.cdm.model.name.NameTypeDesignation;
90 import eu.etaxonomy.cdm.model.name.NomenclaturalSource;
91 import eu.etaxonomy.cdm.model.name.NomenclaturalStatus;
92 import eu.etaxonomy.cdm.model.name.NomenclaturalStatusType;
93 import eu.etaxonomy.cdm.model.name.Registration;
94 import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation;
95 import eu.etaxonomy.cdm.model.name.TaxonName;
96 import eu.etaxonomy.cdm.model.name.TextualTypeDesignation;
97 import eu.etaxonomy.cdm.model.name.TypeDesignationBase;
98 import eu.etaxonomy.cdm.model.occurrence.DerivationEvent;
99 import eu.etaxonomy.cdm.model.occurrence.DeterminationEvent;
100 import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
101 import eu.etaxonomy.cdm.model.permission.User;
102 import eu.etaxonomy.cdm.model.reference.NamedSource;
103 import eu.etaxonomy.cdm.model.reference.NamedSourceBase;
104 import eu.etaxonomy.cdm.model.reference.OriginalSourceBase;
105 import eu.etaxonomy.cdm.model.reference.OriginalSourceType;
106 import eu.etaxonomy.cdm.model.reference.Reference;
107 import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
108 import eu.etaxonomy.cdm.model.taxon.Classification;
109 import eu.etaxonomy.cdm.model.taxon.SecundumSource;
110 import eu.etaxonomy.cdm.model.taxon.Synonym;
111 import eu.etaxonomy.cdm.model.taxon.Taxon;
112 import eu.etaxonomy.cdm.model.taxon.TaxonBase;
113 import eu.etaxonomy.cdm.model.taxon.TaxonNode;
114 import eu.etaxonomy.cdm.model.taxon.TaxonNodeAgentRelation;
115 import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;
116 import eu.etaxonomy.cdm.model.term.AvailableForTermBase;
117 import eu.etaxonomy.cdm.model.term.DefinedTerm;
118 import eu.etaxonomy.cdm.model.term.DefinedTermBase;
119 import eu.etaxonomy.cdm.model.term.OrderedTermBase;
120 import eu.etaxonomy.cdm.model.term.Representation;
121 import eu.etaxonomy.cdm.model.term.TermBase;
122 import eu.etaxonomy.cdm.model.term.TermCollection;
123 import eu.etaxonomy.cdm.model.term.TermNode;
124 import eu.etaxonomy.cdm.model.term.TermRelationBase;
125 import eu.etaxonomy.cdm.model.term.TermTree;
126 import eu.etaxonomy.cdm.model.term.TermVocabulary;
127 import eu.etaxonomy.cdm.persistence.query.MatchMode;
128
129 /**
130 * Base class for migrating data from one CDM instance to another.
131 *
132 * @author a.mueller
133 * @since 17.08.2019
134 */
135 public abstract class Cdm2CdmImportBase
136 extends CdmImportBase<Cdm2CdmImportConfigurator, Cdm2CdmImportState> {
137
138 private static final long serialVersionUID = 1344722304369624443L;
139 private static final Logger logger = LogManager.getLogger();
140
141 protected ICdmApplication sourceRepo(Cdm2CdmImportState state){
142 ICdmApplication repo = state.getSourceRepository();
143 if (repo == null){
144 ICdmImportSource source = state.getConfig().getSource();
145 if (source instanceof ICdmRepository){
146 repo = (ICdmApplication)source;
147 }else if (source instanceof ICdmDataSource){
148 System.out.println("start source repo");
149 boolean omitTermLoading = true;
150 repo = CdmApplicationController.NewInstance((ICdmDataSource)source,
151 DbSchemaValidation.VALIDATE, omitTermLoading);
152 state.setSourceRepository(repo);
153 System.out.println("end source repo");
154 }else{
155 throw new IllegalStateException("Unsupported ICdmImportSource type");
156 }
157 }
158 return repo;
159 }
160
161 protected Contact detach(Contact contact, Cdm2CdmImportState state) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
162 contact = CdmBase.deproxy(contact);
163 if (contact == null){
164 return contact;
165 }else{
166 return handlePersistedContact(contact, state);
167 }
168 }
169
170 protected IIntextReferencable detach(IIntextReferencable cdmBase, boolean onlyForDefinedSignature, Cdm2CdmImportState state) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
171 return (IIntextReferencable)detach((CdmBase)cdmBase, state);
172 }
173 protected IIntextReferenceTarget detach(IIntextReferenceTarget cdmBase, boolean onlyForDefinedSignature, Cdm2CdmImportState state) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
174 return (IIntextReferenceTarget)detach((CdmBase)cdmBase, state);
175 }
176
177 protected <T extends CdmBase> T detach(T cdmBase, Cdm2CdmImportState state) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
178 return detach(cdmBase, false, state);
179 }
180
181 protected <T extends CdmBase> T detach(T cdmBase, boolean notFromSource, Cdm2CdmImportState state) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
182 cdmBase = CdmBase.deproxy(cdmBase);
183 if (cdmBase == null ){
184 return cdmBase;
185 }else if(isInCache(cdmBase, state)){
186 return getCached(cdmBase, state);
187 }else {
188 if (state.getExistingObjects(cdmBase.getClass()) == null){
189 loadExistingUuids(cdmBase.getClass(), state);
190 }
191 boolean exists = state.getExistingObjects(cdmBase.getClass()).contains(cdmBase.getUuid());
192 if (exists){
193 Class<T> clazz = (Class<T>)cdmBase.getClass();
194 T existingObj = getCommonService().find(clazz, cdmBase.getUuid());
195 if (existingObj != null){
196 cache(existingObj, state);
197 return existingObj;
198 }else{
199 logger.warn("Object should exist already but does not exist in target. This should not happen: " + cdmBase.getClass().getSimpleName() + "/" + cdmBase.getUuid());
200 }
201 }
202 }
203 if ( !cdmBase.isPersited()){
204 logger.warn("Non persisted object not in cache and not in target DB. This should not happen: " + cdmBase.getUuid());
205 return cdmBase; //should not happen anymore; either in cache or in target or persisted in source
206 }else{
207 return notFromSource? null : (T)handlePersisted(cdmBase, state);
208 }
209 }
210
211 private Set<UUID> loadExistingUuids(Class<? extends CdmBase> clazz, Cdm2CdmImportState state) {
212 List<UUID> list = getCommonService().listUuid(clazz);
213 Set<UUID> result = new HashSet<>(list);
214 state.putExistingObjects(clazz, result);
215 return result;
216 }
217
218 protected <A extends CdmBase> CdmBase handlePersisted(A cdmBase, Cdm2CdmImportState state) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
219 if(cdmBase instanceof TaxonNode){
220 return handlePersistedTaxonNode((TaxonNode)cdmBase, state);
221 }else if(cdmBase instanceof Taxon){
222 return handlePersistedTaxon((Taxon)cdmBase, state);
223 }else if(cdmBase instanceof Synonym){
224 return handlePersistedSynonym((Synonym)cdmBase, state);
225 }else if(cdmBase instanceof TaxonName){
226 return handlePersistedTaxonName((TaxonName)cdmBase, state);
227 }else if(cdmBase instanceof Team){
228 return handlePersistedTeam((Team)cdmBase, state);
229 }else if(cdmBase instanceof Person){
230 return handlePersistedPerson((Person)cdmBase, state);
231 }else if(cdmBase instanceof Classification){
232 return handlePersistedClassification((Classification)cdmBase, state);
233 }else if(cdmBase instanceof Reference){
234 return handlePersistedReference((Reference)cdmBase, state);
235 }else if(cdmBase instanceof SpecimenOrObservationBase){
236 return handlePersistedSpecimenOrObservationBase((SpecimenOrObservationBase)cdmBase, state);
237 }else if(cdmBase instanceof IdentifiableSource){
238 return handlePersistedIdentifiableSource((IdentifiableSource)cdmBase, state);
239 }else if(cdmBase instanceof DescriptionElementSource){
240 return handlePersistedDescriptionElementSource((DescriptionElementSource)cdmBase, state);
241 }else if(cdmBase instanceof NomenclaturalSource){
242 return handlePersistedNomenclaturalSource((NomenclaturalSource)cdmBase, state);
243 }else if(cdmBase instanceof NamedSource){
244 return handlePersistedNamedSource((NamedSource)cdmBase, state);
245 }else if(cdmBase instanceof SecundumSource){
246 return handlePersistedSecundumSource((SecundumSource)cdmBase, state);
247 }else if(cdmBase instanceof CommonTaxonName){
248 return handlePersistedCommonTaxonName((CommonTaxonName)cdmBase, state);
249 }else if(cdmBase instanceof Distribution){
250 return handlePersistedDistribution((Distribution)cdmBase, state);
251 }else if(cdmBase instanceof TextData){
252 return handlePersistedTextData((TextData)cdmBase, state);
253 }else if(cdmBase instanceof TaxonInteraction){
254 return handlePersistedTaxonInteraction((TaxonInteraction)cdmBase, state);
255 }else if(cdmBase instanceof HomotypicalGroup){
256 return handlePersistedHomotypicalGroup((HomotypicalGroup)cdmBase, state);
257 }else if(cdmBase instanceof SpecimenTypeDesignation){
258 return handlePersistedSpecimenTypeDesignation((SpecimenTypeDesignation)cdmBase, state);
259 }else if(cdmBase instanceof NameTypeDesignation){
260 return handlePersistedNameTypeDesignation((NameTypeDesignation)cdmBase, state);
261 }else if(cdmBase instanceof TextualTypeDesignation){
262 return handlePersistedTextualTypeDesignation((TextualTypeDesignation)cdmBase, state);
263 }else if(cdmBase instanceof TaxonDescription){
264 return handlePersistedTaxonDescription((TaxonDescription)cdmBase, state);
265 }else if(cdmBase instanceof NomenclaturalStatus){
266 return handlePersistedNomenclaturalStatus((NomenclaturalStatus)cdmBase, state);
267 }else if(cdmBase instanceof TaxonNameDescription){
268 return handlePersistedTaxonNameDescription((TaxonNameDescription)cdmBase, state);
269 }else if(cdmBase instanceof TaxonRelationship){
270 return handlePersistedTaxonRelationship((TaxonRelationship)cdmBase, state);
271 }else if(cdmBase instanceof HybridRelationship){
272 return handlePersistedHybridRelationship((HybridRelationship)cdmBase, state);
273 }else if(cdmBase instanceof NameRelationship){
274 return handlePersistedNameRelationship((NameRelationship)cdmBase, state);
275 }else if(cdmBase instanceof TaxonNodeAgentRelation){
276 return handlePersistedTaxonNodeAgentRelation((TaxonNodeAgentRelation)cdmBase, state);
277 }else if(cdmBase instanceof User){
278 return handlePersistedUser((User)cdmBase, state);
279 }else if(cdmBase instanceof Extension){
280 return handlePersistedExtension((Extension)cdmBase, state);
281 }else if(cdmBase instanceof Marker){
282 return handlePersistedMarker((Marker)cdmBase, state);
283 }else if(cdmBase instanceof Annotation){
284 return handlePersistedAnnotation((Annotation)cdmBase, state);
285 }else if(cdmBase instanceof LanguageString){
286 return handlePersistedLanguageString((LanguageString)cdmBase, state);
287 }else if(cdmBase instanceof TermVocabulary){
288 return handlePersistedVocabulary((TermVocabulary<?>)cdmBase, state);
289 }else if(cdmBase instanceof TermTree){
290 return handlePersistedTermTree((TermTree<?>)cdmBase, state);
291 }else if(cdmBase instanceof NamedArea){
292 return handlePersistedNamedArea((NamedArea)cdmBase, state);
293 }else if(cdmBase instanceof TermNode){
294 return handlePersistedTermNode((TermNode)cdmBase, state);
295 }else if(cdmBase instanceof Representation){
296 return handlePersistedRepresentation((Representation)cdmBase, state);
297 }else if(cdmBase instanceof InstitutionalMembership){
298 return handlePersistedInstitutionalMembership((InstitutionalMembership)cdmBase, state);
299 }else if(cdmBase instanceof Institution){
300 return handlePersistedInstitution((Institution)cdmBase, state);
301 }else if(cdmBase instanceof IntextReference){
302 return handlePersistedIntextReference((IntextReference)cdmBase, state);
303 }else if(cdmBase instanceof ExtensionType){
304 return handlePersistedExtensionType((ExtensionType)cdmBase, state);
305 }else if(cdmBase instanceof NomenclaturalStatusType){
306 return handlePersistedNomenclaturalStatusType((NomenclaturalStatusType)cdmBase, state);
307 }else if(cdmBase instanceof MarkerType){
308 return handlePersistedMarkerType((MarkerType)cdmBase, state);
309 }else if(cdmBase instanceof Rights){
310 return handlePersistedRights((Rights)cdmBase, state);
311 }else if(cdmBase instanceof DefinedTerm){
312 return handlePersistedDefinedTerm((DefinedTerm)cdmBase, state);
313 }else if(cdmBase instanceof Feature){
314 return handlePersistedFeature((Feature)cdmBase, state);
315 }else if(cdmBase instanceof DefinedTermBase){
316 return handlePersistedTerm((DefinedTermBase<?>)cdmBase, state);
317 }else if(cdmBase instanceof ExternalLink){
318 return handlePersistedExternalLink((ExternalLink)cdmBase, state);
319 }else {
320 throw new RuntimeException("Type not yet supported: " + cdmBase.getClass().getCanonicalName());
321 }
322 }
323
324
325 protected TaxonNode handlePersistedTaxonNode(TaxonNode node, Cdm2CdmImportState state) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
326
327 TaxonNode result = handlePersisted((AnnotatableEntity)node, state);
328 if (result ==null){
329 return result;
330 }
331 //complete
332 handleCollection(result, TaxonNode.class, "agentRelations", TaxonNodeAgentRelation.class, state);
333 result.setTaxon(detach(result.getTaxon(), state));
334 result.setSource(detach(node.getSource(), state));
335 result.setSynonymToBeUsed(detach(result.getSynonymToBeUsed(), state));
336 handleMap(result, TaxonNode.class, "statusNote", Language.class, LanguageString.class, state);
337 //classification, parent, children
338 this.setInvisible(node, "classification", detach(node.getClassification(), state));
339 handleParentTaxonNode(result, state);
340 setNewCollection(node, TaxonNode.class, "childNodes", TaxonNode.class);
341 return result;
342 }
343
344 private void handleParentTaxonNode(TaxonNode childNode, Cdm2CdmImportState state) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
345 TaxonNode parent = detach(childNode.getParent(), true, state);
346 //TODO
347 String microReference = null;
348 Reference reference = null;
349 if (parent == null && childNode.getClassification().getRootNode().equals(childNode)){
350 //do nothing
351 }else if (parent == null ){
352 childNode.getClassification().addChildNode(childNode, reference, microReference) ;
353 }else{
354 parent.addChildNode(childNode, reference, microReference);
355 }
356 }
357
358 protected Taxon handlePersistedTaxon(Taxon taxon, Cdm2CdmImportState state) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
359 Taxon result = handlePersisted((TaxonBase)taxon, state);
360 //complete
361 handleCollection(result, Taxon.class, "synonyms", Synonym.class, state);
362 // handleCollection(result, Taxon.class, "taxonNodes", TaxonNode.class);
363 setNewCollection(result, Taxon.class, "taxonNodes", TaxonNode.class);
364 handleCollection(result, Taxon.class, "relationsFromThisTaxon", TaxonRelationship.class, state);
365 handleCollection(result, Taxon.class, "relationsToThisTaxon", TaxonRelationship.class, state);
366 if (this.doDescriptions(state)){
367 handleCollection(result, Taxon.class, "descriptions", TaxonDescription.class, state);
368 }else{
369 setNewCollection(result, Taxon.class, "descriptions", TaxonDescription.class);
370 }
371 return result;
372 }
373
374 protected boolean doDescriptions(Cdm2CdmImportState state) {
375 return false;
376 }
377
378 protected Synonym handlePersistedSynonym(Synonym synonym, Cdm2CdmImportState state) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
379 Synonym result = handlePersisted((TaxonBase)synonym, state);
380 //complete
381 setInvisible(result, "acceptedTaxon", detach(result.getAcceptedTaxon(), state));
382 result.setType(detach(result.getType(), state));
383 return result;
384 }
385
386 protected TaxonRelationship handlePersistedTaxonRelationship(TaxonRelationship taxRel, Cdm2CdmImportState state) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
387 TaxonRelationship result = handlePersisted((RelationshipBase)taxRel, state);
388 //complete
389 result.setFromTaxon(detach(result.getFromTaxon(), state));
390 result.setToTaxon(detach(result.getToTaxon(), state));
391 result.setType(detach(result.getType(), state));
392 return result;
393 }
394
395 protected NameRelationship handlePersistedNameRelationship(NameRelationship rel, Cdm2CdmImportState state) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
396 NameRelationship result = handlePersisted((RelationshipBase)rel, state);
397 //complete
398 setInvisible(result, "relatedFrom", detach(result.getFromName(), state));
399 setInvisible(result, "relatedTo", detach(result.getToName(), state));
400 // result.setFromName(detache(result.getFromName(), state));
401 // result.setToName(detache(result.getToName(), state));
402 result.setType(detach(result.getType(), state));
403 return result;
404 }
405
406 protected HybridRelationship handlePersistedHybridRelationship(HybridRelationship rel, Cdm2CdmImportState state) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
407 HybridRelationship result = handlePersisted((RelationshipBase)rel, state);
408 //complete
409 setInvisible(result, "relatedFrom", detach(result.getParentName(), state));
410 setInvisible(result, "relatedTo", detach(result.getHybridName(), state));
411 // result.setFromName(detache(result.getFromName()));
412 // result.setToName(detache(result.getToName()));
413 result.setType(detach(result.getType(), state));
414 return result;
415 }
416
417 protected NomenclaturalStatus handlePersistedNomenclaturalStatus(NomenclaturalStatus status, Cdm2CdmImportState state) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
418 NomenclaturalStatus result = handlePersisted((SingleSourcedEntityBase)status, state);
419 //complete
420 result.setType(detach(result.getType(), state));
421 return result;
422 }
423
424 protected TypeDesignationBase handlePersisted(TypeDesignationBase designation, Cdm2CdmImportState state) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
425 TypeDesignationBase result = handlePersisted((SourcedEntityBase)designation, state);
426 //complete
427 handleCollection(result, TypeDesignationBase.class, "registrations", Registration.class, state);
428 handleCollection(result, TypeDesignationBase.class, "typifiedNames", TaxonName.class, state);
429 return result;
430 }
431
432 protected <T extends TypeDesignationBase> T handlePersistedNameOrSpecimenTypeDesignation(T designation, Cdm2CdmImportState state) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
433 T result = (T)handlePersisted(designation, state);
434 //complete
435 result.setDesignationSource(detach(result.getDesignationSource(), state));
436 result.setTypeStatus(detach(result.getTypeStatus(), state));
437 return result;
438 }
439
440 protected NameTypeDesignation handlePersistedNameTypeDesignation(NameTypeDesignation designation, Cdm2CdmImportState state) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
441 NameTypeDesignation result = handlePersistedNameOrSpecimenTypeDesignation(designation, state);
442 //complete
443 result.setTypeName(detach(result.getTypeName(), state));
444 return result;
445 }
446
447 protected SpecimenTypeDesignation handlePersistedSpecimenTypeDesignation(SpecimenTypeDesignation designation, Cdm2CdmImportState state) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
448 SpecimenTypeDesignation result = handlePersistedNameOrSpecimenTypeDesignation(designation, state);
449 //complete
450 result.setTypeSpecimen(detach(result.getTypeSpecimen(), state));
451 return result;
452 }
453
454 protected TextualTypeDesignation handlePersistedTextualTypeDesignation(TextualTypeDesignation designation, Cdm2CdmImportState state) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
455 TextualTypeDesignation result = (TextualTypeDesignation)handlePersisted(designation, state);
456 //still to test
457 handleMap(result, TextualTypeDesignation.class, "text", Language.class, LanguageString.class, state);
458 return result;
459 }
460
461 protected InstitutionalMembership handlePersistedInstitutionalMembership(InstitutionalMembership institutionalMembership, Cdm2CdmImportState state) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
462 InstitutionalMembership result = handlePersisted((VersionableEntity)institutionalMembership, state);
463 //complete
464 // result.setPerson(detache(result.getPerson()));
465 setInvisible(result, "person", detach(result.getPerson(), state));
466 result.setInstitute(detach(result.getInstitute(), state));
467 return result;
468 }
469
470 protected Institution handlePersistedInstitution(Institution institution, Cdm2CdmImportState state) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
471 Institution result = handlePersisted((AgentBase)institution, state);
472 //complete
473 result.setIsPartOf(detach(result.getIsPartOf(), state));
474 handleCollection(result, Institution.class, "types", DefinedTerm.class, state);
475 return result;
476 }
477
478 protected TaxonNodeAgentRelation handlePersistedTaxonNodeAgentRelation(TaxonNodeAgentRelation nodeAgentRel, Cdm2CdmImportState state) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
479 TaxonNodeAgentRelation result = handlePersisted((AnnotatableEntity)nodeAgentRel, state);
480 //complete
481 result.setAgent(detach(result.getAgent(), state));
482 result.setType(detach(result.getType(), state));
483 setInvisible(result, "taxonNode", detach(result.getTaxonNode(), state));
484 return result;
485 }
486
487
488 protected TaxonName handlePersistedTaxonName(TaxonName taxonName, Cdm2CdmImportState state) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
489 @SuppressWarnings("rawtypes")
490 TaxonName result = handlePersisted((IdentifiableEntity)taxonName, state);
491 //complete
492 result.setRank(detach(result.getRank(), state));
493 result.setCombinationAuthorship(detach(result.getCombinationAuthorship(), state));
494 result.setExCombinationAuthorship(detach(result.getExCombinationAuthorship(), state));
495 result.setBasionymAuthorship(detach(result.getBasionymAuthorship(), state));
496 result.setExBasionymAuthorship(detach(result.getExBasionymAuthorship(), state));
497 result.setInBasionymAuthorship(detach(result.getInBasionymAuthorship(), state));
498 result.setInCombinationAuthorship(detach(result.getInCombinationAuthorship(), state));
499
500 // result.setNomenclaturalReference(detach(result.getNomenclaturalReference(), state));
501 result.setNomenclaturalSource(detach(result.getNomenclaturalSource(), state));
502 result.setHomotypicalGroup(detach(result.getHomotypicalGroup(), state));
503 handleCollection(result, TaxonName.class, "descriptions", TaxonNameDescription.class, state);
504 handleCollection(result, TaxonName.class, "hybridChildRelations", HybridRelationship.class, state);
505 handleCollection(result, TaxonName.class, "hybridParentRelations", HybridRelationship.class, state);
506 handleCollection(result, TaxonName.class, "relationsFromThisName", NameRelationship.class, state);
507 handleCollection(result, TaxonName.class, "relationsToThisName", NameRelationship.class, state);
508 handleCollection(result, TaxonName.class, "status", NomenclaturalStatus.class, state);
509
510 handleCollection(result, TaxonName.class, "registrations", Registration.class, state);
511 handleCollection(result, TaxonName.class, "typeDesignations", TypeDesignationBase.class, state);
512
513 handleCollection(result, TaxonName.class, "taxonBases", TaxonBase.class, state);
514
515 return result;
516 }
517
518 protected HomotypicalGroup handlePersistedHomotypicalGroup(HomotypicalGroup group, Cdm2CdmImportState state) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
519 HomotypicalGroup result = handlePersisted((AnnotatableEntity)group, state);
520 //complete
521 handleCollection(result, HomotypicalGroup.class, "typifiedNames", TaxonName.class, state);
522 return result;
523 }
524
525 protected Annotation handlePersistedAnnotation(Annotation annotation, Cdm2CdmImportState state) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
526 Annotation result = handlePersisted((AnnotatableEntity)annotation, state);
527 //complete
528 result.setAnnotationType(detach(annotation.getAnnotationType(), state));
529 result.setCommentator(detach(result.getCommentator(), state));
530 handleCollection(result, Annotation.class, "intextReferences", IntextReference.class, state);
531 return result;
532 }
533
534 protected Extension handlePersistedExtension(Extension extension, Cdm2CdmImportState state) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
535 Extension result = handlePersisted((VersionableEntity)extension, state);
536 //complete
537 result.setType(detach(extension.getType(), state));
538 return result;
539 }
540
541 protected Marker handlePersistedMarker(Marker marker, Cdm2CdmImportState state) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
542 Marker result = handlePersisted((VersionableEntity)marker, state);
543 //complete
544 result.setMarkerType(detach(marker.getMarkerType(), state));
545 return result;
546 }
547
548 protected Team handlePersistedTeam(Team team, Cdm2CdmImportState state) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
549 Team result = handlePersisted((TeamOrPersonBase)team, state);
550 //complete
551 handleCollection(result, Team.class, "teamMembers", Person.class, state);
552 return result;
553 }
554
555 protected Contact handlePersistedContact(Contact contact, Cdm2CdmImportState state) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
556 Contact result = contact; // getTarget(contact);
557 if (result ==null){
558 return result;
559 }
560 if (!contact.getAddresses().isEmpty() || !contact.getEmailAddresses().isEmpty()
561 || !contact.getFaxNumbers().isEmpty() ||!contact.getPhoneNumbers().isEmpty()
562 ||!contact.getUrls().isEmpty()){
563 logger.warn("Addresses not yet implemented");
564 }
565 setInvisible(result, "addresses", new HashSet<>());
566 // handleCollection(result, Contact.class, "", Address.class);
567 setInvisible(result, "faxNumbers", new ArrayList<>());
568 setInvisible(result, "phoneNumbers", new ArrayList<>());
569 setInvisible(result, "emailAddresses", new ArrayList<>());
570 setInvisible(result, "urls", new ArrayList<>());
571 return result;
572 }
573
574 protected Person handlePersistedPerson(Person person, Cdm2CdmImportState state) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
575 Person result = handlePersisted((TeamOrPersonBase)person, state);
576 //complete
577 handleCollection(result, Person.class, "institutionalMemberships", InstitutionalMembership.class, state);
578 return result;
579 }
580
581 protected NamedArea handlePersistedNamedArea(NamedArea area, Cdm2CdmImportState state) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
582 NamedArea result = handlePersisted((OrderedTermBase)area, state);
583 //complete
584 handleCollection(result, NamedArea.class, "countries", Country.class, state);
585 result.setLevel(detach(result.getLevel(), state));
586 result.setType(detach(result.getType(), state));
587 result.setShape(detach(result.getShape(), state));
588 return result;
589 }
590
591 protected Classification handlePersistedClassification(Classification classification, Cdm2CdmImportState state) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
592 Classification result = handlePersisted((IdentifiableEntity)classification, state);
593 //complete
594 result.setName(detach(classification.getName(), state));
595 result.setSource(detach(classification.getSource(), state));
596 result.setRootNode(detach(classification.getRootNode(), state));
597 handleCollection(result, Classification.class, "geoScopes", NamedArea.class, state);
598 handleMap(result, Classification.class, "description", Language.class, LanguageString.class, state);
599 return result;
600 }
601
602 protected Reference handlePersistedReference(Reference reference, Cdm2CdmImportState state) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
603 Reference result = handlePersisted((IdentifiableMediaEntity)reference, state);
604 result.setAuthorship(detach(result.getAuthorship(), state));
605 result.setInstitution(detach(result.getInstitution(), state));
606 result.setSchool(detach(result.getSchool(), state));
607 result.setInReference(detach(result.getInReference(), state));
608 return result;
609 }
610
611 protected SpecimenOrObservationBase<?> handlePersistedSpecimenOrObservationBase(SpecimenOrObservationBase specimen, Cdm2CdmImportState state) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
612 //TODO implement for classes
613 SpecimenOrObservationBase<?> result = handlePersisted((IdentifiableEntity)specimen, state);
614 //complete
615 result.setSex(detach(result.getSex(), state));
616 result.setLifeStage(detach(result.getLifeStage(), state));
617 result.setKindOfUnit(detach(result.getKindOfUnit(), state));
618 handleCollection(result, SpecimenOrObservationBase.class, "determinations", DeterminationEvent.class, state);
619 handleCollection(result, SpecimenOrObservationBase.class, "descriptions", SpecimenDescription.class, state);
620 handleCollection(result, SpecimenOrObservationBase.class, "derivationEvents", DerivationEvent.class, state);
621 handleMap(result, SpecimenOrObservationBase.class, "definition", Language.class, LanguageString.class, state);
622 return result;
623 }
624
625 protected IdentifiableSource handlePersistedIdentifiableSource(IdentifiableSource source, Cdm2CdmImportState state) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
626 IdentifiableSource result = handlePersisted((OriginalSourceBase)source, state);
627 //complete
628 return result;
629 }
630
631 protected <T extends NamedSourceBase> T handlePersisted(NamedSourceBase source, Cdm2CdmImportState state) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
632 T result = handlePersisted((OriginalSourceBase)source, state);
633 //complete
634 result.setNameUsedInSource(detach(result.getNameUsedInSource(), state));
635 return result;
636 }
637
638 protected NamedSource handlePersistedNamedSource(NamedSource source, Cdm2CdmImportState state) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
639 NamedSource result = handlePersisted((NamedSourceBase)source, state);
640 //complete
641 return result;
642 }
643
644 protected NomenclaturalSource handlePersistedNomenclaturalSource(NomenclaturalSource source, Cdm2CdmImportState state) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
645 NomenclaturalSource result = handlePersisted((NamedSourceBase)source, state);
646 //complete
647 result.setSourcedName(detach(result.getSourcedName(), state));
648 return result;
649 }
650
651 protected SecundumSource handlePersistedSecundumSource(SecundumSource source, Cdm2CdmImportState state) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
652 SecundumSource result = handlePersisted((NamedSourceBase)source, state);
653 //complete
654 result.setSourcedTaxon(detach(result.getSourcedTaxon(), state));
655 return result;
656 }
657
658 protected DescriptionElementSource handlePersistedDescriptionElementSource(DescriptionElementSource source, Cdm2CdmImportState state) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
659 DescriptionElementSource result = handlePersisted((NamedSourceBase)source, state);
660 //complete
661 detach(result.getSourcedElement(), state).addSource(result);
662 return result;
663 }
664
665 protected <T extends CommonTaxonName> T handlePersistedCommonTaxonName(CommonTaxonName element, Cdm2CdmImportState state) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
666 T result = handlePersisted((DescriptionElementBase)element, state);
667 //complete
668 result.setLanguage(detach(result.getLanguage(), state));
669 result.setArea(detach(result.getArea(), state));
670 return result;
671 }
672
673 protected <T extends TextData> T handlePersistedTextData(TextData element, Cdm2CdmImportState state) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
674 T result = handlePersisted((DescriptionElementBase)element, state);
675 //complete
676 result.setFormat(detach(result.getFormat(), state));
677 handleMap(result, TextData.class, "multilanguageText", Language.class, LanguageString.class, state);
678 return result;
679 }
680
681 protected <T extends Distribution> T handlePersistedDistribution(Distribution element, Cdm2CdmImportState state) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
682 T result = handlePersisted((DescriptionElementBase)element, state);
683 //complete
684 result.setArea(detach(result.getArea(), state));
685 result.setStatus(detach(result.getStatus(), state));
686 return result;
687 }
688
689 protected <T extends TaxonInteraction> T handlePersistedTaxonInteraction(TaxonInteraction element, Cdm2CdmImportState state) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
690 T result = handlePersisted((DescriptionElementBase)element, state);
691 //complete
692 handleMap(result, TaxonInteraction.class, "description", Language.class, LanguageString.class, state);
693 result.setTaxon2(detach(result.getTaxon2(), state));
694 return result;
695 }
696
697 protected ExternalLink handlePersistedExternalLink(ExternalLink externalLink, Cdm2CdmImportState state) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
698 ExternalLink result = handlePersisted((VersionableEntity)externalLink, state);
699 //complete
700 handleMap(result, ExternalLink.class, "description", Language.class, LanguageString.class, state);
701 return result;
702 }
703
704 protected Feature handlePersistedFeature(Feature term, Cdm2CdmImportState state) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
705 Feature result = handlePersisted((DefinedTermBase)term, state);
706 //complete
707 handleCollection(result, Feature.class, "inverseRepresentations", Representation.class, state);
708 handleCollection(result, Feature.class, "recommendedMeasurementUnits", MeasurementUnit.class, state);
709 handleCollection(result, Feature.class, "recommendedModifierEnumeration", TermVocabulary.class, state);
710 handleCollection(result, Feature.class, "recommendedStatisticalMeasures", StatisticalMeasure.class, state);
711 handleCollection(result, Feature.class, "supportedCategoricalEnumerations", TermVocabulary.class, state);
712 return result;
713 }
714
715 protected ExtensionType handlePersistedExtensionType(ExtensionType term, Cdm2CdmImportState state) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
716 ExtensionType result = handlePersisted((DefinedTermBase)term, state);
717 //complete
718 return result;
719 }
720
721 protected MarkerType handlePersistedMarkerType(MarkerType term, Cdm2CdmImportState state) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
722 MarkerType result = handlePersisted((DefinedTermBase)term, state);
723 //complete
724 return result;
725 }
726
727 protected NomenclaturalStatusType handlePersistedNomenclaturalStatusType(NomenclaturalStatusType term, Cdm2CdmImportState state) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
728 NomenclaturalStatusType result = handlePersisted((OrderedTermBase)term, state);
729 //complete
730 return result;
731 }
732
733 protected DefinedTerm handlePersistedDefinedTerm(DefinedTerm term, Cdm2CdmImportState state) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
734 DefinedTerm result = handlePersisted((DefinedTermBase)term, state);
735 //complete
736 return result;
737 }
738
739 //placeholder for not implemented methods for subclasses
740 protected DefinedTermBase<?> handlePersistedTerm(DefinedTermBase term, Cdm2CdmImportState state) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
741 DefinedTermBase<?> result = handlePersisted(term, state);
742 logger.warn("Class not yet handled: " + term.getClass().getSimpleName());
743 return result;
744 }
745
746 protected TermVocabulary<?> handlePersistedVocabulary(TermVocabulary voc, Cdm2CdmImportState state) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
747 TermVocabulary<?> result = (TermVocabulary<?>)handlePersisted((TermCollection)voc, state);
748 handleCollection(result, TermVocabulary.class, "terms", DefinedTermBase.class, state);
749 return result;
750 }
751
752 protected TermTree<?> handlePersistedTermTree(TermTree tree, Cdm2CdmImportState state) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
753 //TODO TermGraphBase is still missing
754 TermTree<?> result = (TermTree<?>)handlePersisted((TermCollection)tree, state);
755 //complete
756 result.getRoot().setUuid(tree.getRoot().getUuid());
757 return result;
758 }
759
760 protected TermNode<?> handlePersistedTermNode(TermNode node, Cdm2CdmImportState state) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
761 TermNode<?> result = (TermNode<?>)handlePersisted((TermRelationBase)node, state);
762 //complete
763 setInvisible(result, "parent", detach(result.getParent(), state));
764 handleCollection(result, TermNode.class, "inapplicableIf", FeatureState.class, state);
765 handleCollection(result, TermNode.class, "onlyApplicableIf", FeatureState.class, state);
766 handleCollection(result, TermNode.class, "children", TermNode.class, state);
767
768 return result;
769 }
770
771 protected Representation handlePersistedRepresentation(Representation representation, Cdm2CdmImportState state) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
772 Representation result = (Representation)handlePersisted((LanguageStringBase)representation, state);
773 return result;
774 }
775
776 protected <T extends TermBase> T handlePersisted(TermBase termBase, Cdm2CdmImportState state) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
777 T result = handlePersisted((IdentifiableEntity)termBase, state);
778 //complete
779 handleCollection(result, TermBase.class, "representations", Representation.class, state);
780 return result;
781 }
782
783 protected <T extends TermCollection> T handlePersisted(TermCollection termCollection, Cdm2CdmImportState state) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
784 T result = handlePersisted((TermBase)termCollection, state);
785 //complete
786 handleCollection(result, TermCollection.class, "termRelations", TermRelationBase.class, state);
787 return result;
788 }
789
790 protected <T extends TermRelationBase> T handlePersisted(TermRelationBase termRelationBase, Cdm2CdmImportState state) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
791 T result = handlePersisted((VersionableEntity)termRelationBase, state);
792 result.setTerm(detach(result.getTerm(), state));
793 setInvisible(result, TermRelationBase.class, "graph", detach(result.getGraph(), state));
794 return result;
795 }
796
797 protected User handlePersistedUser(User user, Cdm2CdmImportState state) throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException, InvocationTargetException, NoSuchMethodException {
798 User result = (User)handlePersistedCdmBase(user, state);
799 if (result.getUsername().equals("admin")){
800 //TODO why only admin, is this not a problem for all duplicated usernames? Was this a preliminary decision?
801 result = getUserService().listByUsername("admin", MatchMode.EXACT, null, null, null, null, null).iterator().next();
802 state.putPermanent(user.getUuid(), result);
803 cache(result, state); //necessary?
804 state.addToSave(result);
805 state.removeToSave(user);
806 }
807 if (!result.isPersited()){
808 result.setAuthorities(new HashSet<>());
809 result.setGrantedAuthorities(new HashSet<>());
810 setInvisible(result, "groups", new HashSet<>());
811 }
812 result.setPerson(detach(user.getPerson(), state));
813 return result;
814 }
815
816
817 protected LanguageString handlePersistedLanguageString(LanguageString languageString, Cdm2CdmImportState state) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
818 LanguageString result = handlePersisted((LanguageStringBase)languageString, state);
819 //complete
820 handleCollection(result, LanguageString.class, "intextReferences", IntextReference.class, state);
821 return result;
822 }
823
824 protected Rights handlePersistedRights(Rights rights, Cdm2CdmImportState state) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
825 Rights result = handlePersisted((LanguageStringBase)rights, state);
826 result.setAgent(detach(rights.getAgent(), state));
827 result.setType(detach(rights.getType(), state));
828 //complete
829 return result;
830 }
831
832 protected IntextReference handlePersistedIntextReference(IntextReference intextReference, Cdm2CdmImportState state) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
833 IntextReference result = handlePersisted((VersionableEntity)intextReference, state);
834 result.setReferencedEntity(detach(result.getReferencedEntity(), false, state));
835 Method targetMethod = IntextReference.class.getDeclaredMethod("setTarget", IIntextReferenceTarget.class);
836 targetMethod.setAccessible(true);
837 targetMethod.invoke(result, detach(result.getTarget(), false, state));
838 return result;
839 }
840
841 protected <T extends TaxonDescription> T handlePersistedTaxonDescription(TaxonDescription taxDescription, Cdm2CdmImportState state) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
842 T result = handlePersisted((DescriptionBase)taxDescription, state);
843 //complete
844 setInvisible(taxDescription, "taxon", detach(taxDescription.getTaxon(), state));
845 handleCollection(taxDescription, TaxonDescription.class, "geoScopes", NamedArea.class, state);
846 handleCollection(taxDescription, TaxonDescription.class, "scopes", DefinedTerm.class, state);
847 return result;
848 }
849
850 protected <T extends TaxonDescription> T handlePersistedTaxonNameDescription(TaxonNameDescription nameDescription, Cdm2CdmImportState state) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
851 T result = handlePersisted((DescriptionBase)nameDescription, state);
852 //complete
853 setInvisible(nameDescription, "taxonName", detach(nameDescription.getTaxonName(), state));
854 return result;
855 }
856
857
858 // ***************************** BASE CLASSES ********************************************/
859
860 protected <T extends CdmBase> T handlePersistedCdmBase(CdmBase cdmBase, Cdm2CdmImportState state) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
861 @SuppressWarnings("unchecked")
862 T result = (T)getTarget(cdmBase, state);
863 //complete
864 cdmBase.setCreatedBy(makeCreatedUpdatedBy(cdmBase.getCreatedBy(), state, false));
865 return result;
866 }
867
868 protected <T extends VersionableEntity> T handlePersisted(VersionableEntity entity, Cdm2CdmImportState state) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
869 @SuppressWarnings("unchecked")
870 T result = (T)handlePersistedCdmBase((CdmBase)entity, state);
871 //complete
872 entity.setUpdatedBy(makeCreatedUpdatedBy(entity.getUpdatedBy(), state, true));
873 return result;
874 }
875
876 protected <T extends AnnotatableEntity> T handlePersisted(AnnotatableEntity entity, Cdm2CdmImportState state) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
877 T result = handlePersisted((VersionableEntity)entity, state);
878 //complete
879 handleCollection(result, AnnotatableEntity.class, "annotations", Annotation.class, state);
880 handleCollection(result, AnnotatableEntity.class, "markers", Marker.class, state);
881 return result;
882 }
883
884 protected <T extends SourcedEntityBase<?>> T handlePersisted(SourcedEntityBase sourcedEntity,
885 Cdm2CdmImportState state)
886 throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
887 int originalId = sourcedEntity.getId();
888 T result = handlePersisted((AnnotatableEntity)sourcedEntity, state);
889 //complete
890 handleCollection(result, SourcedEntityBase.class, "sources", OriginalSourceBase.class, state);
891 if (!result.isPersited()){
892 if(state.getConfig().isRemoveImportSources()){
893 filterImportSources(result.getSources());
894 }
895 if (state.getConfig().isAddSources()){
896 Reference sourceRef = getSourceReference(state);
897 OriginalSourceBase newSource = result.addImportSource(String.valueOf(originalId), sourcedEntity.getClass().getSimpleName(),
898 sourceRef, null);
899 getCommonService().save(newSource);
900 addExistingObject(newSource, state);
901 }
902 }
903 return result;
904 }
905
906 /**
907 * @param sources
908 */
909 private void filterImportSources(Set<? extends OriginalSourceBase> sources) {
910 Set<OriginalSourceBase> toDelete = new HashSet<>();
911 for (OriginalSourceBase osb: sources){
912 if (osb.getType() == OriginalSourceType.Import){
913 toDelete.add(osb);
914 }
915 }
916 for (OriginalSourceBase osb: toDelete){
917 sources.remove(osb);
918 }
919 }
920
921 protected <T extends IdentifiableEntity> T handlePersisted(IdentifiableEntity identifiableEntity, Cdm2CdmImportState state) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
922 T result = handlePersisted((SourcedEntityBase)identifiableEntity, state);
923 //complete
924 handleCollection(result, IdentifiableEntity.class, "credits", Credit.class, state);
925 handleCollection(result, IdentifiableEntity.class, "extensions", Extension.class, state);
926 handleCollection(result, IdentifiableEntity.class, "identifiers", Identifier.class, state);
927 handleCollection(result, IdentifiableEntity.class, "rights", Rights.class, state);
928 handleCollection(result, IdentifiableEntity.class, "links", ExternalLink.class, state);
929
930 return result;
931 }
932
933 protected <T extends DefinedTermBase> T handlePersisted(DefinedTermBase definedTermBase, Cdm2CdmImportState state) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
934 T result = handlePersisted((TermBase)definedTermBase, state);
935 //complete
936 handleCollection(result, DefinedTermBase.class, "media", Media.class, state);
937 handleCollection(result, DefinedTermBase.class, "generalizationOf", DefinedTermBase.class, state);
938 handleCollection(result, DefinedTermBase.class, "includes", DefinedTermBase.class, state);
939 result.setKindOf(detach(result.getKindOf(), state));
940 result.setPartOf(detach(result.getPartOf(), state));
941 setInvisible(result, DefinedTermBase.class, "vocabulary", detach(result.getVocabulary(), state));
942
943 return result;
944 }
945
946 protected <T extends AvailableForTermBase> T handlePersisted(AvailableForTermBase availableForTermBase, Cdm2CdmImportState state) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
947 T result = handlePersisted((DefinedTermBase)availableForTermBase, state);
948 //complete
949 return result;
950 }
951
952 protected <T extends OriginalSourceBase> T handlePersisted(OriginalSourceBase source, Cdm2CdmImportState state) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
953 T result = handlePersisted((AnnotatableEntity)source, state);
954 //complete
955 result.setCitation(detach(result.getCitation(), state));
956 handleCollection(result, OriginalSourceBase.class, "links", ExternalLink.class, state);
957 return result;
958 }
959
960 protected <T extends LanguageStringBase> T handlePersisted(LanguageStringBase lsBase, Cdm2CdmImportState state) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
961 T result = handlePersisted((AnnotatableEntity)lsBase, state);
962 //complete
963 result.setLanguage(detach(lsBase.getLanguage(), state));
964 return result;
965 }
966
967 protected <T extends TeamOrPersonBase> T handlePersisted(TeamOrPersonBase teamOrPerson, Cdm2CdmImportState state) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
968 T result = handlePersisted((AgentBase)teamOrPerson, state);
969 //complete
970 return result;
971 }
972
973 protected <T extends AgentBase> T handlePersisted(AgentBase agent, Cdm2CdmImportState state) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
974 T result = handlePersisted((IdentifiableMediaEntity)agent, state);
975 result.setContact(detach(result.getContact(), state));
976 //complete
977 return result;
978 }
979
980 protected <T extends TaxonBase> T handlePersisted(TaxonBase taxonBase, Cdm2CdmImportState state) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
981 T result = handlePersisted((IdentifiableEntity)taxonBase, state);
982 //complete
983 result.setName(detach(taxonBase.getName(), state));
984 result.setSecSource(detach(taxonBase.getSecSource(), state));
985 return result;
986 }
987
988 protected <T extends IdentifiableMediaEntity> T handlePersisted(IdentifiableMediaEntity mediaEntity, Cdm2CdmImportState state) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
989 T result = handlePersisted((IdentifiableEntity)mediaEntity, state);
990 //complete
991 handleCollection(result, IdentifiableMediaEntity.class, "media", Media.class, state);
992 return result;
993 }
994
995 protected <T extends SingleSourcedEntityBase> T handlePersisted(SingleSourcedEntityBase referencedEntity, Cdm2CdmImportState state) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
996 T result = handlePersisted((AnnotatableEntity)referencedEntity, state);
997 //complete
998 result.setSource(detach(result.getSource(), state));
999 return result;
1000 }
1001
1002 protected <T extends DescriptionBase> T handlePersisted(DescriptionBase descriptionBase, Cdm2CdmImportState state) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
1003 T result = handlePersisted((IdentifiableEntity)descriptionBase, state);
1004 //complete
1005 handleCollection(result, DescriptionBase.class, "descriptionElements", DescriptionElementBase.class, state);
1006 handleCollection(result, DescriptionBase.class, "descriptiveDataSets", DescriptiveDataSet.class, state);
1007 handleCollection(result, DescriptionBase.class, "descriptionSources", Reference.class, state);
1008 result.setDescribedSpecimenOrObservation(detach(descriptionBase.getDescribedSpecimenOrObservation(), state));
1009 return result;
1010 }
1011
1012 protected <T extends DescriptionElementBase> T handlePersisted(DescriptionElementBase element, Cdm2CdmImportState state) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
1013 T result = handlePersisted((AnnotatableEntity)element, state);
1014 //complete
1015 result.setFeature(detach(result.getFeature(), state));
1016 setInvisible(result, DescriptionElementBase.class, "inDescription", detach(result.getInDescription(), state));
1017 handleCollection(result, DescriptionElementBase.class, "sources", DescriptionElementSource.class, state);
1018 handleCollection(result, DescriptionElementBase.class, "media", Media.class, state);
1019 handleCollection(result, DescriptionElementBase.class, "modifiers", DefinedTerm.class, state);
1020 handleMap(result, DescriptionElementBase.class, "modifyingText", Language.class, LanguageString.class, state);
1021
1022 return result;
1023 }
1024
1025 protected <T extends RelationshipBase> T handlePersisted(RelationshipBase relBase, Cdm2CdmImportState state) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
1026 T result = handlePersisted((SingleSourcedEntityBase)relBase, state);
1027 return result;
1028 }
1029
1030
1031 //************************** COLLECTIONS / MAPS ****************************************/
1032
1033 protected <HOLDER extends CdmBase, ITEM extends CdmBase> void handleCollection(
1034 HOLDER holder, Class<? super HOLDER> declaringClass, String parameter, Class<ITEM> itemClass,
1035 Cdm2CdmImportState state)
1036 throws NoSuchFieldException, IllegalAccessException, InvocationTargetException, NoSuchMethodException {
1037
1038 Collection<ITEM> oldCollection = setNewCollection(holder, declaringClass, parameter, itemClass);
1039 Collection<ITEM> newCollection = getTargetCollection(itemClass, oldCollection, state);
1040 Field field = declaringClass.getDeclaredField(parameter);
1041 field.setAccessible(true);
1042 field.set(holder, newCollection);
1043 }
1044
1045 protected <HOLDER extends CdmBase, KEY extends CdmBase, ITEM extends CdmBase>
1046 void handleMap(
1047 HOLDER holder, Class<? super HOLDER> declaringClass, String parameter,
1048 Class<KEY> keyClass, Class<ITEM> itemClass, Cdm2CdmImportState state)
1049 throws NoSuchFieldException, IllegalAccessException, InvocationTargetException, NoSuchMethodException {
1050
1051 //TODO we do not need to set the new map 2x
1052 Map<KEY,ITEM> oldMap = setNewMap(holder, declaringClass, parameter, keyClass, itemClass);
1053 Map<KEY,ITEM> newMap = getTargetMap(oldMap, state);
1054 Field field = declaringClass.getDeclaredField(parameter);
1055 field.setAccessible(true);
1056 field.set(holder, newMap);
1057 }
1058
1059 protected <T extends CdmBase> Collection<T> setNewCollection(CdmBase obj, Class<?> holderClass,
1060 String parameter, Class<T> entityClass) throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
1061 Field field = holderClass.getDeclaredField(parameter);
1062 field.setAccessible(true);
1063 Collection<T> oldValue = (Collection<T>)field.get(obj);
1064 Collection<T> newValue = null;
1065 if (Set.class.isAssignableFrom(field.getType())){
1066 newValue = new HashSet<>();
1067 }else if (List.class.isAssignableFrom(field.getType())){
1068 newValue = new ArrayList<>();
1069 }else{
1070 throw new RuntimeException("Unsupported collection type: " + field.getType().getCanonicalName());
1071 }
1072 field.set(obj, newValue);
1073 return oldValue;
1074 }
1075
1076 protected <KEY extends CdmBase, ITEM extends CdmBase> Map<KEY,ITEM> setNewMap(CdmBase obj, Class<?> holderClass,
1077 String parameter, Class<KEY> keyClass, Class<ITEM> itemClass) throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
1078 Field field = holderClass.getDeclaredField(parameter);
1079 field.setAccessible(true);
1080 Map<KEY,ITEM> oldValue = (Map<KEY,ITEM>)field.get(obj);
1081 Map<KEY,ITEM> newValue = null;
1082 if (Map.class.isAssignableFrom(field.getType())){
1083 newValue = new HashMap<>();
1084 }else{
1085 throw new RuntimeException("Unsupported map type: " + field.getType().getCanonicalName());
1086 }
1087 field.set(obj, newValue);
1088 return oldValue;
1089 }
1090
1091
1092 private <T extends Collection<S>, S extends CdmBase> Collection<S> getTargetCollection(
1093 Class<S> clazz, T sourceCollection, Cdm2CdmImportState state) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
1094 Collection<S> result = new ArrayList<>();
1095 if (Set.class.isAssignableFrom(sourceCollection.getClass())){
1096 result = new HashSet<>();
1097 }
1098 for (S entity : sourceCollection){
1099 S target = detach(entity, state);
1100 result.add(target);
1101 }
1102 return result;
1103 }
1104
1105 private <K extends CdmBase, V extends CdmBase> Map<K,V> getTargetMap(Map<K,V> sourceMap, Cdm2CdmImportState state) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
1106 Map<K,V> result = new HashMap<>();
1107 for (K key : sourceMap.keySet()){
1108 K targetKey = detach(key, state);
1109 V targetValue = detach(sourceMap.get(key), state);
1110 result.put(targetKey, targetValue);
1111 }
1112 return result;
1113 }
1114
1115 // ****************************** USER HANDLING
1116
1117 private User makeCreatedUpdatedBy(User createdByOriginal, Cdm2CdmImportState state, boolean isUpdatedBy) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
1118 UserImportMode mode = isUpdatedBy? state.getConfig().getUpdatedByMode() : state.getConfig().getCreatedByMode();
1119
1120 switch (mode) {
1121 case NONE:
1122 return null;
1123 case ORIGINAL:
1124 return detach(createdByOriginal, state);
1125 default:
1126 logger.warn("Mode not yet supported: " + mode);
1127 return null;
1128 }
1129 }
1130
1131
1132 // ****************************** INVISIBLE **************************************/
1133
1134 protected void setInvisible(Object holder, String fieldName, Object value) throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
1135 setInvisible(holder, holder.getClass(), fieldName, value);
1136 }
1137 protected void setInvisible(Object holder, Class<?> holderClazz, String fieldName, Object value) throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
1138 Field field = holderClazz.getDeclaredField(fieldName);
1139 field.setAccessible(true);
1140 field.set(holder, value);
1141 }
1142
1143 // ************************* GET TARGET ******************************************/
1144
1145
1146 //TODO this should be cached for partition
1147 private <T extends CdmBase> T getTarget(T source, Cdm2CdmImportState state) {
1148 if (source == null){
1149 return null;
1150 }
1151 T result = getCached(source, state);
1152 // if (result == null){
1153 // Class<T> clazz = (Class<T>)source.getClass();
1154 // result = getCommonService().find(clazz, source.getUuid());
1155 // }
1156 if (result == null){
1157 //Alternative: clone?
1158 result = CdmBase.deproxy(source);
1159 result.setId(0);
1160 cache(result, state);
1161 state.addToSave(result);
1162 }
1163 return result;
1164 }
1165
1166 // ******************* CACHE *******************************************************/
1167
1168 protected void cache(CdmBase cdmBase, Cdm2CdmImportState state) {
1169 if (cdmBase instanceof User || cdmBase instanceof DefinedTermBase){
1170 state.putPermanent(cdmBase.getUuid(), cdmBase);
1171 }else{
1172 state.putToSessionCache(cdmBase);
1173 }
1174 addExistingObject(cdmBase, state);
1175 }
1176
1177 private void addExistingObject(CdmBase cdmBase, Cdm2CdmImportState state) {
1178 cdmBase = CdmBase.deproxy(cdmBase);
1179 Set<UUID> set = state.getExistingObjects(cdmBase.getClass());
1180 if (set == null){
1181 set = loadExistingUuids(cdmBase.getClass(), state);
1182 // set = new HashSet<>();
1183 // existingObjects.put(cdmBase.getClass(), set);
1184 }
1185 set.add(cdmBase.getUuid());
1186 }
1187
1188 protected boolean isInCache(CdmBase cdmBase, Cdm2CdmImportState state) {
1189 return getCached(cdmBase, state) != null;
1190 }
1191
1192 protected <T extends CdmBase> T getCached(T cdmBase, Cdm2CdmImportState state) {
1193 T result = (T)state.getFromSessionCache(cdmBase.getUuid());
1194 if (result == null){
1195 result = (T)state.getPermanent(cdmBase.getUuid());
1196 }
1197 return result;
1198 }
1199
1200 protected void clearCache(Cdm2CdmImportState state) {
1201 state.clearSessionCache();
1202 }
1203
1204 private Reference getSourceReference(Cdm2CdmImportState state) {
1205 UUID uuid = state.getConfig().getSourceRefUuid();
1206 if (uuid == null && state.getConfig().getSourceReference() != null){
1207 uuid = state.getConfig().getSourceReference().getUuid();
1208 state.getConfig().setSourceRefUuid(uuid);
1209 }
1210 Reference result = (Reference)state.getFromSessionCache(uuid);
1211 if (result == null){
1212 result = (Reference)state.getPermanent(uuid);
1213 }
1214 if (result == null){
1215 result = getReferenceService().find(uuid);
1216 }
1217
1218 if (result == null){
1219 result = state.getConfig().getSourceReference();
1220 if (result == null){
1221 result = ReferenceFactory.newDatabase();
1222 //TODO
1223 result.setTitle("Cdm2Cdm Import");
1224 }
1225 getReferenceService().save(result);
1226 state.putToSessionCache(result);
1227 }
1228 return result;
1229 }
1230
1231
1232 protected ITaxonNodeOutStreamPartitioner getTaxonNodePartitioner(Cdm2CdmImportState state, IProgressMonitor monitor,
1233 Cdm2CdmImportConfigurator config) {
1234 ITaxonNodeOutStreamPartitioner partitioner = config.getPartitioner();
1235 if (partitioner == null){
1236 if(!config.isConcurrent()){
1237 partitioner = TaxonNodeOutStreamPartitioner.NewInstance(sourceRepo(state), state,
1238 state.getConfig().getTaxonNodeFilter(), 100,
1239 monitor, 1, TaxonNodeOutStreamPartitioner.fullPropertyPaths);
1240 ((TaxonNodeOutStreamPartitioner)partitioner).setLastCommitManually(true);
1241 }else{
1242 partitioner = TaxonNodeOutStreamPartitionerConcurrent
1243 .NewInstance(state.getConfig().getSource(), state.getConfig().getTaxonNodeFilter(),
1244 1000, monitor, 1, TaxonNodeOutStreamPartitioner.fullPropertyPaths);
1245 }
1246 }
1247 return partitioner;
1248 }
1249
1250 }