Project

General

Profile

Download (6.69 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

    
10
package eu.etaxonomy.cdm.io.specimen.abcd206.in;
11

    
12

    
13
import java.io.InputStream;
14
import java.net.URI;
15

    
16
import org.apache.log4j.Logger;
17

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

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

    
33
    private static final long serialVersionUID = -7204105522522645681L;
34

    
35
    @SuppressWarnings("unused")
36
    private static final Logger logger = Logger.getLogger(Abcd206ImportConfigurator.class);
37

    
38

    
39
    //TODO
40
    private static IInputTransformer defaultTransformer = null;
41

    
42
    private URI sourceUri;
43

    
44
    private boolean getSiblings = false;
45

    
46

    
47

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

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

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

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

    
82

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

    
100

    
101

    
102

    
103

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

    
109

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

    
127

    
128

    
129
    public URI getSourceUri(){
130
    	return this.sourceUri;
131
    }
132

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

    
138

    
139

    
140

    
141
    @Override
142
    public Reference getSourceReference() {
143
        //TODO
144
        return sourceReference;
145
    }
146

    
147
    /**
148
     * @return the getSiblings
149
     */
150
    public boolean isGetSiblings() {
151
        return getSiblings;
152
    }
153

    
154
    /**
155
     * @param getSiblings the getSiblings to set
156
     */
157
    public void setGetSiblings(boolean getSiblings) {
158
        this.getSiblings = getSiblings;
159
    }
160

    
161

    
162

    
163

    
164
@Override
165
public String toString(){
166

    
167
    StringBuffer result = new StringBuffer();
168
    //the preference value is build like this:
169
      //<section1>:true;<section2>:false....
170

    
171
      result.append("ignoreImportOfExistingSpecimen");
172
      result.append(":");
173
      result.append(this.isIgnoreImportOfExistingSpecimen());
174
      result.append(";");
175
      result.append("addIndividualsAssociationsSuchAsSpecimenAndObservations");
176
      result.append(":");
177
      result.append(this.isAddIndividualsAssociationsSuchAsSpecimenAndObservations());
178
      result.append(";");
179
      result.append("reuseExistingTaxaWhenPossible");
180
      result.append(":");
181
      result.append(this.isReuseExistingTaxaWhenPossible());
182
      result.append(";");
183
      result.append("ignoreAuthorship");
184
      result.append(":");
185
      result.append(this.isIgnoreAuthorship());
186
      result.append(";");
187
      result.append("addMediaAsMediaSpecimen");
188
      result.append(":");
189
      result.append(this.isAddMediaAsMediaSpecimen());
190
      result.append(";");
191
      result.append("reuseExistingMetaData");
192
      result.append(":");
193
      result.append(this.isReuseExistingMetaData());
194
      result.append(";");
195
      result.append("reuseExistingDescriptiveGroups");
196
      result.append(":");
197
      result.append(this.isReuseExistingDescriptiveGroups());
198
      result.append(";");
199
      result.append("allowReuseOtherClassifications");
200
      result.append(":");
201
      result.append(this.isAllowReuseOtherClassifications());
202
      result.append(";");
203
      result.append("deduplicateReferences");
204
      result.append(":");
205
      result.append(this.isDeduplicateReferences());
206
      result.append(";");
207
      result.append("deduplicateClassifications");
208
      result.append(":");
209
      result.append(this.isDeduplicateClassifications());
210
      result.append(";");
211
      result.append("moveNewTaxaToDefaultClassification");
212
      result.append(":");
213
      result.append(this.isMoveNewTaxaToDefaultClassification());
214
      result.append(";");
215

    
216
      result.append("mapUnitIdToCatalogNumber");
217
      result.append(":");
218
      result.append(this.isMapUnitIdToCatalogNumber());
219
      result.append(";");
220
      result.append("mapUnitIdToAccessionNumber");
221
      result.append(":");
222
      result.append(this.isMapUnitIdToAccessionNumber());
223
      result.append(";");
224
      result.append("mapUnitIdToBarcode");
225
      result.append(":");
226
      result.append(this.isMapUnitIdToBarcode());
227
      result.append(";");
228

    
229
      result.append("overwriteExistingSpecimens");
230
      result.append(":");
231
      result.append(this.isOverwriteExistingSpecimens());
232
      result.append(";");
233

    
234

    
235
    return result.toString();
236

    
237
}
238

    
239

    
240

    
241

    
242

    
243

    
244

    
245

    
246

    
247

    
248

    
249
}
(3-3/15)