Project

General

Profile

Revision 91e5776b

ID91e5776b3777175dd0a9af3e4544f429a5be2ef0
Parent d9b720ac
Child 4b37153c

Added by Katja Luther about 5 years ago

specimen import/search changes

View differences:

cdmlib-ext/src/main/java/eu/etaxonomy/cdm/ext/occurrence/bioCase/BioCaseQueryGenerator.java
146 146
            }
147 147
        }
148 148
        if(query.accessionNumber!=null && !query.accessionNumber.trim().isEmpty()){
149
            addLikeFilter(elAnd, query.accessionNumber, ACCESSION_NUMBER_PATH_ABCD_2_0);
149
            Element elOr = new Element(OR);
150
            addLikeFilter(elOr, query.accessionNumber, ACCESSION_NUMBER_PATH_ABCD_2_0);
151
            addLikeFilter(elOr, query.accessionNumber, CAT_PATH_ABCD_2_0);
152
            addLikeFilter(elOr, query.accessionNumber, UNIT_ID_PATH_ABCD_2_0);
153
            elAnd.addContent(elOr);
150 154
        }
151 155
        if(query.collector!=null && !query.collector.trim().isEmpty()){
152 156
            addLikeFilter(elAnd, query.collector, COLLECTOR_PATH_ABCD_2_0);
cdmlib-ext/src/main/java/eu/etaxonomy/cdm/ext/occurrence/gbif/GbifJsonOccurrenceParser.java
24 24
import net.sf.json.JSONObject;
25 25

  
26 26
import org.apache.commons.io.IOUtils;
27
import org.apache.http.HttpException;
27 28
import org.apache.log4j.Logger;
28 29

  
29 30
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
30 31
import eu.etaxonomy.cdm.common.UriUtils;
32
import eu.etaxonomy.cdm.common.media.ImageInfo;
31 33
import eu.etaxonomy.cdm.model.agent.Institution;
32 34
import eu.etaxonomy.cdm.model.agent.Person;
33 35
import eu.etaxonomy.cdm.model.common.IdentifiableSource;
......
35 37
import eu.etaxonomy.cdm.model.location.Country;
36 38
import eu.etaxonomy.cdm.model.location.Point;
37 39
import eu.etaxonomy.cdm.model.location.ReferenceSystem;
40
import eu.etaxonomy.cdm.model.media.ImageFile;
41
import eu.etaxonomy.cdm.model.media.Media;
42
import eu.etaxonomy.cdm.model.media.MediaRepresentation;
38 43
import eu.etaxonomy.cdm.model.name.BacterialName;
39 44
import eu.etaxonomy.cdm.model.name.BotanicalName;
40 45
import eu.etaxonomy.cdm.model.name.CultivarPlantName;
......
158 163

  
159 164
    private static final String BACTERIA = "Bacteria";
160 165

  
166
    private static final String MULTIMEDIA = "media";
167

  
168

  
161 169

  
162 170

  
163 171

  
......
419 427
                    derivedUnitFacade.addSource(source);
420 428
                }
421 429

  
430
                if (record.has(MULTIMEDIA)){
431
                    //http://ww2.bgbm.org/herbarium/images/B/-W/08/53/B_-W_08537%20-00%201__3.jpg
432
                    JSONArray multimediaArray = record.getJSONArray(MULTIMEDIA);
433
                    JSONObject mediaRecord;
434
                    Media media;
435
                    URI uri = null;
436
                    ImageInfo imageInf = null;
437
                    MediaRepresentation representation = null;
438
                    SpecimenOrObservationType type = null;
439
                    for(Object object:multimediaArray){
440
                        //parse every record
441
                       media = Media.NewInstance();
442
                       uri = null;
443
                       imageInf = null;
444

  
445
                        if(object instanceof JSONObject){
446
                            mediaRecord = (JSONObject) object;
447

  
448
                            if (mediaRecord.has("identifier")){
449
                                try {
450
                                    uri = new URI(mediaRecord.getString("identifier"));
451
                                    imageInf = ImageInfo.NewInstance(uri, 0);
452

  
453
                                } catch (URISyntaxException |IOException | HttpException e) {
454
                                    // TODO Auto-generated catch block
455
                                    e.printStackTrace();
456
                                }
457
                               // media.addIdentifier(mediaRecord.getString("identifier"), null);
458
                            }
459
                            if (mediaRecord.has("references")){
460

  
461

  
462
                            }
463
                            if (mediaRecord.has("format")){
464

  
465
                            }
466
                            if (mediaRecord.has("type")){
467
                                if (mediaRecord.get("type").equals("StillImage")){
468
                                    type = SpecimenOrObservationType.StillImage;
469
                                }
470
                            }
471

  
472
                            }
473
                            ImageFile imageFile = ImageFile.NewInstance(uri, null, imageInf);
474
                            representation = MediaRepresentation.NewInstance();
475

  
476
                            representation.addRepresentationPart(imageFile);
477
                            media.addRepresentation(representation);
478

  
479
                            derivedUnitFacade.addDerivedUnitMedia(media);
480
                        }
481
                    //identifier=http://ww2.bgbm.org/herbarium/images/B/-W/08/53/B_-W_08537%20-00%201__3.jpg
482
                   //references=http://ww2.bgbm.org/herbarium/view_biocase.cfm?SpecimenPK=136628
483
                    //format=image/jpeg
484
                    //type=StillImage
485

  
486
                }
487

  
422 488
                // create dataset URL
423 489
                URI uri = null;
424 490
                try {
cdmlib-ext/src/main/java/eu/etaxonomy/cdm/ext/occurrence/gbif/GbifQueryGenerator.java
36 36
        // only look for preserved specimens
37 37

  
38 38
        if (checkForValidQuery(query)) {
39
            ServiceWrapperBase.addNameValuePairTo(queryParamsGET, "basisOfRecord", "PRESERVED_SPECIMEN");
39
            //ServiceWrapperBase.addNameValuePairTo(queryParamsGET, "basisOfRecord", "PRESERVED_SPECIMEN");
40 40

  
41 41
            ServiceWrapperBase.addNameValuePairTo(queryParamsGET, "limit", "100");
42 42
            if (query.tripleIds != null){
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/excel/taxa/NormalExplicitImport.java
53 53
import eu.etaxonomy.cdm.model.reference.INomenclaturalReference;
54 54
import eu.etaxonomy.cdm.model.reference.Reference;
55 55
import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
56
import eu.etaxonomy.cdm.model.reference.ReferenceType;
56 57
import eu.etaxonomy.cdm.model.taxon.Classification;
57 58
import eu.etaxonomy.cdm.model.taxon.Synonym;
58 59
import eu.etaxonomy.cdm.model.taxon.SynonymRelationshipType;
......
636 637
			        ref.setAuthorship(taxonNameBase.getCombinationAuthorship());
637 638
			    }
638 639

  
639
			    ref.setProtectedAbbrevTitleCache(false);
640
			    ref.setProtectedTitleCache(false);
640
			    if (ref.getAbbrevTitle() == null && !ref.isOfType(ReferenceType.Article)) {
641
                    ref.setAbbrevTitle(reference);
642
                    ref.setProtectedAbbrevTitleCache(false);
643
                }
644

  
645
                ref.setProtectedTitleCache(false);
641 646

  
642 647
			    taxonNameBase.setNomenclaturalReference(ref);
643 648
			}
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/service/IOServiceImpl.java
117 117
            stream.write(importData);
118 118
            config.setSource(tempFilePath.toUri());
119 119
            result = cdmImport.execute(config);
120
            Files.delete(tempFilePath);
120
     //       Files.delete(tempFilePath);
121 121
        } catch (Exception e) {
122 122
            throw new RuntimeException(e);
123 123
        } finally {
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/specimen/SpecimenDataHolder.java
36 36
    protected String gatheringElevation;
37 37

  
38 38
    private String gatheringElevationUnit;
39
    protected Double depth;
40
    /**
41
     * @return the depth
42
     */
43
    public Double getDepth() {
44
        return depth;
45
    }
46

  
47

  
48

  
49
    /**
50
     * @param depth the depth to set
51
     */
52
    public void setDepth(Double depth) {
53
        this.depth = depth;
54
    }
55

  
56

  
57

  
39 58
    private String gatheringSpatialDatum;
40 59
    private String gatheringCoordinateErrorMethod;
41 60
    private String kindOfUnit;
......
44 63
    private String fieldNumber;
45 64
    private String unitNotes; //  occurenceRemarks(DwCA)
46 65

  
47
    private List<String> multimediaObjects;
66
    private HashMap<String, Map<String,String>> multimediaObjects;
67
    private HashMap<String, Map<String,String>> gatheringMultimediaObjects;
48 68
    private List<Identification> identificationList;
49 69

  
50 70
    private List<SpecimenTypeDesignationStatus> statusList;
......
294 314

  
295 315
        gatheringElevationUnit = null;
296 316
        gatheringSpatialDatum = null;
297
       gatheringCoordinateErrorMethod = null;
317
        gatheringCoordinateErrorMethod = null;
318
        depth = null;
298 319

  
299 320

  
300 321
    }
