Project

General

Profile

Revision 4d622b5d

ID4d622b5dbfd2cb3d1c4cd1165f0813c7d75ba41f
Parent 92835c7d
Child ce2ea9e9

Added by Katja Luther almost 3 years ago

getUuidAndTitleCache of classificationservice does not need the excluded taxa

View differences:

cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/specimen/abcd206/in/Abcd206ImportReport.java
1
// $Id$
2
/**
3
* Copyright (C) 2015 EDIT
4
* European Distributed Institute of Taxonomy
5
* http://www.e-taxonomy.eu
6
*
7
* The contents of this file are subject to the Mozilla Public License Version 1.1
8
* See LICENSE.TXT at the top of this package for the full license terms.
9
*/
10
package eu.etaxonomy.cdm.io.specimen.abcd206.in;
11

  
12
import java.io.File;
13
import java.io.FileNotFoundException;
14
import java.io.PrintStream;
15
import java.io.PrintWriter;
16
import java.io.StringWriter;
17
import java.net.URI;
18
import java.util.ArrayList;
19
import java.util.HashMap;
20
import java.util.HashSet;
21
import java.util.List;
22
import java.util.Map;
23
import java.util.Map.Entry;
24
import java.util.Set;
25

  
26
import org.apache.log4j.Logger;
27

  
28
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
29
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
30
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
31
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationType;
32
import eu.etaxonomy.cdm.model.taxon.Taxon;
33
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
34

  
35
/**
36
 * Gathers information about the ABCD import and presents them in a suitable way.
37
 * @author pplitzner
38
 * @date Jan 23, 2015
39
 *
40
 */
