Revision b9b58fbb
Added by Andreas Kohlbecker about 9 years ago
.gitattributes | ||
---|---|---|
1499 | 1499 |
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/validation/IEntityConstraintViolationDao.java -text |
1500 | 1500 |
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/validation/IEntityValidationCrud.java -text |
1501 | 1501 |
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/validation/IEntityValidationDao.java -text |
1502 |
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dto/ITermRepresentation_L10n.java -text |
|
1503 |
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dto/TermDto.java -text |
|
1502 | 1504 |
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/fetch/CdmFetch.java -text |
1503 | 1505 |
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/hibernate/CacheStrategyGenerator.java -text |
1504 | 1506 |
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/hibernate/CdmDataChangeEvent.java -text |
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/description/IDescriptionDao.java | ||
---|---|---|
30 | 30 |
import eu.etaxonomy.cdm.persistence.dao.common.IIdentifiableDao; |
31 | 31 |
import eu.etaxonomy.cdm.persistence.dao.initializer.IBeanInitializer; |
32 | 32 |
import eu.etaxonomy.cdm.persistence.dao.media.IMediaDao; |
33 |
import eu.etaxonomy.cdm.persistence.dto.TermDto; |
|
33 | 34 |
import eu.etaxonomy.cdm.persistence.query.MatchMode; |
34 | 35 |
import eu.etaxonomy.cdm.persistence.query.OrderHint; |
35 | 36 |
|
... | ... | |
279 | 280 |
/** |
280 | 281 |
* Method to list all {@link NamedAreas} instances which are currently used |
281 | 282 |
* by {@link Distribution} elements. |
282 |
* |
|
283 |
* @param includeAllParents if set to true all parent areas will be included in the result set
|
|
283 | 284 |
* @param pageSize |
284 | 285 |
* @param pageNumber |
285 |
* @param propertyPaths
|
|
286 |
* |
|
286 | 287 |
* @return |
287 | 288 |
*/ |
288 |
List<NamedArea> listNamedAreasInUse(Integer pageSize, Integer pageNumber, List<String> propertyPaths);
|
|
289 |
List<TermDto> listNamedAreasInUse(boolean includeAllParents, Integer pageSize, Integer pageNumber);
|
|
289 | 290 |
} |
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/hibernate/description/DescriptionDaoImpl.java | ||
---|---|---|
12 | 12 |
import java.util.ArrayList; |
13 | 13 |
import java.util.HashSet; |
14 | 14 |
import java.util.List; |
15 |
import java.util.Map; |
|
15 | 16 |
import java.util.Set; |
16 | 17 |
import java.util.UUID; |
17 | 18 |
|
19 |
import org.apache.commons.lang.ArrayUtils; |
|
18 | 20 |
import org.apache.log4j.Logger; |
19 | 21 |
import org.hibernate.Criteria; |
20 | 22 |
import org.hibernate.Query; |
... | ... | |
29 | 31 |
import eu.etaxonomy.cdm.model.common.DefinedTerm; |
30 | 32 |
import eu.etaxonomy.cdm.model.common.LSID; |
31 | 33 |
import eu.etaxonomy.cdm.model.common.MarkerType; |
34 |
import eu.etaxonomy.cdm.model.common.Representation; |
|
32 | 35 |
import eu.etaxonomy.cdm.model.description.CommonTaxonName; |
33 | 36 |
import eu.etaxonomy.cdm.model.description.DescriptionBase; |
34 | 37 |
import eu.etaxonomy.cdm.model.description.DescriptionElementBase; |
... | ... | |
45 | 48 |
import eu.etaxonomy.cdm.persistence.dao.common.OperationNotSupportedInPriorViewException; |
46 | 49 |
import eu.etaxonomy.cdm.persistence.dao.description.IDescriptionDao; |
47 | 50 |
import eu.etaxonomy.cdm.persistence.dao.hibernate.common.IdentifiableDaoBase; |
51 |
import eu.etaxonomy.cdm.persistence.dto.TermDto; |
|
48 | 52 |
import eu.etaxonomy.cdm.persistence.query.MatchMode; |
49 | 53 |
import eu.etaxonomy.cdm.persistence.query.OrderHint; |
50 | 54 |
|
... | ... | |
864 | 868 |
/* (non-Javadoc) |
865 | 869 |
* @see eu.etaxonomy.cdm.persistence.dao.description.IDescriptionDao#listNamedAreasInUse(java.lang.Integer, java.lang.Integer, java.util.List) |
866 | 870 |
*/ |
871 |
@SuppressWarnings("unchecked") |
|
867 | 872 |
@Override |
868 |
public List<NamedArea> listNamedAreasInUse(Integer pageSize, Integer pageNumber, List<String> propertyPaths) { |
|
869 |
|
|
870 |
String queryString = "select distinct d.area from Distribution as d"; |
|
871 |
Query query = getSession().createQuery(queryString); |
|
873 |
public List<TermDto> listNamedAreasInUse(boolean includeAllParents, Integer pageSize, Integer pageNumber) { |
|
874 |
|
|
875 |
// Logger.getLogger("org.hibernate.SQL").setLevel(Level.TRACE); |
|
876 |
|
|
877 |
StringBuilder queryString = new StringBuilder( |
|
878 |
// TODO use "select new TermDto(distinct a.uuid, r , a.vocabulary.uuid) .... |
|
879 |
"SELECT DISTINCT a.id, a.partOf.id" |
|
880 |
+ " FROM Distribution AS d LEFT JOIN d.area AS a"); |
|
881 |
Query query = getSession().createQuery(queryString.toString()); |
|
882 |
|
|
883 |
List<Object[]> areasInUse = query.list(); |
|
884 |
Set<Object> allAreaIds = new HashSet<Object>(areasInUse.size()); |
|
885 |
|
|
886 |
if(includeAllParents) { |
|
887 |
// find all parent nodes |
|
888 |
String allAreasQueryStr = "select a.id, a.partOf.id from NamedArea as a"; |
|
889 |
query = getSession().createQuery(allAreasQueryStr); |
|
890 |
List<Object[]> allAreasResult = query.list(); |
|
891 |
Map<Object, Object> allAreasMap = ArrayUtils.toMap(allAreasResult.toArray()); |
|
892 |
|
|
893 |
Set<Object> parents = new HashSet<Object>(); |
|
894 |
|
|
895 |
for(Object[] leaf : areasInUse) { |
|
896 |
allAreaIds.add(leaf[0]); |
|
897 |
Object parentId = leaf[1]; |
|
898 |
while (parentId != null) { |
|
899 |
if(parents.contains(parentId)) { |
|
900 |
// break if the parent already is in the set |
|
901 |
break; |
|
902 |
} |
|
903 |
parents.add(parentId); |
|
904 |
parentId = allAreasMap.get(parentId); |
|
905 |
} |
|
906 |
} |
|
907 |
allAreaIds.addAll(parents); |
|
908 |
} else { |
|
909 |
// only add the ids found so far |
|
910 |
for(Object[] leaf : areasInUse) { |
|
911 |
allAreaIds.add(leaf[0]); |
|
912 |
} |
|
913 |
} |
|
872 | 914 |
|
915 |
String parentAreasQueryStr = "select a.uuid, r, p.uuid, v.uuid " |
|
916 |
+ "from NamedArea as a LEFT JOIN a.partOf as p LEFT JOIN a.representations AS r LEFT JOIN a.vocabulary as v " |
|
917 |
+ "where a.id in (:allAreaIds) order by a.id"; |
|
918 |
query = getSession().createQuery(parentAreasQueryStr); |
|
919 |
query.setParameterList("allAreaIds", allAreaIds); |
|
873 | 920 |
if(pageSize != null) { |
874 | 921 |
query.setMaxResults(pageSize); |
875 | 922 |
if(pageNumber != null) { |
876 | 923 |
query.setFirstResult(pageNumber * pageSize); |
877 | 924 |
} |
878 | 925 |
} |
926 |
List<Object[]> parentResults = query.list(); |
|
927 |
List<TermDto> dtoList = termDtoListFrom(parentResults); |
|
879 | 928 |
|
880 |
List<NamedArea> results = query.list(); |
|
881 | 929 |
|
882 |
defaultBeanInitializer.initializeAll(results, propertyPaths); |
|
930 |
return dtoList; |
|
931 |
} |
|
883 | 932 |
|
884 |
return results; |
|
933 |
/** |
|
934 |
* @param results |
|
935 |
* @return |
|
936 |
*/ |
|
937 |
private List<TermDto> termDtoListFrom(List<Object[]> results) { |
|
938 |
List<TermDto> dtoList = new ArrayList<TermDto>(results.size()); |
|
939 |
for (Object[] elements : results) { |
|
940 |
Set<Representation> representations; |
|
941 |
if(elements[1] instanceof Representation) { |
|
942 |
representations = new HashSet<Representation>(1); |
|
943 |
representations.add((Representation)elements[1]); |
|
944 |
} else { |
|
945 |
representations = (Set<Representation>)elements[1]; |
|
946 |
} |
|
947 |
|
|
948 |
dtoList.add(new TermDto((UUID)elements[0], representations, (UUID)elements[2], (UUID)elements[3])); |
|
949 |
} |
|
950 |
return dtoList; |
|
885 | 951 |
} |
886 | 952 |
|
887 | 953 |
|
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dto/ITermRepresentation_L10n.java | ||
---|---|---|
1 |
// $Id$ |
|
2 |
/** |
|
3 |
* Copyright (C) 2015 EDIT |
|
4 |
* European Distributed Institute of Taxonomy |
|
5 |
* http://www.e-taxonomy.eu |
|
6 |
* |
|
7 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
8 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
9 |
*/ |
|
10 |
package eu.etaxonomy.cdm.persistence.dto; |
|
11 |
|
|
12 |
import java.util.Set; |
|
13 |
|
|
14 |
import eu.etaxonomy.cdm.model.common.Representation; |
|
15 |
import eu.etaxonomy.cdm.model.common.TermBase; |
|
16 |
|
|
17 |
/** |
|
18 |
* @author andreas |
|
19 |
* @date Mar 25, 2015 |
|
20 |
* |
|
21 |
*/ |
|
22 |
public interface ITermRepresentation_L10n { |
|
23 |
|
|
24 |
/** |
|
25 |
* @return the label |
|
26 |
*/ |
|
27 |
public abstract String getLabel(); |
|
28 |
|
|
29 |
/** |
|
30 |
* @return the abbreviatedLabel |
|
31 |
*/ |
|
32 |
public abstract String getAbbreviatedLabel(); |
|
33 |
|
|
34 |
/** |
|
35 |
* Derives the localized representations from the given term and sets |
|
36 |
* the according fields of the TermRepresentation_L10n instance |
|
37 |
* |
|
38 |
* @param term |
|
39 |
* @param useInverseRepresentation |
|
40 |
*/ |
|
41 |
public abstract void localize(TermBase term, boolean useInverseRepresentation); |
|
42 |
|
|
43 |
/** |
|
44 |
* @param representations |
|
45 |
*/ |
|
46 |
void localize(Set<Representation> representations); |
|
47 |
|
|
48 |
} |
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dto/TermDto.java | ||
---|---|---|
1 |
// $Id$ |
|
2 |
/** |
|
3 |
* Copyright (C) 2015 EDIT |
|
4 |
* European Distributed Institute of Taxonomy |
|
5 |
* http://www.e-taxonomy.eu |
|
6 |
* |
|
7 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
8 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
9 |
*/ |
|
10 |
package eu.etaxonomy.cdm.persistence.dto; |
|
11 |
|
|
12 |
import java.util.Set; |
|
13 |
import java.util.UUID; |
|
14 |
|
|
15 |
import eu.etaxonomy.cdm.model.common.Representation; |
|
16 |
import eu.etaxonomy.cdm.model.location.NamedArea; |
|
17 |
|
|
18 |
/** |
|
19 |
* @author andreas |
|
20 |
* @date Mar 25, 2015 |
|
21 |
* |
|
22 |
*/ |
|
23 |
public class TermDto { |
|
24 |
|
|
25 |
|
|
26 |
private final UUID uuid; |
|
27 |
private UUID partOfUuid = null; |
|
28 |
private UUID vocabularyUuid = null; |
|
29 |
private final Set<Representation> representations; |
|
30 |
private String representation_L10n = null; |
|
31 |
private String representation_L10n_abbreviatedLabel = null; |
|
32 |
|
|
33 |
public TermDto(UUID uuid, Set<Representation> representations) { |
|
34 |
this.representations = representations; |
|
35 |
this.uuid = uuid; |
|
36 |
} |
|
37 |
|
|
38 |
public TermDto(UUID uuid, Set<Representation> representations, UUID partOfUuid, UUID vocabularyUuid) { |
|
39 |
this.representations = representations; |
|
40 |
this.uuid = uuid; |
|
41 |
this.partOfUuid = partOfUuid; |
|
42 |
this.vocabularyUuid = vocabularyUuid; |
|
43 |
} |
|
44 |
|
|
45 |
static public TermDto fromNamedArea(NamedArea namedArea) { |
|
46 |
TermDto dto = new TermDto(namedArea.getUuid(), namedArea.getRepresentations()); |
|
47 |
return dto; |
|
48 |
} |
|
49 |
|
|
50 |
/** |
|
51 |
* |
|
52 |
* @param representation_L10n a blank instance of ITermRepresentation_L10n |
|
53 |
* created by the default constructor |
|
54 |
*/ |
|
55 |
public void localize(ITermRepresentation_L10n representation_L10n) { |
|
56 |
|
|
57 |
representation_L10n.localize(representations); |
|
58 |
if (representation_L10n.getLabel() != null) { |
|
59 |
setRepresentation_L10n(representation_L10n.getLabel()); |
|
60 |
} |
|
61 |
if (representation_L10n.getAbbreviatedLabel() != null) { |
|
62 |
setRepresentation_L10n_abbreviatedLabel(representation_L10n.getAbbreviatedLabel()); |
|
63 |
} |
|
64 |
} |
|
65 |
|
|
66 |
/** |
|
67 |
* @return the uuid |
|
68 |
*/ |
|
69 |
public UUID getUuid() { |
|
70 |
return uuid; |
|
71 |
} |
|
72 |
|
|
73 |
/** |
|
74 |
* @return the representation_L10n |
|
75 |
*/ |
|
76 |
public String getRepresentation_L10n() { |
|
77 |
return representation_L10n; |
|
78 |
} |
|
79 |
|
|
80 |
/** |
|
81 |
* @param representation_L10n the representation_L10n to set |
|
82 |
*/ |
|
83 |
public void setRepresentation_L10n(String representation_L10n) { |
|
84 |
this.representation_L10n = representation_L10n; |
|
85 |
} |
|
86 |
|
|
87 |
/** |
|
88 |
* @param representation_L10n_abbreviatedLabel the representation_L10n_abbreviatedLabel to set |
|
89 |
*/ |
|
90 |
public void setRepresentation_L10n_abbreviatedLabel(String representation_L10n_abbreviatedLabel) { |
|
91 |
this.representation_L10n_abbreviatedLabel = representation_L10n_abbreviatedLabel; |
|
92 |
} |
|
93 |
|
|
94 |
/** |
|
95 |
* @return the representation_L10n_abbreviatedLabel |
|
96 |
*/ |
|
97 |
public String getRepresentation_L10n_abbreviatedLabel() { |
|
98 |
return representation_L10n_abbreviatedLabel; |
|
99 |
} |
|
100 |
|
|
101 |
/** |
|
102 |
* @return the vocabularyUuid |
|
103 |
*/ |
|
104 |
public UUID getVocabularyUuid() { |
|
105 |
return vocabularyUuid; |
|
106 |
} |
|
107 |
|
|
108 |
/** |
|
109 |
* @param vocabularyUuid the vocabularyUuid to set |
|
110 |
*/ |
|
111 |
public void setVocabularyUuid(UUID vocabularyUuid) { |
|
112 |
this.vocabularyUuid = vocabularyUuid; |
|
113 |
} |
|
114 |
|
|
115 |
/** |
|
116 |
* @return the partOfUuid |
|
117 |
*/ |
|
118 |
public UUID getPartOfUuid() { |
|
119 |
return partOfUuid; |
|
120 |
} |
|
121 |
|
|
122 |
} |
cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/persistence/dao/hibernate/description/DescriptionDaoHibernateImplTest.java | ||
---|---|---|
48 | 48 |
import eu.etaxonomy.cdm.persistence.dao.common.IDefinedTermDao; |
49 | 49 |
import eu.etaxonomy.cdm.persistence.dao.description.IDescriptionDao; |
50 | 50 |
import eu.etaxonomy.cdm.persistence.dao.taxon.ITaxonDao; |
51 |
import eu.etaxonomy.cdm.persistence.dto.TermDto; |
|
51 | 52 |
import eu.etaxonomy.cdm.persistence.query.OrderHint; |
52 | 53 |
import eu.etaxonomy.cdm.persistence.query.OrderHint.SortOrder; |
53 | 54 |
import eu.etaxonomy.cdm.test.integration.CdmTransactionalIntegrationTest; |
... | ... | |
615 | 616 |
@Test |
616 | 617 |
@DataSet |
617 | 618 |
public void testListNamedAreasInUse(){ |
618 |
List<NamedArea> list = descriptionDao.listNamedAreasInUse(null, null, null); |
|
619 |
|
|
620 |
List<TermDto> list = null; |
|
621 |
|
|
622 |
list = descriptionDao.listNamedAreasInUse(false, null, null); |
|
623 |
Assert.assertEquals(3, list.size()); |
|
624 |
|
|
625 |
} |
|
626 |
|
|
627 |
@Test |
|
628 |
@DataSet |
|
629 |
// @Ignore // the first query in listNamedAreasInUse is for some reason not working with h2 |
|
630 |
public void testListNamedAreasInUseWithParents(){ |
|
631 |
|
|
632 |
List<TermDto> list = null; |
|
633 |
|
|
634 |
list = descriptionDao.listNamedAreasInUse(true, null, null); |
|
619 | 635 |
Assert.assertEquals(3, list.size()); |
636 |
|
|
620 | 637 |
} |
621 | 638 |
|
622 | 639 |
|
... | ... | |
626 | 643 |
@Override |
627 | 644 |
public void createTestDataSet() throws FileNotFoundException { |
628 | 645 |
// TODO Auto-generated method stub |
629 |
|
|
646 |
|
|
630 | 647 |
} |
631 | 648 |
|
632 | 649 |
|
cdmlib-persistence/src/test/resources/log4j.properties | ||
---|---|---|
70 | 70 |
#log4j.logger.org.hibernate.hql.ast.AST=debug |
71 | 71 |
|
72 | 72 |
### log just the SQL |
73 |
# to log more context specific use this snipped in the code: |
|
74 |
# Logger.getLogger("org.hibernate.SQL").setLevel(Level.TRACE); |
|
73 | 75 |
#log4j.logger.org.hibernate.SQL=TRACE |
74 | 76 |
|
77 |
### log just hibernate processing queries |
|
78 |
#log4j.logger.org.hibernate.engine.query = TRACE |
|
79 |
|
|
75 | 80 |
### log JDBC bind parameters ### |
76 | 81 |
#log4j.logger.org.hibernate.type=TRACE |
77 | 82 |
|
cdmlib-remote-webapp/ide/eclipse/Jetty Launcher/cdmlib-remote-webapp - run.launch | ||
---|---|---|
45 | 45 |
<intAttribute key="net.sourceforge.eclipsejetty.launcher.threadPool.limit.count" value="16"/> |
46 | 46 |
<booleanAttribute key="net.sourceforge.eclipsejetty.launcher.threadPool.limit.enabled" value="false"/> |
47 | 47 |
<stringAttribute key="net.sourceforge.eclipsejetty.launcher.webappdir" value="src/main/webapp"/> |
48 |
<stringAttribute key="org.eclipse.debug.core.source_locator_id" value="org.eclipse.jdt.launching.sourceLocator.JavaSourceLookupDirector"/> |
|
49 |
<stringAttribute key="org.eclipse.debug.core.source_locator_memento" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <sourceLookupDirector> <sourceContainers duplicates="false"> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;folder nest=&quot;true&quot; path=&quot;/cdmlib-model/src&quot;/&gt;&#10;" typeId="org.eclipse.debug.core.containerType.folder"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;folder nest=&quot;true&quot; path=&quot;/cdmlib-remote/src&quot;/&gt;&#10;" typeId="org.eclipse.debug.core.containerType.folder"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;folder nest=&quot;true&quot; path=&quot;/cdmlib-persistence/src/main/java&quot;/&gt;&#10;" typeId="org.eclipse.debug.core.containerType.folder"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;folder nest=&quot;true&quot; path=&quot;/cdmlib-remote-webapp/src/main/java&quot;/&gt;&#10;" typeId="org.eclipse.debug.core.containerType.folder"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;default/&gt;&#10;" typeId="org.eclipse.debug.core.containerType.default"/> </sourceContainers> </sourceLookupDirector> "/> |
|
48 | 50 |
<listAttribute key="org.eclipse.debug.ui.favoriteGroups"> |
49 | 51 |
<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/> |
50 | 52 |
<listEntry value="org.eclipse.debug.ui.launchGroup.run"/> |
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/AbstractListController.java | ||
---|---|---|
10 | 10 |
package eu.etaxonomy.cdm.remote.controller; |
11 | 11 |
|
12 | 12 |
import eu.etaxonomy.cdm.api.service.IService; |
13 |
import eu.etaxonomy.cdm.api.service.pager.Pager; |
|
13 | 14 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
15 |
import eu.etaxonomy.cdm.persistence.dto.TermDto; |
|
16 |
import eu.etaxonomy.cdm.remote.l10n.TermRepresentation_L10n; |
|
14 | 17 |
|
15 | 18 |
/** |
16 | 19 |
* @author a.kohlbecker |
... | ... | |
21 | 24 |
*/ |
22 | 25 |
public abstract class AbstractListController<T extends CdmBase, SERVICE extends IService<T>> extends AbstractController<T, SERVICE> { |
23 | 26 |
|
27 |
/** |
|
28 |
* @param pager |
|
29 |
*/ |
|
30 |
protected void localizeTerms(Pager<TermDto> pager) { |
|
31 |
for(TermDto termDto: pager.getRecords()){ |
|
32 |
termDto.localize(new TermRepresentation_L10n()); |
|
33 |
} |
|
34 |
|
|
35 |
} |
|
36 |
|
|
24 | 37 |
|
25 | 38 |
} |
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/DescriptionListController.java | ||
---|---|---|
42 | 42 |
import eu.etaxonomy.cdm.model.location.NamedAreaType; |
43 | 43 |
import eu.etaxonomy.cdm.model.name.Rank; |
44 | 44 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
45 |
import eu.etaxonomy.cdm.persistence.dto.TermDto; |
|
45 | 46 |
import eu.etaxonomy.cdm.persistence.query.MatchMode; |
46 | 47 |
import eu.etaxonomy.cdm.persistence.query.OrderHint; |
47 | 48 |
import eu.etaxonomy.cdm.remote.controller.util.PagerParameters; |
... | ... | |
279 | 280 |
} |
280 | 281 |
|
281 | 282 |
@RequestMapping(value = "namedAreasInUse", method = RequestMethod.GET) |
282 |
public Pager<NamedArea> doPageNamedAreasInUse( |
|
283 |
public Pager<TermDto> doPageNamedAreasInUse( |
|
284 |
@RequestParam(value = "includeAllParents", required = false) boolean includeAllParents, |
|
283 | 285 |
@RequestParam(value = "pageSize", required = false) Integer pageSize, |
284 | 286 |
@RequestParam(value = "pageNumber", required = false) Integer pageNumber, HttpServletRequest request, |
285 | 287 |
HttpServletResponse response) throws IOException { |
... | ... | |
289 | 291 |
PagerParameters pagerParams = new PagerParameters(pageSize, pageNumber); |
290 | 292 |
pagerParams.normalizeAndValidate(response); |
291 | 293 |
|
292 |
Pager<NamedArea> pager = service.pageNamedAreasInUse(pageSize, pageNumber, getInitializationStrategy()); |
|
294 |
Pager<TermDto> pager = service.pageNamedAreasInUse(includeAllParents, pageSize, pageNumber); |
|
295 |
|
|
296 |
localizeTerms(pager); |
|
293 | 297 |
|
294 | 298 |
return pager; |
295 | 299 |
} |
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/json/processor/bean/TermBaseBeanProcessor.java | ||
---|---|---|
23 | 23 |
import eu.etaxonomy.cdm.model.common.RelationshipTermBase; |
24 | 24 |
import eu.etaxonomy.cdm.model.common.TermBase; |
25 | 25 |
import eu.etaxonomy.cdm.model.common.TermVocabulary; |
26 |
import eu.etaxonomy.cdm.persistence.dto.ITermRepresentation_L10n; |
|
26 | 27 |
import eu.etaxonomy.cdm.remote.l10n.TermRepresentation_L10n; |
27 | 28 |
|
28 | 29 |
/** |
... | ... | |
76 | 77 |
} |
77 | 78 |
} |
78 | 79 |
|
79 |
TermRepresentation_L10n representation_L10n = new TermRepresentation_L10n(term, false); |
|
80 |
ITermRepresentation_L10n representation_L10n = new TermRepresentation_L10n(term, false);
|
|
80 | 81 |
if (representation_L10n.getLabel() != null) { |
81 | 82 |
json.element("representation_L10n",representation_L10n.getLabel()); |
82 | 83 |
} |
... | ... | |
90 | 91 |
// add additional representation for RelationShipBase |
91 | 92 |
if(RelationshipTermBase.class.isAssignableFrom(term.getClass())){ |
92 | 93 |
RelationshipTermBase<?> relTerm = (RelationshipTermBase<?>)term; |
93 |
TermRepresentation_L10n inverseRepresentation_L10n = new TermRepresentation_L10n(relTerm, true); |
|
94 |
ITermRepresentation_L10n inverseRepresentation_L10n = new TermRepresentation_L10n(relTerm, true);
|
|
94 | 95 |
if (inverseRepresentation_L10n.getLabel() != null) { |
95 | 96 |
json.element("inverseRepresentation_L10n", inverseRepresentation_L10n.getLabel()); |
96 | 97 |
} |
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/l10n/TermRepresentation_L10n.java | ||
---|---|---|
10 | 10 |
package eu.etaxonomy.cdm.remote.l10n; |
11 | 11 |
|
12 | 12 |
import java.util.List; |
13 |
import java.util.Set; |
|
13 | 14 |
|
14 | 15 |
import org.apache.log4j.Logger; |
15 | 16 |
import org.hibernate.Hibernate; |
16 | 17 |
|
18 |
import eu.etaxonomy.cdm.model.common.DefinedTerm; |
|
17 | 19 |
import eu.etaxonomy.cdm.model.common.Language; |
18 | 20 |
import eu.etaxonomy.cdm.model.common.RelationshipTermBase; |
19 | 21 |
import eu.etaxonomy.cdm.model.common.Representation; |
20 | 22 |
import eu.etaxonomy.cdm.model.common.TermBase; |
23 |
import eu.etaxonomy.cdm.model.common.TermType; |
|
24 |
import eu.etaxonomy.cdm.persistence.dto.ITermRepresentation_L10n; |
|
21 | 25 |
|
22 | 26 |
/** |
23 | 27 |
* @author l.morris & a.kohlbecker |
24 | 28 |
* @date Feb 22, 2013 |
25 | 29 |
* |
26 | 30 |
*/ |
27 |
public class TermRepresentation_L10n { |
|
31 |
public class TermRepresentation_L10n implements ITermRepresentation_L10n {
|
|
28 | 32 |
|
29 | 33 |
public static final Logger logger = Logger.getLogger(TermRepresentation_L10n.class); |
30 | 34 |
|
31 | 35 |
String label = null; |
32 | 36 |
String abbreviatedLabel = null; |
33 | 37 |
|
34 |
/** |
|
35 |
* @return the label |
|
36 |
*/ |
|
37 |
public String getLabel() { |
|
38 |
return label; |
|
39 |
} |
|
38 |
public TermRepresentation_L10n() { |
|
40 | 39 |
|
41 |
/** |
|
42 |
* @param label the label to set |
|
43 |
*/ |
|
44 |
public void setLabel(String label) { |
|
45 |
this.label = label; |
|
46 | 40 |
} |
47 | 41 |
|
48 |
/** |
|
49 |
* @return the abbreviatedLabel |
|
50 |
*/ |
|
51 |
public String getAbbreviatedLabel() { |
|
52 |
return abbreviatedLabel; |
|
53 |
} |
|
42 |
public TermRepresentation_L10n(TermBase term, boolean useInverseRepresentation) { |
|
54 | 43 |
|
55 |
/** |
|
56 |
* @param abbreviatedLabel the abbreviatedLabel to set |
|
57 |
*/ |
|
58 |
public void setAbbreviatedLabel(String abbreviatedLabel) { |
|
59 |
this.abbreviatedLabel = abbreviatedLabel; |
|
44 |
localize(term, useInverseRepresentation); |
|
60 | 45 |
} |
61 | 46 |
|
62 |
public TermRepresentation_L10n(TermBase term, boolean useInverseRepresentation) { |
|
47 |
/* (non-Javadoc) |
|
48 |
* @see eu.etaxonomy.cdm.remote.l10n.ITermRepresentation_L10n#localize(eu.etaxonomy.cdm.model.common.TermBase, boolean) |
|
49 |
*/ |
|
50 |
@Override |
|
51 |
public void localize(TermBase term, boolean useInverseRepresentation) { |
|
63 | 52 |
|
64 | 53 |
List<Language> languages = LocaleContext.getLanguages(); |
65 | 54 |
|
... | ... | |
80 | 69 |
logger.debug("representations of term not initialized " + term.getUuid().toString()); |
81 | 70 |
} |
82 | 71 |
} |
72 |
} |
|
83 | 73 |
|
74 |
@Override |
|
75 |
public void localize(Set<Representation> representations) { |
|
76 |
DefinedTerm tmpTerm = DefinedTerm.NewInstance(TermType.Unknown, null, null, null); |
|
77 |
tmpTerm.getRepresentations().clear(); // removes the null representation added throught the constructor |
|
78 |
tmpTerm.getRepresentations().addAll(representations); |
|
79 |
List<Language> languages = LocaleContext.getLanguages(); |
|
80 |
Representation representation = tmpTerm.getPreferredRepresentation(languages); |
|
81 |
setRepresentations(representation); |
|
84 | 82 |
} |
85 | 83 |
|
86 | 84 |
/** |
... | ... | |
100 | 98 |
} |
101 | 99 |
} |
102 | 100 |
|
101 |
/* (non-Javadoc) |
|
102 |
* @see eu.etaxonomy.cdm.remote.l10n.ITermRepresentation_L10n#getLabel() |
|
103 |
*/ |
|
104 |
@Override |
|
105 |
public String getLabel() { |
|
106 |
return label; |
|
107 |
} |
|
108 |
|
|
109 |
/** |
|
110 |
* @param label the label to set |
|
111 |
*/ |
|
112 |
public void setLabel(String label) { |
|
113 |
this.label = label; |
|
114 |
} |
|
115 |
|
|
116 |
/* (non-Javadoc) |
|
117 |
* @see eu.etaxonomy.cdm.remote.l10n.ITermRepresentation_L10n#getAbbreviatedLabel() |
|
118 |
*/ |
|
119 |
@Override |
|
120 |
public String getAbbreviatedLabel() { |
|
121 |
return abbreviatedLabel; |
|
122 |
} |
|
123 |
|
|
124 |
/** |
|
125 |
* @param abbreviatedLabel the abbreviatedLabel to set |
|
126 |
*/ |
|
127 |
public void setAbbreviatedLabel(String abbreviatedLabel) { |
|
128 |
this.abbreviatedLabel = abbreviatedLabel; |
|
129 |
} |
|
130 |
|
|
131 |
|
|
132 |
|
|
103 | 133 |
} |
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/DescriptionServiceImpl.java | ||
---|---|---|
57 | 57 |
import eu.etaxonomy.cdm.persistence.dao.description.IFeatureNodeDao; |
58 | 58 |
import eu.etaxonomy.cdm.persistence.dao.description.IFeatureTreeDao; |
59 | 59 |
import eu.etaxonomy.cdm.persistence.dao.description.IStatisticalMeasurementValueDao; |
60 |
import eu.etaxonomy.cdm.persistence.dto.TermDto; |
|
60 | 61 |
import eu.etaxonomy.cdm.persistence.query.OrderHint; |
61 | 62 |
import eu.etaxonomy.cdm.strategy.cache.common.IIdentifiableEntityCacheStrategy; |
62 | 63 |
|
... | ... | |
459 | 460 |
Taxon tax = taxDescription.getTaxon(); |
460 | 461 |
tax.removeDescription(taxDescription, true); |
461 | 462 |
} |
462 |
|
|
463 |
|
|
463 | 464 |
return dao.delete(description); |
464 | 465 |
} |
465 | 466 |
@Override |
... | ... | |
656 | 657 |
} |
657 | 658 |
|
658 | 659 |
@Override |
659 |
public Pager<NamedArea> pageNamedAreasInUse(Integer pageSize,
|
|
660 |
Integer pageNumber, List<String> propertyPaths){
|
|
660 |
public Pager<TermDto> pageNamedAreasInUse(boolean includeAllParents, Integer pageSize,
|
|
661 |
Integer pageNumber){ |
|
661 | 662 |
|
662 |
List<NamedArea> results = dao.listNamedAreasInUse(pageSize, pageNumber, propertyPaths);
|
|
663 |
return new DefaultPagerImpl<NamedArea>(pageNumber, results.size(), pageSize, results);
|
|
663 |
List<TermDto> results = dao.listNamedAreasInUse(includeAllParents, pageSize, pageNumber);
|
|
664 |
return new DefaultPagerImpl<TermDto>(pageNumber, results.size(), pageSize, results);
|
|
664 | 665 |
} |
665 | 666 |
|
666 | 667 |
} |
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/IDescriptionService.java | ||
---|---|---|
38 | 38 |
import eu.etaxonomy.cdm.model.name.TaxonNameBase; |
39 | 39 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
40 | 40 |
import eu.etaxonomy.cdm.persistence.dao.initializer.IBeanInitializer; |
41 |
import eu.etaxonomy.cdm.persistence.dto.TermDto; |
|
41 | 42 |
import eu.etaxonomy.cdm.persistence.query.OrderHint; |
42 | 43 |
|
43 | 44 |
public interface IDescriptionService extends IIdentifiableEntityService<DescriptionBase> { |
... | ... | |
556 | 557 |
* @return a Pager for all NamedAreas instances which are currently in use. |
557 | 558 |
* |
558 | 559 |
*/ |
559 |
public Pager<NamedArea> pageNamedAreasInUse(Integer pageSize,
|
|
560 |
Integer pageNumber, List<String> propertyPaths);
|
|
560 |
public Pager<TermDto> pageNamedAreasInUse(boolean includeAllParents, Integer pageSize,
|
|
561 |
Integer pageNumber); |
|
561 | 562 |
|
562 | 563 |
UUID deleteDescription(DescriptionBase description); |
563 | 564 |
|
Also available in: Unified diff
implementing better namedAreasInUse service for #3994 (Select widget to choose the filter areas for the advanced search)