-/**\r
-* Copyright (C) 2007 EDIT\r
-* European Distributed Institute of Taxonomy\r
-* http://www.e-taxonomy.eu\r
-*\r
-* The contents of this file are subject to the Mozilla Public License Version 1.1\r
-* See LICENSE.TXT at the top of this package for the full license terms.\r
-*/\r
-\r
-package eu.etaxonomy.cdm.io.common;\r
-\r
-import java.lang.reflect.Method;\r
-import java.util.HashMap;\r
-import java.util.List;\r
-import java.util.Map;\r
-import java.util.UUID;\r
-\r
-import org.apache.log4j.Logger;\r
-import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;\r
-import org.springframework.stereotype.Component;\r
-\r
-import eu.etaxonomy.cdm.database.DbSchemaValidation;\r
-import eu.etaxonomy.cdm.database.ICdmDataSource;\r
-import eu.etaxonomy.cdm.io.common.mapping.IInputTransformer;\r
-import eu.etaxonomy.cdm.model.agent.Person;\r
-import eu.etaxonomy.cdm.model.description.Feature;\r
-import eu.etaxonomy.cdm.model.name.NomenclaturalCode;\r
-import eu.etaxonomy.cdm.model.reference.Reference;\r
-\r
-/**\r
- * @author a.mueller\r
- * @created 20.06.2008\r
- * @param <STATE>\r
- */\r
-@Component\r
-public abstract class ImportConfiguratorBase<STATE extends ImportStateBase, SOURCE> extends IoConfiguratorBase implements IImportConfigurator{\r
- private static final Logger logger = Logger.getLogger(ImportConfiguratorBase.class);\r
-\r
- //check\r
- private CHECK check = CHECK.CHECK_AND_IMPORT;\r
-\r
- //editor\r
- static EDITOR editor = EDITOR.EDITOR_AS_ANNOTATION;\r
-\r
- /**\r
- * The transformer class to be used for Input\r
- */\r
- private IInputTransformer transformer;\r
-\r
-//\r
-// //TODO\r
-// private boolean deleteAll = false;\r
-\r
- //nullValues\r
- private boolean ignoreNull = false;\r
-\r
- //Nomenclatural Code\r
- private NomenclaturalCode nomenclaturalCode = null;\r
-\r
- private Map<Integer, Feature> featureMap = new HashMap<Integer, Feature>();\r
-\r
- /* The classification name for the first classification.\r
- * Needs only to be defined if the import does not handle the naming\r
- * itself (e.g. by using the taxon sec. reference title cache)\r
- */\r
- private String classificationName = "Classification - no name";\r
-\r
- private UUID classificationUuid = UUID.randomUUID();\r
- //uuid of concept reference\r
- private UUID secUuid = UUID.randomUUID();\r
-\r
- private Object sourceSecId = -1;\r
-\r
- private SOURCE source;\r
- protected Reference<?> sourceReference;\r
- private UUID sourceRefUuid;\r
- private ICdmDataSource destination;\r
- private Person commentator = Person.NewTitledInstance("automatic CDM importer");\r
-\r
- protected Class<ICdmIO>[] ioClassList;\r
-\r
- protected ICdmIO[] ioList;\r
-\r
- protected String[] ioBeans;\r
-\r
- /*user interaction*/\r
- private boolean askUserForHelp =false;\r
-\r
-\r
-/* *****************CONSTRUCTOR *****************************/\r
-\r
- public ImportConfiguratorBase(IInputTransformer transformer){\r
- super();\r
- setDbSchemaValidation(DbSchemaValidation.UPDATE);\r
- this.transformer = transformer;\r
-\r
- }\r
-\r
- abstract protected void makeIoClassList();\r
-\r
- /* (non-Javadoc)\r
- * @see eu.etaxonomy.cdm.io.common.IImportConfigurator#getTransformer()\r
- */\r
- @Override\r
- public IInputTransformer getTransformer() {\r
- return this.transformer;\r
- }\r
-\r
- /* (non-Javadoc)\r
- * @see eu.etaxonomy.cdm.io.common.IImportConfigurator#setTransformer(eu.etaxonomy.cdm.io.common.mapping.IInputTransformer)\r
- */\r
- @Override\r
- public void setTransformer(IInputTransformer transformer){\r
- this.transformer = transformer;\r
- }\r
-\r
-\r
-\r
-\r
- /**\r
- * @param source the source to set\r
- */\r
- public void setSource(SOURCE source) {\r
- this.source = source;\r
- }\r
-\r
-\r
- /**\r
- * @param source the source to get\r
- */\r
- @Override\r
- public SOURCE getSource() {\r
- return source;\r
- }\r
-\r
-\r
-\r
- /* (non-Javadoc)\r
- * @see eu.etaxonomy.cdm.io.common.IImportConfigurator#isValid()\r
- */\r
- @Override\r
- public boolean isValid(){\r
- boolean result = true;\r
- if (getSource() == null){\r
- logger.warn("Connection to source could not be established");\r
- result = false;\r
- }\r
-//Not valid any more as the importer may already have a destination\r
-// if (destination == null ){\r
-// logger.warn("Connection to Cdm could not be established");\r
-// result = false;\r
-// }\r
-\r
- return result;\r
- }\r
-\r
-\r
-\r
-/* ****************** GETTER/SETTER **************************/\r
-\r
-// /**\r
-// * @return the state\r
-// */\r
-// public STATE getState() {\r
-// return state;\r
-// }\r
-//\r
-// /**\r
-// * @param state the state to set\r
-// */\r
-// public void setState(STATE state) {\r
-// this.state = state;\r
-// }\r
-\r
- public void setIoClassList(ICdmIO[] ioList){\r
- this.ioList = ioList;\r
- }\r
-\r
- @Override\r
- public Class<ICdmIO>[] getIoClassList(){\r
- if (ioClassList == null){\r
- makeIoClassList();\r
- }\r
- return ioClassList;\r
- }\r
-\r
- /**\r
- * @param ioClassList\r
- */\r
- public void setIoClassList(Class<ICdmIO>[] ioClassList){\r
- this.ioClassList = ioClassList;\r
- }\r
-\r
- @Override\r
- public CHECK getCheck() {\r
- return this.check;\r
- }\r
-\r
- @Override\r
- public void setCheck(CHECK check) {\r
- this.check = check;\r
- }\r
-\r
-\r
- /**\r
- * @return the editor\r
- */\r
- @Override\r
- public EDITOR getEditor() {\r
- return editor;\r
- }\r
-\r
- /**\r
- * @param editor the editor to set\r
- */\r
- @Override\r
- public void setEditor(EDITOR editor) {\r
- ImportConfiguratorBase.editor = editor;\r
- }\r
-\r
- /**\r
- * If true, no errors occur if objects are not found that should exist. This may\r
- * be needed e.g. when only subsets of the data are imported.\r
- * Default value is <cod>false</code>.\r
- * @return the ignoreNull\r
- */\r
- @Override\r
- public boolean isIgnoreNull() {\r
- return ignoreNull;\r
- }\r
-\r
- /**\r
- * @param ignoreNull the ignoreNull to set\r
- */\r
- @Override\r
- public void setIgnoreNull(boolean ignoreNull) {\r
- this.ignoreNull = ignoreNull;\r
- }\r
-\r
- @Override\r
- public ICdmDataSource getDestination() {\r
- return destination;\r
- }\r
- @Override\r
- public void setDestination(ICdmDataSource destination) {\r
- this.destination = destination;\r
- }\r
-\r
- @Override\r
- public abstract Reference getSourceReference();\r
- @Override\r
- public void setSourceReference(Reference sourceReference) {\r
- this.sourceReference = sourceReference;\r
- }\r
- @Override\r
- public String getSourceReferenceTitle() {\r
- return getSourceReference().getTitleCache();\r
- }\r
- @Override\r
- public void setSourceReferenceTitle(String sourceReferenceTitle) {\r
- getSourceReference().setTitleCache(sourceReferenceTitle, true);\r
- }\r
-\r
- @Override\r
- public Person getCommentator() {\r
- return commentator;\r
- }\r
-\r
- @Override\r
- public void setCommentator(Person commentator) {\r
- this.commentator = commentator;\r
- }\r
-\r
- /**\r
- * @return the nomenclaturalCode\r
- */\r
- @Override\r
- public NomenclaturalCode getNomenclaturalCode() {\r
- return nomenclaturalCode;\r
- }\r
-\r
-\r
- /**\r
- * @param nomenclaturalCode the nomenclaturalCode to set\r
- */\r
- @Override\r
- public void setNomenclaturalCode(NomenclaturalCode nomenclaturalCode) {\r
- this.nomenclaturalCode = nomenclaturalCode;\r
- }\r
-\r
-\r
- /* (non-Javadoc)\r
- * @see eu.etaxonomy.cdm.io.common.IImportConfigurator#getTreeUuid()\r
- */\r
- @Override\r
- public UUID getClassificationUuid() {\r
- return classificationUuid;\r
- }\r
-\r
-\r
- @Override\r
- public void setClassificationUuid(UUID classificationUuid) {\r
- this.classificationUuid = classificationUuid;\r
- }\r
-\r
-\r
- @Override\r
- public UUID getSecUuid() {\r
- return secUuid;\r
- }\r
- @Override\r
- public void setSecUuid(UUID secUuid) {\r
- this.secUuid = secUuid;\r
- }\r
-\r
- /**\r
- * @return the sourceSecId\r
- */\r
- @Override\r
- public Object getSourceSecId() {\r
- return sourceSecId;\r
- }\r
-\r
- /**\r
- * @param sourceSecId the sourceSecId to set\r
- */\r
- public void setSourceSecId(Object sourceSecId) {\r
- this.sourceSecId = sourceSecId;\r
- }\r
-\r
-\r
- /**\r
- * @return the featureMap\r
- */\r
- public Map<Integer, Feature> getFeatureMap() {\r
- return featureMap;\r
- }\r
-\r
- /**\r
- * @param featureMap the featureMap to set\r
- */\r
- public void setFeatureMap(Map<Integer, Feature> featureMap) {\r
- this.featureMap = featureMap;\r
- }\r
-\r
-\r
- protected static Method getDefaultFunction(Class<?> clazz, String methodName){\r
- try {\r
- return clazz.getMethod(methodName, List.class) ;\r
- } catch (SecurityException e) {\r
- logger.error(e.getMessage());\r
- e.printStackTrace();\r
- } catch (NoSuchMethodException e) {\r
- logger.error(e.getMessage());\r
- e.printStackTrace();\r
- }\r
- return null;\r
- }\r
-\r
-\r
- /* (non-Javadoc)\r
- * @see eu.etaxonomy.cdm.io.common.IIoConfigurator#getDestinationNameString()\r
- */\r
- @Override\r
- public String getDestinationNameString() {\r
- if (this.getDestination() == null) {\r
- return null;\r
- } else {\r
- return this.getDestination().getName().toString();\r
- }\r
- }\r
-\r
- /* (non-Javadoc)\r
- * @see eu.etaxonomy.cdm.io.common.IImportConfigurator#getSourceNameString()\r
- */\r
- @Override\r
- public String getSourceNameString() {\r
- if (this.getSource() == null){\r
- return null;\r
- }else{\r
- return this.getSource().toString();\r
- }\r
- }\r
-\r
- /**\r
- * The classification name for the first classification.\r
- * Needs only to be defined if the import does not handle the naming\r
- * itself (e.g. by using the taxon sec. reference title cache)\r
- * @param classificationName the classificationName to set\r
- */\r
- public void setClassificationName(String classificationName) {\r
- this.classificationName = classificationName;\r
- }\r
-\r
- /**\r
- * @return the classificationName\r
- */\r
- public String getClassificationName() {\r
- return classificationName;\r
- }\r
-\r
-\r
- public UUID getSourceRefUuid() {\r
- return sourceRefUuid;\r
- }\r
-\r
-\r
-\r
- public void setSourceRefUuid(UUID sourceRefUuid) {\r
- this.sourceRefUuid = sourceRefUuid;\r
- }\r
-\r
- /* (non-Javadoc)\r
- * @see eu.etaxonomy.cdm.io.common.IImportConfigurator#isOmitTermLoading()\r
- */\r
- @Override\r
- public boolean isOmitTermLoading() {\r
- return false;\r
- }\r
-\r
- /* (non-Javadoc)\r
- * @see eu.etaxonomy.cdm.io.common.IImportConfigurator#isCreateNew()\r
- */\r
- @Override\r
- public boolean isCreateNew(){\r
- return false;\r
- }\r
-\r
- @Override\r
- public UsernamePasswordAuthenticationToken getAuthenticationToken(){\r
- return this.authenticationToken;\r
- }\r
-\r
- /*user interaction*/\r
- public boolean isInteractWithUser() {\r
- return askUserForHelp;\r
- }\r
-\r
- public void setInteractWithUser (boolean interaction){\r
- askUserForHelp=interaction;\r
- }\r
-\r
-}\r
+/**
+* Copyright (C) 2007 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+
+package eu.etaxonomy.cdm.io.common;
+
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
+import org.springframework.stereotype.Component;
+
+import eu.etaxonomy.cdm.database.DbSchemaValidation;
+import eu.etaxonomy.cdm.database.ICdmDataSource;
+import eu.etaxonomy.cdm.io.common.mapping.IInputTransformer;
+import eu.etaxonomy.cdm.model.agent.Person;
+import eu.etaxonomy.cdm.model.description.Feature;
+import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
+import eu.etaxonomy.cdm.model.reference.Reference;
+
+/**
+ * @author a.mueller
+ * @created 20.06.2008
+ * @param <STATE>
+ */
+@Component
+public abstract class ImportConfiguratorBase<STATE extends ImportStateBase, SOURCE> extends IoConfiguratorBase implements IImportConfigurator{
+
+
+ //check
+ private CHECK check = CHECK.CHECK_AND_IMPORT;
+
+ //editor
+ static EDITOR editor = EDITOR.EDITOR_AS_ANNOTATION;
+
+ /**
+ * The transformer class to be used for Input
+ */
+ private IInputTransformer transformer;
+
+//
+// //TODO
+// private boolean deleteAll = false;
+
+ //nullValues
+ private boolean ignoreNull = false;
+
+ //Nomenclatural Code
+ private NomenclaturalCode nomenclaturalCode = null;
+
+ private Map<Integer, Feature> featureMap = new HashMap<Integer, Feature>();
+
+ /* The classification name for the first classification.
+ * Needs only to be defined if the import does not handle the naming
+ * itself (e.g. by using the taxon sec. reference title cache)
+ */
+ private String classificationName = "Classification - no name";
+
+ private UUID classificationUuid = UUID.randomUUID();
+ //uuid of concept reference
+ private UUID secUuid = UUID.randomUUID();
+
+ private Object sourceSecId = -1;
+
+ private SOURCE source;
+ protected Reference sourceReference;
+ private UUID sourceRefUuid;
+ private ICdmDataSource destination;
+ private Person commentator = Person.NewTitledInstance("automatic CDM importer");
+
+ protected Class<ICdmImport>[] ioClassList;
+
+ protected ICdmIO[] ioList;
+
+ protected String[] ioBeans;
+
+ /*user interaction*/
+ private boolean askUserForHelp =false;
+
+
+/* *****************CONSTRUCTOR *****************************/
+
+ protected ImportConfiguratorBase(IInputTransformer transformer){
+ super();
+ setDbSchemaValidation(DbSchemaValidation.UPDATE);
+ this.transformer = transformer;
+
+ }
+
+ abstract protected void makeIoClassList();
+
+ @Override
+ public IInputTransformer getTransformer() {
+ return this.transformer;
+ }
+
+ @Override
+ public void setTransformer(IInputTransformer transformer){
+ this.transformer = transformer;
+ }
+
+ /**
+ * @param source the source to set
+ */
+ public void setSource(SOURCE source) {
+ this.source = source;
+ }
+
+ /**
+ * @param source the source to get
+ */
+ @Override
+ public SOURCE getSource() {
+ return source;
+ }
+
+ @Override
+ public boolean isValid(){
+ boolean result = true;
+ if (getSource() == null){
+ //logger.warn("Connection to source could not be established");
+ result = false;
+ }
+//Not valid any more as the importer may already have a destination
+// if (destination == null ){
+// logger.warn("Connection to Cdm could not be established");
+// result = false;
+// }
+
+ return result;
+ }
+
+
+
+/* ****************** GETTER/SETTER **************************/
+
+
+ public void setIoClassList(ICdmImport[] ioList){
+ this.ioList = ioList;
+ }
+
+ @Override
+ public Class<ICdmImport>[] getIoClassList(){
+ if (ioClassList == null){
+ makeIoClassList();
+ }
+ return ioClassList;
+ }
+
+ /**
+ * @param ioClassList
+ */
+ public void setIoClassList(Class<ICdmImport>[] ioClassList){
+ this.ioClassList = ioClassList;
+ }
+
+ @Override
+ public CHECK getCheck() {
+ return this.check;
+ }
+
+ @Override
+ public void setCheck(CHECK check) {
+ this.check = check;
+ }
+
+
+ /**
+ * @return the editor
+ */
+ @Override
+ public EDITOR getEditor() {
+ return editor;
+ }
+
+ /**
+ * @param editor the editor to set
+ */
+ @Override
+ public void setEditor(EDITOR editor) {
+ ImportConfiguratorBase.editor = editor;
+ }
+
+ /**
+ * If true, no errors occur if objects are not found that should exist. This may
+ * be needed e.g. when only subsets of the data are imported.
+ * Default value is <cod>false</code>.
+ * @return the ignoreNull
+ */
+ @Override
+ public boolean isIgnoreNull() {
+ return ignoreNull;
+ }
+
+ /**
+ * @param ignoreNull the ignoreNull to set
+ */
+ @Override
+ public void setIgnoreNull(boolean ignoreNull) {
+ this.ignoreNull = ignoreNull;
+ }
+
+ @Override
+ public ICdmDataSource getDestination() {
+ return destination;
+ }
+ @Override
+ public void setDestination(ICdmDataSource destination) {
+ this.destination = destination;
+ }
+
+ @Override
+ public abstract Reference getSourceReference();
+ @Override
+ public void setSourceReference(Reference sourceReference) {
+ this.sourceReference = sourceReference;
+ }
+ @Override
+ public String getSourceReferenceTitle() {
+ return getSourceReference().getTitleCache();
+ }
+ @Override
+ public void setSourceReferenceTitle(String sourceReferenceTitle) {
+ getSourceReference().setTitleCache(sourceReferenceTitle, true);
+ }
+
+ @Override
+ public Person getCommentator() {
+ return commentator;
+ }
+
+ @Override
+ public void setCommentator(Person commentator) {
+ this.commentator = commentator;
+ }
+
+ /**
+ * @return the nomenclaturalCode
+ */
+ @Override
+ public NomenclaturalCode getNomenclaturalCode() {
+ return nomenclaturalCode;
+ }
+
+
+ /**
+ * @param nomenclaturalCode the nomenclaturalCode to set
+ */
+ @Override
+ public void setNomenclaturalCode(NomenclaturalCode nomenclaturalCode) {
+ this.nomenclaturalCode = nomenclaturalCode;
+ }
+
+ @Override
+ public UUID getClassificationUuid() {
+ return classificationUuid;
+ }
+
+
+ @Override
+ public void setClassificationUuid(UUID classificationUuid) {
+ this.classificationUuid = classificationUuid;
+ }
+
+
+ @Override
+ public UUID getSecUuid() {
+ return secUuid;
+ }
+ @Override
+ public void setSecUuid(UUID secUuid) {
+ this.secUuid = secUuid;
+ }
+
+ /**
+ * @return the sourceSecId
+ */
+ @Override
+ public Object getSourceSecId() {
+ return sourceSecId;
+ }
+
+ /**
+ * @param sourceSecId the sourceSecId to set
+ */
+ public void setSourceSecId(Object sourceSecId) {
+ this.sourceSecId = sourceSecId;
+ }
+
+
+ /**
+ * @return the featureMap
+ */
+ public Map<Integer, Feature> getFeatureMap() {
+ return featureMap;
+ }
+
+ /**
+ * @param featureMap the featureMap to set
+ */
+ public void setFeatureMap(Map<Integer, Feature> featureMap) {
+ this.featureMap = featureMap;
+ }
+
+
+ protected static Method getDefaultFunction(Class<?> clazz, String methodName){
+ try {
+ return clazz.getMethod(methodName, List.class) ;
+ } catch (SecurityException e) {
+ e.printStackTrace();
+ } catch (NoSuchMethodException e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ @Override
+ public String getDestinationNameString() {
+ if (this.getDestination() == null) {
+ return null;
+ } else {
+ return this.getDestination().getName().toString();
+ }
+ }
+
+ @Override
+ public String getSourceNameString() {
+ if (this.getSource() == null){
+ return null;
+ }else{
+ return this.getSource().toString();
+ }
+ }
+
+ /**
+ * The classification name for the first classification.
+ * Needs only to be defined if the import does not handle the naming
+ * itself (e.g. by using the taxon sec. reference title cache)
+ * @param classificationName the classificationName to set
+ */
+ public void setClassificationName(String classificationName) {
+ this.classificationName = classificationName;
+ }
+
+ /**
+ * @return the classificationName
+ */
+ public String getClassificationName() {
+ return classificationName;
+ }
+
+
+ public UUID getSourceRefUuid() {
+ return sourceRefUuid;
+ }
+
+
+
+ public void setSourceRefUuid(UUID sourceRefUuid) {
+ this.sourceRefUuid = sourceRefUuid;
+ }
+
+ @Override
+ public boolean isOmitTermLoading() {
+ return false;
+ }
+
+ @Override
+ public boolean isCreateNew(){
+ return false;
+ }
+
+ @Override
+ public UsernamePasswordAuthenticationToken getAuthenticationToken(){
+ return this.authenticationToken;
+ }
+
+ /*user interaction*/
+ public boolean isInteractWithUser() {
+ return askUserForHelp;
+ }
+
+ public void setInteractWithUser (boolean interaction){
+ askUserForHelp=interaction;
+ }
+
+
+
+}