41
public class Abcd206ImportReport {
42

  
43
    static private final Logger logger = Logger.getLogger(Abcd206ImportReport.class);
44

  
45

  
46
    private final List<Taxon> createdTaxa = new ArrayList<Taxon>();
47
    private final Map<Taxon, List<UnitIdSpecimen>> taxonToAssociatedSpecimens =  new HashMap<Taxon, List<UnitIdSpecimen>>();
48
    private final Map<UnitIdSpecimen, List<UnitIdSpecimen>> derivateMap = new HashMap<UnitIdSpecimen, List<UnitIdSpecimen>>();
49
    private final List<UnitIdSpecimen> alreadyExistingSpecimens = new ArrayList<UnitIdSpecimen>();
50
    private final List<TaxonNameBase<?, ?>> createdNames = new ArrayList<TaxonNameBase<?,?>>();
51
    private final List<TaxonNode> createdTaxonNodes = new ArrayList<TaxonNode>();
52
    private final List<String> infoMessages = new ArrayList<String>();
53

  
54
    public void addTaxon(Taxon taxon){
55
        createdTaxa.add(taxon);
56
    }
57

  
58
    public void addName(TaxonNameBase<?, ?> taxonName){
59
        createdNames.add(taxonName);
60
    }
61

  
62
    public void addTaxonNode(TaxonNode taxonNode){
63
        createdTaxonNodes.add(taxonNode);
64
    }
65

  
66
    public void addDerivate(DerivedUnit parent, Abcd206ImportConfigurator config){
67
        addDerivate(parent, null, config);
68
    }
69

  
70
    public void addDerivate(DerivedUnit parent, DerivedUnit child, Abcd206ImportConfigurator config){
71
        UnitIdSpecimen parentUnitIdSpecimen = new UnitIdSpecimen(AbcdImportUtility.getUnitID(parent, config), parent);
72
        List<UnitIdSpecimen> children = derivateMap.get(parentUnitIdSpecimen);
73
        if(children==null){
74
            children = new ArrayList<UnitIdSpecimen>();
75
        }
76
        if(child!=null){
77
            children.add(new UnitIdSpecimen(AbcdImportUtility.getUnitID(child, config), child));
78
        }
79
        derivateMap.put(parentUnitIdSpecimen, children);
80
    }
81

  
82
    public void addIndividualAssociation(Taxon taxon, String derivedUnitId, DerivedUnit derivedUnitBase) {
83
        UnitIdSpecimen derivedUnitIdSpecimen = new UnitIdSpecimen(derivedUnitId, derivedUnitBase);
84
        List<UnitIdSpecimen> associatedSpecimens = taxonToAssociatedSpecimens.get(taxon);
85
        if(associatedSpecimens==null){
86
            associatedSpecimens = new ArrayList<UnitIdSpecimen>();
87
        }
88
        associatedSpecimens.add(derivedUnitIdSpecimen);
89
        taxonToAssociatedSpecimens.put(taxon, associatedSpecimens);
90
    }
91

  
92
    public void addAlreadyExistingSpecimen(String unitId, DerivedUnit derivedUnit){
93
        alreadyExistingSpecimens.add(new UnitIdSpecimen(unitId, derivedUnit));
94
    }
95

  
96
    public void addException(String message, Exception e) {
97
        StringWriter errors = new StringWriter();
98
        e.printStackTrace(new PrintWriter(errors));
99
        infoMessages.add(message+"\n"+e.getMessage()+"\n"+errors.toString());
100
    }
101

  
102
    public void addInfoMessage(String message) {
103
        infoMessages.add(message);
104
    }
105

  
106
    public void printReport(URI reportUri) {
107
        PrintStream out;
108
        if(reportUri != null){
109
            try {
110
                out = new PrintStream(new File(reportUri));
111
            } catch (FileNotFoundException e) {
112
                logger.warn("Report file could not be found.");
113
                out = System.out;
114
            }
115
        }
116
        else{
117
            out = System.out;
118
        }
119
        printReport(out);
120
    }
121

  
122

  
123
    public void printReport(PrintStream out) {
124

  
125
        out.println("++++++++Import Report+++++++++");
126
      //all specimens
127
        Set<UnitIdSpecimen> allSpecimens = new HashSet<UnitIdSpecimen>();
128
        for (Entry<UnitIdSpecimen, List<UnitIdSpecimen>> entry : derivateMap.entrySet()) {
129
            UnitIdSpecimen parentSpecimen = entry.getKey();
130
            allSpecimens.add(parentSpecimen);
131
            for (UnitIdSpecimen childSpecimen : entry.getValue()) {
132
                allSpecimens.add(childSpecimen);
133
            }
134
        }
135
        out.println("Specimens created: "+allSpecimens.size());
136
        Map<SpecimenOrObservationType, Integer> specimenTypeToCount = new HashMap<SpecimenOrObservationType, Integer>();
137
        for (UnitIdSpecimen unitIdSpecimen : allSpecimens) {
138
            incrementSpecimenTypeCount(specimenTypeToCount, unitIdSpecimen);
139
        }
140
        for(Entry<SpecimenOrObservationType, Integer> entry:specimenTypeToCount.entrySet()){
141
            SpecimenOrObservationType type = entry.getKey();
142
            out.println(type+": "+entry.getValue());
143
        }
144
        out.println("\n");
145

  
146
        //taxon name
147
        out.println("---Created Taxon Names ("+createdNames.size()+")---");
148
        for (TaxonNameBase<?, ?> taxonName : createdNames) {
149
            out.println(taxonName.getTitleCache());
150
        }
151
        out.println("\n");
152

  
153
        //taxa
154
        out.println("---Created Taxa ("+createdTaxa.size()+")---");
155
        for (Taxon taxon : createdTaxa) {
156
            out.println(taxon.getTitleCache());
157
        }
158
        out.println("\n");
159

  
160
        //taxon nodes
161
        out.println("---Created Taxon Nodes ("+createdTaxonNodes.size()+")---");
162
        for (TaxonNode taxonNode : createdTaxonNodes) {
163
            String nodeString = taxonNode.toString();
164
            if(taxonNode.getTaxon()!=null){
165
                nodeString += " ("+taxonNode.getTaxon().getTitleCache()+")";
166
            }
167
            if(taxonNode.getParent()!=null){
168
                nodeString += " with parent "+taxonNode.getParent();
169
                if(taxonNode.getParent().getTaxon()!=null){
170
                    nodeString += " ("+taxonNode.getParent().getTaxon().getTitleCache()+")";
171
                }
172
            }
173
            out.println(nodeString);
174
        }
175
        out.println("\n");
176

  
177
        //not imported
178
        out.println("---Already existing specimen (not imported)---");
179
        for(UnitIdSpecimen specimen:alreadyExistingSpecimens){
180
            out.println(formatSpecimen(specimen));
181
        }
182
        out.println("\n");
183

  
184
        //taxa with associated specimens
185
        out.println("---Taxa with associated specimens---");
186
        for(Entry<Taxon, List<UnitIdSpecimen>> entry:taxonToAssociatedSpecimens.entrySet()){
187
            Taxon taxon = entry.getKey();
188
            List<UnitIdSpecimen> specimens = entry.getValue();
189
            out.println(taxon.getTitleCache() + " ("+specimens.size()+")");
190
            for (UnitIdSpecimen derivedUnit : specimens) {
191
                out.println("\t- "+formatSpecimen(derivedUnit));
192
                //check for derivatives
193
                List<UnitIdSpecimen> list = derivateMap.get(derivedUnit);
194
                for (UnitIdSpecimen derivate : list) {
195
                    out.println("\t\t- "+formatSpecimen(derivate));
196
                }
197
            }
198
        }
199
        out.println("\n");
200
        out.println("\n");
201
        //info messages
202
        out.println("---Info messages---");
203
        for(String message:infoMessages){
204
            out.println(message);
205
            out.println("---");
206
        }
207
        if(out!=System.out){
208
            out.close();
209
        }
210
    }
211

  
212
    private void incrementSpecimenTypeCount(Map<SpecimenOrObservationType, Integer> specimenTypeToCount,
213
            UnitIdSpecimen specimen) {
214
        SpecimenOrObservationType specimenType = specimen.getSpecimen().getRecordBasis();
215
        Integer count = specimenTypeToCount.get(specimenType);
216
        if(count==null){
217
            count = 1;
218
        }
219
        else{
220
            count++;
221
        }
222
        specimenTypeToCount.put(specimenType, count);
223
    }
224

  
225
    private String formatSpecimen(UnitIdSpecimen specimen){
226
        return "("+specimen.getUnitId()+") ["+specimen.getSpecimen().getRecordBasis()+"] "+specimen.getSpecimen().getTitleCache();
227
    }
228

  
229
    private class UnitIdSpecimen{
230
        private final String unitId;
231
        private final SpecimenOrObservationBase<?> specimen;
232

  
233

  
234
        public UnitIdSpecimen(String unitId, SpecimenOrObservationBase<?> specimen) {
235
            super();
236
            this.unitId = unitId;
237
            this.specimen = specimen;
238
        }
239
        public String getUnitId() {
240
            return unitId;
241
        }
242
        public SpecimenOrObservationBase<?> getSpecimen() {
243
            return specimen;
244
        }
245
        @Override
246
        public int hashCode() {
247
            final int prime = 31;
248
            int result = 1;
249
            result = prime * result + ((specimen == null) ? 0 : specimen.hashCode());
250
            result = prime * result + ((unitId == null) ? 0 : unitId.hashCode());
251
            return result;
252
        }
253
        @Override
254
        public boolean equals(Object obj) {
255
            if (this == obj) {
256
                return true;
257
            }
258
            if (obj == null) {
259
                return false;
260
            }
261
            if (getClass() != obj.getClass()) {
262
                return false;
263
            }
264
            UnitIdSpecimen other = (UnitIdSpecimen) obj;
265
            if (specimen == null) {
266
                if (other.specimen != null) {
267
                    return false;
268
                }
269
            } else if (!specimen.equals(other.specimen)) {
270
                return false;
271
            }
272
            if (unitId == null) {
273
                if (other.unitId != null) {
274
                    return false;
275
                }
276
            } else if (!unitId.equals(other.unitId)) {
277
                return false;
278
            }
279
            return true;
280
        }
281

  
282
    }
283

  
284
}
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/specimen/abcd206/in/AbcdImportUtility.java
1
// $Id$
2
/**
3
* Copyright (C) 2015 EDIT
4
* European Distributed Institute of Taxonomy
5
* http://www.e-taxonomy.eu
6
*
7
* The contents of this file are subject to the Mozilla Public License Version 1.1
8
* See LICENSE.TXT at the top of this package for the full license terms.
9
*/
10
package eu.etaxonomy.cdm.io.specimen.abcd206.in;
11

  
12
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
13

  
14
/**
15
 * @author pplitzner
16
 * @date 16.06.2015
17
 *
18
 */