......
340 361
    /**
341 362
     * @return the multimediaObjects
342 363
     */
343
    public List<String> getMultimediaObjects() {
364
    public HashMap<String,Map<String, String>> getMultimediaObjects() {
344 365
        return multimediaObjects;
345 366
    }
346 367

  
......
349 370
    /**
350 371
     * @param multimediaObjects the multimediaObjects to set
351 372
     */
352
    public void setMultimediaObjects(List<String> multimediaObjects) {
373
    public void setMultimediaObjects(HashMap<String,Map<String, String>> multimediaObjects) {
353 374
        this.multimediaObjects = multimediaObjects;
354 375
    }
355 376

  
377
    public void putMultiMediaObject(String uri, Map<String, String> attributes){
378
        this.multimediaObjects.put(uri, attributes);
379
    }
380

  
381
    /**
382
     * @return the multimediaObjects
383
     */
384
    public HashMap<String,Map<String, String>> getGatheringMultimediaObjects() {
385
        return gatheringMultimediaObjects;
386
    }
387

  
388

  
389

  
390
    /**
391
     * @param multimediaObjects the multimediaObjects to set
392
     */
393
    public void setGatheringMultimediaObjects(HashMap<String,Map<String, String>> multimediaObjects) {
394
        this.gatheringMultimediaObjects = multimediaObjects;
395
    }
396

  
397
    public void putGatheringMultiMediaObject(String uri, Map<String, String> attributes){
398
        this.gatheringMultimediaObjects.put(uri, attributes);
399
    }
400

  
356 401

  
357 402

  
358 403
    /**
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/specimen/SpecimenImportConfiguratorBase.java
19 19
import eu.etaxonomy.cdm.io.common.mapping.IInputTransformer;
20 20
import eu.etaxonomy.cdm.model.agent.Person;
21 21
import eu.etaxonomy.cdm.model.agent.Team;
22
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationType;
22 23

  
23 24
/**
24 25
 * @author k.luther
......
69 70

  
70 71
    private boolean overwriteExistingSpecimens = false;
71 72

  
73
    private SpecimenOrObservationType type;
74

  
75

  
76
    /**
77
     * @return the type
78
     */
79
    public SpecimenOrObservationType getType() {
80
        return type;
81
    }
82

  
83
    /**
84
     * @param type the type to set
85
     */
86
    public void setType(SpecimenOrObservationType type) {
87
        this.type = type;
88
    }
72 89

  
73 90
    private final SpecimenUserInteraction specimenUserInteraction = new SpecimenUserInteraction();
74 91

  
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/specimen/UnitsGatheringEvent.java
10 10
package eu.etaxonomy.cdm.io.specimen;
11 11

  
12 12

  
13
import java.util.ArrayList;
14
import java.util.HashSet;
13
import java.util.HashMap;
15 14
import java.util.List;
15
import java.util.Map;
16 16
import java.util.UUID;
17 17

  
18 18
import org.apache.commons.lang.StringUtils;
......
26 26
import eu.etaxonomy.cdm.io.taxonx2013.TaxonXImportConfigurator;
27 27
import eu.etaxonomy.cdm.model.agent.Person;
28 28
import eu.etaxonomy.cdm.model.agent.Team;
29
import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
29 30
import eu.etaxonomy.cdm.model.common.Annotation;
30 31
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
31 32
import eu.etaxonomy.cdm.model.common.Language;
......
95 96
     */
96 97
    public UnitsGatheringEvent(ITermService termService, String locality, String languageIso, Double longitude,
97 98
            Double latitude, String elevationText, String elevationMin, String elevationMax, String elevationUnit,
98
            String date, String gatheringNotes, ReferenceSystem referenceSystem, List<String> collectorName,
99
            List<String> team, Abcd206ImportConfigurator config) {
99
            String date, String gatheringNotes, ReferenceSystem referenceSystem,
100
             Abcd206ImportConfigurator config) {
100 101
        this.setLocality(termService, locality, languageIso);
101 102
        this.setCoordinates(longitude, latitude, referenceSystem);
102 103
        this.setDate(date);
103 104
        this.setNotes(gatheringNotes);
104 105
        this.setElevation(elevationText, elevationMin, elevationMax, elevationUnit);
105
        if (!collectorName.isEmpty()) {
106
            List<String> tmp =  new ArrayList<String>(new HashSet<String>(collectorName));
107
            this.setCollector(tmp.get(0), config);
108
        }
109
        if (!team.isEmpty()) {
110
            List<String> tmpTeam = new ArrayList<String>(new HashSet<String>(team));
111
            this.setTeam(StringUtils.join(tmpTeam," & "), config);
112
        }
106

  
107

  
108

  
109

  
110

  
113 111
    }
114 112

  
113
    /**
114
     * @param gatheringImages
115
     */
116
    public void setGatheringImages(HashMap<String, Map<String, String>> gatheringImages) {
117

  
118

  
119
    }
115 120
    public GatheringEvent getGatheringEvent(){
116 121
        return this.gatheringEvent;
117 122
    }
......
236 241
        }
237 242
    }
238 243

  
244
    public void setHeight(String heightText, String heightMin, String heightMax, String heightUnit){
245
        if(heightText!=null){
246
            this.gatheringEvent.setAbsoluteElevationText(heightText);
247
        }
248
        else{
249
            //TODO check for unit at string end
250
            String pattern = "\\D";// regex for non-digits
251
            if(heightMin!=null){
252
                Double min = Double.parseDouble(heightMin.replaceAll(pattern, ""));
253
                this.gatheringEvent.setDistanceToGround(min);
254
            }
255
            if(heightMax!=null){
256
                Double max = Double.parseDouble(heightMax.replaceAll(pattern, ""));
257
                this.gatheringEvent.setDistanceToGroundMax(max);
258
            }
259
            if(heightUnit!=null){
260
                if (!heightUnit.equals("m")){
261
                    logger.debug("The unit " + heightUnit + " of the distance to ground is not meter.");
262
                }
263
            }
264
        }
265
    }
266

  
267
    public void setGatheringDepth(String depthText, Double depthMin, Double depthMax, String depthUnit){
268
        if(depthText!=null){
269
            this.gatheringEvent.setDistanceToWaterSurfaceText(depthText);
270
        }
271
        else{
272

  
273
            if(depthMin!=null){
274
                this.gatheringEvent.setDistanceToWaterSurface(depthMin);
275
            }
276
            if(depthMax!=null){
277
                this.gatheringEvent.setDistanceToWaterSurfaceMax(depthMax);
278
            }
279
            if(depthUnit!=null){
280
                if (!depthUnit.equals("m")){
281
                    logger.debug("The unit " + depthUnit + " of the distance to ground is not meter.");
282
                }
283
            }
284
        }
285
    }
286

  
239 287
    /*
240 288
     * Add a NamedArea to the GatheringEvent
241 289
     * @param area: the NamedArea to add
......
293 341
     * @param: collectorNames: the list of names to add as collector/collectorTeam
294 342
     * USED - create each time a new Collector
295 343
     */
