Project

General

Profile

Revision 200bc6fb

ID200bc6fb109616b8390aa3821d5dce8dd4180aa3
Parent da12936b
Child 947a405e

Added by Katja Luther over 2 years ago

ref #6166: parsing of siblings and search for siblings in different accessPoints

View differences:

cdmlib-ext/src/main/java/eu/etaxonomy/cdm/ext/occurrence/bioCase/BioCaseQueryGenerator.java
92 92
    private static final String COLLECTOR_PATH_ABCD_2_0 = UNIT_PATH + "/Gathering/Agents/GatheringAgentsText";
93 93
    private static final String ACCESSION_NUMBER_PATH_ABCD_2_0 = UNIT_PATH + "/SpecimenUnit/Accessions/AccessionNumber";
94 94
    private static final String CAT_PATH_ABCD_2_0 = UNIT_PATH + "/CAT";
95
    private static final String ASSOCIATION_UNIT_ID_ABCD_2_0 = UNIT_PATH +"Associations/UnitAssociation/AssociatedUnitID";
95
    private static final String ASSOCIATION_UNIT_ID_ABCD_2_0 = UNIT_PATH +"/Associations/UnitAssociation/AssociatedUnitID";
96 96

  
97 97
    /**
98 98
     * Generates an XML query according to the BioCASe protocol.
cdmlib-ext/src/main/java/eu/etaxonomy/cdm/ext/occurrence/bioCase/BioCaseQueryServiceWrapper.java
147 147
        results.add(unit2.innerDerivedUnit());
148 148
        return results;
149 149
    }
150

  
151
    /**
152
     * @param query
153
     * @param endPoint
154
     * @return
155
     */
156
    public InputStream querySiblings(OccurenceQuery query, URI endPoint) throws ClientProtocolException, IOException{
157
        if(endPoint==null){
158
            logger.warn("URI for querying was null.");
159
            return null;
160
        }
161
        if(UriUtils.isServiceAvailable(endPoint, 10000)){
162
            //check capabilities for ABCD version
163
            Map<String, String> requestHeaders = new HashMap<String, String>();
164
            requestHeaders.put(CAPABILITY_TEST_PARAM.getName(), CAPABILITY_TEST_PARAM.getValue());
165
            InputStream response = executeHttpGet(endPoint, requestHeaders);
166
            String abcdSchema = parseAbcdSchemaVersion(response);
167

  
168
            //build XML query
169
            Document doc = BioCaseQueryGenerator.generateXMLQueryForSiblings(query, abcdSchema);
170
            String xmlOutputString = new XMLOutputter(Format.getPrettyFormat()).outputString(doc);
171

  
172
            //POST parameters
173
            List<NameValuePair> queryParamsPOST = new ArrayList<NameValuePair>();
174
            queryParamsPOST.add(SUBMIT_PARAM);
175
            addNameValuePairTo(queryParamsPOST, QUERY_PARAM_NAME, xmlOutputString);
176
            UrlEncodedFormEntity httpEntity = new UrlEncodedFormEntity(queryParamsPOST);
177

  
178
            //Query provider
179
            logger.info("Querying BioCASE service with " + endPoint + ", POST: " + queryParamsPOST);
180
            //FIXME do the ABCD import here
181
            return executeHttpPost(endPoint, null, httpEntity);
182
        }
183
        else{
184
            logger.error("Querying " + endPoint + " got a timeout!");
185
            return null;
186
        }
187
    }
150 188
}
cdmlib-ext/src/main/java/eu/etaxonomy/cdm/ext/occurrence/gbif/GbifJsonOccurrenceParser.java
257 257
                                name = TaxonNameFactory.NewCultivarInstance(rank);
258 258
                            } else if (string.equals(NomenclaturalCode.ICVCN.getTitleCache())){
259 259
                                name = TaxonNameFactory.NewViralInstance(rank);
260
                            } else {
260
                            } else if (string.equals("ICN")){
261
                                name = TaxonNameFactory.NewBotanicalInstance(rank);
261 262
                            }
