package eu.etaxonomy.cdm.io.specimen.abcd206.in;\r
\r
\r
+import java.io.InputStream;\r
import java.net.URI;\r
import java.util.HashMap;\r
import java.util.Map;\r
\r
import org.apache.log4j.Logger;\r
\r
+import eu.etaxonomy.cdm.common.UriUtils;\r
import eu.etaxonomy.cdm.database.ICdmDataSource;\r
import eu.etaxonomy.cdm.io.common.IImportConfigurator;\r
import eu.etaxonomy.cdm.io.common.IMatchingImportConfigurator;\r
import eu.etaxonomy.cdm.io.common.ImportConfiguratorBase;\r
import eu.etaxonomy.cdm.io.common.mapping.IInputTransformer;\r
+import eu.etaxonomy.cdm.io.specimen.SpecimenUserInteraction;\r
import eu.etaxonomy.cdm.model.agent.Person;\r
import eu.etaxonomy.cdm.model.agent.Team;\r
import eu.etaxonomy.cdm.model.reference.Reference;\r
-import eu.etaxonomy.cdm.model.reference.ReferenceFactory;\r
\r
/**\r
* @author p.kelbert\r
* @created 20.10.2008\r
* @version 1.0\r
*/\r
-public class Abcd206ImportConfigurator extends ImportConfiguratorBase<Abcd206ImportState, URI> implements IImportConfigurator, IMatchingImportConfigurator {\r
+public class Abcd206ImportConfigurator extends ImportConfiguratorBase<Abcd206ImportState, InputStream> implements IImportConfigurator, IMatchingImportConfigurator {\r
private static final Logger logger = Logger.getLogger(Abcd206ImportConfigurator.class);\r
- private boolean doParsing = false;\r
- private boolean reuseMetadata = false;\r
- private boolean reuseTaxon = true;\r
+\r
+ private static String sourceReferenceTitle = null;\r
+ private boolean parseNameAutomatically = false;\r
+ private boolean reuseExistingMetadata = true;\r
private String taxonReference = null;\r
- private boolean doCreateIndividualsAssociations = true;\r
- private boolean doReuseExistingDescription = false;\r
- private boolean doMatchTaxa = true;\r
+ private boolean addIndividualsAssociationsSuchAsSpecimenAndObservations = true;\r
+ private boolean reuseExistingDescriptiveGroups = false;\r
+ private boolean reuseExistingTaxaWhenPossible = true;\r
private final Map<UUID, UUID> taxonToDescriptionMap = new HashMap<UUID, UUID>();\r
private Map<String, Team> titleCacheTeam;\r
private Map<String, Person> titleCachePerson;\r
private String defaultAuthor="";\r
+ private boolean allowReuseOtherClassifications =true;\r
+\r
+\r
+ private final SpecimenUserInteraction specimenUserInteraction = new SpecimenUserInteraction();\r
+\r
+ private Map<String,UUID> namedAreaDecisions = new HashMap<String,UUID>();\r
\r
//TODO\r
private static IInputTransformer defaultTransformer = null;\r
\r
+ private URI sourceUri;\r
+\r
@Override\r
@SuppressWarnings("unchecked")\r
protected void makeIoClassList(){\r
};\r
};\r
\r
- public static Abcd206ImportConfigurator NewInstance(URI uri,\r
- ICdmDataSource destination){\r
- return new Abcd206ImportConfigurator(uri, destination);\r
+ public static Abcd206ImportConfigurator NewInstance(URI uri,ICdmDataSource destination){\r
+ return new Abcd206ImportConfigurator(null, uri, destination, false);\r
+ }\r
+\r
+ /**\r
+ * @param uri\r
+ * @param object\r
+ * @param b\r
+ * @return\r
+ */\r
+ public static Abcd206ImportConfigurator NewInstance(URI uri, ICdmDataSource destination, boolean interact) {\r
+ return new Abcd206ImportConfigurator(null, uri, destination, interact);\r
+ }\r
+\r
+ /**\r
+ * @param uri\r
+ * @param object\r
+ * @param b\r
+ * @return\r
+ */\r
+ public static Abcd206ImportConfigurator NewInstance(InputStream stream, ICdmDataSource destination, boolean interact) {\r
+ return new Abcd206ImportConfigurator(stream, null, destination, interact);\r
}\r
\r
\r
+\r
/**\r
* @param berlinModelSource\r
* @param sourceReference\r
* @param destination\r
*/\r
- private Abcd206ImportConfigurator(URI uri, ICdmDataSource destination) {\r
+ private Abcd206ImportConfigurator(InputStream stream, URI uri, ICdmDataSource destination, boolean interact) {\r
super(defaultTransformer);\r
- setSource(uri);\r
+ if (stream != null){\r
+ setSource(stream);\r
+ }else{\r
+ this.sourceUri = uri;\r
+ }\r
setDestination(destination);\r
+ setSourceReferenceTitle("ABCD classic");\r
+ setInteractWithUser(interact);\r
}\r
\r
\r
\r
\r
- // /* (non-Javadoc)\r
- // * @see eu.etaxonomy.cdm.io.common.ImportConfiguratorBase#getSource()\r
- // */\r
- // public String getSource() {\r
- // return (String)super.getSource();\r
- // }\r
\r
/* (non-Javadoc)\r
* @see eu.etaxonomy.cdm.io.common.IImportConfigurator#getNewState()\r
\r
\r
@Override\r
- public URI getSource(){\r
- return super.getSource();\r
+ public InputStream getSource(){\r
+ if (super.getSource() != null){\r
+ return super.getSource();\r
+ }else if (this.sourceUri != null){\r
+ try {\r
+ InputStream is = UriUtils.getInputStream(sourceUri);\r
+ setSource(is);\r
+ return is;\r
+ } catch (Exception e) {\r
+ throw new RuntimeException(e);\r
+ }\r
+ }else{\r
+ return null;\r
+ }\r
}\r
\r
/**\r
* @param file\r
*/\r
@Override\r
- public void setSource(URI uri) {\r
- super.setSource(uri);\r
+ public void setSource(InputStream is) {\r
+ this.sourceUri = null;\r
+ super.setSource(is);\r
+ }\r
+\r
+ public URI getSourceUri(){\r
+ return this.sourceUri;\r
}\r
\r
+ /**\r
+ * @param file\r
+ */\r
+ public void setSourceUri(URI sourceUri) {\r
+ this.sourceUri = sourceUri;\r
+ super.setSource(null);\r
+ }\r
\r
\r
+ @Override\r
+ public String getSourceReferenceTitle(){\r
+ return this.sourceReferenceTitle;\r
+ }\r
+\r
+ @Override\r
+ public void setSourceReferenceTitle(String name){\r
+ this.sourceReferenceTitle=name;\r
+ }\r
+\r
/* (non-Javadoc)\r
* @see eu.etaxonomy.cdm.io.common.ImportConfiguratorBase#getSourceReference()\r
*/\r
@Override\r
public Reference getSourceReference() {\r
//TODO\r
- if (this.sourceReference == null){\r
- logger.warn("getSource Reference not yet fully implemented");\r
- ReferenceFactory refFactory = ReferenceFactory.newInstance();\r
- sourceReference = refFactory.newDatabase();\r
- sourceReference.setTitleCache("ABCD specimen import", true);\r
- }\r
return sourceReference;\r
}\r
\r
return sourceReference;\r
}\r
\r
- public void setDoAutomaticParsing(boolean doParsing){\r
- this.doParsing=doParsing;\r
+ public void setParseNameAutomatically(boolean doParsing){\r
+ this.parseNameAutomatically=doParsing;\r
}\r
\r
- public boolean isDoAutomaticParsing(){\r
- return this.doParsing;\r
+ public boolean isParseNameAutomatically(){\r
+ return this.parseNameAutomatically;\r
}\r
\r
- public void setReUseExistingMetadata(boolean reuseMetadata){\r
- this.reuseMetadata = reuseMetadata;\r
+ public void setReuseExistingMetadata(boolean reuseMetadata){\r
+ this.reuseExistingMetadata = reuseMetadata;\r
}\r
\r
public boolean isReUseExistingMetadata(){\r
- return this.reuseMetadata;\r
+ return this.reuseExistingMetadata;\r
}\r
\r
- public void setReUseTaxon(boolean reuseTaxon){\r
- this.reuseTaxon = reuseTaxon;\r
- }\r
-\r
- /**\r
- * if {@link #doMatchTaxa} is set false or no matching taxon is found new\r
- * taxa will be created. If this flag is set <code>true</code> the newly created taxa\r
- * will be reused if possible. Setting this flag to <code>false</code> may lead to\r
- * multiple identical taxa.\r
- *\r
- * @return\r
- */\r
- public boolean isDoReUseTaxon(){\r
- return this.reuseTaxon;\r
- }\r
-\r
- public void setDoCreateIndividualsAssociations(\r
+ public void setAddIndividualsAssociationsSuchAsSpecimenAndObservations(\r
boolean doCreateIndividualsAssociations) {\r
- this.doCreateIndividualsAssociations = doCreateIndividualsAssociations;\r
+ this.addIndividualsAssociationsSuchAsSpecimenAndObservations = doCreateIndividualsAssociations;\r
}\r
\r
/**\r
*\r
* @return\r
*/\r
- public boolean isDoCreateIndividualsAssociations() {\r
- return doCreateIndividualsAssociations;\r
+ public boolean isAddIndividualsAssociationsSuchAsSpecimenAndObservations() {\r
+ return addIndividualsAssociationsSuchAsSpecimenAndObservations;\r
}\r
\r
/**\r
* @param doReuseExistingDescription the doReuseExistingDescription to set\r
+ * NOT USED YET\r
*/\r
- public void setDoReuseExistingDescription(boolean doReuseExistingDescription) {\r
- this.doReuseExistingDescription = doReuseExistingDescription;\r
+ public void reuseExistingDescriptiveGroups(boolean doReuseExistingDescription) {\r
+ this.reuseExistingDescriptiveGroups = doReuseExistingDescription;\r
}\r
\r
/**\r
* @return the doReuseExistingDescription\r
*/\r
- public boolean isDoMatchToExistingDescription() {\r
- return doReuseExistingDescription;\r
+ public boolean isReuseExistingDescriptiveGroups() {\r
+ return reuseExistingDescriptiveGroups;\r
}\r
\r
/* (non-Javadoc)\r
* @see eu.etaxonomy.cdm.io.common.IMatchingImportConfigurator#isDoMatchTaxa()\r
*/\r
@Override\r
- public boolean isDoMatchTaxa() {\r
- return doMatchTaxa;\r
+ public boolean isReuseExistingTaxaWhenPossible() {\r
+ return reuseExistingTaxaWhenPossible;\r
}\r
\r
/* (non-Javadoc)\r
* @see eu.etaxonomy.cdm.io.common.IMatchingImportConfigurator#setDoMatchTaxa(boolean)\r
*/\r
@Override\r
- public void setDoMatchTaxa(boolean doMatchTaxa) {\r
- this.doMatchTaxa = doMatchTaxa;\r
+ public void setReuseExistingTaxaWhenPossible(boolean doMatchTaxa) {\r
+ this.reuseExistingTaxaWhenPossible = doMatchTaxa;\r
}\r
\r
/**\r
return defaultAuthor;\r
}\r
\r
+ public Map<String,UUID> getNamedAreaDecisions() {\r
+ return namedAreaDecisions;\r
+ }\r
+\r
+ public void setNamedAreaDecisions(Map<String,UUID> namedAreaDecisions) {\r
+ this.namedAreaDecisions = namedAreaDecisions;\r
+ }\r
+\r
+ public void putNamedAreaDecision(String areaStr,UUID uuid){\r
+ this.namedAreaDecisions.put(areaStr,uuid);\r
+ }\r
+\r
+ public UUID getNamedAreaDecision(String areaStr){\r
+ return namedAreaDecisions.get(areaStr);\r
+ }\r
+\r
+\r
+ /**\r
+ * @return the allowReuseOtherClassifications\r
+ */\r
+ public boolean isAllowReuseOtherClassifications() {\r
+ return allowReuseOtherClassifications;\r
+ }\r
+\r
+ /**\r
+ * @param allowReuseOtherClassifications the allowReuseOtherClassifications to set\r
+ */\r
+ public void setAllowReuseOtherClassifications(boolean allowReuseOtherClassifications) {\r
+ this.allowReuseOtherClassifications = allowReuseOtherClassifications;\r
+ }\r
+\r
+ /**\r
+ * @return the specimenUserInteraction\r
+ */\r
+ public SpecimenUserInteraction getSpecimenUserInteraction() {\r
+ return specimenUserInteraction;\r
+ }\r
+\r
+\r
\r
\r
}\r