Merge remote-tracking branch 'origin/develop' into cdm-4.1
authorAndreas Müller <a.mueller@bgbm.org>
Tue, 18 Oct 2016 16:52:09 +0000 (18:52 +0200)
committerAndreas Müller <a.mueller@bgbm.org>
Tue, 18 Oct 2016 16:52:09 +0000 (18:52 +0200)
Conflicts:
cdmlib-db/pom.xml
cdmlib-ext/pom.xml
cdmlib-io/pom.xml
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/excel/taxa/NormalExplicitImport.java
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/specimen/SpecimenImportBase.java
cdmlib-model/pom.xml
cdmlib-model/src/test/java/eu/etaxonomy/cdm/datagenerator/TaxonGenerator.java
cdmlib-model/src/test/java/eu/etaxonomy/cdm/model/taxon/TaxonTest.java
cdmlib-persistence/pom.xml
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/hibernate/common/CdmEntityDaoBase.java
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/hibernate/taxon/TaxonDaoHibernateImpl.java
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/taxon/ITaxonDao.java
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dto/TaxonNodeDto.java
cdmlib-persistence/src/test/resources/eu/etaxonomy/cdm/persistence/dao/hibernate/taxon/TaxonDaoHibernateImplTest.xml
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/ClassificationServiceImpl.java
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/ITaxonService.java
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/TaxonNodeServiceImpl.java
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/TaxonServiceImpl.java
cdmlib-services/src/test/java/eu/etaxonomy/cdm/test/function/Datasource.java
cdmlib-services/src/test/resources/eu/etaxonomy/cdm/api/service/IdentifiableServiceBaseTest.testFindByIdentifierOrMarker.xml
cdmlib-test/pom.xml

1  2 
cdmlib-ext/pom.xml
cdmlib-model/src/test/java/eu/etaxonomy/cdm/model/taxon/TaxonTest.java
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/hibernate/taxon/TaxonDaoHibernateImpl.java
cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/persistence/dao/hibernate/taxon/TaxonDaoHibernateImplTest.java
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/dto/NameCatalogueController.java
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/ClassificationServiceImpl.java
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/ITaxonService.java

index 90f07e5718133f04522c1e3b30ac6418978ad0f3,e8cbff560a9bfc1f994eb02bcdf332548ce56930..84fc56d62c3bbcd215c94cd0006eab2fc6b49825
@@@ -4,10 -4,10 +4,10 @@@
      xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
     -->
        <parent>
--              <groupId>eu.etaxonomy</groupId>
--              <artifactId>cdmlib-parent</artifactId>
-         <version>4.4.0-SNAPSHOT</version>
-               <relativePath>../pom.xml</relativePath>
++          <groupId>eu.etaxonomy</groupId>
++          <artifactId>cdmlib-parent</artifactId>
+           <version>4.4.0-SNAPSHOT</version>
 -              <relativePath>../pom.xml</relativePath>
++          <relativePath>../pom.xml</relativePath>
        </parent>
  
    <modelVersion>4.0.0</modelVersion>