262 263
                        }else {
263 264
                            if (record.has(KINGDOM)){
......
276 277
                                name = TaxonNameFactory.NewNonViralInstance(rank);
277 278
                            }
278 279
                        }
280
                        if (name == null){
281
                            name = TaxonNameFactory.NewNonViralInstance(rank);
282
                        }
279 283
                        if (record.has(GENUS)){
280 284
                            name.setGenusOrUninomial(record.getString(GENUS));
281 285
                        }
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/specimen/SpecimenImportBase.java
27 27
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
28 28
import eu.etaxonomy.cdm.io.common.CdmImportBase;
29 29
import eu.etaxonomy.cdm.io.common.IImportConfigurator;
30
import eu.etaxonomy.cdm.io.specimen.abcd206.in.Abcd206ImportState;
30 31
import eu.etaxonomy.cdm.io.specimen.abcd206.in.Identification;
31 32
import eu.etaxonomy.cdm.io.specimen.abcd206.in.SpecimenImportReport;
32 33
import eu.etaxonomy.cdm.model.agent.AgentBase;
......
97 98
	 * @param state
98 99
	 * @param item
99 100
	 */
100
	protected abstract void handleSingleUnit(STATE state, Object item) ;
101
	protected abstract void handleSingleUnit(STATE state, Object item, boolean handleAssociatedUnits) ;
101 102

  
102 103

  
103 104

  
......
1466 1467
	        }
1467 1468
	    }
1468 1469

  
1470
        /**
1471
         * @param state
1472
         * @param itemObject
1473
         * @param handleAssociatedUnits
1474
         */
1475
        public void handleSingleUnit(Abcd206ImportState state, Object itemObject, boolean handleAssociatedUnits) {
1476
            // TODO Auto-generated method stub
1477

  
1478
        }
1479

  
1469 1480
}
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/specimen/abcd206/in/Abcd206DataHolder.java
39 39

  
40 40

  
41 41

  
42
    protected List<String> associatedUnitIds;
42
    protected List<String[]> associatedUnitIds;
43 43

  
44 44

  
45 45
    protected String institutionCode;
......
134 134
        setMultimediaObjects(new HashMap<String,Map<String, String>>());
135 135
        setGatheringMultimediaObjects(new HashMap<String,Map<String, String>>());
136 136
        setDocSources(new ArrayList<String>());
137
        associatedUnitIds = new ArrayList<String>();
137
        associatedUnitIds = new ArrayList<String[]>();
138 138
    }
139 139

  
140 140

  
......
222 222
        return this.gatheringMethod ;
223 223

  
224 224
    }
225
    public void addAssociatedUnitId(String associatedUnitId){
225
    public void addAssociatedUnitId(String[] associatedUnitId){
226 226
        this.associatedUnitIds.add(associatedUnitId);
227 227
    }
228 228

  
229
    public List<String> getAssociatedUnitIds(){
229
    public List<String[]> getAssociatedUnitIds(){
230 230
        return associatedUnitIds;
231 231
    }
232 232

  
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/specimen/abcd206/in/Abcd206Import.java
125 125
                    logger.error("An error during ABCD import");
126 126
                }
127 127
            }
128
            SpecimenUserInteraction sui = ((Abcd206ImportConfigurator)state.getConfig()).getSpecimenUserInteraction();
128
            SpecimenUserInteraction sui = state.getConfig().getSpecimenUserInteraction();
129 129

  
130 130
            //init import reference
131 131
        //  List<Reference> references = getReferenceService().list(Reference.class, null, null, null, null);