296
    public void setCollector(String collectorName, Abcd206ImportConfigurator config){
344
    public void setCollector(TeamOrPersonBase collector, Abcd206ImportConfigurator config){
297 345
        //        System.out.println("collectors : "+collectorNames.toString());
298
        Person collector;
299
        collector = Person.NewInstance();
300
        collector.setTitleCache(collectorName, true);
346

  
301 347
        if (DEBUG) {
302 348
            System.out.println("getcoll:"+config.getPersons().get(collector.getTitleCache()));
303 349
        }
304
       // this.gatheringEvent.setCollector(config.getPersons().get(collector.getTitleCache()));
350
        this.gatheringEvent.setCollector(collector);
305 351
    }
306 352

  
307 353
    /**
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/specimen/abcd206/in/Abcd206DataHolder.java
12 12
import java.util.ArrayList;
13 13
import java.util.HashMap;
14 14
import java.util.List;
15
import java.util.Map;
15 16

  
16 17
import org.apache.log4j.Logger;
17 18

  
......
30 31

  
31 32
    protected List<String> knownABCDelements = new ArrayList<String>();
32 33
    protected HashMap<String,String> allABCDelements = new HashMap<String,String>();
33
    public List<String> gatheringAgentList;
34
    protected List<String> gatheringTeamList;
34
    public String gatheringAgents ="";
35

  
35 36

  
36 37
    //per unit
37 38

  
......
55 56
    protected String languageIso;
56 57
    protected String country;
57 58
    protected String isocountry;
58
    protected Integer depth;
59

  
60

  
59 61
    protected Integer altitude;
60 62

  
63
    private String gatheringDepthUnit;
64

  
65
    private Double gatheringDepthMax;
66

  
67
    private Double gatheringDepthMin;
68
    private String gatheringDepthText;
69

  
61 70

  
62 71

  
63 72

  
......
77 86
        languageIso = null;
78 87
        country = null;
79 88
        isocountry = null;
80
        depth = null;
89

  
81 90
        altitude = null;
82 91

  
83 92
        gatheringElevationText = null;
......
85 94

  
86 95

  
87 96
        setReferenceList(new ArrayList<String[]>());
88
        setMultimediaObjects(new ArrayList<String>());
97
        setMultimediaObjects(new HashMap<String,Map<String, String>>());
98
        setGatheringMultimediaObjects(new HashMap<String,Map<String, String>>());
89 99
        setDocSources(new ArrayList<String>());
90 100
        associatedUnitIds = new ArrayList<String>();
91 101
    }
......
93 103

  
94 104

  
95 105

  
106
    /**
107
     * @param textContent
108
     */
109
    public void setGatheringDepthMin(Double gatheringDepthMin) {
110
        this.gatheringDepthMin = gatheringDepthMin;
111

  
112
    }
113

  
114
    public Double getGatheringDepthMin() {
115
        return gatheringDepthMin;
116

  
117
    }
118

  
119

  
120

  
121
    /**
122
     * @param textContent
123
     */
124
    public void setGatheringDepthMax(Double gatheringDepthMax) {
125
        this.gatheringDepthMax = gatheringDepthMax;
126

  
127
    }
128

  
129
    public Double getGatheringDepthMax() {
130
        return gatheringDepthMax;
131

  
132
    }
133

  
134

  
135

  
136
    /**
137
     * @param textContent
138
     */
139
    public void setGatheringDepthUnit(String gatheringDepthUnit) {
140
        this.gatheringDepthUnit = gatheringDepthUnit;
141

  
142
    }
143

  
144
    public String getGatheringDepthUnit() {
145
        return gatheringDepthUnit;
146

  
147
    }
148

  
149

  
150

  
151

  
152

  
153
    /**
154
     * @return the gatheringDepthText
155
     */
156
    public String getGatheringDepthText() {
157
        return gatheringDepthText;
158
    }
159

  
160

  
161

  
162

  
163
    /**
164
     * @param gatheringDepthText the gatheringDepthText to set
165
     */
166
    public void setGatheringDepthText(String gatheringDepthText) {
167
        this.gatheringDepthText = gatheringDepthText;
168
    }
169

  
170

  
96 171
}
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/specimen/abcd206/in/Abcd206Import.java
29 29
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
30 30
import eu.etaxonomy.cdm.ext.occurrence.bioCase.BioCaseQueryServiceWrapper;
31 31
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
32
import eu.etaxonomy.cdm.io.common.ICdmIO;
33
import eu.etaxonomy.cdm.io.common.MapWrapper;
32 34
import eu.etaxonomy.cdm.io.specimen.SpecimenImportBase;
33 35
import eu.etaxonomy.cdm.io.specimen.SpecimenUserInteraction;
34 36
import eu.etaxonomy.cdm.io.specimen.UnitsGatheringArea;
35 37
import eu.etaxonomy.cdm.io.specimen.UnitsGatheringEvent;
36 38
import eu.etaxonomy.cdm.io.specimen.abcd206.in.molecular.AbcdDnaParser;
37
import eu.etaxonomy.cdm.model.agent.AgentBase;
38 39
import eu.etaxonomy.cdm.model.agent.Institution;
39 40
import eu.etaxonomy.cdm.model.agent.Person;
40 41
import eu.etaxonomy.cdm.model.agent.Team;
42
import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
41 43
import eu.etaxonomy.cdm.model.common.Annotation;
42 44
import eu.etaxonomy.cdm.model.common.CdmBase;
43 45
import eu.etaxonomy.cdm.model.common.DefinedTerm;
44 46
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
45 47
import eu.etaxonomy.cdm.model.common.IdentifiableSource;
46 48
import eu.etaxonomy.cdm.model.common.Language;
49
import eu.etaxonomy.cdm.model.common.LanguageString;
47 50
import eu.etaxonomy.cdm.model.common.OriginalSourceBase;
48 51
import eu.etaxonomy.cdm.model.common.OriginalSourceType;
49 52
import eu.etaxonomy.cdm.model.description.DescriptionElementSource;
......
63 66
import eu.etaxonomy.cdm.model.reference.Reference;
64 67
import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
65 68
import eu.etaxonomy.cdm.model.taxon.Classification;
66
import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache;
69
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
67 70

  
68 71
/**
69 72
 * @author p.kelbert
......
96 99
    @SuppressWarnings("rawtypes")
97 100
    public void doInvoke(Abcd206ImportState state) {
98 101
        Abcd206ImportConfigurator config = state.getConfig();
102
        Map<String, MapWrapper<? extends CdmBase>> stores = state.getStores();
103
        MapWrapper<TeamOrPersonBase<?>> authorStore = (MapWrapper<TeamOrPersonBase<?>>)stores.get(ICdmIO.TEAM_STORE);
104
        state.setPersonStore(authorStore);
105
        MapWrapper<Reference> referenceStore = (MapWrapper<Reference>)stores.get(ICdmIO.REFERENCE_STORE);
106
        MapWrapper<TaxonBase> taxonBaseStore = (MapWrapper<TaxonBase>)stores.get(ICdmIO.TAXON_STORE);
99 107
        try{
100 108
            state.setTx(startTransaction());
101 109
            logger.info("INVOKE Specimen Import from ABCD2.06 XML ");
......
118 126

  
119 127
            //init import reference
120 128
        //  List<Reference> references = getReferenceService().list(Reference.class, null, null, null, null);
121
            List<Reference> references = new ArrayList<Reference>();
129
         //   List<Reference> references = new ArrayList<Reference>();
122 130

  
123 131
//            if (state.getConfig().isInteractWithUser()){
124 132
//                Map<String,Reference> refMap = new HashMap<String, Reference>();
......
144 152
//            }else{
145 153
                if (state.getRef()==null){
146 154
                    String name = NB(((Abcd206ImportConfigurator) state.getConfig()).getSourceReferenceTitle());
147
                    for (Reference reference : references) {
155
                    for (Reference reference : referenceStore.getAllValues()) {
148 156
                        if (! StringUtils.isBlank(reference.getTitleCache())) {
149 157
                            if (reference.getTitleCache().equalsIgnoreCase(name)) {
150 158
                                state.setRef(reference);
......
223 231

  
224 232
                prepareCollectors(state, unitsList, abcdFieldGetter);
225 233

  
234

  
235
                // save authors
236
                getAgentService().saveOrUpdate((java.util.Collection)state.getPersonStore().objects());
237

  
238
                commitTransaction(state.getTx());
239
                state.setTx(startTransaction());
240

  
226 241
                state.setAssociationRefs(new ArrayList<OriginalSourceBase<?>>());
227 242
                state.setDescriptionRefs(new ArrayList<OriginalSourceBase<?>>());
228 243
                state.setDerivedUnitSources(new ArrayList<OriginalSourceBase<?>>());
......
330 345
                    state.getDataHolder().getGatheringElevationMin(), state.getDataHolder().getGatheringElevationMax(),
331 346
                    state.getDataHolder().getGatheringElevationUnit(), state.getDataHolder().getGatheringDateText(),
332 347
                    state.getDataHolder().getGatheringNotes(), state.getTransformer().getReferenceSystemByKey(
333
                            state.getDataHolder().getGatheringSpatialDatum()), state.getDataHolder().gatheringAgentList,
334
                    state.getDataHolder().gatheringTeamList, state.getConfig());
348
                            state.getDataHolder().getGatheringSpatialDatum()),
349
                     state.getConfig());
335 350

  
336
            // country
351
            unitsGatheringEvent.setGatheringDepth(state.getDataHolder().getGatheringDepthText(),state.getDataHolder().getGatheringDepthMin(), state.getDataHolder().getGatheringDepthMax(), state.getDataHolder().getGatheringDepthUnit());
352
            //unitsGatheringEvent.setHeight(heightText, heightMin, heightMax, heightUnit);
353
            unitsGatheringEvent.setCollector(state.getPersonStore().get(state.getDataHolder().gatheringAgents), config);
354
            // count
337 355
            UnitsGatheringArea unitsGatheringArea = new UnitsGatheringArea();
338 356
            //  unitsGatheringArea.setConfig(state.getConfig(),getOccurrenceService(), getTermService());
339 357
            unitsGatheringArea.setParams(state.getDataHolder().isocountry, state.getDataHolder().country, (state.getConfig()), cdmAppController.getTermService(), cdmAppController.getOccurrenceService());
......
360 378
            derivedUnitFacade.setAbsoluteElevationText(gatheringEvent.getAbsoluteElevationText());
361 379
            derivedUnitFacade.setAbsoluteElevation(gatheringEvent.getAbsoluteElevation());
362 380
            derivedUnitFacade.setAbsoluteElevationMax(gatheringEvent.getAbsoluteElevationMax());
381
            derivedUnitFacade.setDistanceToGroundText(gatheringEvent.getDistanceToGroundText());
382
            derivedUnitFacade.setDistanceToGroundMax(gatheringEvent.getDistanceToGroundMax());
383
            derivedUnitFacade.setDistanceToGround(gatheringEvent.getDistanceToGround());
384
            derivedUnitFacade.setDistanceToWaterSurfaceText(gatheringEvent.getDistanceToWaterSurfaceText());
385
            derivedUnitFacade.setDistanceToWaterSurfaceMax(gatheringEvent.getDistanceToWaterSurfaceMax());
386
            derivedUnitFacade.setDistanceToWaterSurface(gatheringEvent.getDistanceToWaterSurface());
363 387
            derivedUnitFacade.setGatheringPeriod(gatheringEvent.getTimeperiod());
364 388

  
365 389
            for(DefinedTermBase<?> area:unitsGatheringArea.getAreas()){
......
374 398
            // add unitNotes
375 399
            derivedUnitFacade.addAnnotation(Annotation.NewDefaultLanguageInstance(NB(state.getDataHolder().getUnitNotes())));
376 400

  
401

  
402

  
377 403
            // //add Multimedia URLs
378 404
            if (state.getDataHolder().getMultimediaObjects().size() != -1) {
379
                for (String multimediaObject : state.getDataHolder().getMultimediaObjects()) {
405
                for (String multimediaObject : state.getDataHolder().getMultimediaObjects().keySet()) {
380 406
                    Media media;
381 407
                    try {
382 408
                        media = getImageMedia(multimediaObject, READ_MEDIA_DATA);
409
                        Map<String, String> attributes = state.getDataHolder().getMultimediaObjects().get(multimediaObject);
410
                        if (attributes.containsKey("Context")){
411
                            LanguageString description = LanguageString.NewInstance(attributes.get("Context"), Language.ENGLISH());
412
                            media.addDescription(description);
413
                        }
414
                        if (attributes.containsKey("Comment")){
415
                            LanguageString description = LanguageString.NewInstance(attributes.get("Comment"), Language.ENGLISH());
416
                            media.addDescription(description);
417
                        }
418
                        if (attributes.containsKey("Creators")){
419
                            String creators = attributes.get("Creators");
420
                            Person artist;
421
                            Team artistTeam;
422
                            String[] artists;
423
                            if (creators != null){
424
                                if (creators.contains("&")){
425
                                    artists = creators.split("&");
426
                                    artistTeam = new Team();
427
                                    for (String creator:artists){
428
                                        artist = Person.NewTitledInstance(creator);
429
                                        artistTeam.addTeamMember(artist);
430
                                    }
431
                                    media.setArtist(artistTeam);
432
                                } else{
433

  
434
                                    artist = Person.NewTitledInstance(creators);
435
                                    media.setArtist(artist);
436
                                }
437
                            }
438

  
439

  
440

  
441
                        }
442

  
383 443
                        derivedUnitFacade.addDerivedUnitMedia(media);
384 444
                        if(((Abcd206ImportConfigurator)state.getConfig()).isAddMediaAsMediaSpecimen()){
385 445
                            //add media also as specimen scan
386 446
                            MediaSpecimen mediaSpecimen = MediaSpecimen.NewInstance(SpecimenOrObservationType.StillImage);
387 447
                            mediaSpecimen.setMediaSpecimen(media);
448
                            //do it only once!!
388 449
                            DefinedTermBase specimenScanTerm = getTermService().load(SPECIMEN_SCAN_TERM);
389 450
                            if(specimenScanTerm instanceof DefinedTerm){
390 451
                                mediaSpecimen.setKindOfUnit((DefinedTerm) specimenScanTerm);
......
401 462

  
402 463
                }
403 464
            }
465
            //multimedia for fieldUnit
466
            if (state.getDataHolder().getGatheringMultimediaObjects().size() != -1) {
467
                for (String multimediaObject : state.getDataHolder().getGatheringMultimediaObjects().keySet()) {
468
                    Media media;
469
                    try {
470
                        media = getImageMedia(multimediaObject, READ_MEDIA_DATA);
471
                        Map<String, String> attributes = state.getDataHolder().getGatheringMultimediaObjects().get(multimediaObject);
472
                        if (attributes.containsKey("Context")){
473
                            LanguageString description = LanguageString.NewInstance(attributes.get("Context"), Language.ENGLISH());
474
                            media.addDescription(description);
475
                        }
476
                        if (attributes.containsKey("Comment")){
477
                            LanguageString description = LanguageString.NewInstance(attributes.get("Comment"), Language.ENGLISH());
478
                            media.addDescription(description);
479
                        }
480
                        if (attributes.containsKey("Creators")){
481
                            String creators = attributes.get("Creators");
482
                            Person artist;
483
                            Team artistTeam;
484
                            String[] artists;
485
                            if (creators != null){
486
                                if (creators.contains("&")){
487
                                    artists = creators.split("&");
488
                                    artistTeam = new Team();
489
                                    for (String creator:artists){
490
                                        artist = Person.NewTitledInstance(creator);
491
                                        artistTeam.addTeamMember(artist);
492
                                    }
493
                                    media.setArtist(artistTeam);
494
                                } else{
495

  
496
                                    artist = Person.NewTitledInstance(creators);
497
                                    media.setArtist(artist);
498
                                }
499
                            }
500

  
501

  
502

  
503
                        }
504

  
505
                        derivedUnitFacade.addFieldObjectMedia(media);
506

  
507

  
508
                    } catch (MalformedURLException e) {
509
                        // TODO Auto-generated catch block
510
                        e.printStackTrace();
511
                    }
512

  
513
                }
514
            }
404 515

  
405 516
            //			/*
406 517
            //			 * merge AND STORE DATA
......
410 521
            //			for (NamedArea area : otherAreas) {
411 522
            //				getTermService().saveOrUpdate(area);// merge it sooner (foreach area)
412 523
            //			}
413

  
524
           save(derivedUnitFacade.getFieldUnit(false), state);
414 525
            save(unitsGatheringEvent.getLocality(), state);
415 526

  
416 527
            // handle collection data
......
769 880
                break;
770 881
            }
771 882
        }
772
        state.getDataHolder().gatheringAgentList = new ArrayList<String>();
773
        state.getDataHolder().gatheringTeamList = new ArrayList<String>();
883
        //state.getDataHolder().gatheringAgents = "";
884

  
774 885
        abcdFieldGetter.getType(root);
775 886
        abcdFieldGetter.getGatheringPeople(root);
776 887
    }
......
798 909
            state.getDataHolder().setStatusList(new ArrayList<SpecimenTypeDesignationStatus>());
799 910
            state.getDataHolder().setAtomisedIdentificationList(new ArrayList<HashMap<String, String>>());
800 911
            state.getDataHolder().setReferenceList(new ArrayList<String[]>());
801
            state.getDataHolder().setMultimediaObjects(new ArrayList<String>());
912
            state.getDataHolder().setMultimediaObjects(new HashMap<String,Map<String, String>>());
913
            state.getDataHolder().setGatheringMultimediaObjects(new HashMap<String,Map<String, String>>());
802 914

  
803 915
            abcdFieldGetter.getScientificNames(group);
804 916
            abcdFieldGetter.getType(root);
......
816 928
            abcdFieldGetter.getGatheringDate(root);
817 929
            abcdFieldGetter.getGatheringElevation(root);
818 930
            abcdFieldGetter.getGatheringNotes(root);
931
            abcdFieldGetter.getGatheringImages(root);
819 932
            abcdFieldGetter.getAssociatedUnitIds(root);
820 933
            abcdFieldGetter.getUnitNotes(root);
821 934
            boolean referencefound = abcdFieldGetter.getReferences(root);
......
870 983
     * @param abcdFieldGetter : the ABCD parser
871 984
     */
