Project

General

Profile

Revision 1a8f15ad

ID1a8f15ad715a30df38ebd8db04915ee97b029216
Parent ce2ea9e9
Child 4d017d52

Added by Katja Luther almost 3 years ago

first implementation for harmonization of import of specimen data

View differences:

cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/specimen/SpecimenDataHolder.java
1
// $Id$
2
/**
3
* Copyright (C) 2016 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;
11

  
12
import java.util.HashMap;
13
import java.util.List;
14

  
15
/**
16
 * @author k.luther
17
 * @date 18.07.2016
18
 *
19
 */
20
public class SpecimenDataHolder {
21

  
22
    private String nomenclatureCode;
23
    private List<HashMap<String, String>> atomisedIdentificationList;
24

  
25

  
26

  
27
    /**
28
     * @return the nomenclatureCode
29
     */
30
    public String getNomenclatureCode() {
31
        return nomenclatureCode;
32
    }
33

  
34

  
35

  
36
    /**
37
     * @param nomenclatureCode the nomenclatureCode to set
38
     */
39
    public void setNomenclatureCode(String nomenclatureCode) {
40
        this.nomenclatureCode = nomenclatureCode;
41
    }
42

  
43

  
44

  
45
    /**
46
     * @return the atomisedIdentificationList
47
     */
48
    public List<HashMap<String, String>> getAtomisedIdentificationList() {
49
        return atomisedIdentificationList;
50
    }
51

  
52

  
53

  
54
    /**
55
     * @param atomisedIdentificationList the atomisedIdentificationList to set
56
     */
57
    public void setAtomisedIdentificationList(List<HashMap<String, String>> atomisedIdentificationList) {
58
        this.atomisedIdentificationList = atomisedIdentificationList;
59
    }
60
}
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/specimen/SpecimenImportConfiguratorBase.java
1
// $Id$
2
/**
3
* Copyright (C) 2016 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;
11

  
12
import java.util.Map;
13

  
14
import eu.etaxonomy.cdm.ext.occurrence.OccurenceQuery;
15
import eu.etaxonomy.cdm.io.common.ImportConfiguratorBase;
16
import eu.etaxonomy.cdm.io.common.mapping.IInputTransformer;
17
import eu.etaxonomy.cdm.model.agent.Person;
18
import eu.etaxonomy.cdm.model.agent.Team;
19

  
20
/**
21
 * @author k.luther
22
 * @date 15.07.2016
23
 *
24
 */
25
public abstract class SpecimenImportConfiguratorBase<STATE extends SpecimenImportStateBase, InputStream>  extends ImportConfiguratorBase<STATE, InputStream> {
26

  
27
    private boolean ignoreImportOfExistingSpecimen;
28
    private boolean reuseExistingTaxaWhenPossible;
29
    private Map<String, Team> teams;
30
    private Map<String, Person> persons;
31
    private boolean ignoreAuthorship;
32
    private boolean removeCountryFromLocalityText;
33
    private OccurenceQuery query ;
34

  
35
    /**
36
     * @param transformer
37
     */
38
    public SpecimenImportConfiguratorBase(IInputTransformer transformer) {
39
        super(transformer);
40
        // TODO Auto-generated constructor stub
41
    }
42

  
43
    /**
44
     * @return
45
     */
46
    public boolean isReuseExistingTaxaWhenPossible() {
47

  
48
        return reuseExistingTaxaWhenPossible;
49
    }
50

  
51
    /**
52
     * @param titleCacheTeam
53
     */
54
    public void setTeams(Map<String, Team> titleCacheTeam) {
55
       this.teams  = titleCacheTeam;
56

  
57
    }
58

  
59
    /**
60
     * @param titleCachePerson
61
     */
62
    public void setPersons(Map<String, Person> titleCachePerson) {
63
        this.persons = titleCachePerson;
64
    }
65

  
66
    /**
67
     * @return
68
     */
69
    public boolean isIgnoreAuthorship() {
70
        return ignoreAuthorship;
71
    }
72

  
73
    /**
74
     * @return
75
     */
76
    public boolean isRemoveCountryFromLocalityText() {
77
        return removeCountryFromLocalityText;
78
    }
79

  
80
    public boolean isIgnoreImportOfExistingSpecimens(){
81
        return ignoreImportOfExistingSpecimen;
82
    }
83

  
84
    public OccurenceQuery getOccurenceQuery(){
85
        return query;
86
    }
87

  
88
    public void setOccurenceQuery(OccurenceQuery query){
89
        this.query = query;
90
    }
91

  
92
}
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/specimen/SpecimenImportStateBase.java
1
// $Id$
2
/**
3
* Copyright (C) 2016 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;
11

  
12
import org.springframework.transaction.TransactionStatus;
13

  
14
import eu.etaxonomy.cdm.api.application.ICdmApplicationConfiguration;
15
import eu.etaxonomy.cdm.io.common.CdmImportBase;
16
import eu.etaxonomy.cdm.io.common.ImportStateBase;
17
import eu.etaxonomy.cdm.io.specimen.abcd206.in.SpecimenImportReport;
18
import eu.etaxonomy.cdm.model.description.TaxonDescription;
19
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
20
import eu.etaxonomy.cdm.model.reference.Reference;
21
import eu.etaxonomy.cdm.model.taxon.Classification;
22

  
23
/**
24
 * @author k.luther
25
 * @param <CONFIG>
26
 * @date 15.07.2016
27
 *
28
 */
29
public abstract class SpecimenImportStateBase<CONFIG extends SpecimenImportConfiguratorBase, STATE extends SpecimenImportStateBase> extends ImportStateBase<CONFIG , CdmImportBase<CONFIG , STATE >>{
30

  
31

  
32
    private TransactionStatus tx;
33

  
34
    private ICdmApplicationConfiguration cdmRepository;
35
    private Classification classification = null;
36
    private Classification defaultClassification = null;
37
    private Reference ref = null;
38

  
39
    private TaxonDescription descriptionGroup = null;
40
    private DerivedUnit derivedUnitBase;
41

  
42
    private SpecimenImportReport report;
43

  
44
    private SpecimenDataHolder dataHolder;
45

  
46

  
47
    /**
48
     * @param config
49
     */
50
    protected SpecimenImportStateBase(CONFIG config) {
51
        super(config);
52
        // TODO Auto-generated constructor stub
53
    }
54

  
55
    /* -----Getter/Setter ---*/
56

  
57
    public TransactionStatus getTx() {
58
        return tx;
59
    }
60

  
61
    public void setTx(TransactionStatus tx) {
62
        this.tx = tx;
63
    }
64

  
65
    public ICdmApplicationConfiguration getCdmRepository() {
66
        return cdmRepository;
67
    }
68

  
69
    public void setCdmRepository(ICdmApplicationConfiguration cdmRepository) {
70
        this.cdmRepository = cdmRepository;
71
    }
72

  
73
    public Classification getClassification() {
74
        return classification;
75
    }
76

  
77
    public void setClassification(Classification classification) {
78
        this.classification = classification;
79
    }
80

  
81
    public Classification getDefaultClassification() {
82
        if(defaultClassification==null){
83
            final String defaultClassificationAbcd = "Default Classification ABCD";
84
            for (Classification classif : cdmRepository.getClassificationService().list(Classification.class, null, null, null, null)){
85
                if (classif.getTitleCache()!=null && classif.getTitleCache().equalsIgnoreCase(defaultClassificationAbcd)
86
                        && classif.getCitation()!=null && classif.getCitation().equals(getRef())) {
87
                    defaultClassification = classif;
88
                    break;
89
                }
90
            }
91
            if(defaultClassification==null){
92
                defaultClassification = Classification.NewInstance(defaultClassificationAbcd);
93
                cdmRepository.getClassificationService().save(defaultClassification);
94
            }
95
        }
96
        return defaultClassification;
97
    }
98

  
99
    public void setDefaultClassification(Classification defaultClassification) {
100
        this.defaultClassification = defaultClassification;
101
    }
102

  
103
    public Reference getRef() {
104
        return ref;
105
    }
106

  
107
    public void setRef(Reference ref) {
108
        this.ref = ref;
109
    }
110

  
111
    public TaxonDescription getDescriptionGroup() {
112
        return descriptionGroup;
113
    }
114

  
115
    public void setDescriptionGroup(TaxonDescription descriptionGroup) {
116
        this.descriptionGroup = descriptionGroup;
117
    }
118

  
119
    public DerivedUnit getDerivedUnitBase() {
120
        return derivedUnitBase;
121
    }
122

  
123
    public void setDerivedUnitBase(DerivedUnit derivedUnitBase) {
124
        this.derivedUnitBase = derivedUnitBase;
125
    }
126

  
127
    /**
128
     * @return the report
129
     */
130
    public SpecimenImportReport getReport() {
131
        return report;
132
    }
133

  
134
    /**
135
     * @param report the report to set
136
     */
137
    public void setReport(SpecimenImportReport report) {
138
        this.report = report;
139
    }
140

  
141
    /**
142
     *
143
     */
144
    public abstract void reset() ;
145

  
146
    /**
147
     * @return the dataHolder
148
     */
149
    public SpecimenDataHolder getDataHolder() {
150
        return dataHolder;
151
    }
152

  
153
    /**
154
     * @param dataHolder the dataHolder to set
155
     */
156
    public void setDataHolder(SpecimenDataHolder dataHolder) {
157
        this.dataHolder = dataHolder;
158
    }
159

  
160

  
161
}

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)