Project

General

Profile

Download (8.06 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
 * Copyright (C) 2007 EDIT
3
 * European Distributed Institute of Taxonomy
4
 * http://www.e-taxonomy.eu
5
 *
6
 * The contents of this file are subject to the Mozilla Public License Version 1.1
7
 * See LICENSE.TXT at the top of this package for the full license terms.
8
 */
9
package eu.etaxonomy.cdm.io.specimen.abcd206.in;
10

    
11
import java.io.InputStream;
12

    
13
import org.apache.logging.log4j.LogManager;import org.apache.logging.log4j.Logger;
14

    
15
import eu.etaxonomy.cdm.common.URI;
16
import eu.etaxonomy.cdm.common.UriUtils;
17
import eu.etaxonomy.cdm.database.ICdmDataSource;
18
import eu.etaxonomy.cdm.io.common.IMatchingImportConfigurator;
19
import eu.etaxonomy.cdm.io.common.mapping.IInputTransformer;
20
import eu.etaxonomy.cdm.io.specimen.SpecimenImportConfiguratorBase;
21
import eu.etaxonomy.cdm.model.reference.Reference;
22

    
23
/**
24
 * @author p.kelbert
25
 * @since 20.10.2008
26
 */
27
public class Abcd206ImportConfigurator
28
        extends SpecimenImportConfiguratorBase<Abcd206ImportConfigurator, Abcd206ImportState, InputStream>
29
        implements IMatchingImportConfigurator {
30

    
31
    private static final long serialVersionUID = -7204105522522645681L;
32

    
33
    @SuppressWarnings("unused")
34
    private static final Logger logger = LogManager.getLogger(Abcd206ImportConfigurator.class);
35

    
36

    
37
    //TODO
38
    private static IInputTransformer defaultTransformer = null;
39

    
40
    private URI sourceUri;
41

    
42
    private boolean getSiblings = false;
43

    
44
    private URI dnaSoure; // = URI.create("https://ww3.bgbm.org/biocase/pywrapper.cgi?dsa=DNA_Bank");
45

    
46
    @Override
47
    @SuppressWarnings("unchecked")
48
    protected void makeIoClassList(){
49
        System.out.println("makeIOClassList");
50
        ioClassList = new Class[]{
51
                Abcd206Import.class,
52
        };
53
    }
54

    
55
    public static Abcd206ImportConfigurator NewInstance(URI uri,ICdmDataSource destination){
56
        return new Abcd206ImportConfigurator(null, uri, destination, false);
57
    }
58

    
59
    /**
60
     * @param uri
61
     * @param object
62
     * @param b
63
     * @return
64
     */
65
    public static Abcd206ImportConfigurator NewInstance(URI uri, ICdmDataSource destination, boolean interact) {
66
        return new Abcd206ImportConfigurator(null, uri, destination, interact);
67
    }
68

    
69
    /**
70
     * @param uri
71
     * @param object
72
     * @param b
73
     * @return
74
     *//*
75
    public static Abcd206ImportConfigurator NewInstance(InputStream stream, ICdmDataSource destination, boolean interact) {
76
        return new Abcd206ImportConfigurator(stream, null, destination, interact);
77
    }
78
*/
79

    
80

    
81
    /**
82
     * @param berlinModelSource
83
     * @param sourceReference
84
     * @param destination
85
     */
86
    private Abcd206ImportConfigurator(InputStream stream, URI uri, ICdmDataSource destination, boolean interact) {
87
        super(defaultTransformer);
88
        if (stream != null){
89
        	setSource(stream);
90
        }else{
91
        	this.sourceUri = uri;
92
        }
93
        setDestination(destination);
94
        setSourceReferenceTitle("ABCD classic");
95
        setInteractWithUser(interact);
96
    }
97

    
98

    
99

    
100

    
101

    
102
    @Override
103
    public Abcd206ImportState getNewState() {
104
        return new Abcd206ImportState(this);
105
    }
106

    
107

    
108
    @Override
109
    public InputStream getSource(){
110
        if (super.getSource() != null){
111
        	return super.getSource();
112
        }else if (this.sourceUri != null){
113
        	try {
114
				InputStream is = UriUtils.getInputStream(sourceUri);
115
				setSource(is);
116
				return is;
117
			} catch (Exception e) {
118
				throw new RuntimeException(e);
119
			}
120
        }else{
121
        	return null;
122
        }
123
    }
124

    
125

    
126

    
127
    public URI getSourceUri(){
128
    	return this.sourceUri;
129
    }
130

    
131
    public void setSourceUri(URI sourceUri) {
132
        this.sourceUri = sourceUri;
133
        super.setSource(null);
134
    }
135

    
136

    
137

    
138

    
139
    public URI getDnaSoure() {
140
        return dnaSoure;
141
    }
142

    
143
    public void setDnaSoure(URI dnaSoure) {
144
        this.dnaSoure = dnaSoure;
145
    }
146

    
147
    @Override
148
    public Reference getSourceReference() {
149
        //TODO
150
        return sourceReference;
151
    }
152

    
153
    /**
154
     * @return the getSiblings
155
     */
156
    public boolean isGetSiblings() {
157
        return getSiblings;
158
    }
159

    
160
    /**
161
     * @param getSiblings the getSiblings to set
162
     */
163
    public void setGetSiblings(boolean getSiblings) {
164
        this.getSiblings = getSiblings;
165
    }
166

    
167

    
168

    
169

    
170
@Override
171
public String toString(){
172

    
173
    StringBuffer result = new StringBuffer();
174
    //the preference value is build like this:
175
      //<section1>:true;<section2>:false....
176

    
177
      result.append("ignoreImportOfExistingSpecimen");
178
      result.append(":");
179
      result.append(this.isIgnoreImportOfExistingSpecimen());
180
      result.append(";");
181
      result.append("addIndividualsAssociationsSuchAsSpecimenAndObservations");
182
      result.append(":");
183
      result.append(this.isAddIndividualsAssociationsSuchAsSpecimenAndObservations());
184
      result.append(";");
185
      result.append("reuseExistingTaxaWhenPossible");
186
      result.append(":");
187
      result.append(this.isReuseExistingTaxaWhenPossible());
188
      result.append(";");
189
      result.append("ignoreAuthorship");
190
      result.append(":");
191
      result.append(this.isIgnoreAuthorship());
192
      result.append(";");
193
      result.append("addMediaAsMediaSpecimen");
194
      result.append(":");
195
      result.append(this.isAddMediaAsMediaSpecimen());
196
      result.append(";");
197
      result.append("reuseExistingMetaData");
198
      result.append(":");
199
      result.append(this.isReuseExistingMetaData());
200
      result.append(";");
201
      result.append("reuseExistingDescriptiveGroups");
202
      result.append(":");
203
      result.append(this.isReuseExistingDescriptiveGroups());
204
      result.append(";");
205
      result.append("allowReuseOtherClassifications");
206
      result.append(":");
207
      result.append(this.isAllowReuseOtherClassifications());
208
      result.append(";");
209
      result.append("deduplicateReferences");
210
      result.append(":");
211
      result.append(this.isDeduplicateReferences());
212
      result.append(";");
213
      result.append("deduplicateClassifications");
214
      result.append(":");
215
      result.append(this.isDeduplicateClassifications());
216
      result.append(";");
217
      result.append("moveNewTaxaToDefaultClassification");
218
      result.append(":");
219
      result.append(this.isMoveNewTaxaToDefaultClassification());
220
      result.append(";");
221
      result.append("getSiblings");
222
      result.append(":");
223
      result.append(this.isGetSiblings());
224
      result.append(";");
225
      result.append("removeCountryFromLocalityText");
226
      result.append(":");
227
      result.append(this.isRemoveCountryFromLocalityText());
228
      result.append(";");
229

    
230
      result.append("mapUnitIdToCatalogNumber");
231
      result.append(":");
232
      result.append(this.isMapUnitIdToCatalogNumber());
233
      result.append(";");
234
      result.append("mapUnitIdToAccessionNumber");
235
      result.append(":");
236
      result.append(this.isMapUnitIdToAccessionNumber());
237
      result.append(";");
238
      result.append("mapUnitIdToBarcode");
239
      result.append(":");
240
      result.append(this.isMapUnitIdToBarcode());
241
      result.append(";");
242

    
243
      result.append("overwriteExistingSpecimens");
244
      result.append(":");
245
      result.append(this.isOverwriteExistingSpecimens());
246
      result.append(";");
247
      result.append("nomenclaturalCode");
248
      result.append(":");
249
      result.append(this.getNomenclaturalCode() != null ? this.getNomenclaturalCode().getKey():"");
250
      result.append(";");
251
      result.append("dnaSource");
252
      result.append(":");
253
      result.append(this.getDnaSoure() != null ? this.getDnaSoure().toString():"");
254
      result.append(";");
255
      result.append("classificationUUID");
256
      result.append(":");
257
      result.append(this.getClassificationUuid() != null ? this.getClassificationUuid().toString():"");
258
      result.append(";");
259
      result.append("classificationName");
260
      result.append(":");
261
      result.append(this.getClassificationName() != null ? this.getClassificationName():"");
262
      result.append(";");
263

    
264

    
265
    return result.toString();
266

    
267
}
268

    
269

    
270

    
271

    
272

    
273

    
274

    
275

    
276

    
277

    
278

    
279
}
(3-3/15)