19
public class AbcdImportUtility {
20

  
21
    public static String getUnitID(DerivedUnit derivedUnit, Abcd206ImportConfigurator config){
22
        if(config.isMapUnitIdToAccessionNumber()){
23
            return derivedUnit.getAccessionNumber();
24
        }
25
        if(config.isMapUnitIdToBarcode()){
26
            return derivedUnit.getBarcode();
27
        }
28
        return derivedUnit.getCatalogNumber();
29
    }
30

  
31
    public static void setUnitID(DerivedUnit derivedUnit, String unitId, Abcd206ImportConfigurator config){
32
        if(config.isMapUnitIdToCatalogNumber()
33
                || !(config.isMapUnitIdToAccessionNumber() || config.isMapUnitIdToBarcode() || config.isMapUnitIdToCatalogNumber())){
34
            // set catalog number (default if nothing is set)
35
            derivedUnit.setCatalogNumber(unitId);
36
        }
37
        if(config.isMapUnitIdToAccessionNumber()){
38
            derivedUnit.setAccessionNumber(unitId);
39
        }
40
        if(config.isMapUnitIdToBarcode()){
41
            derivedUnit.setBarcode(unitId);
42
        }
43
    }
44

  
45
}
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/specimen/abcd206/in/SpecimenImportReport.java
1
// $Id$
2
/**
3
* Copyright (C) 2015 EDIT
4
* European Distributed Institute of Taxonomy
5
* http://www.e-taxonomy.eu
6
*
7
* The contents of this file are subject to the Mozilla Public License Version 1.1
8
* See LICENSE.TXT at the top of this package for the full license terms.
9
*/
10
package eu.etaxonomy.cdm.io.specimen.abcd206.in;
11

  
12
import java.io.File;
13
import java.io.FileNotFoundException;
14
import java.io.PrintStream;
15
import java.io.PrintWriter;
16
import java.io.StringWriter;
17
import java.net.URI;
18
import java.util.ArrayList;
19
import java.util.HashMap;
20
import java.util.HashSet;
21
import java.util.List;
22
import java.util.Map;
23
import java.util.Map.Entry;
24
import java.util.Set;
25

  
26
import org.apache.log4j.Logger;
27

  
28
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
29
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
30
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
31
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationType;
32
import eu.etaxonomy.cdm.model.taxon.Taxon;
33
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
34

  
35
/**
36
 * Gathers information about the ABCD import and presents them in a suitable way.
37
 * @author pplitzner
38
 * @date Jan 23, 2015
39
 *
40
 */
