Commit 9edda553 authored by igoshin's avatar igoshin

#13943 FaoInstitute#allowsMaterialRequests

parent 3d5ca3f7
......@@ -90,6 +90,9 @@ public class FaoInstitute extends BusinessModel implements GeoReferencedEntity,
private Double elevation;
private boolean uniqueAcceNumbs = true;
@Column(name = "allowMaterialRequests", columnDefinition = "boolean default true", nullable = false)
private boolean allowMaterialRequests = true;
public FaoInstitute() {
}
......@@ -240,4 +243,12 @@ public class FaoInstitute extends BusinessModel implements GeoReferencedEntity,
public void setCurrent(boolean current) {
this.current = current;
}
public boolean isAllowMaterialRequests() {
return allowMaterialRequests;
}
public void setAllowMaterialRequests(boolean allowMaterialRequests) {
this.allowMaterialRequests = allowMaterialRequests;
}
}
......@@ -92,7 +92,7 @@ public interface AccessionRepository extends JpaRepository<Accession, Long> {
List<Accession> findByInstituteAndAccessionName(FaoInstitute faoInstitute, String accessionName);
@Query("from Accession a where a.id in ( ?1 )")
@Query("from Accession a where a.institute.allowMaterialRequests=true and a.id in ( ?1 )")
Page<Accession> findById(Collection<Long> accessionIds, Pageable pageable);
@Query("from Accession a where a.id in ( ?1 )")
......
......@@ -60,6 +60,8 @@ public interface InstituteService {
void setUniqueAcceNumbs(FaoInstitute faoInstitute, boolean uniqueAcceNumbs);
void setallowMaterialRequests(FaoInstitute faoInstitute, boolean allowMaterialRequests);
void delete(String instCode);
List<FaoInstitute> listMyInstitutes(Sort sort);
......
......@@ -146,7 +146,17 @@ public class InstituteServiceImpl implements InstituteService {
instituteRepository.save(inst);
}
@Override
@Override
@PreAuthorize("hasRole('ADMINISTRATOR') or hasPermission(#faoInstitute, 'ADMINISTRATION')")
@Transactional(readOnly = false)
public void setallowMaterialRequests(FaoInstitute faoInstitute, boolean allowMaterialRequests) {
final FaoInstitute inst = instituteRepository.findOne(faoInstitute.getId());
LOG.info("Setting 'uniqueAcceNumbs' to " + allowMaterialRequests + " for " + faoInstitute);
inst.setAllowMaterialRequests(allowMaterialRequests);
instituteRepository.save(inst);
}
@Override
@PreAuthorize("hasRole('ADMINISTRATOR') or hasPermission(#faoInstitute, 'ADMINISTRATION')")
@Transactional(readOnly = false)
public void updateSettings(FaoInstitute faoInstitute, Map<String, String> settings) {
......
......@@ -158,7 +158,9 @@ public class WiewsController extends BaseController {
@RequestMapping("/{wiewsCode}/update")
public String update(ModelMap model, @PathVariable(value = "wiewsCode") String wiewsCode, @RequestParam("blurp") String blurp,
@RequestParam("gaTracker") String gaTracker, @RequestParam("mailto") String mailto, @RequestParam("uniqueAcceNumbs") boolean uniqueAcceNumbs) {
@RequestParam("gaTracker") String gaTracker, @RequestParam("mailto") String mailto,
@RequestParam("uniqueAcceNumbs") boolean uniqueAcceNumbs,
@RequestParam (value = "allowMaterialRequests",required = false,defaultValue = "false") boolean allowMaterialRequests) {
_logger.debug("Updating institite " + wiewsCode);
final FaoInstitute faoInstitute = instituteService.getInstitute(wiewsCode);
if (faoInstitute == null) {
......@@ -171,6 +173,7 @@ public class WiewsController extends BaseController {
settings.put("requests.mailto", mailto);
instituteService.updateSettings(faoInstitute, settings);
instituteService.setUniqueAcceNumbs(faoInstitute, uniqueAcceNumbs);
instituteService.setallowMaterialRequests(faoInstitute, allowMaterialRequests);
return "redirect:/wiews/" + wiewsCode;
}
......
......@@ -162,6 +162,7 @@ faoInstitute.member-of-organizations-and-networks=Organizations and Networks:
faoInstitute.uniqueAcceNumbs.true=Each accession number is unique within this institute.
faoInstitute.uniqueAcceNumbs.false=The same accession number may be used in separate collections in this institute.
faoInstitute.requests.mailto=Email address for material requests:
faoInstitute.allow.requests=Allow material requests
view.accessions=View accessions...
view.datasets=View datasets...
......
......@@ -42,7 +42,10 @@
<label><input type="radio" name="uniqueAcceNumbs" class="" value="true" ${faoInstitute.uniqueAcceNumbs==true ? 'checked' : ''} /> <spring:message code="faoInstitute.uniqueAcceNumbs.true" /></label>
<label><input type="radio" name="uniqueAcceNumbs" class="" value="false" ${faoInstitute.uniqueAcceNumbs==false ? 'checked' : ''} /> <spring:message code="faoInstitute.uniqueAcceNumbs.false" /></label>
</div>
</div>
<div class="controls col-lg-offset-3 col-lg-9">
<label><input type="checkbox" name="allowMaterialRequests" class="" ${faoInstitute.allowMaterialRequests==true ? 'checked' : ''} /> <spring:message code="faoInstitute.allow.requests" /></label>
</div>
</div>
<input type="submit" value="<spring:message code="save"/>" class="btn btn-primary" /> <a href="<c:url value="/wiews/${faoInstitute.code}" />" class="btn btn-default"> <spring:message code="cancel" />
</a>
......
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