import eu.etaxonomy.cdm.io.common.MapWrapper;\r
import eu.etaxonomy.cdm.io.common.Source;\r
import eu.etaxonomy.cdm.model.common.Annotation;\r
+import eu.etaxonomy.cdm.model.common.DescriptionElementSource;\r
import eu.etaxonomy.cdm.model.common.Language;\r
import eu.etaxonomy.cdm.model.common.Marker;\r
import eu.etaxonomy.cdm.model.common.MarkerType;\r
citation = null;\r
}\r
\r
- \r
- textData.setCitation(citation);\r
- textData.setCitationMicroReference(details);\r
+ if (citation != null || CdmUtils.isNotEmpty(details)){\r
+ DescriptionElementSource originalSource = DescriptionElementSource.NewInstance();\r
+ originalSource.setCitation(citation);\r
+ originalSource.setCitationMicroReference(details);\r
+ textData.addSource(originalSource);\r
+ }\r
taxonDescription.addElement(textData);\r
//doubtfulFlag\r
if (doubtfulFlag){\r
import java.sql.ResultSet;\r
import java.sql.SQLException;\r
import java.util.ArrayList;\r
+import java.util.HashMap;\r
import java.util.HashSet;\r
import java.util.List;\r
+import java.util.Map;\r
import java.util.Set;\r
+import java.util.UUID;\r
\r
import org.apache.log4j.Logger;\r
import org.springframework.stereotype.Component;\r
\r
+import eu.etaxonomy.cdm.common.CdmUtils;\r
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;\r
import eu.etaxonomy.cdm.io.berlinModel.BerlinModelTransformer;\r
import eu.etaxonomy.cdm.io.common.ICdmIO;\r
import eu.etaxonomy.cdm.io.common.MapWrapper;\r
import eu.etaxonomy.cdm.io.common.Source;\r
+import eu.etaxonomy.cdm.model.common.DescriptionElementSource;\r
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;\r
import eu.etaxonomy.cdm.model.description.Distribution;\r
import eu.etaxonomy.cdm.model.description.PresenceAbsenceTermBase;\r
import eu.etaxonomy.cdm.model.description.TaxonDescription;\r
import eu.etaxonomy.cdm.model.location.NamedArea;\r
import eu.etaxonomy.cdm.model.location.TdwgArea;\r
+import eu.etaxonomy.cdm.model.name.NonViralName;\r
+import eu.etaxonomy.cdm.model.name.TaxonNameBase;\r
import eu.etaxonomy.cdm.model.reference.ReferenceBase;\r
import eu.etaxonomy.cdm.model.taxon.Taxon;\r
import eu.etaxonomy.cdm.model.taxon.TaxonBase;\r
import eu.etaxonomy.cdm.strategy.exceptions.UnknownCdmTypeException;\r
+import eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl;\r
\r
\r
/**\r
boolean success = true;\r
MapWrapper<TaxonBase> taxonMap = (MapWrapper<TaxonBase>)state.getStore(ICdmIO.TAXON_STORE);\r
MapWrapper<ReferenceBase> referenceMap = (MapWrapper<ReferenceBase>)state.getStore(ICdmIO.REFERENCE_STORE);\r
+ MapWrapper<Distribution> distributionMap = new MapWrapper<Distribution>(null);\r
BerlinModelImportConfigurator config = state.getConfig();\r
Source source = config.getSource();\r
\r
" ORDER BY PTaxon.RIdentifier";\r
ResultSet rs = source.getResultSet(strQuery) ;\r
\r
+ //map to store the mapping of duplicate berlin model occurrences to their real distributions\r
+ Map<Integer, Distribution> duplicateMap = new HashMap<Integer, Distribution>();\r
int oldTaxonId = -1;\r
TaxonDescription oldDescription = null;\r
int i = 0;\r
//status\r
PresenceAbsenceTermBase<?> status = null;\r
if (emStatusId != null){\r
- status = BerlinModelTransformer.occStatus2PresenceAbsence(emStatusId);\r
+ status = BerlinModelTransformer.occStatus2PresenceAbsence(emStatusId);\r
}\r
\r
//Create area list\r
}\r
}\r
}\r
- \r
+ ReferenceBase<?> sourceRef = state.getConfig().getSourceReference();\r
//create description(elements)\r
- TaxonDescription taxonDescription = getTaxonDescription(newTaxonId, oldTaxonId, oldDescription, taxonMap, occurrenceId);\r
+ TaxonDescription taxonDescription = getTaxonDescription(newTaxonId, oldTaxonId, oldDescription, taxonMap, occurrenceId, sourceRef);\r
for (NamedArea tdwgArea : tdwgAreas){\r
Distribution distribution = Distribution.NewInstance(tdwgArea, status);\r
+// distribution.setCitation(sourceRef);\r
if (taxonDescription != null) { \r
- if (checkIsNoDuplicate(taxonDescription , distribution)){\r
+ if (checkIsNoDuplicate(taxonDescription, distribution, duplicateMap , occurrenceId)){\r
+ distributionMap.put(occurrenceId, distribution);\r
taxonDescription.addElement(distribution); \r
countDistributions++; \r
if (taxonDescription != oldDescription){ \r
countDescriptions++; \r
} \r
}else{\r
- logger.debug("Distribution is duplicate");\r
- }\r
+ logger.debug("Distribution is duplicate"); }\r
} else { \r
logger.warn("Distribution " + tdwgArea.toString() + " ignored");\r
success = false;\r
}\r
\r
} catch (UnknownCdmTypeException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
+ logger.error("Unknown presenceAbsence status id: " + emStatusId); \r
+ e.printStackTrace();\r
success = false;\r
}\r
-\r
-// TODO\r
-// sources\r
-// references\r
+ \r
}\r
-\r
- logger.info("Distributions: " + countDistributions + ", Descriptions: " + countDescriptions );\r
+ makeOccurreceSource(distributionMap, state, duplicateMap);\r
+ \r
+ logger.info("Distributions: " + countDistributions + ", Descriptions: " + countDescriptions );\r
logger.warn("Unmatched occurrences: " + (i - countDescriptions));\r
logger.info("Taxa to save: " + taxonStore.size());\r
getTaxonService().saveTaxonAll(taxonStore); \r
\r
}\r
\r
+ /**\r
+ * @param distributionMap\r
+ * @param state\r
+ * @throws SQLException \r
+ */\r
+ private void makeOccurreceSource(MapWrapper<Distribution> distributionMap, BerlinModelImportState state, Map<Integer, Distribution> duplicateMap) \r
+ throws SQLException {\r
+ //FIXME multiple sources for one distribution, needs model change first\r
+ Map<String, ReferenceBase<?>> sourceIdMap = makeSourceIdMap(state); \r
+ Source source = state.getConfig().getSource();\r
+ String strQuery = " SELECT OccurrenceSourceId, OccurrenceFk, SourceNumber, OldName, OldNameFk, PreferredReferenceFlag " + \r
+ " FROM emOccurrenceSource " +\r
+ " ORDER BY SourceNumber DESC ";\r
+ \r
+ \r
+ ResultSet rs = source.getResultSet(strQuery) ;\r
+ while (rs.next()){\r
+ int occurrenceSourceId = rs.getInt("OccurrenceSourceId"); //TODO make originalSourceId\r
+ Integer occurrenceFk = (Integer)rs.getObject("OccurrenceFk");\r
+ String sourceNumber = rs.getString("SourceNumber");\r
+ String oldName = rs.getString("OldName");\r
+ int oldNameFk = rs.getInt("OldNameFk");\r
+ Distribution distribution = distributionMap.get(occurrenceFk);\r
+ if (distribution == null){\r
+ distribution = duplicateMap.get(occurrenceFk);\r
+ }\r
+ if (distribution != null){\r
+ ReferenceBase<?> ref = sourceIdMap.get(sourceNumber);\r
+ if (ref != null){\r
+ DescriptionElementSource originalSource = DescriptionElementSource.NewInstance();\r
+ originalSource.setCitation(ref);\r
+ TaxonNameBase<?,?> taxonName = getName(state, oldName, oldNameFk);\r
+ if (taxonName != null){\r
+ originalSource.setNameUsedInSource(taxonName);\r
+ }else if(CdmUtils.isNotEmpty(oldName)){\r
+ originalSource.setOriginalNameString(oldName);\r
+ }\r
+ distribution.addSource(originalSource);\r
+ }else{\r
+ logger.warn("reference for sourceId "+sourceNumber+" could not be found." );\r
+ }\r
+ }else{\r
+ logger.warn("distribution ("+occurrenceFk+") could not be found." );\r
+ }\r
+ \r
+ }\r
+ }\r
+\r
\r
- /**\r
- * Tests if a distribution with the same tdwgArea and the same status already exists in the description\r
- * Returns false, if a duplicate exists. True otherwise\r
+ private NonViralNameParserImpl nameParser = NonViralNameParserImpl.NewInstance();\r
+ /**\r
+ * @param state\r
+ * @param oldName\r
+ * @param oldNameFk\r
+ * @return\r
+ */\r
+ private TaxonNameBase<?, ?> getName(BerlinModelImportState state, String oldName, int oldNameFk) {\r
+ TaxonNameBase<?,?> taxonName = null;\r
+ MapWrapper<TaxonNameBase<?,?>> taxonNameMap = (MapWrapper<TaxonNameBase<?,?>>)state.getStore(ICdmIO.TAXONNAME_STORE);\r
+ taxonName = taxonNameMap.get(oldNameFk);\r
+ if (taxonName == null && oldName != null){\r
+ List<NonViralName> names = getNameService().getNamesByNameCache(oldName);\r
+ if (names.size() == 1){\r
+ return names.get(0);\r
+ }else {\r
+ if (names.size()> 2){\r
+ logger.info("Name has non unique NameCache: " + oldName + ".");\r
+ }\r
+ return null;\r
+ //taxonName = nameParser.parseSimpleName(oldName);\r
+ }\r
+ }\r
+ return taxonName;\r
+ }\r
+\r
+ /**\r
+ * @param state\r
+ * @return\r
+ * @throws SQLException \r
+ */\r
+ private Map<String, ReferenceBase<?>> makeSourceIdMap(\r
+ BerlinModelImportState state) throws SQLException {\r
+ MapWrapper<ReferenceBase<?>> referenceMap = (MapWrapper<ReferenceBase<?>>)state.getStore(ICdmIO.REFERENCE_STORE);\r
+ MapWrapper<ReferenceBase<?>> nomRefMap = (MapWrapper<ReferenceBase<?>>)state.getStore(ICdmIO.NOMREF_STORE);\r
+ \r
+ Map<String, ReferenceBase<?>> result = new HashMap<String, ReferenceBase<?>>();\r
+ Source source = state.getConfig().getSource();\r
+ String strQuery = " SELECT RefId, IdInSource " + \r
+ " FROM Reference " + \r
+ " WHERE (IdInSource IS NOT NULL) AND (IdInSource NOT LIKE '') ";\r
+ ResultSet rs = source.getResultSet(strQuery) ;\r
+ while (rs.next()){\r
+ int refId = rs.getInt("RefId");\r
+ String idInSource = rs.getString("IdInSource");\r
+ if (idInSource != null){\r
+ String[] singleSources = idInSource.split("\\|");\r
+ for (String singleSource : singleSources){\r
+ singleSource = singleSource.trim();\r
+ ReferenceBase<?> ref = getReference(refId, referenceMap, nomRefMap);\r
+ if (ref == null){\r
+ logger.warn("Reference ("+refId+")not found in refStore.");\r
+ }\r
+ result.put(singleSource, ref);\r
+ }\r
+ }\r
+ }\r
+ return result;\r
+ }\r
+\r
+ /**\r
+ * @param refId\r
+ * @param referenceMap\r
+ * @param nomRefMap\r
+ */\r
+ private ReferenceBase<?> getReference(int refId, MapWrapper<ReferenceBase<?>> referenceMap, MapWrapper<ReferenceBase<?>> nomRefMap) {\r
+ ReferenceBase<?> ref = referenceMap.get(refId);\r
+ if (ref == null){\r
+ ref = nomRefMap.get(refId);\r
+ }\r
+ return ref;\r
+ }\r
+\r
+ /**\r
+ * Tests if a distribution with the same tdwgArea and the same status already exists in the description. If so \r
+ * the duplicate will be registered in the duplicateMap.\r
* @param description\r
* @param tdwgArea\r
- * @return\r
+ * @return false, if dupplicate exists. True otherwise.\r
*/\r
- private boolean checkIsNoDuplicate(TaxonDescription description, Distribution distribution){\r
+ private boolean checkIsNoDuplicate(TaxonDescription description, Distribution distribution, Map<Integer, Distribution> duplicateMap, Integer bmDistributionId){\r
for (DescriptionElementBase descElBase : description.getElements()){\r
if (descElBase.isInstanceOf(Distribution.class)){\r
Distribution oldDistr = HibernateProxyHelper.deproxy(descElBase, Distribution.class);\r
if (oldArea != null && oldArea.equals(distribution.getArea())){\r
PresenceAbsenceTermBase<?> oldStatus = oldDistr.getStatus();\r
if (oldStatus != null && oldStatus.equals(distribution.getStatus())){\r
+ duplicateMap.put(bmDistributionId, oldDistr);\r
return false;\r
}\r
}\r
* @param taxonMap\r
* @return\r
*/\r
- private TaxonDescription getTaxonDescription(int newTaxonId, int oldTaxonId, TaxonDescription oldDescription, MapWrapper<TaxonBase> taxonMap, int occurrenceId){\r
+ private TaxonDescription getTaxonDescription(int newTaxonId, int oldTaxonId, TaxonDescription oldDescription, MapWrapper<TaxonBase> taxonMap, int occurrenceId, ReferenceBase<?> sourceSec){\r
TaxonDescription result = null;\r
if (oldDescription == null || newTaxonId != oldTaxonId){\r
TaxonBase taxonBase = taxonMap.get(newTaxonId);\r
} else {\r
logger.warn("TaxonBase for Occurrence " + occurrenceId + " is null.");\r
return null;\r
+ } \r
+ Set<TaxonDescription> descriptionSet= taxon.getDescriptions();\r
+ if (descriptionSet.size() > 0) {\r
+ result = descriptionSet.iterator().next(); \r
+ }else{\r
+ result = TaxonDescription.NewInstance();\r
+ result.setTitleCache(sourceSec.getTitleCache());\r
+ taxon.addDescription(result);\r
}\r
- \r
- result = TaxonDescription.NewInstance();\r
- taxon.addDescription(result);\r
- //TODO add source title as title (or reference at least)\r
- //result.setTitleCache("");\r
}else{\r
result = oldDescription;\r
}\r
import eu.etaxonomy.cdm.model.agent.Team;\r
import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;\r
import eu.etaxonomy.cdm.model.common.CdmBase;\r
+import eu.etaxonomy.cdm.model.common.DescriptionElementSource;\r
+import eu.etaxonomy.cdm.model.description.DescriptionElementBase;\r
import eu.etaxonomy.cdm.model.description.Feature;\r
import eu.etaxonomy.cdm.model.description.TaxonDescription;\r
import eu.etaxonomy.cdm.model.description.TextData;\r
for (FaunaEuropaeaReference storedReference : fauEuHelperTaxon.getReferences()) {\r
\r
TextData textData = TextData.NewInstance(Feature.CITATION());\r
+ \r
+ ReferenceBase citation = storedReference.getCdmReference();\r
+ String microCitation = storedReference.getPage();\r
+ DescriptionElementSource originalSource = DescriptionElementSource.NewInstance(null, null, citation, microCitation, null, null);\r
if (isSynonym){\r
Synonym syn = CdmBase.deproxy(taxonBase, Synonym.class);\r
- textData.setNameUsedInReference(syn.getName());\r
+ originalSource.setNameUsedInSource(syn.getName());\r
}\r
- textData.setCitation(storedReference.getCdmReference());\r
- textData.setCitationMicroReference(storedReference.getPage());\r
+ textData.addSource(originalSource);\r
taxonDescription.addElement(textData);\r
}\r
}\r
description.addElement(descriptionElement);\r
\r
//add reference\r
- descriptionElement.setCitation(state.getModsReference());\r
+ if (state.getModsReference() != null){\r
+ descriptionElement.addSource(null, null, state.getModsReference(), null, null, null);\r
+ }\r
}\r
\r
}\r
updated timestamp,
citationmicroreference varchar(255),
originalnamestring varchar(255),
- idinsource varchar(255),
+ nameUsedInSource_id integer,
+ idinsource varchar(255),
idnamespace varchar(255),
sourcedObj_type varchar(255),
sourcedObj_id integer not null,
updated timestamp,
citationmicroreference varchar(255),
originalnamestring varchar(255),
- idinsource varchar(255),
+ nameUsedInSource_id integer,
+ idinsource varchar(255),
idnamespace varchar(255),
createdby_id integer,
updatedby_id integer,
foreign key (citation_id)
references Reference;
+ alter table OriginalSourceBase
+ add constraint FK820A492C9803E12F
+ foreign key (nameUsedInSource_id)
+ references TaxonNameBase;
+
alter table OriginalSourceBase
add constraint FK229A496CBC5DA539
foreign key (updatedby_id)
UPDATED CDATA #IMPLIED
CITATIONMICROREFERENCE CDATA #IMPLIED
ORIGINALNAMESTRING CDATA #IMPLIED
+ NAMEUSEDINSOURCE_ID CDATA #IMPLIED
IDINSOURCE CDATA #IMPLIED
IDNAMESPACE CDATA #IMPLIED
SOURCEDOBJ_TYPE CDATA #IMPLIED
* be handled by SCHEMA_VALIDATION.UPDATE\r
* The last number represents the date of change.\r
*/\r
- private static final String dbSchemaVersion = "2.1.1.0.200909181723";\r
+ private static final String dbSchemaVersion = "2.1.2.0.200909211654";\r
\r
public enum MetaDataPropertyName{\r
DB_SCHEMA_VERSION\r
import javax.persistence.Entity;\r
import javax.persistence.FetchType;\r
import javax.persistence.JoinColumn;\r
+import javax.persistence.ManyToOne;\r
import javax.xml.bind.annotation.XmlElement;\r
import javax.xml.bind.annotation.XmlIDREF;\r
import javax.xml.bind.annotation.XmlSchemaType;\r
\r
import org.apache.log4j.Logger;\r
import org.hibernate.annotations.Any;\r
+import org.hibernate.annotations.Cascade;\r
+import org.hibernate.annotations.CascadeType;\r
import org.hibernate.envers.Audited;\r
import org.hibernate.envers.NotAudited;\r
\r
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;\r
+import eu.etaxonomy.cdm.model.name.TaxonNameBase;\r
import eu.etaxonomy.cdm.model.reference.ReferenceBase;\r
\r
/**\r
* @version 1.0\r
*/\r
@XmlType(name = "DescriptionElementSource", propOrder = {\r
- "sourcedObj"\r
+ "sourcedObj",\r
+ "nameUsedInSource",\r
})\r
@Entity\r
@Audited\r
return result;\r
}\r
\r
+ public static DescriptionElementSource NewInstance(String id, String idNamespace, ReferenceBase citation, String microReference, TaxonNameBase nameUsedInSource, String originalNameString){\r
+ DescriptionElementSource result = NewInstance(id, idNamespace, citation, microReference);\r
+ result.setNameUsedInSource(nameUsedInSource);\r
+ result.setOriginalNameString(originalNameString);\r
+ return result;\r
+ }\r
+ \r
@XmlElement(name = "SourcedObject")\r
@XmlIDREF\r
@XmlSchemaType(name = "IDREF")\r
@NotAudited\r
private DescriptionElementBase sourcedObj;\r
\r
-\r
+ @XmlElement(name = "nameUsedInSource")\r
+ @XmlIDREF\r
+ @XmlSchemaType(name = "IDREF")\r
+ @ManyToOne(fetch = FetchType.LAZY)\r
+ @Cascade({CascadeType.SAVE_UPDATE})\r
+ private TaxonNameBase nameUsedInSource;\r
+ \r
+ private DescriptionElementSource(){\r
+ \r
+ }\r
+ \r
+ \r
+// ************************** GETTER / SETTER ****************************************************/\r
+ \r
+ \r
/* (non-Javadoc)\r
* @see eu.etaxonomy.cdm.model.common.IOriginalSource#getSourcedObj()\r
*/\r
this.sourcedObj = sourcedObj;\r
}\r
\r
+ \r
+ /**\r
+ * @return the taxonNameUsedInSource\r
+ */\r
+ public TaxonNameBase getNameUsedInSource() {\r
+ return nameUsedInSource;\r
+ }\r
+\r
+ /**\r
+ * @param nameUsedInReference the nameUsedInReference to set\r
+ */\r
+ public void setNameUsedInSource(TaxonNameBase nameUsedInSource) {\r
+ this.nameUsedInSource = nameUsedInSource;\r
+ }\r
+\r
+ \r
+ \r
+ \r
}\r
import org.hibernate.search.annotations.IndexedEmbedded;
import eu.etaxonomy.cdm.jaxb.MultilanguageTextAdapter;
+import eu.etaxonomy.cdm.model.common.AnnotatableEntity;
import eu.etaxonomy.cdm.model.common.DescriptionElementSource;
import eu.etaxonomy.cdm.model.common.ISourceable;
import eu.etaxonomy.cdm.model.common.Language;
import eu.etaxonomy.cdm.model.media.Media;
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
+import eu.etaxonomy.cdm.model.reference.ReferenceBase;
import eu.etaxonomy.cdm.model.taxon.Taxon;
import eu.etaxonomy.cdm.strategy.merge.Merge;
import eu.etaxonomy.cdm.strategy.merge.MergeMode;
"modifyingText",
"media",
"inDescription",
- "nameUsedInReference",
"sources"
})
@Entity
@Audited
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
-public abstract class DescriptionElementBase extends ReferencedEntityBase implements ISourceable<DescriptionElementSource> {
+public abstract class DescriptionElementBase extends AnnotatableEntity implements ISourceable<DescriptionElementSource> {
private static final long serialVersionUID = 5000910777835755905L;
@SuppressWarnings("unused")
private static final Logger logger = Logger.getLogger(DescriptionElementBase.class);
private DescriptionBase inDescription;
//TODO can this be handled together with ReferencedEntityBase.originalNameString??
- @XmlElement(name = "nameUsedInReference")
- @XmlIDREF
- @XmlSchemaType(name = "IDREF")
- @ManyToOne(fetch = FetchType.LAZY)
- @Cascade({CascadeType.SAVE_UPDATE})
- private TaxonNameBase nameUsedInReference;
+// @XmlElement(name = "nameUsedInReference")
+// @XmlIDREF
+// @XmlSchemaType(name = "IDREF")
+// @ManyToOne(fetch = FetchType.LAZY)
+// @Cascade({CascadeType.SAVE_UPDATE})
+// private TaxonNameBase nameUsedInReference;
@XmlElementWrapper(name = "Sources")
@XmlElement(name = "OriginalSource")
source.setSourcedObj(this);
}
}
+
+ public void addSource(String id, String idNamespace, ReferenceBase citation, String microReference, TaxonNameBase nameUsedInSource, String originalNameString){
+ DescriptionElementSource newSource = DescriptionElementSource.NewInstance(id, idNamespace, citation, microReference, nameUsedInSource, originalNameString);
+ addSource(newSource);
+ }
/* (non-Javadoc)
* @see eu.etaxonomy.cdm.model.common.ISourceable#removeSource(eu.etaxonomy.cdm.model.common.IOriginalSource)
/**
- * @return the nameUsedInReference
+ * Gets the citation micro reference of the first source. This method is deprecated and exists only to be compliant with version 2.0.
+ * It will be removed in v2.3
+ * @return
*/
- public TaxonNameBase getNameUsedInReference() {
- return nameUsedInReference;
+ @Transient
+ @Deprecated
+ public String getCitationMicroReference(){
+ if (this.sources.size() < 1){
+ return null;
+ }else{
+ return this.sources.iterator().next().getCitationMicroReference();
+ }
+ }
+
+ /**
+ * Sets the citation micro reference of the first source. This method is deprecated and exists only to be compliant with version 2.0.
+ * It will be removed in v2.3
+ * If more than one source exists an IllegalStateException is thrown
+ **/
+ @Transient
+ @Deprecated
+ public void setCitationMicroReference(String citationMicroReference){
+ if (this.sources.size() < 1){
+ this.addSource(DescriptionElementSource.NewInstance(null, null, null, citationMicroReference));
+ }else if (this.sources.size() > 1){
+ throw new IllegalStateException("When adding a microcitation via the setCitationMicroReference method there must be only one source available");
+ }else{
+ this.sources.iterator().next().setCitationMicroReference(citationMicroReference);
+ }
}
/**
- * @param nameUsedInReference the nameUsedInReference to set
+ * Gets the citation of the first source. This method is deprecated and exists only to be compliant with version 2.0.
+ * It will be removed in v2.3
+ */
+ @Transient
+ @Deprecated
+ public ReferenceBase getCitation(){
+ if (this.sources.size() < 1){
+ return null;
+ }else{
+ return this.sources.iterator().next().getCitation();
+ }
+ }
+
+ /**
+ * Sets the citation of the first source. This method is deprecated and exists only to be compliant with version 2.0.
+ * It will be removed in v2.3
+ * If more than one source exists an IllegalStateException is thrown
+ **/
+ @Deprecated
+ public void setCitation(ReferenceBase citation) {
+ if (this.sources.size() < 1){
+ this.addSource(DescriptionElementSource.NewInstance(null, null, citation, null));
+ }else if (this.sources.size() > 1){
+ throw new IllegalStateException("When adding a citation via the setCitation method there must be only one source available");
+ }else{
+ this.sources.iterator().next().setCitation(citation);
+ }
+ }
+
+
+ /**
+ * Gets the original name string of the first source. This method is deprecated and exists only to be compliant with version 2.0.
+ * It will be removed in v2.3
+ * @return
*/
- public void setNameUsedInReference(TaxonNameBase nameUsedInReference) {
- this.nameUsedInReference = nameUsedInReference;
+ @Transient
+ @Deprecated
+ public String getOriginalNameString(){
+ if (this.sources.size() < 1){
+ return null;
+ }else{
+ return this.sources.iterator().next().getOriginalNameString();
+ }
+ }
+
+ /**
+ * Sets the original name string of the first source. This method is deprecated and exists only to be compliant with version 2.0.
+ * It will be removed in v2.3
+ * If more than one source exists an IllegalStateException is thrown
+ **/
+ @Transient
+ @Deprecated
+ public void setOriginalNameString(String originalNameString){
+ if (this.sources.size() < 1){
+ this.addSource(DescriptionElementSource.NewInstance(null, null, null, null, null, originalNameString));
+ }else if (this.sources.size() > 1){
+ throw new IllegalStateException("When adding a microcitation via the setCitationMicroReference method there must be only one source available");
+ }else{
+ this.sources.iterator().next().setOriginalNameString(originalNameString);
+ }
}
+
+ /**
+ * Gets the name used in source of the first source. This method is deprecated and exists only to be compliant with version 2.0.
+ * It will be removed in v2.3
+ */
+ @Transient
+ @Deprecated
+ public TaxonNameBase getNameUsedInReference(){
+ if (this.sources.size() < 1){
+ return null;
+ }else{
+ return this.sources.iterator().next().getNameUsedInSource();
+ }
+ }
+
+ /**
+ * Sets the name used in reference of the first source. This method is deprecated and exists only to be compliant with version 2.0.
+ * It will be removed in v2.3
+ * If more than one source exists an IllegalStateException is thrown
+ **/
+ @Deprecated
+ public void setNameUsedInReference(TaxonNameBase nameUsedInSource) {
+ if (this.sources.size() < 1){
+ this.addSource(DescriptionElementSource.NewInstance(null, null, null, null, nameUsedInSource, null));
+ }else if (this.sources.size() > 1){
+ throw new IllegalStateException("When adding a citation via the setCitation method there must be only one source available");
+ }else{
+ this.sources.iterator().next().setNameUsedInSource(nameUsedInSource);
+ }
+ }
}
\ No newline at end of file
updated timestamp,
citationmicroreference varchar(255),
originalnamestring varchar(255),
- idinsource varchar(255),
+ nameUsedInSource_id integer,
+ idinsource varchar(255),
idnamespace varchar(255),
sourcedObj_type varchar(255),
sourcedObj_id integer not null,
updated timestamp,
citationmicroreference varchar(255),
originalnamestring varchar(255),
- idinsource varchar(255),
+ nameUsedInSource_id integer,
+ idinsource varchar(255),
idnamespace varchar(255),
createdby_id integer,
updatedby_id integer,
foreign key (citation_id)
references Reference;
+ alter table OriginalSourceBase
+ add constraint FK820A492C9803E12F
+ foreign key (nameUsedInSource_id)
+ references TaxonNameBase;
+
alter table OriginalSourceBase
add constraint FK229A496CBC5DA539
foreign key (updatedby_id)
updated timestamp,
citationmicroreference varchar(255),
originalnamestring varchar(255),
- idinsource varchar(255),
+ nameUsedInSource_id integer,
+ idinsource varchar(255),
idnamespace varchar(255),
sourcedObj_type varchar(255),
sourcedObj_id integer not null,
updated timestamp,
citationmicroreference varchar(255),
originalnamestring varchar(255),
- idinsource varchar(255),
+ nameUsedInSource_id integer,
+ idinsource varchar(255),
idnamespace varchar(255),
createdby_id integer,
updatedby_id integer,
foreign key (citation_id)
references Reference;
+ alter table OriginalSourceBase
+ add constraint FK820A492C9803E12F
+ foreign key (nameUsedInSource_id)
+ references TaxonNameBase;
+
alter table OriginalSourceBase
add constraint FK229A496CBC5DA539
foreign key (updatedby_id)