41
public class Abcd206ImportReport {
42

  
43
    static private final Logger logger = Logger.getLogger(Abcd206ImportReport.class);
44

  
45

  
46
    private final List<Taxon> createdTaxa = new ArrayList<Taxon>();
47
    private final Map<Taxon, List<UnitIdSpecimen>> taxonToAssociatedSpecimens =  new HashMap<Taxon, List<UnitIdSpecimen>>();
48
    private final Map<UnitIdSpecimen, List<UnitIdSpecimen>> derivateMap = new HashMap<UnitIdSpecimen, List<UnitIdSpecimen>>();
49
    private final List<UnitIdSpecimen> alreadyExistingSpecimens = new ArrayList<UnitIdSpecimen>();
50
    private final List<TaxonNameBase<?, ?>> createdNames = new ArrayList<TaxonNameBase<?,?>>();
51
    private final List<TaxonNode> createdTaxonNodes = new ArrayList<TaxonNode>();
52
    private final List<String> infoMessages = new ArrayList<String>();
53

  
54
    public void addTaxon(Taxon taxon){
55
        createdTaxa.add(taxon);
56
    }
57

  
58
    public void addName(TaxonNameBase<?, ?> taxonName){
59
        createdNames.add(taxonName);
60
    }
61

  
62
    public void addTaxonNode(TaxonNode taxonNode){
63
        createdTaxonNodes.add(taxonNode);
64
    }
65

  
66
    public void addDerivate(DerivedUnit parent, Abcd206ImportConfigurator config){
67
        addDerivate(parent, null, config);
68
    }
69

  
70
    public void addDerivate(DerivedUnit parent, DerivedUnit child, Abcd206ImportConfigurator config){
71
        UnitIdSpecimen parentUnitIdSpecimen = new UnitIdSpecimen(AbcdImportUtility.getUnitID(parent, config), parent);
72
        List<UnitIdSpecimen> children = derivateMap.get(parentUnitIdSpecimen);
73
        if(children==null){
74
            children = new ArrayList<UnitIdSpecimen>();
75
        }
76
        if(child!=null){
77
            children.add(new UnitIdSpecimen(AbcdImportUtility.getUnitID(child, config), child));
78
        }
79
        derivateMap.put(parentUnitIdSpecimen, children);
80
    }
81

  
82
    public void addIndividualAssociation(Taxon taxon, String derivedUnitId, DerivedUnit derivedUnitBase) {
83
        UnitIdSpecimen derivedUnitIdSpecimen = new UnitIdSpecimen(derivedUnitId, derivedUnitBase);
84
        List<UnitIdSpecimen> associatedSpecimens = taxonToAssociatedSpecimens.get(taxon);
85
        if(associatedSpecimens==null){
86
            associatedSpecimens = new ArrayList<UnitIdSpecimen>();
87
        }
88
        associatedSpecimens.add(derivedUnitIdSpecimen);
89
        taxonToAssociatedSpecimens.put(taxon, associatedSpecimens);
90
    }
91

  
92
    public void addAlreadyExistingSpecimen(String unitId, DerivedUnit derivedUnit){
93
        alreadyExistingSpecimens.add(new UnitIdSpecimen(unitId, derivedUnit));
94
    }
95

  
96
    public void addException(String message, Exception e) {
97
        StringWriter errors = new StringWriter();
98
        e.printStackTrace(new PrintWriter(errors));
99
        infoMessages.add(message+"\n"+e.getMessage()+"\n"+errors.toString());
100
    }
101

  
102
    public void addInfoMessage(String message) {
103
        infoMessages.add(message);
104
    }
105

  
106
    public void printReport(URI reportUri) {
107
        PrintStream out;
108
        if(reportUri != null){
109
            try {
110
                out = new PrintStream(new File(reportUri));
111
            } catch (FileNotFoundException e) {
112
                logger.warn("Report file could not be found.");
113
                out = System.out;
114
            }
115
        }
116
        else{
117
            out = System.out;
118
        }
119
        printReport(out);
120
    }
121

  
122

  
123
    public void printReport(PrintStream out) {
124

  
125
        out.println("++++++++Import Report+++++++++");
126
      //all specimens
127
        Set<UnitIdSpecimen> allSpecimens = new HashSet<UnitIdSpecimen>();
128
        for (Entry<UnitIdSpecimen, List<UnitIdSpecimen>> entry : derivateMap.entrySet()) {
129
            UnitIdSpecimen parentSpecimen = entry.getKey();
130
            allSpecimens.add(parentSpecimen);
131
            for (UnitIdSpecimen childSpecimen : entry.getValue()) {
132
                allSpecimens.add(childSpecimen);
133
            }
134
        }
135
        out.println("Specimens created: "+allSpecimens.size());
136
        Map<SpecimenOrObservationType, Integer> specimenTypeToCount = new HashMap<SpecimenOrObservationType, Integer>();
137
        for (UnitIdSpecimen unitIdSpecimen : allSpecimens) {
138
            incrementSpecimenTypeCount(specimenTypeToCount, unitIdSpecimen);
139
        }
140
        for(Entry<SpecimenOrObservationType, Integer> entry:specimenTypeToCount.entrySet()){
141
            SpecimenOrObservationType type = entry.getKey();
142
            out.println(type+": "+entry.getValue());
143
        }
144
        out.println("\n");
145

  
146
        //taxon name
147
        out.println("---Created Taxon Names ("+createdNames.size()+")---");
148
        for (TaxonNameBase<?, ?> taxonName : createdNames) {
149
            out.println(taxonName.getTitleCache());
150
        }
151
        out.println("\n");
152

  
153
        //taxa
154
        out.println("---Created Taxa ("+createdTaxa.size()+")---");
155
        for (Taxon taxon : createdTaxa) {
156
            out.println(taxon.getTitleCache());
157
        }
158
        out.println("\n");
159

  
160
        //taxon nodes
161
        out.println("---Created Taxon Nodes ("+createdTaxonNodes.size()+")---");
162
        for (TaxonNode taxonNode : createdTaxonNodes) {
163
            String nodeString = taxonNode.toString();
164
            if(taxonNode.getTaxon()!=null){
165
                nodeString += " ("+taxonNode.getTaxon().getTitleCache()+")";
166
            }
167
            if(taxonNode.getParent()!=null){
168
                nodeString += " with parent "+taxonNode.getParent();
169
                if(taxonNode.getParent().getTaxon()!=null){
170
                    nodeString += " ("+taxonNode.getParent().getTaxon().getTitleCache()+")";
171
                }
172
            }
173
            out.println(nodeString);
174
        }
175
        out.println("\n");
176

  
177
        //not imported
178
        out.println("---Already existing specimen (not imported)---");
179
        for(UnitIdSpecimen specimen:alreadyExistingSpecimens){
180
            out.println(formatSpecimen(specimen));
181
        }
182
        out.println("\n");
183

  
184
        //taxa with associated specimens
185
        out.println("---Taxa with associated specimens---");
186
        for(Entry<Taxon, List<UnitIdSpecimen>> entry:taxonToAssociatedSpecimens.entrySet()){
187
            Taxon taxon = entry.getKey();
188
            List<UnitIdSpecimen> specimens = entry.getValue();
189
            out.println(taxon.getTitleCache() + " ("+specimens.size()+")");
190
            for (UnitIdSpecimen derivedUnit : specimens) {
191
                out.println("\t- "+formatSpecimen(derivedUnit));
192
                //check for derivatives
193
                List<UnitIdSpecimen> list = derivateMap.get(derivedUnit);
194
                for (UnitIdSpecimen derivate : list) {
195
                    out.println("\t\t- "+formatSpecimen(derivate));
196
                }
197
            }
198
        }
199
        out.println("\n");
200
        out.println("\n");
201
        //info messages
202
        out.println("---Info messages---");
203
        for(String message:infoMessages){
204
            out.println(message);
205
            out.println("---");
206
        }
207
        if(out!=System.out){
208
            out.close();
209
        }
210
    }
211

  
212
    private void incrementSpecimenTypeCount(Map<SpecimenOrObservationType, Integer> specimenTypeToCount,
213
            UnitIdSpecimen specimen) {
214
        SpecimenOrObservationType specimenType = specimen.getSpecimen().getRecordBasis();
215
        Integer count = specimenTypeToCount.get(specimenType);
216
        if(count==null){
217
            count = 1;
218
        }
219
        else{
220
            count++;
221
        }
222
        specimenTypeToCount.put(specimenType, count);
223
    }
224

  
225
    private String formatSpecimen(UnitIdSpecimen specimen){
226
        return "("+specimen.getUnitId()+") ["+specimen.getSpecimen().getRecordBasis()+"] "+specimen.getSpecimen().getTitleCache();
227
    }
228

  
229
    private class UnitIdSpecimen{
230
        private final String unitId;
231
        private final SpecimenOrObservationBase<?> specimen;
232

  
233

  
234
        public UnitIdSpecimen(String unitId, SpecimenOrObservationBase<?> specimen) {
235
            super();
236
            this.unitId = unitId;
237
            this.specimen = specimen;
238
        }
239
        public String getUnitId() {
240
            return unitId;
241
        }
242
        public SpecimenOrObservationBase<?> getSpecimen() {
243
            return specimen;
244
        }
245
        @Override
246
        public int hashCode() {
247
            final int prime = 31;
248
            int result = 1;
249
            result = prime * result + ((specimen == null) ? 0 : specimen.hashCode());
250
            result = prime * result + ((unitId == null) ? 0 : unitId.hashCode());
251
            return result;
252
        }
253
        @Override
254
        public boolean equals(Object obj) {
255
            if (this == obj) {
256
                return true;
257
            }
258
            if (obj == null) {
259
                return false;
260
            }
261
            if (getClass() != obj.getClass()) {
262
                return false;
263
            }
264
            UnitIdSpecimen other = (UnitIdSpecimen) obj;
265
            if (specimen == null) {
266
                if (other.specimen != null) {
267
                    return false;
268
                }
269
            } else if (!specimen.equals(other.specimen)) {
270
                return false;
271
            }
272
            if (unitId == null) {
273
                if (other.unitId != null) {
274
                    return false;
275
                }
276
            } else if (!unitId.equals(other.unitId)) {
277
                return false;
278
            }
279
            return true;
280
        }
281

  
282
    }
283

  
284
}
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/specimen/abcd206/in/SpecimenImportUtility.java
1
// $Id$
2
/**
3
* Copyright (C) 2015 EDIT
4
* European Distributed Institute of Taxonomy
5
* http://www.e-taxonomy.eu
6
*
7
* The contents of this file are subject to the Mozilla Public License Version 1.1
8
* See LICENSE.TXT at the top of this package for the full license terms.
9
*/
10
package eu.etaxonomy.cdm.io.specimen.abcd206.in;
11

  
12
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
13

  
14
/**
15
 * @author pplitzner
16
 * @date 16.06.2015
17
 *
18
 */
