private boolean useTreeDto = true;
+ private boolean includeUnpublished = false;
+
//********************* GETTER / SETTER ***************************/
public boolean isPreferSubareas() {
public void setStatusTree(UUID statusTree) {
this.statusTree = statusTree;
}
+
+ public boolean isIncludeUnpublished() {
+ return includeUnpublished;
+ }
+ public void setIncludeUnpublished(boolean includeUnpublished) {
+ this.includeUnpublished = includeUnpublished;
+ }
}
\ No newline at end of file
Set<TaxonDescription> taxonSet = secondTaxon.getTaxon().getDescriptions();
assertTrue("Description is not Empty", !taxonSet.isEmpty());
- assertEquals("Number of Distributions should be 7", 7, descriptionService.listDescriptionElements(null, null, Distribution.class, null, null, null).size());
+ assertEquals("Number of Distributions should be 7", 7, descriptionService.listDescriptionElements(null, null, Distribution.class, false, null, null, null).size());
// assertEquals("Number of Vernecular Names should be 7", 6, descriptionService.listDescriptionElements(null, null, CommonTaxonName.class, null, null, null).size());
- List<CommonTaxonName> list = descriptionService.listDescriptionElements(null, null, CommonTaxonName.class, null, null, null);
+ List<CommonTaxonName> list = descriptionService.listDescriptionElements(null, null, CommonTaxonName.class, false, null, null, null);
for(DescriptionElementBase db : list){
System.out.println(db.toString());
}
* @return the list of matching DescriptionElementBase instances
*/
<T extends DescriptionElementBase> List<T> getDescriptionElementForTaxon(UUID taxonUuid,
- Set<Feature> features,
- Class<T> type, Integer pageSize,
- Integer pageNumber, List<String> propertyPaths);
+ Set<Feature> features, Class<T> type, boolean includeUnpublished,
+ Integer pageSize, Integer pageNumber, List<String> propertyPaths);
/**
* Return a list of ids of the specimens attached to a taxon via IndividualsAssociations
- * @param taxonUuid
- * @param features
- * @param pageSize
- * @param pageNumber
- * @param propertyPaths
- * @return
*/
public List<Integer> getIndividualAssociationSpecimenIDs(UUID taxonUuid,
- Set<Feature> features, Integer pageSize,
- Integer pageNumber, List<String> propertyPaths);
+ Set<Feature> features, boolean includeUnpublished,
+ Integer pageSize, Integer pageNumber, List<String> propertyPaths);
/**
* @param taxon
* @return the count of matching TaxonDescription instances
*/
<T extends DescriptionElementBase> long countDescriptionElementForTaxon(UUID taxonUuid,
- Set<Feature> features, Class<T> type);
+ Set<Feature> features, Class<T> type, boolean includeUnpublished);
/**
* Method to list all {@link NamedAreas} instances which are currently used
@Override
public List<Integer> getIndividualAssociationSpecimenIDs(UUID taxonUuid,
- Set<Feature> features, Integer pageSize,
- Integer pageNumber, List<String> propertyPaths){
- Query<Integer> query = prepareGetDescriptionElementForTaxon(taxonUuid, features, IndividualsAssociation.class, pageSize, pageNumber, "de.associatedSpecimenOrObservation.id");
+ Set<Feature> features, boolean includeUnpublished,
+ Integer pageSize, Integer pageNumber, List<String> propertyPaths){
+ Query<Integer> query = prepareGetDescriptionElementForTaxon(taxonUuid, features,
+ IndividualsAssociation.class, includeUnpublished, pageSize, pageNumber, "de.associatedSpecimenOrObservation.id");
List<Integer> results = query.list();
return results;
}
@Override
public <T extends DescriptionElementBase> List<T> getDescriptionElementForTaxon(
UUID taxonUuid, Set<Feature> features,
- Class<T> type, Integer pageSize,
- Integer pageNumber, List<String> propertyPaths) {
+ Class<T> type, boolean includeUnpublished,
+ Integer pageSize, Integer pageNumber, List<String> propertyPaths) {
// LogUtils.setLevel("org.hibernate.SQL", Level.TRACE);
- Query<T> query = prepareGetDescriptionElementForTaxon(taxonUuid, features, type, pageSize, pageNumber, "de");
+ Query<T> query = prepareGetDescriptionElementForTaxon(taxonUuid, features, type, includeUnpublished,
+ pageSize, pageNumber, "de");
if (logger.isDebugEnabled()){logger.debug(" dao: get list ...");}
List<T> results = query.list();
@Override
public <T extends DescriptionElementBase> long countDescriptionElementForTaxon(
- UUID taxonUuid, Set<Feature> features, Class<T> type) {
+ UUID taxonUuid, Set<Feature> features, Class<T> type, boolean includeUnpublished) {
- Query<Long> query = prepareGetDescriptionElementForTaxon(taxonUuid, features, type, null, null, "count(de)");
+ Query<Long> query = prepareGetDescriptionElementForTaxon(taxonUuid, features, type, includeUnpublished, null, null, "count(de)");
return query.uniqueResult();
}
private <T extends DescriptionElementBase, R extends Object> Query<R> prepareGetDescriptionElementForTaxon(UUID taxonUuid,
- Set<Feature> features, Class<T> type, Integer pageSize, Integer pageNumber, String selectString) {
+ Set<Feature> features, Class<T> type, boolean includeUnpublished, Integer pageSize, Integer pageNumber, String selectString) {
String queryString = "SELECT " + selectString + " 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 ";
+ " WHERE d.class = 'TaxonDescription' AND t.uuid = :taxon_uuid " +
+ (includeUnpublished? "" : " AND de.publish = :publish "); ;
if(type != null){
queryString += " and de.class = :type";
if(type != null){
query.setParameter("type", type.getSimpleName());
}
+ if (!includeUnpublished){
+ query.setParameter("publish", true);
+ }
if(hasFeatureFilter){
query.setParameterList("features", features) ;
}
@Override
public <T extends SpecimenOrObservationBase> List<UuidAndTitleCache<SpecimenOrObservationBase>> findOccurrencesUuidAndTitleCache(
Class<T> clazz, String queryString, String significantIdentifier, SpecimenOrObservationType recordBasis,
- Taxon associatedTaxon, TaxonName associatedTaxonName, MatchMode matchmode, Integer limit, Integer start,
- List<OrderHint> orderHints) {
+ Taxon associatedTaxon, TaxonName associatedTaxonName, MatchMode matchmode, boolean includeUnpublished,
+ Integer limit, Integer start, List<OrderHint> orderHints) {
+
Criteria criteria = createFindOccurrenceCriteria(clazz, queryString, significantIdentifier, recordBasis,
- associatedTaxon, associatedTaxonName, matchmode, limit, start, orderHints, null);
+ associatedTaxon, associatedTaxonName, matchmode, includeUnpublished, limit, start, orderHints, null);
if(criteria!=null){
ProjectionList projectionList = Projections.projectionList();
projectionList.add(Projections.property("uuid"));
@Override
public <T extends SpecimenOrObservationBase> List<T> findOccurrences(Class<T> clazz, String queryString,
String significantIdentifier, SpecimenOrObservationType recordBasis, Taxon associatedTaxon, TaxonName associatedTaxonName,
- MatchMode matchmode, Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths) {
+ MatchMode matchmode, boolean includeUnpublished,
+ Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths) {
Criteria criteria = createFindOccurrenceCriteria(clazz, queryString, significantIdentifier, recordBasis,
- associatedTaxon, associatedTaxonName, matchmode, limit, start, orderHints, propertyPaths);
+ associatedTaxon, associatedTaxonName, matchmode, includeUnpublished, limit, start, orderHints, propertyPaths);
if(criteria!=null){
@SuppressWarnings("unchecked")
List<T> results = criteria.list();
private <T extends SpecimenOrObservationBase> Criteria createFindOccurrenceCriteria(Class<T> clazz, String queryString,
String significantIdentifier, SpecimenOrObservationType recordBasis, Taxon associatedTaxon,
- TaxonName associatedTaxonName, MatchMode matchmode, Integer limit,
- Integer start, List<OrderHint> orderHints, List<String> propertyPaths) {
+ TaxonName associatedTaxonName, MatchMode matchmode, boolean includeUnpublished,
+ Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths) {
+
Criteria criteria = null;
if(clazz == null) {
Set<UUID> associationUuids = new HashSet<>();
//taxon associations
if(associatedTaxon!=null){
- List<UuidAndTitleCache<SpecimenOrObservationBase>> associatedTaxaList = listUuidAndTitleCacheByAssociatedTaxon(clazz, associatedTaxon, limit, start, orderHints);
+ List<UuidAndTitleCache<SpecimenOrObservationBase>> associatedTaxaList = listUuidAndTitleCacheByAssociatedTaxon(
+ clazz, associatedTaxon, includeUnpublished, limit, start, orderHints);
if(associatedTaxaList!=null){
for (UuidAndTitleCache<SpecimenOrObservationBase> uuidAndTitleCache : associatedTaxaList) {
associationUuids.add(uuidAndTitleCache.getUuid());
@Override
public <T extends SpecimenOrObservationBase> long countOccurrences(Class<T> clazz, String queryString,
String significantIdentifier, SpecimenOrObservationType recordBasis, Taxon associatedTaxon, TaxonName associatedTaxonName,
- MatchMode matchmode, Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths) {
+ MatchMode matchmode, boolean includeUnpublished, Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths) {
Criteria criteria = createFindOccurrenceCriteria(clazz, queryString, significantIdentifier, recordBasis,
- associatedTaxon, associatedTaxonName, matchmode, limit, start, orderHints, propertyPaths);
+ associatedTaxon, associatedTaxonName, matchmode, includeUnpublished, limit, start, orderHints, propertyPaths);
if(criteria!=null){
criteria.setProjection(Projections.rowCount());
}
@Override
- public <T extends SpecimenOrObservationBase> List<UuidAndTitleCache<SpecimenOrObservationBase>> listUuidAndTitleCacheByAssociatedTaxon(Class<T> clazz, Taxon associatedTaxon,
+ public <T extends SpecimenOrObservationBase> List<UuidAndTitleCache<SpecimenOrObservationBase>> listUuidAndTitleCacheByAssociatedTaxon(
+ Class<T> clazz, Taxon associatedTaxon, boolean includeUnpublished,
Integer limit, Integer start, List<OrderHint> orderHints){
- Query<Object[]> query = createSpecimenQuery("sob.uuid, sob.id, sob.titleCache", clazz, associatedTaxon, limit, start, orderHints, Object[].class);
+
+ Query<Object[]> query = createSpecimenQuery("sob.uuid, sob.id, sob.titleCache", clazz, associatedTaxon, includeUnpublished, limit, start, orderHints, Object[].class);
if(query==null){
return Collections.emptyList();
}
@Override
public <T extends SpecimenOrObservationBase> List<T> listByAssociatedTaxon(Class<T> clazz,
- Taxon associatedTaxon, Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths) {
+ Taxon associatedTaxon, boolean includeUnpublished, Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths) {
@SuppressWarnings("rawtypes")
- Query<SpecimenOrObservationBase> query = createSpecimenQuery("sob", clazz, associatedTaxon, limit, start, orderHints, SpecimenOrObservationBase.class);
+ Query<SpecimenOrObservationBase> query = createSpecimenQuery(
+ "sob", clazz, associatedTaxon, includeUnpublished, limit, start, orderHints, SpecimenOrObservationBase.class);
if(query==null){
return Collections.emptyList();
}
}
private <T extends SpecimenOrObservationBase, R extends Object> Query<R> createSpecimenQuery(String select, Class<T> clazz,
- Taxon associatedTaxon, Integer limit, Integer start, List<OrderHint> orderHints, Class<R> returnClass){
+ Taxon associatedTaxon, boolean includeUnpublished, Integer limit, Integer start, List<OrderHint> orderHints, Class<R> returnClass){
Set<Integer> setOfAllIds = new HashSet<>();
// The IndividualsAssociation elements in a TaxonDescription contain DerivedUnits
setOfAllIds.addAll(descriptionDao.getIndividualAssociationSpecimenIDs(
- associatedTaxon.getUuid(), null, null, 0, null));
+ associatedTaxon.getUuid(), null, includeUnpublished, null, 0, null));
// SpecimenTypeDesignations may be associated with the TaxonName.
*/\r
public <T extends SpecimenOrObservationBase> List<T> findOccurrences(Class<T> clazz, String queryString,\r
String significantIdentifier, SpecimenOrObservationType type, Taxon determinedAs,\r
- TaxonName associatedTaxonName, MatchMode matchmode, Integer limit, Integer start,\r
+ TaxonName associatedTaxonName, MatchMode matchmode, boolean includeUnpublished,\r
+ Integer limit, Integer start,\r
List<OrderHint> orderHints, List<String> propertyPaths);\r
\r
/**\r
public <T extends SpecimenOrObservationBase> List<UuidAndTitleCache<SpecimenOrObservationBase>> findOccurrencesUuidAndTitleCache(\r
Class<T> clazz, String queryString,\r
String significantIdentifier, SpecimenOrObservationType type, Taxon determinedAs,\r
- TaxonName associatedTaxonName, MatchMode matchmode, Integer limit, Integer start,\r
- List<OrderHint> orderHints);\r
+ TaxonName associatedTaxonName, MatchMode matchmode, boolean includeUnpublished,\r
+ Integer limit, Integer start, List<OrderHint> orderHints);\r
\r
/**\r
* Returns the number of specimens that match the given parameters\r
*/\r
public <T extends SpecimenOrObservationBase> long countOccurrences(Class<T> clazz, String queryString,\r
String significantIdentifier, SpecimenOrObservationType recordBasis, Taxon associatedTaxon,\r
- TaxonName associatedTaxonName, MatchMode matchmode, Integer limit, Integer start,\r
+ TaxonName associatedTaxonName, MatchMode matchmode, boolean includeUnpublished,\r
+ Integer limit, Integer start,\r
List<OrderHint> orderHints, List<String> propertyPaths);\r
\r
/**\r
* <li>{@link SpecimenTypeDesignation}s may be associated with any {@link HomotypicalGroup} related to the specific {@link Taxon}.</li>\r
* <li>A {@link Taxon} or a {@link TaxonName} may be referenced by the {@link DeterminationEvent} of the {@link SpecimenOrObservationBase}</li>\r
* </ul>\r
- *\r
- * @param <T>\r
- * @param type\r
- * @param associatedTaxon\r
- * @param limit\r
- * @param start\r
- * @param orderHints\r
- * @param propertyPaths\r
- * @return\r
*/\r
public <T extends SpecimenOrObservationBase> List<T> listByAssociatedTaxon(Class<T> type, Taxon associatedTaxon,\r
- Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths);\r
+ boolean includeUnpublished, Integer limit, Integer start,\r
+ List<OrderHint> orderHints, List<String> propertyPaths);\r
\r
/**\r
* @see IOccurrenceDao#listByAssociatedTaxon(Class, Taxon, Integer, Integer, List, List)\r
- * @param type\r
- * @param associatedTaxon\r
- * @param limit\r
- * @param start\r
- * @param orderHints\r
- * @param propertyPaths\r
- * @return\r
*/\r
- public <T extends SpecimenOrObservationBase> List<UuidAndTitleCache<SpecimenOrObservationBase>> listUuidAndTitleCacheByAssociatedTaxon(Class<T> type, Taxon associatedTaxon,\r
+ public <T extends SpecimenOrObservationBase> List<UuidAndTitleCache<SpecimenOrObservationBase>> listUuidAndTitleCacheByAssociatedTaxon(\r
+ Class<T> type, Taxon associatedTaxon, boolean includeUnpublished,\r
Integer limit, Integer start, List<OrderHint> orderHints);\r
\r
/**\r
// 1.
List<DescriptionElementBase> elements1 = descriptionDao.getDescriptionElementForTaxon(
- taxonSphingidae.getUuid() , null, null, null, 0, null);
+ taxonSphingidae.getUuid(), null, null, false, null, 0, null);
assertNotNull("getDescriptionElementForTaxon should return a List", elements1);
assertEquals("getDescriptionElementForTaxon should return 1 elements",1,elements1.size());
// 2.
List<DescriptionElementBase> elements2 = descriptionDao.getDescriptionElementForTaxon(
- taxonSphingidae.getUuid() , null, DescriptionElementBase.class, null, 0, null);
+ taxonSphingidae.getUuid(), null, DescriptionElementBase.class, false, null, 0, null);
assertNotNull("getDescriptionElementForTaxon should return a List", elements2);
assertTrue("getDescriptionElementForTaxon should be empty",elements2.isEmpty());
// 3.
List<Distribution> elements3 = descriptionDao.getDescriptionElementForTaxon(
- taxonSphingidae.getUuid() , null, Distribution.class, null, 0, null);
+ taxonSphingidae.getUuid() , null, Distribution.class, false, null, 0, null);
assertNotNull("getDescriptionElementForTaxon should return a List", elements3);
assertEquals("getDescriptionElementForTaxon should return 1 elements",1,elements3.size());
Assert.assertEquals(3, list.size());
}
-
+
@Test
@DataSet
public void testGetNodeOfIndividualAssociationForSpecimen() {
List<SortableTaxonNodeQueryResult> list = descriptionDao.getNodeOfIndividualAssociationForSpecimen(UUID.fromString("4c3231a9-336e-4b21-acf2-129683627de4"), null);
Assert.assertEquals(1, list.size());
-
+
}
@Override
public void createTestDataSet() throws FileNotFoundException {}
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
+import java.util.Set;
import java.util.UUID;
import javax.servlet.http.HttpServletRequest;
HttpServletResponse response) throws IOException {
logger.info("doPageDescriptionElementsByFeature : " + requestPathAndQuery(request));
+ boolean includeUnpublished = false;
PagerParameters pagerParams = new PagerParameters(pageSize, pageIndex);
pagerParams.normalizeAndValidate(response);
}
Pager<? extends DescriptionElementBase> pager = service.pageDescriptionElements(null, descriptionType, features.asSet(),
- type, pagerParams.getPageSize(), pagerParams.getPageIndex(), getInitializationStrategy());
+ type, includeUnpublished, pagerParams.getPageSize(), pagerParams.getPageIndex(), getInitializationStrategy());
return pager;
}
PagerParameters pagerParams = new PagerParameters(pageSize, pageIndex);
pagerParams.normalizeAndValidate(response);
+ boolean includeUnpublished = false;
Taxon taxon = null;
if( taxon_uuid!= null){
try {
HttpStatusMessage.UUID_NOT_FOUND.send(response);
}
}
+ Set<Feature> featureSet = features != null ? features.asSet() : null;
List<String> propertyPath = getInitializationStrategy();
- Pager<T> pager = service.pageDescriptionElementsForTaxon(taxon, features != null ? features.asSet() : null, type, pageSize,
- pageIndex, getInitializationStrategy());
+ Pager<T> pager = service.pageDescriptionElementsForTaxon(taxon, featureSet, type, includeUnpublished,
+ pageSize, pageIndex, propertyPath);
return pager;
}
return pager;
}
-
@RequestMapping(value = "specimensOrObservationsCount", method = RequestMethod.GET)
public StringResultDTO doCountSpecimensOrObservations(
@PathVariable("uuid") UUID uuid,
HttpServletRequest request,
HttpServletResponse response) {
+
logger.info("doListSpecimensOrObservations() - " + request.getRequestURI());
+ boolean includeUnpublished = NO_UNPUBLISHED;
List<OrderHint> orderHints = new ArrayList<>();
orderHints.add(new OrderHint("titleCache", SortOrder.DESCENDING));
FindOccurrencesConfigurator config = new FindOccurrencesConfigurator();
+ config.setIncludeUnpublished(includeUnpublished);
config.setAssociatedTaxonUuid(uuid);
long countSpecimen = occurrenceService.countOccurrences(config);
return new StringResultDTO(String.valueOf(countSpecimen));
+ classSimpleName);
if (taxonDescriptions != null) {
for (TaxonDescription description : taxonDescriptions) {
- elements = descriptionService.listDescriptionElements(description, null, type, null, 0, initStrategy);
+ elements = descriptionService.listDescriptionElements(
+ description, null, type, includeUnpublished, null, 0, initStrategy);
allElements.addAll(elements);
count += elements.size();
}
@Override
public <T extends DescriptionElementBase> Pager<T> pageDescriptionElements(DescriptionBase description, Class<? extends DescriptionBase> descriptionType,
- Set<Feature> features, Class<T> type, Integer pageSize, Integer pageNumber, List<String> propertyPaths) {
+ Set<Feature> features, Class<T> type, boolean includeUnpublished,
+ Integer pageSize, Integer pageNumber, List<String> propertyPaths) {
- List<T> results = listDescriptionElements(description, descriptionType, features, type, pageSize, pageNumber, propertyPaths);
+ List<T> results = listDescriptionElements(description, descriptionType, features, type, includeUnpublished,
+ pageSize, pageNumber, propertyPaths);
return new DefaultPagerImpl<>(pageNumber, Integer.valueOf(results.size()).longValue(), pageSize, results);
}
@Override
@Deprecated
public <T extends DescriptionElementBase> Pager<T> getDescriptionElements(DescriptionBase description,
- Set<Feature> features, Class<T> type, Integer pageSize, Integer pageNumber, List<String> propertyPaths) {
- return pageDescriptionElements(description, null, features, type, pageSize, pageNumber, propertyPaths);
+ Set<Feature> features, Class<T> type, boolean includeUnpublished,
+ Integer pageSize, Integer pageNumber, List<String> propertyPaths) {
+ return pageDescriptionElements(description, null, features, type, includeUnpublished, pageSize, pageNumber, propertyPaths);
}
@Override
public <T extends DescriptionElementBase> List<T> listDescriptionElements(DescriptionBase description,
- Class<? extends DescriptionBase> descriptionType, Set<Feature> features, Class<T> type, Integer pageSize, Integer pageNumber,
+ Class<? extends DescriptionBase> descriptionType,
+ Set<Feature> features, Class<T> type, boolean includeUnpublished,
+ Integer pageSize, Integer pageNumber,
List<String> propertyPaths) {
long numberOfResults = dao.countDescriptionElements(description, descriptionType, features, type);
@Override
@Deprecated
- public <T extends DescriptionElementBase> List<T> listDescriptionElements(DescriptionBase description,
- Set<Feature> features, Class<T> type, Integer pageSize, Integer pageNumber, List<String> propertyPaths) {
+ public <T extends DescriptionElementBase> List<T> listDescriptionElements(
+ DescriptionBase description,
+ Set<Feature> features, Class<T> type, boolean includeUnpublished,
+ Integer pageSize, Integer pageNumber, List<String> propertyPaths) {
- return listDescriptionElements(description, null, features, type, pageSize, pageNumber, propertyPaths);
+ return listDescriptionElements(description, null, features, type, includeUnpublished,
+ pageSize, pageNumber, propertyPaths);
}
@Override
@Deprecated
public <T extends DescriptionElementBase> List<T> getDescriptionElementsForTaxon(
Taxon taxon, Set<Feature> features,
- Class<T> type, Integer pageSize,
- Integer pageNumber, List<String> propertyPaths) {
- return listDescriptionElementsForTaxon(taxon, features, type, pageSize, pageNumber, propertyPaths);
+ Class<T> type, boolean includeUnpublished,
+ Integer pageSize, Integer pageNumber, List<String> propertyPaths) {
+
+ return listDescriptionElementsForTaxon(taxon, features, type, includeUnpublished,
+ pageSize, pageNumber, propertyPaths);
}
@Override
public <T extends DescriptionElementBase> List<T> listDescriptionElementsForTaxon(
Taxon taxon, Set<Feature> features,
- Class<T> type, Integer pageSize,
- Integer pageNumber, List<String> propertyPaths) {
- return dao.getDescriptionElementForTaxon(taxon.getUuid(), features, type, pageSize, pageNumber, propertyPaths);
+ Class<T> type, boolean includePublished,
+ Integer pageSize, Integer pageNumber, List<String> propertyPaths) {
+
+ return dao.getDescriptionElementForTaxon(taxon.getUuid(), features, type, includePublished,
+ pageSize, pageNumber, propertyPaths);
}
@Override
public <T extends DescriptionElementBase> Pager<T> pageDescriptionElementsForTaxon(
Taxon taxon, Set<Feature> features,
- Class<T> type, Integer pageSize,
- Integer pageNumber, List<String> propertyPaths) {
+ Class<T> type, boolean includeUnpublished,
+ Integer pageSize, Integer pageNumber, List<String> propertyPaths) {
+
if (logger.isDebugEnabled()){logger.debug(" get count ...");}
- Long count = dao.countDescriptionElementForTaxon(taxon.getUuid(), features, type);
+ Long count = dao.countDescriptionElementForTaxon(taxon.getUuid(), features, type, includeUnpublished);
List<T> descriptionElements;
if(AbstractPagerImpl.hasResultsInRange(count, pageNumber, pageSize)){ // no point checking again
if (logger.isDebugEnabled()){logger.debug(" get list ...");}
- descriptionElements = listDescriptionElementsForTaxon(taxon, features, type, pageSize, pageNumber, propertyPaths);
+ descriptionElements = listDescriptionElementsForTaxon(taxon, features, type, includeUnpublished,
+ pageSize, pageNumber, propertyPaths);
} else {
- descriptionElements = new ArrayList<T>(0);
+ descriptionElements = new ArrayList<>(0);
}
if (logger.isDebugEnabled()){logger.debug(" service - DONE ...");}
- return new DefaultPagerImpl<T>(pageNumber, count, pageSize, descriptionElements);
+ return new DefaultPagerImpl<>(pageNumber, count, pageSize, descriptionElements);
}
@Override
* instead
*/
@Deprecated
- public <T extends DescriptionElementBase> Pager<T> getDescriptionElements(DescriptionBase description,Set<Feature> features, Class<T> type, Integer pageSize, Integer pageNumber, List<String> propertyPaths);
+ public <T extends DescriptionElementBase> Pager<T> getDescriptionElements(
+ DescriptionBase description,Set<Feature> features, Class<T> type, boolean includeUnpublished,
+ Integer pageSize, Integer pageNumber, List<String> propertyPaths);
/**
*
* @return a Pager containing DescriptionElementBase instances
*/
- public <T extends DescriptionElementBase> Pager<T> pageDescriptionElements(DescriptionBase description, Class<? extends DescriptionBase> descriptionType, Set<Feature> features, Class<T> type, Integer pageSize, Integer pageNumber, List<String> propertyPaths);
+ public <T extends DescriptionElementBase> Pager<T> pageDescriptionElements(
+ DescriptionBase description, Class<? extends DescriptionBase> descriptionType,
+ Set<Feature> features, Class<T> type, boolean includeUnpublished,
+ Integer pageSize, Integer pageNumber, List<String> propertyPaths);
/**
* Returns description elements of type <TYPE>, belonging to a given
* @deprecated use {@link #listDescriptionElements(DescriptionBase, Class, Set, Class, Integer, Integer, List)} instead
*/
@Deprecated
- public <T extends DescriptionElementBase> List<T> listDescriptionElements(DescriptionBase description,Set<Feature> features, Class<T> type, Integer pageSize, Integer pageNumber, List<String> propertyPaths);
+ public <T extends DescriptionElementBase> List<T> listDescriptionElements(
+ DescriptionBase description, Set<Feature> features, Class<T> type, boolean includeUnpublished,
+ Integer pageSize, Integer pageNumber, List<String> propertyPaths);
/**
* Returns description elements of type <TYPE>, belonging to a given
* Restrict the results to those description elements which are
* scoped by one of the Features passed (can be null or empty)
* @param type
- * A filter DescriptionElements of a for specific class
+ * A filter DescriptionElements of a specific class
* @param pageSize
* The maximum number of description elements returned (can be
* null for all description elements)
* {@link IBeanInitializer#initialize(Object, List)}
* @return a List of DescriptionElementBase instances
*/
- public <T extends DescriptionElementBase> List<T> listDescriptionElements(DescriptionBase description, Class<? extends DescriptionBase> descriptionType, Set<Feature> features, Class<T> type, Integer pageSize, Integer pageNumber, List<String> propertyPaths);
+ public <T extends DescriptionElementBase> List<T> listDescriptionElements(
+ DescriptionBase description, Class<? extends DescriptionBase> descriptionType,
+ Set<Feature> features, Class<T> type, boolean includeUnpublished,
+ Integer pageSize, Integer pageNumber, List<String> propertyPaths);
/**
* @deprecated use {@link #listDescriptionElementsForTaxon(Taxon, Set, Class, Integer, Integer, List)} instead
*/
@Deprecated
- public <T extends DescriptionElementBase> List<T> getDescriptionElementsForTaxon(Taxon taxon, Set<Feature> features, Class<T> type, Integer pageSize, Integer pageNumber, List<String> propertyPaths);
+ public <T extends DescriptionElementBase> List<T> getDescriptionElementsForTaxon(
+ Taxon taxon, Set<Feature> features, Class<T> type, boolean includeUnpublished,
+ Integer pageSize, Integer pageNumber, List<String> propertyPaths);
/**
* Provides access to all DescriptionElements associated with the given Taxon
* scoped by one of the Features passed (can be null or empty)
* @param type
* A filter for DescriptionElements of a specific class
+ * @param includeUnpublished
+ * If true factual data in a description not being published
+ * is included.
* @param pageSize
* The maximum number of description elements returned (can be
* null for all description elements)
* @return a List containing all matching DescriptionElementBase instances
*
*/
- public <T extends DescriptionElementBase> List<T> listDescriptionElementsForTaxon(Taxon taxon, Set<Feature> features, Class<T> type, Integer pageSize, Integer pageNumber, List<String> propertyPaths);
+ public <T extends DescriptionElementBase> List<T> listDescriptionElementsForTaxon(
+ Taxon taxon, Set<Feature> features, Class<T> type, boolean includePublished,
+ Integer pageSize, Integer pageNumber, List<String> propertyPaths);
/**
* Provides access to all DescriptionElements associated with the given Taxon
* scoped by one of the Features passed (can be null or empty)
* @param type
* A filter for DescriptionElements of a specific class
+ * @param includeUnpublished
+ * If true factual data in a description not being published
+ * is included.
* @param pageSize
* The maximum number of description elements returned
* @param pageNumber
* @return a Pager for all matching DescriptionElementBase instances
*
*/
- public <T extends DescriptionElementBase> Pager<T> pageDescriptionElementsForTaxon(Taxon taxon, Set<Feature> features, Class<T> type, Integer pageSize, Integer pageNumber, List<String> propertyPaths);
+ public <T extends DescriptionElementBase> Pager<T> pageDescriptionElementsForTaxon(
+ Taxon taxon, Set<Feature> features, Class<T> type, boolean includeUnpublished,
+ Integer pageSize, Integer pageNumber, List<String> propertyPaths);
/**
* Generate a string representation of the structured <code>description</code> supplied in natural language
public DerivedUnitFacade getDerivedUnitFacade(DerivedUnit derivedUnit, List<String> propertyPaths) throws DerivedUnitFacadeNotSupportedException;
- public List<DerivedUnitFacade> listDerivedUnitFacades(DescriptionBase description, List<String> propertyPaths);
+ public List<DerivedUnitFacade> listDerivedUnitFacades(DescriptionBase description, boolean includeUnpublished, List<String> propertyPaths);
/**
* Lists all instances of {@link SpecimenOrObservationBase} which are
@Override
public List<DerivedUnitFacade> listDerivedUnitFacades(
- DescriptionBase description, List<String> derivedUnitFacadeInitStrategy) {
+ DescriptionBase description, boolean includeUnpublished,
+ List<String> derivedUnitFacadeInitStrategy) {
List<DerivedUnitFacade> derivedUnitFacadeList = new ArrayList<>();
IndividualsAssociation tempIndividualsAssociation;
SpecimenOrObservationBase tempSpecimenOrObservationBase;
- List<IndividualsAssociation> elements = descriptionService.listDescriptionElements(description, null, IndividualsAssociation.class, null, 0, Arrays.asList(new String []{"associatedSpecimenOrObservation"}));
+ List<IndividualsAssociation> elements = descriptionService.listDescriptionElements(
+ description, null, IndividualsAssociation.class, includeUnpublished, null, 0, Arrays.asList(new String []{"associatedSpecimenOrObservation"}));
for (IndividualsAssociation element : elements) {
tempIndividualsAssociation = HibernateProxyHelper.deproxy(element, IndividualsAssociation.class);
if (tempIndividualsAssociation.getAssociatedSpecimenOrObservation() != null) {
taxa.add(associatedTaxon);
for (Taxon taxon : taxa) {
- List<T> perTaxonOccurrences = dao.listByAssociatedTaxon(type, taxon, null, null, orderHints, propertyPaths);
+ List<T> perTaxonOccurrences = dao.listByAssociatedTaxon(type, taxon, includeUnpublished,
+ null, null, orderHints, propertyPaths);
for (SpecimenOrObservationBase<?> o : perTaxonOccurrences) {
occurrenceIds.add(o.getId());
}
for (Taxon taxon : taxa) {
// TODO there might be a good potential to speed up the whole processing by collecting all entities first
// and to create the DTOs in a second step
- Set<SpecimenOrObservationBase> perTaxonOccurrences = dao.listByAssociatedTaxon(null, taxon, null, null, null, propertyPaths)
+ Set<SpecimenOrObservationBase> perTaxonOccurrences = dao.listByAssociatedTaxon(
+ null, taxon, includeUnpublished, null, null, null, propertyPaths)
.stream()
.map(u -> HibernateProxyHelper.deproxy(u, SpecimenOrObservationBase.class))
.collect(Collectors.toSet());
@Override
public long countByTitle(IIdentifiableEntityServiceConfigurator<SpecimenOrObservationBase> config){
+
if (config instanceof FindOccurrencesConfigurator) {
FindOccurrencesConfigurator occurrenceConfig = (FindOccurrencesConfigurator) config;
Taxon taxon = null;
List<SpecimenOrObservationBase> occurrences = new ArrayList<>();
List<SpecimenOrObservationBase> sobs = dao.findOccurrences(occurrenceConfig.getClazz(),
occurrenceConfig.getTitleSearchStringSqlized(), occurrenceConfig.getSignificantIdentifier(),
- occurrenceConfig.getSpecimenType(), taxon, taxonName, occurrenceConfig.getMatchMode(), null, null,
+ occurrenceConfig.getSpecimenType(), taxon, taxonName, occurrenceConfig.getMatchMode(),
+ occurrenceConfig.isIncludeUnpublished(), null, null,
occurrenceConfig.getOrderHints(), occurrenceConfig.getPropertyPaths());
occurrences.addAll(sobs);
occurrences = filterOccurencesByAssignmentAndHierarchy(occurrenceConfig, occurrences, taxon, taxonName);
return dao.countOccurrences(occurrenceConfig.getClazz(),
occurrenceConfig.getTitleSearchStringSqlized(), occurrenceConfig.getSignificantIdentifier(),
- occurrenceConfig.getSpecimenType(), taxon, taxonName, occurrenceConfig.getMatchMode(), null, null,
+ occurrenceConfig.getSpecimenType(), taxon, taxonName, occurrenceConfig.getMatchMode(),
+ occurrenceConfig.isIncludeUnpublished(), null, null,
occurrenceConfig.getOrderHints(), occurrenceConfig.getPropertyPaths());
}
else{
@Override
public Pager<UuidAndTitleCache<SpecimenOrObservationBase>> findByTitleUuidAndTitleCache(
FindOccurrencesConfigurator config){
+
List<UuidAndTitleCache<SpecimenOrObservationBase>> occurrences = new ArrayList<>();
Taxon taxon = null;
if(config.getAssociatedTaxonUuid()!=null){
}
occurrences.addAll(dao.findOccurrencesUuidAndTitleCache(config.getClazz(),
config.getTitleSearchString(), config.getSignificantIdentifier(),
- config.getSpecimenType(), taxon, taxonName, config.getMatchMode(), null, null,
- config.getOrderHints()));
+ config.getSpecimenType(), taxon, taxonName, config.getMatchMode(),
+ config.isIncludeUnpublished(),
+ null, null, config.getOrderHints()));
long count = Integer.valueOf(occurrences.size()).longValue();
return new DefaultPagerImpl<>(config.getPageNumber(), count, config.getPageSize(), occurrences);
}
@Override
public List<DerivedUnitDTO> findByTitleDerivedUnitDTO(FindOccurrencesConfigurator config) {
+
Taxon taxon = null;
if(config.getAssociatedTaxonUuid()!=null){
TaxonBase<?> taxonBase = taxonService.load(config.getAssociatedTaxonUuid());
List<DerivedUnit> occurrences = new ArrayList<>();
occurrences.addAll(dao.findOccurrences(DerivedUnit.class,
config.getTitleSearchString(), config.getSignificantIdentifier(),
- config.getSpecimenType(), taxon, taxonName, config.getMatchMode(), null, null,
+ config.getSpecimenType(), taxon, taxonName, config.getMatchMode(),
+ config.isIncludeUnpublished(), null, null,
config.getOrderHints(), null));
List<DerivedUnitDTO> dtos = new ArrayList<>();
@Override
public <S extends SpecimenOrObservationBase> Pager<S> findByTitle(
IIdentifiableEntityServiceConfigurator<S> config) {
+
if (config instanceof FindOccurrencesConfigurator) {
FindOccurrencesConfigurator occurrenceConfig = (FindOccurrencesConfigurator) config;
List<SpecimenOrObservationBase> occurrences = new ArrayList<>();
if(occurrenceConfig.getAssociatedTaxonNameUuid()!=null){
taxonName = nameService.load(occurrenceConfig.getAssociatedTaxonNameUuid());
}
- List<? extends SpecimenOrObservationBase> foundOccurrences = dao.findOccurrences(occurrenceConfig.getClazz(),
+ List<? extends SpecimenOrObservationBase> foundOccurrences = dao.findOccurrences(
+ occurrenceConfig.getClazz(),
occurrenceConfig.getTitleSearchString(), occurrenceConfig.getSignificantIdentifier(),
- occurrenceConfig.getSpecimenType(), taxon, taxonName, occurrenceConfig.getMatchMode(), null, null,
- occurrenceConfig.getOrderHints(), occurrenceConfig.getPropertyPaths());
+ occurrenceConfig.getSpecimenType(), taxon, taxonName,
+ occurrenceConfig.getMatchMode(), occurrenceConfig.isIncludeUnpublished(),
+ null, null, occurrenceConfig.getOrderHints(), occurrenceConfig.getPropertyPaths());
occurrences.addAll(foundOccurrences);
occurrences = filterOccurencesByAssignmentAndHierarchy(occurrenceConfig, occurrences, taxon, taxonName);
@Override
public List<Media> listMedia(Taxon taxon, Set<TaxonRelationshipEdge> includeRelationships,
- Boolean limitToGalleries, Boolean includeTaxonDescriptions, Boolean includeOccurrences, Boolean includeOriginalOccurences,
- Boolean includeTaxonNameDescriptions, List<String> propertyPath) {
+ Boolean limitToGalleries, Boolean includeTaxonDescriptions, Boolean includeOccurrences,
+ Boolean includeOriginalOccurences, Boolean includeTaxonNameDescriptions,
+ List<String> propertyPath) {
//TODO let inherit
boolean includeUnpublished = INCLUDE_UNPUBLISHED;
Set<SpecimenOrObservationBase> specimensOrObservations = new HashSet<>();
// --- Specimens
for (Taxon t : taxa) {
- specimensOrObservations.addAll(occurrenceDao.listByAssociatedTaxon(null, t, null, null, null, null));
+ specimensOrObservations.addAll(occurrenceDao.listByAssociatedTaxon(
+ null, t, includeUnpublished, null, null, null, null));
}
for (SpecimenOrObservationBase<?> occurrence : specimensOrObservations) {
public class IdentifiableServiceConfiguratorImpl<T extends IIdentifiableEntity>\r
implements IIdentifiableEntityServiceConfigurator<T>{\r
\r
- private static final long serialVersionUID = -8126736101861741087L;\r
+ private static final long serialVersionUID = -8136736101861741087L;\r
\r
private String titleSearchString;\r
protected MatchMode matchMode;\r
private List<Restriction<?>> restrictions;\r
private List<String> propertyPaths;\r
private List<OrderHint> orderHints;\r
+ private boolean includeUnpublished = false;\r
\r
@Override\r
public Class<T> getClazz() {\r
public List<String> getPropertyPaths() {\r
return propertyPaths;\r
}\r
-\r
@Override\r
public void setPropertyPaths(List<String> propertyPaths) {\r
this.propertyPaths = propertyPaths;\r
}\r
+\r
+ public boolean isIncludeUnpublished() {\r
+ return includeUnpublished;\r
+ }\r
+ public void setIncludeUnpublished(boolean includeUnpublished) {\r
+ this.includeUnpublished = includeUnpublished;\r
+ }\r
}\r
initStrategy.add("markers.markerType");
}
- List<Distribution> distributions = dao.getDescriptionElementForTaxon(taxonUUID, features, Distribution.class, null, null, initStrategy);
+ List<Distribution> distributions = dao.getDescriptionElementForTaxon(
+ taxonUUID, features, Distribution.class, config.isIncludeUnpublished(), null, null, initStrategy);
return composeDistributionInfoFor(config, distributions, neverUseFallbackAreaAsParent, presenceAbsenceTermColors, languages);
}
}
}
service.saveOrUpdate(descBase);
- Pager<DescriptionElementBase> allElements = service.getDescriptionElements(null, null, null, null, null, null);
+ Pager<DescriptionElementBase> allElements = service.getDescriptionElements(null, null, null, false, null, null, null);
Assert.assertEquals(1, allElements.getCount().intValue());
DescriptionElementBase test = allElements.getRecords().get(0);
if (test instanceof TextData){
// wildcard search => all derivates
FindOccurrencesConfigurator config = new FindOccurrencesConfigurator();
+ config.setIncludeUnpublished(false);
config.setTitleSearchString("*");
assertEquals(6, occurrenceService.countOccurrences(config));
@SuppressWarnings("rawtypes")