872 985
    private void prepareCollectors(Abcd206ImportState state, NodeList unitsList, Abcd206XMLFieldGetter abcdFieldGetter) {
873
        List<String> collectors = new ArrayList<String>();
874
        List<String> teams = new ArrayList<String>();
875
        List<List<String>> collectorinteams = new ArrayList<List<String>>();
876 986

  
987
        TeamOrPersonBase teamOrPerson = null;
988

  
989
        //ImportHelper.setOriginalSource(teamOrPerson, state.getConfig().getSourceReference(), collector, "Collector");
877 990
        for (int i = 0; i < unitsList.getLength(); i++) {
878 991
            this.getCollectorsFromXML((Element) unitsList.item(i), abcdFieldGetter, state);
879
            for (String agent : state.getDataHolder().gatheringAgentList) {
880
                collectors.add(agent);
881
            }
882
            List<String> tmpTeam = new ArrayList<String>(new HashSet<String>(state.getDataHolder().gatheringTeamList));
883
            if(!tmpTeam.isEmpty()) {
884
                teams.add(StringUtils.join(tmpTeam.toArray()," & "));
885
            }
886
            for (String agent:tmpTeam) {
887
                collectors.add(agent);
888
            }
889
        }
890

  
891
        List<String> collectorsU = new ArrayList<String>(new HashSet<String>(collectors));
892
        List<String> teamsU = new ArrayList<String>(new HashSet<String>(teams));
893

  
894

  
895
        //existing teams in DB
896
        Map<String,Team> titleCacheTeam = new HashMap<String, Team>();
897
        List<UuidAndTitleCache<Team>> hiberTeam = new ArrayList<UuidAndTitleCache<Team>>();//getAgentService().getTeamUuidAndTitleCache();
898

  
899
        Set<UUID> uuids = new HashSet<UUID>();
900
        for (UuidAndTitleCache<Team> hibernateT:hiberTeam){
901
            uuids.add(hibernateT.getUuid());
902
        }
903
        if (!uuids.isEmpty()){
904
            List<AgentBase> existingTeams = getAgentService().find(uuids);
905
            for (AgentBase<?> existingP:existingTeams){
906
                titleCacheTeam.put(existingP.getTitleCache(),CdmBase.deproxy(existingP,Team.class));
992
            if (!StringUtils.isBlank(state.getDataHolder().gatheringAgents)){
993
                teamOrPerson = parseAuthorString(state.getDataHolder().gatheringAgents);
994
                if (!state.getPersonStore().containsId(state.getDataHolder().gatheringAgents)) {
995
                    state.getPersonStore().put(state.getDataHolder().gatheringAgents, teamOrPerson);
996
                    if (logger.isDebugEnabled()) { logger.debug("Stored author " + state.getDataHolder().gatheringAgents  ); }
997
                } else {
998
                    logger.warn("Not imported author with duplicated aut_id " + state.getDataHolder().gatheringAgents  );
999
                }
907 1000
            }
908
        }
909

  
910 1001

  
911
        Map<String,UUID> teamMap = new HashMap<String, UUID>();
912
        for (UuidAndTitleCache<Team> uuidt:hiberTeam){
913
            teamMap.put(uuidt.getTitleCache(), uuidt.getUuid());
914 1002
        }
915 1003

  
916
        //existing persons in DB
917
        List<UuidAndTitleCache<Person>> hiberPersons = new ArrayList<UuidAndTitleCache<Person>>();//getAgentService().getPersonUuidAndTitleCache();
918
        Map<String,Person> titleCachePerson = new HashMap<String, Person>();
919
        uuids = new HashSet<UUID>();
920
        for (UuidAndTitleCache<Person> hibernateP:hiberPersons){
921
            uuids.add(hibernateP.getUuid());
922
        }
923 1004

  
924
        if (!uuids.isEmpty()){
925
            List<AgentBase> existingPersons = getAgentService().find(uuids);
926
            for (AgentBase<?> existingP:existingPersons){
927
                titleCachePerson.put(existingP.getTitleCache(),CdmBase.deproxy(existingP,Person.class));
928
            }
929
        }
930 1005

  
931
        Map<String,UUID> personMap = new HashMap<String, UUID>();
932
        for (UuidAndTitleCache<Person> person:hiberPersons){
933
            personMap.put(person.getTitleCache(), person.getUuid());
934
        }
935 1006

  
936
        java.util.Collection<Person> personToadd = new ArrayList<Person>();
937
        java.util.Collection<Team> teamToAdd = new ArrayList<Team>();
1007
//        List<String> collectorsU = new ArrayList<String>(new HashSet<String>(collectors));
1008
//        List<String> teamsU = new ArrayList<String>(new HashSet<String>(teams));
1009
//
1010
//
1011
//        //existing teams in DB
1012
//        Map<String,Team> titleCacheTeam = new HashMap<String, Team>();
1013
       // List<UuidAndTitleCache<Team>> hiberTeam = new ArrayList<UuidAndTitleCache<Team>>();//getAgentService().getTeamUuidAndTitleCache();
1014

  
1015
//        Set<UUID> uuids = new HashSet<UUID>();
1016
//        for (UuidAndTitleCache<Team> hibernateT:hiberTeam){
1017
//            uuids.add(hibernateT.getUuid());
1018
//        }
1019
//        if (!uuids.isEmpty()){
1020
//            List<AgentBase> existingTeams = getAgentService().find(uuids);
1021
//            for (AgentBase<?> existingP:existingTeams){
1022
//                titleCacheTeam.put(existingP.getTitleCache(),CdmBase.deproxy(existingP,Team.class));
1023
//            }
1024
//        }
938 1025

  
939
        for (String collector:collectorsU){
940
            Person p = Person.NewInstance();
941
            p.setTitleCache(collector,true);
942
            if (!personMap.containsKey(p.getTitleCache())){
943
                personToadd.add(p);
944
            }
945
        }
946
        for (String team:teamsU){
947
            Team p = Team.NewInstance();
948
            p.setTitleCache(team,true);
949
            if (!teamMap.containsKey(p.getTitleCache())){
950
                teamToAdd.add(p);
951
            }
952
        }
953 1026

  
954
        if(!personToadd.isEmpty()){
955
            for (Person agent: personToadd){
956
                save(agent, state);
957
                titleCachePerson.put(agent.getTitleCache(),CdmBase.deproxy(agent, Person.class) );
958
            }
959
        }
1027
//        Map<String,UUID> teamMap = new HashMap<String, UUID>();
1028
//        for (UuidAndTitleCache<Team> uuidt:hiberTeam){
1029
//            teamMap.put(uuidt.getTitleCache(), uuidt.getUuid());
1030
//        }
960 1031

  
961
        Person ptmp ;
962
        Map <String,Integer>teamdone = new HashMap<String, Integer>();
963
        for (List<String> collteam: collectorinteams){
964
            if (!teamdone.containsKey(StringUtils.join(collteam.toArray(),"-"))){
965
                Team team = new Team();
966
                boolean em =true;
967
                for (String collector:collteam){
968
                    ptmp = Person.NewInstance();
969
                    ptmp.setTitleCache(collector,true);
970
                    Person p2 = titleCachePerson.get(ptmp.getTitleCache());
971
                    team.addTeamMember(p2);
972
                    em=false;
973
                }
974
                if (!em) {
975
                    teamToAdd.add(team);
976
                }
977
                teamdone.put(StringUtils.join(collteam.toArray(),"-"),0);
978
            }
979
        }
980

  
981
        if(!teamToAdd.isEmpty()){
982
            for (Team agent: teamToAdd){
983
                save(agent, state);
984
                titleCacheTeam.put(agent.getTitleCache(), CdmBase.deproxy( agent,Team.class) );
985
            }
986
        }
1032
        //existing persons in DB
1033
//        List<UuidAndTitleCache<Person>> hiberPersons = new ArrayList<UuidAndTitleCache<Person>>();//getAgentService().getPersonUuidAndTitleCache();
1034
//        Map<String,Person> titleCachePerson = new HashMap<String, Person>();
1035
//        uuids = new HashSet<UUID>();
1036
//        for (UuidAndTitleCache<Person> hibernateP:hiberPersons){
1037
//            uuids.add(hibernateP.getUuid());
1038
//        }
1039
//
1040
//        if (!uuids.isEmpty()){
1041
//            List<AgentBase> existingPersons = getAgentService().find(uuids);
1042
//            for (AgentBase<?> existingP:existingPersons){
1043
//                titleCachePerson.put(existingP.getTitleCache(),CdmBase.deproxy(existingP,Person.class));
1044
//            }
1045
//        }
1046
//
1047
//        Map<String,UUID> personMap = new HashMap<String, UUID>();
1048
//        for (UuidAndTitleCache<Person> person:hiberPersons){
1049
//            personMap.put(person.getTitleCache(), person.getUuid());
1050
//        }
1051
//
1052
//        java.util.Collection<Person> personToadd = new ArrayList<Person>();
1053
//        java.util.Collection<Team> teamToAdd = new ArrayList<Team>();
1054
//
1055
//        for (String collector:collectorsU){
1056
//            Person p = Person.NewInstance();
1057
//            p.setTitleCache(collector,true);
1058
//            if (!personMap.containsKey(p.getTitleCache())){
1059
//                personToadd.add(p);
1060
//            }
1061
//        }
1062
//        for (String team:teamsU){
1063
//            Team p = Team.NewInstance();
1064
//            p.setTitleCache(team,true);
1065
//            if (!teamMap.containsKey(p.getTitleCache())){
1066
//                teamToAdd.add(p);
1067
//            }
1068
//        }
1069
//
1070
//        if(!personToadd.isEmpty()){
1071
//            for (Person agent: personToadd){
1072
//                save(agent, state);
1073
//                titleCachePerson.put(agent.getTitleCache(),CdmBase.deproxy(agent, Person.class) );
1074
//            }
1075
//        }
1076
//
1077
//        Person ptmp ;
1078
//        Map <String,Integer>teamdone = new HashMap<String, Integer>();
1079
//        for (List<String> collteam: collectorinteams){
1080
//            if (!teamdone.containsKey(StringUtils.join(collteam.toArray(),"-"))){
1081
//                Team team = new Team();
1082
//                boolean em =true;
1083
//                for (String collector:collteam){
1084
//                    ptmp = Person.NewInstance();
1085
//                    ptmp.setTitleCache(collector,true);
1086
//                    Person p2 = titleCachePerson.get(ptmp.getTitleCache());
1087
//                    team.addTeamMember(p2);
1088
//                    em=false;
1089
//                }
1090
//                if (!em) {
1091
//                    teamToAdd.add(team);
1092
//                }
1093
//                teamdone.put(StringUtils.join(collteam.toArray(),"-"),0);
1094
//            }
1095
//        }
1096
//
1097
//        if(!teamToAdd.isEmpty()){
1098
//            for (Team agent: teamToAdd){
1099
//                save(agent, state);
1100
//                titleCacheTeam.put(agent.getTitleCache(), CdmBase.deproxy( agent,Team.class) );
1101
//            }
1102
//        }
987 1103

  
988
        ((Abcd206ImportConfigurator) state.getConfig()).setTeams(titleCacheTeam);
989
        ((Abcd206ImportConfigurator) state.getConfig()).setPersons(titleCachePerson);
1104
//        ((Abcd206ImportConfigurator) state.getConfig()).setTeams(titleCacheTeam);
1105
//        ((Abcd206ImportConfigurator) state.getConfig()).setPersons(titleCachePerson);
990 1106
    }
991 1107

  
992 1108
    @Override
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/specimen/abcd206/in/Abcd206ImportState.java
16 16

  
17 17
import org.apache.log4j.Logger;
18 18

  
19
import eu.etaxonomy.cdm.io.common.MapWrapper;
19 20
import eu.etaxonomy.cdm.io.specimen.SpecimenImportStateBase;
21
import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
20 22

  
21 23
/**
22 24
 * @author a.mueller
......
29 31

  
30 32

  
31 33
	private String prefix;
32

  
34
	MapWrapper<TeamOrPersonBase<?>> personStore;
33 35

  
34 36

  
35 37

  
......
42 44

  
43 45
//****************** CONSTRUCTOR ***************************************************/
44 46

  
45
	public Abcd206ImportState(Abcd206ImportConfigurator config) {
47
	/**
48
     * @return the personStore
49
     */
50
    public MapWrapper<TeamOrPersonBase<?>> getPersonStore() {
51
        return personStore;
52
    }
53

  
54
    /**
55
     * @param personStore the personStore to set
56
     */
57
    public void setPersonStore(MapWrapper<TeamOrPersonBase<?>> personStore) {
58
        this.personStore = personStore;
59
    }
60

  
61
    public Abcd206ImportState(Abcd206ImportConfigurator config) {
46 62
		super(config);
47 63
        setReport(new SpecimenImportReport());
48 64
        setTransformer(new AbcdTransformer());
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/specimen/abcd206/in/Abcd206XMLFieldGetter.java
2 2

  
3 3
import java.util.ArrayList;
4 4
import java.util.HashMap;
5
import java.util.Map;
5 6

  
6 7
import org.apache.log4j.Logger;
7 8
import org.w3c.dom.Element;
......
84 85
    protected void getScientificNames(NodeList group) {
85 86
        NodeList identifications, results;
86 87
        String tmpName = null;
87

  
88
        //TODO: add the identifier!!
89
//        abcd:Identification>
90
//        <abcd:Result>
91
//        <abcd:TaxonIdentified>
92
//        <abcd:ScientificName>
93
//        <abcd:FullScientificNameString>Melosira varians C. Agardh</abcd:FullScientificNameString>
94
//        <abcd:NameAtomised><abcd:Botanical><abcd:GenusOrMonomial>Melosira</abcd:GenusOrMonomial><abcd:FirstEpithet>varians</abcd:FirstEpithet><abcd:Rank>sp.</abcd:Rank><abcd:AuthorTeam>C.Agardh</abcd:AuthorTeam></abcd:Botanical></abcd:NameAtomised>
95
//        </abcd:ScientificName>
96
//        </abcd:TaxonIdentified>
97
//        </abcd:Result>
98
//        <abcd:PreferredFlag>true</abcd:PreferredFlag>
99
//        <abcd:Identifiers>
100
//        <abcd:Identifier>
101
//        <abcd:PersonName><abcd:FullName>W.-H. Kusber</abcd:FullName></abcd:PersonName>
102
//        </abcd:Identifier>
103
//        </abcd:Identifiers>
104
//        <abcd:Date>
105
//        <abcd:DateText>2014-07-11T00:00:00</abcd:DateText></abcd:Date>
106
//        </abcd:Identification>
88 107
        for (int j = 0; j < group.getLength(); j++) {
89 108
            if (group.item(j).getNodeName().equals(prefix + "Identification")) {
90 109
                identifications = group.item(j).getChildNodes();
......
551 570
            dataHolder.altitude = -9999;
552 571
        }
553 572

  
554
        try {
555
            group = root.getElementsByTagName(prefix + "Depth");
556
            path = group.item(0).getNodeName();
557
            getHierarchie(group.item(0));
558
            dataHolder.knownABCDelements.add(path);
559
            path = "";
560
            dataHolder.depth = Integer.valueOf(group.item(0).getTextContent());
561
        } catch (NullPointerException e) {
562
            dataHolder.depth = -9999;
563
        }
573
        getGatheringDepth(root);
564 574

  
565 575
        try {
566 576
            group = root.getElementsByTagName(prefix + "NamedArea");
......
606 616
        }
607 617
    }
608 618

  
619

  
620
    /**
621
     * @param root
622
     */
623
    private void getGatheringDepth(Element root) {
624
        NodeList group;
625
        try {
626
            group = root.getElementsByTagName(prefix + "Gathering");
627
            for (int i = 0; i < group.getLength(); i++) {
628
                NodeList children = group.item(i).getChildNodes();
629
                for (int j = 0; j < children.getLength(); j++) {
630
                    if (children.item(j).getNodeName().equals(prefix + "Depth")) {
631
                        NodeList altitudes = children.item(j).getChildNodes();
632
                        for (int k = 0; k < altitudes.getLength(); k++) {
633
                            if (altitudes.item(k).getNodeName().equals(prefix + "MeasurementOrFactText")) {
634
                                path = altitudes.item(k).getNodeName();
635
                                getHierarchie(altitudes.item(k));
636
                                dataHolder.knownABCDelements.add(path);
637
                                path = "";
638
                                try{
639
                                    dataHolder.setGatheringDepthText(altitudes.item(k).getTextContent());
640
                                }catch(NumberFormatException e){
641
                                    logger.debug("Gathering depth value is not parsable to double: " + altitudes.item(k).getTextContent());
642
                                }
643
                            }
644
                        }
645
                    }
646
                }
647
                }
648
            } catch (NullPointerException e) {
649
                dataHolder.setDepth( -9999.0);
650
            }
651
        if(dataHolder.getDepth()==null){
652
            group = root.getElementsByTagName(prefix + "Gathering");
653
            for (int i = 0; i < group.getLength(); i++) {
654
                NodeList children = group.item(i).getChildNodes();
655
                for (int j = 0; j < children.getLength(); j++) {
656
                    if (children.item(j).getNodeName().equals(prefix + "Depth")) {
657
                        NodeList altitudes = children.item(j).getChildNodes();
658
                        for (int k = 0; k < altitudes.getLength(); k++) {
659
                            if (altitudes.item(k).getNodeName().equals(prefix + "MeasurementOrFactAtomised")) {
660
                                NodeList facts = altitudes.item(k).getChildNodes();
661
                                for (int l = 0; l < facts.getLength(); l++) {
662
                                    if (facts.item(l).getNodeName().equalsIgnoreCase(prefix + "LowerValue")) {
663
                                        path = facts.item(l).getNodeName();
664
                                        getHierarchie(facts.item(l));
665
                                        dataHolder.knownABCDelements.add(path);
666
                                        path = "";
667
                                        try{
668
                                            dataHolder.setGatheringDepthMin(Double.parseDouble(facts.item(l).getTextContent()));
669
                                        } catch(NumberFormatException e){
670
                                            logger.debug("Gathering depth min is not numeric. " + facts.item(l).getTextContent());
671
                                        }
672
                                    }
673
                                    else if (facts.item(l).getNodeName().equalsIgnoreCase(prefix + "UpperValue")) {
674
                                        path = facts.item(l).getNodeName();
675
                                        getHierarchie(facts.item(l));
676
                                        dataHolder.knownABCDelements.add(path);
677
                                        path = "";
678
                                        try{
679
                                            dataHolder.setGatheringDepthMax(Double.parseDouble(facts.item(l).getTextContent()));
680
                                        }catch(NumberFormatException e){
681
                                            logger.debug("Gathering depth max is not numeric. " + facts.item(l).getTextContent());
682
                                        }
683
                                    }
684
                                    else if (facts.item(l).getNodeName().equals(prefix + "UnitOfMeasurement")) {
685
                                        path = facts.item(l).getNodeName();
686
                                        getHierarchie(facts.item(l));
687
                                        dataHolder.knownABCDelements.add(path);
688
                                        path = "";
689
                                        dataHolder.setGatheringDepthUnit(facts.item(l).getTextContent());
690
                                    } else{
691
                                        System.out.println(facts.item(l).getNodeName() + " " + facts.item(l).getTextContent());
692
                                    }
693
                                }
694
                            }
695
                        }
696
                    }
697
                }
698
            }
699
        }
700
    }
701

  
609 702
    /**
610 703
     * getMultimedia: get the FileURI objects
611 704
     * @param root
612 705
     */
613 706
    protected void getMultimedia(Element root) {
614
        NodeList group, multimedias, multimedia;
707
        NodeList group, multimedias, multimedia, creators, creator, copyRightNodes, iprNodes, textNodes, licences, copyrights;
615 708
        try {
616 709
            group = root.getElementsByTagName(prefix + "MultiMediaObjects");
617 710
            for (int i = 0; i < group.getLength(); i++) {
......
619 712
                for (int j = 0; j < multimedias.getLength(); j++) {
620 713
                    if (multimedias.item(j).getNodeName().equals(prefix + "MultiMediaObject")) {
621 714
                        multimedia = multimedias.item(j).getChildNodes();
715
                        Map<String,String> mediaObjectMap = new HashMap<String, String>();
716
                        String fileUri = "";
622 717
                        for (int k = 0; k < multimedia.getLength(); k++) {
623
                            if (multimedia.item(k).getNodeName().equals(prefix + "FileURI")) {
624
                                dataHolder.getMultimediaObjects().add(multimedia.item(k).getTextContent());
718
                            if (multimedia.item(k).getNodeName().equalsIgnoreCase(prefix + "fileURI")) {
719
                                fileUri = multimedia.item(k).getTextContent();
720
                                mediaObjectMap.put("fileUri", fileUri);
625 721
                                path = multimedia.item(k).getNodeName();
626 722
                                getHierarchie(multimedia.item(k));
627 723
                                dataHolder.knownABCDelements.add(path);
628 724
                                path = "";
725
                            } else if (multimedia.item(k).getNodeName().equalsIgnoreCase(prefix + "context")) {
726
                                mediaObjectMap.put("Context", multimedia.item(k).getTextContent());
727
                            } else if (multimedia.item(k).getNodeName().equalsIgnoreCase(prefix + "Creators")){
728
                                String creatorString = "";
729
                                creators = multimedia.item(k).getChildNodes();
730
                                for (int l = 0; l < creators.getLength(); l++) {
731

  
732
                                    if (creators.item(l).getNodeName().equalsIgnoreCase(prefix + "Creator")){
733
                                        if (creatorString != ""){
734
                                            creatorString += ", ";
735
                                        }
736
                                       creatorString += creators.item(l).getTextContent();
737
                                    }
738
                                }
739
                                mediaObjectMap.put("Creators",creatorString);
740
                            } else if (multimedia.item(k).getNodeName().equalsIgnoreCase(prefix + "Creator")){
741
                                mediaObjectMap.put("Creators",multimedia.item(k).getTextContent());
742
                            } else if (multimedia.item(k).getNodeName().equals("CreatedDate")){
743
                                mediaObjectMap.put("CreatedDate",multimedia.item(k).getTextContent());
744
                            } else if (multimedia.item(k).getNodeName().equalsIgnoreCase(prefix + "comment")){
745
                                mediaObjectMap.put("Comment",multimedia.item(k).getTextContent());
746
                            } else if (multimedia.item(k).getNodeName().equalsIgnoreCase(prefix + "IPR")){
747
                                String copyRightString = "";
748
                                iprNodes = multimedia.item(k).getChildNodes();
749
                                for (int l = 0; l < iprNodes.getLength(); l++) {
750
                                    if (iprNodes.item(l).getNodeName().equalsIgnoreCase(prefix + "Copyrights")){
751
                                        copyRightNodes = iprNodes.item(l).getChildNodes();
752
                                        for (int m = 0; m < copyRightNodes.getLength(); m++) {
753
                                            if (copyRightNodes.item(l).getNodeName().equalsIgnoreCase(prefix + "Copyright")){
754
                                                copyrights = copyRightNodes.item(l).getChildNodes();
755
                                                for (int n = 0; n < copyrights.getLength(); n++){
756
                                                    if (copyrights.item(n).getNodeName().equalsIgnoreCase(prefix + "text")){
757
                                                           //TODO: decide whether this is the copyright owner or a description text
758
                                                    }
759
                                                }
760
                                            }
761
                                        }
762
                                    }
763
                                }
764

  
765

  
766

  
767
                              // TODO: mediaObjectMap.put("IPR",multimedia.item(k).getTextContent());
768
                            } else{
769
                                System.out.println(multimedia.item(k).getNodeName() + " " + multimedia.item(k).getTextContent());
629 770
                            }
771

  
772
                        }
773
                        if (fileUri != ""){
774
                            dataHolder.putMultiMediaObject(fileUri,mediaObjectMap);
630 775
                        }
631 776
                    }
632 777
                }
......
817 962
     */
818 963
    protected void getGatheringPeople(Element root) {
819 964
        try {
820
            dataHolder.gatheringAgentList = new ArrayList<String>();
965
            dataHolder.gatheringAgents = "";
821 966

  
822 967
            NodeList group = root.getElementsByTagName(prefix + "GatheringAgent");
823 968
            for (int i = 0; i < group.getLength(); i++) {
......
832 977
                                dataHolder.knownABCDelements.add(path);
833 978
                                path = "";
834 979
                                if (!persons.item(k).getTextContent().trim().equalsIgnoreCase("none")) {
835
                                    dataHolder.gatheringAgentList.add(persons.item(k).getTextContent());
980

  
981
                                    dataHolder.gatheringAgents += persons.item(k).getTextContent();
836 982
                                }
837 983
                            }
838 984
                        }
......
854 1000
                                dataHolder.knownABCDelements.add(path);
855 1001
                                path = "";
856 1002
                                if (!persons.item(k).getTextContent().trim().equalsIgnoreCase("none")) {
857
                                    dataHolder.gatheringAgentList.add(persons.item(k).getTextContent());
1003
                                    dataHolder.gatheringAgents+=persons.item(k).getTextContent();
858 1004
                                }
859 1005
                            }
860 1006
                        }
......
864 1010
            }
865 1011

  
866 1012
        } catch (NullPointerException e) {
867
            dataHolder.gatheringAgentList = new ArrayList<String>();
868
        }
869
        if (dataHolder.gatheringAgentList.size() > 1){
870
            dataHolder.gatheringTeamList.addAll(dataHolder.gatheringAgentList);
871
            dataHolder.gatheringAgentList = new ArrayList<String>();
1013
            dataHolder.gatheringAgents = "";
872 1014
        }
1015

  
873 1016
    }
874 1017

  
875 1018
    /*PARSING METHODS*/
......
1137 1280
        return atomisedMap;
1138 1281
    }
1139 1282

  
1283

  
1284
    /**
1285
     * @param root
1286
     */
1287
    public void getGatheringImages(Element root) {
1288
        NodeList group, multimedias, multimedia, creators, creator;
1289
        try {
1290
            group = root.getElementsByTagName(prefix + "SiteImages");
1291
            for (int i = 0; i < group.getLength(); i++) {
1292
                multimedias = group.item(i).getChildNodes();
1293
                for (int j = 0; j < multimedias.getLength(); j++) {
1294
                    if (multimedias.item(j).getNodeName().equals(prefix + "SiteImage")) {
1295
                        multimedia = multimedias.item(j).getChildNodes();
1296
                        Map<String,String> mediaObjectMap = new HashMap<String, String>();
1297
                        String fileUri = "";
1298
                        for (int k = 0; k < multimedia.getLength(); k++) {
1299

  
1300

  
1301
                            if (multimedia.item(k).getNodeName().equalsIgnoreCase(prefix + "fileURI")) {
1302
                                fileUri = multimedia.item(k).getTextContent();
1303
                                mediaObjectMap.put("fileUri", fileUri);
1304
                                path = multimedia.item(k).getNodeName();
1305
                                getHierarchie(multimedia.item(k));
1306
                                dataHolder.knownABCDelements.add(path);
1307
                                path = "";
1308
                            } else if (multimedia.item(k).getNodeName().equalsIgnoreCase(prefix + "Context")) {
1309
                                mediaObjectMap.put("Context", multimedia.item(k).getTextContent());
1310
                            }else if (multimedia.item(k).getNodeName().equalsIgnoreCase(prefix + "Comment")) {
1311
                                mediaObjectMap.put("Comment", multimedia.item(k).getTextContent());
1312
                            } else if (multimedia.item(k).getNodeName().equalsIgnoreCase(prefix + "Creators")){
1313
                                String creatorString = "";
1314
                                creators = multimedia.item(k).getChildNodes();
1315
                                for (int l = 0; l < creators.getLength(); l++) {
1316

  
1317
                                    if (creators.item(l).getNodeName().equalsIgnoreCase(prefix + "Creator")){
1318
                                        if (creatorString != ""){
1319
                                            creatorString += ", ";
1320
                                        }
1321
                                       creatorString += creators.item(l).getTextContent();
1322
                                    }
1323
                                }
1324
                                mediaObjectMap.put("Creators",creatorString);
1325
                            } else if (multimedia.item(k).getNodeName().equalsIgnoreCase(prefix + "Creator")){
1326
                                mediaObjectMap.put("Creators",multimedia.item(k).getTextContent());
1327
                            }
1328
                        }
1329
                        if (fileUri != ""){
1330
                            dataHolder.putGatheringMultiMediaObject(fileUri,mediaObjectMap);
1331
                        }
1332
                    }
1333
                }
1334
            }
1335
        } catch (NullPointerException e) {
1336
            logger.info(e);
1337
        }
1338

  
1339
    }
1340

  
1140 1341
}
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/specimen/abcd206/in/SpecimenImportReport.java
142 142
            SpecimenOrObservationType type = entry.getKey();
143 143
            out.println(type+": "+entry.getValue());
144 144
        }
145
        //not imported
146
        out.println("Skipped/not imported: "+alreadyExistingSpecimens.size());
145 147
        out.println("\n");
146 148

  
147 149
        out.println("Imported unit ids");
......
188 190
        out.println("\n");
189 191

  
190 192
        //not imported
191
        out.println("---Already existing specimen (not imported)---");
193
        out.println("---Already existing specimen/not imported ("+alreadyExistingSpecimens.size()+")---");
192 194
        for(UnitIdSpecimen specimen:alreadyExistingSpecimens){
193 195
            out.println(formatSpecimen(specimen));
194 196
        }
195 197
        out.println("\n");
196 198

  
197 199
        //taxa with associated specimens
198
        out.println("---Taxa with associated specimens---");
200
        out.println("---Taxa with associated specimens ("+taxonToAssociatedSpecimens.size()+")---");
199 201
        for(Entry<Taxon, List<UnitIdSpecimen>> entry:taxonToAssociatedSpecimens.entrySet()){
200 202
            Taxon taxon = entry.getKey();
201 203
            List<UnitIdSpecimen> specimens = entry.getValue();
......
295 297
    }
296 298

  
297 299
}
300

  
cdmlib-io/src/test/java/eu/etaxonomy/cdm/io/specimen/abcd206/in/AbcdGgbnImportTest.java
524 524

  
525 525
	    boolean result = defaultImport.invoke(importConfigurator).isSuccess();
526 526
	    assertTrue("Return value for import.invoke should be true", result);
527
	    assertEquals("Number of derived units is incorrect", 2, occurrenceService.count(DerivedUnit.class));
528 527
	    List<DerivedUnit> derivedUnits = occurrenceService.list(DerivedUnit.class, null, null, null, null);
528
	    for (DerivedUnit derivedUnit:derivedUnits){
529
	        System.out.println(derivedUnit.getTitleCache());
530
	    }
531
	    assertEquals("Number of derived units is incorrect", 2, occurrenceService.count(DerivedUnit.class));
532
	   // List<DerivedUnit> derivedUnits = occurrenceService.list(DerivedUnit.class, null, null, null, null);
529 533

  
530 534
	    List<FieldUnit> fieldUnitsTemp = occurrenceService.list(FieldUnit.class, null, null, null, null);
531 535
	    assertEquals("Number of derived units is incorrect", 2, derivedUnits.size());
cdmlib-model/src/main/java/eu/etaxonomy/cdm/hibernate/HHH_9751_Util.java
12 12
import java.util.Collection;
13 13

  
14 14
import org.apache.log4j.Logger;
15
import org.hibernate.Hibernate;
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)