Commit 94f9f904 authored by Matija Obreza's avatar Matija Obreza

Merge branch 'fao-institute-material-requests'

Conflicts:
	src/main/java/org/genesys2/server/servlet/controller/WiewsController.java
parents 64c40ee0 b142ecc4
......@@ -69,6 +69,9 @@ public class FaoInstitute extends BusinessModel implements GeoReferencedEntity,
@Column(length = 10)
private String vCode;
@Column(name = "codeSGSV")
private String codeSGSV;
private boolean current;
@JsonIgnore
......@@ -251,4 +254,12 @@ public class FaoInstitute extends BusinessModel implements GeoReferencedEntity,
public void setAllowMaterialRequests(boolean allowMaterialRequests) {
this.allowMaterialRequests = allowMaterialRequests;
}
public String getCodeSGSV() {
return codeSGSV;
}
public void setCodeSGSV(String codeSGSV) {
this.codeSGSV = codeSGSV;
}
}
......@@ -107,6 +107,9 @@ public interface AccessionRepository extends JpaRepository<Accession, Long> {
Accession findByInstituteCodeAndAccessionName(String instCode, String accessionName);
@Query("select a from Accession a where a.accessionName=?1 and (a.institute.code=?2 or a.institute.codeSGSV=?2) and a.taxonomy.genus=?3")
Accession findOneSGSV(String acceNumb, String instCode, String genus);
@Query("select a from Accession a where a.institute.code=:instCode and a.accessionName=:acceNumb and a.taxonomy.genus=:genus")
Accession findOne(@Param("instCode") String holdingInstitute, @Param("acceNumb") String accessionName, @Param("genus") String genus);
......
......@@ -96,7 +96,7 @@ public interface GenesysService {
Page<Accession> listAccessions(Collection<Long> accessionIds, Pageable pageable);
List<Accession> listAccessions(List<? extends AccessionIdentifier3> accns);
List<Accession> listAccessionsSGSV(List<? extends AccessionIdentifier3> accns);
Accession getAccession(AccessionIdentifier3 aid3) throws NonUniqueAccessionException;
......
......@@ -54,7 +54,9 @@ public interface InstituteService {
List<Organization> getOrganizations(FaoInstitute faoInstitute);
void updateSettings(FaoInstitute faoInstitute, Map<String, String> settings);
void setCodeSGSV(FaoInstitute faoInstitute, String codeSGSV);
void updateSettings(FaoInstitute faoInstitute, Map<String, String> settings);
long countActive();
......
......@@ -222,10 +222,10 @@ public class GenesysServiceImpl implements GenesysService, TraitService, Dataset
}
@Override
public List<Accession> listAccessions(List<? extends AccessionIdentifier3> accns) {
public List<Accession> listAccessionsSGSV(List<? extends AccessionIdentifier3> accns) {
final List<Accession> result = new ArrayList<Accession>(accns.size());
for (final AccessionIdentifier3 aid3 : accns) {
final Accession accn = accessionRepository.findOne(aid3.getHoldingInstitute(), aid3.getAccessionName(), aid3.getGenus());
final Accession accn = accessionRepository.findOneSGSV(aid3.getHoldingInstitute(), aid3.getAccessionName(), aid3.getGenus());
if (accn != null) {
result.add(accn);
......
......@@ -151,11 +151,21 @@ public class InstituteServiceImpl implements InstituteService {
@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);
LOG.info("Setting 'allowMaterialRequests' to " + allowMaterialRequests + " for " + faoInstitute);
inst.setAllowMaterialRequests(allowMaterialRequests);
instituteRepository.save(inst);
}
@Override
@PreAuthorize("hasRole('ADMINISTRATOR') or hasPermission(#faoInstitute, 'ADMINISTRATION')")
@Transactional(readOnly = false)
public void setCodeSGSV(FaoInstitute faoInstitute, String codeSGSV) {
final FaoInstitute inst = instituteRepository.findOne(faoInstitute.getId());
LOG.info("Setting 'codeSGSV' to " + codeSGSV + " for " + faoInstitute);
inst.setCodeSGSV(codeSGSV);
instituteRepository.save(inst);
}
@Override
@PreAuthorize("hasRole('ADMINISTRATOR') or hasPermission(#faoInstitute, 'ADMINISTRATION')")
@Transactional(readOnly = false)
......
......@@ -264,7 +264,7 @@ public class SGSVUpdate {
// Find accessions based on holdingInstitute and
// accession
// name
final List<Accession> accessions = genesysService.listAccessions(accns);
final List<Accession> accessions = genesysService.listAccessionsSGSV(accns);
// Must be same order
if (accessions.size() != accns.size()) {
......
......@@ -159,8 +159,15 @@ public class WiewsController extends BaseController {
@RequestMapping("/{wiewsCode}/update")
public String update(ModelMap model, @PathVariable(value = "wiewsCode") String wiewsCode, @RequestParam("blurp") String blurp,
<<<<<<< HEAD
@RequestParam("gaTracker") String gaTracker, @RequestParam("mailto") String mailto, @RequestParam("uniqueAcceNumbs") boolean uniqueAcceNumbs,
@RequestParam(value = "allowMaterialRequests", required = false, defaultValue = "false") boolean allowMaterialRequests) {
=======
@RequestParam("gaTracker") String gaTracker, @RequestParam("mailto") String mailto,
@RequestParam("uniqueAcceNumbs") boolean uniqueAcceNumbs,
@RequestParam (value = "allowMaterialRequests",required = false,defaultValue = "false") boolean allowMaterialRequests,
@RequestParam("codeSVGS")String codeSVGS) {
>>>>>>> fao-institute-material-requests
_logger.debug("Updating institite " + wiewsCode);
final FaoInstitute faoInstitute = instituteService.getInstitute(wiewsCode);
if (faoInstitute == null) {
......@@ -174,6 +181,7 @@ public class WiewsController extends BaseController {
instituteService.updateSettings(faoInstitute, settings);
instituteService.setUniqueAcceNumbs(faoInstitute, uniqueAcceNumbs);
instituteService.setAllowMaterialRequests(faoInstitute, allowMaterialRequests);
instituteService.setCodeSGSV(faoInstitute,codeSVGS);
return "redirect:/wiews/" + wiewsCode;
}
......
......@@ -163,6 +163,7 @@ faoInstitute.uniqueAcceNumbs.true=Each accession number is unique within this in
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
faoInstitute.sgsv=Code SGSV
view.accessions=View accessions...
view.datasets=View datasets...
......
......@@ -37,6 +37,13 @@
</div>
</div>
<div class="form-group">
<label class="col-lg-3 control-label"><spring:message code="faoInstitute.sgsv" /></label>
<div class="controls col-lg-9">
<input type="text" name="codeSVGS" class="form-control required" value="${faoInstitute.codeSGSV}" />
</div>
</div>
<div class="form-group">
<div class="controls col-lg-offset-3 col-lg-9">
<label><input type="radio" name="uniqueAcceNumbs" class="" value="true" ${faoInstitute.uniqueAcceNumbs==true ? 'checked' : ''} /> <spring:message code="faoInstitute.uniqueAcceNumbs.true" /></label>
......
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