Revision 99741bc0
Added by Andreas Kohlbecker over 5 years ago
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/StartRegistrationPresenter.java | ||
---|---|---|
16 | 16 |
|
17 | 17 |
import org.hibernate.criterion.Criterion; |
18 | 18 |
import org.hibernate.criterion.Restrictions; |
19 |
import org.joda.time.DateTime; |
|
19 | 20 |
import org.springframework.beans.factory.annotation.Autowired; |
20 | 21 |
import org.vaadin.spring.events.EventScope; |
21 | 22 |
import org.vaadin.spring.events.annotation.EventBusListenerMethod; |
... | ... | |
96 | 97 |
Collection<CdmAuthority> referencePermissions = UserHelperAccess.userHelper().findUserPermissions(Reference.class, Operation.UPDATE); |
97 | 98 |
boolean generalUpdatePermission = referencePermissions.stream().anyMatch(p -> p.getTargetUUID() == null); |
98 | 99 |
if(!generalUpdatePermission){ |
100 |
// exclude unpublished publications |
|
101 |
DateTime nowLocal = new DateTime(); |
|
102 |
String dateString = nowLocal.toString("yyyyMMdd"); |
|
103 |
logger.debug("dateString:" + dateString); |
|
104 |
Criterion pulishedOnly = Restrictions.or( |
|
105 |
Restrictions.and(Restrictions.isNull("datePublished.start"), Restrictions.isNull("datePublished.end"), Restrictions.isNull("datePublished.freeText")), |
|
106 |
Restrictions.and(Restrictions.isNotNull("datePublished.start"), Restrictions.sqlRestriction("datePublished_start < " + dateString)), |
|
107 |
Restrictions.and(Restrictions.isNull("datePublished.start"), Restrictions.isNotNull("datePublished.end"), Restrictions.sqlRestriction("datePublished_end < " + dateString)) |
|
108 |
); |
|
99 | 109 |
// restrict by allowed reference uuids |
100 | 110 |
Set<UUID> allowedUuids = referencePermissions.stream().filter(p -> p.getTargetUUID() != null).map(CdmAuthority::getTargetUUID).collect(Collectors.toSet()); |
101 | 111 |
Criterion uuidRestriction = Restrictions.in("uuid", allowedUuids); |
102 |
criterion = Restrictions.and(criterion, uuidRestriction);
|
|
112 |
criterion = Restrictions.and(criterion, Restrictions.or(pulishedOnly, uuidRestriction));
|
|
103 | 113 |
} |
104 | 114 |
} |
105 | 115 |
referencePagingProvider.addCriterion(criterion); |
Also available in: Unified diff
ref #7833 registration start view excludes unpublished references