-// $Id$
-/**
- * Copyright (C) 2009 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.ext.geo;
-
-import java.awt.Color;
-import java.io.IOException;
-import java.io.Reader;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.EnumSet;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.UUID;
-
-import javax.persistence.EntityNotFoundException;
-
-import org.apache.log4j.Logger;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-
-import eu.etaxonomy.cdm.api.service.IDescriptionService;
-import eu.etaxonomy.cdm.api.service.dto.DistributionInfoDTO;
-import eu.etaxonomy.cdm.api.service.dto.DistributionInfoDTO.InfoPart;
-import eu.etaxonomy.cdm.api.utility.DescriptionUtility;
-import eu.etaxonomy.cdm.model.common.DefinedTermBase;
-import eu.etaxonomy.cdm.model.common.Language;
-import eu.etaxonomy.cdm.model.common.MarkerType;
-import eu.etaxonomy.cdm.model.common.TermVocabulary;
-import eu.etaxonomy.cdm.model.description.Distribution;
-import eu.etaxonomy.cdm.model.description.Feature;
-import eu.etaxonomy.cdm.model.description.IndividualsAssociation;
-import eu.etaxonomy.cdm.model.description.PresenceAbsenceTerm;
-import eu.etaxonomy.cdm.model.description.TaxonDescription;
-import eu.etaxonomy.cdm.model.location.NamedArea;
-import eu.etaxonomy.cdm.model.location.NamedAreaLevel;
-import eu.etaxonomy.cdm.model.location.Point;
-import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
-import eu.etaxonomy.cdm.model.occurrence.FieldUnit;
-import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
-import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationType;
-import eu.etaxonomy.cdm.persistence.dao.common.IDefinedTermDao;
-import eu.etaxonomy.cdm.persistence.dao.common.ITermVocabularyDao;
-import eu.etaxonomy.cdm.persistence.dao.description.IDescriptionDao;
-import eu.etaxonomy.cdm.persistence.dao.occurrence.IOccurrenceDao;
-
-/**
- * @author a.kohlbecker
- * @date 18.06.2009
- *
- */
-@Service
-@Transactional(readOnly = true)
-public class EditGeoService implements IEditGeoService {
- public static final Logger logger = Logger.getLogger(EditGeoService.class);
-
- @Autowired
- private IDescriptionDao dao;
-
- @Autowired
- private IGeoServiceAreaMapping areaMapping;
-
- @Autowired
- private IDescriptionService descriptionService;
-
- @Autowired
- private ITermVocabularyDao vocabDao;
-
- private IDefinedTermDao termDao;
- @Autowired
- public void setTermDao(IDefinedTermDao termDao) {
- this.termDao = termDao;
- EditGeoServiceUtilities.setTermDao(termDao);
- }
-
- @Autowired
- private IOccurrenceDao occurrenceDao;
-
- private Set<Feature> getDistributionFeatures() {
- Set<Feature> distributionFeature = new HashSet<Feature>();
- Feature feature = (Feature) termDao.findByUuid(Feature.DISTRIBUTION().getUuid());
- distributionFeature.add(feature);
- return distributionFeature;
- }
-
- @Override
- public String getDistributionServiceRequestParameterString(List<TaxonDescription> taxonDescriptions,
- boolean subAreaPreference,
- boolean statusOrderPreference,
- Set<MarkerType> hideMarkedAreas, Map<PresenceAbsenceTerm, Color> presenceAbsenceTermColors,
- List<Language> langs) {
-
- Set<Distribution> distributions = new HashSet<Distribution>();
- for (TaxonDescription taxonDescription : taxonDescriptions) {
- List<Distribution> result = (List) dao.getDescriptionElements(
- taxonDescription,
- null,
- getDistributionFeatures(),
- Distribution.class,
- null,
- null,
- null);
- distributions.addAll(result);
- }
-
- String uriParams = getDistributionServiceRequestParameterString(distributions,
- subAreaPreference,
- statusOrderPreference,
- hideMarkedAreas,
- presenceAbsenceTermColors,
- langs);
-
- return uriParams;
- }
-
-
- @Override
- public String getDistributionServiceRequestParameterString(
- Set<Distribution> distributions,
- boolean subAreaPreference,
- boolean statusOrderPreference,
- Set<MarkerType> hideMarkedAreas,
- Map<PresenceAbsenceTerm, Color> presenceAbsenceTermColors,
- List<Language> langs) {
-
-// if (backLayer == null) {
-// backLayer = DEFAULT_BACK_LAYER;
-// }
- String uriParams = EditGeoServiceUtilities.getDistributionServiceRequestParameterString(distributions,
- subAreaPreference,
- statusOrderPreference,
- hideMarkedAreas,
- areaMapping, presenceAbsenceTermColors, null, langs);
- return uriParams;
- }
-
-
- @Override
- @Deprecated
- public String getDistributionServiceRequestParameterString(TaxonDescription taxonDescription,
- boolean subAreaPreference,
- boolean statusOrderPreference,
- Set<MarkerType> hideMarkedAreas,
- Map<PresenceAbsenceTerm, Color> presenceAbsenceTermColors,
- List<Language> langs) {
-
- List<TaxonDescription> taxonDescriptions = new ArrayList<TaxonDescription>();
- taxonDescriptions.add(taxonDescription);
-
- return getDistributionServiceRequestParameterString(taxonDescriptions,
- subAreaPreference,
- statusOrderPreference,
- hideMarkedAreas, presenceAbsenceTermColors,
- langs);
- }
-
- @Override
- public OccurrenceServiceRequestParameterDto getOccurrenceServiceRequestParameterString(List<SpecimenOrObservationBase> specimensOrObersvations,
- Map<SpecimenOrObservationType, Color> specimenOrObservationTypeColors) {
-
- List<Point> fieldUnitPoints = new ArrayList<Point>();
- List<Point> derivedUnitPoints = new ArrayList<Point>();
-
- IndividualsAssociation individualsAssociation;
- DerivedUnit derivedUnit;
-
- for (SpecimenOrObservationBase specimenOrObservationBase : specimensOrObersvations) {
- SpecimenOrObservationBase<?> specimenOrObservation = occurrenceDao
- .load(specimenOrObservationBase.getUuid());
-
- if (specimenOrObservation instanceof FieldUnit) {
- fieldUnitPoints.add(((FieldUnit) specimenOrObservation).getGatheringEvent()
- .getExactLocation());
- }
- if (specimenOrObservation instanceof DerivedUnit) {
- registerDerivedUnitLocations((DerivedUnit) specimenOrObservation, derivedUnitPoints);
- }
- }
-
- return EditGeoServiceUtilities.getOccurrenceServiceRequestParameterString(fieldUnitPoints,
- derivedUnitPoints, specimenOrObservationTypeColors);
-
- }
-
- /**
- * @param derivedUnit
- * @param derivedUnitPoints
- */
- private void registerDerivedUnitLocations(DerivedUnit derivedUnit, List<Point> derivedUnitPoints) {
-
- Set<SpecimenOrObservationBase> originals = derivedUnit.getOriginals();
- if (originals != null) {
- for (SpecimenOrObservationBase original : originals) {
- if (original instanceof FieldUnit) {
- if (((FieldUnit) original).getGatheringEvent() != null) {
- Point point = ((FieldUnit) original).getGatheringEvent().getExactLocation();
- if (point != null) {
- // points with no longitude or latitude should not exist
- // see #4173 ([Rule] Longitude and Latitude in Point must not be null)
- if (point.getLatitude() == null || point.getLongitude() == null){
- continue;
- }
- // FIXME: remove next statement after
- // DerivedUnitFacade or ABCD import is fixed
- //
- if(point.getLatitude() == 0.0 || point.getLongitude() == 0.0) {
- continue;
- }
- derivedUnitPoints.add(point);
- }
- }
- } else {
- registerDerivedUnitLocations((DerivedUnit) original, derivedUnitPoints);
- }
- }
- }
-
- }
-
- @Override
- public void setMapping(NamedArea area, GeoServiceArea geoServiceArea) {
- areaMapping.set(area, geoServiceArea);
-
- }
-
- @Override
- @Transactional(readOnly=false)
- public Map<NamedArea, String> mapShapeFileToNamedAreas(Reader csvReader,
- List<String> idSearchFields, String wmsLayerName, UUID areaVocabularyUuid,
- Set<UUID> namedAreaUuids) throws IOException {
-
- Set<NamedArea> areas = new HashSet<NamedArea>();
-
- if(areaVocabularyUuid != null){
- TermVocabulary<NamedArea> areaVocabulary = vocabDao.load(areaVocabularyUuid);
- if(areaVocabulary == null){
- throw new EntityNotFoundException("No Vocabulary found for uuid " + areaVocabularyUuid);
- }
- areas.addAll(areaVocabulary.getTerms());
- }
- if(namedAreaUuids != null && !namedAreaUuids.isEmpty()){
- for(DefinedTermBase dtb : termDao.list(namedAreaUuids, null, null, null, null)){
- areas.add((NamedArea)dtb);
- }
- }
-
- ShpAttributesToNamedAreaMapper mapper = new ShpAttributesToNamedAreaMapper(areas, areaMapping);
- Map<NamedArea, String> resultMap = mapper.readCsv(csvReader, idSearchFields, wmsLayerName);
- termDao.saveOrUpdateAll((Collection)areas);
- return resultMap;
- }
-
-
- @Override
- public DistributionInfoDTO composeDistributionInfoFor(EnumSet<DistributionInfoDTO.InfoPart> parts, UUID taxonUUID,
- boolean subAreaPreference, boolean statusOrderPreference, Set<MarkerType> hideMarkedAreas,
- Set<NamedAreaLevel> omitLevels, Map<PresenceAbsenceTerm, Color> presenceAbsenceTermColors,
- List<Language> languages, List<String> propertyPaths){
-
- DistributionInfoDTO dto = new DistributionInfoDTO();
-
- // Adding default initStrategies to improve the performance of this method
- // adding 'status' and 'area' has a good positive effect:
- // filterDistributions() only takes 21% of the total method time (before it was 46%)
- // at the same time the cost of the getDescriptionElementForTaxon is not increased at all!
- //
- // adding 'markers.markerType' is not improving the performance since it only
- // moved the load from the filter method to the getDescriptionElementForTaxon()
- // method.
- // overall improvement by this means is by 42% (from 77,711 ms to 44,868 ms)
- ArrayList<String> initStrategy = new ArrayList<String>(propertyPaths);
- if(!initStrategy.contains("status")) {
- initStrategy.add("status");
- }
- if(!initStrategy.contains("area")) {
- initStrategy.add("area");
- }
- if(!initStrategy.contains("markers.markerType")) {
- initStrategy.add("markers.markerType");
- }
-
- List<Distribution> distributions = dao.getDescriptionElementForTaxon(taxonUUID, null, Distribution.class, null, null, initStrategy);
- Set<Distribution> filteredDistributions = DescriptionUtility.filterDistributions(distributions, subAreaPreference, statusOrderPreference, hideMarkedAreas);
-
- if(parts.contains(InfoPart.elements)) {
- dto.setElements(filteredDistributions);
- }
-
- if(parts.contains(InfoPart.tree)) {
- dto.setTree(DescriptionUtility.orderDistributions(termDao, omitLevels, filteredDistributions));
- }
-
- if (parts.contains(InfoPart.mapUriParams)) {
- dto.setMapUriParams(EditGeoServiceUtilities.getDistributionServiceRequestParameterString(filteredDistributions,
- subAreaPreference,
- statusOrderPreference,
- hideMarkedAreas,
- areaMapping, presenceAbsenceTermColors, null, languages));
- }
-
- if(parts.contains(InfoPart.condensedStatusString)) {
- logger.error("condensedStatusString not yet supported: #3907 (EuroMed: implement condensed status string of distribution information)");
- }
-
- return dto;
- }
-}
+// $Id$\r
+/**\r
+ * Copyright (C) 2009 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
+package eu.etaxonomy.cdm.ext.geo;\r
+\r
+import java.awt.Color;\r
+import java.io.IOException;\r
+import java.io.Reader;\r
+import java.util.ArrayList;\r
+import java.util.Collection;\r
+import java.util.EnumSet;\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 javax.persistence.EntityNotFoundException;\r
+\r
+import org.apache.log4j.Logger;\r
+import org.springframework.beans.factory.annotation.Autowired;\r
+import org.springframework.stereotype.Service;\r
+import org.springframework.transaction.annotation.Transactional;\r
+\r
+import eu.etaxonomy.cdm.api.service.IDescriptionService;\r
+import eu.etaxonomy.cdm.api.service.dto.DistributionInfoDTO;\r
+import eu.etaxonomy.cdm.api.service.dto.DistributionInfoDTO.InfoPart;\r
+import eu.etaxonomy.cdm.api.utility.DescriptionUtility;\r
+import eu.etaxonomy.cdm.model.common.DefinedTermBase;\r
+import eu.etaxonomy.cdm.model.common.Language;\r
+import eu.etaxonomy.cdm.model.common.MarkerType;\r
+import eu.etaxonomy.cdm.model.common.TermVocabulary;\r
+import eu.etaxonomy.cdm.model.description.Distribution;\r
+import eu.etaxonomy.cdm.model.description.Feature;\r
+import eu.etaxonomy.cdm.model.description.IndividualsAssociation;\r
+import eu.etaxonomy.cdm.model.description.PresenceAbsenceTerm;\r
+import eu.etaxonomy.cdm.model.description.TaxonDescription;\r
+import eu.etaxonomy.cdm.model.location.NamedArea;\r
+import eu.etaxonomy.cdm.model.location.NamedAreaLevel;\r
+import eu.etaxonomy.cdm.model.location.Point;\r
+import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;\r
+import eu.etaxonomy.cdm.model.occurrence.FieldUnit;\r
+import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;\r
+import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationType;\r
+import eu.etaxonomy.cdm.persistence.dao.common.IDefinedTermDao;\r
+import eu.etaxonomy.cdm.persistence.dao.common.ITermVocabularyDao;\r
+import eu.etaxonomy.cdm.persistence.dao.description.IDescriptionDao;\r
+import eu.etaxonomy.cdm.persistence.dao.occurrence.IOccurrenceDao;\r
+\r
+/**\r
+ * @author a.kohlbecker\r
+ * @date 18.06.2009\r
+ *\r
+ */\r
+@Service\r
+@Transactional(readOnly = true)\r
+public class EditGeoService implements IEditGeoService {\r
+ public static final Logger logger = Logger.getLogger(EditGeoService.class);\r
+\r
+ @Autowired\r
+ private IDescriptionDao dao;\r
+\r
+ @Autowired\r
+ private IGeoServiceAreaMapping areaMapping;\r
+\r
+ @Autowired\r
+ private IDescriptionService descriptionService;\r
+\r
+ @Autowired\r
+ private ITermVocabularyDao vocabDao;\r
+\r
+ private IDefinedTermDao termDao;\r
+ @Autowired\r
+ public void setTermDao(IDefinedTermDao termDao) {\r
+ this.termDao = termDao;\r
+ EditGeoServiceUtilities.setTermDao(termDao);\r
+ }\r
+\r
+ @Autowired\r
+ private IOccurrenceDao occurrenceDao;\r
+\r
+ private Set<Feature> getDistributionFeatures() {\r
+ Set<Feature> distributionFeature = new HashSet<Feature>();\r
+ Feature feature = (Feature) termDao.findByUuid(Feature.DISTRIBUTION().getUuid());\r
+ distributionFeature.add(feature);\r
+ return distributionFeature;\r
+ }\r
+\r
+ @Override\r
+ public String getDistributionServiceRequestParameterString(List<TaxonDescription> taxonDescriptions,\r
+ boolean subAreaPreference,\r
+ boolean statusOrderPreference,\r
+ Set<MarkerType> hideMarkedAreas, Map<PresenceAbsenceTerm, Color> presenceAbsenceTermColors,\r
+ List<Language> langs) {\r
+\r
+ Set<Distribution> distributions = new HashSet<Distribution>();\r
+ for (TaxonDescription taxonDescription : taxonDescriptions) {\r
+ List<Distribution> result = (List) dao.getDescriptionElements(\r
+ taxonDescription,\r
+ null,\r
+ getDistributionFeatures(),\r
+ Distribution.class,\r
+ null,\r
+ null,\r
+ null);\r
+ distributions.addAll(result);\r
+ }\r
+\r
+ String uriParams = getDistributionServiceRequestParameterString(distributions,\r
+ subAreaPreference,\r
+ statusOrderPreference,\r
+ hideMarkedAreas,\r
+ presenceAbsenceTermColors,\r
+ langs);\r
+\r
+ return uriParams;\r
+ }\r
+\r
+\r
+ @Override\r
+ public String getDistributionServiceRequestParameterString(\r
+ Set<Distribution> distributions,\r
+ boolean subAreaPreference,\r
+ boolean statusOrderPreference,\r
+ Set<MarkerType> hideMarkedAreas,\r
+ Map<PresenceAbsenceTerm, Color> presenceAbsenceTermColors,\r
+ List<Language> langs) {\r
+\r
+// if (backLayer == null) {\r
+// backLayer = DEFAULT_BACK_LAYER;\r
+// }\r
+ String uriParams = EditGeoServiceUtilities.getDistributionServiceRequestParameterString(distributions,\r
+ subAreaPreference,\r
+ statusOrderPreference,\r
+ hideMarkedAreas,\r
+ areaMapping, presenceAbsenceTermColors, null, langs);\r
+ return uriParams;\r
+ }\r
+\r
+\r
+ @Override\r
+ @Deprecated\r
+ public String getDistributionServiceRequestParameterString(TaxonDescription taxonDescription,\r
+ boolean subAreaPreference,\r
+ boolean statusOrderPreference,\r
+ Set<MarkerType> hideMarkedAreas,\r
+ Map<PresenceAbsenceTerm, Color> presenceAbsenceTermColors,\r
+ List<Language> langs) {\r
+\r
+ List<TaxonDescription> taxonDescriptions = new ArrayList<TaxonDescription>();\r
+ taxonDescriptions.add(taxonDescription);\r
+\r
+ return getDistributionServiceRequestParameterString(taxonDescriptions,\r
+ subAreaPreference,\r
+ statusOrderPreference,\r
+ hideMarkedAreas, presenceAbsenceTermColors,\r
+ langs);\r
+ }\r
+\r
+ @Override\r
+ public OccurrenceServiceRequestParameterDto getOccurrenceServiceRequestParameterString(List<SpecimenOrObservationBase> specimensOrObersvations,\r
+ Map<SpecimenOrObservationType, Color> specimenOrObservationTypeColors) {\r
+\r
+ List<Point> fieldUnitPoints = new ArrayList<Point>();\r
+ List<Point> derivedUnitPoints = new ArrayList<Point>();\r
+\r
+ IndividualsAssociation individualsAssociation;\r
+ DerivedUnit derivedUnit;\r
+\r
+ for (SpecimenOrObservationBase specimenOrObservationBase : specimensOrObersvations) {\r
+ SpecimenOrObservationBase<?> specimenOrObservation = occurrenceDao\r
+ .load(specimenOrObservationBase.getUuid());\r
+\r
+ if (specimenOrObservation instanceof FieldUnit) {\r
+ fieldUnitPoints.add(((FieldUnit) specimenOrObservation).getGatheringEvent()\r
+ .getExactLocation());\r
+ }\r
+ if (specimenOrObservation instanceof DerivedUnit) {\r
+ registerDerivedUnitLocations((DerivedUnit) specimenOrObservation, derivedUnitPoints);\r
+ }\r
+ }\r
+\r
+ return EditGeoServiceUtilities.getOccurrenceServiceRequestParameterString(fieldUnitPoints,\r
+ derivedUnitPoints, specimenOrObservationTypeColors);\r
+\r
+ }\r
+\r
+ /**\r
+ * @param derivedUnit\r
+ * @param derivedUnitPoints\r
+ */\r
+ private void registerDerivedUnitLocations(DerivedUnit derivedUnit, List<Point> derivedUnitPoints) {\r
+\r
+ Set<SpecimenOrObservationBase> originals = derivedUnit.getOriginals();\r
+ if (originals != null) {\r
+ for (SpecimenOrObservationBase original : originals) {\r
+ if (original instanceof FieldUnit) {\r
+ if (((FieldUnit) original).getGatheringEvent() != null) {\r
+ Point point = ((FieldUnit) original).getGatheringEvent().getExactLocation();\r
+ if (point != null) {\r
+ // points with no longitude or latitude should not exist\r
+ // see #4173 ([Rule] Longitude and Latitude in Point must not be null)\r
+ if (point.getLatitude() == null || point.getLongitude() == null){\r
+ continue;\r
+ }\r
+ // FIXME: remove next statement after\r
+ // DerivedUnitFacade or ABCD import is fixed\r
+ //\r
+ if(point.getLatitude() == 0.0 || point.getLongitude() == 0.0) {\r
+ continue;\r
+ }\r
+ derivedUnitPoints.add(point);\r
+ }\r
+ }\r
+ } else {\r
+ registerDerivedUnitLocations((DerivedUnit) original, derivedUnitPoints);\r
+ }\r
+ }\r
+ }\r
+\r
+ }\r
+\r
+ @Override\r
+ public void setMapping(NamedArea area, GeoServiceArea geoServiceArea) {\r
+ areaMapping.set(area, geoServiceArea);\r
+\r
+ }\r
+\r
+ @Override\r
+ @Transactional(readOnly=false)\r
+ public Map<NamedArea, String> mapShapeFileToNamedAreas(Reader csvReader,\r
+ List<String> idSearchFields, String wmsLayerName, UUID areaVocabularyUuid,\r
+ Set<UUID> namedAreaUuids) throws IOException {\r
+\r
+ Set<NamedArea> areas = new HashSet<NamedArea>();\r
+\r
+ if(areaVocabularyUuid != null){\r
+ TermVocabulary<NamedArea> areaVocabulary = vocabDao.load(areaVocabularyUuid);\r
+ if(areaVocabulary == null){\r
+ throw new EntityNotFoundException("No Vocabulary found for uuid " + areaVocabularyUuid);\r
+ }\r
+ areas.addAll(areaVocabulary.getTerms());\r
+ }\r
+ if(namedAreaUuids != null && !namedAreaUuids.isEmpty()){\r
+ for(DefinedTermBase dtb : termDao.list(namedAreaUuids, null, null, null, null)){\r
+ areas.add((NamedArea)dtb);\r
+ }\r
+ }\r
+\r
+ ShpAttributesToNamedAreaMapper mapper = new ShpAttributesToNamedAreaMapper(areas, areaMapping);\r
+ Map<NamedArea, String> resultMap = mapper.readCsv(csvReader, idSearchFields, wmsLayerName);\r
+ termDao.saveOrUpdateAll((Collection)areas);\r
+ return resultMap;\r
+ }\r
+\r
+\r
+ @Override\r
+ public DistributionInfoDTO composeDistributionInfoFor(EnumSet<DistributionInfoDTO.InfoPart> parts, UUID taxonUUID,\r
+ boolean subAreaPreference, boolean statusOrderPreference, Set<MarkerType> hideMarkedAreas,\r
+ Set<NamedAreaLevel> omitLevels, Map<PresenceAbsenceTerm, Color> presenceAbsenceTermColors,\r
+ List<Language> languages, List<String> propertyPaths){\r
+\r
+ DistributionInfoDTO dto = new DistributionInfoDTO();\r
+\r
+ // Adding default initStrategies to improve the performance of this method\r
+ // adding 'status' and 'area' has a good positive effect:\r
+ // filterDistributions() only takes 21% of the total method time (before it was 46%)\r
+ // at the same time the cost of the getDescriptionElementForTaxon is not increased at all!\r
+ //\r
+ // adding 'markers.markerType' is not improving the performance since it only\r
+ // moved the load from the filter method to the getDescriptionElementForTaxon()\r
+ // method.\r
+ // overall improvement by this means is by 42% (from 77,711 ms to 44,868 ms)\r
+ ArrayList<String> initStrategy = new ArrayList<String>(propertyPaths);\r
+ if(!initStrategy.contains("status")) {\r
+ initStrategy.add("status");\r
+ }\r
+ if(!initStrategy.contains("area")) {\r
+ initStrategy.add("area");\r
+ }\r
+ if(!initStrategy.contains("markers.markerType")) {\r
+ initStrategy.add("markers.markerType");\r
+ }\r
+\r
+ List<Distribution> distributions = dao.getDescriptionElementForTaxon(taxonUUID, null, Distribution.class, null, null, initStrategy);\r
+ Set<Distribution> filteredDistributions = DescriptionUtility.filterDistributions(distributions, subAreaPreference, statusOrderPreference, hideMarkedAreas);\r
+\r
+ if(parts.contains(InfoPart.elements)) {\r
+ dto.setElements(filteredDistributions);\r
+ }\r
+\r
+ if(parts.contains(InfoPart.tree)) {\r
+ dto.setTree(DescriptionUtility.orderDistributions(termDao, omitLevels, filteredDistributions));\r
+ }\r
+\r
+ if (parts.contains(InfoPart.mapUriParams)) {\r
+ dto.setMapUriParams(EditGeoServiceUtilities.getDistributionServiceRequestParameterString(filteredDistributions,\r
+ subAreaPreference,\r
+ statusOrderPreference,\r
+ hideMarkedAreas,\r
+ areaMapping, presenceAbsenceTermColors, null, languages));\r
+ }\r
+\r
+ if(parts.contains(InfoPart.condensedStatusString)) {\r
+ logger.error("condensedStatusString not yet supported: #3907 (EuroMed: implement condensed status string of distribution information)");\r
+ }\r
+\r
+ return dto;\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.berlinModel;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.UUID;
-
-import org.apache.log4j.Logger;
-
-import eu.etaxonomy.cdm.common.ResultWrapper;
-import eu.etaxonomy.cdm.io.common.mapping.UndefinedTransformerMethodException;
-import eu.etaxonomy.cdm.model.common.Language;
-import eu.etaxonomy.cdm.model.common.OrderedTermVocabulary;
-import eu.etaxonomy.cdm.model.common.RelationshipBase;
-import eu.etaxonomy.cdm.model.common.RelationshipTermBase;
-import eu.etaxonomy.cdm.model.description.Feature;
-import eu.etaxonomy.cdm.model.description.PresenceAbsenceTerm;
-import eu.etaxonomy.cdm.model.name.HybridRelationshipType;
-import eu.etaxonomy.cdm.model.name.NameRelationshipType;
-import eu.etaxonomy.cdm.model.name.NomenclaturalStatus;
-import eu.etaxonomy.cdm.model.name.NomenclaturalStatusType;
-import eu.etaxonomy.cdm.model.name.Rank;
-import eu.etaxonomy.cdm.model.name.RankClass;
-import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignationStatus;
-import eu.etaxonomy.cdm.model.reference.ISection;
-import eu.etaxonomy.cdm.model.reference.Reference;
-import eu.etaxonomy.cdm.model.reference.ReferenceType;
-import eu.etaxonomy.cdm.model.taxon.Synonym;
-import eu.etaxonomy.cdm.model.taxon.SynonymRelationshipType;
-import eu.etaxonomy.cdm.model.taxon.Taxon;
-import eu.etaxonomy.cdm.model.taxon.TaxonBase;
-import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
-import eu.etaxonomy.cdm.strategy.exceptions.UnknownCdmTypeException;
-
-/**
- * @author a.mueller
- * @created 20.03.2008
- */
-public class BerlinModelTransformer {
- private static final Logger logger = Logger.getLogger(BerlinModelTransformer.class);
-
- //source Refs
- public static final UUID uuidSourceRefEuroMed = UUID.fromString("0603a84a-f024-4454-ab92-9e2ac0139126");
-
- //ranks
- public static UUID uuidRankCollSpecies = UUID.fromString("e14630ee-9446-4bb4-a7b7-4c3881bc5d94");
- public static UUID uuidRankProles = UUID.fromString("8810d1ba-6a34-4ae3-a355-919ccd1cd1a5");
- public static UUID uuidRankRace = UUID.fromString("196dee39-cfd8-4460-8bf0-88b83da27f62");
- public static UUID uuidRankSublusus = UUID.fromString("1fafa596-a8e7-4e62-a378-3cc8cb3627ca");
-
- //named areas
- public static UUID euroMedUuid = UUID.fromString("9fe09988-58c0-4c06-8474-f660a0c50014");
-
- public static UUID uuidEasternEuropeanRussia = UUID.fromString("3f013375-0e0a-40c3-8a14-84c0535fab40");
- public static UUID uuidSerbiaMontenegro = UUID.fromString("8926dbe6-863e-47a9-98a0-7dc9ed2c57f7");
- public static UUID uuidSerbia = UUID.fromString("4ffed197-3d7e-4cd9-8984-e64b8dee9512");
- public static UUID uuidLebanonSyria = UUID.fromString("0c45f250-99da-4b19-aa89-c3e56cfdf103");
- public static UUID uuidUssr = UUID.fromString("a512e00a-45f3-4be5-82fa-bba8d675696f");
- public static UUID uuidSicilyMalta = UUID.fromString("424d81ee-d272-4ae8-9600-0a334049cd72");
-
- public static UUID uuidDesertas = UUID.fromString("36f5e93e-34e8-45b5-a401-f0e0faad21cf");
- public static UUID uuidMadeira = UUID.fromString("086e27ee-78ff-4236-aca9-9850850cd355");
- public static UUID uuidPortoSanto = UUID.fromString("1f9ab6a0-a402-4dfe-8c5b-b1844eb4d8e5");
- //azores
- public static UUID uuidFlores = UUID.fromString("ef0067c2-8bbb-4e37-8462-97b03f51ba43");
- public static UUID uuidCorvo = UUID.fromString("b1e6117c-2be1-43a3-9233-227dd90bdee9");
- public static UUID uuidFaial = UUID.fromString("14f6dcdb-6524-4700-b80c-66424952ef2b");
- public static UUID uuidGraciosa = UUID.fromString("05f93a7b-d813-4833-864f-eedbba747133");
- public static UUID uuidSaoJorge = UUID.fromString("578e0ecd-b5e3-4c87-8ecc-0fc4c7e217d9");
- public static UUID uuidSaoMiguel = UUID.fromString("0e2f6ad8-7afb-4f01-b134-4f71991e877a");
- public static UUID uuidPico = UUID.fromString("98cc566f-4110-43d5-830f-68436a009f49");
- public static UUID uuidSantaMaria = UUID.fromString("bd5e5d4a-22b7-41aa-8e58-1d1d73a9954d");
- public static UUID uuidTerceira = UUID.fromString("6fc257c0-a131-41f0-b6c3-51ef9c4fa962");
- //Canyry islands
- public static UUID uuidGranCanaria = UUID.fromString("a0240c35-0e05-4157-8321-67ba8e31fdb9");
- public static UUID uuidFuerteventura = UUID.fromString("549ce2c1-6d49-4bf3-b75d-cf3f4b5a1398");
- public static UUID uuidGomera = UUID.fromString("895fab09-7478-4210-b42a-423d23c6f85e");
- public static UUID uuidHierro = UUID.fromString("d137b6a5-31bc-418c-9403-f042017dc04b");
- public static UUID uuidLanzaroteWithGraciosa = UUID.fromString("c9b08dc1-f301-4d9d-b447-b8744602c776");
- public static UUID uuidLaPalma = UUID.fromString("fdb3f2b2-f154-4f04-9f31-240a47a0e780");
- public static UUID uuidTenerife = UUID.fromString("73658c7e-a568-465e-bd84-4554fc93ca56");
- //Baleares
- public static UUID uuidIbizaWithFormentera = UUID.fromString("1cda2a33-3469-49d5-8e77-cb5451110519");
- public static UUID uuidMallorca = UUID.fromString("a10cba04-b4b5-4a4b-b69a-fcd4b3916fec");
- public static UUID uuidMenorca = UUID.fromString("9f6ede48-27f8-4270-bf4e-c97eaa86aab7");
-
- //russia
- public static UUID uuidRussiaNorthern = UUID.fromString("c23bc1c9-a775-4426-b883-07d4d7d47eed");
- public static UUID uuidRussiaBaltic = UUID.fromString("579dad44-9439-4b19-8716-ab90d8f27944");
- public static UUID uuidRussiaCentral = UUID.fromString("8bbc8c6a-2ef2-4024-ad51-66fe34c70092");
- public static UUID uuidRussiaSouthWest = UUID.fromString("daa5c207-5567-4690-8742-5e4d153b6a64");
- public static UUID uuidRussiaSouthEast = UUID.fromString("e8516598-b529-489e-9ee8-63bbbd295c1b");
- public static UUID uuidEastAegeanIslands = UUID.fromString("1c429593-c493-46e6-971a-0d70be690da8");
- public static UUID uuidTurkishEastAegeanIslands = UUID.fromString("ba35dba3-ac70-41ae-81c2-2070943f44f2");
- public static UUID uuidBalticStates = UUID.fromString("bf9d64f6-3183-4fa5-8e90-73090e7a2282");
- public static final UUID uuidTurkey = UUID.fromString("d344ee2c-14c8-438d-b03d-11538edb1268");
- public static final UUID uuidCaucasia = UUID.fromString("ebfd3fd1-3859-4e5e-95c7-f66010599d7e");
-
-
-
- //E+M areas
- public static UUID uuidVocEuroMedAreas = UUID.fromString("625a4962-c211-4597-816e-5804083efe26");
- public static UUID uuidEM = UUID.fromString("111BDF38-7A32-440A-9808-8AF1C9E54B51");
- public static UUID uuidEUR = UUID.fromString("80B3CEEE-2F78-45CE-B4F4-E473F5ED8343");
- public static UUID uuid14 = UUID.fromString("4FF83A35-97DE-4C39-BEDE-27EE9ECEFB45");
- public static UUID uuid20 = UUID.fromString("19D93AD1-59E7-49ED-B513-D7D493EDC4DE");
- public static UUID uuid21 = UUID.fromString("1B98DAF0-A709-4871-9A8B-CFDD09F41763");
- public static UUID uuid33 = UUID.fromString("6B719260-1E48-4D85-8BC3-320852E1B331");
- public static UUID uuidDa = UUID.fromString("867871C9-9931-47D0-AEF7-468B9519EBB2");
- public static UUID uuidFe = UUID.fromString("C4EF26AF-11E0-4888-9FC3-5E56F4422BB4");
- public static UUID uuidFa = UUID.fromString("70426E7E-2EAA-4987-95FB-5CB6E56980F3");
- public static UUID uuidBr = UUID.fromString("A22329C4-0B81-4E00-BCC3-2F44A6CA56D0");
- public static UUID uuidIs = UUID.fromString("3D2950E9-C2FD-462E-9697-DCB7241D514E");
- public static UUID uuidHb = UUID.fromString("65E405E7-B3D4-44B6-BE67-4881582EA274");
- public static UUID uuidNo = UUID.fromString("2D3F1181-6838-4034-96CB-F254A558572A");
- public static UUID uuidSb = UUID.fromString("BC847AF8-30C3-48B2-A881-2B2DEAC0A137");
- public static UUID uuidSu = UUID.fromString("F064AB9F-EDDB-47D8-8E54-B9E8AD19111D");
- public static UUID uuidAu = UUID.fromString("37C77C23-9673-4ABC-87C2-B29E9FA87FA8");
- public static UUID uuidBe = UUID.fromString("4840373B-F949-4630-B655-9B37F845CFDA");
- public static UUID uuidCz = UUID.fromString("02E67A70-C192-4A01-A311-99F8C42F9D51");
- public static UUID uuidGe = UUID.fromString("F617DDEA-51C9-4EF1-B7F4-ED22F871631D");
- public static UUID uuidHu = UUID.fromString("AD7EDDB1-C089-436F-88BA-BC9115BBD6E0");
- public static UUID uuidHo = UUID.fromString("00B8FE6D-D04B-4CAC-ADCE-32B44ABB385A");
- public static UUID uuidPo = UUID.fromString("F23864DF-DFD6-4ABC-B7D0-FD97408AE0A9");
- public static UUID uuidHe = UUID.fromString("7C28D878-F16D-4043-A94E-750BEF910064");
- public static UUID uuidBl = UUID.fromString("A4326211-3219-4655-83AD-599D635DB638");
- public static UUID uuidCo = UUID.fromString("3EE3CB3E-23DE-491F-94DF-35DB7A1D3AC0");
- public static UUID uuidGa = UUID.fromString("28591C04-60E3-432A-9D05-CBC945462D2E");
- public static UUID uuidLu = UUID.fromString("205512B0-AA22-4041-B92B-336FEB79FA4F");
- public static UUID uuidSa = UUID.fromString("11368A92-2362-4029-A26A-E35CEC0798C1");
- public static UUID uuidHs = UUID.fromString("6AD92C01-1442-4F2F-BD58-F73075B26C27");
- public static UUID uuidAl = UUID.fromString("635B63DA-0AAF-446C-843E-BEB52E2A1B90");
- public static UUID uuidBu = UUID.fromString("75F3CF66-B272-464E-9B1E-35B8E511936D");
- public static UUID uuidGr = UUID.fromString("34DF8B89-7DFA-4265-9A3E-D540DB72AA77");
- public static UUID uuidIt = UUID.fromString("06B8F41D-B9A8-4B55-8AAB-DE90EB3D0A9C");
- public static UUID uuidCr = UUID.fromString("20A8A822-1C87-43F0-A5EF-2AF1CC5DC0FC");
- public static UUID uuidRm = UUID.fromString("EAB29D40-E3B2-4920-BB1F-8757DFBC9E86");
- public static UUID uuidSi_S = UUID.fromString("DD861671-930F-4C9E-92D8-EADDC28EB6B7");
- public static UUID uuidTu_E = UUID.fromString("2B732609-55DB-4F25-BC73-618FFF515ADC");
- public static UUID uuidJu = UUID.fromString("BD5E6833-7E0E-41A8-83D6-149A31F2CE05");
- public static UUID uuidUk_K = UUID.fromString("40B7219D-E38C-44EB-9877-E311A2734022");
- public static UUID uuidUk = UUID.fromString("7A8DF5D0-3D18-4386-891E-96E11BDB6FEB");
- public static UUID uuidAg = UUID.fromString("548E583C-DBE7-463F-A01B-2A966F2B32D2");
- public static UUID uuidEg = UUID.fromString("9EDDDE2E-95B7-4443-89A8-C30D031E16A5");
- public static UUID uuidLi = UUID.fromString("2F506902-2A56-40C8-84CB-B436C84ED258");
- public static UUID uuidMa = UUID.fromString("D639A7AC-F873-414E-8869-73D10B9CF842");
- public static UUID uuidTn = UUID.fromString("AF4D86D4-2CA0-48A2-BA15-0D74454D1EAD");
- public static UUID uuidAz = UUID.fromString("CEC2EBD3-DFD0-4CE6-827F-BFF8FBAF5283");
- public static UUID uuidSg = UUID.fromString("BC4A0307-B81A-4233-B8BD-EFB9CEDFD530");
- public static UUID uuidAb = UUID.fromString("D3744C2D-2777-4E85-98BF-04D2FD589EBF");
- public static UUID uuidAr = UUID.fromString("535FED1E-3EC9-4563-AF55-E753AEFCFBFE");
- public static UUID uuidAb_A = UUID.fromString("0F4C98BF-AF7B-4CDA-B62C-AD6A1909BFA0");
- public static UUID uuidGg = UUID.fromString("DA1CCDA8-5867-4098-A709-100A66E2150A");
- public static UUID uuidAb_N = UUID.fromString("AA75B0CA-49C9-4F8E-8CC2-2A343EB2FFF4");
- public static UUID uuidCy = UUID.fromString("36EFDF69-09C0-4160-A502-9EEFBC22A984");
- public static UUID uuidAE_G = UUID.fromString("76F5F3F6-9C3E-47F5-8E85-55360C50273C");
- public static UUID uuidLe = UUID.fromString("639F5D97-EC9E-4EE2-ADFC-DFF73F7CC970");
- public static UUID uuidSn = UUID.fromString("5D8E0B00-96CE-4ACC-AF02-62A1B9866144");
- public static UUID uuidTu_A = UUID.fromString("F7B59D79-15C2-47C9-91B0-DEC1F388CB62");
- public static UUID uuidTu = UUID.fromString("DB98809B-EF22-413B-B1EA-A79C4E1C4903");
- public static UUID uuidAu_A = UUID.fromString("AE65867C-00F6-406C-A315-B3E4CC9A93D2");
- public static UUID uuidAu_L = UUID.fromString("78146B6E-E71A-46DA-8DBC-244CC648BBE7");
- public static UUID uuidAz_C = UUID.fromString("D35B8259-CC76-4FB0-AFC0-6A23D657EE3E");
- public static UUID uuidAz_F = UUID.fromString("0F8F470D-CA2A-4130-842A-0A0C6912A123");
- public static UUID uuidAz_G = UUID.fromString("CFF9FC6D-E3B2-45B1-87A9-6FEFB029A12F");
- public static UUID uuidAz_P = UUID.fromString("C8000982-19E8-492E-912D-59EB370E52C0");
- public static UUID uuidAz_S = UUID.fromString("BD852931-47B3-466C-A422-4F312B913CA2");
- public static UUID uuidAz_J = UUID.fromString("4A5CED9F-F078-44B3-94BF-F3EE79315236");
- public static UUID uuidAz_M = UUID.fromString("B8C76F37-6483-474F-85AB-96399219DE57");
- public static UUID uuidAz_T = UUID.fromString("7A52595F-DA5E-440A-B2BD-F63999CE979E");
- public static UUID uuidBe_B = UUID.fromString("9E263401-ACEC-4E2E-AA89-4AAF56AE7180");
- public static UUID uuidBe_L = UUID.fromString("AF71559C-7765-493C-8C9A-1248DFF28789");
- public static UUID uuidBl_I = UUID.fromString("121B07A0-8031-4F22-B9B7-C334FC3204CE");
- public static UUID uuidBl_M = UUID.fromString("E8E8EFDC-E9EB-4B26-9711-F986265AD114");
- public static UUID uuidBl_N = UUID.fromString("D96DD8A7-4BD8-4ADF-8CDB-05873686DB1A");
- public static UUID uuidBH = UUID.fromString("6A109EF5-3AC1-4C59-8599-08F944ABA499");
- public static UUID uuidBy = UUID.fromString("5D972AF7-6AE2-44D1-840B-EDB1DBE8B7AC");
- public static UUID uuidCa = UUID.fromString("CFA26682-B0AB-4FEB-9191-6AA098638382");
- public static UUID uuidCa_F = UUID.fromString("0D8ED2C4-0313-464C-A5B4-EC0A52E45ADF");
- public static UUID uuidCa_G = UUID.fromString("865D1319-B157-4D1A-BBF0-F56B7EB2ED96");
- public static UUID uuidCa_C = UUID.fromString("486FCBED-84C4-4673-8724-9A8A4A6613AD");
- public static UUID uuidCa_H = UUID.fromString("0B57C693-DB09-4D7F-9FA9-0DBBEFF3B3B6");
- public static UUID uuidCa_L = UUID.fromString("A88D6DF4-7924-4BEC-BFA6-071BDA82A4B3");
- public static UUID uuidCa_P = UUID.fromString("BBF04D1A-1FC0-4A7B-BF0B-7D7BF69D8392");
- public static UUID uuidCa_T = UUID.fromString("BBAD170B-285D-4BEA-8C3F-C43894FB75FF");
- public static UUID uuidCs = UUID.fromString("2ADA45F0-C7CC-4026-A8B1-B816971F0753");
- public static UUID uuidCt = UUID.fromString("09B5728A-4775-4530-B362-9B1EF4A9E8C3");
- public static UUID uuidEs = UUID.fromString("1011D427-401B-47EE-A42C-4C1698957D55");
- public static UUID uuidGa_C = UUID.fromString("3653A4DC-1ADE-4237-A62C-4F0AC11E576F");
- public static UUID uuidGa_F = UUID.fromString("860F92B6-5CDA-456B-964C-6162D1D08161");
- public static UUID uuidGg_A = UUID.fromString("5FAD859B-7929-4D5F-B92C-95E3E0469BB2");
- public static UUID uuidGg_D = UUID.fromString("6091C975-B946-4EF3-A18F-2E148EAE6A06");
- public static UUID uuidGg_G = UUID.fromString("048799B0-D7B9-44C6-B2D1-5CA2A49FA175");
- public static UUID uuidHs_A = UUID.fromString("EAED6C21-42E5-496D-B43E-C121F96FA672");
- public static UUID uuidHs_G = UUID.fromString("35350D75-6952-48BD-B265-C005BC1B2909");
- public static UUID uuidHs_S = UUID.fromString("264649F7-192D-4AE5-9840-81FC782F59F0");
- public static UUID uuidIr = UUID.fromString("A3B35528-5FFD-43B1-B605-711807C1EC9F");
- public static UUID uuidIt_I = UUID.fromString("E3BC327E-0B42-4439-811B-595BC55A8FF8");
- public static UUID uuidIt_S = UUID.fromString("57F35807-8CFA-4698-BB04-AAD3549C12EB");
- public static UUID uuidJo = UUID.fromString("567A537D-F2FA-43EF-A20A-AEC76723E269");
- public static UUID uuidKz = UUID.fromString("F8ABE715-D859-4B6F-B8F1-DB1A847DEAC4");
- public static UUID uuidLa = UUID.fromString("8E338882-2631-4AD6-BC53-799C698C807D");
- public static UUID uuidLt = UUID.fromString("ECF200B6-B1DF-414F-B215-EDAC503B1A65");
- public static UUID uuidMa_E = UUID.fromString("80980607-FBD8-46E3-BE56-05D997F2D331");
- public static UUID uuidMa_S = UUID.fromString("B743AE57-DC0B-4CCC-B4D9-7BF51E579E8E");
- public static UUID uuidMk = UUID.fromString("0CE83170-2FA7-4C72-81F7-7FFF17343E48");
- public static UUID uuidMd = UUID.fromString("2CFB90B1-0BA0-4578-AD11-AAD5AAB62899");
- public static UUID uuidMd_D = UUID.fromString("DBE1F3CA-4C7C-4062-AC1E-ADE0C17DCA52");
- public static UUID uuidMd_M = UUID.fromString("4658DADD-60FE-46D8-94E3-C6A6C4646105");
- public static UUID uuidMd_P = UUID.fromString("2C41EB67-A330-4214-B452-6E6741262CE5");
- public static UUID uuidSi_M = UUID.fromString("2920D738-54A1-49CE-AF3A-9CB742064587");
- public static UUID uuidMo = UUID.fromString("64F98B98-1050-42C6-B2C7-F72DA642E4D5");
- public static UUID uuidRf = UUID.fromString("4B6BDFEE-2BCB-4638-99CF-0F9612FA4787");
- public static UUID uuidRf_C = UUID.fromString("1FFAF0B5-6311-4BF6-977F-8940622C4986");
- public static UUID uuidRf_E = UUID.fromString("4280A0F6-298E-4B3C-8CE8-56A1208183F7");
- public static UUID uuidRf_K = UUID.fromString("D9559D9A-1798-4496-8671-DE667CC30EC0");
- public static UUID uuidRf_CS = UUID.fromString("6E886ACC-22C9-4C63-BEA5-A51AD84AF3D1");
- public static UUID uuidRf_N = UUID.fromString("B0D8F65E-B5A4-4C0B-A5EF-54CC9F378CC6");
- public static UUID uuidRf_NW = UUID.fromString("06CC9983-B444-4322-A03E-9A7A2AF1D4AD");
- public static UUID uuidRf_A = UUID.fromString("1786C13D-D26D-49E3-BA60-E3F3E7852713");
- public static UUID uuidRf_S = UUID.fromString("6AAB10D5-05E9-470A-8AF5-B6F8D48A71EC");
- public static UUID uuidSk = UUID.fromString("09267309-E771-4BD7-A67F-B6B4321546E0");
- public static UUID uuidSl = UUID.fromString("BC242D21-98CA-402C-BDB7-3ED347C7BDFD");
- public static UUID uuidSy = UUID.fromString("A5974D4B-F878-422C-A7A8-A1D8268109EF");
- public static UUID uuidUk_U = UUID.fromString("4A6C5155-154E-4B0D-AC73-550B51CCE374");
- public static UUID uuidSM = UUID.fromString("AC360FC1-30F4-444A-92EB-B55BF98B8E97");
- public static UUID uuidYu_K = UUID.fromString("F3F05E88-99AF-48FA-92EF-1A169BCC7ACF");
- public static UUID uuidCg = UUID.fromString("38A4FD15-40D6-43F4-9685-F87465FDBD3F");
- public static UUID uuidSr = UUID.fromString("468CFEA2-008F-40CF-B2C8-ADF5C09C0FA4");
- public static UUID uuidIJ = UUID.fromString("9351B972-0C0B-4A97-87B1-4CC11E67D21E");
- public static UUID uuidLS = UUID.fromString("F7BFDAE0-3DD9-4FC4-9B0B-0BF203B94031");
- public static UUID uuidRs = UUID.fromString("C4A898CE-0F32-44FE-A8A3-278E11A4BA53");
- public static UUID uuidSi = UUID.fromString("DB1FACF2-58A5-483E-9B2A-EB4290CA1B71");
- public static UUID uuidAz_L = UUID.fromString("F5AEF252-C4F8-4ECC-9B6E-4821DB7ADECF");
- public static UUID uuidHb_E = UUID.fromString("1D400E37-F39A-4CAE-8885-CF485B900CC5");
- public static UUID uuidHb_N = UUID.fromString("B1D514DA-B9E6-4F0E-ACE4-18FB061FC132");
- public static UUID uuidGa_M = UUID.fromString("E73942F0-292A-4F6A-8B2F-15AFE8634319");
- public static UUID uuidMa_M = UUID.fromString("D9F7DFFC-0E76-4790-9AAE-B7AEB5AD76ED");
- public static UUID uuidRs_N = UUID.fromString("44F262E3-5091-4D28-8081-440D3978FB0B");
- public static UUID uuidRs_B = UUID.fromString("A575D608-DD53-4C01-B2AF-5067D0711F64");
- public static UUID uuidRs_C = UUID.fromString("DA4E9CC3-B1CC-403A-81FF-BCC5D9FADBD1");
- public static UUID uuidRs_W = UUID.fromString("EFABC8FD-0B3C-475B-B532-E1CA0BA0BDBB");
- public static UUID uuidRs_E = UUID.fromString("7E0F8FA3-5DB9-48F0-9FA8-87FCAB3EAA53");
- public static UUID uuidAE = UUID.fromString("C8FCD4E0-E1A2-4A7D-8EE2-6F397F5C546C");
- public static UUID uuidAE_T = UUID.fromString("AF83B475-BB35-4594-8380-EA64B4313091");
- public static UUID uuidRs_K = UUID.fromString("2188E3A5-0446-47C8-B11B-B4B2B9A71C75");
- public static UUID uuidCc = UUID.fromString("05B0DD06-30F8-477D-BF4C-30D9DEF56320");
- public static UUID uuidBt = UUID.fromString("EE13FB74-F3AC-46B1-9F23-6A25AC504446");
- public static UUID uuidTcs = UUID.fromString("904C3980-B98D-422E-A195-95F4F41FC734");
-
-
-
- //language areas
-// public static final UUID uuidUkraineAndCrimea = UUID.fromString("99d4d1c2-09f6-416e-86a3-bdde5cae52af");
- public static final UUID uuidAzerbaijanNakhichevan = UUID.fromString("232fbef0-9f4a-4cab-8ac1-e14c717e9de6");
-
- //Marker Types
- public static final UUID uuidMisappliedCommonName = UUID.fromString("25f5cfc3-16ab-4aba-a008-0db0f2cf7f9d");
- public static final UUID uuidEurArea = UUID.fromString("71dd0368-835c-4b53-889a-2bf316e10297");
- public static final UUID uuidEurMedArea = UUID.fromString("aa6a5b25-3ee3-4771-b4d1-b91918f23fa5");
- public static final UUID uuidHiddenArea = UUID.fromString("0318c67d-e323-4e9c-bffb-bc0c7f8f9f40");
-
-
- //Extension Types
- public static final UUID uuidSpeciesExpertName = UUID.fromString("2e8153d2-7412-49e4-87e1-5c38f4c5153a");
- public static final UUID uuidExpertName = UUID.fromString("24becb79-a90c-47d3-be35-efc87bb48fd3");
-
- public static final UUID DETAIL_EXT_UUID = UUID.fromString("c3959b4f-d876-4b7a-a739-9260f4cafd1c");
- public static final UUID ID_IN_SOURCE_EXT_UUID = UUID.fromString("23dac094-e793-40a4-bad9-649fc4fcfd44");
- public static final UUID uuidIsoCode = UUID.fromString("048b8153-e3ee-451c-a72c-f1c8bc291c3e");
- public static final UUID uuidTdwgAreaCode = UUID.fromString("73ad0288-b71b-4a14-9c2e-7f81f1e64a36");
- public static final UUID uuidMclCode = UUID.fromString("aa27083a-6a96-42aa-a2f8-5541cf057067");
-
- //Area Level
- public static final UUID uuidEuroMedAreaLevelTop = UUID.fromString("190d5758-4b96-4016-9412-6dc9c36ef5fd");
- public static final UUID uuidEuroMedAreaLevelFirst = UUID.fromString("d21503e3-875e-4abc-82ec-f812e3cfea84");
- public static final UUID uuidEuroMedAreaLevelSecond = UUID.fromString("97ac0bf5-b31c-487a-8ed5-a576f46c902c");
-
- //languages
- public static final UUID uuidLangMajorcan = UUID.fromString("82d696d7-cb4e-49de-ac89-63a0e12ca766");
-
- //REFERENCES
- public static int REF_ARTICLE = 1;
- public static int REF_PART_OF_OTHER_TITLE = 2;
- public static int REF_BOOK = 3;
- public static int REF_DATABASE = 4;
- public static int REF_INFORMAL = 5;
- public static int REF_NOT_APPLICABLE = 6;
- public static int REF_WEBSITE = 7;
- public static int REF_CD = 8;
- public static int REF_JOURNAL = 9;
- public static int REF_UNKNOWN = 10;
- public static int REF_PRINT_SERIES = 55;
- public static int REF_CONFERENCE_PROCEEDINGS = 56;
- public static int REF_JOURNAL_VOLUME = 57;
-
-
-
- //NameStatus
- public static int NAME_ST_NOM_INVAL = 1;
- public static int NAME_ST_NOM_ILLEG = 2;
- public static int NAME_ST_NOM_NUD = 3;
- public static int NAME_ST_NOM_REJ = 4;
- public static int NAME_ST_NOM_REJ_PROP = 5;
- public static int NAME_ST_NOM_UTIQUE_REJ = 6;
- public static int NAME_ST_NOM_UTIQUE_REJ_PROP = 7;
- public static int NAME_ST_NOM_CONS = 8;
- public static int NAME_ST_NOM_CONS_PROP = 9;
- public static int NAME_ST_ORTH_CONS = 10;
- public static int NAME_ST_ORTH_CONS_PROP = 11;
- public static int NAME_ST_NOM_SUPERFL = 12;
- public static int NAME_ST_NOM_AMBIG = 13;
- public static int NAME_ST_NOM_PROVIS = 14;
- public static int NAME_ST_NOM_DUB = 15;
- public static int NAME_ST_NOM_NOV = 16;
- public static int NAME_ST_NOM_CONFUS = 17;
- public static int NAME_ST_NOM_ALTERN = 18;
- public static int NAME_ST_COMB_INVAL = 19;
-
-
- //NameRelationShip
- public static int NAME_REL_IS_BASIONYM_FOR = 1;
- public static int NAME_REL_IS_LATER_HOMONYM_OF = 2;
- public static int NAME_REL_IS_REPLACED_SYNONYM_FOR = 3;
- public static int NAME_REL_IS_VALIDATION_OF = 4;
- public static int NAME_REL_IS_LATER_VALIDATION_OF = 5;
- public static int NAME_REL_IS_TYPE_OF = 6;
- public static int NAME_REL_IS_CONSERVED_TYPE_OF =7;
- public static int NAME_REL_IS_REJECTED_TYPE_OF = 8;
- public static int NAME_REL_IS_FIRST_PARENT_OF = 9;
- public static int NAME_REL_IS_SECOND_PARENT_OF = 10;
- public static int NAME_REL_IS_FEMALE_PARENT_OF = 11;
- public static int NAME_REL_IS_MALE_PARENT_OF = 12;
- public static int NAME_REL_IS_CONSERVED_AGAINST =13;
- public static int NAME_REL_IS_REJECTED_IN_FAVOUR_OF = 14;
- public static int NAME_REL_IS_TREATED_AS_LATER_HOMONYM_OF = 15;
- public static int NAME_REL_IS_ORTHOGRAPHIC_VARIANT_OF = 16;
- public static int NAME_REL_IS_ALTERNATIVE_NAME_FOR = 17;
- public static int NAME_REL_HAS_SAME_TYPE_AS = 18;
- public static int NAME_REL_IS_LECTOTYPE_OF = 61;
- public static int NAME_REL_TYPE_NOT_DESIGNATED = 62;
-
- //NameFacts
- public static String NAME_FACT_PROTOLOGUE = "Protologue";
- public static String NAME_FACT_ALSO_PUBLISHED_IN = "Also published in";
- public static String NAME_FACT_BIBLIOGRAPHY = "Bibliography";
-
- //TaxonRelationShip
- public static int TAX_REL_IS_INCLUDED_IN = 1;
- public static int TAX_REL_IS_SYNONYM_OF = 2;
- public static int TAX_REL_IS_MISAPPLIED_NAME_OF = 3;
- public static int TAX_REL_IS_PROPARTE_SYN_OF = 4;
- public static int TAX_REL_IS_PARTIAL_SYN_OF = 5;
- public static int TAX_REL_IS_HETEROTYPIC_SYNONYM_OF = 6;
- public static int TAX_REL_IS_HOMOTYPIC_SYNONYM_OF = 7;
- public static int TAX_REL_IS_PROPARTE_HOMOTYPIC_SYNONYM_OF = 101;
- public static int TAX_REL_IS_PROPARTE_HETEROTYPIC_SYNONYM_OF = 102;
- public static int TAX_REL_IS_PARTIAL_HOMOTYPIC_SYNONYM_OF = 103;
- public static int TAX_REL_IS_PARTIAL_HETEROTYPIC_SYNONYM_OF = 104;
-
-
-
- //TaxonStatus
- public static int T_STATUS_ACCEPTED = 1;
- public static int T_STATUS_SYNONYM = 2;
- public static int T_STATUS_PARTIAL_SYN = 3;
- public static int T_STATUS_PRO_PARTE_SYN = 4;
- public static int T_STATUS_UNRESOLVED = 5;
- public static int T_STATUS_ORPHANED = 6;
-
-
- //Facts
- public static int FACT_DESCRIPTION = 1;
- public static int FACT_GROWTH_FORM = 2;
- public static int FACT_HARDINESS = 3;
- public static int FACT_ECOLOGY = 4;
- public static int FACT_PHENOLOGY = 5;
- public static int FACT_KARYOLOGY = 6;
- public static int FACT_ILLUSTRATION = 7;
- public static int FACT_IDENTIFICATION = 8;
- public static int FACT_OBSERVATION = 9;
- public static int FACT_DISTRIBUTION_EM = 10;
- public static int FACT_DISTRIBUTION_WORLD = 11;
- //E+M
- public static final UUID uuidFeatureMaps = UUID.fromString("8367730e-f3c3-4361-8360-a2057e4295ed");
- public static final UUID uuidFeatureConservationStatus = UUID.fromString("a32f33cd-1966-4a22-986c-94c5e688bbd1");
- public static final UUID uuidFeatureUse = UUID.fromString("199bbbd8-2db6-4335-b454-2e92ae02b699");
- public static final UUID uuidFeatureComments = UUID.fromString("31cc2b92-5cad-44e9-b50f-b8af591a527c");
- public static final UUID uuidFeatureDistrEM = UUID.fromString("a5ba7e7f-ca7f-4f50-afc7-73e76b3231d4");
- public static final UUID uuidFeatureDistrWorld = UUID.fromString("e4e24080-7017-47e6-924e-d2560fa68fb8");
- public static final UUID uuidFeatureEditorBrackets = UUID.fromString("b3b5bc1a-7ba8-4a39-9c0d-63ba599eb5d8");
- public static final UUID uuidFeatureEditorParenthesis = UUID.fromString("6ee10a2e-ff02-4cf4-a520-89630edc5b44");
- public static final UUID uuidFeatureInedited = UUID.fromString("c93e2968-bc52-4165-9755-ce37611faf01");
- public static final UUID uuidFeatureCommentsEditing = UUID.fromString("7a155021-158a-48bb-81d0-9a72b718e2de");
-
-
-
- public static UUID uuidNomStatusCombIned = UUID.fromString("dde8a2e7-bf9e-42ec-b186-d5bde9c9c128");
- public static UUID uuidNomStatusSpNovIned = UUID.fromString("1a359ca1-9364-43bc-93e4-834bdcd52b72");
- public static UUID uuidNomStatusNomOrthCons = UUID.fromString("0f838183-ffa0-4014-928e-0e3a27eb3918");
-
- static NomenclaturalStatusType nomStatusCombIned;
- static NomenclaturalStatusType nomStatusSpNovIned;
- static NomenclaturalStatusType nomStatusNomOrthCons;
-
- public static NomenclaturalStatusType nomStatusTypeAbbrev2NewNomStatusType(String nomStatus){
- NomenclaturalStatusType result = null;
- if (nomStatus == null){
- return null;
- }else if (nomStatus.equalsIgnoreCase("comb. ined.")){
- if (nomStatusCombIned == null){
- nomStatusCombIned = NomenclaturalStatusType.NewInstance("comb. ined.", "comb. ined.", "comb. ined.", Language.LATIN());
- nomStatusCombIned.setUuid(uuidNomStatusCombIned);
- NomenclaturalStatusType.ALTERNATIVE().getVocabulary().addTerm(nomStatusCombIned);
- }
- result = nomStatusCombIned;
- }else if (nomStatus.equalsIgnoreCase("sp. nov. ined.")){
- if (nomStatusSpNovIned == null){
- nomStatusSpNovIned = NomenclaturalStatusType.NewInstance("sp. nov. ined.", "sp. nov. ined.", "sp. nov. ined.", Language.LATIN());
- nomStatusSpNovIned.setUuid(uuidNomStatusSpNovIned);
- NomenclaturalStatusType.ALTERNATIVE().getVocabulary().addTerm(nomStatusSpNovIned);
- }
- result = nomStatusSpNovIned;
- }else if (nomStatus.equalsIgnoreCase("nom. & orth. cons.")){
- if (nomStatusNomOrthCons == null){
- nomStatusNomOrthCons = NomenclaturalStatusType.NewInstance("nom. & orth. cons.", "nom. & orth. cons.", "nom. & orth. cons.", Language.LATIN());
- nomStatusNomOrthCons.setUuid(uuidNomStatusNomOrthCons);
- NomenclaturalStatusType.ALTERNATIVE().getVocabulary().addTerm(nomStatusNomOrthCons);
- }
- result = nomStatusNomOrthCons;
- }
- return result;
- }
-
-
- public static NomenclaturalStatus nomStatusFkToNomStatus(int nomStatusFk, String nomStatusLabel) throws UnknownCdmTypeException{
- if (nomStatusFk == NAME_ST_NOM_INVAL){
- return NomenclaturalStatus.NewInstance(NomenclaturalStatusType.INVALID());
- }else if (nomStatusFk == NAME_ST_NOM_ILLEG){
- return NomenclaturalStatus.NewInstance(NomenclaturalStatusType.ILLEGITIMATE());
- }else if (nomStatusFk == NAME_ST_NOM_NUD){
- return NomenclaturalStatus.NewInstance(NomenclaturalStatusType.NUDUM());
- }else if (nomStatusFk == NAME_ST_NOM_REJ){
- return NomenclaturalStatus.NewInstance(NomenclaturalStatusType.REJECTED());
- }else if (nomStatusFk == NAME_ST_NOM_REJ_PROP){
- return NomenclaturalStatus.NewInstance(NomenclaturalStatusType.REJECTED_PROP());
- }else if (nomStatusFk == NAME_ST_NOM_UTIQUE_REJ){
- return NomenclaturalStatus.NewInstance(NomenclaturalStatusType.UTIQUE_REJECTED());
- }else if (nomStatusFk == NAME_ST_NOM_UTIQUE_REJ_PROP){
- return NomenclaturalStatus.NewInstance(NomenclaturalStatusType.UTIQUE_REJECTED_PROP());
- }else if (nomStatusFk == NAME_ST_NOM_CONS){
- return NomenclaturalStatus.NewInstance(NomenclaturalStatusType.CONSERVED());
- }else if (nomStatusFk == NAME_ST_NOM_CONS_PROP){
- return NomenclaturalStatus.NewInstance(NomenclaturalStatusType.CONSERVED_PROP());
- }else if (nomStatusFk == NAME_ST_ORTH_CONS){
- return NomenclaturalStatus.NewInstance(NomenclaturalStatusType.ORTHOGRAPHY_CONSERVED());
- }else if (nomStatusFk == NAME_ST_ORTH_CONS_PROP){
- return NomenclaturalStatus.NewInstance(NomenclaturalStatusType.ORTHOGRAPHY_CONSERVED_PROP());
- }else if (nomStatusFk == NAME_ST_NOM_SUPERFL){
- return NomenclaturalStatus.NewInstance(NomenclaturalStatusType.SUPERFLUOUS());
- }else if (nomStatusFk == NAME_ST_NOM_AMBIG){
- return NomenclaturalStatus.NewInstance(NomenclaturalStatusType.AMBIGUOUS());
- }else if (nomStatusFk == NAME_ST_NOM_PROVIS){
- return NomenclaturalStatus.NewInstance(NomenclaturalStatusType.PROVISIONAL());
- }else if (nomStatusFk == NAME_ST_NOM_DUB){
- return NomenclaturalStatus.NewInstance(NomenclaturalStatusType.DOUBTFUL());
- }else if (nomStatusFk == NAME_ST_NOM_NOV){
- return NomenclaturalStatus.NewInstance(NomenclaturalStatusType.NOVUM());
- }else if (nomStatusFk == NAME_ST_NOM_CONFUS){
- return NomenclaturalStatus.NewInstance(NomenclaturalStatusType.CONFUSUM());
- }else if (nomStatusFk == NAME_ST_NOM_ALTERN){
- return NomenclaturalStatus.NewInstance(NomenclaturalStatusType.ALTERNATIVE());
- }else if (nomStatusFk == NAME_ST_COMB_INVAL){
- return NomenclaturalStatus.NewInstance(NomenclaturalStatusType.COMBINATION_INVALID());
- }else {
- NomenclaturalStatusType statusType = nomStatusTypeAbbrev2NewNomStatusType(nomStatusLabel);
- NomenclaturalStatus result = NomenclaturalStatus.NewInstance(statusType);
- if (result != null){
- return result;
- }
- throw new UnknownCdmTypeException("Unknown NomenclaturalStatus (id=" + Integer.valueOf(nomStatusFk).toString() + ")");
- }
- }
-
- public static UUID getEMAreaUuid(String areaId){
- if (areaId == null){
- logger.warn("No AreaId given");
- return null;
- }else if (areaId.equals("EM")){return uuidEM;
- }else if (areaId.equals("EUR")){return uuidEUR;
- }else if (areaId.equals("14")){return uuid14;
- }else if (areaId.equals("20")){return uuid20;
- }else if (areaId.equals("21")){return uuid21;
- }else if (areaId.equals("33")){return uuid33;
- }else if (areaId.equals("Da")){return uuidDa;
- }else if (areaId.equals("Fe")){return uuidFe;
- }else if (areaId.equals("Fa")){return uuidFa;
- }else if (areaId.equals("Br")){return uuidBr;
- }else if (areaId.equals("Is")){return uuidIs;
- }else if (areaId.equals("Hb")){return uuidHb;
- }else if (areaId.equals("No")){return uuidNo;
- }else if (areaId.equals("Sb")){return uuidSb;
- }else if (areaId.equals("Su")){return uuidSu;
- }else if (areaId.equals("Au")){return uuidAu;
- }else if (areaId.equals("Be")){return uuidBe;
- }else if (areaId.equals("Cz")){return uuidCz;
- }else if (areaId.equals("Ge")){return uuidGe;
- }else if (areaId.equals("Hu")){return uuidHu;
- }else if (areaId.equals("Ho")){return uuidHo;
- }else if (areaId.equals("Po")){return uuidPo;
- }else if (areaId.equals("He")){return uuidHe;
- }else if (areaId.equals("Bl")){return uuidBl;
- }else if (areaId.equals("Co")){return uuidCo;
- }else if (areaId.equals("Ga")){return uuidGa;
- }else if (areaId.equals("Lu")){return uuidLu;
- }else if (areaId.equals("Sa")){return uuidSa;
- }else if (areaId.equals("Hs")){return uuidHs;
- }else if (areaId.equals("Al")){return uuidAl;
- }else if (areaId.equals("Bu")){return uuidBu;
- }else if (areaId.equals("Gr")){return uuidGr;
- }else if (areaId.equals("It")){return uuidIt;
- }else if (areaId.equals("Cr")){return uuidCr;
- }else if (areaId.equals("Rm")){return uuidRm;
- }else if (areaId.equals("Si(S)")){return uuidSi_S;
- }else if (areaId.equals("Tu(E)")){return uuidTu_E;
- }else if (areaId.equals("Ju")){return uuidJu;
- }else if (areaId.equals("Uk(K)")){return uuidUk_K;
- }else if (areaId.equals("Uk")){return uuidUk;
- }else if (areaId.equals("Ag")){return uuidAg;
- }else if (areaId.equals("Eg")){return uuidEg;
- }else if (areaId.equals("Li")){return uuidLi;
- }else if (areaId.equals("Ma")){return uuidMa;
- }else if (areaId.equals("Tn")){return uuidTn;
- }else if (areaId.equals("Az")){return uuidAz;
- }else if (areaId.equals("Sg")){return uuidSg;
- }else if (areaId.equals("Ab")){return uuidAb;
- }else if (areaId.equals("Ar")){return uuidAr;
- }else if (areaId.equals("Ab(A)")){return uuidAb_A;
- }else if (areaId.equals("Gg")){return uuidGg;
- }else if (areaId.equals("Ab(N)")){return uuidAb_N;
- }else if (areaId.equals("Cy")){return uuidCy;
- }else if (areaId.equals("AE(G)")){return uuidAE_G;
- }else if (areaId.equals("Le")){return uuidLe;
- }else if (areaId.equals("Sn")){return uuidSn;
- }else if (areaId.equals("Tu(A)")){return uuidTu_A;
- }else if (areaId.equals("Tu")){return uuidTu;
- }else if (areaId.equals("Au(A)")){return uuidAu_A;
- }else if (areaId.equals("Au(L)")){return uuidAu_L;
- }else if (areaId.equals("Az(C)")){return uuidAz_C;
- }else if (areaId.equals("Az(F)")){return uuidAz_F;
- }else if (areaId.equals("Az(G)")){return uuidAz_G;
- }else if (areaId.equals("Az(P)")){return uuidAz_P;
- }else if (areaId.equals("Az(S)")){return uuidAz_S;
- }else if (areaId.equals("Az(J)")){return uuidAz_J;
- }else if (areaId.equals("Az(M)")){return uuidAz_M;
- }else if (areaId.equals("Az(T)")){return uuidAz_T;
- }else if (areaId.equals("Be(B)")){return uuidBe_B;
- }else if (areaId.equals("Be(L)")){return uuidBe_L;
- }else if (areaId.equals("Bl(I)")){return uuidBl_I;
- }else if (areaId.equals("Bl(M)")){return uuidBl_M;
- }else if (areaId.equals("Bl(N)")){return uuidBl_N;
- }else if (areaId.equals("BH")){return uuidBH;
- }else if (areaId.equals("By")){return uuidBy;
- }else if (areaId.equals("Ca")){return uuidCa;
- }else if (areaId.equals("Ca(F)")){return uuidCa_F;
- }else if (areaId.equals("Ca(G)")){return uuidCa_G;
- }else if (areaId.equals("Ca(C)")){return uuidCa_C;
- }else if (areaId.equals("Ca(H)")){return uuidCa_H;
- }else if (areaId.equals("Ca(L)")){return uuidCa_L;
- }else if (areaId.equals("Ca(P)")){return uuidCa_P;
- }else if (areaId.equals("Ca(T)")){return uuidCa_T;
- }else if (areaId.equals("Cs")){return uuidCs;
- }else if (areaId.equals("Ct")){return uuidCt;
- }else if (areaId.equals("Es")){return uuidEs;
- }else if (areaId.equals("Ga(C)")){return uuidGa_C;
- }else if (areaId.equals("Ga(F)")){return uuidGa_F;
- }else if (areaId.equals("Gg(A)")){return uuidGg_A;
- }else if (areaId.equals("Gg(D)")){return uuidGg_D;
- }else if (areaId.equals("Gg(G)")){return uuidGg_G;
- }else if (areaId.equals("Hs(A)")){return uuidHs_A;
- }else if (areaId.equals("Hs(G)")){return uuidHs_G;
- }else if (areaId.equals("Hs(S)")){return uuidHs_S;
- }else if (areaId.equals("Ir")){return uuidIr;
- }else if (areaId.equals("It(I)")){return uuidIt_I;
- }else if (areaId.equals("It(S)")){return uuidIt_S;
- }else if (areaId.equals("Jo")){return uuidJo;
- }else if (areaId.equals("Kz")){return uuidKz;
- }else if (areaId.equals("La")){return uuidLa;
- }else if (areaId.equals("Lt")){return uuidLt;
- }else if (areaId.equals("Ma(E)")){return uuidMa_E;
- }else if (areaId.equals("Ma(S)")){return uuidMa_S;
- }else if (areaId.equals("Mk")){return uuidMk;
- }else if (areaId.equals("Md")){return uuidMd;
- }else if (areaId.equals("Md(D)")){return uuidMd_D;
- }else if (areaId.equals("Md(M)")){return uuidMd_M;
- }else if (areaId.equals("Md(P)")){return uuidMd_P;
- }else if (areaId.equals("Si(M)")){return uuidSi_M;
- }else if (areaId.equals("Mo")){return uuidMo;
- }else if (areaId.equals("Rf")){return uuidRf;
- }else if (areaId.equals("Rf(C)")){return uuidRf_C;
- }else if (areaId.equals("Rf(E)")){return uuidRf_E;
- }else if (areaId.equals("Rf(K)")){return uuidRf_K;
- }else if (areaId.equals("Rf(CS)")){return uuidRf_CS;
- }else if (areaId.equals("Rf(N)")){return uuidRf_N;
- }else if (areaId.equals("Rf(NW)")){return uuidRf_NW;
- }else if (areaId.equals("Rf(A)")){return uuidRf_A;
- }else if (areaId.equals("Rf(S)")){return uuidRf_S;
- }else if (areaId.equals("Sk")){return uuidSk;
- }else if (areaId.equals("Sl")){return uuidSl;
- }else if (areaId.equals("Sy")){return uuidSy;
- }else if (areaId.equals("Uk(U)")){return uuidUk_U;
- }else if (areaId.equals("SM")){return uuidSM;
- }else if (areaId.equals("Yu(K)")){return uuidYu_K;
- }else if (areaId.equals("Cg")){return uuidCg;
- }else if (areaId.equals("Sr")){return uuidSr;
- }else if (areaId.equals("IJ")){return uuidIJ;
- }else if (areaId.equals("LS")){return uuidLS;
- }else if (areaId.equals("Rs")){return uuidRs;
- }else if (areaId.equals("Si")){return uuidSi;
- }else if (areaId.equals("Az(L)")){return uuidAz_L;
- }else if (areaId.equals("Hb(E)")){return uuidHb_E;
- }else if (areaId.equals("Hb(N)")){return uuidHb_N;
- }else if (areaId.equals("Ga(M)")){return uuidGa_M;
- }else if (areaId.equals("Ma(M)")){return uuidMa_M;
- }else if (areaId.equals("Rs(N)")){return uuidRs_N;
- }else if (areaId.equals("Rs(B)")){return uuidRs_B;
- }else if (areaId.equals("Rs(C)")){return uuidRs_C;
- }else if (areaId.equals("Rs(W)")){return uuidRs_W;
- }else if (areaId.equals("Rs(E)")){return uuidRs_E;
- }else if (areaId.equals("AE")){return uuidAE;
- }else if (areaId.equals("AE(T)")){return uuidAE_T;
- }else if (areaId.equals("Rs(K)")){return uuidRs_K;
- }else if (areaId.equals("Cc")){return uuidCc;
- }else if (areaId.equals("Bt")){return uuidBt;
- }else if (areaId.equals("Tcs")){return uuidTcs;
- }else{
- logger.warn("Area not found: " + areaId);
- return null;
- }
-
- }
-
-
- //TypeDesignation
- public static SpecimenTypeDesignationStatus typeStatusId2TypeStatus (int typeStatusId) throws UnknownCdmTypeException{
- switch (typeStatusId){
- case 0: return null;
- case 1: return SpecimenTypeDesignationStatus.HOLOTYPE();
- case 2: return SpecimenTypeDesignationStatus.LECTOTYPE();
- case 3: return SpecimenTypeDesignationStatus.NEOTYPE();
- case 4: return SpecimenTypeDesignationStatus.EPITYPE();
- case 5: return SpecimenTypeDesignationStatus.ISOLECTOTYPE();
- case 6: return SpecimenTypeDesignationStatus.ISONEOTYPE();
- case 7: return SpecimenTypeDesignationStatus.ISOTYPE();
- case 8: return SpecimenTypeDesignationStatus.PARANEOTYPE();
- case 9: return SpecimenTypeDesignationStatus.PARATYPE();
- case 10: return SpecimenTypeDesignationStatus.SECOND_STEP_LECTOTYPE();
- case 11: return SpecimenTypeDesignationStatus.SECOND_STEP_NEOTYPE();
- case 12: return SpecimenTypeDesignationStatus.SYNTYPE();
- case 21: return SpecimenTypeDesignationStatus.ICONOTYPE();
- case 22: return SpecimenTypeDesignationStatus.PHOTOTYPE();
- default: {
- throw new UnknownCdmTypeException("Unknown TypeDesignationStatus (id=" + Integer.valueOf(typeStatusId).toString() + ")");
- }
- }
- }
-
- //TypeDesignation
- public static TaxonRelationshipType taxonRelId2TaxonRelType (int relTaxonTypeId, ResultWrapper<Boolean> isInverse, ResultWrapper<Boolean> isDoubtful) throws UnknownCdmTypeException{
- isInverse.setValue(false);
- switch (relTaxonTypeId){
- case 0: return null;
- case 11: return TaxonRelationshipType.CONGRUENT_TO();
- case 12: isInverse.setValue(true); return TaxonRelationshipType.INCLUDES();
- case 13: isInverse.setValue(true); return TaxonRelationshipType.CONGRUENT_OR_INCLUDES();
- case 14: return TaxonRelationshipType.INCLUDES();
- case 15: return TaxonRelationshipType.CONGRUENT_OR_INCLUDES();
- case 16: return TaxonRelationshipType.INCLUDED_OR_INCLUDES();
- case 17: return TaxonRelationshipType.CONGRUENT_OR_INCLUDED_OR_INCLUDES();
- case 18: return TaxonRelationshipType.OVERLAPS();
- case 19: return TaxonRelationshipType.CONGRUENT_OR_OVERLAPS();
- case 20: isInverse.setValue(true); return TaxonRelationshipType.INCLUDES_OR_OVERLAPS();
- case 21: isInverse.setValue(true); return TaxonRelationshipType.CONGRUENT_OR_INCLUDES_OR_OVERLAPS();
- case 22: return TaxonRelationshipType.INCLUDES_OR_OVERLAPS();
- case 23: return TaxonRelationshipType.CONGRUENT_OR_INCLUDES_OR_OVERLAPS();
- case 24: return TaxonRelationshipType.INCLUDED_OR_INCLUDES_OR_OVERLAPS();
-
- case 26: return TaxonRelationshipType.EXCLUDES();
-
- //TODO other relationshipTypes
-
- case 40: return TaxonRelationshipType.NOT_CONGRUENT_TO();
-
- //how to implement this, what is a purely doubtful relationship ??
-// case 42: isDoubtful.setValue(true); return TaxonRelationshipType.();
-
- case 43: isDoubtful.setValue(true); return TaxonRelationshipType.CONGRUENT_TO();
- case 44: isInverse.setValue(true);isDoubtful.setValue(true); return TaxonRelationshipType.INCLUDES();
- case 46: isDoubtful.setValue(true); return TaxonRelationshipType.INCLUDES();
- case 48: isDoubtful.setValue(true); return TaxonRelationshipType.INCLUDED_OR_INCLUDES();
- case 50: isDoubtful.setValue(true); return TaxonRelationshipType.OVERLAPS();
- case 51: isDoubtful.setValue(true); return TaxonRelationshipType.CONGRUENT_OR_OVERLAPS();
- case 58: isDoubtful.setValue(true); return TaxonRelationshipType.EXCLUDES();
-
-
- default: {
- throw new UnknownCdmTypeException("Unknown TypeDesignationStatus (id=" + Integer.valueOf(relTaxonTypeId).toString() + ")");
- }
- }
- }
-
- //TypeDesignation
- public static HybridRelationshipType relNameId2HybridRel (int relNameId) throws UnknownCdmTypeException{
- switch (relNameId){
- case 0: return null;
- case 9: return HybridRelationshipType.FIRST_PARENT();
- case 10: return HybridRelationshipType.SECOND_PARENT();
- case 11: return HybridRelationshipType.FEMALE_PARENT();
- case 12: return HybridRelationshipType.MALE_PARENT();
- default: {
- throw new UnknownCdmTypeException("Unknown HybridRelationshipType (id=" + Integer.valueOf(relNameId).toString() + ")");
- }
- }
- }
-
- //OccStatus
- public static PresenceAbsenceTerm occStatus2PresenceAbsence (int occStatusId) throws UnknownCdmTypeException{
- switch (occStatusId){
- case 0: return null;
- case 110: return PresenceAbsenceTerm.CULTIVATED_REPORTED_IN_ERROR();
- case 120: return PresenceAbsenceTerm.CULTIVATED();
- case 210: return PresenceAbsenceTerm.INTRODUCED_REPORTED_IN_ERROR();
- case 220: return PresenceAbsenceTerm.INTRODUCED_PRESENCE_QUESTIONABLE();
- case 230: return PresenceAbsenceTerm.INTRODUCED_FORMERLY_INTRODUCED();
- case 240: return PresenceAbsenceTerm.INTRODUCED_DOUBTFULLY_INTRODUCED();
- case 250: return PresenceAbsenceTerm.INTRODUCED();
- case 260: return PresenceAbsenceTerm.INTRODUCED_UNCERTAIN_DEGREE_OF_NATURALISATION();
- case 270: return PresenceAbsenceTerm.INTRODUCED_ADVENTITIOUS();
- case 280: return PresenceAbsenceTerm.INTRODUCED_NATURALIZED();
- case 310: return PresenceAbsenceTerm.NATIVE_REPORTED_IN_ERROR();
- case 320: return PresenceAbsenceTerm.NATIVE_PRESENCE_QUESTIONABLE();
- case 330: return PresenceAbsenceTerm.NATIVE_FORMERLY_NATIVE();
- case 340: return PresenceAbsenceTerm.NATIVE_DOUBTFULLY_NATIVE();
- case 350: return PresenceAbsenceTerm.NATIVE();
- case 999: {
- logger.info("endemic for EM can not be transformed in legal status. Used 'PRESENT' instead");
- //TODO preliminary
- return PresenceAbsenceTerm.PRESENT();
- }
- default: {
- throw new UnknownCdmTypeException("Unknown occurrence status (id=" + Integer.valueOf(occStatusId).toString() + ")");
- }
- }
- }
-
-
- //FactCategory
- public static Feature factCategory2Feature (int factCategoryId) throws UnknownCdmTypeException{
- switch (factCategoryId){
- case 0: return null;
- case 1: return Feature.DESCRIPTION();
- case 4: return Feature.ECOLOGY();
- case 5: return Feature.PHENOLOGY();
- case 12: return Feature.COMMON_NAME();
- case 13: return Feature.OCCURRENCE();
- case 99: return Feature.CITATION();
- default: {
- throw new UnknownCdmTypeException("Unknown FactCategory (id=" + Integer.valueOf(factCategoryId).toString() + ")");
- }
- }
- }
-
- public static UUID getFeatureUuid(String key) throws UndefinedTransformerMethodException {
- if (key == null){
- return null;
- }else if (key.equalsIgnoreCase("14-Maps")){ return uuidFeatureMaps;
- }else if (key.equalsIgnoreCase("301-Conservation Status")){ return uuidFeatureConservationStatus;
- }else if (key.equalsIgnoreCase("302-Use")){ return uuidFeatureUse;
- }else if (key.equalsIgnoreCase("303-Comments")){ return uuidFeatureComments;
-
- }else if (key.equalsIgnoreCase("10-general distribution (Euro+Med)")){ return uuidFeatureDistrEM;
- }else if (key.equalsIgnoreCase("11-general distribution (world)")){ return uuidFeatureDistrWorld;
- }else if (key.equalsIgnoreCase("250-Editor_Brackets")){ return uuidFeatureEditorBrackets;
- }else if (key.equalsIgnoreCase("251-Editor_Parenthesis")){ return uuidFeatureEditorParenthesis;
- }else if (key.equalsIgnoreCase("252-Inedited")){ return uuidFeatureInedited;
- }else if (key.equalsIgnoreCase("253-Comments on editing process")){ return uuidFeatureCommentsEditing;
-
- }else{
- return null;
- }
- }
-
-
- static Rank collSpeciesRank;
- /**
- * @param i
- * @return
- */
- private static Rank rankId2NewRank(Integer rankId, boolean switchRank) {
- Rank result = null;
- if (rankId == null){
- return null;
- }else if (rankId == 57){
-
- if (collSpeciesRank == null){
- collSpeciesRank = Rank.NewInstance(RankClass.SpeciesGroup, "Collective species", "Coll. species", "coll.");
- collSpeciesRank.setUuid(uuidRankCollSpecies);
- OrderedTermVocabulary<Rank> voc = (OrderedTermVocabulary<Rank>)Rank.SPECIES().getVocabulary();
- voc.addTermBelow(collSpeciesRank, Rank.SPECIESGROUP());
- }
- result = collSpeciesRank;
- }
- return result;
- }
-
-
- public static Rank rankId2Rank (ResultSet rs, boolean useUnknown, boolean switchSpeciesGroup) throws UnknownCdmTypeException{
- Rank result;
- try {
- int rankId = rs.getInt("rankFk");
-
- String abbrev = rs.getString("rankAbbrev");
- String rankName = rs.getString("rank");
- if (logger.isDebugEnabled()){logger.debug(rankId);}
- if (logger.isDebugEnabled()){logger.debug(abbrev);}
- if (logger.isDebugEnabled()){logger.debug(rankName);}
-
- if (switchSpeciesGroup){
- if (rankId == 59){
- rankId = 57;
- }else if (rankId == 57){
- rankId = 59;
- }
- }
- try {
- result = Rank.getRankByNameOrIdInVoc(abbrev);
- } catch (UnknownCdmTypeException e) {
- try {
- result = Rank.getRankByNameOrIdInVoc(rankName);
- } catch (UnknownCdmTypeException e1) {
- switch (rankId){
- case 0: return null;
- case 1: return Rank.KINGDOM();
- case 3: return Rank.SUBKINGDOM();
- case 5: return Rank.PHYLUM();
- case 7: return Rank.SUBPHYLUM();
- case 8: return Rank.DIVISION();
- case 9: return Rank.SUBDIVISION();
- case 10: return Rank.CLASS();
- case 13: return Rank.SUBCLASS();
- case 16: return Rank.SUPERORDER();
- case 18: return Rank.ORDER();
- case 19: return Rank.SUBORDER();
- case 20: return Rank.FAMILY();
- case 25: return Rank.SUBFAMILY();
- case 30: return Rank.TRIBE();
- case 35: return Rank.SUBTRIBE();
- case 40: return Rank.GENUS();
- case 42: return Rank.SUBGENUS();
- case 45: return Rank.SECTION_BOTANY();
- case 47: return Rank.SUBSECTION_BOTANY();
- case 50: return Rank.SERIES();
- case 52: return Rank.SUBSERIES();
- case 58: return Rank.SPECIESAGGREGATE();
- case 59: return Rank.SPECIESGROUP();
- case 60: return Rank.SPECIES();
- case 61: return Rank.GREX();
- case 65: return Rank.SUBSPECIES();
- case 66: {System.out.println("Rank 66 not yet implemented"); throw new UnknownCdmTypeException("Unknown Rank id" + Integer.valueOf(rankId).toString());}
- case 67: {System.out.println("Rank 67 not yet implemented"); throw new UnknownCdmTypeException("Unknown Rank id" + Integer.valueOf(rankId).toString());}
- case 68: return Rank.CONVAR();
- case 70: return Rank.VARIETY();
- case 73: return Rank.SUBVARIETY();
- case 80: return Rank.FORM();
- case 82: return Rank.SUBFORM();
- case 84: return Rank.SPECIALFORM();
- case 98: return Rank.INFRAGENERICTAXON();
- case 99: return Rank.INFRASPECIFICTAXON();
-
- case 750: return Rank.SUPERCLASS();
- case 780: return Rank.INFRACLASS();
- case 820: return Rank.INFRAORDER();
-
- case 830: return Rank.SUPERFAMILY();
-
- default: {
- Rank rank = rankId2NewRank(57, switchSpeciesGroup);
- if (rank != null){
- return rank;
- }
- if (useUnknown){
- logger.error("Rank unknown: " + rankId + ". Created UNKNOWN_RANK");
- return Rank.UNKNOWN_RANK();
- }
- throw new UnknownCdmTypeException("Unknown Rank id" + Integer.valueOf(rankId).toString());
- }
- }
- }
- }
- return result;
- } catch (SQLException e) {
- e.printStackTrace();
- logger.warn("Exception occurred. Created UNKNOWN_RANK instead");
- return Rank.UNKNOWN_RANK();
- }
- }
-
-
- public static Integer rank2RankId (Rank rank){
- if (rank == null){
- return null;
- }
- else if (rank.equals(Rank.KINGDOM())){ return 1;}
- else if (rank.equals(Rank.SUBKINGDOM())){ return 3;}
- else if (rank.equals(Rank.PHYLUM())){ return 5;}
- else if (rank.equals(Rank.SUBPHYLUM())){ return 7;}
- else if (rank.equals(Rank.DIVISION())){ return 8;}
- else if (rank.equals(Rank.SUBDIVISION())){ return 9;}
-
- else if (rank.equals(Rank.CLASS())){ return 10;}
- else if (rank.equals(Rank.SUBCLASS())){ return 13;}
- else if (rank.equals(Rank.SUPERORDER())){ return 16;}
- else if (rank.equals(Rank.ORDER())){ return 18;}
- else if (rank.equals(Rank.SUBORDER())){ return 19;}
- else if (rank.equals(Rank.FAMILY())){ return 20;}
- else if (rank.equals(Rank.SUBFAMILY())){ return 25;}
- else if (rank.equals(Rank.TRIBE())){ return 30;}
- else if (rank.equals(Rank.SUBTRIBE())){ return 35;}
- else if (rank.equals(Rank.GENUS())){ return 40;}
- else if (rank.equals(Rank.SUBGENUS())){ return 42;}
- else if (rank.equals(Rank.SECTION_BOTANY())){ return 45;}
- else if (rank.equals(Rank.SUBSECTION_BOTANY())){ return 47;}
- else if (rank.equals(Rank.SERIES())){ return 50;}
- else if (rank.equals(Rank.SUBSERIES())){ return 52;}
- else if (rank.equals(Rank.SPECIESAGGREGATE())){ return 58;}
- //TODO
- // else if (rank.equals(Rank.XXX())){ return 59;}
- else if (rank.equals(Rank.SPECIES())){ return 60;}
- else if (rank.equals(Rank.SUBSPECIES())){ return 65;}
- else if (rank.equals(Rank.CONVAR())){ return 68;}
- else if (rank.equals(Rank.VARIETY())){ return 70;}
- else if (rank.equals(Rank.SUBVARIETY())){ return 73;}
- else if (rank.equals(Rank.FORM())){ return 80;}
- else if (rank.equals(Rank.SUBFORM())){ return 82;}
- else if (rank.equals(Rank.SPECIALFORM())){ return 84;}
- else if (rank.equals(Rank.INFRAGENERICTAXON())){ return 98;}
- else if (rank.equals(Rank.INFRASPECIFICTAXON())){ return 99;}
-
- else if (rank.equals(Rank.SUPERCLASS())){ return 750;}
- else if (rank.equals(Rank.INFRACLASS())){ return 780;}
- else if (rank.equals(Rank.INFRAORDER())){ return 820;}
- else if (rank.equals(Rank.SUPERFAMILY())){ return 830;}
-
- else {
- //TODO Exception
- logger.warn("Rank not yet supported in Berlin Model: "+ rank.getLabel());
- return null;
- }
- }
-
- public static Integer textData2FactCategoryFk (Feature feature){
- if (feature == null){return null;}
- if (feature.equals(Feature.DESCRIPTION())){
- return 1;
- }else if (feature.equals(Feature.ECOLOGY())){
- return 4;
- }else if (feature.equals(Feature.PHENOLOGY())){
- return 5;
- }else if (feature.equals(Feature.COMMON_NAME())){
- return 12;
- }else if (feature.equals(Feature.OCCURRENCE())){
- return 13;
- }else if (feature.equals(Feature.CITATION())){
- return 99;
- }else{
- logger.debug("Unknown Feature.");
- return null;
- }
- }
-
-
- public static Integer taxonBase2statusFk (TaxonBase<?> taxonBase){
- if (taxonBase == null){return null;}
- if (taxonBase.isInstanceOf(Taxon.class)){
- return T_STATUS_ACCEPTED;
- }else if (taxonBase.isInstanceOf(Synonym.class)){
- return T_STATUS_SYNONYM;
- }else{
- logger.warn("Unknown ");
- return T_STATUS_UNRESOLVED;
- }
- //TODO
-// public static int T_STATUS_PARTIAL_SYN = 3;
-// public static int T_STATUS_PRO_PARTE_SYN = 4;
-// public static int T_STATUS_UNRESOLVED = 5;
-// public static int T_STATUS_ORPHANED = 6;
- }
-
- public static Integer ref2refCategoryId (Reference<?> ref){
- if (ref == null){
- return null;
- }
- else if (ref.getType().equals(ReferenceType.Article)){ return REF_ARTICLE;}
- else if (ref instanceof ISection){ return REF_PART_OF_OTHER_TITLE;}
- else if (ref.getType().equals(ReferenceType.Book)){ return REF_BOOK;}
- else if (ref.getType().equals(ReferenceType.Database)){ return REF_DATABASE;}
-// else if (ref instanceof SectionBas){ return REF_INFORMAL;}
-// else if (ref instanceof SectionBas){ return REF_NOT_APPLICABLE;}
- else if (ref.getType().equals(ReferenceType.WebPage)){ return REF_WEBSITE;}
- else if (ref.getType().equals(ReferenceType.CdDvd)){ return REF_CD;}
- else if (ref.getType().equals(ReferenceType.Journal)){ return REF_JOURNAL;}
- else if (ref.getType().equals(ReferenceType.Generic)){ return REF_UNKNOWN;}
- else if (ref.getType().equals(ReferenceType.PrintSeries)){
- logger.warn("Print Series is not a standard Berlin Model category");
- return REF_PRINT_SERIES;
- }
- else if (ref.getType().equals(ReferenceType.Proceedings)){
- logger.warn("Proceedings is not a standard Berlin Model category");
- return REF_CONFERENCE_PROCEEDINGS;
- }
-// else if (ref instanceof ){ return REF_JOURNAL_VOLUME;}
- else if (ref.getType().equals(ReferenceType.Patent)){ return REF_NOT_APPLICABLE;}
- else if (ref.getType().equals(ReferenceType.PersonalCommunication)){ return REF_INFORMAL;}
- else if (ref.getType().equals(ReferenceType.Report)){ return REF_NOT_APPLICABLE;}
- else if (ref.getType().equals(ReferenceType.Thesis)){ return REF_NOT_APPLICABLE;}
- else if (ref.getType().equals(ReferenceType.Report)){ return REF_NOT_APPLICABLE;}
-
- else {
- //TODO Exception
- logger.warn("Reference type not yet supported in Berlin Model: "+ ref.getClass().getSimpleName());
- return null;
- }
- }
-
-
- public static Integer taxRelation2relPtQualifierFk (RelationshipBase<?,?,?> rel){
- if (rel == null){
- return null;
- }
-// else if (rel instanceof SynonymRelationship){
-// return ;
-// }else if (rel instanceof TaxonRelationship){
- RelationshipTermBase<?> type = rel.getType();
- if (type.equals(TaxonRelationshipType.TAXONOMICALLY_INCLUDED_IN())) {return TAX_REL_IS_INCLUDED_IN;
- }else if (type.equals(TaxonRelationshipType.MISAPPLIED_NAME_FOR())) {return TAX_REL_IS_MISAPPLIED_NAME_OF;
- }else if (type.equals(SynonymRelationshipType.SYNONYM_OF())) {return TAX_REL_IS_SYNONYM_OF;
- }else if (type.equals(SynonymRelationshipType.HOMOTYPIC_SYNONYM_OF())) {return TAX_REL_IS_HOMOTYPIC_SYNONYM_OF;
- }else if (type.equals(SynonymRelationshipType.HETEROTYPIC_SYNONYM_OF())) {return TAX_REL_IS_HETEROTYPIC_SYNONYM_OF;
- }else if (type.equals(TaxonRelationshipType.CONGRUENT_TO())) {return 11;
-// public static int TAX_REL_IS_PROPARTE_SYN_OF = 4;
-// public static int TAX_REL_IS_PARTIAL_SYN_OF = 5;
-// public static int TAX_REL_IS_PROPARTE_HOMOTYPIC_SYNONYM_OF = 101;
-// public static int TAX_REL_IS_PROPARTE_HETEROTYPIC_SYNONYM_OF = 102;
-// public static int TAX_REL_IS_PARTIAL_HOMOTYPIC_SYNONYM_OF = 103;
-// public static int TAX_REL_IS_PARTIAL_HETEROTYPIC_SYNONYM_OF = 104;
-
- }else {
- //TODO Exception
- logger.warn("Relationship type not yet supported by Berlin Model export: "+ rel.getType());
- return null;
- }
- }
-
- public static Integer nomStatus2nomStatusFk (NomenclaturalStatusType status){
- if (status == null){
- return null;
- }
- if (status.equals(NomenclaturalStatusType.INVALID())) {return NAME_ST_NOM_INVAL;
- }else if (status.equals(NomenclaturalStatusType.ILLEGITIMATE())) {return NAME_ST_NOM_ILLEG;
- }else if (status.equals(NomenclaturalStatusType.NUDUM())) {return NAME_ST_NOM_NUD;
- }else if (status.equals(NomenclaturalStatusType.REJECTED())) {return NAME_ST_NOM_REJ;
- }else if (status.equals(NomenclaturalStatusType.REJECTED_PROP())) {return NAME_ST_NOM_REJ_PROP;
- }else if (status.equals(NomenclaturalStatusType.UTIQUE_REJECTED())) {return NAME_ST_NOM_UTIQUE_REJ;
- }else if (status.equals(NomenclaturalStatusType.UTIQUE_REJECTED_PROP())) {return NAME_ST_NOM_UTIQUE_REJ_PROP;
- }else if (status.equals(NomenclaturalStatusType.CONSERVED())) {return NAME_ST_NOM_CONS;
-
- }else if (status.equals(NomenclaturalStatusType.CONSERVED_PROP())) {return NAME_ST_NOM_CONS_PROP;
- }else if (status.equals(NomenclaturalStatusType.ORTHOGRAPHY_CONSERVED())) {return NAME_ST_ORTH_CONS;
- }else if (status.equals(NomenclaturalStatusType.ORTHOGRAPHY_CONSERVED_PROP())) {return NAME_ST_ORTH_CONS_PROP;
- }else if (status.equals(NomenclaturalStatusType.SUPERFLUOUS())) {return NAME_ST_NOM_SUPERFL;
- }else if (status.equals(NomenclaturalStatusType.AMBIGUOUS())) {return NAME_ST_NOM_AMBIG;
- }else if (status.equals(NomenclaturalStatusType.PROVISIONAL())) {return NAME_ST_NOM_PROVIS;
- }else if (status.equals(NomenclaturalStatusType.DOUBTFUL())) {return NAME_ST_NOM_DUB;
- }else if (status.equals(NomenclaturalStatusType.NOVUM())) {return NAME_ST_NOM_NOV;
-
- }else if (status.equals(NomenclaturalStatusType.CONFUSUM())) {return NAME_ST_NOM_CONFUS;
- }else if (status.equals(NomenclaturalStatusType.ALTERNATIVE())) {return NAME_ST_NOM_ALTERN;
- }else if (status.equals(NomenclaturalStatusType.COMBINATION_INVALID())) {return NAME_ST_COMB_INVAL;
- //TODO
- }else {
- //TODO Exception
- logger.warn("NomStatus type not yet supported by Berlin Model export: "+ status);
- return null;
- }
- }
-
-
-
- public static Integer nameRel2RelNameQualifierFk (RelationshipBase<?,?,?> rel){
- if (rel == null){
- return null;
- }
- RelationshipTermBase<?> type = rel.getType();
- if (type.equals(NameRelationshipType.BASIONYM())) {return NAME_REL_IS_BASIONYM_FOR;
- }else if (type.equals(NameRelationshipType.LATER_HOMONYM())) {return NAME_REL_IS_LATER_HOMONYM_OF;
- }else if (type.equals(NameRelationshipType.REPLACED_SYNONYM())) {return NAME_REL_IS_REPLACED_SYNONYM_FOR;
- //TODO
- }else if (type.equals(NameRelationshipType.VALIDATED_BY_NAME())) {return NAME_REL_IS_VALIDATION_OF;
- }else if (type.equals(NameRelationshipType.LATER_VALIDATED_BY_NAME())) {return NAME_REL_IS_LATER_VALIDATION_OF;
- }else if (type.equals(NameRelationshipType.CONSERVED_AGAINST())) {return NAME_REL_IS_CONSERVED_AGAINST;
-
-
- }else if (type.equals(NameRelationshipType.TREATED_AS_LATER_HOMONYM())) {return NAME_REL_IS_TREATED_AS_LATER_HOMONYM_OF;
- }else if (type.equals(NameRelationshipType.ORTHOGRAPHIC_VARIANT())) {return NAME_REL_IS_ORTHOGRAPHIC_VARIANT_OF;
- }else {
- //TODO Exception
- logger.warn("Relationship type not yet supported by Berlin Model export: "+ rel.getType());
- return null;
- }
-
- //NameRelationShip
-
-// }else if (type.equals(NameRelationshipType.())) {return NAME_REL_IS_REJECTED_IN_FAVOUR_OF;
-
-// public static int NAME_REL_IS_FIRST_PARENT_OF = 9;
-// public static int NAME_REL_IS_SECOND_PARENT_OF = 10;
-// public static int NAME_REL_IS_FEMALE_PARENT_OF = 11;
-// public static int NAME_REL_IS_MALE_PARENT_OF = 12;
-//
-// public static int NAME_REL_IS_REJECTED_IN_FAVOUR_OF = 14;
-// }else if (type.equals(NameRelationshipType.)) {return NAME_REL_IS_REJECTED_TYPE_OF;
-//
-// public static int NAME_REL_HAS_SAME_TYPE_AS = 18;
-// public static int NAME_REL_IS_LECTOTYPE_OF = 61;
-// public static int NAME_REL_TYPE_NOT_DESIGNATED = 62;
-
- // }else if (type.equals(NameRelationshipType.LATER_VALIDATED_BY_NAME())) {return NAME_REL_IS_TYPE_OF;
-
-
- }
-
- public static UUID getWebMarkerUuid (int markerCategoryId){
- if (markerCategoryId == 1){
- return UUID.fromString("d8554418-d1ae-471d-a1bd-a0cbc7ab860c"); //any as not to find in cichorieae
- }else if (markerCategoryId == 2){
- return UUID.fromString("7f189c48-8632-4870-9ec8-e4d2489f324e");
- }else if (markerCategoryId == 3){
- return UUID.fromString("9a115e6b-8210-4dd3-825a-6fed11016c63");
- }else if (markerCategoryId == 4){
- return UUID.fromString("1d287011-2054-41c5-a919-17ac1d0a9270");
- }else if (markerCategoryId == 9){
- return UUID.fromString("cc5eca5c-1ae5-4feb-9a95-507fc167b0c9");
- //Salvador
- }else if (markerCategoryId == 5){
- return UUID.fromString("7d8875b3-107c-4189-97e5-cadb470e543a");
- }else if (markerCategoryId == 20){
- return UUID.fromString("3574e2b0-6431-4d71-b456-bc967c80f622");
- }else if (markerCategoryId == 30){
- return UUID.fromString("9924b27e-0dbe-4d95-ae9b-096fbbc3edcb");
- }else if (markerCategoryId == 40){
- return UUID.fromString("69241b97-f4d2-4f60-9aed-1c4ccb5bced5");
- }else if (markerCategoryId == 50){
- return UUID.fromString("f3b62ce3-0212-4542-a74c-0c68d08859b1");
- }else if (markerCategoryId == 55){
- return UUID.fromString("bec822f2-8242-425f-ad46-f11f0b82f69b");
- }else if (markerCategoryId == 60){
- return UUID.fromString("722fca60-0416-4bf0-aa4b-a07400f9710d");
- }else if (markerCategoryId == 70){
- return UUID.fromString("ed57857b-1001-4b09-b48e-d88ab146bb2b");
- }else if (markerCategoryId == 80){
- return UUID.fromString("637e8b77-1202-462b-9d77-1023f3c192d9");
- }else if (markerCategoryId == 90){
- return UUID.fromString("c769c231-6e76-46df-88f7-2c459342a3c2");
- }else if (markerCategoryId == 93){
- return UUID.fromString("075ee97e-246f-4f3d-aa96-16930df6268c");
- }else if (markerCategoryId == 100){
- return UUID.fromString("e17065bf-3e44-417a-b05c-f82929f680c3");
- }else if (markerCategoryId == 110){
- return UUID.fromString("e2b8de07-770e-4fda-b445-c4735f4e95c8");
- }else if (markerCategoryId == 900){
- return UUID.fromString("d029c3c9-944a-4bb9-bba6-12c95da94a04");
- }else if (markerCategoryId == 920){
- return UUID.fromString("98af97b1-e5e3-4ee4-902e-15032316bfc3");
- }else if (markerCategoryId == 930){
- return UUID.fromString("4b6c3130-4e50-4f45-8461-d2698cf5f80b");
- }else if (markerCategoryId == 950){
- return UUID.fromString("1e53f58c-6528-42c6-99ae-0f75a3c3c264");
- }else if (markerCategoryId == 960){
- return UUID.fromString("1903d460-94cc-4fc4-b2a8-a3fb0cfd69a0");
- }else{
- logger.warn("Unknown webMarker category: " + markerCategoryId);
- return null;
- }
-
- }
-
-}
+/**\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.berlinModel;\r
+\r
+import java.sql.ResultSet;\r
+import java.sql.SQLException;\r
+import java.util.UUID;\r
+\r
+import org.apache.log4j.Logger;\r
+\r
+import eu.etaxonomy.cdm.common.ResultWrapper;\r
+import eu.etaxonomy.cdm.io.common.mapping.UndefinedTransformerMethodException;\r
+import eu.etaxonomy.cdm.model.common.Language;\r
+import eu.etaxonomy.cdm.model.common.OrderedTermVocabulary;\r
+import eu.etaxonomy.cdm.model.common.RelationshipBase;\r
+import eu.etaxonomy.cdm.model.common.RelationshipTermBase;\r
+import eu.etaxonomy.cdm.model.description.Feature;\r
+import eu.etaxonomy.cdm.model.description.PresenceAbsenceTerm;\r
+import eu.etaxonomy.cdm.model.name.HybridRelationshipType;\r
+import eu.etaxonomy.cdm.model.name.NameRelationshipType;\r
+import eu.etaxonomy.cdm.model.name.NomenclaturalStatus;\r
+import eu.etaxonomy.cdm.model.name.NomenclaturalStatusType;\r
+import eu.etaxonomy.cdm.model.name.Rank;\r
+import eu.etaxonomy.cdm.model.name.RankClass;\r
+import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignationStatus;\r
+import eu.etaxonomy.cdm.model.reference.ISection;\r
+import eu.etaxonomy.cdm.model.reference.Reference;\r
+import eu.etaxonomy.cdm.model.reference.ReferenceType;\r
+import eu.etaxonomy.cdm.model.taxon.Synonym;\r
+import eu.etaxonomy.cdm.model.taxon.SynonymRelationshipType;\r
+import eu.etaxonomy.cdm.model.taxon.Taxon;\r
+import eu.etaxonomy.cdm.model.taxon.TaxonBase;\r
+import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;\r
+import eu.etaxonomy.cdm.strategy.exceptions.UnknownCdmTypeException;\r
+\r
+/**\r
+ * @author a.mueller\r
+ * @created 20.03.2008\r
+ */\r
+public class BerlinModelTransformer {\r
+ private static final Logger logger = Logger.getLogger(BerlinModelTransformer.class);\r
+\r
+ //source Refs\r
+ public static final UUID uuidSourceRefEuroMed = UUID.fromString("0603a84a-f024-4454-ab92-9e2ac0139126");\r
+\r
+ //ranks\r
+ public static UUID uuidRankCollSpecies = UUID.fromString("e14630ee-9446-4bb4-a7b7-4c3881bc5d94");\r
+ public static UUID uuidRankProles = UUID.fromString("8810d1ba-6a34-4ae3-a355-919ccd1cd1a5");\r
+ public static UUID uuidRankRace = UUID.fromString("196dee39-cfd8-4460-8bf0-88b83da27f62");\r
+ public static UUID uuidRankSublusus = UUID.fromString("1fafa596-a8e7-4e62-a378-3cc8cb3627ca");\r
+\r
+ //named areas\r
+ public static UUID euroMedUuid = UUID.fromString("9fe09988-58c0-4c06-8474-f660a0c50014");\r
+\r
+ public static UUID uuidEasternEuropeanRussia = UUID.fromString("3f013375-0e0a-40c3-8a14-84c0535fab40");\r
+ public static UUID uuidSerbiaMontenegro = UUID.fromString("8926dbe6-863e-47a9-98a0-7dc9ed2c57f7");\r
+ public static UUID uuidSerbia = UUID.fromString("4ffed197-3d7e-4cd9-8984-e64b8dee9512");\r
+ public static UUID uuidLebanonSyria = UUID.fromString("0c45f250-99da-4b19-aa89-c3e56cfdf103");\r
+ public static UUID uuidUssr = UUID.fromString("a512e00a-45f3-4be5-82fa-bba8d675696f");\r
+ public static UUID uuidSicilyMalta = UUID.fromString("424d81ee-d272-4ae8-9600-0a334049cd72");\r
+\r
+ public static UUID uuidDesertas = UUID.fromString("36f5e93e-34e8-45b5-a401-f0e0faad21cf");\r
+ public static UUID uuidMadeira = UUID.fromString("086e27ee-78ff-4236-aca9-9850850cd355");\r
+ public static UUID uuidPortoSanto = UUID.fromString("1f9ab6a0-a402-4dfe-8c5b-b1844eb4d8e5");\r
+ //azores\r
+ public static UUID uuidFlores = UUID.fromString("ef0067c2-8bbb-4e37-8462-97b03f51ba43");\r
+ public static UUID uuidCorvo = UUID.fromString("b1e6117c-2be1-43a3-9233-227dd90bdee9");\r
+ public static UUID uuidFaial = UUID.fromString("14f6dcdb-6524-4700-b80c-66424952ef2b");\r
+ public static UUID uuidGraciosa = UUID.fromString("05f93a7b-d813-4833-864f-eedbba747133");\r
+ public static UUID uuidSaoJorge = UUID.fromString("578e0ecd-b5e3-4c87-8ecc-0fc4c7e217d9");\r
+ public static UUID uuidSaoMiguel = UUID.fromString("0e2f6ad8-7afb-4f01-b134-4f71991e877a");\r
+ public static UUID uuidPico = UUID.fromString("98cc566f-4110-43d5-830f-68436a009f49");\r
+ public static UUID uuidSantaMaria = UUID.fromString("bd5e5d4a-22b7-41aa-8e58-1d1d73a9954d");\r
+ public static UUID uuidTerceira = UUID.fromString("6fc257c0-a131-41f0-b6c3-51ef9c4fa962");\r
+ //Canyry islands\r
+ public static UUID uuidGranCanaria = UUID.fromString("a0240c35-0e05-4157-8321-67ba8e31fdb9");\r
+ public static UUID uuidFuerteventura = UUID.fromString("549ce2c1-6d49-4bf3-b75d-cf3f4b5a1398");\r
+ public static UUID uuidGomera = UUID.fromString("895fab09-7478-4210-b42a-423d23c6f85e");\r
+ public static UUID uuidHierro = UUID.fromString("d137b6a5-31bc-418c-9403-f042017dc04b");\r
+ public static UUID uuidLanzaroteWithGraciosa = UUID.fromString("c9b08dc1-f301-4d9d-b447-b8744602c776");\r
+ public static UUID uuidLaPalma = UUID.fromString("fdb3f2b2-f154-4f04-9f31-240a47a0e780");\r
+ public static UUID uuidTenerife = UUID.fromString("73658c7e-a568-465e-bd84-4554fc93ca56");\r
+ //Baleares\r
+ public static UUID uuidIbizaWithFormentera = UUID.fromString("1cda2a33-3469-49d5-8e77-cb5451110519");\r
+ public static UUID uuidMallorca = UUID.fromString("a10cba04-b4b5-4a4b-b69a-fcd4b3916fec");\r
+ public static UUID uuidMenorca = UUID.fromString("9f6ede48-27f8-4270-bf4e-c97eaa86aab7");\r
+\r
+ //russia\r
+ public static UUID uuidRussiaNorthern = UUID.fromString("c23bc1c9-a775-4426-b883-07d4d7d47eed");\r
+ public static UUID uuidRussiaBaltic = UUID.fromString("579dad44-9439-4b19-8716-ab90d8f27944");\r
+ public static UUID uuidRussiaCentral = UUID.fromString("8bbc8c6a-2ef2-4024-ad51-66fe34c70092");\r
+ public static UUID uuidRussiaSouthWest = UUID.fromString("daa5c207-5567-4690-8742-5e4d153b6a64");\r
+ public static UUID uuidRussiaSouthEast = UUID.fromString("e8516598-b529-489e-9ee8-63bbbd295c1b");\r
+ public static UUID uuidEastAegeanIslands = UUID.fromString("1c429593-c493-46e6-971a-0d70be690da8");\r
+ public static UUID uuidTurkishEastAegeanIslands = UUID.fromString("ba35dba3-ac70-41ae-81c2-2070943f44f2");\r
+ public static UUID uuidBalticStates = UUID.fromString("bf9d64f6-3183-4fa5-8e90-73090e7a2282");\r
+ public static final UUID uuidTurkey = UUID.fromString("d344ee2c-14c8-438d-b03d-11538edb1268");\r
+ public static final UUID uuidCaucasia = UUID.fromString("ebfd3fd1-3859-4e5e-95c7-f66010599d7e");\r
+\r
+\r
+\r
+ //E+M areas\r
+ public static UUID uuidVocEuroMedAreas = UUID.fromString("625a4962-c211-4597-816e-5804083efe26");\r
+ public static UUID uuidEM = UUID.fromString("111BDF38-7A32-440A-9808-8AF1C9E54B51");\r
+ public static UUID uuidEUR = UUID.fromString("80B3CEEE-2F78-45CE-B4F4-E473F5ED8343");\r
+ public static UUID uuid14 = UUID.fromString("4FF83A35-97DE-4C39-BEDE-27EE9ECEFB45");\r
+ public static UUID uuid20 = UUID.fromString("19D93AD1-59E7-49ED-B513-D7D493EDC4DE");\r
+ public static UUID uuid21 = UUID.fromString("1B98DAF0-A709-4871-9A8B-CFDD09F41763");\r
+ public static UUID uuid33 = UUID.fromString("6B719260-1E48-4D85-8BC3-320852E1B331");\r
+ public static UUID uuidDa = UUID.fromString("867871C9-9931-47D0-AEF7-468B9519EBB2");\r
+ public static UUID uuidFe = UUID.fromString("C4EF26AF-11E0-4888-9FC3-5E56F4422BB4");\r
+ public static UUID uuidFa = UUID.fromString("70426E7E-2EAA-4987-95FB-5CB6E56980F3");\r
+ public static UUID uuidBr = UUID.fromString("A22329C4-0B81-4E00-BCC3-2F44A6CA56D0");\r
+ public static UUID uuidIs = UUID.fromString("3D2950E9-C2FD-462E-9697-DCB7241D514E");\r
+ public static UUID uuidHb = UUID.fromString("65E405E7-B3D4-44B6-BE67-4881582EA274");\r
+ public static UUID uuidNo = UUID.fromString("2D3F1181-6838-4034-96CB-F254A558572A");\r
+ public static UUID uuidSb = UUID.fromString("BC847AF8-30C3-48B2-A881-2B2DEAC0A137");\r
+ public static UUID uuidSu = UUID.fromString("F064AB9F-EDDB-47D8-8E54-B9E8AD19111D");\r
+ public static UUID uuidAu = UUID.fromString("37C77C23-9673-4ABC-87C2-B29E9FA87FA8");\r
+ public static UUID uuidBe = UUID.fromString("4840373B-F949-4630-B655-9B37F845CFDA");\r
+ public static UUID uuidCz = UUID.fromString("02E67A70-C192-4A01-A311-99F8C42F9D51");\r
+ public static UUID uuidGe = UUID.fromString("F617DDEA-51C9-4EF1-B7F4-ED22F871631D");\r
+ public static UUID uuidHu = UUID.fromString("AD7EDDB1-C089-436F-88BA-BC9115BBD6E0");\r
+ public static UUID uuidHo = UUID.fromString("00B8FE6D-D04B-4CAC-ADCE-32B44ABB385A");\r
+ public static UUID uuidPo = UUID.fromString("F23864DF-DFD6-4ABC-B7D0-FD97408AE0A9");\r
+ public static UUID uuidHe = UUID.fromString("7C28D878-F16D-4043-A94E-750BEF910064");\r
+ public static UUID uuidBl = UUID.fromString("A4326211-3219-4655-83AD-599D635DB638");\r
+ public static UUID uuidCo = UUID.fromString("3EE3CB3E-23DE-491F-94DF-35DB7A1D3AC0");\r
+ public static UUID uuidGa = UUID.fromString("28591C04-60E3-432A-9D05-CBC945462D2E");\r
+ public static UUID uuidLu = UUID.fromString("205512B0-AA22-4041-B92B-336FEB79FA4F");\r
+ public static UUID uuidSa = UUID.fromString("11368A92-2362-4029-A26A-E35CEC0798C1");\r
+ public static UUID uuidHs = UUID.fromString("6AD92C01-1442-4F2F-BD58-F73075B26C27");\r
+ public static UUID uuidAl = UUID.fromString("635B63DA-0AAF-446C-843E-BEB52E2A1B90");\r
+ public static UUID uuidBu = UUID.fromString("75F3CF66-B272-464E-9B1E-35B8E511936D");\r
+ public static UUID uuidGr = UUID.fromString("34DF8B89-7DFA-4265-9A3E-D540DB72AA77");\r
+ public static UUID uuidIt = UUID.fromString("06B8F41D-B9A8-4B55-8AAB-DE90EB3D0A9C");\r
+ public static UUID uuidCr = UUID.fromString("20A8A822-1C87-43F0-A5EF-2AF1CC5DC0FC");\r
+ public static UUID uuidRm = UUID.fromString("EAB29D40-E3B2-4920-BB1F-8757DFBC9E86");\r
+ public static UUID uuidSi_S = UUID.fromString("DD861671-930F-4C9E-92D8-EADDC28EB6B7");\r
+ public static UUID uuidTu_E = UUID.fromString("2B732609-55DB-4F25-BC73-618FFF515ADC");\r
+ public static UUID uuidJu = UUID.fromString("BD5E6833-7E0E-41A8-83D6-149A31F2CE05");\r
+ public static UUID uuidUk_K = UUID.fromString("40B7219D-E38C-44EB-9877-E311A2734022");\r
+ public static UUID uuidUk = UUID.fromString("7A8DF5D0-3D18-4386-891E-96E11BDB6FEB");\r
+ public static UUID uuidAg = UUID.fromString("548E583C-DBE7-463F-A01B-2A966F2B32D2");\r
+ public static UUID uuidEg = UUID.fromString("9EDDDE2E-95B7-4443-89A8-C30D031E16A5");\r
+ public static UUID uuidLi = UUID.fromString("2F506902-2A56-40C8-84CB-B436C84ED258");\r
+ public static UUID uuidMa = UUID.fromString("D639A7AC-F873-414E-8869-73D10B9CF842");\r
+ public static UUID uuidTn = UUID.fromString("AF4D86D4-2CA0-48A2-BA15-0D74454D1EAD");\r
+ public static UUID uuidAz = UUID.fromString("CEC2EBD3-DFD0-4CE6-827F-BFF8FBAF5283");\r
+ public static UUID uuidSg = UUID.fromString("BC4A0307-B81A-4233-B8BD-EFB9CEDFD530");\r
+ public static UUID uuidAb = UUID.fromString("D3744C2D-2777-4E85-98BF-04D2FD589EBF");\r
+ public static UUID uuidAr = UUID.fromString("535FED1E-3EC9-4563-AF55-E753AEFCFBFE");\r
+ public static UUID uuidAb_A = UUID.fromString("0F4C98BF-AF7B-4CDA-B62C-AD6A1909BFA0");\r
+ public static UUID uuidGg = UUID.fromString("DA1CCDA8-5867-4098-A709-100A66E2150A");\r
+ public static UUID uuidAb_N = UUID.fromString("AA75B0CA-49C9-4F8E-8CC2-2A343EB2FFF4");\r
+ public static UUID uuidCy = UUID.fromString("36EFDF69-09C0-4160-A502-9EEFBC22A984");\r
+ public static UUID uuidAE_G = UUID.fromString("76F5F3F6-9C3E-47F5-8E85-55360C50273C");\r
+ public static UUID uuidLe = UUID.fromString("639F5D97-EC9E-4EE2-ADFC-DFF73F7CC970");\r
+ public static UUID uuidSn = UUID.fromString("5D8E0B00-96CE-4ACC-AF02-62A1B9866144");\r
+ public static UUID uuidTu_A = UUID.fromString("F7B59D79-15C2-47C9-91B0-DEC1F388CB62");\r
+ public static UUID uuidTu = UUID.fromString("DB98809B-EF22-413B-B1EA-A79C4E1C4903");\r
+ public static UUID uuidAu_A = UUID.fromString("AE65867C-00F6-406C-A315-B3E4CC9A93D2");\r
+ public static UUID uuidAu_L = UUID.fromString("78146B6E-E71A-46DA-8DBC-244CC648BBE7");\r
+ public static UUID uuidAz_C = UUID.fromString("D35B8259-CC76-4FB0-AFC0-6A23D657EE3E");\r
+ public static UUID uuidAz_F = UUID.fromString("0F8F470D-CA2A-4130-842A-0A0C6912A123");\r
+ public static UUID uuidAz_G = UUID.fromString("CFF9FC6D-E3B2-45B1-87A9-6FEFB029A12F");\r
+ public static UUID uuidAz_P = UUID.fromString("C8000982-19E8-492E-912D-59EB370E52C0");\r
+ public static UUID uuidAz_S = UUID.fromString("BD852931-47B3-466C-A422-4F312B913CA2");\r
+ public static UUID uuidAz_J = UUID.fromString("4A5CED9F-F078-44B3-94BF-F3EE79315236");\r
+ public static UUID uuidAz_M = UUID.fromString("B8C76F37-6483-474F-85AB-96399219DE57");\r
+ public static UUID uuidAz_T = UUID.fromString("7A52595F-DA5E-440A-B2BD-F63999CE979E");\r
+ public static UUID uuidBe_B = UUID.fromString("9E263401-ACEC-4E2E-AA89-4AAF56AE7180");\r
+ public static UUID uuidBe_L = UUID.fromString("AF71559C-7765-493C-8C9A-1248DFF28789");\r
+ public static UUID uuidBl_I = UUID.fromString("121B07A0-8031-4F22-B9B7-C334FC3204CE");\r
+ public static UUID uuidBl_M = UUID.fromString("E8E8EFDC-E9EB-4B26-9711-F986265AD114");\r
+ public static UUID uuidBl_N = UUID.fromString("D96DD8A7-4BD8-4ADF-8CDB-05873686DB1A");\r
+ public static UUID uuidBH = UUID.fromString("6A109EF5-3AC1-4C59-8599-08F944ABA499");\r
+ public static UUID uuidBy = UUID.fromString("5D972AF7-6AE2-44D1-840B-EDB1DBE8B7AC");\r
+ public static UUID uuidCa = UUID.fromString("CFA26682-B0AB-4FEB-9191-6AA098638382");\r
+ public static UUID uuidCa_F = UUID.fromString("0D8ED2C4-0313-464C-A5B4-EC0A52E45ADF");\r
+ public static UUID uuidCa_G = UUID.fromString("865D1319-B157-4D1A-BBF0-F56B7EB2ED96");\r
+ public static UUID uuidCa_C = UUID.fromString("486FCBED-84C4-4673-8724-9A8A4A6613AD");\r
+ public static UUID uuidCa_H = UUID.fromString("0B57C693-DB09-4D7F-9FA9-0DBBEFF3B3B6");\r
+ public static UUID uuidCa_L = UUID.fromString("A88D6DF4-7924-4BEC-BFA6-071BDA82A4B3");\r
+ public static UUID uuidCa_P = UUID.fromString("BBF04D1A-1FC0-4A7B-BF0B-7D7BF69D8392");\r
+ public static UUID uuidCa_T = UUID.fromString("BBAD170B-285D-4BEA-8C3F-C43894FB75FF");\r
+ public static UUID uuidCs = UUID.fromString("2ADA45F0-C7CC-4026-A8B1-B816971F0753");\r
+ public static UUID uuidCt = UUID.fromString("09B5728A-4775-4530-B362-9B1EF4A9E8C3");\r
+ public static UUID uuidEs = UUID.fromString("1011D427-401B-47EE-A42C-4C1698957D55");\r
+ public static UUID uuidGa_C = UUID.fromString("3653A4DC-1ADE-4237-A62C-4F0AC11E576F");\r
+ public static UUID uuidGa_F = UUID.fromString("860F92B6-5CDA-456B-964C-6162D1D08161");\r
+ public static UUID uuidGg_A = UUID.fromString("5FAD859B-7929-4D5F-B92C-95E3E0469BB2");\r
+ public static UUID uuidGg_D = UUID.fromString("6091C975-B946-4EF3-A18F-2E148EAE6A06");\r
+ public static UUID uuidGg_G = UUID.fromString("048799B0-D7B9-44C6-B2D1-5CA2A49FA175");\r
+ public static UUID uuidHs_A = UUID.fromString("EAED6C21-42E5-496D-B43E-C121F96FA672");\r
+ public static UUID uuidHs_G = UUID.fromString("35350D75-6952-48BD-B265-C005BC1B2909");\r
+ public static UUID uuidHs_S = UUID.fromString("264649F7-192D-4AE5-9840-81FC782F59F0");\r
+ public static UUID uuidIr = UUID.fromString("A3B35528-5FFD-43B1-B605-711807C1EC9F");\r
+ public static UUID uuidIt_I = UUID.fromString("E3BC327E-0B42-4439-811B-595BC55A8FF8");\r
+ public static UUID uuidIt_S = UUID.fromString("57F35807-8CFA-4698-BB04-AAD3549C12EB");\r
+ public static UUID uuidJo = UUID.fromString("567A537D-F2FA-43EF-A20A-AEC76723E269");\r
+ public static UUID uuidKz = UUID.fromString("F8ABE715-D859-4B6F-B8F1-DB1A847DEAC4");\r
+ public static UUID uuidLa = UUID.fromString("8E338882-2631-4AD6-BC53-799C698C807D");\r
+ public static UUID uuidLt = UUID.fromString("ECF200B6-B1DF-414F-B215-EDAC503B1A65");\r
+ public static UUID uuidMa_E = UUID.fromString("80980607-FBD8-46E3-BE56-05D997F2D331");\r
+ public static UUID uuidMa_S = UUID.fromString("B743AE57-DC0B-4CCC-B4D9-7BF51E579E8E");\r
+ public static UUID uuidMk = UUID.fromString("0CE83170-2FA7-4C72-81F7-7FFF17343E48");\r
+ public static UUID uuidMd = UUID.fromString("2CFB90B1-0BA0-4578-AD11-AAD5AAB62899");\r
+ public static UUID uuidMd_D = UUID.fromString("DBE1F3CA-4C7C-4062-AC1E-ADE0C17DCA52");\r
+ public static UUID uuidMd_M = UUID.fromString("4658DADD-60FE-46D8-94E3-C6A6C4646105");\r
+ public static UUID uuidMd_P = UUID.fromString("2C41EB67-A330-4214-B452-6E6741262CE5");\r
+ public static UUID uuidSi_M = UUID.fromString("2920D738-54A1-49CE-AF3A-9CB742064587");\r
+ public static UUID uuidMo = UUID.fromString("64F98B98-1050-42C6-B2C7-F72DA642E4D5");\r
+ public static UUID uuidRf = UUID.fromString("4B6BDFEE-2BCB-4638-99CF-0F9612FA4787");\r
+ public static UUID uuidRf_C = UUID.fromString("1FFAF0B5-6311-4BF6-977F-8940622C4986");\r
+ public static UUID uuidRf_E = UUID.fromString("4280A0F6-298E-4B3C-8CE8-56A1208183F7");\r
+ public static UUID uuidRf_K = UUID.fromString("D9559D9A-1798-4496-8671-DE667CC30EC0");\r
+ public static UUID uuidRf_CS = UUID.fromString("6E886ACC-22C9-4C63-BEA5-A51AD84AF3D1");\r
+ public static UUID uuidRf_N = UUID.fromString("B0D8F65E-B5A4-4C0B-A5EF-54CC9F378CC6");\r
+ public static UUID uuidRf_NW = UUID.fromString("06CC9983-B444-4322-A03E-9A7A2AF1D4AD");\r
+ public static UUID uuidRf_A = UUID.fromString("1786C13D-D26D-49E3-BA60-E3F3E7852713");\r
+ public static UUID uuidRf_S = UUID.fromString("6AAB10D5-05E9-470A-8AF5-B6F8D48A71EC");\r
+ public static UUID uuidSk = UUID.fromString("09267309-E771-4BD7-A67F-B6B4321546E0");\r
+ public static UUID uuidSl = UUID.fromString("BC242D21-98CA-402C-BDB7-3ED347C7BDFD");\r
+ public static UUID uuidSy = UUID.fromString("A5974D4B-F878-422C-A7A8-A1D8268109EF");\r
+ public static UUID uuidUk_U = UUID.fromString("4A6C5155-154E-4B0D-AC73-550B51CCE374");\r
+ public static UUID uuidSM = UUID.fromString("AC360FC1-30F4-444A-92EB-B55BF98B8E97");\r
+ public static UUID uuidYu_K = UUID.fromString("F3F05E88-99AF-48FA-92EF-1A169BCC7ACF");\r
+ public static UUID uuidCg = UUID.fromString("38A4FD15-40D6-43F4-9685-F87465FDBD3F");\r
+ public static UUID uuidSr = UUID.fromString("468CFEA2-008F-40CF-B2C8-ADF5C09C0FA4");\r
+ public static UUID uuidIJ = UUID.fromString("9351B972-0C0B-4A97-87B1-4CC11E67D21E");\r
+ public static UUID uuidLS = UUID.fromString("F7BFDAE0-3DD9-4FC4-9B0B-0BF203B94031");\r
+ public static UUID uuidRs = UUID.fromString("C4A898CE-0F32-44FE-A8A3-278E11A4BA53");\r
+ public static UUID uuidSi = UUID.fromString("DB1FACF2-58A5-483E-9B2A-EB4290CA1B71");\r
+ public static UUID uuidAz_L = UUID.fromString("F5AEF252-C4F8-4ECC-9B6E-4821DB7ADECF");\r
+ public static UUID uuidHb_E = UUID.fromString("1D400E37-F39A-4CAE-8885-CF485B900CC5");\r
+ public static UUID uuidHb_N = UUID.fromString("B1D514DA-B9E6-4F0E-ACE4-18FB061FC132");\r
+ public static UUID uuidGa_M = UUID.fromString("E73942F0-292A-4F6A-8B2F-15AFE8634319");\r
+ public static UUID uuidMa_M = UUID.fromString("D9F7DFFC-0E76-4790-9AAE-B7AEB5AD76ED");\r
+ public static UUID uuidRs_N = UUID.fromString("44F262E3-5091-4D28-8081-440D3978FB0B");\r
+ public static UUID uuidRs_B = UUID.fromString("A575D608-DD53-4C01-B2AF-5067D0711F64");\r
+ public static UUID uuidRs_C = UUID.fromString("DA4E9CC3-B1CC-403A-81FF-BCC5D9FADBD1");\r
+ public static UUID uuidRs_W = UUID.fromString("EFABC8FD-0B3C-475B-B532-E1CA0BA0BDBB");\r
+ public static UUID uuidRs_E = UUID.fromString("7E0F8FA3-5DB9-48F0-9FA8-87FCAB3EAA53");\r
+ public static UUID uuidAE = UUID.fromString("C8FCD4E0-E1A2-4A7D-8EE2-6F397F5C546C");\r
+ public static UUID uuidAE_T = UUID.fromString("AF83B475-BB35-4594-8380-EA64B4313091");\r
+ public static UUID uuidRs_K = UUID.fromString("2188E3A5-0446-47C8-B11B-B4B2B9A71C75");\r
+ public static UUID uuidCc = UUID.fromString("05B0DD06-30F8-477D-BF4C-30D9DEF56320");\r
+ public static UUID uuidBt = UUID.fromString("EE13FB74-F3AC-46B1-9F23-6A25AC504446");\r
+ public static UUID uuidTcs = UUID.fromString("904C3980-B98D-422E-A195-95F4F41FC734");\r
+\r
+\r
+\r
+ //language areas\r
+// public static final UUID uuidUkraineAndCrimea = UUID.fromString("99d4d1c2-09f6-416e-86a3-bdde5cae52af");\r
+ public static final UUID uuidAzerbaijanNakhichevan = UUID.fromString("232fbef0-9f4a-4cab-8ac1-e14c717e9de6");\r
+\r
+ //Marker Types\r
+ public static final UUID uuidMisappliedCommonName = UUID.fromString("25f5cfc3-16ab-4aba-a008-0db0f2cf7f9d");\r
+ public static final UUID uuidEurArea = UUID.fromString("71dd0368-835c-4b53-889a-2bf316e10297");\r
+ public static final UUID uuidEurMedArea = UUID.fromString("aa6a5b25-3ee3-4771-b4d1-b91918f23fa5");\r
+ public static final UUID uuidHiddenArea = UUID.fromString("0318c67d-e323-4e9c-bffb-bc0c7f8f9f40");\r
+\r
+\r
+ //Extension Types\r
+ public static final UUID uuidSpeciesExpertName = UUID.fromString("2e8153d2-7412-49e4-87e1-5c38f4c5153a");\r
+ public static final UUID uuidExpertName = UUID.fromString("24becb79-a90c-47d3-be35-efc87bb48fd3");\r
+\r
+ public static final UUID DETAIL_EXT_UUID = UUID.fromString("c3959b4f-d876-4b7a-a739-9260f4cafd1c");\r
+ public static final UUID ID_IN_SOURCE_EXT_UUID = UUID.fromString("23dac094-e793-40a4-bad9-649fc4fcfd44");\r
+ public static final UUID uuidIsoCode = UUID.fromString("048b8153-e3ee-451c-a72c-f1c8bc291c3e");\r
+ public static final UUID uuidTdwgAreaCode = UUID.fromString("73ad0288-b71b-4a14-9c2e-7f81f1e64a36");\r
+ public static final UUID uuidMclCode = UUID.fromString("aa27083a-6a96-42aa-a2f8-5541cf057067");\r
+\r
+ //Area Level\r
+ public static final UUID uuidEuroMedAreaLevelTop = UUID.fromString("190d5758-4b96-4016-9412-6dc9c36ef5fd");\r
+ public static final UUID uuidEuroMedAreaLevelFirst = UUID.fromString("d21503e3-875e-4abc-82ec-f812e3cfea84");\r
+ public static final UUID uuidEuroMedAreaLevelSecond = UUID.fromString("97ac0bf5-b31c-487a-8ed5-a576f46c902c");\r
+\r
+ //languages\r
+ public static final UUID uuidLangMajorcan = UUID.fromString("82d696d7-cb4e-49de-ac89-63a0e12ca766");\r
+\r
+ //REFERENCES\r
+ public static int REF_ARTICLE = 1;\r
+ public static int REF_PART_OF_OTHER_TITLE = 2;\r
+ public static int REF_BOOK = 3;\r
+ public static int REF_DATABASE = 4;\r
+ public static int REF_INFORMAL = 5;\r
+ public static int REF_NOT_APPLICABLE = 6;\r
+ public static int REF_WEBSITE = 7;\r
+ public static int REF_CD = 8;\r
+ public static int REF_JOURNAL = 9;\r
+ public static int REF_UNKNOWN = 10;\r
+ public static int REF_PRINT_SERIES = 55;\r
+ public static int REF_CONFERENCE_PROCEEDINGS = 56;\r
+ public static int REF_JOURNAL_VOLUME = 57;\r
+\r
+\r
+\r
+ //NameStatus\r
+ public static int NAME_ST_NOM_INVAL = 1;\r
+ public static int NAME_ST_NOM_ILLEG = 2;\r
+ public static int NAME_ST_NOM_NUD = 3;\r
+ public static int NAME_ST_NOM_REJ = 4;\r
+ public static int NAME_ST_NOM_REJ_PROP = 5;\r
+ public static int NAME_ST_NOM_UTIQUE_REJ = 6;\r
+ public static int NAME_ST_NOM_UTIQUE_REJ_PROP = 7;\r
+ public static int NAME_ST_NOM_CONS = 8;\r
+ public static int NAME_ST_NOM_CONS_PROP = 9;\r
+ public static int NAME_ST_ORTH_CONS = 10;\r
+ public static int NAME_ST_ORTH_CONS_PROP = 11;\r
+ public static int NAME_ST_NOM_SUPERFL = 12;\r
+ public static int NAME_ST_NOM_AMBIG = 13;\r
+ public static int NAME_ST_NOM_PROVIS = 14;\r
+ public static int NAME_ST_NOM_DUB = 15;\r
+ public static int NAME_ST_NOM_NOV = 16;\r
+ public static int NAME_ST_NOM_CONFUS = 17;\r
+ public static int NAME_ST_NOM_ALTERN = 18;\r
+ public static int NAME_ST_COMB_INVAL = 19;\r
+\r
+\r
+ //NameRelationShip\r
+ public static int NAME_REL_IS_BASIONYM_FOR = 1;\r
+ public static int NAME_REL_IS_LATER_HOMONYM_OF = 2;\r
+ public static int NAME_REL_IS_REPLACED_SYNONYM_FOR = 3;\r
+ public static int NAME_REL_IS_VALIDATION_OF = 4;\r
+ public static int NAME_REL_IS_LATER_VALIDATION_OF = 5;\r
+ public static int NAME_REL_IS_TYPE_OF = 6;\r
+ public static int NAME_REL_IS_CONSERVED_TYPE_OF =7;\r
+ public static int NAME_REL_IS_REJECTED_TYPE_OF = 8;\r
+ public static int NAME_REL_IS_FIRST_PARENT_OF = 9;\r
+ public static int NAME_REL_IS_SECOND_PARENT_OF = 10;\r
+ public static int NAME_REL_IS_FEMALE_PARENT_OF = 11;\r
+ public static int NAME_REL_IS_MALE_PARENT_OF = 12;\r
+ public static int NAME_REL_IS_CONSERVED_AGAINST =13;\r
+ public static int NAME_REL_IS_REJECTED_IN_FAVOUR_OF = 14;\r
+ public static int NAME_REL_IS_TREATED_AS_LATER_HOMONYM_OF = 15;\r
+ public static int NAME_REL_IS_ORTHOGRAPHIC_VARIANT_OF = 16;\r
+ public static int NAME_REL_IS_ALTERNATIVE_NAME_FOR = 17;\r
+ public static int NAME_REL_HAS_SAME_TYPE_AS = 18;\r
+ public static int NAME_REL_IS_LECTOTYPE_OF = 61;\r
+ public static int NAME_REL_TYPE_NOT_DESIGNATED = 62;\r
+\r
+ //NameFacts\r
+ public static String NAME_FACT_PROTOLOGUE = "Protologue";\r
+ public static String NAME_FACT_ALSO_PUBLISHED_IN = "Also published in";\r
+ public static String NAME_FACT_BIBLIOGRAPHY = "Bibliography";\r
+\r
+ //TaxonRelationShip\r
+ public static int TAX_REL_IS_INCLUDED_IN = 1;\r
+ public static int TAX_REL_IS_SYNONYM_OF = 2;\r
+ public static int TAX_REL_IS_MISAPPLIED_NAME_OF = 3;\r
+ public static int TAX_REL_IS_PROPARTE_SYN_OF = 4;\r
+ public static int TAX_REL_IS_PARTIAL_SYN_OF = 5;\r
+ public static int TAX_REL_IS_HETEROTYPIC_SYNONYM_OF = 6;\r
+ public static int TAX_REL_IS_HOMOTYPIC_SYNONYM_OF = 7;\r
+ public static int TAX_REL_IS_PROPARTE_HOMOTYPIC_SYNONYM_OF = 101;\r
+ public static int TAX_REL_IS_PROPARTE_HETEROTYPIC_SYNONYM_OF = 102;\r
+ public static int TAX_REL_IS_PARTIAL_HOMOTYPIC_SYNONYM_OF = 103;\r
+ public static int TAX_REL_IS_PARTIAL_HETEROTYPIC_SYNONYM_OF = 104;\r
+\r
+\r
+\r
+ //TaxonStatus\r
+ public static int T_STATUS_ACCEPTED = 1;\r
+ public static int T_STATUS_SYNONYM = 2;\r
+ public static int T_STATUS_PARTIAL_SYN = 3;\r
+ public static int T_STATUS_PRO_PARTE_SYN = 4;\r
+ public static int T_STATUS_UNRESOLVED = 5;\r
+ public static int T_STATUS_ORPHANED = 6;\r
+\r
+\r
+ //Facts\r
+ public static int FACT_DESCRIPTION = 1;\r
+ public static int FACT_GROWTH_FORM = 2;\r
+ public static int FACT_HARDINESS = 3;\r
+ public static int FACT_ECOLOGY = 4;\r
+ public static int FACT_PHENOLOGY = 5;\r
+ public static int FACT_KARYOLOGY = 6;\r
+ public static int FACT_ILLUSTRATION = 7;\r
+ public static int FACT_IDENTIFICATION = 8;\r
+ public static int FACT_OBSERVATION = 9;\r
+ public static int FACT_DISTRIBUTION_EM = 10;\r
+ public static int FACT_DISTRIBUTION_WORLD = 11;\r
+ //E+M\r
+ public static final UUID uuidFeatureMaps = UUID.fromString("8367730e-f3c3-4361-8360-a2057e4295ed");\r
+ public static final UUID uuidFeatureConservationStatus = UUID.fromString("a32f33cd-1966-4a22-986c-94c5e688bbd1");\r
+ public static final UUID uuidFeatureUse = UUID.fromString("199bbbd8-2db6-4335-b454-2e92ae02b699");\r
+ public static final UUID uuidFeatureComments = UUID.fromString("31cc2b92-5cad-44e9-b50f-b8af591a527c");\r
+ public static final UUID uuidFeatureDistrEM = UUID.fromString("a5ba7e7f-ca7f-4f50-afc7-73e76b3231d4");\r
+ public static final UUID uuidFeatureDistrWorld = UUID.fromString("e4e24080-7017-47e6-924e-d2560fa68fb8");\r
+ public static final UUID uuidFeatureEditorBrackets = UUID.fromString("b3b5bc1a-7ba8-4a39-9c0d-63ba599eb5d8");\r
+ public static final UUID uuidFeatureEditorParenthesis = UUID.fromString("6ee10a2e-ff02-4cf4-a520-89630edc5b44");\r
+ public static final UUID uuidFeatureInedited = UUID.fromString("c93e2968-bc52-4165-9755-ce37611faf01");\r
+ public static final UUID uuidFeatureCommentsEditing = UUID.fromString("7a155021-158a-48bb-81d0-9a72b718e2de");\r
+\r
+\r
+\r
+ public static UUID uuidNomStatusCombIned = UUID.fromString("dde8a2e7-bf9e-42ec-b186-d5bde9c9c128");\r
+ public static UUID uuidNomStatusSpNovIned = UUID.fromString("1a359ca1-9364-43bc-93e4-834bdcd52b72");\r
+ public static UUID uuidNomStatusNomOrthCons = UUID.fromString("0f838183-ffa0-4014-928e-0e3a27eb3918");\r
+\r
+ static NomenclaturalStatusType nomStatusCombIned;\r
+ static NomenclaturalStatusType nomStatusSpNovIned;\r
+ static NomenclaturalStatusType nomStatusNomOrthCons;\r
+\r
+ public static NomenclaturalStatusType nomStatusTypeAbbrev2NewNomStatusType(String nomStatus){\r
+ NomenclaturalStatusType result = null;\r
+ if (nomStatus == null){\r
+ return null;\r
+ }else if (nomStatus.equalsIgnoreCase("comb. ined.")){\r
+ if (nomStatusCombIned == null){\r
+ nomStatusCombIned = NomenclaturalStatusType.NewInstance("comb. ined.", "comb. ined.", "comb. ined.", Language.LATIN());\r
+ nomStatusCombIned.setUuid(uuidNomStatusCombIned);\r
+ NomenclaturalStatusType.ALTERNATIVE().getVocabulary().addTerm(nomStatusCombIned);\r
+ }\r
+ result = nomStatusCombIned;\r
+ }else if (nomStatus.equalsIgnoreCase("sp. nov. ined.")){\r
+ if (nomStatusSpNovIned == null){\r
+ nomStatusSpNovIned = NomenclaturalStatusType.NewInstance("sp. nov. ined.", "sp. nov. ined.", "sp. nov. ined.", Language.LATIN());\r
+ nomStatusSpNovIned.setUuid(uuidNomStatusSpNovIned);\r
+ NomenclaturalStatusType.ALTERNATIVE().getVocabulary().addTerm(nomStatusSpNovIned);\r
+ }\r
+ result = nomStatusSpNovIned;\r
+ }else if (nomStatus.equalsIgnoreCase("nom. & orth. cons.")){\r
+ if (nomStatusNomOrthCons == null){\r
+ nomStatusNomOrthCons = NomenclaturalStatusType.NewInstance("nom. & orth. cons.", "nom. & orth. cons.", "nom. & orth. cons.", Language.LATIN());\r
+ nomStatusNomOrthCons.setUuid(uuidNomStatusNomOrthCons);\r
+ NomenclaturalStatusType.ALTERNATIVE().getVocabulary().addTerm(nomStatusNomOrthCons);\r
+ }\r
+ result = nomStatusNomOrthCons;\r
+ }\r
+ return result;\r
+ }\r
+\r
+\r
+ public static NomenclaturalStatus nomStatusFkToNomStatus(int nomStatusFk, String nomStatusLabel) throws UnknownCdmTypeException{\r
+ if (nomStatusFk == NAME_ST_NOM_INVAL){\r
+ return NomenclaturalStatus.NewInstance(NomenclaturalStatusType.INVALID());\r
+ }else if (nomStatusFk == NAME_ST_NOM_ILLEG){\r
+ return NomenclaturalStatus.NewInstance(NomenclaturalStatusType.ILLEGITIMATE());\r
+ }else if (nomStatusFk == NAME_ST_NOM_NUD){\r
+ return NomenclaturalStatus.NewInstance(NomenclaturalStatusType.NUDUM());\r
+ }else if (nomStatusFk == NAME_ST_NOM_REJ){\r
+ return NomenclaturalStatus.NewInstance(NomenclaturalStatusType.REJECTED());\r
+ }else if (nomStatusFk == NAME_ST_NOM_REJ_PROP){\r
+ return NomenclaturalStatus.NewInstance(NomenclaturalStatusType.REJECTED_PROP());\r
+ }else if (nomStatusFk == NAME_ST_NOM_UTIQUE_REJ){\r
+ return NomenclaturalStatus.NewInstance(NomenclaturalStatusType.UTIQUE_REJECTED());\r
+ }else if (nomStatusFk == NAME_ST_NOM_UTIQUE_REJ_PROP){\r
+ return NomenclaturalStatus.NewInstance(NomenclaturalStatusType.UTIQUE_REJECTED_PROP());\r
+ }else if (nomStatusFk == NAME_ST_NOM_CONS){\r
+ return NomenclaturalStatus.NewInstance(NomenclaturalStatusType.CONSERVED());\r
+ }else if (nomStatusFk == NAME_ST_NOM_CONS_PROP){\r
+ return NomenclaturalStatus.NewInstance(NomenclaturalStatusType.CONSERVED_PROP());\r
+ }else if (nomStatusFk == NAME_ST_ORTH_CONS){\r
+ return NomenclaturalStatus.NewInstance(NomenclaturalStatusType.ORTHOGRAPHY_CONSERVED());\r
+ }else if (nomStatusFk == NAME_ST_ORTH_CONS_PROP){\r
+ return NomenclaturalStatus.NewInstance(NomenclaturalStatusType.ORTHOGRAPHY_CONSERVED_PROP());\r
+ }else if (nomStatusFk == NAME_ST_NOM_SUPERFL){\r
+ return NomenclaturalStatus.NewInstance(NomenclaturalStatusType.SUPERFLUOUS());\r
+ }else if (nomStatusFk == NAME_ST_NOM_AMBIG){\r
+ return NomenclaturalStatus.NewInstance(NomenclaturalStatusType.AMBIGUOUS());\r
+ }else if (nomStatusFk == NAME_ST_NOM_PROVIS){\r
+ return NomenclaturalStatus.NewInstance(NomenclaturalStatusType.PROVISIONAL());\r
+ }else if (nomStatusFk == NAME_ST_NOM_DUB){\r
+ return NomenclaturalStatus.NewInstance(NomenclaturalStatusType.DOUBTFUL());\r
+ }else if (nomStatusFk == NAME_ST_NOM_NOV){\r
+ return NomenclaturalStatus.NewInstance(NomenclaturalStatusType.NOVUM());\r
+ }else if (nomStatusFk == NAME_ST_NOM_CONFUS){\r
+ return NomenclaturalStatus.NewInstance(NomenclaturalStatusType.CONFUSUM());\r
+ }else if (nomStatusFk == NAME_ST_NOM_ALTERN){\r
+ return NomenclaturalStatus.NewInstance(NomenclaturalStatusType.ALTERNATIVE());\r
+ }else if (nomStatusFk == NAME_ST_COMB_INVAL){\r
+ return NomenclaturalStatus.NewInstance(NomenclaturalStatusType.COMBINATION_INVALID());\r
+ }else {\r
+ NomenclaturalStatusType statusType = nomStatusTypeAbbrev2NewNomStatusType(nomStatusLabel);\r
+ NomenclaturalStatus result = NomenclaturalStatus.NewInstance(statusType);\r
+ if (result != null){\r
+ return result;\r
+ }\r
+ throw new UnknownCdmTypeException("Unknown NomenclaturalStatus (id=" + Integer.valueOf(nomStatusFk).toString() + ")");\r
+ }\r
+ }\r
+\r
+ public static UUID getEMAreaUuid(String areaId){\r
+ if (areaId == null){\r
+ logger.warn("No AreaId given");\r
+ return null;\r
+ }else if (areaId.equals("EM")){return uuidEM;\r
+ }else if (areaId.equals("EUR")){return uuidEUR;\r
+ }else if (areaId.equals("14")){return uuid14;\r
+ }else if (areaId.equals("20")){return uuid20;\r
+ }else if (areaId.equals("21")){return uuid21;\r
+ }else if (areaId.equals("33")){return uuid33;\r
+ }else if (areaId.equals("Da")){return uuidDa;\r
+ }else if (areaId.equals("Fe")){return uuidFe;\r
+ }else if (areaId.equals("Fa")){return uuidFa;\r
+ }else if (areaId.equals("Br")){return uuidBr;\r
+ }else if (areaId.equals("Is")){return uuidIs;\r
+ }else if (areaId.equals("Hb")){return uuidHb;\r
+ }else if (areaId.equals("No")){return uuidNo;\r
+ }else if (areaId.equals("Sb")){return uuidSb;\r
+ }else if (areaId.equals("Su")){return uuidSu;\r
+ }else if (areaId.equals("Au")){return uuidAu;\r
+ }else if (areaId.equals("Be")){return uuidBe;\r
+ }else if (areaId.equals("Cz")){return uuidCz;\r
+ }else if (areaId.equals("Ge")){return uuidGe;\r
+ }else if (areaId.equals("Hu")){return uuidHu;\r
+ }else if (areaId.equals("Ho")){return uuidHo;\r
+ }else if (areaId.equals("Po")){return uuidPo;\r
+ }else if (areaId.equals("He")){return uuidHe;\r
+ }else if (areaId.equals("Bl")){return uuidBl;\r
+ }else if (areaId.equals("Co")){return uuidCo;\r
+ }else if (areaId.equals("Ga")){return uuidGa;\r
+ }else if (areaId.equals("Lu")){return uuidLu;\r
+ }else if (areaId.equals("Sa")){return uuidSa;\r
+ }else if (areaId.equals("Hs")){return uuidHs;\r
+ }else if (areaId.equals("Al")){return uuidAl;\r
+ }else if (areaId.equals("Bu")){return uuidBu;\r
+ }else if (areaId.equals("Gr")){return uuidGr;\r
+ }else if (areaId.equals("It")){return uuidIt;\r
+ }else if (areaId.equals("Cr")){return uuidCr;\r
+ }else if (areaId.equals("Rm")){return uuidRm;\r
+ }else if (areaId.equals("Si(S)")){return uuidSi_S;\r
+ }else if (areaId.equals("Tu(E)")){return uuidTu_E;\r
+ }else if (areaId.equals("Ju")){return uuidJu;\r
+ }else if (areaId.equals("Uk(K)")){return uuidUk_K;\r
+ }else if (areaId.equals("Uk")){return uuidUk;\r
+ }else if (areaId.equals("Ag")){return uuidAg;\r
+ }else if (areaId.equals("Eg")){return uuidEg;\r
+ }else if (areaId.equals("Li")){return uuidLi;\r
+ }else if (areaId.equals("Ma")){return uuidMa;\r
+ }else if (areaId.equals("Tn")){return uuidTn;\r
+ }else if (areaId.equals("Az")){return uuidAz;\r
+ }else if (areaId.equals("Sg")){return uuidSg;\r
+ }else if (areaId.equals("Ab")){return uuidAb;\r
+ }else if (areaId.equals("Ar")){return uuidAr;\r
+ }else if (areaId.equals("Ab(A)")){return uuidAb_A;\r
+ }else if (areaId.equals("Gg")){return uuidGg;\r
+ }else if (areaId.equals("Ab(N)")){return uuidAb_N;\r
+ }else if (areaId.equals("Cy")){return uuidCy;\r
+ }else if (areaId.equals("AE(G)")){return uuidAE_G;\r
+ }else if (areaId.equals("Le")){return uuidLe;\r
+ }else if (areaId.equals("Sn")){return uuidSn;\r
+ }else if (areaId.equals("Tu(A)")){return uuidTu_A;\r
+ }else if (areaId.equals("Tu")){return uuidTu;\r
+ }else if (areaId.equals("Au(A)")){return uuidAu_A;\r
+ }else if (areaId.equals("Au(L)")){return uuidAu_L;\r
+ }else if (areaId.equals("Az(C)")){return uuidAz_C;\r
+ }else if (areaId.equals("Az(F)")){return uuidAz_F;\r
+ }else if (areaId.equals("Az(G)")){return uuidAz_G;\r
+ }else if (areaId.equals("Az(P)")){return uuidAz_P;\r
+ }else if (areaId.equals("Az(S)")){return uuidAz_S;\r
+ }else if (areaId.equals("Az(J)")){return uuidAz_J;\r
+ }else if (areaId.equals("Az(M)")){return uuidAz_M;\r
+ }else if (areaId.equals("Az(T)")){return uuidAz_T;\r
+ }else if (areaId.equals("Be(B)")){return uuidBe_B;\r
+ }else if (areaId.equals("Be(L)")){return uuidBe_L;\r
+ }else if (areaId.equals("Bl(I)")){return uuidBl_I;\r
+ }else if (areaId.equals("Bl(M)")){return uuidBl_M;\r
+ }else if (areaId.equals("Bl(N)")){return uuidBl_N;\r
+ }else if (areaId.equals("BH")){return uuidBH;\r
+ }else if (areaId.equals("By")){return uuidBy;\r
+ }else if (areaId.equals("Ca")){return uuidCa;\r
+ }else if (areaId.equals("Ca(F)")){return uuidCa_F;\r
+ }else if (areaId.equals("Ca(G)")){return uuidCa_G;\r
+ }else if (areaId.equals("Ca(C)")){return uuidCa_C;\r
+ }else if (areaId.equals("Ca(H)")){return uuidCa_H;\r
+ }else if (areaId.equals("Ca(L)")){return uuidCa_L;\r
+ }else if (areaId.equals("Ca(P)")){return uuidCa_P;\r
+ }else if (areaId.equals("Ca(T)")){return uuidCa_T;\r
+ }else if (areaId.equals("Cs")){return uuidCs;\r
+ }else if (areaId.equals("Ct")){return uuidCt;\r
+ }else if (areaId.equals("Es")){return uuidEs;\r
+ }else if (areaId.equals("Ga(C)")){return uuidGa_C;\r
+ }else if (areaId.equals("Ga(F)")){return uuidGa_F;\r
+ }else if (areaId.equals("Gg(A)")){return uuidGg_A;\r
+ }else if (areaId.equals("Gg(D)")){return uuidGg_D;\r
+ }else if (areaId.equals("Gg(G)")){return uuidGg_G;\r
+ }else if (areaId.equals("Hs(A)")){return uuidHs_A;\r
+ }else if (areaId.equals("Hs(G)")){return uuidHs_G;\r
+ }else if (areaId.equals("Hs(S)")){return uuidHs_S;\r
+ }else if (areaId.equals("Ir")){return uuidIr;\r
+ }else if (areaId.equals("It(I)")){return uuidIt_I;\r
+ }else if (areaId.equals("It(S)")){return uuidIt_S;\r
+ }else if (areaId.equals("Jo")){return uuidJo;\r
+ }else if (areaId.equals("Kz")){return uuidKz;\r
+ }else if (areaId.equals("La")){return uuidLa;\r
+ }else if (areaId.equals("Lt")){return uuidLt;\r
+ }else if (areaId.equals("Ma(E)")){return uuidMa_E;\r
+ }else if (areaId.equals("Ma(S)")){return uuidMa_S;\r
+ }else if (areaId.equals("Mk")){return uuidMk;\r
+ }else if (areaId.equals("Md")){return uuidMd;\r
+ }else if (areaId.equals("Md(D)")){return uuidMd_D;\r
+ }else if (areaId.equals("Md(M)")){return uuidMd_M;\r
+ }else if (areaId.equals("Md(P)")){return uuidMd_P;\r
+ }else if (areaId.equals("Si(M)")){return uuidSi_M;\r
+ }else if (areaId.equals("Mo")){return uuidMo;\r
+ }else if (areaId.equals("Rf")){return uuidRf;\r
+ }else if (areaId.equals("Rf(C)")){return uuidRf_C;\r
+ }else if (areaId.equals("Rf(E)")){return uuidRf_E;\r
+ }else if (areaId.equals("Rf(K)")){return uuidRf_K;\r
+ }else if (areaId.equals("Rf(CS)")){return uuidRf_CS;\r
+ }else if (areaId.equals("Rf(N)")){return uuidRf_N;\r
+ }else if (areaId.equals("Rf(NW)")){return uuidRf_NW;\r
+ }else if (areaId.equals("Rf(A)")){return uuidRf_A;\r
+ }else if (areaId.equals("Rf(S)")){return uuidRf_S;\r
+ }else if (areaId.equals("Sk")){return uuidSk;\r
+ }else if (areaId.equals("Sl")){return uuidSl;\r
+ }else if (areaId.equals("Sy")){return uuidSy;\r
+ }else if (areaId.equals("Uk(U)")){return uuidUk_U;\r
+ }else if (areaId.equals("SM")){return uuidSM;\r
+ }else if (areaId.equals("Yu(K)")){return uuidYu_K;\r
+ }else if (areaId.equals("Cg")){return uuidCg;\r
+ }else if (areaId.equals("Sr")){return uuidSr;\r
+ }else if (areaId.equals("IJ")){return uuidIJ;\r
+ }else if (areaId.equals("LS")){return uuidLS;\r
+ }else if (areaId.equals("Rs")){return uuidRs;\r
+ }else if (areaId.equals("Si")){return uuidSi;\r
+ }else if (areaId.equals("Az(L)")){return uuidAz_L;\r
+ }else if (areaId.equals("Hb(E)")){return uuidHb_E;\r
+ }else if (areaId.equals("Hb(N)")){return uuidHb_N;\r
+ }else if (areaId.equals("Ga(M)")){return uuidGa_M;\r
+ }else if (areaId.equals("Ma(M)")){return uuidMa_M;\r
+ }else if (areaId.equals("Rs(N)")){return uuidRs_N;\r
+ }else if (areaId.equals("Rs(B)")){return uuidRs_B;\r
+ }else if (areaId.equals("Rs(C)")){return uuidRs_C;\r
+ }else if (areaId.equals("Rs(W)")){return uuidRs_W;\r
+ }else if (areaId.equals("Rs(E)")){return uuidRs_E;\r
+ }else if (areaId.equals("AE")){return uuidAE;\r
+ }else if (areaId.equals("AE(T)")){return uuidAE_T;\r
+ }else if (areaId.equals("Rs(K)")){return uuidRs_K;\r
+ }else if (areaId.equals("Cc")){return uuidCc;\r
+ }else if (areaId.equals("Bt")){return uuidBt;\r
+ }else if (areaId.equals("Tcs")){return uuidTcs;\r
+ }else{\r
+ logger.warn("Area not found: " + areaId);\r
+ return null;\r
+ }\r
+\r
+ }\r
+\r
+\r
+ //TypeDesignation\r
+ public static SpecimenTypeDesignationStatus typeStatusId2TypeStatus (int typeStatusId) throws UnknownCdmTypeException{\r
+ switch (typeStatusId){\r
+ case 0: return null;\r
+ case 1: return SpecimenTypeDesignationStatus.HOLOTYPE();\r
+ case 2: return SpecimenTypeDesignationStatus.LECTOTYPE();\r
+ case 3: return SpecimenTypeDesignationStatus.NEOTYPE();\r
+ case 4: return SpecimenTypeDesignationStatus.EPITYPE();\r
+ case 5: return SpecimenTypeDesignationStatus.ISOLECTOTYPE();\r
+ case 6: return SpecimenTypeDesignationStatus.ISONEOTYPE();\r
+ case 7: return SpecimenTypeDesignationStatus.ISOTYPE();\r
+ case 8: return SpecimenTypeDesignationStatus.PARANEOTYPE();\r
+ case 9: return SpecimenTypeDesignationStatus.PARATYPE();\r
+ case 10: return SpecimenTypeDesignationStatus.SECOND_STEP_LECTOTYPE();\r
+ case 11: return SpecimenTypeDesignationStatus.SECOND_STEP_NEOTYPE();\r
+ case 12: return SpecimenTypeDesignationStatus.SYNTYPE();\r
+ case 21: return SpecimenTypeDesignationStatus.ICONOTYPE();\r
+ case 22: return SpecimenTypeDesignationStatus.PHOTOTYPE();\r
+ default: {\r
+ throw new UnknownCdmTypeException("Unknown TypeDesignationStatus (id=" + Integer.valueOf(typeStatusId).toString() + ")");\r
+ }\r
+ }\r
+ }\r
+\r
+ //TypeDesignation\r
+ public static TaxonRelationshipType taxonRelId2TaxonRelType (int relTaxonTypeId, ResultWrapper<Boolean> isInverse, ResultWrapper<Boolean> isDoubtful) throws UnknownCdmTypeException{\r
+ isInverse.setValue(false);\r
+ switch (relTaxonTypeId){\r
+ case 0: return null;\r
+ case 11: return TaxonRelationshipType.CONGRUENT_TO();\r
+ case 12: isInverse.setValue(true); return TaxonRelationshipType.INCLUDES();\r
+ case 13: isInverse.setValue(true); return TaxonRelationshipType.CONGRUENT_OR_INCLUDES();\r
+ case 14: return TaxonRelationshipType.INCLUDES();\r
+ case 15: return TaxonRelationshipType.CONGRUENT_OR_INCLUDES();\r
+ case 16: return TaxonRelationshipType.INCLUDED_OR_INCLUDES();\r
+ case 17: return TaxonRelationshipType.CONGRUENT_OR_INCLUDED_OR_INCLUDES();\r
+ case 18: return TaxonRelationshipType.OVERLAPS();\r
+ case 19: return TaxonRelationshipType.CONGRUENT_OR_OVERLAPS();\r
+ case 20: isInverse.setValue(true); return TaxonRelationshipType.INCLUDES_OR_OVERLAPS();\r
+ case 21: isInverse.setValue(true); return TaxonRelationshipType.CONGRUENT_OR_INCLUDES_OR_OVERLAPS();\r
+ case 22: return TaxonRelationshipType.INCLUDES_OR_OVERLAPS();\r
+ case 23: return TaxonRelationshipType.CONGRUENT_OR_INCLUDES_OR_OVERLAPS();\r
+ case 24: return TaxonRelationshipType.INCLUDED_OR_INCLUDES_OR_OVERLAPS();\r
+\r
+ case 26: return TaxonRelationshipType.EXCLUDES();\r
+\r
+ //TODO other relationshipTypes\r
+\r
+ case 40: return TaxonRelationshipType.NOT_CONGRUENT_TO();\r
+\r
+ //how to implement this, what is a purely doubtful relationship ??\r
+// case 42: isDoubtful.setValue(true); return TaxonRelationshipType.();\r
+\r
+ case 43: isDoubtful.setValue(true); return TaxonRelationshipType.CONGRUENT_TO();\r
+ case 44: isInverse.setValue(true);isDoubtful.setValue(true); return TaxonRelationshipType.INCLUDES();\r
+ case 46: isDoubtful.setValue(true); return TaxonRelationshipType.INCLUDES();\r
+ case 48: isDoubtful.setValue(true); return TaxonRelationshipType.INCLUDED_OR_INCLUDES();\r
+ case 50: isDoubtful.setValue(true); return TaxonRelationshipType.OVERLAPS();\r
+ case 51: isDoubtful.setValue(true); return TaxonRelationshipType.CONGRUENT_OR_OVERLAPS();\r
+ case 58: isDoubtful.setValue(true); return TaxonRelationshipType.EXCLUDES();\r
+\r
+\r
+ default: {\r
+ throw new UnknownCdmTypeException("Unknown TypeDesignationStatus (id=" + Integer.valueOf(relTaxonTypeId).toString() + ")");\r
+ }\r
+ }\r
+ }\r
+\r
+ //TypeDesignation\r
+ public static HybridRelationshipType relNameId2HybridRel (int relNameId) throws UnknownCdmTypeException{\r
+ switch (relNameId){\r
+ case 0: return null;\r
+ case 9: return HybridRelationshipType.FIRST_PARENT();\r
+ case 10: return HybridRelationshipType.SECOND_PARENT();\r
+ case 11: return HybridRelationshipType.FEMALE_PARENT();\r
+ case 12: return HybridRelationshipType.MALE_PARENT();\r
+ default: {\r
+ throw new UnknownCdmTypeException("Unknown HybridRelationshipType (id=" + Integer.valueOf(relNameId).toString() + ")");\r
+ }\r
+ }\r
+ }\r
+\r
+ //OccStatus\r
+ public static PresenceAbsenceTerm occStatus2PresenceAbsence (int occStatusId) throws UnknownCdmTypeException{\r
+ switch (occStatusId){\r
+ case 0: return null;\r
+ case 110: return PresenceAbsenceTerm.CULTIVATED_REPORTED_IN_ERROR();\r
+ case 120: return PresenceAbsenceTerm.CULTIVATED();\r
+ case 210: return PresenceAbsenceTerm.INTRODUCED_REPORTED_IN_ERROR();\r
+ case 220: return PresenceAbsenceTerm.INTRODUCED_PRESENCE_QUESTIONABLE();\r
+ case 230: return PresenceAbsenceTerm.INTRODUCED_FORMERLY_INTRODUCED();\r
+ case 240: return PresenceAbsenceTerm.INTRODUCED_DOUBTFULLY_INTRODUCED();\r
+ case 250: return PresenceAbsenceTerm.INTRODUCED();\r
+ case 260: return PresenceAbsenceTerm.INTRODUCED_UNCERTAIN_DEGREE_OF_NATURALISATION();\r
+ case 270: return PresenceAbsenceTerm.INTRODUCED_ADVENTITIOUS();\r
+ case 280: return PresenceAbsenceTerm.INTRODUCED_NATURALIZED();\r
+ case 310: return PresenceAbsenceTerm.NATIVE_REPORTED_IN_ERROR();\r
+ case 320: return PresenceAbsenceTerm.NATIVE_PRESENCE_QUESTIONABLE();\r
+ case 330: return PresenceAbsenceTerm.NATIVE_FORMERLY_NATIVE();\r
+ case 340: return PresenceAbsenceTerm.NATIVE_DOUBTFULLY_NATIVE();\r
+ case 350: return PresenceAbsenceTerm.NATIVE();\r
+ case 999: {\r
+ logger.info("endemic for EM can not be transformed in legal status. Used 'PRESENT' instead");\r
+ //TODO preliminary\r
+ return PresenceAbsenceTerm.PRESENT();\r
+ }\r
+ default: {\r
+ throw new UnknownCdmTypeException("Unknown occurrence status (id=" + Integer.valueOf(occStatusId).toString() + ")");\r
+ }\r
+ }\r
+ }\r
+\r
+\r
+ //FactCategory\r
+ public static Feature factCategory2Feature (int factCategoryId) throws UnknownCdmTypeException{\r
+ switch (factCategoryId){\r
+ case 0: return null;\r
+ case 1: return Feature.DESCRIPTION();\r
+ case 4: return Feature.ECOLOGY();\r
+ case 5: return Feature.PHENOLOGY();\r
+ case 12: return Feature.COMMON_NAME();\r
+ case 13: return Feature.OCCURRENCE();\r
+ case 99: return Feature.CITATION();\r
+ default: {\r
+ throw new UnknownCdmTypeException("Unknown FactCategory (id=" + Integer.valueOf(factCategoryId).toString() + ")");\r
+ }\r
+ }\r
+ }\r
+\r
+ public static UUID getFeatureUuid(String key) throws UndefinedTransformerMethodException {\r
+ if (key == null){\r
+ return null;\r
+ }else if (key.equalsIgnoreCase("14-Maps")){ return uuidFeatureMaps;\r
+ }else if (key.equalsIgnoreCase("301-Conservation Status")){ return uuidFeatureConservationStatus;\r
+ }else if (key.equalsIgnoreCase("302-Use")){ return uuidFeatureUse;\r
+ }else if (key.equalsIgnoreCase("303-Comments")){ return uuidFeatureComments;\r
+\r
+ }else if (key.equalsIgnoreCase("10-general distribution (Euro+Med)")){ return uuidFeatureDistrEM;\r
+ }else if (key.equalsIgnoreCase("11-general distribution (world)")){ return uuidFeatureDistrWorld;\r
+ }else if (key.equalsIgnoreCase("250-Editor_Brackets")){ return uuidFeatureEditorBrackets;\r
+ }else if (key.equalsIgnoreCase("251-Editor_Parenthesis")){ return uuidFeatureEditorParenthesis;\r
+ }else if (key.equalsIgnoreCase("252-Inedited")){ return uuidFeatureInedited;\r
+ }else if (key.equalsIgnoreCase("253-Comments on editing process")){ return uuidFeatureCommentsEditing;\r
+\r
+ }else{\r
+ return null;\r
+ }\r
+ }\r
+\r
+\r
+ static Rank collSpeciesRank;\r
+ /**\r
+ * @param i\r
+ * @return\r
+ */\r
+ private static Rank rankId2NewRank(Integer rankId, boolean switchRank) {\r
+ Rank result = null;\r
+ if (rankId == null){\r
+ return null;\r
+ }else if (rankId == 57){\r
+\r
+ if (collSpeciesRank == null){\r
+ collSpeciesRank = Rank.NewInstance(RankClass.SpeciesGroup, "Collective species", "Coll. species", "coll.");\r
+ collSpeciesRank.setUuid(uuidRankCollSpecies);\r
+ OrderedTermVocabulary<Rank> voc = (OrderedTermVocabulary<Rank>)Rank.SPECIES().getVocabulary();\r
+ voc.addTermBelow(collSpeciesRank, Rank.SPECIESGROUP());\r
+ }\r
+ result = collSpeciesRank;\r
+ }\r
+ return result;\r
+ }\r
+\r
+\r
+ public static Rank rankId2Rank (ResultSet rs, boolean useUnknown, boolean switchSpeciesGroup) throws UnknownCdmTypeException{\r
+ Rank result;\r
+ try {\r
+ int rankId = rs.getInt("rankFk");\r
+\r
+ String abbrev = rs.getString("rankAbbrev");\r
+ String rankName = rs.getString("rank");\r
+ if (logger.isDebugEnabled()){logger.debug(rankId);}\r
+ if (logger.isDebugEnabled()){logger.debug(abbrev);}\r
+ if (logger.isDebugEnabled()){logger.debug(rankName);}\r
+\r
+ if (switchSpeciesGroup){\r
+ if (rankId == 59){\r
+ rankId = 57;\r
+ }else if (rankId == 57){\r
+ rankId = 59;\r
+ }\r
+ }\r
+ try {\r
+ result = Rank.getRankByNameOrIdInVoc(abbrev);\r
+ } catch (UnknownCdmTypeException e) {\r
+ try {\r
+ result = Rank.getRankByNameOrIdInVoc(rankName);\r
+ } catch (UnknownCdmTypeException e1) {\r
+ switch (rankId){\r
+ case 0: return null;\r
+ case 1: return Rank.KINGDOM();\r
+ case 3: return Rank.SUBKINGDOM();\r
+ case 5: return Rank.PHYLUM();\r
+ case 7: return Rank.SUBPHYLUM();\r
+ case 8: return Rank.DIVISION();\r
+ case 9: return Rank.SUBDIVISION();\r
+ case 10: return Rank.CLASS();\r
+ case 13: return Rank.SUBCLASS();\r
+ case 16: return Rank.SUPERORDER();\r
+ case 18: return Rank.ORDER();\r
+ case 19: return Rank.SUBORDER();\r
+ case 20: return Rank.FAMILY();\r
+ case 25: return Rank.SUBFAMILY();\r
+ case 30: return Rank.TRIBE();\r
+ case 35: return Rank.SUBTRIBE();\r
+ case 40: return Rank.GENUS();\r
+ case 42: return Rank.SUBGENUS();\r
+ case 45: return Rank.SECTION_BOTANY();\r
+ case 47: return Rank.SUBSECTION_BOTANY();\r
+ case 50: return Rank.SERIES();\r
+ case 52: return Rank.SUBSERIES();\r
+ case 58: return Rank.SPECIESAGGREGATE();\r
+ case 59: return Rank.SPECIESGROUP();\r
+ case 60: return Rank.SPECIES();\r
+ case 61: return Rank.GREX();\r
+ case 65: return Rank.SUBSPECIES();\r
+ case 66: {System.out.println("Rank 66 not yet implemented"); throw new UnknownCdmTypeException("Unknown Rank id" + Integer.valueOf(rankId).toString());}\r
+ case 67: {System.out.println("Rank 67 not yet implemented"); throw new UnknownCdmTypeException("Unknown Rank id" + Integer.valueOf(rankId).toString());}\r
+ case 68: return Rank.CONVAR();\r
+ case 70: return Rank.VARIETY();\r
+ case 73: return Rank.SUBVARIETY();\r
+ case 80: return Rank.FORM();\r
+ case 82: return Rank.SUBFORM();\r
+ case 84: return Rank.SPECIALFORM();\r
+ case 98: return Rank.INFRAGENERICTAXON();\r
+ case 99: return Rank.INFRASPECIFICTAXON();\r
+\r
+ case 750: return Rank.SUPERCLASS();\r
+ case 780: return Rank.INFRACLASS();\r
+ case 820: return Rank.INFRAORDER();\r
+\r
+ case 830: return Rank.SUPERFAMILY();\r
+\r
+ default: {\r
+ Rank rank = rankId2NewRank(57, switchSpeciesGroup);\r
+ if (rank != null){\r
+ return rank;\r
+ }\r
+ if (useUnknown){\r
+ logger.error("Rank unknown: " + rankId + ". Created UNKNOWN_RANK");\r
+ return Rank.UNKNOWN_RANK();\r
+ }\r
+ throw new UnknownCdmTypeException("Unknown Rank id" + Integer.valueOf(rankId).toString());\r
+ }\r
+ }\r
+ }\r
+ }\r
+ return result;\r
+ } catch (SQLException e) {\r
+ e.printStackTrace();\r
+ logger.warn("Exception occurred. Created UNKNOWN_RANK instead");\r
+ return Rank.UNKNOWN_RANK();\r
+ }\r
+ }\r
+\r
+\r
+ public static Integer rank2RankId (Rank rank){\r
+ if (rank == null){\r
+ return null;\r
+ }\r
+ else if (rank.equals(Rank.KINGDOM())){ return 1;}\r
+ else if (rank.equals(Rank.SUBKINGDOM())){ return 3;}\r
+ else if (rank.equals(Rank.PHYLUM())){ return 5;}\r
+ else if (rank.equals(Rank.SUBPHYLUM())){ return 7;}\r
+ else if (rank.equals(Rank.DIVISION())){ return 8;}\r
+ else if (rank.equals(Rank.SUBDIVISION())){ return 9;}\r
+\r
+ else if (rank.equals(Rank.CLASS())){ return 10;}\r
+ else if (rank.equals(Rank.SUBCLASS())){ return 13;}\r
+ else if (rank.equals(Rank.SUPERORDER())){ return 16;}\r
+ else if (rank.equals(Rank.ORDER())){ return 18;}\r
+ else if (rank.equals(Rank.SUBORDER())){ return 19;}\r
+ else if (rank.equals(Rank.FAMILY())){ return 20;}\r
+ else if (rank.equals(Rank.SUBFAMILY())){ return 25;}\r
+ else if (rank.equals(Rank.TRIBE())){ return 30;}\r
+ else if (rank.equals(Rank.SUBTRIBE())){ return 35;}\r
+ else if (rank.equals(Rank.GENUS())){ return 40;}\r
+ else if (rank.equals(Rank.SUBGENUS())){ return 42;}\r
+ else if (rank.equals(Rank.SECTION_BOTANY())){ return 45;}\r
+ else if (rank.equals(Rank.SUBSECTION_BOTANY())){ return 47;}\r
+ else if (rank.equals(Rank.SERIES())){ return 50;}\r
+ else if (rank.equals(Rank.SUBSERIES())){ return 52;}\r
+ else if (rank.equals(Rank.SPECIESAGGREGATE())){ return 58;}\r
+ //TODO\r
+ // else if (rank.equals(Rank.XXX())){ return 59;}\r
+ else if (rank.equals(Rank.SPECIES())){ return 60;}\r
+ else if (rank.equals(Rank.SUBSPECIES())){ return 65;}\r
+ else if (rank.equals(Rank.CONVAR())){ return 68;}\r
+ else if (rank.equals(Rank.VARIETY())){ return 70;}\r
+ else if (rank.equals(Rank.SUBVARIETY())){ return 73;}\r
+ else if (rank.equals(Rank.FORM())){ return 80;}\r
+ else if (rank.equals(Rank.SUBFORM())){ return 82;}\r
+ else if (rank.equals(Rank.SPECIALFORM())){ return 84;}\r
+ else if (rank.equals(Rank.INFRAGENERICTAXON())){ return 98;}\r
+ else if (rank.equals(Rank.INFRASPECIFICTAXON())){ return 99;}\r
+\r
+ else if (rank.equals(Rank.SUPERCLASS())){ return 750;}\r
+ else if (rank.equals(Rank.INFRACLASS())){ return 780;}\r
+ else if (rank.equals(Rank.INFRAORDER())){ return 820;}\r
+ else if (rank.equals(Rank.SUPERFAMILY())){ return 830;}\r
+\r
+ else {\r
+ //TODO Exception\r
+ logger.warn("Rank not yet supported in Berlin Model: "+ rank.getLabel());\r
+ return null;\r
+ }\r
+ }\r
+\r
+ public static Integer textData2FactCategoryFk (Feature feature){\r
+ if (feature == null){return null;}\r
+ if (feature.equals(Feature.DESCRIPTION())){\r
+ return 1;\r
+ }else if (feature.equals(Feature.ECOLOGY())){\r
+ return 4;\r
+ }else if (feature.equals(Feature.PHENOLOGY())){\r
+ return 5;\r
+ }else if (feature.equals(Feature.COMMON_NAME())){\r
+ return 12;\r
+ }else if (feature.equals(Feature.OCCURRENCE())){\r
+ return 13;\r
+ }else if (feature.equals(Feature.CITATION())){\r
+ return 99;\r
+ }else{\r
+ logger.debug("Unknown Feature.");\r
+ return null;\r
+ }\r
+ }\r
+\r
+\r
+ public static Integer taxonBase2statusFk (TaxonBase<?> taxonBase){\r
+ if (taxonBase == null){return null;}\r
+ if (taxonBase.isInstanceOf(Taxon.class)){\r
+ return T_STATUS_ACCEPTED;\r
+ }else if (taxonBase.isInstanceOf(Synonym.class)){\r
+ return T_STATUS_SYNONYM;\r
+ }else{\r
+ logger.warn("Unknown ");\r
+ return T_STATUS_UNRESOLVED;\r
+ }\r
+ //TODO\r
+// public static int T_STATUS_PARTIAL_SYN = 3;\r
+// public static int T_STATUS_PRO_PARTE_SYN = 4;\r
+// public static int T_STATUS_UNRESOLVED = 5;\r
+// public static int T_STATUS_ORPHANED = 6;\r
+ }\r
+\r
+ public static Integer ref2refCategoryId (Reference<?> ref){\r
+ if (ref == null){\r
+ return null;\r
+ }\r
+ else if (ref.getType().equals(ReferenceType.Article)){ return REF_ARTICLE;}\r
+ else if (ref instanceof ISection){ return REF_PART_OF_OTHER_TITLE;}\r
+ else if (ref.getType().equals(ReferenceType.Book)){ return REF_BOOK;}\r
+ else if (ref.getType().equals(ReferenceType.Database)){ return REF_DATABASE;}\r
+// else if (ref instanceof SectionBas){ return REF_INFORMAL;}\r
+// else if (ref instanceof SectionBas){ return REF_NOT_APPLICABLE;}\r
+ else if (ref.getType().equals(ReferenceType.WebPage)){ return REF_WEBSITE;}\r
+ else if (ref.getType().equals(ReferenceType.CdDvd)){ return REF_CD;}\r
+ else if (ref.getType().equals(ReferenceType.Journal)){ return REF_JOURNAL;}\r
+ else if (ref.getType().equals(ReferenceType.Generic)){ return REF_UNKNOWN;}\r
+ else if (ref.getType().equals(ReferenceType.PrintSeries)){\r
+ logger.warn("Print Series is not a standard Berlin Model category");\r
+ return REF_PRINT_SERIES;\r
+ }\r
+ else if (ref.getType().equals(ReferenceType.Proceedings)){\r
+ logger.warn("Proceedings is not a standard Berlin Model category");\r
+ return REF_CONFERENCE_PROCEEDINGS;\r
+ }\r
+// else if (ref instanceof ){ return REF_JOURNAL_VOLUME;}\r
+ else if (ref.getType().equals(ReferenceType.Patent)){ return REF_NOT_APPLICABLE;}\r
+ else if (ref.getType().equals(ReferenceType.PersonalCommunication)){ return REF_INFORMAL;}\r
+ else if (ref.getType().equals(ReferenceType.Report)){ return REF_NOT_APPLICABLE;}\r
+ else if (ref.getType().equals(ReferenceType.Thesis)){ return REF_NOT_APPLICABLE;}\r
+ else if (ref.getType().equals(ReferenceType.Report)){ return REF_NOT_APPLICABLE;}\r
+\r
+ else {\r
+ //TODO Exception\r
+ logger.warn("Reference type not yet supported in Berlin Model: "+ ref.getClass().getSimpleName());\r
+ return null;\r
+ }\r
+ }\r
+\r
+\r
+ public static Integer taxRelation2relPtQualifierFk (RelationshipBase<?,?,?> rel){\r
+ if (rel == null){\r
+ return null;\r
+ }\r
+// else if (rel instanceof SynonymRelationship){\r
+// return ;\r
+// }else if (rel instanceof TaxonRelationship){\r
+ RelationshipTermBase<?> type = rel.getType();\r
+ if (type.equals(TaxonRelationshipType.TAXONOMICALLY_INCLUDED_IN())) {return TAX_REL_IS_INCLUDED_IN;\r
+ }else if (type.equals(TaxonRelationshipType.MISAPPLIED_NAME_FOR())) {return TAX_REL_IS_MISAPPLIED_NAME_OF;\r
+ }else if (type.equals(SynonymRelationshipType.SYNONYM_OF())) {return TAX_REL_IS_SYNONYM_OF;\r
+ }else if (type.equals(SynonymRelationshipType.HOMOTYPIC_SYNONYM_OF())) {return TAX_REL_IS_HOMOTYPIC_SYNONYM_OF;\r
+ }else if (type.equals(SynonymRelationshipType.HETEROTYPIC_SYNONYM_OF())) {return TAX_REL_IS_HETEROTYPIC_SYNONYM_OF;\r
+ }else if (type.equals(TaxonRelationshipType.CONGRUENT_TO())) {return 11;\r
+// public static int TAX_REL_IS_PROPARTE_SYN_OF = 4;\r
+// public static int TAX_REL_IS_PARTIAL_SYN_OF = 5;\r
+// public static int TAX_REL_IS_PROPARTE_HOMOTYPIC_SYNONYM_OF = 101;\r
+// public static int TAX_REL_IS_PROPARTE_HETEROTYPIC_SYNONYM_OF = 102;\r
+// public static int TAX_REL_IS_PARTIAL_HOMOTYPIC_SYNONYM_OF = 103;\r
+// public static int TAX_REL_IS_PARTIAL_HETEROTYPIC_SYNONYM_OF = 104;\r
+\r
+ }else {\r
+ //TODO Exception\r
+ logger.warn("Relationship type not yet supported by Berlin Model export: "+ rel.getType());\r
+ return null;\r
+ }\r
+ }\r
+\r
+ public static Integer nomStatus2nomStatusFk (NomenclaturalStatusType status){\r
+ if (status == null){\r
+ return null;\r
+ }\r
+ if (status.equals(NomenclaturalStatusType.INVALID())) {return NAME_ST_NOM_INVAL;\r
+ }else if (status.equals(NomenclaturalStatusType.ILLEGITIMATE())) {return NAME_ST_NOM_ILLEG;\r
+ }else if (status.equals(NomenclaturalStatusType.NUDUM())) {return NAME_ST_NOM_NUD;\r
+ }else if (status.equals(NomenclaturalStatusType.REJECTED())) {return NAME_ST_NOM_REJ;\r
+ }else if (status.equals(NomenclaturalStatusType.REJECTED_PROP())) {return NAME_ST_NOM_REJ_PROP;\r
+ }else if (status.equals(NomenclaturalStatusType.UTIQUE_REJECTED())) {return NAME_ST_NOM_UTIQUE_REJ;\r
+ }else if (status.equals(NomenclaturalStatusType.UTIQUE_REJECTED_PROP())) {return NAME_ST_NOM_UTIQUE_REJ_PROP;\r
+ }else if (status.equals(NomenclaturalStatusType.CONSERVED())) {return NAME_ST_NOM_CONS;\r
+\r
+ }else if (status.equals(NomenclaturalStatusType.CONSERVED_PROP())) {return NAME_ST_NOM_CONS_PROP;\r
+ }else if (status.equals(NomenclaturalStatusType.ORTHOGRAPHY_CONSERVED())) {return NAME_ST_ORTH_CONS;\r
+ }else if (status.equals(NomenclaturalStatusType.ORTHOGRAPHY_CONSERVED_PROP())) {return NAME_ST_ORTH_CONS_PROP;\r
+ }else if (status.equals(NomenclaturalStatusType.SUPERFLUOUS())) {return NAME_ST_NOM_SUPERFL;\r
+ }else if (status.equals(NomenclaturalStatusType.AMBIGUOUS())) {return NAME_ST_NOM_AMBIG;\r
+ }else if (status.equals(NomenclaturalStatusType.PROVISIONAL())) {return NAME_ST_NOM_PROVIS;\r
+ }else if (status.equals(NomenclaturalStatusType.DOUBTFUL())) {return NAME_ST_NOM_DUB;\r
+ }else if (status.equals(NomenclaturalStatusType.NOVUM())) {return NAME_ST_NOM_NOV;\r
+\r
+ }else if (status.equals(NomenclaturalStatusType.CONFUSUM())) {return NAME_ST_NOM_CONFUS;\r
+ }else if (status.equals(NomenclaturalStatusType.ALTERNATIVE())) {return NAME_ST_NOM_ALTERN;\r
+ }else if (status.equals(NomenclaturalStatusType.COMBINATION_INVALID())) {return NAME_ST_COMB_INVAL;\r
+ //TODO\r
+ }else {\r
+ //TODO Exception\r
+ logger.warn("NomStatus type not yet supported by Berlin Model export: "+ status);\r
+ return null;\r
+ }\r
+ }\r
+\r
+\r
+\r
+ public static Integer nameRel2RelNameQualifierFk (RelationshipBase<?,?,?> rel){\r
+ if (rel == null){\r
+ return null;\r
+ }\r
+ RelationshipTermBase<?> type = rel.getType();\r
+ if (type.equals(NameRelationshipType.BASIONYM())) {return NAME_REL_IS_BASIONYM_FOR;\r
+ }else if (type.equals(NameRelationshipType.LATER_HOMONYM())) {return NAME_REL_IS_LATER_HOMONYM_OF;\r
+ }else if (type.equals(NameRelationshipType.REPLACED_SYNONYM())) {return NAME_REL_IS_REPLACED_SYNONYM_FOR;\r
+ //TODO\r
+ }else if (type.equals(NameRelationshipType.VALIDATED_BY_NAME())) {return NAME_REL_IS_VALIDATION_OF;\r
+ }else if (type.equals(NameRelationshipType.LATER_VALIDATED_BY_NAME())) {return NAME_REL_IS_LATER_VALIDATION_OF;\r
+ }else if (type.equals(NameRelationshipType.CONSERVED_AGAINST())) {return NAME_REL_IS_CONSERVED_AGAINST;\r
+\r
+\r
+ }else if (type.equals(NameRelationshipType.TREATED_AS_LATER_HOMONYM())) {return NAME_REL_IS_TREATED_AS_LATER_HOMONYM_OF;\r
+ }else if (type.equals(NameRelationshipType.ORTHOGRAPHIC_VARIANT())) {return NAME_REL_IS_ORTHOGRAPHIC_VARIANT_OF;\r
+ }else {\r
+ //TODO Exception\r
+ logger.warn("Relationship type not yet supported by Berlin Model export: "+ rel.getType());\r
+ return null;\r
+ }\r
+\r
+ //NameRelationShip\r
+\r
+// }else if (type.equals(NameRelationshipType.())) {return NAME_REL_IS_REJECTED_IN_FAVOUR_OF;\r
+\r
+// public static int NAME_REL_IS_FIRST_PARENT_OF = 9;\r
+// public static int NAME_REL_IS_SECOND_PARENT_OF = 10;\r
+// public static int NAME_REL_IS_FEMALE_PARENT_OF = 11;\r
+// public static int NAME_REL_IS_MALE_PARENT_OF = 12;\r
+//\r
+// public static int NAME_REL_IS_REJECTED_IN_FAVOUR_OF = 14;\r
+// }else if (type.equals(NameRelationshipType.)) {return NAME_REL_IS_REJECTED_TYPE_OF;\r
+//\r
+// public static int NAME_REL_HAS_SAME_TYPE_AS = 18;\r
+// public static int NAME_REL_IS_LECTOTYPE_OF = 61;\r
+// public static int NAME_REL_TYPE_NOT_DESIGNATED = 62;\r
+\r
+ // }else if (type.equals(NameRelationshipType.LATER_VALIDATED_BY_NAME())) {return NAME_REL_IS_TYPE_OF;\r
+\r
+\r
+ }\r
+\r
+ public static UUID getWebMarkerUuid (int markerCategoryId){\r
+ if (markerCategoryId == 1){\r
+ return UUID.fromString("d8554418-d1ae-471d-a1bd-a0cbc7ab860c"); //any as not to find in cichorieae\r
+ }else if (markerCategoryId == 2){\r
+ return UUID.fromString("7f189c48-8632-4870-9ec8-e4d2489f324e");\r
+ }else if (markerCategoryId == 3){\r
+ return UUID.fromString("9a115e6b-8210-4dd3-825a-6fed11016c63");\r
+ }else if (markerCategoryId == 4){\r
+ return UUID.fromString("1d287011-2054-41c5-a919-17ac1d0a9270");\r
+ }else if (markerCategoryId == 9){\r
+ return UUID.fromString("cc5eca5c-1ae5-4feb-9a95-507fc167b0c9");\r
+ //Salvador\r
+ }else if (markerCategoryId == 5){\r
+ return UUID.fromString("7d8875b3-107c-4189-97e5-cadb470e543a");\r
+ }else if (markerCategoryId == 20){\r
+ return UUID.fromString("3574e2b0-6431-4d71-b456-bc967c80f622");\r
+ }else if (markerCategoryId == 30){\r
+ return UUID.fromString("9924b27e-0dbe-4d95-ae9b-096fbbc3edcb");\r
+ }else if (markerCategoryId == 40){\r
+ return UUID.fromString("69241b97-f4d2-4f60-9aed-1c4ccb5bced5");\r
+ }else if (markerCategoryId == 50){\r
+ return UUID.fromString("f3b62ce3-0212-4542-a74c-0c68d08859b1");\r
+ }else if (markerCategoryId == 55){\r
+ return UUID.fromString("bec822f2-8242-425f-ad46-f11f0b82f69b");\r
+ }else if (markerCategoryId == 60){\r
+ return UUID.fromString("722fca60-0416-4bf0-aa4b-a07400f9710d");\r
+ }else if (markerCategoryId == 70){\r
+ return UUID.fromString("ed57857b-1001-4b09-b48e-d88ab146bb2b");\r
+ }else if (markerCategoryId == 80){\r
+ return UUID.fromString("637e8b77-1202-462b-9d77-1023f3c192d9");\r
+ }else if (markerCategoryId == 90){\r
+ return UUID.fromString("c769c231-6e76-46df-88f7-2c459342a3c2");\r
+ }else if (markerCategoryId == 93){\r
+ return UUID.fromString("075ee97e-246f-4f3d-aa96-16930df6268c");\r
+ }else if (markerCategoryId == 100){\r
+ return UUID.fromString("e17065bf-3e44-417a-b05c-f82929f680c3");\r
+ }else if (markerCategoryId == 110){\r
+ return UUID.fromString("e2b8de07-770e-4fda-b445-c4735f4e95c8");\r
+ }else if (markerCategoryId == 900){\r
+ return UUID.fromString("d029c3c9-944a-4bb9-bba6-12c95da94a04");\r
+ }else if (markerCategoryId == 920){\r
+ return UUID.fromString("98af97b1-e5e3-4ee4-902e-15032316bfc3");\r
+ }else if (markerCategoryId == 930){\r
+ return UUID.fromString("4b6c3130-4e50-4f45-8461-d2698cf5f80b");\r
+ }else if (markerCategoryId == 950){\r
+ return UUID.fromString("1e53f58c-6528-42c6-99ae-0f75a3c3c264");\r
+ }else if (markerCategoryId == 960){\r
+ return UUID.fromString("1903d460-94cc-4fc4-b2a8-a3fb0cfd69a0");\r
+ }else{\r
+ logger.warn("Unknown webMarker category: " + markerCategoryId);\r
+ return null;\r
+ }\r
+\r
+ }\r
+\r
+}\r
-/**
-* Copyright (C) 2009 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.util.UUID;
-
-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.name.NomenclaturalCode;
-import eu.etaxonomy.cdm.model.reference.Reference;
-
-/**
- * @author a.mueller
- * @created 29.01.2009
- * @version 1.0
- */
-public interface IImportConfigurator extends IIoConfigurator {
-
- public static enum CHECK{
- CHECK_ONLY,
- IMPORT_WITHOUT_CHECK,
- CHECK_AND_IMPORT;
-
- public boolean isImport(){
- return this == IMPORT_WITHOUT_CHECK || this == CHECK_AND_IMPORT ;
- }
- }
-
- public static enum EDITOR{
- NO_EDITORS, //leaves out createdBy and updatedBy information
- EDITOR_AS_ANNOTATION,//save createdBy and updatedBy in annotations
- EDITOR_AS_EDITOR, //save createdBy and updatedBy in createdBy and updatedBy
- }
-
- public static enum DO_REFERENCES{
- NONE,
- NOMENCLATURAL,
- CONCEPT_REFERENCES,
- ALL;
-
- public DO_REFERENCES invers(){
- if (this == DO_REFERENCES.NONE){
- return ALL;
- }else if (this == ALL){
- return NONE;
- }else if (this == NOMENCLATURAL){ //don't change
- return NOMENCLATURAL;
- }else if (this == CONCEPT_REFERENCES){ //don't change
- return CONCEPT_REFERENCES;
- }else{
- throw new RuntimeException("inverse for DO_REFERENCE type: " + this + " not yet handled");
- }
- }
- }
-
-
-
- public boolean isValid();
-
- /**
- * Factory method. Creates a new state for the import type and adds this configuration to it.
- * @return
- */
- public <STATE extends ImportStateBase> STATE getNewState();
-
- /* ****************** GETTER/SETTER **************************/
-
- /**
- * @return the doReferences
- */
- public CHECK getCheck();
-
- /**
- * @param doReferences the doReferences to set
- */
- public void setCheck(CHECK check);
-
- /**
- * @return the editor
- */
- public EDITOR getEditor();
-
- /**
- * @param editor sets the way how editing (created, updated) information is handled
- */
- public void setEditor(EDITOR editor);
-
- /**
- * If true, no errors occurs 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
- */
- public boolean isIgnoreNull();
- /**
- * @param ignoreNull the ignoreNull to set
- */
- public void setIgnoreNull(boolean ignoreNull);
-
-
- /**
- * The destination data source for the import
- * Don't use when using a spring data source
- * @return
- */
- public ICdmDataSource getDestination();
-
- public void setDestination(ICdmDataSource destination);
-
- @Override
- public DbSchemaValidation getDbSchemaValidation();
-
- @Override
- public void setDbSchemaValidation(
- DbSchemaValidation dbSchemaValidation);
-
- /**
- * The reference that represents the source. E.g. if the import source is a database
- * the returned reference should be of type eu.etaxonomy.cdm.model.reference.Database and
- * should represent the according database.
- * If the import comes from a file (e.g. XML) the returned value should best represent the
- * source of this file (e.g. if the source of an XML file is a certain database this database
- * should be mentioned as the source. Otherwise a eu.etaxonomy.cdm.model.reference.Generic
- * reference with the name of the XML file should be returned value
- * @return
- */
- public Reference getSourceReference();
-
-
- /**
- * Any object that represents the Source. The implementing class must cast this to
- * the correct class type
- * @return
- */
- public Object getSource();
-
- //public abstract void setSource(Object url);
-
- public void setSourceReference(Reference sourceReference);
-
- public String getSourceReferenceTitle();
-
- public void setSourceReferenceTitle(String sourceReferenceTitle);
-
- public Person getCommentator();
-
- public void setCommentator(Person commentator);
-
- public NomenclaturalCode getNomenclaturalCode();
-
- public void setNomenclaturalCode(NomenclaturalCode nomenclaturalCode);
-
- public Class<ICdmIO>[] getIoClassList();
-
-// public String[] getIoBeans();
-// public void setIoBeans(String[] ioBeans);
-
- /**
- * Returns a <code>CdmApplicationController</code> created by the values of this configuration.
- * If a controller was already created before the last created controller is returned.
- * @return
- */
-// public CdmApplicationController getCdmAppController();
-// public CdmApplicationController getCdmAppController(boolean createNew, boolean omitTermLoading);
-//
- public Object getSourceSecId();
-
-
-
- /**
- * If this import implicitly represents a classification in the destination CDM database
- * one can define the classification's uuid here. The congrete import class must support this
- * functionality otherwise it will have no effect.
- * @return
- */
- public UUID getClassificationUuid();
- public void setClassificationUuid(UUID treeUuid);
-
- /**
- * If one wants do define the uuid of the accepted taxa (except for missaplied names) this can be
- * done here
- * @return
- */
- public UUID getSecUuid();
- public void setSecUuid(UUID secUuid);
-
-
- /**
- * Returns the transformer used during import
- * @return
- */
- public IInputTransformer getTransformer();
-
- /**
- * Sets the transformer used during import
- * @param transformer
- */
- public void setTransformer(IInputTransformer transformer);
-
-
- /**
- * Defines if term loading should take place if a new application controller
- * is created. Usually should return false as imports run into existing databases.
- * However, some imports like the current implementation of the JAXB import require
- * to create ALL data anew and import the data itself. Therefore they need to
- * allow omitting term loading.
- * This may be replaced by a more sophisticated solution in future.
- * @return
- */
- public boolean isOmitTermLoading();
-
- /**
- * Defines if the database will be created anew. Usually should return false as imports
- * run into existing databases.
- * However, some imports like the current implementation of the JAXB import require
- * to create ALL data anew. Therefore they need to allow to create all data anew.
- * This may be replaced by a more sophisticated solution in future.
- * @return
- */
- public boolean isCreateNew();
-
+/**\r
+* Copyright (C) 2009 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.util.UUID;\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.name.NomenclaturalCode;\r
+import eu.etaxonomy.cdm.model.reference.Reference;\r
+\r
+/**\r
+ * @author a.mueller\r
+ * @created 29.01.2009\r
+ * @version 1.0\r
+ */\r
+public interface IImportConfigurator extends IIoConfigurator {\r
+\r
+ public static enum CHECK{\r
+ CHECK_ONLY,\r
+ IMPORT_WITHOUT_CHECK,\r
+ CHECK_AND_IMPORT;\r
+\r
+ public boolean isImport(){\r
+ return this == IMPORT_WITHOUT_CHECK || this == CHECK_AND_IMPORT ;\r
+ }\r
+ }\r
+\r
+ public static enum EDITOR{\r
+ NO_EDITORS, //leaves out createdBy and updatedBy information\r
+ EDITOR_AS_ANNOTATION,//save createdBy and updatedBy in annotations\r
+ EDITOR_AS_EDITOR, //save createdBy and updatedBy in createdBy and updatedBy\r
+ }\r
+\r
+ public static enum DO_REFERENCES{\r
+ NONE,\r
+ NOMENCLATURAL,\r
+ CONCEPT_REFERENCES,\r
+ ALL;\r
+\r
+ public DO_REFERENCES invers(){\r
+ if (this == DO_REFERENCES.NONE){\r
+ return ALL;\r
+ }else if (this == ALL){\r
+ return NONE;\r
+ }else if (this == NOMENCLATURAL){ //don't change\r
+ return NOMENCLATURAL;\r
+ }else if (this == CONCEPT_REFERENCES){ //don't change\r
+ return CONCEPT_REFERENCES;\r
+ }else{\r
+ throw new RuntimeException("inverse for DO_REFERENCE type: " + this + " not yet handled");\r
+ }\r
+ }\r
+ }\r
+\r
+\r
+\r
+ public boolean isValid();\r
+\r
+ /**\r
+ * Factory method. Creates a new state for the import type and adds this configuration to it.\r
+ * @return\r
+ */\r
+ public <STATE extends ImportStateBase> STATE getNewState();\r
+\r
+ /* ****************** GETTER/SETTER **************************/\r
+\r
+ /**\r
+ * @return the doReferences\r
+ */\r
+ public CHECK getCheck();\r
+\r
+ /**\r
+ * @param doReferences the doReferences to set\r
+ */\r
+ public void setCheck(CHECK check);\r
+\r
+ /**\r
+ * @return the editor\r
+ */\r
+ public EDITOR getEditor();\r
+\r
+ /**\r
+ * @param editor sets the way how editing (created, updated) information is handled\r
+ */\r
+ public void setEditor(EDITOR editor);\r
+\r
+ /**\r
+ * If true, no errors occurs 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
+ public boolean isIgnoreNull();\r
+ /**\r
+ * @param ignoreNull the ignoreNull to set\r
+ */\r
+ public void setIgnoreNull(boolean ignoreNull);\r
+\r
+\r
+ /**\r
+ * The destination data source for the import\r
+ * Don't use when using a spring data source\r
+ * @return\r
+ */\r
+ public ICdmDataSource getDestination();\r
+\r
+ public void setDestination(ICdmDataSource destination);\r
+\r
+ @Override\r
+ public DbSchemaValidation getDbSchemaValidation();\r
+\r
+ @Override\r
+ public void setDbSchemaValidation(\r
+ DbSchemaValidation dbSchemaValidation);\r
+\r
+ /**\r
+ * The reference that represents the source. E.g. if the import source is a database\r
+ * the returned reference should be of type eu.etaxonomy.cdm.model.reference.Database and\r
+ * should represent the according database.\r
+ * If the import comes from a file (e.g. XML) the returned value should best represent the\r
+ * source of this file (e.g. if the source of an XML file is a certain database this database\r
+ * should be mentioned as the source. Otherwise a eu.etaxonomy.cdm.model.reference.Generic\r
+ * reference with the name of the XML file should be returned value\r
+ * @return\r
+ */\r
+ public Reference getSourceReference();\r
+\r
+\r
+ /**\r
+ * Any object that represents the Source. The implementing class must cast this to\r
+ * the correct class type\r
+ * @return\r
+ */\r
+ public Object getSource();\r
+\r
+ //public abstract void setSource(Object url);\r
+\r
+ public void setSourceReference(Reference sourceReference);\r
+\r
+ public String getSourceReferenceTitle();\r
+\r
+ public void setSourceReferenceTitle(String sourceReferenceTitle);\r
+\r
+ public Person getCommentator();\r
+\r
+ public void setCommentator(Person commentator);\r
+\r
+ public NomenclaturalCode getNomenclaturalCode();\r
+\r
+ public void setNomenclaturalCode(NomenclaturalCode nomenclaturalCode);\r
+\r
+ public Class<ICdmIO>[] getIoClassList();\r
+\r
+// public String[] getIoBeans();\r
+// public void setIoBeans(String[] ioBeans);\r
+\r
+ /**\r
+ * Returns a <code>CdmApplicationController</code> created by the values of this configuration.\r
+ * If a controller was already created before the last created controller is returned.\r
+ * @return\r
+ */\r
+// public CdmApplicationController getCdmAppController();\r
+// public CdmApplicationController getCdmAppController(boolean createNew, boolean omitTermLoading);\r
+//\r
+ public Object getSourceSecId();\r
+\r
+\r
+\r
+ /**\r
+ * If this import implicitly represents a classification in the destination CDM database\r
+ * one can define the classification's uuid here. The congrete import class must support this\r
+ * functionality otherwise it will have no effect.\r
+ * @return\r
+ */\r
+ public UUID getClassificationUuid();\r
+ public void setClassificationUuid(UUID treeUuid);\r
+\r
+ /**\r
+ * If one wants do define the uuid of the accepted taxa (except for missaplied names) this can be\r
+ * done here\r
+ * @return\r
+ */\r
+ public UUID getSecUuid();\r
+ public void setSecUuid(UUID secUuid);\r
+\r
+\r
+ /**\r
+ * Returns the transformer used during import\r
+ * @return\r
+ */\r
+ public IInputTransformer getTransformer();\r
+\r
+ /**\r
+ * Sets the transformer used during import\r
+ * @param transformer\r
+ */\r
+ public void setTransformer(IInputTransformer transformer);\r
+\r
+\r
+ /**\r
+ * Defines if term loading should take place if a new application controller\r
+ * is created. Usually should return false as imports run into existing databases.\r
+ * However, some imports like the current implementation of the JAXB import require\r
+ * to create ALL data anew and import the data itself. Therefore they need to\r
+ * allow omitting term loading.\r
+ * This may be replaced by a more sophisticated solution in future.\r
+ * @return\r
+ */\r
+ public boolean isOmitTermLoading();\r
+\r
+ /**\r
+ * Defines if the database will be created anew. Usually should return false as imports\r
+ * run into existing databases.\r
+ * However, some imports like the current implementation of the JAXB import require\r
+ * to create ALL data anew. Therefore they need to allow to create all data anew.\r
+ * This may be replaced by a more sophisticated solution in future.\r
+ * @return\r
+ */\r
+ public boolean isCreateNew();\r
+\r
}
\ No newline at end of file
-/**
-* 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.model.common;
-
-import java.util.HashSet;
-import java.util.Set;
-import java.util.UUID;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.FetchType;
-import javax.persistence.ManyToMany;
-import javax.persistence.Table;
-import javax.validation.constraints.NotNull;
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlElementWrapper;
-import javax.xml.bind.annotation.XmlIDREF;
-import javax.xml.bind.annotation.XmlRootElement;
-import javax.xml.bind.annotation.XmlSchemaType;
-import javax.xml.bind.annotation.XmlType;
-
-import org.apache.log4j.Logger;
-import org.hibernate.annotations.Cascade;
-import org.hibernate.annotations.CascadeType;
-import org.hibernate.search.annotations.Field;
-import org.hibernate.search.annotations.Indexed;
-import org.springframework.security.core.GrantedAuthority;
-
-@XmlAccessorType(XmlAccessType.FIELD)
-@XmlType(name = "Group", propOrder = {
- "name",
- "members",
- "grantedAuthorities"
-})
-@XmlRootElement(name = "Group")
-@Entity
-@Indexed(index = "eu.etaxonomy.cdm.model.common.Group")
-@Table(name = "PermissionGroup")
-public class Group extends CdmBase {
- private static final long serialVersionUID = 7216686200093054648L;
- private static final Logger logger = Logger.getLogger(Group.class);
-
- public final static UUID groupEditorUuid = UUID.fromString("22e5e8af-b99c-4884-a92f-71978efd3770");
- public final static UUID groupProjectManagerUuid = UUID.fromString("645191ae-32a4-4d4e-9b86-c90e0d41944a");
- public final static UUID groupPublisherUuid = UUID.fromString("c1f20ad8-1782-40a7-b06b-ce4773acb5ea");
-
-//*********************** FACTORY *********************/
-
- public static Group NewInstance(){
- return new Group();
- }
-
- public static Group NewInstance(String name){
- Group group = Group.NewInstance();
- group.setName(name);
- return group;
- }
-
-//**************** FIELDS ******************************/
-
- @XmlElement(name = "Name")
- @Column(unique = true)
- @Field
- @NotNull
- protected String name;
-
- @XmlElementWrapper(name = "Members")
- @XmlElement(name = "Member")
- @XmlIDREF
- @XmlSchemaType(name = "IDREF")
- @ManyToMany(fetch = FetchType.LAZY, mappedBy = "groups")
- @Cascade(CascadeType.REFRESH) // see #2414 (Group updating doesn't work)
- protected Set<User> members = new HashSet<User>();
-
- @XmlElementWrapper(name = "GrantedAuthorities")
- @XmlElement(name = "GrantedAuthority", type = GrantedAuthorityImpl.class)
- @XmlIDREF
- @XmlSchemaType(name = "IDREF")
- @ManyToMany(fetch = FetchType.LAZY, targetEntity = GrantedAuthorityImpl.class)
- @Cascade({CascadeType.SAVE_UPDATE,CascadeType.MERGE})
- protected Set <GrantedAuthority> grantedAuthorities = new HashSet<GrantedAuthority>();
-
-// ********************* CONSTRUCTOR ************************/
-
- protected Group(){
- super();
- }
-
-// *************** METHODS ***********************************/
-
- public Set<GrantedAuthority> getGrantedAuthorities() {
- return grantedAuthorities;
- }
-
- public boolean addGrantedAuthority(GrantedAuthority grantedAuthority){
- return grantedAuthorities.add(grantedAuthority);
- }
-
- public boolean removeGrantedAuthority(GrantedAuthority grantedAuthority){
- return grantedAuthorities.remove(grantedAuthority);
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getName() {
- return name;
- }
-
- public Set<User> getMembers() {
- return members;
- }
-
- public boolean addMember(User user) {
- user.getGroups().add(this);
- return this.members.add(user);
- }
-
- public boolean removeMember(User user) {
- if(members.contains(user)) {
- user.getGroups().remove(this);
- return this.members.remove(user);
- } else {
- return false;
- }
- }
-//*********************** CLONE ********************************************************/
-
- /**
- * Clones <i>this</i> Group. This is a shortcut that enables to create
- * a new instance that differs only slightly from <i>this</i> group by
- * modifying only some of the attributes.
- *
- * @see eu.etaxonomy.cdm.model.common.TermBase#clone()
- * @see java.lang.Object#clone()
- */
- @Override
- public Object clone() {
- Group result;
- try{
- result = (Group)super.clone();
- result.grantedAuthorities = new HashSet<GrantedAuthority>();
- for (GrantedAuthority grantedauthority: this.grantedAuthorities){
- result.addGrantedAuthority(grantedauthority);
- }
-
- result.members = new HashSet<User>();
- for (User member: this.members){
- result.addMember(member);
- }
-
- //no changes to name
- return result;
- } catch (CloneNotSupportedException e) {
- logger.warn("Object does not implement cloneable");
- e.printStackTrace();
- return null;
-
- }
-
-
- }
-
-}
+/**\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
+package eu.etaxonomy.cdm.model.common;\r
+\r
+import java.util.HashSet;\r
+import java.util.Set;\r
+import java.util.UUID;\r
+\r
+import javax.persistence.Column;\r
+import javax.persistence.Entity;\r
+import javax.persistence.FetchType;\r
+import javax.persistence.ManyToMany;\r
+import javax.persistence.Table;\r
+import javax.validation.constraints.NotNull;\r
+import javax.xml.bind.annotation.XmlAccessType;\r
+import javax.xml.bind.annotation.XmlAccessorType;\r
+import javax.xml.bind.annotation.XmlElement;\r
+import javax.xml.bind.annotation.XmlElementWrapper;\r
+import javax.xml.bind.annotation.XmlIDREF;\r
+import javax.xml.bind.annotation.XmlRootElement;\r
+import javax.xml.bind.annotation.XmlSchemaType;\r
+import javax.xml.bind.annotation.XmlType;\r
+\r
+import org.apache.log4j.Logger;\r
+import org.hibernate.annotations.Cascade;\r
+import org.hibernate.annotations.CascadeType;\r
+import org.hibernate.search.annotations.Field;\r
+import org.hibernate.search.annotations.Indexed;\r
+import org.springframework.security.core.GrantedAuthority;\r
+\r
+@XmlAccessorType(XmlAccessType.FIELD)\r
+@XmlType(name = "Group", propOrder = {\r
+ "name",\r
+ "members",\r
+ "grantedAuthorities"\r
+})\r
+@XmlRootElement(name = "Group")\r
+@Entity\r
+@Indexed(index = "eu.etaxonomy.cdm.model.common.Group")\r
+@Table(name = "PermissionGroup")\r
+public class Group extends CdmBase {\r
+ private static final long serialVersionUID = 7216686200093054648L;\r
+ private static final Logger logger = Logger.getLogger(Group.class);\r
+\r
+ public final static UUID groupEditorUuid = UUID.fromString("22e5e8af-b99c-4884-a92f-71978efd3770");\r
+ public final static UUID groupProjectManagerUuid = UUID.fromString("645191ae-32a4-4d4e-9b86-c90e0d41944a");\r
+ public final static UUID groupPublisherUuid = UUID.fromString("c1f20ad8-1782-40a7-b06b-ce4773acb5ea");\r
+\r
+//*********************** FACTORY *********************/\r
+\r
+ public static Group NewInstance(){\r
+ return new Group();\r
+ }\r
+\r
+ public static Group NewInstance(String name){\r
+ Group group = Group.NewInstance();\r
+ group.setName(name);\r
+ return group;\r
+ }\r
+\r
+//**************** FIELDS ******************************/\r
+\r
+ @XmlElement(name = "Name")\r
+ @Column(unique = true)\r
+ @Field\r
+ @NotNull\r
+ protected String name;\r
+\r
+ @XmlElementWrapper(name = "Members")\r
+ @XmlElement(name = "Member")\r
+ @XmlIDREF\r
+ @XmlSchemaType(name = "IDREF")\r
+ @ManyToMany(fetch = FetchType.LAZY, mappedBy = "groups")\r
+ @Cascade(CascadeType.REFRESH) // see #2414 (Group updating doesn't work)\r
+ protected Set<User> members = new HashSet<User>();\r
+\r
+ @XmlElementWrapper(name = "GrantedAuthorities")\r
+ @XmlElement(name = "GrantedAuthority", type = GrantedAuthorityImpl.class)\r
+ @XmlIDREF\r
+ @XmlSchemaType(name = "IDREF")\r
+ @ManyToMany(fetch = FetchType.LAZY, targetEntity = GrantedAuthorityImpl.class)\r
+ @Cascade({CascadeType.SAVE_UPDATE,CascadeType.MERGE})\r
+ protected Set <GrantedAuthority> grantedAuthorities = new HashSet<GrantedAuthority>();\r
+\r
+// ********************* CONSTRUCTOR ************************/\r
+\r
+ protected Group(){\r
+ super();\r
+ }\r
+\r
+// *************** METHODS ***********************************/\r
+\r
+ public Set<GrantedAuthority> getGrantedAuthorities() {\r
+ return grantedAuthorities;\r
+ }\r
+\r
+ public boolean addGrantedAuthority(GrantedAuthority grantedAuthority){\r
+ return grantedAuthorities.add(grantedAuthority);\r
+ }\r
+\r
+ public boolean removeGrantedAuthority(GrantedAuthority grantedAuthority){\r
+ return grantedAuthorities.remove(grantedAuthority);\r
+ }\r
+\r
+ public void setName(String name) {\r
+ this.name = name;\r
+ }\r
+\r
+ public String getName() {\r
+ return name;\r
+ }\r
+\r
+ public Set<User> getMembers() {\r
+ return members;\r
+ }\r
+\r
+ public boolean addMember(User user) {\r
+ user.getGroups().add(this);\r
+ return this.members.add(user);\r
+ }\r
+\r
+ public boolean removeMember(User user) {\r
+ if(members.contains(user)) {\r
+ user.getGroups().remove(this);\r
+ return this.members.remove(user);\r
+ } else {\r
+ return false;\r
+ }\r
+ }\r
+//*********************** CLONE ********************************************************/\r
+\r
+ /**\r
+ * Clones <i>this</i> Group. This is a shortcut that enables to create\r
+ * a new instance that differs only slightly from <i>this</i> group by\r
+ * modifying only some of the attributes.\r
+ *\r
+ * @see eu.etaxonomy.cdm.model.common.TermBase#clone()\r
+ * @see java.lang.Object#clone()\r
+ */\r
+ @Override\r
+ public Object clone() {\r
+ Group result;\r
+ try{\r
+ result = (Group)super.clone();\r
+ result.grantedAuthorities = new HashSet<GrantedAuthority>();\r
+ for (GrantedAuthority grantedauthority: this.grantedAuthorities){\r
+ result.addGrantedAuthority(grantedauthority);\r
+ }\r
+\r
+ result.members = new HashSet<User>();\r
+ for (User member: this.members){\r
+ result.addMember(member);\r
+ }\r
+\r
+ //no changes to name\r
+ return result;\r
+ } catch (CloneNotSupportedException e) {\r
+ logger.warn("Object does not implement cloneable");\r
+ e.printStackTrace();\r
+ return null;\r
+\r
+ }\r
+\r
+\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.persistence.dao.hibernate.description;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.UUID;
-
-import org.apache.commons.lang.ArrayUtils;
-import org.apache.log4j.Logger;
-import org.hibernate.Criteria;
-import org.hibernate.Query;
-import org.hibernate.criterion.ProjectionList;
-import org.hibernate.criterion.Projections;
-import org.hibernate.criterion.Restrictions;
-import org.hibernate.envers.query.AuditEntity;
-import org.hibernate.envers.query.AuditQuery;
-import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.stereotype.Repository;
-
-import eu.etaxonomy.cdm.model.common.DefinedTerm;
-import eu.etaxonomy.cdm.model.common.LSID;
-import eu.etaxonomy.cdm.model.common.MarkerType;
-import eu.etaxonomy.cdm.model.common.Representation;
-import eu.etaxonomy.cdm.model.description.CommonTaxonName;
-import eu.etaxonomy.cdm.model.description.DescriptionBase;
-import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
-import eu.etaxonomy.cdm.model.description.Feature;
-import eu.etaxonomy.cdm.model.description.PresenceAbsenceTerm;
-import eu.etaxonomy.cdm.model.description.SpecimenDescription;
-import eu.etaxonomy.cdm.model.description.TaxonDescription;
-import eu.etaxonomy.cdm.model.description.TaxonNameDescription;
-import eu.etaxonomy.cdm.model.location.NamedArea;
-import eu.etaxonomy.cdm.model.media.Media;
-import eu.etaxonomy.cdm.model.name.TaxonNameBase;
-import eu.etaxonomy.cdm.model.taxon.Taxon;
-import eu.etaxonomy.cdm.model.view.AuditEvent;
-import eu.etaxonomy.cdm.persistence.dao.common.OperationNotSupportedInPriorViewException;
-import eu.etaxonomy.cdm.persistence.dao.description.IDescriptionDao;
-import eu.etaxonomy.cdm.persistence.dao.hibernate.common.IdentifiableDaoBase;
-import eu.etaxonomy.cdm.persistence.dto.TermDto;
-import eu.etaxonomy.cdm.persistence.query.MatchMode;
-import eu.etaxonomy.cdm.persistence.query.OrderHint;
-
-@Repository
-@Qualifier("descriptionDaoImpl")
-public class DescriptionDaoImpl extends IdentifiableDaoBase<DescriptionBase> implements IDescriptionDao{
-
- private static final Logger logger = Logger.getLogger(DescriptionDaoImpl.class);
-
- public DescriptionDaoImpl() {
- super(DescriptionBase.class);
- indexedClasses = new Class[3];
- indexedClasses[0] = TaxonDescription.class;
- indexedClasses[1] = TaxonNameDescription.class;
- indexedClasses[2] = SpecimenDescription.class;
- }
-
-// @Override //Override for testing
-// public DescriptionBase load(UUID uuid, List<String> propertyPaths){
-// DescriptionBase bean = findByUuid(uuid);
-// if(bean == null){
-// return bean;
-// }
-// defaultBeanInitializer.initialize(bean, propertyPaths);
-//
-// return bean;
-// }
-
- @Override
- public int countDescriptionByDistribution(Set<NamedArea> namedAreas, PresenceAbsenceTerm status) {
- checkNotInPriorView("DescriptionDaoImpl.countDescriptionByDistribution(Set<NamedArea> namedAreas, PresenceAbsenceTermBase status)");
- Query query = null;
-
- if(status == null) {
- query = getSession().createQuery("select count(distinct description) from TaxonDescription description left join description.descriptionElements element join element.area area where area in (:namedAreas)");
- } else {
- query = getSession().createQuery("select count(distinct description) from TaxonDescription description left join description.descriptionElements element join element.area area join element.status status where area in (:namedAreas) and status = :status");
- query.setParameter("status", status);
- }
- query.setParameterList("namedAreas", namedAreas);
-
- return ((Long)query.uniqueResult()).intValue();
- }
-
- @Override
- public int countDescriptionElements(DescriptionBase description, Set<Feature> features, Class<? extends DescriptionElementBase> clazz) {
- return countDescriptionElements(description, null, features, clazz);
- }
-
- @Override
- public int countDescriptionElements(DescriptionBase description, Class<? extends DescriptionBase> descriptionType,
- Set<Feature> features, Class<? extends DescriptionElementBase> clazz) {
- AuditEvent auditEvent = getAuditEventFromContext();
- if(auditEvent.equals(AuditEvent.CURRENT_VIEW)) {
- Criteria criteria = null;
- if(clazz == null) {
- criteria = getSession().createCriteria(DescriptionElementBase.class);
- } else {
- criteria = getSession().createCriteria(clazz);
- }
-
- if(description != null) {
- criteria.add(Restrictions.eq("inDescription", description));
- }
-
- if(descriptionType != null) {
- criteria.createAlias("inDescription", "d").add(Restrictions.eq("d.class", descriptionType));
- }
-
- if(features != null && !features.isEmpty()) {
- criteria.add(Restrictions.in("feature", features));
- }
-
- criteria.setProjection(Projections.rowCount());
-
- return ((Number)criteria.uniqueResult()).intValue();
- } else {
- if(features != null && !features.isEmpty()) {
- Integer count = 0;
- for(Feature f : features) {
- AuditQuery query = null;
- if(clazz == null) {
- query = getAuditReader().createQuery().forEntitiesAtRevision(DescriptionElementBase.class,auditEvent.getRevisionNumber());
- } else {
- query = getAuditReader().createQuery().forEntitiesAtRevision(clazz,auditEvent.getRevisionNumber());
- }
-
- if(description != null) {
- query.add(AuditEntity.relatedId("inDescription").eq(description.getId()));
- }
-
- if(descriptionType != null) {
- query.add(AuditEntity.property("inDescription.class").eq(descriptionType));
- }
-
- query.add(AuditEntity.relatedId("feature").eq(f.getId()));
- query.addProjection(AuditEntity.id().count("id"));
- count += ((Long)query.getSingleResult()).intValue();
- }
-
- return count;
- } else {
- AuditQuery query = null;
- if(clazz == null) {
- query = getAuditReader().createQuery().forEntitiesAtRevision(DescriptionElementBase.class,auditEvent.getRevisionNumber());
- } else {
- query = getAuditReader().createQuery().forEntitiesAtRevision(clazz,auditEvent.getRevisionNumber());
- }
-
- if(description != null) {
- query.add(AuditEntity.relatedId("inDescription").eq(description.getId()));
- }
- if(descriptionType != null) {
- query.add(AuditEntity.property("inDescription.class").eq(descriptionType));
- }
-
- query.addProjection(AuditEntity.id().count("id"));
- return ((Long)query.getSingleResult()).intValue();
- }
- }
- }
-
- @Override
- public int countDescriptions(Class<? extends DescriptionBase> clazz, Boolean hasImages, Boolean hasText, Set<Feature> features) {
- checkNotInPriorView("DescriptionDaoImpl.countDescriptions(Class<TYPE> type, Boolean hasImages, Boolean hasText, Set<Feature> features)");
- Criteria inner = null;
-
- if(clazz == null) {
- inner = getSession().createCriteria(type);
- } else {
- inner = getSession().createCriteria(clazz);
- }
-
- Criteria elementsCriteria = inner.createCriteria("descriptionElements");
- if(hasText != null) {
- if(hasText) {
- elementsCriteria.add(Restrictions.isNotEmpty("multilanguageText"));
- } else {
- elementsCriteria.add(Restrictions.isEmpty("multilanguageText"));
- }
- }
-
- if(hasImages != null) {
- if(hasImages) {
- elementsCriteria.add(Restrictions.isNotEmpty("media"));
- } else {
- elementsCriteria.add(Restrictions.isEmpty("media"));
- }
- }
-
- if(features != null && !features.isEmpty()) {
- elementsCriteria.add(Restrictions.in("feature", features));
- }
-
- inner.setProjection(Projections.countDistinct("id"));
-
- return ((Number) inner.uniqueResult()).intValue();
- }
-
- @Override
- public int countTaxonDescriptions(Taxon taxon, Set<DefinedTerm> scopes,Set<NamedArea> geographicalScopes, Set<MarkerType> markerTypes) {
- AuditEvent auditEvent = getAuditEventFromContext();
- if(auditEvent.equals(AuditEvent.CURRENT_VIEW)) {
- Criteria criteria = getSession().createCriteria(TaxonDescription.class);
-
- if(taxon != null) {
- criteria.add(Restrictions.eq("taxon", taxon));
- }
-
- if(scopes != null && !scopes.isEmpty()) {
- Set<Integer> scopeIds = new HashSet<Integer>();
- for(DefinedTerm s : scopes) {
- scopeIds.add(s.getId());
- }
- criteria.createCriteria("scopes").add(Restrictions.in("id", scopeIds));
- }
-
- if(geographicalScopes != null && !geographicalScopes.isEmpty()) {
- Set<Integer> geoScopeIds = new HashSet<Integer>();
- for(NamedArea n : geographicalScopes) {
- geoScopeIds.add(n.getId());
- }
- criteria.createCriteria("geoScopes").add(Restrictions.in("id", geoScopeIds));
- }
-
-
- addMarkerTypesCriterion(markerTypes, criteria);
-
-
- criteria.setProjection(Projections.rowCount());
-
- return ((Number)criteria.uniqueResult()).intValue();
- } else {
- if((scopes == null || scopes.isEmpty())&& (geographicalScopes == null || geographicalScopes.isEmpty()) && (markerTypes == null || markerTypes.isEmpty())) {
- AuditQuery query = getAuditReader().createQuery().forEntitiesAtRevision(TaxonDescription.class,auditEvent.getRevisionNumber());
- if(taxon != null) {
- query.add(AuditEntity.relatedId("taxon").eq(taxon.getId()));
- }
-
- query.addProjection(AuditEntity.id().count("id"));
-
- return ((Long)query.getSingleResult()).intValue();
- } else {
- throw new OperationNotSupportedInPriorViewException("countTaxonDescriptions(Taxon taxon, Set<Scope> scopes,Set<NamedArea> geographicalScopes)");
- }
- }
- }
-
- /**
- * @param markerTypes
- * @param criteria
- *
- */
- //TODO move to AnnotatableEntityDao(?)
- private void addMarkerTypesCriterion(Set<MarkerType> markerTypes, Criteria criteria) {
-
- if(markerTypes != null && !markerTypes.isEmpty()) {
- Set<Integer> markerTypeIds = new HashSet<Integer>();
- for(MarkerType markerType : markerTypes) {
- markerTypeIds.add(markerType.getId());
- }
- criteria.createCriteria("markers").add(Restrictions.eq("flag", true))
- .createAlias("markerType", "mt")
- .add(Restrictions.in("mt.id", markerTypeIds));
- } else if (markerTypes != null && markerTypes.isEmpty()){
- //AT: added in case the projects requires an third state description, An empty Marker type set
- }
- }
- @Override
- public List<DescriptionElementBase> getDescriptionElements(
- DescriptionBase description, Set<Feature> features,
- Class<? extends DescriptionElementBase> clazz, Integer pageSize, Integer pageNumber, List<String> propertyPaths) {
- return getDescriptionElements(description, null, features, clazz, pageSize, pageNumber, propertyPaths);
- }
-
- @Override
- public List<DescriptionElementBase> getDescriptionElements(
- DescriptionBase description, Class<? extends DescriptionBase> descriptionType,
- Set<Feature> features,
- Class<? extends DescriptionElementBase> clazz,
- Integer pageSize, Integer pageNumber, List<String> propertyPaths) {
-
- AuditEvent auditEvent = getAuditEventFromContext();
- if(auditEvent.equals(AuditEvent.CURRENT_VIEW)) {
- Criteria criteria = null;
- if(clazz == null) {
- criteria = getSession().createCriteria(DescriptionElementBase.class);
- } else {
- criteria = getSession().createCriteria(clazz);
- }
-
- if(description != null) {
- criteria.add(Restrictions.eq("inDescription", description));
- }
- if(descriptionType != null) {
- criteria.createAlias("inDescription", "d").add(Restrictions.eq("d.class", descriptionType));
- }
-
- if(features != null && !features.isEmpty()) {
- criteria.add(Restrictions.in("feature", features));
- }
-
- if(pageSize != null) {
- criteria.setMaxResults(pageSize);
- if(pageNumber != null) {
- criteria.setFirstResult(pageNumber * pageSize);
- }
- }
-
- List<DescriptionElementBase> results = criteria.list();
-
- defaultBeanInitializer.initializeAll(results, propertyPaths);
-
- return results;
- } else {
- List<DescriptionElementBase> result = new ArrayList<DescriptionElementBase>();
- if(features != null && !features.isEmpty()) {
-
- for(Feature f : features) {
- AuditQuery query = null;
- if(clazz == null) {
- query = getAuditReader().createQuery().forEntitiesAtRevision(DescriptionElementBase.class,auditEvent.getRevisionNumber());
- } else {
- query = getAuditReader().createQuery().forEntitiesAtRevision(clazz,auditEvent.getRevisionNumber());
- }
-
- if(description != null) {
- query.add(AuditEntity.relatedId("inDescription").eq(description.getId()));
- }
-
- if(descriptionType != null) {
- query.add(AuditEntity.property("inDescription.class").eq(descriptionType));
- }
-
- query.add(AuditEntity.relatedId("feature").eq(f.getId()));
- result.addAll(query.getResultList());
- }
- } else {
- AuditQuery query = null;
- if(clazz == null) {
- query = getAuditReader().createQuery().forEntitiesAtRevision(DescriptionElementBase.class,auditEvent.getRevisionNumber());
- } else {
- query = getAuditReader().createQuery().forEntitiesAtRevision(clazz,auditEvent.getRevisionNumber());
- }
-
- if(description != null) {
- query.add(AuditEntity.relatedId("inDescription").eq(description.getId()));
- }
-
- if(descriptionType != null) {
- query.add(AuditEntity.property("inDescription.class").eq(descriptionType));
- }
-
- result = query.getResultList();
- }
-
- defaultBeanInitializer.initializeAll(result, propertyPaths);
-
- return result;
- }
- }
-
- @Override
- public List<TaxonDescription> listTaxonDescriptions(Taxon taxon, Set<DefinedTerm> scopes, Set<NamedArea> geographicalScopes, Set<MarkerType> markerTypes, Integer pageSize, Integer pageNumber, List<String> propertyPaths) {
- AuditEvent auditEvent = getAuditEventFromContext();
- if(auditEvent.equals(AuditEvent.CURRENT_VIEW)) {
- Criteria criteria = getSession().createCriteria(TaxonDescription.class);
-
- if(taxon != null) {
- criteria.add(Restrictions.eq("taxon", taxon));
- }
-
- if(scopes != null && !scopes.isEmpty()) {
- Set<Integer> scopeIds = new HashSet<Integer>();
- for(DefinedTerm s : scopes) {
- scopeIds.add(s.getId());
- }
- criteria.createCriteria("scopes").add(Restrictions.in("id", scopeIds));
- }
-
- if(geographicalScopes != null && !geographicalScopes.isEmpty()) {
- Set<Integer> geoScopeIds = new HashSet<Integer>();
- for(NamedArea n : geographicalScopes) {
- geoScopeIds.add(n.getId());
- }
- criteria.createCriteria("geoScopes").add(Restrictions.in("id", geoScopeIds));
- }
-
- addMarkerTypesCriterion(markerTypes, criteria);
-
- if(pageSize != null) {
- criteria.setMaxResults(pageSize);
- if(pageNumber != null) {
- criteria.setFirstResult(pageNumber * pageSize);
- }
- }
-
- List<TaxonDescription> results = criteria.list();
-
- defaultBeanInitializer.initializeAll(results, propertyPaths);
-
- return results;
- } else {
- if((scopes == null || scopes.isEmpty())&& (geographicalScopes == null || geographicalScopes.isEmpty())&& (markerTypes == null || markerTypes.isEmpty())) {
- AuditQuery query = getAuditReader().createQuery().forEntitiesAtRevision(TaxonDescription.class,auditEvent.getRevisionNumber());
- if(taxon != null) {
- query.add(AuditEntity.relatedId("taxon").eq(taxon.getId()));
- }
-
- if(pageSize != null) {
- query.setMaxResults(pageSize);
- if(pageNumber != null) {
- query.setFirstResult(pageNumber * pageSize);
- } else {
- query.setFirstResult(0);
- }
- }
-
- List<TaxonDescription> results = query.getResultList();
- defaultBeanInitializer.initializeAll(results, propertyPaths);
- return results;
- } else {
- throw new OperationNotSupportedInPriorViewException("countTaxonDescriptions(Taxon taxon, Set<Scope> scopes,Set<NamedArea> geographicalScopes)");
- }
- }
- }
-
- @Override
- public List<TaxonNameDescription> getTaxonNameDescriptions(TaxonNameBase name, Integer pageSize, Integer pageNumber, List<String> propertyPaths) {
- AuditEvent auditEvent = getAuditEventFromContext();
- if(auditEvent.equals(AuditEvent.CURRENT_VIEW)) {
- Criteria criteria = getSession().createCriteria(TaxonNameDescription.class);
-
- if(name != null) {
- criteria.add(Restrictions.eq("taxonName", name));
- }
-
- if(pageSize != null) {
- criteria.setMaxResults(pageSize);
- if(pageNumber != null) {
- criteria.setFirstResult(pageNumber * pageSize);
- }
- }
-
- List<TaxonNameDescription> results = criteria.list();
-
- defaultBeanInitializer.initializeAll(results, propertyPaths);
-
- return results;
- } else {
- AuditQuery query = getAuditReader().createQuery().forEntitiesAtRevision(TaxonNameDescription.class,auditEvent.getRevisionNumber());
-
- if(name != null) {
- query.add(AuditEntity.relatedId("taxonName").eq(name.getId()));
- }
-
- if(pageSize != null) {
- query.setMaxResults(pageSize);
- if(pageNumber != null) {
- query.setFirstResult(pageNumber * pageSize);
- }
- }
-
- List<TaxonNameDescription> results = query.getResultList();
-
- defaultBeanInitializer.initializeAll(results, propertyPaths);
-
- return results;
- }
-
- }
-
- @Override
- public int countTaxonNameDescriptions(TaxonNameBase name) {
- AuditEvent auditEvent = getAuditEventFromContext();
- if(auditEvent.equals(AuditEvent.CURRENT_VIEW)) {
- Criteria criteria = getSession().createCriteria(TaxonNameDescription.class);
-
- if(name != null) {
- criteria.add(Restrictions.eq("taxonName", name));
- }
-
- criteria.setProjection(Projections.rowCount());
-
- return ((Number)criteria.uniqueResult()).intValue();
- } else {
- AuditQuery query = getAuditReader().createQuery().forEntitiesAtRevision(TaxonNameDescription.class,auditEvent.getRevisionNumber());
-
- if(name != null) {
- query.add(AuditEntity.relatedId("taxonName").eq(name.getId()));
- }
-
- query.addProjection(AuditEntity.id().count("id"));
- return ((Long)query.getSingleResult()).intValue();
- }
- }
-
- /**
- * Should use a DetachedCriteria & subquery, but HHH-158 prevents this, for now.
- *
- * e.g. DetachedCriteria inner = DestachedCriteria.forClass(type);
- *
- * outer.add(Subqueries.propertyIn("id", inner));
- */
- @Override
- public List<DescriptionBase> listDescriptions(Class<? extends DescriptionBase> clazz, Boolean hasImages, Boolean hasText, Set<Feature> features, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths) {
- checkNotInPriorView("DescriptionDaoImpl.listDescriptions(Class<TYPE> type, Boolean hasImages, Boolean hasText, Set<Feature> features, Integer pageSize, Integer pageNumber)");
- Criteria inner = null;
-
- if(clazz == null) {
- inner = getSession().createCriteria(type);
- } else {
- inner = getSession().createCriteria(clazz);
- }
-
- Criteria elementsCriteria = inner.createCriteria("descriptionElements");
- if(hasText != null) {
- if(hasText) {
- elementsCriteria.add(Restrictions.isNotEmpty("multilanguageText"));
- } else {
- elementsCriteria.add(Restrictions.isEmpty("multilanguageText"));
- }
- }
-
- if(hasImages != null) {
- if(hasImages) {
- elementsCriteria.add(Restrictions.isNotEmpty("media"));
- } else {
- elementsCriteria.add(Restrictions.isEmpty("media"));
- }
- }
-
- if(features != null && !features.isEmpty()) {
- elementsCriteria.add(Restrictions.in("feature", features));
- }
-
- inner.setProjection(Projections.distinct(Projections.id()));
-
- List<Object> intermediateResult = inner.list();
-
- if(intermediateResult.isEmpty()) {
- return new ArrayList<DescriptionBase>();
- }
-
- Integer[] resultIds = new Integer[intermediateResult.size()];
- for(int i = 0; i < resultIds.length; i++) {
- resultIds[i] = ((Number)intermediateResult.get(i)).intValue();
- }
-
- Criteria outer = null;
-
- if(clazz == null) {
- outer = getSession().createCriteria(type);
- } else {
- outer = getSession().createCriteria(clazz);
- }
-
- outer.add(Restrictions.in("id", resultIds));
- addOrder(outer, orderHints);
-
- if(pageSize != null) {
- outer.setMaxResults(pageSize);
- if(pageNumber != null) {
- outer.setFirstResult(pageNumber * pageSize);
- }
- }
-
- List<DescriptionBase> results = outer.list();
- defaultBeanInitializer.initializeAll(results, propertyPaths);
- return results;
- }
-
- @Override
- public List<TaxonDescription> searchDescriptionByDistribution(Set<NamedArea> namedAreas, PresenceAbsenceTerm status, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths) {
- checkNotInPriorView("DescriptionDaoImpl.searchDescriptionByDistribution(Set<NamedArea> namedAreas, PresenceAbsenceTermBase status, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths)");
-
- Criteria criteria = getSession().createCriteria(TaxonDescription.class);
- Criteria elements = criteria.createCriteria("descriptionElements", "descriptionElement", Criteria.LEFT_JOIN);
- elements.add(Restrictions.in("area", namedAreas.toArray()));
-
- if(status != null) {
- elements.add(Restrictions.eq("status", status));
- }
-
- ProjectionList projectionList = Projections.projectionList().add(Projections.id());
-
- if(orderHints != null && !orderHints.isEmpty()) {
- for(OrderHint orderHint : orderHints) {
- projectionList = projectionList.add(Projections.property(orderHint.getPropertyName()));
- }
- }
-
- criteria.setProjection(Projections.distinct(projectionList));
-
- if(pageSize != null) {
- criteria.setMaxResults(pageSize);
- if(pageNumber != null) {
- criteria.setFirstResult(pageNumber * pageSize);
- }
- }
-
- addOrder(criteria,orderHints);
-
- List<Object> intermediateResult = criteria.list();
-
- if(intermediateResult.isEmpty()) {
- return new ArrayList<TaxonDescription>();
- }
-
- Integer[] resultIds = new Integer[intermediateResult.size()];
- for(int i = 0; i < resultIds.length; i++) {
- if(orderHints == null || orderHints.isEmpty()) {
- resultIds[i] = ((Number)intermediateResult.get(i)).intValue();
- } else {
- resultIds[i] = ((Number)((Object[])intermediateResult.get(i))[0]).intValue();
- }
- }
-
- criteria = getSession().createCriteria(TaxonDescription.class);
- criteria.add(Restrictions.in("id", resultIds));
- addOrder(criteria,orderHints);
-
- List<TaxonDescription> results = criteria.list();
- defaultBeanInitializer.initializeAll(results, propertyPaths);
- return results;
- }
-
- @Override
- public List<CommonTaxonName> searchDescriptionByCommonName(String queryString, MatchMode matchMode, Integer pageSize, Integer pageNumber) {
-
- Criteria crit = getSession().createCriteria(CommonTaxonName.class);
- if (matchMode == MatchMode.EXACT) {
- crit.add(Restrictions.eq("name", matchMode.queryStringFrom(queryString)));
- } else {
- crit.add(Restrictions.ilike("name", matchMode.queryStringFrom(queryString)));
- }
-
- if(pageSize != null) {
- crit.setMaxResults(pageSize);
- if(pageNumber != null) {
- crit.setFirstResult(pageNumber * pageSize);
- }
- }
- List<CommonTaxonName> results = crit.list();
- return results;
- }
-
- @Override
- public Integer countDescriptionByCommonName(String queryString, MatchMode matchMode) {
- //TODO inprove performance
- List<CommonTaxonName> results = searchDescriptionByCommonName(queryString, matchMode, null, null);
- return results.size();
- }
-
- @Override
- public DescriptionBase find(LSID lsid) {
- DescriptionBase descriptionBase = super.find(lsid);
- if(descriptionBase != null) {
- List<String> propertyPaths = new ArrayList<String>();
- propertyPaths.add("createdBy");
- propertyPaths.add("updatedBy");
- propertyPaths.add("taxon");
- propertyPaths.add("taxonName");
- propertyPaths.add("descriptionElements");
- propertyPaths.add("descriptionElements.createdBy");
- propertyPaths.add("descriptionElements.updatedBy");
- propertyPaths.add("descriptionElements.feature");
- propertyPaths.add("descriptionElements.multilanguageText");
- propertyPaths.add("descriptionElements.multilanguageText.language");
- propertyPaths.add("descriptionElements.area");
- propertyPaths.add("descriptionElements.status");
- propertyPaths.add("descriptionElements.modifyingText");
- propertyPaths.add("descriptionElementsmodifyingText.language");
- propertyPaths.add("descriptionElements.modifiers");
-
- defaultBeanInitializer.initialize(descriptionBase, propertyPaths);
- }
- return descriptionBase;
- }
-
-
- @Override
- public <T extends DescriptionElementBase> List<T> getDescriptionElementForTaxon(
- UUID taxonUuid, Set<Feature> features,
- Class<T> type, Integer pageSize,
- Integer pageNumber, List<String> propertyPaths) {
-
-// Logger.getLogger("org.hibernate.SQL").setLevel(Level.TRACE);
-
- Query query = prepareGetDescriptionElementForTaxon(taxonUuid, features, type, pageSize, pageNumber, false);
-
- if (logger.isDebugEnabled()){logger.debug(" dao: get list ...");}
- @SuppressWarnings("unchecked")
- List<T> results = query.list();
- if (logger.isDebugEnabled()){logger.debug(" dao: initialize ...");}
- defaultBeanInitializer.initializeAll(results, propertyPaths);
- if (logger.isDebugEnabled()){logger.debug(" dao: initialize - DONE");}
-
-// Logger.getLogger("org.hibernate.SQL").setLevel(Level.WARN);
- return results;
- }
-
- @Override
- public <T extends DescriptionElementBase> long countDescriptionElementForTaxon(
- UUID taxonUuid, Set<Feature> features, Class<T> type) {
-
- Query query = prepareGetDescriptionElementForTaxon(taxonUuid, features, type, null, null, true);
-
- return (Long)query.uniqueResult();
- }
-
- /**
- * @param taxon
- * @param features
- * @param type
- * @param pageSize
- * @param pageNumber
- * @return
- */
- private <T extends DescriptionElementBase> Query prepareGetDescriptionElementForTaxon(UUID taxonUuid,
- Set<Feature> features, Class<T> type, Integer pageSize, Integer pageNumber, boolean asCountQuery) {
-
- String listOrCount;
- if(asCountQuery){
- listOrCount = "count(de)";
- } else {
- listOrCount = "de";
- }
-
- String queryString = "SELECT " + listOrCount + " FROM DescriptionElementBase AS de" +
- " LEFT JOIN de.inDescription AS d" +
- " LEFT JOIN d.taxon AS t" +
- " WHERE d.class = 'TaxonDescription' AND t.uuid = :taxon_uuid ";
-
- if(type != null){
- queryString += " and de.class = :type";
- }
- if (features != null && features.size() > 0){
- queryString += " and de.feature in (:features) ";
- }
-// System.out.println(queryString);
- Query query = getSession().createQuery(queryString);
-
- query.setParameter("taxon_uuid", taxonUuid);
- if(type != null){
- query.setParameter("type", type.getSimpleName());
- }
- if(features != null && features.size() > 0){
- query.setParameterList("features", features) ;
- }
-
- if(pageSize != null) {
- query.setMaxResults(pageSize);
- if(pageNumber != null) {
- query.setFirstResult(pageNumber * pageSize);
- }
- }
- return query;
- }
-
- /* (non-Javadoc)
- * @see eu.etaxonomy.cdm.persistence.dao.description.IDescriptionDao#listTaxonDescriptionMedia(java.util.UUID, java.lang.Boolean, java.util.Set, java.lang.Integer, java.lang.Integer, java.util.List)
- */
- @Override
- public List<Media> listTaxonDescriptionMedia(UUID taxonUuid,
- Boolean limitToGalleries, Set<MarkerType> markerTypes,
- Integer pageSize, Integer pageNumber, List<String> propertyPaths) {
-
- AuditEvent auditEvent = getAuditEventFromContext();
- if(auditEvent.equals(AuditEvent.CURRENT_VIEW)) {
- String queryString = " SELECT media " +
- getTaxonDescriptionMediaQueryString(
- taxonUuid, limitToGalleries, markerTypes);
- queryString +=
- " GROUP BY media "
-// " ORDER BY index(media) " //not functional
- ;
-
- Query query = getSession().createQuery(queryString);
-
- setTaxonDescriptionMediaParameters(query, taxonUuid, limitToGalleries, markerTypes);
-
-
-// addMarkerTypesCriterion(markerTypes, hql);
-
- setPagingParameter(query, pageSize, pageNumber);
-
- List<Media> results = query.list();
-
- defaultBeanInitializer.initializeAll(results, propertyPaths);
-
- return results;
- } else {
- throw new OperationNotSupportedInPriorViewException("countTaxonDescriptionMedia(UUID taxonUuid, boolean restrictToGalleries)");
- }
- }
-
-
- /* (non-Javadoc)
- * @see eu.etaxonomy.cdm.persistence.dao.description.IDescriptionDao#countTaxonDescriptionMedia(java.util.UUID, java.lang.Boolean, java.util.Set)
- */
- @Override
- public int countTaxonDescriptionMedia(UUID taxonUuid,
- Boolean limitToGalleries, Set<MarkerType> markerTypes) {
- AuditEvent auditEvent = getAuditEventFromContext();
- if(auditEvent.equals(AuditEvent.CURRENT_VIEW)) {
- String queryString = " SELECT count(DISTINCT media) " +
- getTaxonDescriptionMediaQueryString(
- taxonUuid, limitToGalleries, markerTypes);
-
- Query query = getSession().createQuery(queryString);
- setTaxonDescriptionMediaParameters(query, taxonUuid, limitToGalleries, markerTypes);
- return ((Long)query.uniqueResult()).intValue();
- }else{
- throw new OperationNotSupportedInPriorViewException("countTaxonDescriptionMedia(UUID taxonUuid)");
- }
-
- }
-
- private void setTaxonDescriptionMediaParameters(Query query, UUID taxonUuid, Boolean limitToGalleries, Set<MarkerType> markerTypes) {
- if(taxonUuid != null){
- query.setParameter("uuid", taxonUuid);
- }
-
- }
-
- /**
- * @param taxonUuid
- * @param restrictToGalleries
- * @param markerTypes
- * @return
- */
- private String getTaxonDescriptionMediaQueryString(UUID taxonUuid,
- Boolean restrictToGalleries, Set<MarkerType> markerTypes) {
- String fromQueryString =
- " FROM DescriptionElementBase as deb INNER JOIN " +
- " deb.inDescription as td "
- + " INNER JOIN td.taxon as t "
- + " JOIN deb.media as media "
- + " LEFT JOIN td.markers marker ";
-
- String whereQueryString = " WHERE (1=1) ";
- if (taxonUuid != null){
- whereQueryString += " AND t.uuid = :uuid ";
- }
- if (restrictToGalleries){
- whereQueryString += " AND td.imageGallery is true ";
- }
- if (markerTypes != null && !markerTypes.isEmpty()){
- whereQueryString += " AND (1=0";
- for (MarkerType markerType : markerTypes){
- whereQueryString += " OR ( marker.markerType.id = " + markerType.getId() + " AND marker.flag is true)";
-
- }
- whereQueryString += ") ";
- }
-
- return fromQueryString + whereQueryString;
-
- }
-
- /* (non-Javadoc)
- * @see eu.etaxonomy.cdm.persistence.dao.description.IDescriptionDao#listNamedAreasInUse(java.lang.Integer, java.lang.Integer, java.util.List)
- */
- @SuppressWarnings("unchecked")
- @Override
- public List<TermDto> listNamedAreasInUse(boolean includeAllParents, Integer pageSize, Integer pageNumber) {
-
-// Logger.getLogger("org.hibernate.SQL").setLevel(Level.TRACE);
-
- StringBuilder queryString = new StringBuilder(
- "SELECT DISTINCT a.id, a.partOf.id"
- + " FROM Distribution AS d JOIN d.area AS a");
- Query query = getSession().createQuery(queryString.toString());
-
- List<Object[]> areasInUse = query.list();
- List<Object[]> parentResults = new ArrayList<Object[]>();
-
- if(!areasInUse.isEmpty()) {
- Set<Object> allAreaIds = new HashSet<Object>(areasInUse.size());
-
- if(includeAllParents) {
- // find all parent nodes
- String allAreasQueryStr = "select a.id, a.partOf.id from NamedArea as a";
- query = getSession().createQuery(allAreasQueryStr);
- List<Object[]> allAreasResult = query.list();
- Map<Object, Object> allAreasMap = ArrayUtils.toMap(allAreasResult.toArray());
-
- Set<Object> parents = new HashSet<Object>();
-
- for(Object[] leaf : areasInUse) {
- allAreaIds.add(leaf[0]);
- Object parentId = leaf[1];
- while (parentId != null) {
- if(parents.contains(parentId)) {
- // break if the parent already is in the set
- break;
- }
- parents.add(parentId);
- parentId = allAreasMap.get(parentId);
- }
- }
- allAreaIds.addAll(parents);
- } else {
- // only add the ids found so far
- for(Object[] leaf : areasInUse) {
- allAreaIds.add(leaf[0]);
- }
- }
-
-
- // NOTE can't use "select new TermDto(distinct a.uuid, r , a.vocabulary.uuid) since we will get multiple
- // rows for a term with multiple representations
- String parentAreasQueryStr = "select a.uuid, r, p.uuid, v.uuid "
- + "from NamedArea as a LEFT JOIN a.partOf as p LEFT JOIN a.representations AS r LEFT JOIN a.vocabulary as v "
- + "where a.id in (:allAreaIds) order by a.idInVocabulary";
- query = getSession().createQuery(parentAreasQueryStr);
- query.setParameterList("allAreaIds", allAreaIds);
- if(pageSize != null) {
- query.setMaxResults(pageSize);
- if(pageNumber != null) {
- query.setFirstResult(pageNumber * pageSize);
- }
- }
- parentResults = query.list();
- }
- List<TermDto> dtoList = termDtoListFrom(parentResults);
-
- return dtoList;
- }
-
- /**
- * @param results
- * @return
- */
- private List<TermDto> termDtoListFrom(List<Object[]> results) {
- Map<UUID, TermDto> dtoMap = new HashMap<UUID, TermDto>(results.size());
- for (Object[] elements : results) {
- UUID uuid = (UUID)elements[0];
- if(dtoMap.containsKey(uuid)){
- dtoMap.get(uuid).addRepresentation((Representation)elements[1]);
- } else {
- Set<Representation> representations;
- if(elements[1] instanceof Representation) {
- representations = new HashSet<Representation>(1);
- representations.add((Representation)elements[1]);
- } else {
- representations = (Set<Representation>)elements[1];
- }
- dtoMap.put(uuid, new TermDto(uuid, representations, (UUID)elements[2], (UUID)elements[3]));
- }
- }
- return new ArrayList<TermDto>(dtoMap.values());
- }
-
-
-
-}
+/**\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.persistence.dao.hibernate.description;\r
+\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.commons.lang.ArrayUtils;\r
+import org.apache.log4j.Logger;\r
+import org.hibernate.Criteria;\r
+import org.hibernate.Query;\r
+import org.hibernate.criterion.ProjectionList;\r
+import org.hibernate.criterion.Projections;\r
+import org.hibernate.criterion.Restrictions;\r
+import org.hibernate.envers.query.AuditEntity;\r
+import org.hibernate.envers.query.AuditQuery;\r
+import org.springframework.beans.factory.annotation.Qualifier;\r
+import org.springframework.stereotype.Repository;\r
+\r
+import eu.etaxonomy.cdm.model.common.DefinedTerm;\r
+import eu.etaxonomy.cdm.model.common.LSID;\r
+import eu.etaxonomy.cdm.model.common.MarkerType;\r
+import eu.etaxonomy.cdm.model.common.Representation;\r
+import eu.etaxonomy.cdm.model.description.CommonTaxonName;\r
+import eu.etaxonomy.cdm.model.description.DescriptionBase;\r
+import eu.etaxonomy.cdm.model.description.DescriptionElementBase;\r
+import eu.etaxonomy.cdm.model.description.Feature;\r
+import eu.etaxonomy.cdm.model.description.PresenceAbsenceTerm;\r
+import eu.etaxonomy.cdm.model.description.SpecimenDescription;\r
+import eu.etaxonomy.cdm.model.description.TaxonDescription;\r
+import eu.etaxonomy.cdm.model.description.TaxonNameDescription;\r
+import eu.etaxonomy.cdm.model.location.NamedArea;\r
+import eu.etaxonomy.cdm.model.media.Media;\r
+import eu.etaxonomy.cdm.model.name.TaxonNameBase;\r
+import eu.etaxonomy.cdm.model.taxon.Taxon;\r
+import eu.etaxonomy.cdm.model.view.AuditEvent;\r
+import eu.etaxonomy.cdm.persistence.dao.common.OperationNotSupportedInPriorViewException;\r
+import eu.etaxonomy.cdm.persistence.dao.description.IDescriptionDao;\r
+import eu.etaxonomy.cdm.persistence.dao.hibernate.common.IdentifiableDaoBase;\r
+import eu.etaxonomy.cdm.persistence.dto.TermDto;\r
+import eu.etaxonomy.cdm.persistence.query.MatchMode;\r
+import eu.etaxonomy.cdm.persistence.query.OrderHint;\r
+\r
+@Repository\r
+@Qualifier("descriptionDaoImpl")\r
+public class DescriptionDaoImpl extends IdentifiableDaoBase<DescriptionBase> implements IDescriptionDao{\r
+\r
+ private static final Logger logger = Logger.getLogger(DescriptionDaoImpl.class);\r
+\r
+ public DescriptionDaoImpl() {\r
+ super(DescriptionBase.class);\r
+ indexedClasses = new Class[3];\r
+ indexedClasses[0] = TaxonDescription.class;\r
+ indexedClasses[1] = TaxonNameDescription.class;\r
+ indexedClasses[2] = SpecimenDescription.class;\r
+ }\r
+\r
+// @Override //Override for testing\r
+// public DescriptionBase load(UUID uuid, List<String> propertyPaths){\r
+// DescriptionBase bean = findByUuid(uuid);\r
+// if(bean == null){\r
+// return bean;\r
+// }\r
+// defaultBeanInitializer.initialize(bean, propertyPaths);\r
+//\r
+// return bean;\r
+// }\r
+\r
+ @Override\r
+ public int countDescriptionByDistribution(Set<NamedArea> namedAreas, PresenceAbsenceTerm status) {\r
+ checkNotInPriorView("DescriptionDaoImpl.countDescriptionByDistribution(Set<NamedArea> namedAreas, PresenceAbsenceTermBase status)");\r
+ Query query = null;\r
+\r
+ if(status == null) {\r
+ query = getSession().createQuery("select count(distinct description) from TaxonDescription description left join description.descriptionElements element join element.area area where area in (:namedAreas)");\r
+ } else {\r
+ query = getSession().createQuery("select count(distinct description) from TaxonDescription description left join description.descriptionElements element join element.area area join element.status status where area in (:namedAreas) and status = :status");\r
+ query.setParameter("status", status);\r
+ }\r
+ query.setParameterList("namedAreas", namedAreas);\r
+\r
+ return ((Long)query.uniqueResult()).intValue();\r
+ }\r
+\r
+ @Override\r
+ public int countDescriptionElements(DescriptionBase description, Set<Feature> features, Class<? extends DescriptionElementBase> clazz) {\r
+ return countDescriptionElements(description, null, features, clazz);\r
+ }\r
+\r
+ @Override\r
+ public int countDescriptionElements(DescriptionBase description, Class<? extends DescriptionBase> descriptionType,\r
+ Set<Feature> features, Class<? extends DescriptionElementBase> clazz) {\r
+ AuditEvent auditEvent = getAuditEventFromContext();\r
+ if(auditEvent.equals(AuditEvent.CURRENT_VIEW)) {\r
+ Criteria criteria = null;\r
+ if(clazz == null) {\r
+ criteria = getSession().createCriteria(DescriptionElementBase.class);\r
+ } else {\r
+ criteria = getSession().createCriteria(clazz);\r
+ }\r
+\r
+ if(description != null) {\r
+ criteria.add(Restrictions.eq("inDescription", description));\r
+ }\r
+\r
+ if(descriptionType != null) {\r
+ criteria.createAlias("inDescription", "d").add(Restrictions.eq("d.class", descriptionType));\r
+ }\r
+\r
+ if(features != null && !features.isEmpty()) {\r
+ criteria.add(Restrictions.in("feature", features));\r
+ }\r
+\r
+ criteria.setProjection(Projections.rowCount());\r
+\r
+ return ((Number)criteria.uniqueResult()).intValue();\r
+ } else {\r
+ if(features != null && !features.isEmpty()) {\r
+ Integer count = 0;\r
+ for(Feature f : features) {\r
+ AuditQuery query = null;\r
+ if(clazz == null) {\r
+ query = getAuditReader().createQuery().forEntitiesAtRevision(DescriptionElementBase.class,auditEvent.getRevisionNumber());\r
+ } else {\r
+ query = getAuditReader().createQuery().forEntitiesAtRevision(clazz,auditEvent.getRevisionNumber());\r
+ }\r
+\r
+ if(description != null) {\r
+ query.add(AuditEntity.relatedId("inDescription").eq(description.getId()));\r
+ }\r
+\r
+ if(descriptionType != null) {\r
+ query.add(AuditEntity.property("inDescription.class").eq(descriptionType));\r
+ }\r
+\r
+ query.add(AuditEntity.relatedId("feature").eq(f.getId()));\r
+ query.addProjection(AuditEntity.id().count("id"));\r
+ count += ((Long)query.getSingleResult()).intValue();\r
+ }\r
+\r
+ return count;\r
+ } else {\r
+ AuditQuery query = null;\r
+ if(clazz == null) {\r
+ query = getAuditReader().createQuery().forEntitiesAtRevision(DescriptionElementBase.class,auditEvent.getRevisionNumber());\r
+ } else {\r
+ query = getAuditReader().createQuery().forEntitiesAtRevision(clazz,auditEvent.getRevisionNumber());\r
+ }\r
+\r
+ if(description != null) {\r
+ query.add(AuditEntity.relatedId("inDescription").eq(description.getId()));\r
+ }\r
+ if(descriptionType != null) {\r
+ query.add(AuditEntity.property("inDescription.class").eq(descriptionType));\r
+ }\r
+\r
+ query.addProjection(AuditEntity.id().count("id"));\r
+ return ((Long)query.getSingleResult()).intValue();\r
+ }\r
+ }\r
+ }\r
+\r
+ @Override\r
+ public int countDescriptions(Class<? extends DescriptionBase> clazz, Boolean hasImages, Boolean hasText, Set<Feature> features) {\r
+ checkNotInPriorView("DescriptionDaoImpl.countDescriptions(Class<TYPE> type, Boolean hasImages, Boolean hasText, Set<Feature> features)");\r
+ Criteria inner = null;\r
+\r
+ if(clazz == null) {\r
+ inner = getSession().createCriteria(type);\r
+ } else {\r
+ inner = getSession().createCriteria(clazz);\r
+ }\r
+\r
+ Criteria elementsCriteria = inner.createCriteria("descriptionElements");\r
+ if(hasText != null) {\r
+ if(hasText) {\r
+ elementsCriteria.add(Restrictions.isNotEmpty("multilanguageText"));\r
+ } else {\r
+ elementsCriteria.add(Restrictions.isEmpty("multilanguageText"));\r
+ }\r
+ }\r
+\r
+ if(hasImages != null) {\r
+ if(hasImages) {\r
+ elementsCriteria.add(Restrictions.isNotEmpty("media"));\r
+ } else {\r
+ elementsCriteria.add(Restrictions.isEmpty("media"));\r
+ }\r
+ }\r
+\r
+ if(features != null && !features.isEmpty()) {\r
+ elementsCriteria.add(Restrictions.in("feature", features));\r
+ }\r
+\r
+ inner.setProjection(Projections.countDistinct("id"));\r
+\r
+ return ((Number) inner.uniqueResult()).intValue();\r
+ }\r
+\r
+ @Override\r
+ public int countTaxonDescriptions(Taxon taxon, Set<DefinedTerm> scopes,Set<NamedArea> geographicalScopes, Set<MarkerType> markerTypes) {\r
+ AuditEvent auditEvent = getAuditEventFromContext();\r
+ if(auditEvent.equals(AuditEvent.CURRENT_VIEW)) {\r
+ Criteria criteria = getSession().createCriteria(TaxonDescription.class);\r
+\r
+ if(taxon != null) {\r
+ criteria.add(Restrictions.eq("taxon", taxon));\r
+ }\r
+\r
+ if(scopes != null && !scopes.isEmpty()) {\r
+ Set<Integer> scopeIds = new HashSet<Integer>();\r
+ for(DefinedTerm s : scopes) {\r
+ scopeIds.add(s.getId());\r
+ }\r
+ criteria.createCriteria("scopes").add(Restrictions.in("id", scopeIds));\r
+ }\r
+\r
+ if(geographicalScopes != null && !geographicalScopes.isEmpty()) {\r
+ Set<Integer> geoScopeIds = new HashSet<Integer>();\r
+ for(NamedArea n : geographicalScopes) {\r
+ geoScopeIds.add(n.getId());\r
+ }\r
+ criteria.createCriteria("geoScopes").add(Restrictions.in("id", geoScopeIds));\r
+ }\r
+\r
+\r
+ addMarkerTypesCriterion(markerTypes, criteria);\r
+\r
+\r
+ criteria.setProjection(Projections.rowCount());\r
+\r
+ return ((Number)criteria.uniqueResult()).intValue();\r
+ } else {\r
+ if((scopes == null || scopes.isEmpty())&& (geographicalScopes == null || geographicalScopes.isEmpty()) && (markerTypes == null || markerTypes.isEmpty())) {\r
+ AuditQuery query = getAuditReader().createQuery().forEntitiesAtRevision(TaxonDescription.class,auditEvent.getRevisionNumber());\r
+ if(taxon != null) {\r
+ query.add(AuditEntity.relatedId("taxon").eq(taxon.getId()));\r
+ }\r
+\r
+ query.addProjection(AuditEntity.id().count("id"));\r
+\r
+ return ((Long)query.getSingleResult()).intValue();\r
+ } else {\r
+ throw new OperationNotSupportedInPriorViewException("countTaxonDescriptions(Taxon taxon, Set<Scope> scopes,Set<NamedArea> geographicalScopes)");\r
+ }\r
+ }\r
+ }\r
+\r
+ /**\r
+ * @param markerTypes\r
+ * @param criteria\r
+ *\r
+ */\r
+ //TODO move to AnnotatableEntityDao(?)\r
+ private void addMarkerTypesCriterion(Set<MarkerType> markerTypes, Criteria criteria) {\r
+\r
+ if(markerTypes != null && !markerTypes.isEmpty()) {\r
+ Set<Integer> markerTypeIds = new HashSet<Integer>();\r
+ for(MarkerType markerType : markerTypes) {\r
+ markerTypeIds.add(markerType.getId());\r
+ }\r
+ criteria.createCriteria("markers").add(Restrictions.eq("flag", true))\r
+ .createAlias("markerType", "mt")\r
+ .add(Restrictions.in("mt.id", markerTypeIds));\r
+ } else if (markerTypes != null && markerTypes.isEmpty()){\r
+ //AT: added in case the projects requires an third state description, An empty Marker type set\r
+ }\r
+ }\r
+ @Override\r
+ public List<DescriptionElementBase> getDescriptionElements(\r
+ DescriptionBase description, Set<Feature> features,\r
+ Class<? extends DescriptionElementBase> clazz, Integer pageSize, Integer pageNumber, List<String> propertyPaths) {\r
+ return getDescriptionElements(description, null, features, clazz, pageSize, pageNumber, propertyPaths);\r
+ }\r
+\r
+ @Override\r
+ public List<DescriptionElementBase> getDescriptionElements(\r
+ DescriptionBase description, Class<? extends DescriptionBase> descriptionType,\r
+ Set<Feature> features,\r
+ Class<? extends DescriptionElementBase> clazz,\r
+ Integer pageSize, Integer pageNumber, List<String> propertyPaths) {\r
+\r
+ AuditEvent auditEvent = getAuditEventFromContext();\r
+ if(auditEvent.equals(AuditEvent.CURRENT_VIEW)) {\r
+ Criteria criteria = null;\r
+ if(clazz == null) {\r
+ criteria = getSession().createCriteria(DescriptionElementBase.class);\r
+ } else {\r
+ criteria = getSession().createCriteria(clazz);\r
+ }\r
+\r
+ if(description != null) {\r
+ criteria.add(Restrictions.eq("inDescription", description));\r
+ }\r
+ if(descriptionType != null) {\r
+ criteria.createAlias("inDescription", "d").add(Restrictions.eq("d.class", descriptionType));\r
+ }\r
+\r
+ if(features != null && !features.isEmpty()) {\r
+ criteria.add(Restrictions.in("feature", features));\r
+ }\r
+\r
+ if(pageSize != null) {\r
+ criteria.setMaxResults(pageSize);\r
+ if(pageNumber != null) {\r
+ criteria.setFirstResult(pageNumber * pageSize);\r
+ }\r
+ }\r
+\r
+ List<DescriptionElementBase> results = criteria.list();\r
+\r
+ defaultBeanInitializer.initializeAll(results, propertyPaths);\r
+\r
+ return results;\r
+ } else {\r
+ List<DescriptionElementBase> result = new ArrayList<DescriptionElementBase>();\r
+ if(features != null && !features.isEmpty()) {\r
+\r
+ for(Feature f : features) {\r
+ AuditQuery query = null;\r
+ if(clazz == null) {\r
+ query = getAuditReader().createQuery().forEntitiesAtRevision(DescriptionElementBase.class,auditEvent.getRevisionNumber());\r
+ } else {\r
+ query = getAuditReader().createQuery().forEntitiesAtRevision(clazz,auditEvent.getRevisionNumber());\r
+ }\r
+\r
+ if(description != null) {\r
+ query.add(AuditEntity.relatedId("inDescription").eq(description.getId()));\r
+ }\r
+\r
+ if(descriptionType != null) {\r
+ query.add(AuditEntity.property("inDescription.class").eq(descriptionType));\r
+ }\r
+\r
+ query.add(AuditEntity.relatedId("feature").eq(f.getId()));\r
+ result.addAll(query.getResultList());\r
+ }\r
+ } else {\r
+ AuditQuery query = null;\r
+ if(clazz == null) {\r
+ query = getAuditReader().createQuery().forEntitiesAtRevision(DescriptionElementBase.class,auditEvent.getRevisionNumber());\r
+ } else {\r
+ query = getAuditReader().createQuery().forEntitiesAtRevision(clazz,auditEvent.getRevisionNumber());\r
+ }\r
+\r
+ if(description != null) {\r
+ query.add(AuditEntity.relatedId("inDescription").eq(description.getId()));\r
+ }\r
+\r
+ if(descriptionType != null) {\r
+ query.add(AuditEntity.property("inDescription.class").eq(descriptionType));\r
+ }\r
+\r
+ result = query.getResultList();\r
+ }\r
+\r
+ defaultBeanInitializer.initializeAll(result, propertyPaths);\r
+\r
+ return result;\r
+ }\r
+ }\r
+\r
+ @Override\r
+ public List<TaxonDescription> listTaxonDescriptions(Taxon taxon, Set<DefinedTerm> scopes, Set<NamedArea> geographicalScopes, Set<MarkerType> markerTypes, Integer pageSize, Integer pageNumber, List<String> propertyPaths) {\r
+ AuditEvent auditEvent = getAuditEventFromContext();\r
+ if(auditEvent.equals(AuditEvent.CURRENT_VIEW)) {\r
+ Criteria criteria = getSession().createCriteria(TaxonDescription.class);\r
+\r
+ if(taxon != null) {\r
+ criteria.add(Restrictions.eq("taxon", taxon));\r
+ }\r
+\r
+ if(scopes != null && !scopes.isEmpty()) {\r
+ Set<Integer> scopeIds = new HashSet<Integer>();\r
+ for(DefinedTerm s : scopes) {\r
+ scopeIds.add(s.getId());\r
+ }\r
+ criteria.createCriteria("scopes").add(Restrictions.in("id", scopeIds));\r
+ }\r
+\r
+ if(geographicalScopes != null && !geographicalScopes.isEmpty()) {\r
+ Set<Integer> geoScopeIds = new HashSet<Integer>();\r
+ for(NamedArea n : geographicalScopes) {\r
+ geoScopeIds.add(n.getId());\r
+ }\r
+ criteria.createCriteria("geoScopes").add(Restrictions.in("id", geoScopeIds));\r
+ }\r
+\r
+ addMarkerTypesCriterion(markerTypes, criteria);\r
+\r
+ if(pageSize != null) {\r
+ criteria.setMaxResults(pageSize);\r
+ if(pageNumber != null) {\r
+ criteria.setFirstResult(pageNumber * pageSize);\r
+ }\r
+ }\r
+\r
+ List<TaxonDescription> results = criteria.list();\r
+\r
+ defaultBeanInitializer.initializeAll(results, propertyPaths);\r
+\r
+ return results;\r
+ } else {\r
+ if((scopes == null || scopes.isEmpty())&& (geographicalScopes == null || geographicalScopes.isEmpty())&& (markerTypes == null || markerTypes.isEmpty())) {\r
+ AuditQuery query = getAuditReader().createQuery().forEntitiesAtRevision(TaxonDescription.class,auditEvent.getRevisionNumber());\r
+ if(taxon != null) {\r
+ query.add(AuditEntity.relatedId("taxon").eq(taxon.getId()));\r
+ }\r
+\r
+ if(pageSize != null) {\r
+ query.setMaxResults(pageSize);\r
+ if(pageNumber != null) {\r
+ query.setFirstResult(pageNumber * pageSize);\r
+ } else {\r
+ query.setFirstResult(0);\r
+ }\r
+ }\r
+\r
+ List<TaxonDescription> results = query.getResultList();\r
+ defaultBeanInitializer.initializeAll(results, propertyPaths);\r
+ return results;\r
+ } else {\r
+ throw new OperationNotSupportedInPriorViewException("countTaxonDescriptions(Taxon taxon, Set<Scope> scopes,Set<NamedArea> geographicalScopes)");\r
+ }\r
+ }\r
+ }\r
+\r
+ @Override\r
+ public List<TaxonNameDescription> getTaxonNameDescriptions(TaxonNameBase name, Integer pageSize, Integer pageNumber, List<String> propertyPaths) {\r
+ AuditEvent auditEvent = getAuditEventFromContext();\r
+ if(auditEvent.equals(AuditEvent.CURRENT_VIEW)) {\r
+ Criteria criteria = getSession().createCriteria(TaxonNameDescription.class);\r
+\r
+ if(name != null) {\r
+ criteria.add(Restrictions.eq("taxonName", name));\r
+ }\r
+\r
+ if(pageSize != null) {\r
+ criteria.setMaxResults(pageSize);\r
+ if(pageNumber != null) {\r
+ criteria.setFirstResult(pageNumber * pageSize);\r
+ }\r
+ }\r
+\r
+ List<TaxonNameDescription> results = criteria.list();\r
+\r
+ defaultBeanInitializer.initializeAll(results, propertyPaths);\r
+\r
+ return results;\r
+ } else {\r
+ AuditQuery query = getAuditReader().createQuery().forEntitiesAtRevision(TaxonNameDescription.class,auditEvent.getRevisionNumber());\r
+\r
+ if(name != null) {\r
+ query.add(AuditEntity.relatedId("taxonName").eq(name.getId()));\r
+ }\r
+\r
+ if(pageSize != null) {\r
+ query.setMaxResults(pageSize);\r
+ if(pageNumber != null) {\r
+ query.setFirstResult(pageNumber * pageSize);\r
+ }\r
+ }\r
+\r
+ List<TaxonNameDescription> results = query.getResultList();\r
+\r
+ defaultBeanInitializer.initializeAll(results, propertyPaths);\r
+\r
+ return results;\r
+ }\r
+\r
+ }\r
+\r
+ @Override\r
+ public int countTaxonNameDescriptions(TaxonNameBase name) {\r
+ AuditEvent auditEvent = getAuditEventFromContext();\r
+ if(auditEvent.equals(AuditEvent.CURRENT_VIEW)) {\r
+ Criteria criteria = getSession().createCriteria(TaxonNameDescription.class);\r
+\r
+ if(name != null) {\r
+ criteria.add(Restrictions.eq("taxonName", name));\r
+ }\r
+\r
+ criteria.setProjection(Projections.rowCount());\r
+\r
+ return ((Number)criteria.uniqueResult()).intValue();\r
+ } else {\r
+ AuditQuery query = getAuditReader().createQuery().forEntitiesAtRevision(TaxonNameDescription.class,auditEvent.getRevisionNumber());\r
+\r
+ if(name != null) {\r
+ query.add(AuditEntity.relatedId("taxonName").eq(name.getId()));\r
+ }\r
+\r
+ query.addProjection(AuditEntity.id().count("id"));\r
+ return ((Long)query.getSingleResult()).intValue();\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Should use a DetachedCriteria & subquery, but HHH-158 prevents this, for now.\r
+ *\r
+ * e.g. DetachedCriteria inner = DestachedCriteria.forClass(type);\r
+ *\r
+ * outer.add(Subqueries.propertyIn("id", inner));\r
+ */\r
+ @Override\r
+ public List<DescriptionBase> listDescriptions(Class<? extends DescriptionBase> clazz, Boolean hasImages, Boolean hasText, Set<Feature> features, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths) {\r
+ checkNotInPriorView("DescriptionDaoImpl.listDescriptions(Class<TYPE> type, Boolean hasImages, Boolean hasText, Set<Feature> features, Integer pageSize, Integer pageNumber)");\r
+ Criteria inner = null;\r
+\r
+ if(clazz == null) {\r
+ inner = getSession().createCriteria(type);\r
+ } else {\r
+ inner = getSession().createCriteria(clazz);\r
+ }\r
+\r
+ Criteria elementsCriteria = inner.createCriteria("descriptionElements");\r
+ if(hasText != null) {\r
+ if(hasText) {\r
+ elementsCriteria.add(Restrictions.isNotEmpty("multilanguageText"));\r
+ } else {\r
+ elementsCriteria.add(Restrictions.isEmpty("multilanguageText"));\r
+ }\r
+ }\r
+\r
+ if(hasImages != null) {\r
+ if(hasImages) {\r
+ elementsCriteria.add(Restrictions.isNotEmpty("media"));\r
+ } else {\r
+ elementsCriteria.add(Restrictions.isEmpty("media"));\r
+ }\r
+ }\r
+\r
+ if(features != null && !features.isEmpty()) {\r
+ elementsCriteria.add(Restrictions.in("feature", features));\r
+ }\r
+\r
+ inner.setProjection(Projections.distinct(Projections.id()));\r
+\r
+ List<Object> intermediateResult = inner.list();\r
+\r
+ if(intermediateResult.isEmpty()) {\r
+ return new ArrayList<DescriptionBase>();\r
+ }\r
+\r
+ Integer[] resultIds = new Integer[intermediateResult.size()];\r
+ for(int i = 0; i < resultIds.length; i++) {\r
+ resultIds[i] = ((Number)intermediateResult.get(i)).intValue();\r
+ }\r
+\r
+ Criteria outer = null;\r
+\r
+ if(clazz == null) {\r
+ outer = getSession().createCriteria(type);\r
+ } else {\r
+ outer = getSession().createCriteria(clazz);\r
+ }\r
+\r
+ outer.add(Restrictions.in("id", resultIds));\r
+ addOrder(outer, orderHints);\r
+\r
+ if(pageSize != null) {\r
+ outer.setMaxResults(pageSize);\r
+ if(pageNumber != null) {\r
+ outer.setFirstResult(pageNumber * pageSize);\r
+ }\r
+ }\r
+\r
+ List<DescriptionBase> results = outer.list();\r
+ defaultBeanInitializer.initializeAll(results, propertyPaths);\r
+ return results;\r
+ }\r
+\r
+ @Override\r
+ public List<TaxonDescription> searchDescriptionByDistribution(Set<NamedArea> namedAreas, PresenceAbsenceTerm status, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths) {\r
+ checkNotInPriorView("DescriptionDaoImpl.searchDescriptionByDistribution(Set<NamedArea> namedAreas, PresenceAbsenceTermBase status, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths)");\r
+\r
+ Criteria criteria = getSession().createCriteria(TaxonDescription.class);\r
+ Criteria elements = criteria.createCriteria("descriptionElements", "descriptionElement", Criteria.LEFT_JOIN);\r
+ elements.add(Restrictions.in("area", namedAreas.toArray()));\r
+\r
+ if(status != null) {\r
+ elements.add(Restrictions.eq("status", status));\r
+ }\r
+\r
+ ProjectionList projectionList = Projections.projectionList().add(Projections.id());\r
+\r
+ if(orderHints != null && !orderHints.isEmpty()) {\r
+ for(OrderHint orderHint : orderHints) {\r
+ projectionList = projectionList.add(Projections.property(orderHint.getPropertyName()));\r
+ }\r
+ }\r
+\r
+ criteria.setProjection(Projections.distinct(projectionList));\r
+\r
+ if(pageSize != null) {\r
+ criteria.setMaxResults(pageSize);\r
+ if(pageNumber != null) {\r
+ criteria.setFirstResult(pageNumber * pageSize);\r
+ }\r
+ }\r
+\r
+ addOrder(criteria,orderHints);\r
+\r
+ List<Object> intermediateResult = criteria.list();\r
+\r
+ if(intermediateResult.isEmpty()) {\r
+ return new ArrayList<TaxonDescription>();\r
+ }\r
+\r
+ Integer[] resultIds = new Integer[intermediateResult.size()];\r
+ for(int i = 0; i < resultIds.length; i++) {\r
+ if(orderHints == null || orderHints.isEmpty()) {\r
+ resultIds[i] = ((Number)intermediateResult.get(i)).intValue();\r
+ } else {\r
+ resultIds[i] = ((Number)((Object[])intermediateResult.get(i))[0]).intValue();\r
+ }\r
+ }\r
+\r
+ criteria = getSession().createCriteria(TaxonDescription.class);\r
+ criteria.add(Restrictions.in("id", resultIds));\r
+ addOrder(criteria,orderHints);\r
+\r
+ List<TaxonDescription> results = criteria.list();\r
+ defaultBeanInitializer.initializeAll(results, propertyPaths);\r
+ return results;\r
+ }\r
+\r
+ @Override\r
+ public List<CommonTaxonName> searchDescriptionByCommonName(String queryString, MatchMode matchMode, Integer pageSize, Integer pageNumber) {\r
+\r
+ Criteria crit = getSession().createCriteria(CommonTaxonName.class);\r
+ if (matchMode == MatchMode.EXACT) {\r
+ crit.add(Restrictions.eq("name", matchMode.queryStringFrom(queryString)));\r
+ } else {\r
+ crit.add(Restrictions.ilike("name", matchMode.queryStringFrom(queryString)));\r
+ }\r
+\r
+ if(pageSize != null) {\r
+ crit.setMaxResults(pageSize);\r
+ if(pageNumber != null) {\r
+ crit.setFirstResult(pageNumber * pageSize);\r
+ }\r
+ }\r
+ List<CommonTaxonName> results = crit.list();\r
+ return results;\r
+ }\r
+\r
+ @Override\r
+ public Integer countDescriptionByCommonName(String queryString, MatchMode matchMode) {\r
+ //TODO inprove performance\r
+ List<CommonTaxonName> results = searchDescriptionByCommonName(queryString, matchMode, null, null);\r
+ return results.size();\r
+ }\r
+\r
+ @Override\r
+ public DescriptionBase find(LSID lsid) {\r
+ DescriptionBase descriptionBase = super.find(lsid);\r
+ if(descriptionBase != null) {\r
+ List<String> propertyPaths = new ArrayList<String>();\r
+ propertyPaths.add("createdBy");\r
+ propertyPaths.add("updatedBy");\r
+ propertyPaths.add("taxon");\r
+ propertyPaths.add("taxonName");\r
+ propertyPaths.add("descriptionElements");\r
+ propertyPaths.add("descriptionElements.createdBy");\r
+ propertyPaths.add("descriptionElements.updatedBy");\r
+ propertyPaths.add("descriptionElements.feature");\r
+ propertyPaths.add("descriptionElements.multilanguageText");\r
+ propertyPaths.add("descriptionElements.multilanguageText.language");\r
+ propertyPaths.add("descriptionElements.area");\r
+ propertyPaths.add("descriptionElements.status");\r
+ propertyPaths.add("descriptionElements.modifyingText");\r
+ propertyPaths.add("descriptionElementsmodifyingText.language");\r
+ propertyPaths.add("descriptionElements.modifiers");\r
+\r
+ defaultBeanInitializer.initialize(descriptionBase, propertyPaths);\r
+ }\r
+ return descriptionBase;\r
+ }\r
+\r
+\r
+ @Override\r
+ public <T extends DescriptionElementBase> List<T> getDescriptionElementForTaxon(\r
+ UUID taxonUuid, Set<Feature> features,\r
+ Class<T> type, Integer pageSize,\r
+ Integer pageNumber, List<String> propertyPaths) {\r
+\r
+// Logger.getLogger("org.hibernate.SQL").setLevel(Level.TRACE);\r
+\r
+ Query query = prepareGetDescriptionElementForTaxon(taxonUuid, features, type, pageSize, pageNumber, false);\r
+\r
+ if (logger.isDebugEnabled()){logger.debug(" dao: get list ...");}\r
+ @SuppressWarnings("unchecked")\r
+ List<T> results = query.list();\r
+ if (logger.isDebugEnabled()){logger.debug(" dao: initialize ...");}\r
+ defaultBeanInitializer.initializeAll(results, propertyPaths);\r
+ if (logger.isDebugEnabled()){logger.debug(" dao: initialize - DONE");}\r
+\r
+// Logger.getLogger("org.hibernate.SQL").setLevel(Level.WARN);\r
+ return results;\r
+ }\r
+\r
+ @Override\r
+ public <T extends DescriptionElementBase> long countDescriptionElementForTaxon(\r
+ UUID taxonUuid, Set<Feature> features, Class<T> type) {\r
+\r
+ Query query = prepareGetDescriptionElementForTaxon(taxonUuid, features, type, null, null, true);\r
+\r
+ return (Long)query.uniqueResult();\r
+ }\r
+\r
+ /**\r
+ * @param taxon\r
+ * @param features\r
+ * @param type\r
+ * @param pageSize\r
+ * @param pageNumber\r
+ * @return\r
+ */\r
+ private <T extends DescriptionElementBase> Query prepareGetDescriptionElementForTaxon(UUID taxonUuid,\r
+ Set<Feature> features, Class<T> type, Integer pageSize, Integer pageNumber, boolean asCountQuery) {\r
+\r
+ String listOrCount;\r
+ if(asCountQuery){\r
+ listOrCount = "count(de)";\r
+ } else {\r
+ listOrCount = "de";\r
+ }\r
+\r
+ String queryString = "SELECT " + listOrCount + " FROM DescriptionElementBase AS de" +\r
+ " LEFT JOIN de.inDescription AS d" +\r
+ " LEFT JOIN d.taxon AS t" +\r
+ " WHERE d.class = 'TaxonDescription' AND t.uuid = :taxon_uuid ";\r
+\r
+ if(type != null){\r
+ queryString += " and de.class = :type";\r
+ }\r
+ if (features != null && features.size() > 0){\r
+ queryString += " and de.feature in (:features) ";\r
+ }\r
+// System.out.println(queryString);\r
+ Query query = getSession().createQuery(queryString);\r
+\r
+ query.setParameter("taxon_uuid", taxonUuid);\r
+ if(type != null){\r
+ query.setParameter("type", type.getSimpleName());\r
+ }\r
+ if(features != null && features.size() > 0){\r
+ query.setParameterList("features", features) ;\r
+ }\r
+\r
+ if(pageSize != null) {\r
+ query.setMaxResults(pageSize);\r
+ if(pageNumber != null) {\r
+ query.setFirstResult(pageNumber * pageSize);\r
+ }\r
+ }\r
+ return query;\r
+ }\r
+\r
+ /* (non-Javadoc)\r
+ * @see eu.etaxonomy.cdm.persistence.dao.description.IDescriptionDao#listTaxonDescriptionMedia(java.util.UUID, java.lang.Boolean, java.util.Set, java.lang.Integer, java.lang.Integer, java.util.List)\r
+ */\r
+ @Override\r
+ public List<Media> listTaxonDescriptionMedia(UUID taxonUuid,\r
+ Boolean limitToGalleries, Set<MarkerType> markerTypes,\r
+ Integer pageSize, Integer pageNumber, List<String> propertyPaths) {\r
+\r
+ AuditEvent auditEvent = getAuditEventFromContext();\r
+ if(auditEvent.equals(AuditEvent.CURRENT_VIEW)) {\r
+ String queryString = " SELECT media " +\r
+ getTaxonDescriptionMediaQueryString(\r
+ taxonUuid, limitToGalleries, markerTypes);\r
+ queryString +=\r
+ " GROUP BY media "\r
+// " ORDER BY index(media) " //not functional\r
+ ;\r
+\r
+ Query query = getSession().createQuery(queryString);\r
+\r
+ setTaxonDescriptionMediaParameters(query, taxonUuid, limitToGalleries, markerTypes);\r
+\r
+\r
+// addMarkerTypesCriterion(markerTypes, hql);\r
+\r
+ setPagingParameter(query, pageSize, pageNumber);\r
+\r
+ List<Media> results = query.list();\r
+\r
+ defaultBeanInitializer.initializeAll(results, propertyPaths);\r
+\r
+ return results;\r
+ } else {\r
+ throw new OperationNotSupportedInPriorViewException("countTaxonDescriptionMedia(UUID taxonUuid, boolean restrictToGalleries)");\r
+ }\r
+ }\r
+\r
+\r
+ /* (non-Javadoc)\r
+ * @see eu.etaxonomy.cdm.persistence.dao.description.IDescriptionDao#countTaxonDescriptionMedia(java.util.UUID, java.lang.Boolean, java.util.Set)\r
+ */\r
+ @Override\r
+ public int countTaxonDescriptionMedia(UUID taxonUuid,\r
+ Boolean limitToGalleries, Set<MarkerType> markerTypes) {\r
+ AuditEvent auditEvent = getAuditEventFromContext();\r
+ if(auditEvent.equals(AuditEvent.CURRENT_VIEW)) {\r
+ String queryString = " SELECT count(DISTINCT media) " +\r
+ getTaxonDescriptionMediaQueryString(\r
+ taxonUuid, limitToGalleries, markerTypes);\r
+\r
+ Query query = getSession().createQuery(queryString);\r
+ setTaxonDescriptionMediaParameters(query, taxonUuid, limitToGalleries, markerTypes);\r
+ return ((Long)query.uniqueResult()).intValue();\r
+ }else{\r
+ throw new OperationNotSupportedInPriorViewException("countTaxonDescriptionMedia(UUID taxonUuid)");\r
+ }\r
+\r
+ }\r
+\r
+ private void setTaxonDescriptionMediaParameters(Query query, UUID taxonUuid, Boolean limitToGalleries, Set<MarkerType> markerTypes) {\r
+ if(taxonUuid != null){\r
+ query.setParameter("uuid", taxonUuid);\r
+ }\r
+\r
+ }\r
+\r
+ /**\r
+ * @param taxonUuid\r
+ * @param restrictToGalleries\r
+ * @param markerTypes\r
+ * @return\r
+ */\r
+ private String getTaxonDescriptionMediaQueryString(UUID taxonUuid,\r
+ Boolean restrictToGalleries, Set<MarkerType> markerTypes) {\r
+ String fromQueryString =\r
+ " FROM DescriptionElementBase as deb INNER JOIN " +\r
+ " deb.inDescription as td "\r
+ + " INNER JOIN td.taxon as t "\r
+ + " JOIN deb.media as media "\r
+ + " LEFT JOIN td.markers marker ";\r
+\r
+ String whereQueryString = " WHERE (1=1) ";\r
+ if (taxonUuid != null){\r
+ whereQueryString += " AND t.uuid = :uuid ";\r
+ }\r
+ if (restrictToGalleries){\r
+ whereQueryString += " AND td.imageGallery is true ";\r
+ }\r
+ if (markerTypes != null && !markerTypes.isEmpty()){\r
+ whereQueryString += " AND (1=0";\r
+ for (MarkerType markerType : markerTypes){\r
+ whereQueryString += " OR ( marker.markerType.id = " + markerType.getId() + " AND marker.flag is true)";\r
+\r
+ }\r
+ whereQueryString += ") ";\r
+ }\r
+\r
+ return fromQueryString + whereQueryString;\r
+\r
+ }\r
+\r
+ /* (non-Javadoc)\r
+ * @see eu.etaxonomy.cdm.persistence.dao.description.IDescriptionDao#listNamedAreasInUse(java.lang.Integer, java.lang.Integer, java.util.List)\r
+ */\r
+ @SuppressWarnings("unchecked")\r
+ @Override\r
+ public List<TermDto> listNamedAreasInUse(boolean includeAllParents, Integer pageSize, Integer pageNumber) {\r
+\r
+// Logger.getLogger("org.hibernate.SQL").setLevel(Level.TRACE);\r
+\r
+ StringBuilder queryString = new StringBuilder(\r
+ "SELECT DISTINCT a.id, a.partOf.id"\r
+ + " FROM Distribution AS d JOIN d.area AS a");\r
+ Query query = getSession().createQuery(queryString.toString());\r
+\r
+ List<Object[]> areasInUse = query.list();\r
+ List<Object[]> parentResults = new ArrayList<Object[]>();\r
+\r
+ if(!areasInUse.isEmpty()) {\r
+ Set<Object> allAreaIds = new HashSet<Object>(areasInUse.size());\r
+\r
+ if(includeAllParents) {\r
+ // find all parent nodes\r
+ String allAreasQueryStr = "select a.id, a.partOf.id from NamedArea as a";\r
+ query = getSession().createQuery(allAreasQueryStr);\r
+ List<Object[]> allAreasResult = query.list();\r
+ Map<Object, Object> allAreasMap = ArrayUtils.toMap(allAreasResult.toArray());\r
+\r
+ Set<Object> parents = new HashSet<Object>();\r
+\r
+ for(Object[] leaf : areasInUse) {\r
+ allAreaIds.add(leaf[0]);\r
+ Object parentId = leaf[1];\r
+ while (parentId != null) {\r
+ if(parents.contains(parentId)) {\r
+ // break if the parent already is in the set\r
+ break;\r
+ }\r
+ parents.add(parentId);\r
+ parentId = allAreasMap.get(parentId);\r
+ }\r
+ }\r
+ allAreaIds.addAll(parents);\r
+ } else {\r
+ // only add the ids found so far\r
+ for(Object[] leaf : areasInUse) {\r
+ allAreaIds.add(leaf[0]);\r
+ }\r
+ }\r
+\r
+\r
+ // NOTE can't use "select new TermDto(distinct a.uuid, r , a.vocabulary.uuid) since we will get multiple\r
+ // rows for a term with multiple representations\r
+ String parentAreasQueryStr = "select a.uuid, r, p.uuid, v.uuid "\r
+ + "from NamedArea as a LEFT JOIN a.partOf as p LEFT JOIN a.representations AS r LEFT JOIN a.vocabulary as v "\r
+ + "where a.id in (:allAreaIds) order by a.idInVocabulary";\r
+ query = getSession().createQuery(parentAreasQueryStr);\r
+ query.setParameterList("allAreaIds", allAreaIds);\r
+ if(pageSize != null) {\r
+ query.setMaxResults(pageSize);\r
+ if(pageNumber != null) {\r
+ query.setFirstResult(pageNumber * pageSize);\r
+ }\r
+ }\r
+ parentResults = query.list();\r
+ }\r
+ List<TermDto> dtoList = termDtoListFrom(parentResults);\r
+\r
+ return dtoList;\r
+ }\r
+\r
+ /**\r
+ * @param results\r
+ * @return\r
+ */\r
+ private List<TermDto> termDtoListFrom(List<Object[]> results) {\r
+ Map<UUID, TermDto> dtoMap = new HashMap<UUID, TermDto>(results.size());\r
+ for (Object[] elements : results) {\r
+ UUID uuid = (UUID)elements[0];\r
+ if(dtoMap.containsKey(uuid)){\r
+ dtoMap.get(uuid).addRepresentation((Representation)elements[1]);\r
+ } else {\r
+ Set<Representation> representations;\r
+ if(elements[1] instanceof Representation) {\r
+ representations = new HashSet<Representation>(1);\r
+ representations.add((Representation)elements[1]);\r
+ } else {\r
+ representations = (Set<Representation>)elements[1];\r
+ }\r
+ dtoMap.put(uuid, new TermDto(uuid, representations, (UUID)elements[2], (UUID)elements[3]));\r
+ }\r
+ }\r
+ return new ArrayList<TermDto>(dtoMap.values());\r
+ }\r
+\r
+\r
+\r
+}\r