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