index 458cb0c3cd64dbced81c4696a54e2851caf56ab3,cafd4b2b46a03bdba53bbdc05f292ca1b731a8f9..55d6281dfc427cbb99bcf03fc3d0506171626c3a
@@@ -184,40 -184,7 +184,36 @@@ public class TaxonTest extends EntityTe
                assertEquals("There should be exactly one taxon relationships", 1, taxon.getTaxonRelations().size());
        }
  
 +    @Test
 +    public void testAddHomotypicSynonymName(){
 +        TaxonNameBase<?,?> taxonName = BotanicalName.NewInstance(null);
 +        Taxon taxon = Taxon.NewInstance(taxonName, null);
 +        TaxonNameBase<?,?> synonymName1 = BotanicalName.NewInstance(null);
 +        // add a synonym to the taxon
 +        Synonym synonym1 = taxon.addHomotypicSynonymName(synonymName1);
 +        // get the homotypic group of that synonym
 +        HomotypicalGroup homotypicGroupOfSynonym = synonym1.getHomotypicGroup();
 +        // everything is fine
 +        Assert.assertEquals("We should have two names in the homotypic group",
 +                2, homotypicGroupOfSynonym.getTypifiedNames().size());
 +    }
 +    @Test
 +    public void testAddHomotypicSynonym(){
 +        TaxonNameBase<?,?> taxonName = BotanicalName.NewInstance(null);
 +        Taxon taxon = Taxon.NewInstance(taxonName, null);
 +        TaxonNameBase<?,?> synonymName1 = BotanicalName.NewInstance(null);
 +        Synonym synonym = Synonym.NewInstance(synonymName1, null);
 +        // add a synonym to the taxon
 +        taxon.addHomotypicSynonym(synonym);
 +        //synonym type must be homotypic
 +        Assert.assertEquals("Synonym must be homotypic", SynonymType.HOMOTYPIC_SYNONYM_OF(), synonym.getType());
 +        // get the homotypic group of that synonym
 +        HomotypicalGroup homotypicGroupOfSynonym = synonym.getHomotypicGroup();
 +        // everything is fine
 +        Assert.assertEquals("We should have two names in the homotypic group",
 +                2, homotypicGroupOfSynonym.getTypifiedNames().size());
 +    }
  
        @Test
        public void testAddRemoveSynonymInSameGroup(){
                TaxonNameBase<?,?> taxonName = BotanicalName.NewInstance(null);
index 1d1856e922a1a80072582403fc854cf5a8b52547,ae3395f8a9b9264e528469b641e87af4f02e883f..5e4a43b04e629c6ca5cb25636a628372b9c3cbb9
@@@ -1410,7 -1767,129 +1410,6 @@@ public class TaxonDaoHibernateImpl exte
          return 0;
      }
  
 -    @Override
 -    public long deleteSynonymRelationships(Synonym synonym, Taxon taxon) {
 -
 -        String hql = "delete SynonymRelationship sr where sr.relatedFrom = :syn ";
 -        if (taxon != null){
 -            hql += " and sr.relatedTo = :taxon";
 -        }
 -        Session session = this.getSession();
 -        Query q = session.createQuery(hql);
 -
 -        q.setParameter("syn", synonym);
 -        if (taxon != null){
 -            q.setParameter("taxon", taxon);
 -        }
 -        long result = q.executeUpdate();
 -
 -        return result;
 -    }
 -
 -
 -    @Override
 -    public Integer countSynonymRelationships(TaxonBase taxonBase,
 -            SynonymRelationshipType type, Direction relatedfrom) {
 -        AuditEvent auditEvent = getAuditEventFromContext();
 -        if(auditEvent.equals(AuditEvent.CURRENT_VIEW)) {
 -            Query query = null;
 -
 -            if(type == null) {
 -                query = getSession().createQuery("select count(synonymRelationship) from SynonymRelationship synonymRelationship where synonymRelationship."+relatedfrom+" = :relatedSynonym");
 -            } else {
 -                query = getSession().createQuery("select count(synonymRelationship) from SynonymRelationship synonymRelationship where synonymRelationship."+relatedfrom+" = :relatedSynonym and synonymRelationship.type = :type");
 -                query.setParameter("type",type);
 -            }
 -            query.setParameter("relatedTaxon", taxonBase);
 -
 -            return ((Long)query.uniqueResult()).intValue();
 -        } else {
 -            AuditQuery query = getAuditReader().createQuery().forEntitiesAtRevision(TaxonRelationship.class,auditEvent.getRevisionNumber());
 -            query.add(AuditEntity.relatedId(relatedfrom.toString()).eq(taxonBase.getId()));
 -            query.addProjection(AuditEntity.id().count());
 -
 -            if(type != null) {
 -                query.add(AuditEntity.relatedId("type").eq(type.getId()));
 -            }
 -
 -            return ((Long)query.getSingleResult()).intValue();
 -        }
 -    }
 -
 -
 -    @Override
 -    public List<SynonymRelationship> getSynonymRelationships(TaxonBase taxonBase,
 -            SynonymRelationshipType type, Integer pageSize, Integer pageNumber,
 -            List<OrderHint> orderHints, List<String> propertyPaths,
 -            Direction direction) {
 -
 -        AuditEvent auditEvent = getAuditEventFromContext();
 -        if(auditEvent.equals(AuditEvent.CURRENT_VIEW)) {
 -            Criteria criteria = getSession().createCriteria(SynonymRelationship.class);
 -
 -            if (direction.equals(Direction.relatedTo)){
 -                criteria.add(Restrictions.eq("relatedTo", taxonBase));
 -            }else{
 -                criteria.add(Restrictions.eq("relatedFrom", taxonBase));
 -            }
 -            if(type != null) {
 -                criteria.add(Restrictions.eq("type", type));
 -            }
 -
 -            addOrder(criteria,orderHints);
 -
 -            if(pageSize != null) {
 -                criteria.setMaxResults(pageSize);
 -                if(pageNumber != null) {
 -                    criteria.setFirstResult(pageNumber * pageSize);
 -                } else {
 -                    criteria.setFirstResult(0);
 -                }
 -            }
 -
 -            List<SynonymRelationship> result = criteria.list();
 -            defaultBeanInitializer.initializeAll(result, propertyPaths);
 -
 -            return result;
 -        } else {
 -            AuditQuery query = getAuditReader().createQuery().forEntitiesAtRevision(TaxonRelationship.class,auditEvent.getRevisionNumber());
 -
 -            if (direction.equals(Direction.relatedTo)){
 -                query.add(AuditEntity.relatedId("relatedTo").eq(taxonBase.getId()));
 -            }else{
 -                query.add(AuditEntity.relatedId("relatedFrom").eq(taxonBase.getId()));
 -            }
 -
 -            if(type != null) {
 -                query.add(AuditEntity.relatedId("type").eq(type.getId()));
 -            }
 -
 -            if(pageSize != null) {
 -                query.setMaxResults(pageSize);
 -                if(pageNumber != null) {
 -                    query.setFirstResult(pageNumber * pageSize);
 -                } else {
 -                    query.setFirstResult(0);
 -                }
 -            }
 -
 -            List<SynonymRelationship> result = query.getResultList();
 -            defaultBeanInitializer.initializeAll(result, propertyPaths);
 -
 -            // Ugly, but for now, there is no way to sort on a related entity property in Envers,
 -            // and we can't live without this functionality in CATE as it screws up the whole
 -            // taxon tree thing
 -            if(orderHints != null && !orderHints.isEmpty()) {
 -                SortedSet<SynonymRelationship> sortedList = new TreeSet<SynonymRelationship>(new SynonymRelationshipFromTaxonComparator());
 -                sortedList.addAll(result);
 -                return new ArrayList<SynonymRelationship>(sortedList);
 -            }
 -
 -            return result;
 -        }
 -    }
 -
