Merge branch 'develop' into feature/cdm-4.7
authorAndreas Müller <a.mueller@bgbm.org>
Sat, 20 May 2017 21:28:19 +0000 (23:28 +0200)
committerAndreas Müller <a.mueller@bgbm.org>
Sat, 20 May 2017 21:28:19 +0000 (23:28 +0200)
1  2 
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/common/CdmImportBase.java
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/name/ITaxonNameBase.java
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/name/TaxonNameBase.java
cdmlib-services/pom.xml
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/CommonServiceImpl.java
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/NameServiceImpl.java

index 88fdc109ac254972910526de9d6dce263432dbbe,b234cf04fcbb8d118716b78c19bd35fce3e12f51..0c6069eb39e22a00941ebf229f61ec6c866440a8
@@@ -89,7 -89,7 +89,7 @@@ public abstract class CdmImportBase<CON
              implements ICdmImport<CONFIG, STATE>{
  
      private static final long serialVersionUID = 8730012744209195616L;
 -    private static Logger logger = Logger.getLogger(CdmImportBase.class);
 +    private static final Logger logger = Logger.getLogger(CdmImportBase.class);
  
        protected static final boolean CREATE = true;
        protected static final boolean IMAGE_GALLERY = true;
                }
        }
  
+       protected Media getImageMedia(String uriString, boolean readMediaData) throws MalformedURLException {
+           return getImageMedia(uriString, null, readMediaData);
+       }
  
        /**
         * Creates
         * @return
         * @throws MalformedURLException
         */
