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>
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);
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;
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;
if (parentNode != null){
handleAncestorsForMarkersRecursive(result, markerTypes, parentNode);
}
++ if (parentNode != null){
++ handleAncestorsForMarkersRecursive(result, markerTypes, parentNode);
++ }
}
}
*/
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