--
      private String[] createHQLString(boolean doTaxa, boolean doSynonyms, boolean doIncludeMisappliedNames, Classification classification,  Set<NamedArea> areasExpanded, MatchMode matchMode, String searchField){
  
             boolean doAreaRestriction = areasExpanded.size() > 0;
index c01f6013218c13cd86eca80e4f993c9ea3216b51,191688eca2d15526aa46912bff92716ebd9d3c05..1d441cc3af252bd64261510c837bfb076bbecbab
@@@ -848,15 -855,17 +853,16 @@@ public class NameCatalogueController ex
                              didname[1],
                              secTitle,
                              modified,
-                             taxon.getLsid().toString());
+                             lsidString
+                      );
  
  
 -                    Set<SynonymRelationship> synRelationships = taxon.getSynonymRelations();
 +                    Set<Synonym> syns = taxon.getSynonyms();
                      // add synonyms (if exists) to taxon information object
 -                    for (SynonymRelationship sr : synRelationships) {
 -                        Synonym syn = sr.getSynonym();
 +                    for (Synonym syn : syns) {
                          String uuid = syn.getUuid().toString();
                          String title = syn.getTitleCache();
 -                        TaxonNameBase synnvn = syn.getName();
 +                        TaxonNameBase<?,?> synnvn = syn.getName();
                          String name = synnvn.getTitleCache();
                          String rank = (synnvn.getRank() == null)? "" : synnvn.getRank().getTitleCache();
                          String status = SYNONYM_STATUS;
index 496e40c218444bf9a85f5416386b7c706b4117c7,38730070903b13d8d3ad7b0cada307abec7f7da3..1e9519babd56845d7dccf89160490e417d024d61
@@@ -846,6 -850,6 +847,9 @@@ public class ClassificationServiceImpl 
          if (parentNode != null){
              handleAncestorsForMarkersRecursive(result, markerTypes, parentNode);
          }
++        if (parentNode != null){
++            handleAncestorsForMarkersRecursive(result, markerTypes, parentNode);
++        }
      }
  
  }
index 024ee0f2f5f7c213d6549e239a743eaf3bc35a07,46e38b51be9cfeda62227ab0d1e8c10a22b042ef..c5aab8cba37b5f0735a260f43f04d799105e540e
@@@ -851,11 -856,42 +851,25 @@@ public interface ITaxonService extends 
       */
      public List<Synonym>  createAllInferredSynonyms(Taxon taxon, Classification tree, boolean doWithMisappliedNames);
  
 +    public Taxon findAcceptedTaxonFor(UUID synonymUuid, UUID classificationUuid, List<String> propertyPaths);
  
 +    public List<TaxonBase> findTaxaByName(MatchingTaxonConfigurator config);
  
  
 -     * Removes a synonym.<BR><BR>
 -     *
 -     * In detail it removes
 -     *  <li>all synonym relationship to the given taxon or to all taxa if taxon is <code>null</code></li>
 -     *  <li>the synonym concept if it is not referenced by any synonym relationship anymore</li>
 -     *  <BR><BR>
 -     *  If <code>config.removeNameIfPossible</code> is true
 -     *  it also removes the synonym name if it is not used in any other context
 -     *  (part of a concept, in DescriptionElementSource, part of a name relationship, used inline, ...)<BR><BR>
 -     *  If <code>config.newHomotypicGroupIfNeeded</code> is <code>true</code> and the synonym name is not deleted and
 -     *  the name is homotypic to the taxon the name is moved to a new homotypical group.<BR><BR>
 -     *
 -     *  If synonym is <code>null</code> the method has no effect.
 -     *
 -     * @param taxon
 -     * @param synonym
 -     * @param config
 -     * @return deleteResult