......
154 154
//                }
155 155
//            }else{
156 156
                if (state.getRef()==null){
157
                    String name = NB(((Abcd206ImportConfigurator) state.getConfig()).getSourceReferenceTitle());
157
                    String name = NB(state.getConfig().getSourceReferenceTitle());
158 158
                    for (Reference reference : referenceStore.getAllValues()) {
159 159
                        if (! StringUtils.isBlank(reference.getTitleCache())) {
160 160
                            if (reference.getTitleCache().equalsIgnoreCase(name)) {
......
169 169
                }
170 170
            //}
171 171
            save(state.getRef(), state);
172
            ((Abcd206ImportConfigurator) state.getConfig()).setSourceReference(state.getRef());
172
            state.getConfig().setSourceReference(state.getRef());
173 173

  
174
            if(((Abcd206ImportConfigurator) state.getConfig()).getClassificationUuid()!=null){
174
            if(state.getConfig().getClassificationUuid()!=null){
175 175
                //load classification from config if it exists
176
                state.setClassification(getClassificationService().load(((Abcd206ImportConfigurator) state.getConfig()).getClassificationUuid()));
176
                state.setClassification(getClassificationService().load(state.getConfig().getClassificationUuid()));
177 177
            }
178 178
            if(state.getClassification()==null){//no existing classification was set in config
179 179
                List<Classification> classificationList = getClassificationService().list(Classification.class, null, null, null, null);
180 180
                //get classification via user interaction
181
                if (((Abcd206ImportConfigurator) state.getConfig()).isUseClassification() && ((Abcd206ImportConfigurator) state.getConfig()).isInteractWithUser()){
181
                if (state.getConfig().isUseClassification() && state.getConfig().isInteractWithUser()){
182 182
                    Map<String,Classification> classMap = new HashMap<String, Classification>();
183 183
                    for (Classification tree : classificationList) {
184 184
                        if (! StringUtils.isBlank(tree.getTitleCache())) {
......
198 198
                }
199 199
                // use default classification as the classification to import into
200 200
                if (state.getClassification() == null) {
201
                    String name = NB(((Abcd206ImportConfigurator) state.getConfig()).getClassificationName());
201
                    String name = NB(state.getConfig().getClassificationName());
202 202
                    for (Classification classif : classificationList){
203 203
                        if (classif.getTitleCache() != null && classif.getTitleCache().equalsIgnoreCase(name)) {
204 204
                            state.setClassification(classif);
......
215 215
            }
216 216

  
217 217
            if (response == null){
218
                response =(InputStream) ((Abcd206ImportConfigurator) state.getConfig()).getSource();
218
                response =state.getConfig().getSource();
219 219
            }
220 220
            UnitAssociationWrapper unitAssociationWrapper = AbcdParseUtility.parseUnitsNodeList(response, state.getReport());
221 221
            NodeList unitsList = unitAssociationWrapper.getAssociatedUnits();
......
258 258

  
259 259
                    //import unit + field unit data
260 260
                    state.setAssociatedUnitIds(state.getDataHolder().getAssociatedUnitIds());
261
                    this.handleSingleUnit(state, item);
261
                    this.handleSingleUnit(state, item, true);
262 262

  
263
//                    if (state.getConfig().isGetSiblings() && (state.getDataHolder().getKindOfUnit().toLowerCase().indexOf("clone")>-1 || state.getDataHolder().getRecordBasis().toLowerCase().indexOf("sample")>-1)){
263
//                   if (state.getDataHolder().getKindOfUnit() != null && state.getConfig().isGetSiblings() && (state.getDataHolder().getKindOfUnit().toLowerCase().indexOf("clone")>-1 || state.getDataHolder().getRecordBasis().toLowerCase().indexOf("sample")>-1)){
264 264
//                        getSiblings(state, sourceUri);
265 265
//                    }
266
//                   if (state.getConfig().isSearchForAssociatingSpecimen()){
267
//                       getAssociatingSpecimen(state, sourceUri);
268
//                   }
266 269

  
267 270
                }
268
                if(((Abcd206ImportConfigurator)state.getConfig()).isDeduplicateReferences()){
271
                if(state.getConfig().isDeduplicateReferences()){
269 272
                    getReferenceService().deduplicate(Reference.class, null, null);
270 273
                }
271
                if(((Abcd206ImportConfigurator)state.getConfig()).isDeduplicateClassifications()){
274
                if(state.getConfig().isDeduplicateClassifications()){
272 275
                    getClassificationService().deduplicate(Classification.class, null, null);
273 276
                }
274 277
            }
......
285 288
        return;
286 289
    }
287 290

  
291

  
288 292
    /**
289 293
     * @param state
290 294
     * @param item
291 295
     */
292
    private void getSiblings(Abcd206ImportState state, URI sourceUri) {
296
    private void getSiblings(Abcd206ImportState state, Object item, DerivedUnitFacade facade) {
293 297
        NodeList unitAssociationList = null;
294 298

  
295
        List<String> unitIds = state.getAssociatedUnitIds();
296

  
299
        String unitId = facade.getCatalogNumber();
297 300

  
298
        URI accessPoint = sourceUri;
299
        for (String unitId:unitIds){
300 301
            UnitAssociationParser unitParser = new UnitAssociationParser(state.getPrefix(), state.getReport(), state.getCdmRepository());
301
            UnitAssociationWrapper unitAssociationWrapper = unitParser.parseSiblings(unitId, accessPoint);
302
            UnitAssociationWrapper unitAssociationWrapper = null;
303
            for (URI accessPoint: state.getActualAccesPoint()){
304
                unitAssociationWrapper = unitParser.parseSiblings(unitId, accessPoint);
305
                if (unitAssociationWrapper.getAssociatedUnits() != null){
306
                    break;
307
                }
308
            }
309

  
302 310
            DerivedUnit currentUnit = state.getDerivedUnitBase();
303 311
           DerivationEvent currentDerivedFrom = currentUnit.getDerivedFrom();
312
           FieldUnit currentFieldUnit = facade.getFieldUnit(false);
304 313
            if(unitAssociationWrapper!=null){
305 314
                NodeList associatedUnits = unitAssociationWrapper.getAssociatedUnits();
306 315
                if(associatedUnits!=null){
307 316
                    for(int m=0;m<associatedUnits.getLength();m++){
308 317
                        if(associatedUnits.item(m) instanceof Element){
309 318
                            state.reset();
310
                            state.setPrefix(unitAssociationWrapper.getPrefix());
311
                            Abcd206ImportParser.setUnitPropertiesXML((Element) associatedUnits.item(m), new Abcd206XMLFieldGetter(state.getDataHolder(), state.getPrefix()), state);
319
                            //state.setPrefix(unitAssociationWrapper.getPrefix());
320

  
321
                            String associationType = AbcdParseUtility.parseFirstTextContent(((Element) associatedUnits.item(m)).getElementsByTagName(state.getPrefix()+"AssociationType"));
322

  
323
                            Abcd206ImportParser.setUnitPropertiesXML((Element) associatedUnits.item(m), new Abcd206XMLFieldGetter(state.getDataHolder(), unitAssociationWrapper.getPrefix()), state);
312 324
                           // logger.debug("derived unit: " + state.getDerivedUnitBase().toString() + " associated unit: " +state.getDataHolder().getKindOfUnit() + ", " + state.getDataHolder().accessionNumber + ", " + state.getDataHolder().getRecordBasis() + ", " + state.getDataHolder().getUnitID());
313
                            handleSingleUnit(state, associatedUnits.item(m));
325
                            handleSingleUnit(state, associatedUnits.item(m), false);
314 326

  
315 327
                            DerivedUnit associatedUnit = state.getDerivedUnitBase();
316 328
                            FieldUnit associatedFieldUnit = null;
......
327 339

  
328 340
                            //parent-child relation:
329 341
                            //copy derivation event and connect parent and sub derivative
330
                            if(unitAssociationWrapper.getAssociationType().contains("individual") || unitAssociationWrapper.getAssociationType().contains("culture") ){
342
                            if(associationType.contains("individual") || associationType.contains("culture") || associationType.contains("sample")){
331 343
                                if(currentDerivedFrom==null){
332 344
                                    state.getReport().addInfoMessage(String.format("No derivation event found for unit %s. Defaulting to ACCESSIONING event.",SpecimenImportUtility.getUnitID(currentUnit, state.getConfig())));
333 345
                                    DerivationEvent.NewSimpleInstance(associatedUnit, currentUnit, DerivationEventType.ACCESSIONING());
334 346
                                }
335 347
                                else{
336
                                    DerivationEvent updatedDerivationEvent = DerivationEvent.NewSimpleInstance(associatedUnit, currentUnit, currentDerivedFrom.getType());
348
                                    DerivationEvent updatedDerivationEvent = DerivationEvent.NewSimpleInstance(currentUnit, associatedUnit, currentDerivedFrom.getType());
337 349
                                    updatedDerivationEvent.setActor(currentDerivedFrom.getActor());
338 350
                                    updatedDerivationEvent.setDescription(currentDerivedFrom.getDescription());
339 351
                                    updatedDerivationEvent.setInstitution(currentDerivedFrom.getInstitution());
......
342 354
                                }
343 355
                                state.getReport().addDerivate(associatedUnit, currentUnit, state.getConfig());
344 356
                            }
357
                            //siblings relation
358
                            //connect current unit to field unit of associated unit
359
                            else if(associationType.contains("population")|| associationType.contains("sample")){
360
                                //no associated field unit -> using current one
361
                                if(associatedFieldUnit==null){
362
                                    if(currentFieldUnit!=null){
363
                                        DerivationEvent.NewSimpleInstance(currentFieldUnit, associatedUnit, DerivationEventType.ACCESSIONING());
364
                                    }
365
                                }
366
                                else{
367
                                    if(currentDerivedFrom==null){
368
                                        state.getReport().addInfoMessage("No derivation event found for unit "+SpecimenImportUtility.getUnitID(currentUnit, state.getConfig())+". Defaulting to ACCESIONING event.");
369
                                        DerivationEvent.NewSimpleInstance(associatedFieldUnit, currentUnit, DerivationEventType.ACCESSIONING());
370
                                    }
371
                                    if(currentDerivedFrom!=null && associatedFieldUnit!=currentFieldUnit){
372
                                        DerivationEvent updatedDerivationEvent = DerivationEvent.NewSimpleInstance(associatedFieldUnit, currentUnit, currentDerivedFrom.getType());
373
                                        updatedDerivationEvent.setActor(currentDerivedFrom.getActor());
374
                                        updatedDerivationEvent.setDescription(currentDerivedFrom.getDescription());
375
                                        updatedDerivationEvent.setInstitution(currentDerivedFrom.getInstitution());
376
                                        updatedDerivationEvent.setTimeperiod(currentDerivedFrom.getTimeperiod());
377
                                    }
378
                                }
379
                            }
345 380

  
346 381

  
347 382

  
348 383
                            save(associatedUnit, state);
349
                        }
384

  
350 385
                    }
351 386
                }
352 387
            }
353 388
        }
389
            state.reset();
390
            state.setDerivedUnitBase(currentUnit);
391
            //state.setPrefix(currentPrefix);
354 392
    }
355 393

  
356 394
    /**
......
360 398
     */
361 399
    @Override
362 400
    @SuppressWarnings("rawtypes")
363
    public void handleSingleUnit(Abcd206ImportState state, Object itemObject) {
401
    public void handleSingleUnit(Abcd206ImportState state, Object itemObject, boolean handleAssociatedUnits) {
364 402
        Element item = (Element) itemObject;
365 403

  
366 404
        Abcd206ImportConfigurator config = state.getConfig();
......
374 412
            }
375 413
            //check if unit already exists
376 414
            DerivedUnitFacade derivedUnitFacade = null;
377
            if(((Abcd206ImportConfigurator)state.getConfig()).isIgnoreImportOfExistingSpecimen()){
415
            if(state.getConfig().isIgnoreImportOfExistingSpecimen()){
378 416
                SpecimenOrObservationBase<?> existingSpecimen = findExistingSpecimen(state.getDataHolder().getUnitID(), state);
379 417
                if(existingSpecimen!=null && existingSpecimen.isInstanceOf(DerivedUnit.class)){
380 418
                    DerivedUnit derivedUnit = HibernateProxyHelper.deproxy(existingSpecimen, DerivedUnit.class);
381 419
                    state.setDerivedUnitBase(derivedUnit);
382 420
                    derivedUnitFacade = DerivedUnitFacade.NewInstance(state.getDerivedUnitBase());
383
                    importAssociatedUnits(state, item, derivedUnitFacade);
421
                    if (handleAssociatedUnits){
422
                        importAssociatedUnits(state, item, derivedUnitFacade);
423
                    }
384 424
                    state.getReport().addAlreadyExistingSpecimen(SpecimenImportUtility.getUnitID(derivedUnit, config), derivedUnit);
385 425
                    return;
386 426
                }
......
530 570
                        }
531 571

  
532 572
                        derivedUnitFacade.addDerivedUnitMedia(media);
533
                        if(((Abcd206ImportConfigurator)state.getConfig()).isAddMediaAsMediaSpecimen()){
573
                        if(state.getConfig().isAddMediaAsMediaSpecimen()){
534 574
                            //add media also as specimen scan
535 575
                            MediaSpecimen mediaSpecimen = MediaSpecimen.NewInstance(SpecimenOrObservationType.StillImage);
536 576
                            mediaSpecimen.setMediaSpecimen(media);
......
670 710

  
671 711
            addToSourceMap(sourceMap, osbSet);
672 712

  
673
            if( ((Abcd206ImportConfigurator) state.getConfig()).isInteractWithUser()){
713
            if( state.getConfig().isInteractWithUser()){
674 714
                List<OriginalSourceBase<?>>sources=null;
675 715
                if(!state.isDerivedUnitSourcesSet()){
676 716
                    sources= sui.askForSource(sourceMap, "the unit itself","",getReferenceService(), state.getDataHolder().getDocSources());
......
721 761
            handleIdentifications(state, derivedUnitFacade);
722 762

  
723 763
            //associatedUnits
724
            importAssociatedUnits(state, item, derivedUnitFacade);
725

  
764
            if (handleAssociatedUnits){
765
                importAssociatedUnits(state, item, derivedUnitFacade);
766
            }
767
            if (derivedUnitFacade.getType() != null && (derivedUnitFacade.getType().equals(SpecimenOrObservationType.LivingSpecimen) ||  derivedUnitFacade.getType().equals(SpecimenOrObservationType.TissueSample) ) &&state.getConfig().isGetSiblings()){
768
                getSiblings(state, item, derivedUnitFacade);
769
            }
726 770

  
727 771

  
728 772
        } catch (Exception e) {
......
758 802
                    Element unitAssociation = (Element)unitAssociationList.item(k);
759 803
                    UnitAssociationParser unitAssociationParser = new UnitAssociationParser(currentPrefix, state.getReport(), state.getCdmRepository());
760 804
                    UnitAssociationWrapper associationWrapper = unitAssociationParser.parse(unitAssociation);
805
                    state.addActualAccesPoint(associationWrapper.getAccesPoint());
761 806
                    if(associationWrapper!=null){
762 807
                        NodeList associatedUnits = associationWrapper.getAssociatedUnits();
763 808
                        if(associatedUnits!=null){
......
767 812
                                    state.setPrefix(associationWrapper.getPrefix());
768 813
                                    Abcd206ImportParser.setUnitPropertiesXML((Element) associatedUnits.item(m), new Abcd206XMLFieldGetter(state.getDataHolder(), state.getPrefix()), state);
769 814
                                    logger.debug("derived unit: " + state.getDerivedUnitBase().toString() + " associated unit: " +state.getDataHolder().getKindOfUnit() + ", " + state.getDataHolder().accessionNumber + ", " + state.getDataHolder().getRecordBasis() + ", " + state.getDataHolder().getUnitID());
770
                                    handleSingleUnit(state, associatedUnits.item(m));
815
                                    handleSingleUnit(state, associatedUnits.item(m), true);
771 816

  
772 817
                                    DerivedUnit associatedUnit = state.getDerivedUnitBase();
773 818
                                    FieldUnit associatedFieldUnit = null;
......
784 829

  
785 830
                                    //parent-child relation:
786 831
                                    //copy derivation event and connect parent and sub derivative
787
                                    if(associationWrapper.getAssociationType().contains("individual") || associationWrapper.getAssociationType().contains("culture") ){
832
                                    if(associationWrapper.getAssociationType().contains("individual") || associationWrapper.getAssociationType().contains("culture") || associationWrapper.getAssociationType().contains("sample")){
788 833
                                        if(currentDerivedFrom==null){
789 834
                                            state.getReport().addInfoMessage(String.format("No derivation event found for unit %s. Defaulting to ACCESSIONING event.",SpecimenImportUtility.getUnitID(currentUnit, config)));
790 835
                                            DerivationEvent.NewSimpleInstance(associatedUnit, currentUnit, DerivationEventType.ACCESSIONING());
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/specimen/abcd206/in/Abcd206ImportState.java
11 11

  
12 12
import java.io.ByteArrayOutputStream;
13 13
import java.io.PrintStream;
14
import java.net.URI;
14 15
import java.util.ArrayList;
15 16
import java.util.List;
16 17

  
......
30 31

  
31 32
	private String prefix;
32 33

  
33
	private List<String> associatedUnitIds = new ArrayList<String>();
34
	private List<String[]> associatedUnitIds = new ArrayList<String[]>();
35

  
36
	private List<URI> actualAccesPoints = new ArrayList<>();
34 37

  
35 38

  
36 39
//****************** CONSTRUCTOR ***************************************************/
......
71 74
        return importStream.toByteArray();
72 75
    }
73 76

  
74
    public void setAssociatedUnitIds(List<String> associatedUnitIds){
77
    public void setAssociatedUnitIds(List<String[]> associatedUnitIds){
75 78
        this.associatedUnitIds = associatedUnitIds;
76 79
    }
77 80

  
78
    public List<String> getAssociatedUnitIds(){
81
    public List<String[]> getAssociatedUnitIds(){
79 82
        return this.associatedUnitIds;
80 83
    }
81 84

  
85
    /**
86
     * @return the actualAccesPoint
87
     */
88
    public List<URI> getActualAccesPoint() {
89
        return actualAccesPoints;
90
    }
91

  
92
    /**
93
     * @param actualAccesPoint the actualAccesPoint to set
94
     */
95
    public void addActualAccesPoint(URI actualAccesPoint) {
96
        this.actualAccesPoints.add(actualAccesPoint);
97
    }
98

  
82 99
//
83 100
//    public void reset() {
84 101
//        getDataHolder().reset();
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/specimen/abcd206/in/Abcd206XMLFieldGetter.java
866 866
                for (int j = 0; j < childrenAssociations.getLength(); j++) {
867 867
                    if (childrenAssociations.item(j).getNodeName().equals(prefix + "UnitAssociation")) {
868 868
                        childrenUnitAssociations = childrenAssociations.item(j).getChildNodes();
869
                        String[] associatedUnitId = new String[2];
869 870
                        for (int k = 0; k < childrenUnitAssociations.getLength(); k++) {
871
                            System.err.println(childrenUnitAssociations.item(k).getNodeName());
870 872
                            if (childrenUnitAssociations.item(k).getNodeName().equals(prefix + "UnitID")) {
871
                                dataHolder.addAssociatedUnitId(childrenUnitAssociations.item(k).getTextContent());
873
                                associatedUnitId[0]= childrenUnitAssociations.item(k).getTextContent();
874

  
872 875
                                path = childrenUnitAssociations.item(k).getNodeName();
873 876
                                getHierarchie(childrenUnitAssociations.item(k));
874 877
                                dataHolder.knownABCDelements.add(path);
875 878
                                path = "";
876 879
                            }
880
                            if (childrenUnitAssociations.item(k).getNodeName().equals(prefix +"DatasetAccessPoint")){
881
                                associatedUnitId[1]= childrenUnitAssociations.item(k).getTextContent();
882
                                System.err.println(childrenUnitAssociations.item(k).getTextContent());
883
                            }
877 884
                        }
885
                        dataHolder.addAssociatedUnitId(associatedUnitId);
878 886
                    }
879 887
                }
880 888
            }
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/specimen/abcd206/in/UnitAssociationParser.java
94 94

  
95 95
                    if(unitAssociationWrapper!=null){
96 96
                        unitAssociationWrapper.setAssociationType(associationType);
97
                        unitAssociationWrapper.setAccesPoint(datasetAccessPoint);
97 98
                        if(unitAssociationWrapper.getAssociatedUnits()!=null && unitAssociationWrapper.getAssociatedUnits().getLength()>1){
98 99
                            String moreThanOneUnitFoundMessage = String.format("More than one unit was found for unit association to %s", unitId);
99 100
                            logger.warn(moreThanOneUnitFoundMessage);
......
129 130

  
130 131
            OccurenceQuery query = new OccurenceQuery(unitID);
131 132

  
133

  
132 134
                InputStream inputStream;
133 135
                try {
134
                    inputStream = serviceWrapper.query(query, datasetAccessPoint);
136
                    inputStream = serviceWrapper.querySiblings(query, datasetAccessPoint);
135 137

  
136 138
                    if(inputStream!=null){
137 139
                    UnitAssociationWrapper unitAssociationWrapper = null;
138 140
                    try {
139 141
                        unitAssociationWrapper = AbcdParseUtility.parseUnitsNodeList(inputStream, report);
142

  
140 143
                    } catch (Exception e) {
141 144
                        String exceptionMessage = "An exception occurred during parsing of associated units!";
142 145
                        logger.error(exceptionMessage, e);
......
150 153
                            logger.warn(moreThanOneUnitFoundMessage);
151 154
                            report.addInfoMessage(moreThanOneUnitFoundMessage);
152 155
                        }
156

  
153 157
                    }
154 158
                    return unitAssociationWrapper;
155 159
                    }
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/specimen/abcd206/in/UnitAssociationWrapper.java
8 8
*/
9 9
package eu.etaxonomy.cdm.io.specimen.abcd206.in;
10 10

  
11
import java.net.URI;
12

  
11 13
import org.w3c.dom.NodeList;
12 14

  
13 15
/**
......
20 22
public class UnitAssociationWrapper {
21 23

  
22 24
    private NodeList associatedUnits;
25
    private URI accesPoint;
23 26
    private String associationType;
24 27
    private String prefix;
25 28

  
......
47 50
        this.prefix = prefix;
48 51
    }
49 52

  
53
    /**
54
     * @return the accesPoint
55
     */
56
    public URI getAccesPoint() {
57
        return accesPoint;
58
    }
59

  
60
    /**
61
     * @param accesPoint the accesPoint to set
62
     */
63
    public void setAccesPoint(URI accesPoint) {
64
        this.accesPoint = accesPoint;
65
    }
66

  
50 67
}

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)