Commit 0392db16 authored by Matija Obreza's avatar Matija Obreza

Added Accession#historic

parent c65213e9
......@@ -82,6 +82,8 @@ public class AccessionDetails {
private Date modifiedDate;
private Date acqusitionDate;
private boolean historic;
public static AccessionDetails from(Accession accession) {
AccessionDetails ad = new AccessionDetails();
ad.version = accession.getVersion();
......@@ -93,6 +95,7 @@ public class AccessionDetails {
ad.acqDate = accession.getAcquisitionDate();
ad.acqSrc = accession.getAcquisitionSource();
ad.available = accession.getAvailability();
ad.historic = accession.getHistoric();
ad.orgCty = Country.from(accession.getCountryOfOrigin());
ad.duplSite = MCPDUtil.toStrings(accession.getDuplSite());
ad.institute = Institute.from(accession.getInstitute());
......@@ -397,6 +400,14 @@ public class AccessionDetails {
this.inSgsv = inSgsv;
}
public boolean getHistoric() {
return historic;
}
public void setHistoric(boolean historic) {
this.historic = historic;
}
public void networks(List<Organization> organizations) {
if (organizations == null || organizations.isEmpty())
return;
......
......@@ -92,6 +92,9 @@ public class Accession extends VersionedAuditedModel {
@Column(name = "available")
private Boolean availability;
@Column(name = "historic")
private boolean historic = false;
@Column(name = "mlsStat")
private Boolean mlsStatus;
......@@ -277,6 +280,14 @@ public class Accession extends VersionedAuditedModel {
protected void setStorage(String storage) {
this.storage = storage;
}
public void setHistoric(boolean historic) {
this.historic = historic;
}
public boolean getHistoric() {
return this.historic;
}
@Override
public String toString() {
......
......@@ -44,6 +44,7 @@ public class AccessionJson {
private CollectingJson coll;
private GeoJson geo;
private Remark[] remarks;
private boolean historic;
public long getVersion() {
return version;
......@@ -252,4 +253,12 @@ public class AccessionJson {
public void setRemarks(Remark[] remarks) {
this.remarks = remarks;
}
public void setHistoric(boolean historic) {
this.historic=historic;
}
public boolean getHistoric() {
return this.historic;
}
}
......@@ -57,6 +57,7 @@ public class GenesysJsonFactory {
aj.setMlsStat(accession.getMlsStatus());
aj.setInTrust(accession.getInTrust());
aj.setAvailable(accession.getAvailability());
aj.setHistoric(accession.getHistoric());
// private Integer[] storage;
aj.setStorage(accession.getStoRage().toArray(ArrayUtils.EMPTY_INTEGER_OBJECT_ARRAY));
// private Integer sampStat;
......
......@@ -86,10 +86,10 @@ public interface AccessionRepository extends JpaRepository<Accession, Long> {
@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);
@Query("select count(a.id) from Accession a where a.id in ( ?1 ) and a.availability = true and a.institute.allowMaterialRequests = true")
@Query("select count(a.id) from Accession a where a.id in ( ?1 ) and a.historic = false and (a.availability is null or a.availability = true) and a.institute.allowMaterialRequests = true")
long countAvailableForDistribution(Set<Long> accessionIds);
@Query("select a.id from Accession a where a.id in ( ?1 ) and a.availability = true and a.institute.allowMaterialRequests = true")
@Query("select a.id from Accession a where a.id in ( ?1 ) and a.historic = false and (a.availability is null or a.availability = true) and a.institute.allowMaterialRequests = true")
Set<Long> filterAvailableForDistribution(Set<Long> accessionIds);
@Modifying
......
......@@ -239,7 +239,7 @@ public class GenesysLowlevelRepositoryImpl implements GenesysLowlevelRepository
@Override
public PreparedStatement createPreparedStatement(final Connection con) throws SQLException {
final PreparedStatement stmt = con.prepareStatement(directQuery
.getQuery("a.id, a.uuid, a.instCode, a.acceNumb, t.genus, t.species, t.taxonName, a.orgCty, a.acqSrc, a.acqDate, a.mlsStat, a.available, null, a.sampStat, a.duplSite, a.createdBy, a.createdDate, a.lastModifiedBy, a.lastModifiedDate"));
.getQuery("a.id, a.uuid, a.instCode, a.acceNumb, t.genus, t.species, t.taxonName, a.orgCty, a.acqSrc, a.acqDate, a.mlsStat, a.available, a.historic, a.storage, a.sampStat, a.duplSite, a.createdBy, a.createdDate, a.lastModifiedBy, a.lastModifiedDate"));
final ArgumentPreparedStatementSetter apss = new ArgumentPreparedStatementSetter(directQuery.getParameters());
apss.setValues(stmt);
......
......@@ -67,4 +67,6 @@ public interface FilterConstants {
public static final String IN_SGSV = "inSgsv";
public static final String TAXONOMY_GENUSSPECIES = "taxonomy.genusSpecies";
public static final String HISTORIC = "historic";
}
......@@ -229,6 +229,17 @@ public class BatchRESTServiceImpl implements BatchRESTService {
updated = true;
}
}
value = accnJson.get("historic");
if (value != null) {
if (value.isNull() || !value.isBoolean()) {
throw new RESTApiDataTypeException("If provided, 'historic' must be a boolean");
}
final boolean historic = value.asBoolean();
if (!areEqual(historic, accession.getHistoric())) {
accession.setHistoric(historic);
updated = true;
}
}
value = accnJson.get("acceName");
if (value != null) {
......
......@@ -168,6 +168,7 @@ public class DirectMysqlQuery {
createQuery(whereBuffer, "a.inTrust", filters.get(FilterConstants.ART15), params);
createQuery(whereBuffer, "a.sampStat", filters.get(FilterConstants.SAMPSTAT), params);
createQuery(whereBuffer, "a.available", filters.get(FilterConstants.AVAILABLE), params);
createQuery(whereBuffer, "a.historic", filters.get(FilterConstants.HISTORIC), params);
createQuery(whereBuffer, "org.slug", filters.get(FilterConstants.INSTITUTE_NETWORK), params);
createQuery(whereBuffer, "t.genus", filters.get(FilterConstants.TAXONOMY_GENUS), params);
createQuery(whereBuffer, "t.species", filters.get(FilterConstants.TAXONOMY_SPECIES), params);
......
......@@ -99,6 +99,7 @@ public class FilterHandler {
this.availableFilters.add(new BasicFilter(FilterConstants.MLSSTATUS, DataType.BOOLEAN));
this.availableFilters.add(new BasicFilter(FilterConstants.ART15, DataType.BOOLEAN));
this.availableFilters.add(new BasicFilter(FilterConstants.AVAILABLE, DataType.BOOLEAN));
this.availableFilters.add(new BasicFilter(FilterConstants.HISTORIC, DataType.BOOLEAN));
this.availableFilters.add(new BasicFilter(FilterConstants.COLLMISSID, DataType.STRING).setAnalyzed(true));
this.availableFilters.add(new I18nListFilter<Integer>(FilterConstants.STORAGE, DataType.NUMERIC).build("accession.storage", new Integer[] { 10, 11, 12,
13, 20, 30, 40, 50, 99 }));
......
......@@ -1094,7 +1094,7 @@ public class GenesysServiceImpl implements GenesysService, DatasetService {
@SuppressWarnings("resource")
final CSVWriter csv = new CSVWriter(new BufferedWriter(new OutputStreamWriter(zos)), ',', '"', '\\', "\n");
csv.writeNext(new String[] { "genesysId", "uuid", "instCode", "acceNumb", "genus", "species", "fullTaxa", "orgCty", "acqSrc", "acqDate", "mlsStat",
"available", "~storage", "sampStat", "duplSite", "createdBy", "createdDate", "lastModifiedBy", "lastModifiedDate" });
"available", "historic", "storage", "sampStat", "duplSite", "createdBy", "createdDate", "lastModifiedBy", "lastModifiedDate" });
final ResultSetHelper csvResultsetHelper = new ResultSetHelperService();
......
......@@ -486,6 +486,7 @@ public class ExplorerController extends BaseController {
overviewInstitutes(model, appliedFilters);
overviewComposition(model, appliedFilters);
overviewAvailability(model, appliedFilters);
overviewHistoric(model, appliedFilters);
overviewManagement(model, appliedFilters);
overviewSources(model, appliedFilters);
......@@ -507,6 +508,10 @@ public class ExplorerController extends BaseController {
model.addAttribute("statsAvailable", elasticService.termStatisticsAuto(appliedFilters, FilterConstants.AVAILABLE, 2));
}
private void overviewHistoric(ModelMap model, AppliedFilters appliedFilters) throws SearchException {
model.addAttribute("statsHistoric", elasticService.termStatisticsAuto(appliedFilters, FilterConstants.HISTORIC, 2));
}
private void overviewManagement(ModelMap model, AppliedFilters appliedFilters) throws SearchException {
model.addAttribute("statsStorage", elasticService.termStatisticsAuto(appliedFilters, FilterConstants.STORAGE, 30));
model.addAttribute("statsDuplSite", elasticService.termStatisticsAuto(appliedFilters, FilterConstants.DUPLSITE, 20));
......
......@@ -202,7 +202,9 @@ accession.inSvalbard=Safety duplicated in Svalbard
accession.inTrust.true=This accession is under Article 15 of the International Treaty on Plant Genetic Resources for Food and Agriculture.
accession.mlsStatus.true=This accession is in the Multilateral System of the ITPGRFA.
accession.inSvalbard.true=Safety duplicated in Svalbard Global Seed Vault.
accession.not-available-for-distribution=The accession is NOT available for distribution.
accession.not-available-for-distribution=The accession is NOT available for distribution.
accession.this-is-a-historic-entry=This is a historic record of an accession.
accession.historic=Historic entry
accession.available-for-distribution=The accession is available for distribution.
accession.elevation=Elevation
accession.geolocation=Geolocation (lat, long)
......@@ -298,6 +300,9 @@ accession.availability.=Unknown
accession.availability.true=Available
accession.availability.false=Not available
accession.historic.true=Historic
accession.historic.false=Active
accession.page.profile.title=Accession profile: {0}
accession.page.resolve.title=Multiple accessions found
accession.resolve=Multiple accessions with the name ''{0}'' found in Genesys. Select one from the list.
......@@ -355,6 +360,7 @@ filter.taxonomy.sciName=Scientific name
filter.sgsv=Safety duplicated in Svalbard
filter.mlsStatus=MLS status of the accession
filter.available=Available for distribution
filter.historic=Historic record
filter.donorCode=Donor institute
filter.duplSite=Site of safety duplication
filter.download-dwca=Download ZIP
......
......@@ -36,7 +36,14 @@
<spring:message code="accession.mlsStatus.true" />
</div>
</c:if>
<c:if test="${accession.historic eq true}">
<div class="alert alert-warning">
<spring:message code="accession.this-is-a-historic-entry" />
</div>
</c:if>
<%--
<c:if test="${accession.availability eq false}">
<div class="alert alert-warning">
<spring:message code="accession.not-available-for-distribution" />
......@@ -48,7 +55,7 @@
<spring:message code="accession.available-for-distribution" />
</div>
</c:if>
--%>
<%--
<div itemscope itemtype="http://data-vocabulary.org/Breadcrumb">
<a href="<c:url value="/wiews/${accession.institute.code}" />" itemprop="url">
......
......@@ -182,6 +182,14 @@
<c:remove var="termResult" />
<c:remove var="type" />
</div>
<div class="col-xs-12 col-sm-6 row-section">
<h4 id="stats-available"><spring:message code="filter.historic" /></h4>
<c:set var="type" value="bool" />
<c:set var="termResult" value="${statsHistoric}" />
<%@include file="termresult.jspf"%>
<c:remove var="termResult" />
<c:remove var="type" />
</div>
</div>
<h3><spring:message code="data-overview.management" /></h3>
......
......@@ -42,6 +42,7 @@
<tr>
<td class="idx-col"></td>
<td><spring:message code="accession.availability" /></td>
<td><spring:message code="accession.historic" /></td>
<td><spring:message code="accession.accessionName" /></td>
<td class="notimportant"><spring:message code="accession.taxonomy" /></td>
<%-- <td class="notimportant"><spring:message code="accession.origin" /></td> --%>
......@@ -50,9 +51,10 @@
</thead>
<tbody>
<c:forEach items="${pagedData.content}" var="accession" varStatus="status">
<tr id="a${accession.id}" class="acn targeted ${status.count % 2 == 0 ? 'even' : 'odd'} ${accession.availability and accession.institute.allowMaterialRequests ? '' : 'not-available'}">
<tr id="a${accession.id}" class="acn targeted ${status.count % 2 == 0 ? 'even' : 'odd'} ${accession.availability!=false and !accession.historic and accession.institute.allowMaterialRequests ? '' : 'not-available'}">
<td class="idx-col">${status.count + pagedData.size * pagedData.number}</td>
<td><spring:message code="accession.availability.${accession.availability}" /></td>
<td><spring:message code="accession.historic.${accession.historic}" /></td>
<td><a href="<c:url value="/acn/id/${accession.id}" />"><b><c:out value="${accession.accessionName}" /></b></a></td>
<td class="notimportant"><c:out value="${accession.taxonomy.taxonName}" /></td>
<%-- <td class="notimportant"><c:out value="${accession.countryOfOrigin.getName(pageContext.response.locale)}" /></td> --%>
......
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