added FEATURE_STORE to be compliant with XML-IMPORT for cdmlib-app
[cdmlib.git] / cdmlib-io / src / main / java / eu / etaxonomy / cdm / io / common / IImportConfigurator.java
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 CHECK{
29 CHECK_ONLY,
30 IMPORT_WITHOUT_CHECK,
31 CHECK_AND_IMPORT,
32 }
33
34 public static enum EDITOR{
35 NO_EDITORS, //leaves out createdBy and updatedBy information
36 EDITOR_AS_ANNOTATION,//save createdBy and updatedBy in annotations
37 EDITOR_AS_EDITOR, //save createdBy and updatedBy in createdBy and updatedBy
38 }
39
40 public static enum DO_REFERENCES{
41 NONE,
42 NOMENCLATURAL,
43 CONCEPT_REFERENCES,
44 ALL;
45
46 public DO_REFERENCES invers(){
47 if (this == DO_REFERENCES.NONE){
48 return ALL;
49 }else if (this == ALL){
50 return NONE;
51 }else if (this == NOMENCLATURAL){ //don't change
52 return NOMENCLATURAL;
53 }else if (this == CONCEPT_REFERENCES){ //don't change
54 return CONCEPT_REFERENCES;
55 }else{
56 throw new RuntimeException("inverse for DO_REFERENCE type: " + this + " not yet handled");
57 }
58 }
59 }
60
61
62
63 public boolean isValid();
64
65 /**
66 * Factory method. Creates a new state for the import type and adds this configuration to it.
67 * @return
68 */
69 public <STATE extends ImportStateBase> STATE getNewState();
70
71 /* ****************** GETTER/SETTER **************************/
72
73 /**
74 * @return the doReferences
75 */
76 public CHECK getCheck();
77
78 /**
79 * @param doReferences the doReferences to set
80 */
81 public void setCheck(CHECK check);
82
83 /**
84 * @return the editor
85 */
86 public EDITOR getEditor();
87
88 /**
89 * @param editor sets the way how editing (created, updated) information is handled
90 */
91 public void setEditor(EDITOR editor);
92
93 /**
94 * If true, no errors occurs if objects are not found that should exist. This may
95 * be needed e.g. when only subsets of the data are imported.
96 * Default value is <cod>false</code>.
97 * @return the ignoreNull
98 */
99 public boolean isIgnoreNull();
100 /**
101 * @param ignoreNull the ignoreNull to set
102 */
103 public void setIgnoreNull(boolean ignoreNull);
104
105
106 /**
107 * The destination data source for the import
108 * Don't use when using a spring data source
109 * @return
110 */
111 public ICdmDataSource getDestination();
112
113 public void setDestination(ICdmDataSource destination);
114
115 public DbSchemaValidation getDbSchemaValidation();
116
117 public void setDbSchemaValidation(
118 DbSchemaValidation dbSchemaValidation);
119
120 /**
121 * The reference that represents the source. E.g. if the import source is a database
122 * the returned reference should be of type eu.etaxonomy.cdm.model.reference.Database and
123 * should represent the according database.
124 * If the import comes from a file (e.g. XML) the returned value should best represent the
125 * source of this file (e.g. if the source of an XML file is a certain database this database
126 * should be mentioned as the source. Otherwise a eu.etaxonomy.cdm.model.reference.Generic
127 * reference with the name of the XML file should be returned value
128 * @return
129 */
130 public Reference getSourceReference();
131
132
133 /**
134 * Any object that represents the Source. The implementing class must cast this to
135 * the correct class type
136 * @return
137 */
138 public Object getSource();
139
140 //public abstract void setSource(Object url);
141
142 public void setSourceReference(Reference sourceReference);
143
144 public String getSourceReferenceTitle();
145
146 public void setSourceReferenceTitle(String sourceReferenceTitle);
147
148 public Person getCommentator();
149
150 public void setCommentator(Person commentator);
151
152 public NomenclaturalCode getNomenclaturalCode();
153
154 public void setNomenclaturalCode(NomenclaturalCode nomenclaturalCode);
155
156 public Class<ICdmIO>[] getIoClassList();
157
158 // public String[] getIoBeans();
159 // public void setIoBeans(String[] ioBeans);
160
161 /**
162 * Returns a <code>CdmApplicationController</code> created by the values of this configuration.
163 * If a controller was already created before the last created controller is returned.
164 * @return
165 */
166 // public CdmApplicationController getCdmAppController();
167 // public CdmApplicationController getCdmAppController(boolean createNew, boolean omitTermLoading);
168 //
169 public Object getSourceSecId();
170
171
172
173 /**
174 * If this import implicitly represents a classification in the destination CDM database
175 * one can define the classification's uuid here. The congrete import class must support this
176 * functionality otherwise it will have no effect.
177 * @return
178 */
179 public UUID getClassificationUuid();
180 public void setClassificationUuid(UUID treeUuid);
181
182 /**
183 * If one wants do define the uuid of the accepted taxa (except for missaplied names) this can be
184 * done here
185 * @return
186 */
187 public UUID getSecUuid();
188 public void setSecUuid(UUID secUuid);
189
190
191 /**
192 * Returns the transformer used during import
193 * @return
194 */
195 public IInputTransformer getTransformer();
196
197 /**
198 * Sets the transformer used during import
199 * @param transformer
200 */
201 public void setTransformer(IInputTransformer transformer);
202
203
204 /**
205 * Defines if term loading should take place if a new application controller
206 * is created. Usually should return false as imports run into existing databases.
207 * However, some imports like the current implementation of the JAXB import require
208 * to create ALL data anew and import the data itself. Therefore they need to
209 * allow omitting term loading.
210 * This may be replaced by a more sophisticated solution in future.
211 * @return
212 */
213 public boolean isOmitTermLoading();
214
215 /**
216 * Defines if the database will be created anew. Usually should return false as imports
217 * run into existing databases.
218 * However, some imports like the current implementation of the JAXB import require
219 * to create ALL data anew. Therefore they need to allow to create all data anew.
220 * This may be replaced by a more sophisticated solution in future.
221 * @return
222 */
223 public boolean isCreateNew();
224
225 }