Commit 4b2a725e authored by Matija Obreza's avatar Matija Obreza
Browse files

Generated UUIDs when missing and include in RDF and HTML

parent f6ca37a6
......@@ -37,7 +37,7 @@ import org.genesys2.server.model.VersionedAuditedModel;
@Table(name = "acce")
public class AccessionId extends VersionedAuditedModel implements IdUUID {
@Column(columnDefinition = "binary(16)", updatable = false)
@Column(columnDefinition = "binary(16)")
protected UUID uuid;
@PrePersist
......
......@@ -16,9 +16,16 @@
package org.genesys2.server.persistence.domain;
import java.util.List;
import org.genesys2.server.model.genesys.AccessionId;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
public interface AccessionIdRepository extends JpaRepository<AccessionId, Long> {
@Query("select aid from AccessionId aid where aid.uuid is null")
List<AccessionId> findMissingUuid(Pageable pageable);
}
......@@ -217,5 +217,7 @@ public interface GenesysService {
Set<AccessionDetails> getAccessionDetails(Collection<Long> accessionIds);
int assignMissingUuid(int count);
}
......@@ -31,6 +31,7 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
......@@ -102,6 +103,7 @@ import org.springframework.cache.annotation.CacheEvict;
import org.springframework.dao.IncorrectResultSizeDataAccessException;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.repository.query.Param;
import org.springframework.jdbc.core.RowCallbackHandler;
......@@ -1508,4 +1510,18 @@ public class GenesysServiceImpl implements GenesysService, DatasetService {
return accessionRepository.listAccessionsIds(taxonomy);
}
@Override
@Transactional
public int assignMissingUuid(int count) {
List<AccessionId> accessionIds = accessionIdRepository.findMissingUuid(new PageRequest(0, count));
for (AccessionId accessionId : accessionIds) {
if (accessionId.getUuid()==null) {
accessionId.setUuid(UUID.randomUUID());
}
}
accessionIdRepository.save(accessionIds);
LOG.info("Generated " + accessionIds.size() + " new UUIDs");
return accessionIds.size();
}
}
......@@ -354,4 +354,12 @@ public class AdminController {
}
return "redirect:/admin/";
}
@RequestMapping("/assign-uuid")
public String assignUuid() {
while (genesysService.assignMissingUuid(100)>0) {
}
return "redirect:/admin/";
}
}
......@@ -25,7 +25,7 @@ db.url=jdbc:mysql://localhost/genesys5?useUnicode=true&characterEncoding=UTF-8&u
db.driverClassName=com.mysql.jdbc.Driver
db.username=root
db.password=
db.showSql=true
db.showSql=false
db.hbm2ddl=false
hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
......
......@@ -5,6 +5,7 @@
<html lang="${pageContext.response.locale.language}" dir="${pageContext.response.locale.language=='fa' || pageContext.response.locale.language=='ar' ? 'rtl' : 'ltr'}"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:schema="http://schema.org/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:dwc="http://rs.tdwg.org/dwc/terms/"
xmlns:germplasm="http://purl.org/germplasm/germplasmTerm#"
xmlns:germplasmType="http://purl.org/germplasm/germplasmType#"
......
......@@ -3,6 +3,7 @@
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix wgs84_pos: <http://www.w3.org/2003/01/geo/wgs84_pos#> .
@prefix dc: <http://purl.org/dc/elements/1.1/> .
# using DarwinCore
@prefix dwc: <http://rs.tdwg.org/dwc/terms/> .
# using https://code.google.com/p/darwincore-germplasm/
......@@ -13,6 +14,7 @@
<http://www.genesys-pgr.org/acn/id/${accession.id}>
a germplasm:GermplasmAccession;
germplasm:germplasmID "<c:out value="${accession.id}" />";
dc:identifier "urn:uuid:<c:out value="${accession.uuid}" />";
dwc:catalogNumber "<c:out value="${accession.accessionName}" />";
dwc:institutionCode "<c:out value="${accession.instituteCode}" />";
dwc:instituteId "<c:out value="${accession.institute.id}" />";
......
......@@ -103,16 +103,6 @@
</div>
<div class="crop-details">
<c:if test="${accession.uuid ne null}">
<div class="row text-muted">
<div class="col-xs-4"><spring:message code="accession.uuid" /></div>
<div class="col-xs-8"><c:out value="${accession.uuid}" /></div>
</div>
<div class="row">
<div class="col-xs-4"><spring:message code="accession.purl" /></div>
<div class="col-xs-8"><a href="https://purl.org/germplasm/id/${accession.uuid}"><c:out value="https://purl.org/germplasm/id/${accession.uuid}" /></a></div>
</div>
</c:if>
<div class="row">
<div class="col-xs-4"><spring:message code="accession.holdingInstitute" /></div>
<div class="col-xs-8"><a property="dwc:institutionCode" href="<c:url value="/wiews/${accession.instituteCode}" />"> <c:out value="${accession.institute.fullName}" />
......@@ -224,6 +214,17 @@
<div class="col-xs-4"><spring:message code="accession.donor.accessionNumber" /></div>
<div class="col-xs-8">${accessionExchange.accNumbDonor}</div>
</div>
<c:if test="${accession.uuid ne null}">
<div class="row text-muted">
<div class="col-xs-4"><spring:message code="accession.uuid" /></div>
<div class="col-xs-8"><span property="dc:identifier">urn:uuid:<c:out value="${accession.uuid}" /></span></div>
</div>
<div class="row">
<div class="col-xs-4"><spring:message code="accession.purl" /></div>
<div class="col-xs-8"><span property="dc:identifier"><a href="https://purl.org/germplasm/id/${accession.uuid}"><c:out value="https://purl.org/germplasm/id/${accession.uuid}" /></a></span></div>
</div>
</c:if>
</c:if>
<c:if test="${accessionCollect ne null}">
......
......@@ -8,119 +8,124 @@
<title><spring:message code="admin.page.title" /></title>
</head>
<body>
<h1>
<spring:message code="admin.page.title" />
</h1>
<%@ include file="/WEB-INF/jsp/admin/menu.jsp" %>
<h3>Full-text Search</h3>
<form method="post" action="<c:url value="/admin/reindex-elastic" />">
<input type="text" name="startAt" disabled="true" />
<input type="text" name="filter" />
<label>
<input type="checkbox" name="slow" value="false" /> No sleep
</label>
<input type="submit" class="btn btn-default" value="ES reindex" />
<!-- CSRF protection -->
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}"/>
</form>
<form method="post" action="<c:url value="/admin/clear-queues" />">
<input type="submit" class="btn btn-default" value="Clear ES update queues" />
<!-- CSRF protection -->
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}"/>
</form>
<h3>Country data</h3>
<form method="post" action="<c:url value="/admin/refreshCountries" />">
<input type="submit" class="btn btn-default" value="Refresh country data" />
<!-- CSRF protection -->
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}"/>
</form>
<form method="post" action="<c:url value="/admin/updateAlternateNames" />">
<input type="submit" class="btn btn-default" value="Update alternate GEO names" />
<!-- CSRF protection -->
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}"/>
</form>
<form method="post" action="<c:url value="/admin/updateITPGRFA" />">
<input type="submit" class="btn btn-default" class="btn btn-default" value="Update country ITPGRFA status" />
<!-- CSRF protection -->
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}"/>
</form>
<h3>WIEWS</h3>
<form method="post" action="<c:url value="/admin/refreshWiews" />">
<input type="submit" class="btn btn-default" value="Refresh WIEWS data" />
<!-- CSRF protection -->
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}"/>
</form>
<h3>Svalbard Global Seed Vault</h3>
<form method="post" action="<c:url value="/admin/updateSGSV" />">
<input type="submit" class="btn btn-default" value="Update SGSV" />
<!-- CSRF protection -->
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}"/>
</form>
<h3>Accession</h3>
<form method="post" action="<c:url value="/admin/updateAccessionCountryRefs" />">
<input type="submit" class="btn btn-default" class="btn btn-default" value="Update accession country info" />
<!-- CSRF protection -->
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}"/>
</form>
<form method="post" action="<c:url value="/admin/updateInstituteCountryRefs" />">
<input type="submit" class="btn btn-default" class="btn btn-default" value="Update WIEWS country info" />
<!-- CSRF protection -->
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}"/>
</form>
<form method="post" action="<c:url value="/admin/updateAccessionInstituteRefs" />">
<input type="submit" class="btn btn-default" value="Update accession institute info" />
<!-- CSRF protection -->
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}"/>
</form>
<form method="post" action="<c:url value="/admin/convertNames" />">
<input type="submit" class="btn btn-default" value="Convert old names to aliases" />
<!-- CSRF protection -->
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}"/>
</form>
<h3>C&E</h3>
<form method="post" action="<c:url value="/admin/refreshMetadataMethods" />">
<input type="submit" class="btn btn-default" class="btn btn-default" value="Recalculate metadata methods" />
<!-- CSRF protection -->
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}"/>
</form>
<h3>Content</h3>
<form method="post" action="<c:url value="/admin/sanitize" />">
<input type="submit" class="btn btn-default" value="Sanitize HTML content" />
<!-- CSRF protection -->
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}"/>
</form>
<h3>Full-text Search</h3>
<form method="post" action="<c:url value="/admin/reindexEverything" />">
<input type="submit" class="btn btn-default" class="btn btn-default" value="Reindex search indexes" />
<!-- CSRF protection -->
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}"/>
</form>
<form method="post" action="<c:url value="/admin/reindexEntity" />">
<select name="entity">
<option value="org.genesys2.server.model.impl.Country">Countries</option>
<option value="org.genesys2.server.model.impl.FaoInstitute">WIEWS Institutes</option>
<option value="org.genesys2.server.model.impl.ActivityPost">Posts</option>
<option value="org.genesys2.server.model.impl.Article">Articles</option>
<option value="org.genesys2.server.model.impl.Organization">Organizations</option>
<option value="org.genesys2.server.model.genesys.Accession">Accessions</option>
<option value="org.genesys2.server.model.genesys.AccessionAlias">Accession alias</option>
<option value="org.genesys2.server.model.genesys.Taxonomy2">Taxonomy2</option>
</select> <input type="submit" class="btn btn-default" value="Reindex search indexes" />
<!-- CSRF protection -->
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}"/>
</form>
<h1>
<spring:message code="admin.page.title" />
</h1>
<%@ include file="/WEB-INF/jsp/admin/menu.jsp"%>
<form method="post" action="<c:url value="/admin/assign-uuid" />">
<input type="submit" class="btn btn-default" value="Assign missing UUIDs" />
<!-- CSRF protection -->
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}" />
</form>
<h3>Full-text Search</h3>
<form method="post" action="<c:url value="/admin/reindex-elastic" />">
<input type="text" name="startAt" disabled="disabled" /> <input type="text" name="filter" /> <label> <input
type="checkbox" name="slow" value="false"
/> No sleep
</label> <input type="submit" class="btn btn-default" value="ES reindex" />
<!-- CSRF protection -->
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}" />
</form>
<form method="post" action="<c:url value="/admin/clear-queues" />">
<input type="submit" class="btn btn-default" value="Clear ES update queues" />
<!-- CSRF protection -->
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}" />
</form>
<h3>Country data</h3>
<form method="post" action="<c:url value="/admin/refreshCountries" />">
<input type="submit" class="btn btn-default" value="Refresh country data" />
<!-- CSRF protection -->
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}" />
</form>
<form method="post" action="<c:url value="/admin/updateAlternateNames" />">
<input type="submit" class="btn btn-default" value="Update alternate GEO names" />
<!-- CSRF protection -->
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}" />
</form>
<form method="post" action="<c:url value="/admin/updateITPGRFA" />">
<input type="submit" class="btn btn-default" class="btn btn-default" value="Update country ITPGRFA status" />
<!-- CSRF protection -->
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}" />
</form>
<h3>WIEWS</h3>
<form method="post" action="<c:url value="/admin/refreshWiews" />">
<input type="submit" class="btn btn-default" value="Refresh WIEWS data" />
<!-- CSRF protection -->
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}" />
</form>
<h3>Svalbard Global Seed Vault</h3>
<form method="post" action="<c:url value="/admin/updateSGSV" />">
<input type="submit" class="btn btn-default" value="Update SGSV" />
<!-- CSRF protection -->
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}" />
</form>
<h3>Accession</h3>
<form method="post" action="<c:url value="/admin/updateAccessionCountryRefs" />">
<input type="submit" class="btn btn-default" class="btn btn-default" value="Update accession country info" />
<!-- CSRF protection -->
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}" />
</form>
<form method="post" action="<c:url value="/admin/updateInstituteCountryRefs" />">
<input type="submit" class="btn btn-default" class="btn btn-default" value="Update WIEWS country info" />
<!-- CSRF protection -->
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}" />
</form>
<form method="post" action="<c:url value="/admin/updateAccessionInstituteRefs" />">
<input type="submit" class="btn btn-default" value="Update accession institute info" />
<!-- CSRF protection -->
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}" />
</form>
<form method="post" action="<c:url value="/admin/convertNames" />">
<input type="submit" class="btn btn-default" value="Convert old names to aliases" />
<!-- CSRF protection -->
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}" />
</form>
<h3>C&amp;E</h3>
<form method="post" action="<c:url value="/admin/refreshMetadataMethods" />">
<input type="submit" class="btn btn-default" class="btn btn-default" value="Recalculate metadata methods" />
<!-- CSRF protection -->
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}" />
</form>
<h3>Content</h3>
<form method="post" action="<c:url value="/admin/sanitize" />">
<input type="submit" class="btn btn-default" value="Sanitize HTML content" />
<!-- CSRF protection -->
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}" />
</form>
<h3>Full-text Search</h3>
<form method="post" action="<c:url value="/admin/reindexEverything" />">
<input type="submit" class="btn btn-default" class="btn btn-default" value="Reindex search indexes" />
<!-- CSRF protection -->
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}" />
</form>
<form method="post" action="<c:url value="/admin/reindexEntity" />">
<select name="entity">
<option value="org.genesys2.server.model.impl.Country">Countries</option>
<option value="org.genesys2.server.model.impl.FaoInstitute">WIEWS Institutes</option>
<option value="org.genesys2.server.model.impl.ActivityPost">Posts</option>
<option value="org.genesys2.server.model.impl.Article">Articles</option>
<option value="org.genesys2.server.model.impl.Organization">Organizations</option>
<option value="org.genesys2.server.model.genesys.Accession">Accessions</option>
<option value="org.genesys2.server.model.genesys.AccessionAlias">Accession alias</option>
<option value="org.genesys2.server.model.genesys.Taxonomy2">Taxonomy2</option>
</select> <input type="submit" class="btn btn-default" value="Reindex search indexes" />
<!-- CSRF protection -->
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}" />
</form>
</body>
</html>
\ No newline at end of file
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