-       protected Media getImageMedia(String uriString, boolean readMediaData) throws MalformedURLException {
+       protected Media getImageMedia(String uriString, String uriStrThumb, boolean readMediaData) throws MalformedURLException {
                if( uriString == null){
                        return null;
                } else {
-                       ImageInfo imageInfo = null;
-                       URI uri;
                        uriString = uriString.replace(" ", "%20");  //replace whitespace
                        try {
-                               uri = new URI(uriString);
-                               try {
+                           ImageInfo imageInfo = null;
+                               URI uri = new URI(uriString);
+                 try {
                                        if (readMediaData){
                                                logger.info("Read media data from: " + uri);
                                                imageInfo = ImageInfo.NewInstance(uri, 0);
                                        fireWarningEvent(message, "unknown location", 2, 0);
                                }
                                ImageFile imageFile = ImageFile.NewInstance(uri, null, imageInfo);
                                MediaRepresentation representation = MediaRepresentation.NewInstance();
                                if(imageInfo != null){
                                        representation.setMimeType(imageInfo.getMimeType());
                                        representation.setSuffix(imageInfo.getSuffix());
                                }
                                representation.addRepresentationPart(imageFile);
                                Media media = Media.NewInstance();
-                               media.addRepresentation(representation);
+                 media.addRepresentation(representation);
+                               if (uriStrThumb != null){
+                                   ImageInfo imageInfoThumb = null;
+                       uriStrThumb = uriStrThumb.replace(" ", "%20");  //replace whitespace
+                       URI uriThumb = new URI(uriStrThumb);
+                       try {
+                           if (readMediaData){
+                               logger.info("Read media data from: " + uriThumb);
+                               imageInfoThumb = ImageInfo.NewInstance(uriThumb, 0);
+                           }
+                       } catch (Exception e) {
+                           String message = "An error occurred when trying to read image meta data for " + uriThumb.toString() + ": " +  e.getMessage();
+                           logger.warn(message);
+                           fireWarningEvent(message, "unknown location", 2, 0);
+                       }
+                       ImageFile imageFileFhumb = ImageFile.NewInstance(uriThumb, null, imageInfoThumb);
+                                   MediaRepresentation reprThumb = MediaRepresentation.NewInstance();
+                                   if(imageInfoThumb != null){
+                                       reprThumb.setMimeType(imageInfoThumb.getMimeType());
+                                       reprThumb.setSuffix(imageInfoThumb.getSuffix());
+                       }
+                                   reprThumb.addRepresentationPart(imageFileFhumb);
+                                   media.addRepresentation(reprThumb);
+                               }
                                return media;
                        } catch (URISyntaxException e1) {
                                String message = "An URISyntaxException occurred when trying to create uri from multimedia objcet string: " +  uriString;
index 24755b2c546c04d0b116baaaffaed1ae75c3775f,003b9109304a9f6bd2a71b4df5149e8bda5d0ef4..ef2e10d26c5e7bfcdf571431d8225efa65083938
@@@ -90,12 -90,13 +90,13 @@@ public interface ITaxonNameBas
       * @param toName          the taxon name of the target for this new name relationship
       * @param type            the type of this new name relationship
       * @param ruleConsidered  the string which specifies the rule on which this name relationship is based
+      * @return
       * @see                   #getRelationsToThisName()
       * @see                   #getNameRelations()
       * @see                   #addRelationshipFromName(TaxonNameBase, NameRelationshipType, String)
       * @see                   #addNameRelationship(NameRelationship)
       */
-     public void addRelationshipToName(TaxonNameBase toName, NameRelationshipType type, String ruleConsidered);
+     public NameRelationship addRelationshipToName(TaxonNameBase toName, NameRelationshipType type, String ruleConsidered);
  
      /**
       * Creates a new {@link NameRelationship#NameRelationship(TaxonNameBase, TaxonNameBase, NameRelationshipType, String) name relationship} from <i>this</i> taxon name to another taxon name
       */
      public int compareToName(TaxonNameBase<?,?> otherName);
  
 +    /**
 +     * This method returns als {@link Registration registrations} for the given name.
 +     * @return
 +     */
 +    public Set<Registration> getRegistrations();
 +
  
  
  }
index 610ed56536aaef1433655e624ca62d6e3a53e60e,c99ece8dc9c8c2dca2cfd054db348825bda36390..4b29300ecee5557429cbda398a4bc1e7850e5d25
@@@ -49,7 -49,6 +49,7 @@@ import org.apache.log4j.Logger
  import org.hibernate.annotations.Cascade;
  import org.hibernate.annotations.CascadeType;
  import org.hibernate.annotations.Table;
 +import org.hibernate.annotations.Type;
  import org.hibernate.envers.Audited;
  import org.hibernate.search.annotations.Analyze;
  import org.hibernate.search.annotations.Analyzer;
@@@ -66,14 -65,11 +66,14 @@@ import eu.etaxonomy.cdm.common.UTF8
  import eu.etaxonomy.cdm.model.agent.INomenclaturalAuthor;
  import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
  import eu.etaxonomy.cdm.model.common.CdmBase;
 +import eu.etaxonomy.cdm.model.common.DefinedTermBase;
  import eu.etaxonomy.cdm.model.common.IIntextReferenceTarget;
  import eu.etaxonomy.cdm.model.common.IParsable;
  import eu.etaxonomy.cdm.model.common.IRelated;
  import eu.etaxonomy.cdm.model.common.IdentifiableEntity;
  import eu.etaxonomy.cdm.model.common.RelationshipBase;
 +import eu.etaxonomy.cdm.model.common.TermType;
 +import eu.etaxonomy.cdm.model.common.TermVocabulary;
  import eu.etaxonomy.cdm.model.description.TaxonNameDescription;
  import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
  import eu.etaxonomy.cdm.model.reference.INomenclaturalReference;
@@@ -118,7 -114,6 +118,7 @@@ import eu.etaxonomy.cdm.validation.anno
   */
  @XmlAccessorType(XmlAccessType.FIELD)
  @XmlType(name = "TaxonNameBase", propOrder = {
 +    "nameType",
      "appendedPhrase",
      "nomenclaturalMicroReference",
      "nomenclaturalReference",
      "status",
      "descriptions",
      "taxonBases",
 +    "registrations",
  
      "nameCache",
      "genusOrUninomial",
@@@ -182,19 -176,6 +182,19 @@@ public abstract class TaxonNameBase<T e
      private static final Logger logger = Logger.getLogger(TaxonNameBase.class);
  
  
 +    /**
 +     * The {@link TermType type} of this term. Needs to be the same type in a {@link DefinedTermBase defined term}
 +     * and in it's {@link TermVocabulary vocabulary}.
 +     */
 +    @XmlAttribute(name ="NameType")
 +    @Column(name="nameType", length=15)
 +    @NotNull
 +    @Type(type = "eu.etaxonomy.cdm.hibernate.EnumUserType",
 +        parameters = {@org.hibernate.annotations.Parameter(name  = "enumClass", value = "eu.etaxonomy.cdm.model.name.NomenclaturalCode")}
 +    )
 +    @Audited //needed ?
 +    private NomenclaturalCode nameType;
 +
      @XmlElement(name = "FullTitleCache")
      @Column(length=800, name="fullTitleCache")  //see #1592
      @Match(value=MatchMode.CACHE, cacheReplaceMode=ReplaceMode.ALL)
      @IndexedEmbedded
      private Reference nomenclaturalReference;
  
 +    @XmlElementWrapper(name = "Registrations")
 +    @XmlElement(name = "Registration")
 +    @XmlIDREF
 +    @XmlSchemaType(name = "IDREF")
 +    @OneToMany(mappedBy="name", fetch= FetchType.LAZY)
 +    @NotNull
 +    @IndexedEmbedded(depth=1)
 +    private Set<Registration> registrations = new HashSet<>();
 +
  //****** Non-ViralName attributes ***************************************/
  
      @XmlElement(name = "NameCache")
  
      //see TaxonNameFactory
  
 -// *********************** PARSER STATIC *******************************/
 -
 -
  
  // ************* CONSTRUCTORS *************/
      /**
       * Class constructor: creates a new empty taxon name.
 +     * @param code
       *
       * @see #TaxonNameBase(Rank)
       * @see #TaxonNameBase(HomotypicalGroup)
          super();
          setNameCacheStrategy();
      }
 +    /**
 +     * Class constructor: creates a new empty taxon name.
 +     * @param code
 +     *
 +     * @see #TaxonNameBase(Rank)
 +     * @see #TaxonNameBase(HomotypicalGroup)
 +     * @see #TaxonNameBase(Rank, HomotypicalGroup)
 +     */
 +    protected TaxonNameBase(NomenclaturalCode type) {
 +        super();
 +        this.nameType = type;
 +        setNameCacheStrategy();
 +    }
      /**
       * Class constructor: creates a new taxon name
       * only containing its {@link Rank rank}.
       * @see                    #TaxonNameBase(HomotypicalGroup)
       * @see                    #TaxonNameBase(Rank, HomotypicalGroup)
       */
 -    protected TaxonNameBase(Rank rank) {
 -        this(rank, null);
 +    protected TaxonNameBase(NomenclaturalCode code, Rank rank) {
 +        this(code, rank, null);
      }
      /**
       * Class constructor: creates a new taxon name instance
       * @see                                            #TaxonNameBase(Rank)
       * @see                                            #TaxonNameBase(Rank, HomotypicalGroup)
       */
 -    protected TaxonNameBase(HomotypicalGroup homotypicalGroup) {
 -        this(null, homotypicalGroup);
 +    protected TaxonNameBase(NomenclaturalCode type, HomotypicalGroup homotypicalGroup) {
 +        this(type, null, homotypicalGroup);
      }
  
      /**
       * @see                                            #TaxonNameBase(Rank)
       * @see                                            #TaxonNameBase(HomotypicalGroup)
       */
 -    protected TaxonNameBase(Rank rank, HomotypicalGroup homotypicalGroup) {
 +    protected TaxonNameBase(NomenclaturalCode type, Rank rank, HomotypicalGroup homotypicalGroup) {
          super();
 +        this.nameType = type;
          this.setRank(rank);
          if (homotypicalGroup == null){
              homotypicalGroup = new HomotypicalGroup();
       * @see     eu.etaxonomy.cdm.strategy.cache.name.INameCacheStrategy
       * @see     eu.etaxonomy.cdm.strategy.cache.common.IIdentifiableEntityCacheStrategy
       */
 -    protected TaxonNameBase(Rank rank, String genusOrUninomial, String infraGenericEpithet, String specificEpithet, String infraSpecificEpithet, TeamOrPersonBase combinationAuthorship, INomenclaturalReference nomenclaturalReference, String nomenclMicroRef, HomotypicalGroup homotypicalGroup) {
 -        this(rank, homotypicalGroup);
 +    protected TaxonNameBase(NomenclaturalCode type, Rank rank, String genusOrUninomial, String infraGenericEpithet, String specificEpithet, String infraSpecificEpithet, TeamOrPersonBase combinationAuthorship, INomenclaturalReference nomenclaturalReference, String nomenclMicroRef, HomotypicalGroup homotypicalGroup) {
 +        this(type, rank, homotypicalGroup);
          setGenusOrUninomial(genusOrUninomial);
          setInfraGenericEpithet (infraGenericEpithet);
          setSpecificEpithet(specificEpithet);
       * @param toName            the taxon name of the target for this new name relationship
       * @param type                      the type of this new name relationship
       * @param ruleConsidered  the string which specifies the rule on which this name relationship is based
+      * @return
       * @see                                     #getRelationsToThisName()
       * @see                                     #getNameRelations()
       * @see                                     #addRelationshipFromName(TaxonNameBase, NameRelationshipType, String)
       * @see                                     #addNameRelationship(NameRelationship)
       */
      @Override
-     public void addRelationshipToName(TaxonNameBase toName, NameRelationshipType type, String ruleConsidered){
-         addRelationshipToName(toName, type, null, null, ruleConsidered);
-         //            NameRelationship rel = new NameRelationship(toName, this, type, ruleConsidered);
+     public NameRelationship addRelationshipToName(TaxonNameBase toName, NameRelationshipType type, String ruleConsidered){
+         return addRelationshipToName(toName, type, null, null, ruleConsidered);
      }
  
      /**
      @Override
      @Transient
      public Set<Taxon> getTaxa(){
 -        Set<Taxon> result = new HashSet<Taxon>();
 +        Set<Taxon> result = new HashSet<>();
          for (TaxonBase taxonBase : this.taxonBases){
              if (taxonBase instanceof Taxon){
                  result.add((Taxon)taxonBase);
      @Override
      @Transient
      public Set<Synonym> getSynonyms() {
 -        Set<Synonym> result = new HashSet<Synonym>();
 +        Set<Synonym> result = new HashSet<>();
          for (TaxonBase taxonBase : this.taxonBases){
              if (taxonBase instanceof Synonym){
                  result.add((Synonym)taxonBase);
          return result;
      }
  
 +    //******* REGISTRATION *****************/
 +
 +    @Override
 +    public Set<Registration> getRegistrations() {
 +        return this.registrations;
 +    }
 +
 +
  // ************* RELATIONSHIPS *****************************/
  
  
diff --combined cdmlib-services/pom.xml
index 220af69b6ef498d473f98b01c34ce06cbb5edae4,760c2db2399c493c9e5f9bf95d16b080b64d3ca9..54ca3c7c1df909794e4ad31531c4986c36dde367
@@@ -6,7 -6,7 +6,7 @@@
    <parent>
      <groupId>eu.etaxonomy</groupId>
      <artifactId>cdmlib-parent</artifactId>
-     <version>4.7.0-SNAPSHOT</version>
+     <version>4.8.0-SNAPSHOT</version>
      <relativePath>../pom.xml</relativePath>
    </parent>
  
@@@ -14,6 -14,7 +14,6 @@@
    <artifactId>cdmlib-services</artifactId>    
    <name>CDM Services</name>
    <description>EDIT CDM library services. The local API and basis for webservices too.</description>
 -  <packaging>bundle</packaging>
    <scm>
      <connection>scm:svn:http://dev.e-taxonomy.eu/svn/trunk/cdmlib/cdmlib-service/</connection>
      <developerConnection>scm:svn:http://dev.e-taxonomy.eu/svn/trunk/cdmlib/cdmlib-service/</developerConnection>
    </scm>
    <build>
      <plugins>
 -      <plugin>
 -        <groupId>org.apache.felix</groupId>
 -        <artifactId>maven-bundle-plugin</artifactId>
 -        <version>2.3.6</version>
 -        <extensions>true</extensions>
 -        <configuration>
 -          <instructions>
 -            <Export-Package>eu.etaxonomy.cdm.api.service</Export-Package>
 -            <Bundle-SymbolicName>eu.etaxonomy.cdm.services</Bundle-SymbolicName>
 -            <Bundle-Activator>eu.etaxonomy.cdm.services.impl.Activator</Bundle-Activator>
 -          </instructions>
 -        </configuration>
 -      </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-surefire-plugin</artifactId>
     </plugins>
    </build>
    <dependencies>
 -    <dependency>
 -      <groupId>org.apache.felix</groupId>
 -      <artifactId>org.osgi.core</artifactId>
 -      <version>1.0.0</version>
 -    </dependency>
      <dependency>
        <groupId>eu.etaxonomy</groupId>
        <artifactId>cdmlib-persistence</artifactId>
index 52eecb1a24f2d0c3bde012bfef64173fa199e0ef,9af5e51af9bb1c5f90dd47f3545063bf591b4b58..8e6861f6e1cf3aa710fc48e06402cdfc19eb219d
@@@ -26,7 -26,7 +26,7 @@@ import eu.etaxonomy.cdm.model.common.Cd
  import eu.etaxonomy.cdm.model.common.ISourceable;\r
  import eu.etaxonomy.cdm.model.common.IdentifiableEntity;\r
  import eu.etaxonomy.cdm.model.metadata.CdmMetaData;\r
 -import eu.etaxonomy.cdm.model.metadata.CdmMetaData.MetaDataPropertyName;\r
 +import eu.etaxonomy.cdm.model.metadata.CdmMetaDataPropertyName;\r
  import eu.etaxonomy.cdm.persistence.dao.common.ICdmGenericDao;\r
  import eu.etaxonomy.cdm.persistence.dao.common.IOriginalSourceDao;\r
  import eu.etaxonomy.cdm.persistence.query.OrderHint;\r
@@@ -105,7 -105,7 +105,7 @@@ public class CommonServiceImpl /*extend
  \r
      @Override\r
      public Integer getReferencingObjectsCount(CdmBase referencedCdmBase){\r
-         return this.genericDao.getReferencingObjects(referencedCdmBase).size();\r
+         return this.genericDao.getReferencingObjectsCount(referencedCdmBase);\r
      }\r
  \r
      @Override\r
      //\r
      //                        referencedCdmBase = (CdmBase)HibernateProxyHelper.deproxy(referencedCdmBase);\r
      //                        Class referencedClass = referencedCdmBase.getClass();\r
 -    //                        Set<CdmBase> result = new HashSet<CdmBase>();\r
 +    //                        Set<CdmBase> result = new HashSet<>();\r
      //                        logger.debug("Referenced Class: " + referencedClass.getName());\r
      //\r
      //                        for (Class<? extends CdmBase> cdmClass : allCdmClasses){\r
      //        }\r
      //\r
      //        private Set<Field> getFields(Class clazz){\r
 -    //                Set<Field> result = new HashSet<Field>();\r
 +    //                Set<Field> result = new HashSet<>();\r
      //                for (Field field: clazz.getDeclaredFields()){\r
      //                        if (!Modifier.isStatic(field.getModifiers())){\r
      //                                result.add(field);\r
      //        }\r
      //\r
      //        private Set<CdmBase> getCdmBasesByFieldAndClass(Field field, Class itemClass, Class otherClazz, CdmBase item, boolean isCollection){\r
 -    //                Set<CdmBase> result = new HashSet<CdmBase>();\r
 +    //                Set<CdmBase> result = new HashSet<>();\r
      //                if (isCollection){\r
      //                        result.addAll(genericDao.getCdmBasesWithItemInCollection(itemClass, otherClazz, field.getName(), item));\r
      //                }else{\r
      }\r
  \r
      @Override\r
 -    public Map<MetaDataPropertyName, CdmMetaData> getCdmMetaData() {\r
 -        Map<MetaDataPropertyName, CdmMetaData> result = new HashMap<MetaDataPropertyName, CdmMetaData>();\r
 +    public Map<CdmMetaDataPropertyName, CdmMetaData> getCdmMetaData() {\r
 +        Map<CdmMetaDataPropertyName, CdmMetaData> result = new HashMap<>();\r
          List<CdmMetaData> metaDataList = genericDao.getMetaData();\r
          for (CdmMetaData metaData : metaDataList){\r
 -            MetaDataPropertyName propertyName = metaData.getPropertyName();\r
 +            CdmMetaDataPropertyName propertyName = metaData.getPropertyName();\r
              result.put(propertyName, metaData);\r
          }\r
          return result;\r
index 9db4ab2fbb42df3eff7eb740eb550d11ecdb2240,6a9b70d38cf7dc07c01c1ce82b3f9451c434c180..88157f688c22d3a877d56e8f2a34ef5aec7af1ce
@@@ -135,30 -135,27 +135,27 @@@ public class NameServiceImpl extends Id
          return delete(name.getUuid());
      }
  
-     /* (non-Javadoc)
-      * @see eu.etaxonomy.cdm.api.service.INameService#delete(eu.etaxonomy.cdm.model.name.TaxonNameBase, eu.etaxonomy.cdm.api.service.NameDeletionConfigurator)
-      */
      @Override
      @Transactional(readOnly = false)
-     public DeleteResult delete(UUID nameUUID, NameDeletionConfigurator config) {
-       DeleteResult result = new DeleteResult();
-               TaxonNameBase name = dao.load(nameUUID);
+     public DeleteResult delete(TaxonNameBase name, NameDeletionConfigurator config) {
+         DeleteResult result = new DeleteResult();
  
-       if (name == null){
-               result.setAbort();
+         if (name == null){
+             result.setAbort();
              return result;
          }
  
-       try{
-               result = this.isDeletable(name.getUuid(), config);
+         try{
+             result = this.isDeletable(name, config);
          }catch(Exception e){
-               result.addException(e);
-               result.setError();
-               return result;
+             result.addException(e);
+             result.setError();
+             return result;
          }
          if (result.isOk()){
          //remove references to this name
-               removeNameRelationshipsByDeleteConfig(name, config);
+             removeNameRelationshipsByDeleteConfig(name, config);
  
             //remove name from homotypical group
              HomotypicalGroup homotypicalGroup = name.getHomotypicalGroup();
              }
  
               //all type designation relationships are removed as they belong to the name
-               deleteTypeDesignation(name, null);
-       //              //type designations
-       //              if (! name.getTypeDesignations().isEmpty()){
-       //                      String message = "Name can't be deleted as it has types. Remove types prior to deletion.";
-       //                      throw new ReferrencedObjectUndeletableException(message);
-       //              }
+             deleteTypeDesignation(name, null);
+     //      //type designations
+     //      if (! name.getTypeDesignations().isEmpty()){
+     //          String message = "Name can't be deleted as it has types. Remove types prior to deletion.";
+     //          throw new ReferrencedObjectUndeletableException(message);
+     //      }
  
  
-               try{
-               UUID nameUuid = dao.delete(name);
+             try{
+             UUID nameUuid = dao.delete(name);
  
-               }catch(Exception e){
-                       result.addException(e);
-                       result.setError();
-               }
-               return result;
+             }catch(Exception e){
+                 result.addException(e);
+                 result.setError();
+             }
+             return result;
          }
  
          return result;
      }
  
+     /* (non-Javadoc)
+      * @see eu.etaxonomy.cdm.api.service.INameService#delete(eu.etaxonomy.cdm.model.name.TaxonNameBase, eu.etaxonomy.cdm.api.service.NameDeletionConfigurator)
+      */
+     @Override
+     @Transactional(readOnly = false)
+     public DeleteResult delete(UUID nameUUID, NameDeletionConfigurator config) {
+         TaxonNameBase name = dao.load(nameUUID);
+         return delete(name, config);
+     }
      @Override
      public DeleteResult deleteTypeDesignation(TaxonNameBase name, TypeDesignationBase typeDesignation){
        if(typeDesignation!=null && typeDesignation.getId()!=0){
          return referencedEntityDao.saveAll(referencedEntityCollection);
      }
  
 -    /**
 -     * TODO candidate for harmonization
 -     * new name getNames
 -     */
 -    public List<TaxonNameBase> getAllNames(int limit, int start){
 -        return dao.list(limit, start);
 -    }
 -
      /**
       * TODO candidate for harmonization
       * new name getNomenclaturalStatus
          return taggedName;
      }
  
-     @Override
-     public DeleteResult isDeletable(UUID nameUUID, DeleteConfiguratorBase config){
-       DeleteResult result = new DeleteResult();
-       TaxonNameBase name = this.load(nameUUID);
-       NameDeletionConfigurator nameConfig = null;
-       if (config instanceof NameDeletionConfigurator){
-               nameConfig = (NameDeletionConfigurator) config;
-       }else{
-                result.addException(new Exception("The delete configurator should be of the type NameDeletionConfigurator."));
-                result.setError();
-                return result;
-       }
  
-       if (!name.getNameRelations().isEmpty() && !nameConfig.isRemoveAllNameRelationships()){
-               HomotypicalGroup homotypicalGroup = HibernateProxyHelper.deproxy(name.getHomotypicalGroup(), HomotypicalGroup.class);
+     public DeleteResult isDeletable(TaxonNameBase name, DeleteConfiguratorBase config){
+         DeleteResult result = new DeleteResult();
+         NameDeletionConfigurator nameConfig = null;
+         if (config instanceof NameDeletionConfigurator){
+             nameConfig = (NameDeletionConfigurator) config;
+         }else{
+              result.addException(new Exception("The delete configurator should be of the type NameDeletionConfigurator."));
+              result.setError();
+              return result;
+         }
+         if (!name.getNameRelations().isEmpty() && !nameConfig.isRemoveAllNameRelationships()){
+             HomotypicalGroup homotypicalGroup = HibernateProxyHelper.deproxy(name.getHomotypicalGroup(), HomotypicalGroup.class);
  
-               if (!nameConfig.isIgnoreIsBasionymFor() && homotypicalGroup.getBasionyms().contains(name)){
-                               result.addException(new Exception( "Name can't be deleted as it is a basionym."));
-                               result.setAbort();
+             if (!nameConfig.isIgnoreIsBasionymFor() && homotypicalGroup.getBasionyms().contains(name)){
+                 result.addException(new Exception( "Name can't be deleted as it is a basionym."));
+                 result.setAbort();
              }
              if (!nameConfig.isIgnoreHasBasionym() && (name.getBasionyms().size()>0)){
-               result.addException(new Exception( "Name can't be deleted as it has a basionym."));
-               result.setAbort();
+                 result.addException(new Exception( "Name can't be deleted as it has a basionym."));
+                 result.setAbort();
              }
              Set<NameRelationship> relationships = name.getNameRelations();
              for (NameRelationship rel: relationships){
-               if (!rel.getType().equals(NameRelationshipType.BASIONYM())){
-                       result.addException(new Exception("Name can't be deleted as it is used in name relationship(s). Remove name relationships prior to deletion."));
-                       result.setAbort();
-                       break;
-               }
+                 if (!rel.getType().equals(NameRelationshipType.BASIONYM())){
+                     result.addException(new Exception("Name can't be deleted as it is used in name relationship(s). Remove name relationships prior to deletion."));
+                     result.setAbort();
+                     break;
+                 }
              }
          }
  
          //concepts
          if (! name.getTaxonBases().isEmpty()){
-               result.addException(new Exception("Name can't be deleted as it is used in concept(s). Remove or change concept prior to deletion."));
-               result.setAbort();
+             result.addException(new Exception("Name can't be deleted as it is used in concept(s). Remove or change concept prior to deletion."));
+             result.setAbort();
          }
  
          //hybrid relationships
              Set<HybridRelationship> parentHybridRelations = nvn.getHybridParentRelations();
              //Hibernate.initialize(parentHybridRelations);
              if (! parentHybridRelations.isEmpty()){
-               result.addException(new Exception("Name can't be deleted as it is a parent in (a) hybrid relationship(s). Remove hybrid relationships prior to deletion."));
-               result.setAbort();
+                 result.addException(new Exception("Name can't be deleted as it is a parent in (a) hybrid relationship(s). Remove hybrid relationships prior to deletion."));
+                 result.setAbort();
              }
          }
-       Set<CdmBase> referencingObjects = genericDao.getReferencingObjectsForDeletion(name);
+         Set<CdmBase> referencingObjects = genericDao.getReferencingObjectsForDeletion(name);
          for (CdmBase referencingObject : referencingObjects){
              //DerivedUnit?.storedUnder
              if (referencingObject.isInstanceOf(DerivedUnit.class)){
              result.addException(new Exception(message));
              result.setAbort();
          }
-       return result;
+         return result;
  
      }
  
+     @Override
+     public DeleteResult isDeletable(UUID nameUUID, DeleteConfiguratorBase config){
+         TaxonNameBase name = this.load(nameUUID);
+         return isDeletable(name, config);
+     }
      @Override
      @Transactional(readOnly = true)
      public UpdateResult setAsGroupsBasionym(UUID nameUuid) {