Project

General

Profile

Download (7.23 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2009 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.common;
11

    
12
import java.util.UUID;
13

    
14
import eu.etaxonomy.cdm.database.DbSchemaValidation;
15
import eu.etaxonomy.cdm.database.ICdmDataSource;
16
import eu.etaxonomy.cdm.io.common.mapping.IInputTransformer;
17
import eu.etaxonomy.cdm.model.agent.Person;
18
import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
19
import eu.etaxonomy.cdm.model.reference.Reference;
20

    
21
/**
22
 * @author a.mueller
23
 * @created 29.01.2009
24
 * @version 1.0
25
 */
26
public interface IImportConfigurator extends IIoConfigurator {
27

    
28
    public static enum SOURCE_TYPE {
29
        URI,
30
        INPUTSTREAM
31
    }
32
    public static enum CHECK{
33
        CHECK_ONLY,
34
        IMPORT_WITHOUT_CHECK,
35
        CHECK_AND_IMPORT;
36

    
37
        public boolean isImport(){
38
            return this == IMPORT_WITHOUT_CHECK || this == CHECK_AND_IMPORT ;
39
        }
40
    }
41

    
42
    public static enum EDITOR{
43
        NO_EDITORS,  //leaves out createdBy and updatedBy information
44
        EDITOR_AS_ANNOTATION,//save createdBy and updatedBy in annotations
45
        EDITOR_AS_EDITOR, //save createdBy and updatedBy in createdBy and updatedBy
46
    }
47

    
48
    public static enum DO_REFERENCES{
49
        NONE,
50
        NOMENCLATURAL,
51
        CONCEPT_REFERENCES,
52
        ALL;
53

    
54
        public DO_REFERENCES invers(){
55
        	if (this == DO_REFERENCES.NONE){
56
        		return ALL;
57
        	}else if (this == ALL){
58
        		return NONE;
59
        	}else if (this == NOMENCLATURAL){  //don't change
60
        		return NOMENCLATURAL;
61
        	}else if (this == CONCEPT_REFERENCES){  //don't change
62
        		return CONCEPT_REFERENCES;
63
        	}else{
64
        		throw new RuntimeException("inverse for DO_REFERENCE type: " + this + " not yet handled");
65
        	}
66
        }
67
    }
68

    
69

    
70

    
71
    public boolean isValid();
72

    
73
    /**
74
     * Factory method. Creates a new state for the import type and adds this configuration to it.
75
     * @return
76
     */
77
    public <STATE extends ImportStateBase> STATE getNewState();
78

    
79
    /* ****************** GETTER/SETTER **************************/
80

    
81
    /**
82
     * @return the doReferences
83
     */
84
    public CHECK getCheck();
85

    
86
    /**
87
     * @param doReferences the doReferences to set
88
     */
89
    public void setCheck(CHECK check);
90

    
91
    /**
92
     * @return the editor
93
     */
94
    public EDITOR getEditor();
95

    
96
    /**
97
     * @param editor sets the way how editing (created, updated) information is handled
98
     */
99
    public void setEditor(EDITOR editor);
100

    
101
    /**
102
     * If true, no errors occurs if objects are not found that should exist. This may
103
     * be needed e.g. when only subsets of the data are imported.
104
     * Default value is <cod>false</code>.
105
     * @return the ignoreNull
106
     */
107
    public boolean isIgnoreNull();
108
    /**
109
     * @param ignoreNull the ignoreNull to set
110
     */
111
    public void setIgnoreNull(boolean ignoreNull);
112

    
113

    
114
    /**
115
     * The destination data source for the import
116
     * Don't use when using a spring data source
117
     * @return
118
     */
119
    public ICdmDataSource getDestination();
120

    
121
    public void setDestination(ICdmDataSource destination);
122

    
123
    @Override
124
    public DbSchemaValidation getDbSchemaValidation();
125

    
126
    @Override
127
    public void setDbSchemaValidation(
128
            DbSchemaValidation dbSchemaValidation);
129

    
130
    /**
131
     * The reference that represents the source. E.g. if the import source is a database
132
     * the returned reference should be of type eu.etaxonomy.cdm.model.reference.Database and
133
     * should represent the according database.
134
     * If the import comes from a file (e.g. XML) the returned value should best represent the
135
     * source of this file (e.g. if the source of an XML file is a certain database this database
136
     * should be mentioned as the source. Otherwise a eu.etaxonomy.cdm.model.reference.Generic
137
     * reference with the name of the XML file should be returned value
138
     * @return
139
     */
140
    public Reference getSourceReference();
141

    
142

    
143

    
144
    /**
145
     * Any object that represents the Source. The implementing class must cast this to
146
     * the correct class type
147
     * @return
148
     */
149
    public Object getSource();
150

    
151
    //public abstract void setSource(Object url);
152

    
153
    public void setSourceReference(Reference sourceReference);
154

    
155
    public String getSourceReferenceTitle();
156

    
157
    public void setSourceReferenceTitle(String sourceReferenceTitle);
158

    
159
    public Person getCommentator();
160

    
161
    public void setCommentator(Person commentator);
162

    
163
    public NomenclaturalCode getNomenclaturalCode();
164

    
165
    public void setNomenclaturalCode(NomenclaturalCode nomenclaturalCode);
166

    
167
    public Class<ICdmIO>[] getIoClassList();
168

    
169
//	public String[] getIoBeans();
170
//	public void setIoBeans(String[] ioBeans);
171

    
172
    /**
173
     * Returns a <code>CdmApplicationController</code> created by the values of this configuration.
174
     * If a controller was already created before the last created controller is returned.
175
     * @return
176
     */
177
//	public CdmApplicationController getCdmAppController();
178
//	public CdmApplicationController getCdmAppController(boolean createNew, boolean omitTermLoading);
179
//
180
    public Object getSourceSecId();
181

    
182

    
183

    
184
     /**
185
      * If this import implicitly represents a classification in the destination CDM database
186
      * one can define the classification's uuid here. The congrete import class must support this
187
      * functionality otherwise it will have no effect.
188
      * @return
189
      */
190
     public UUID getClassificationUuid();
191
    public void setClassificationUuid(UUID treeUuid);
192

    
193
    /**
194
      * If one wants do define the uuid of the accepted taxa (except for missaplied names) this can be
195
      * done here
196
      * @return
197
      */
198
     public UUID getSecUuid();
199
    public void setSecUuid(UUID secUuid);
200

    
201

    
202
    /**
203
     * Returns the transformer used during import
204
     * @return
205
     */
206
    public IInputTransformer getTransformer();
207

    
208
    /**
209
     * Sets the transformer used during import
210
     * @param transformer
211
     */
212
    public void setTransformer(IInputTransformer transformer);
213

    
214

    
215
    /**
216
     * Defines if term loading should take place if a new application controller
217
     * is created. Usually should return false as imports run into existing databases.
218
     * However, some imports like the current implementation of the JAXB import require
219
     * to create ALL data anew and import the data itself. Therefore they need to
220
     * allow omitting term loading.
221
     * This may be replaced by a more sophisticated solution in future.
222
     * @return
223
     */
224
    public boolean isOmitTermLoading();
225

    
226
    /**
227
     * Defines if the database will be created anew. Usually should return false as imports
228
     * run into existing databases.
229
     * However, some imports like the current implementation of the JAXB import require
230
     * to create ALL data anew. Therefore they need to allow to create all data anew.
231
     * This may be replaced by a more sophisticated solution in future.
232
     * @return
233
     */
234
    public boolean isCreateNew();
235

    
236
}
(31-31/59)