19
public class AbcdImportUtility {
20

  
21
    public static String getUnitID(DerivedUnit derivedUnit, Abcd206ImportConfigurator config){
22
        if(config.isMapUnitIdToAccessionNumber()){
23
            return derivedUnit.getAccessionNumber();
24
        }
25
        if(config.isMapUnitIdToBarcode()){
26
            return derivedUnit.getBarcode();
27
        }
28
        return derivedUnit.getCatalogNumber();
29
    }
30

  
31
    public static void setUnitID(DerivedUnit derivedUnit, String unitId, Abcd206ImportConfigurator config){
32
        if(config.isMapUnitIdToCatalogNumber()
33
                || !(config.isMapUnitIdToAccessionNumber() || config.isMapUnitIdToBarcode() || config.isMapUnitIdToCatalogNumber())){
34
            // set catalog number (default if nothing is set)
35
            derivedUnit.setCatalogNumber(unitId);
36
        }
37
        if(config.isMapUnitIdToAccessionNumber()){
38
            derivedUnit.setAccessionNumber(unitId);
39
        }
40
        if(config.isMapUnitIdToBarcode()){
41
            derivedUnit.setBarcode(unitId);
42
        }
43
    }
44

  
45
}
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/ClassificationServiceImpl.java
332 332
    }
