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

Generated UUIDs when missing and include in RDF and HTML

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