+     /**
 -    public DeleteResult deleteSynonym(Synonym synonym, Taxon taxon, SynonymDeletionConfigurator config);
 -
 -
 -
 -    public Pager<Taxon> pageAcceptedTaxaFor(UUID synonymUuid, UUID classificationUuid, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints,
 -            List<String> propertyPaths);
 -
 -    public List<Taxon> listAcceptedTaxaFor(UUID synonymUuid, UUID classificationUuid, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints,
 -            List<String> propertyPaths);
 -
 -    public List<TaxonBase> findTaxaByName(MatchingTaxonConfigurator config);
 -
 -
++     * @param clazz the optional {@link TaxonBase} subclass
++     * @param identifier the identifier string
++     * @param identifierType the identifier type
++     * @param subtreeFilter filter on a classification subtree (TaxonNode)
++     * @param matchmode the match mode for the identifier string
++     * @param includeEntity should the taxon as an object be included in the result
++     * @param pageSize page size
++     * @param pageNumber page number
++     * @param propertyPaths property path for initializing the returned taxon object (requires includeEntity=true)
++     * @return the resulting {@link IdentifiedEntityDTO} pager
++     * @see IIdentifiableEntityService#findByIdentifier(Class, String, DefinedTerm, MatchMode, boolean, Integer, Integer, List)
+      */
++    public <S extends TaxonBase> Pager<IdentifiedEntityDTO<S>> findByIdentifier(
      /**
       * @param clazz the optional {@link TaxonBase} subclass
       * @param identifier the identifier string
       * @param markerType the obligatory marker type, if not given, the results will always be empty
       * @param markerValue the optional
       * @param subtreeFilter filter on a classification subtree (TaxonNode)
 -
+      * @param includeEntity should the taxon as an object be included in the result
+      * @param pageSize page size
+      * @param pageNumber page number
+      * @param propertyPaths property path for initializing the returned taxon object (requires includeEntity=true)
+      * @return the resulting {@link MarkedEntityDTO} pager
+      * @see IIdentifiableEntityService#findByMarker(Class, MarkerType, Boolean, boolean, Integer, Integer, List)
+      */
+     public <S extends TaxonBase> Pager<MarkedEntityDTO<S>> findByMarker(
+             Class<S> clazz, MarkerType markerType, Boolean markerValue,
+             TaxonNode subtreeFilter, boolean includeEntity, Integer pageSize,
+             Integer pageNumber, List<String> propertyPaths);
 -     * @param synonymUuid
 -     * @param taxonUuid
 -     * @param config
 -     * @return
+     /**
++     * Returns a pager for {@link MarkedEntityDTO DTOs} that hold the marker including type, title and uuid
++     * and the according {@link TaxonBase} information (uuid, title and the taxon object itself (optional)).
++     *
++     * @param clazz The optional {@link TaxonBase} subclass
++     * @param markerType the obligatory marker type, if not given, the results will always be empty
++     * @param markerValue the optional
++     * @param subtreeFilter filter on a classification subtree (TaxonNode)
 +     * @param includeEntity should the taxon as an object be included in the result
 +     * @param pageSize page size
 +     * @param pageNumber page number
 +     * @param propertyPaths property path for initializing the returned taxon object (requires includeEntity=true)
 +     * @return the resulting {@link MarkedEntityDTO} pager
 +     * @see IIdentifiableEntityService#findByMarker(Class, MarkerType, Boolean, boolean, Integer, Integer, List)
       */
 -    public DeleteResult deleteSynonym(UUID synonymUuid, UUID taxonUuid, SynonymDeletionConfigurator config);
 +    public <S extends TaxonBase> Pager<MarkedEntityDTO<S>> findByMarker(
 +            Class<S> clazz, MarkerType markerType, Boolean markerValue,
 +            TaxonNode subtreeFilter, boolean includeEntity, Integer pageSize,
 +            Integer pageNumber, List<String> propertyPaths);
  
      /**
       * @param synonymUUid