333 333

  
334 334
    @Override
335
    public List<UuidAndTitleCache<TaxonNode>> getTaxonNodeUuidAndTitleCacheOfAcceptedTaxaByClassification(UUID classificationUuid, List<UUID> excludeTaxa, Integer limit, String pattern) {
336
        return taxonDao.getTaxonNodeUuidAndTitleCacheOfAcceptedTaxaByClassification(dao.load(classificationUuid), excludeTaxa, limit, pattern);
335
    public List<UuidAndTitleCache<TaxonNode>> getTaxonNodeUuidAndTitleCacheOfAcceptedTaxaByClassification(UUID classificationUuid, Integer limit, String pattern) {
336
        return taxonDao.getTaxonNodeUuidAndTitleCacheOfAcceptedTaxaByClassification(dao.load(classificationUuid), limit, pattern);
337 337
    }
338 338

  
339 339
    @Override
340
    public List<UuidAndTitleCache<TaxonNode>> getTaxonNodeUuidAndTitleCacheOfAcceptedTaxaByClassification(Classification classification, List<UUID> excludeTaxa, Integer limit, String pattern) {
341
        return taxonDao.getTaxonNodeUuidAndTitleCacheOfAcceptedTaxaByClassification(classification, excludeTaxa, limit, pattern);
340
    public List<UuidAndTitleCache<TaxonNode>> getTaxonNodeUuidAndTitleCacheOfAcceptedTaxaByClassification(Classification classification,  Integer limit, String pattern) {
341
        return taxonDao.getTaxonNodeUuidAndTitleCacheOfAcceptedTaxaByClassification(classification,  limit, pattern);
342 342
    }
343 343

  
344 344
    @Override
345
    public List<UuidAndTitleCache<TaxonNode>> getTaxonNodeUuidAndTitleCacheOfAcceptedTaxaByClassification(UUID classificationUuid, List<UUID> excludeTaxa) {
346
        return taxonDao.getTaxonNodeUuidAndTitleCacheOfAcceptedTaxaByClassification(dao.load(classificationUuid), excludeTaxa, null, null);
345
    public List<UuidAndTitleCache<TaxonNode>> getTaxonNodeUuidAndTitleCacheOfAcceptedTaxaByClassification(UUID classificationUuid ) {
346
        return taxonDao.getTaxonNodeUuidAndTitleCacheOfAcceptedTaxaByClassification(dao.load(classificationUuid),  null, null);
347 347
    }
348 348

  
349 349
    @Override
350
    public List<UuidAndTitleCache<TaxonNode>> getTaxonNodeUuidAndTitleCacheOfAcceptedTaxaByClassification(Classification classification, List<UUID> excludeTaxa) {
351
        return taxonDao.getTaxonNodeUuidAndTitleCacheOfAcceptedTaxaByClassification(classification, excludeTaxa, null, null);
350
    public List<UuidAndTitleCache<TaxonNode>> getTaxonNodeUuidAndTitleCacheOfAcceptedTaxaByClassification(Classification classification){
351
        return taxonDao.getTaxonNodeUuidAndTitleCacheOfAcceptedTaxaByClassification(classification, null, null);
352 352
    }
353 353

  
354 354
    @Override
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/IClassificationService.java
49 49
     * @return
50 50
     */
51 51
    public ITaxonTreeNode getTreeNodeByUuid(UUID uuid);
52
    
52

  
53 53
    /**
54
     * 
54
     *
55 55
     * Returns the root node of the the given classification (specified by its UUID)
56 56
     * @param classificationUuid the uuid of the classification
57 57
     * @return the root node of the classification
......
187 187
     * @param classification
188 188
     * @return
189 189
     */
190
    public List<UuidAndTitleCache<TaxonNode>> getTaxonNodeUuidAndTitleCacheOfAcceptedTaxaByClassification(Classification classification, List<UUID> excludeTaxa);
190
    public List<UuidAndTitleCache<TaxonNode>> getTaxonNodeUuidAndTitleCacheOfAcceptedTaxaByClassification(Classification classification);
191 191

  
192 192
    /**
193 193
     * @param taxon
......
269 269
     * @param excludeTaxa
270 270
     * @return
271 271
     */
272
    public List<UuidAndTitleCache<TaxonNode>> getTaxonNodeUuidAndTitleCacheOfAcceptedTaxaByClassification(UUID classificationUuid, List<UUID> excludeTaxa);
272
    public List<UuidAndTitleCache<TaxonNode>> getTaxonNodeUuidAndTitleCacheOfAcceptedTaxaByClassification(UUID classificationUuid);
273 273

  
274 274
    /**
275 275
     * @param classificationUuid
......
279 279
     * @return
280 280
     */
281 281
    List<UuidAndTitleCache<TaxonNode>> getTaxonNodeUuidAndTitleCacheOfAcceptedTaxaByClassification(
282
            UUID classificationUuid, List<UUID> excludeTaxa, Integer limit, String pattern);
282
            UUID classificationUuid, Integer limit, String pattern);
283 283

  
284 284
    /**
285 285
     * @param classification
......
289 289
     * @return
290 290
     */
291 291
    List<UuidAndTitleCache<TaxonNode>> getTaxonNodeUuidAndTitleCacheOfAcceptedTaxaByClassification(
292
            Classification classification, List<UUID> excludeTaxa, Integer limit, String pattern);
292
            Classification classification, Integer limit, String pattern);
293 293

  
294 294
    /**
295 295
     * @param taxonUuid

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)