Commit 802fdc59 authored by Matija Obreza's avatar Matija Obreza
Browse files

Subsets: missing @PreUpdate and aclParentObject

parent 4470f0c0
......@@ -29,6 +29,7 @@ import javax.persistence.Lob;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.PrePersist;
import javax.persistence.PreUpdate;
import javax.persistence.Table;
import org.genesys.blocks.model.SelfCleaning;
......@@ -103,6 +104,7 @@ public class Subset extends UuidModel implements AclAwareModel, SelfCleaning {
* Generate UUID if missing.
*/
@PrePersist
@PreUpdate
protected void prepersist() {
trimStringsToNull();
......@@ -112,6 +114,11 @@ public class Subset extends UuidModel implements AclAwareModel, SelfCleaning {
this.accessionCount=this.getAccessionIds().size();
}
}
@Override
public AclAwareModel aclParentObject() {
return institute;
}
/**
* Checks if published.
......
......@@ -27,6 +27,7 @@ import org.genesys2.server.model.PublishState;
import org.genesys2.server.model.UserRole;
import org.genesys2.server.model.genesys.AccessionData;
import org.genesys2.server.model.genesys.AccessionId;
import org.genesys2.server.model.impl.QSubset;
import org.genesys2.server.model.impl.Subset;
import org.genesys2.server.persistence.AccessionRepository;
import org.genesys2.server.persistence.FaoInstituteRepository;
......@@ -45,6 +46,9 @@ import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.querydsl.core.BooleanBuilder;
/**
* The Class SubsetServiceImpl.
*
......@@ -74,7 +78,10 @@ public class SubsetServiceImpl implements SubsetService {
*/
@Override
public Page<Subset> list(final SubsetFilter filter, final Pageable page) {
return subsetRepository.findAll(filter.buildQuery(), page);
final BooleanBuilder published = new BooleanBuilder();
published.and(QSubset.subset.state.eq(PublishState.PUBLISHED));
published.and(filter.buildQuery());
return subsetRepository.findAll(published, page);
}
/**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment