diff --git a/src/main/java/org/genesys2/server/model/genesys/AccessionId.java b/src/main/java/org/genesys2/server/model/genesys/AccessionId.java index f12c103c31d8740ff823499afc00265668390bc2..e3cb2be8b177147822c2dbd3631bc02c9e065c83 100644 --- a/src/main/java/org/genesys2/server/model/genesys/AccessionId.java +++ b/src/main/java/org/genesys2/server/model/genesys/AccessionId.java @@ -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 diff --git a/src/main/java/org/genesys2/server/persistence/domain/AccessionIdRepository.java b/src/main/java/org/genesys2/server/persistence/domain/AccessionIdRepository.java index be75e925c69613ce92df8c29ca40dc34466f63ab..cee4b01205ceb7541cd10500abb2c3c529890474 100644 --- a/src/main/java/org/genesys2/server/persistence/domain/AccessionIdRepository.java +++ b/src/main/java/org/genesys2/server/persistence/domain/AccessionIdRepository.java @@ -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 { + @Query("select aid from AccessionId aid where aid.uuid is null") + List findMissingUuid(Pageable pageable); + } diff --git a/src/main/java/org/genesys2/server/service/GenesysService.java b/src/main/java/org/genesys2/server/service/GenesysService.java index 4cce502740856a616f279dda594d6fe0f795184b..7a85857592cf59e27ebd9ff3818b75ced2089aec 100644 --- a/src/main/java/org/genesys2/server/service/GenesysService.java +++ b/src/main/java/org/genesys2/server/service/GenesysService.java @@ -217,5 +217,7 @@ public interface GenesysService { Set getAccessionDetails(Collection accessionIds); + int assignMissingUuid(int count); + } diff --git a/src/main/java/org/genesys2/server/service/impl/GenesysServiceImpl.java b/src/main/java/org/genesys2/server/service/impl/GenesysServiceImpl.java index 8f28530ad5b7f608b8c2957edc0388a97c60c10b..fe5b04c84586d854325a41008cd23043db276e99 100644 --- a/src/main/java/org/genesys2/server/service/impl/GenesysServiceImpl.java +++ b/src/main/java/org/genesys2/server/service/impl/GenesysServiceImpl.java @@ -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 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(); + } + } diff --git a/src/main/java/org/genesys2/server/servlet/controller/admin/AdminController.java b/src/main/java/org/genesys2/server/servlet/controller/admin/AdminController.java index eaa8445fc1d2a634699230ca77e8e7179fce23b3..c53dc2cc63fc442d56857f5fa6a0a4244da4256e 100644 --- a/src/main/java/org/genesys2/server/servlet/controller/admin/AdminController.java +++ b/src/main/java/org/genesys2/server/servlet/controller/admin/AdminController.java @@ -354,4 +354,12 @@ public class AdminController { } return "redirect:/admin/"; } + + @RequestMapping("/assign-uuid") + public String assignUuid() { + while (genesysService.assignMissingUuid(100)>0) { + + } + return "redirect:/admin/"; + } } diff --git a/src/main/resources/spring/spring.properties b/src/main/resources/spring/spring.properties index 508e20cacdd26b60bbaef5ec829444bf94f95f10..9330a36e27b358fdebed724b335a055b60c17691 100644 --- a/src/main/resources/spring/spring.properties +++ b/src/main/resources/spring/spring.properties @@ -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 diff --git a/src/main/webapp/WEB-INF/decorator/main.jsp b/src/main/webapp/WEB-INF/decorator/main.jsp index 3f6686a8cfe01ee5850261a9bccffa6c251e6068..4e2dbe64e2513a9862544905935541bff2167804 100644 --- a/src/main/webapp/WEB-INF/decorator/main.jsp +++ b/src/main/webapp/WEB-INF/decorator/main.jsp @@ -5,6 +5,7 @@ . @prefix wgs84_pos: . +@prefix dc: . # using DarwinCore @prefix dwc: . # using https://code.google.com/p/darwincore-germplasm/ @@ -13,6 +14,7 @@ a germplasm:GermplasmAccession; germplasm:germplasmID ""; + dc:identifier "urn:uuid:"; dwc:catalogNumber ""; dwc:institutionCode ""; dwc:instituteId ""; diff --git a/src/main/webapp/WEB-INF/jsp/accession/details.jsp b/src/main/webapp/WEB-INF/jsp/accession/details.jsp index 28c379ed6718a95eb8cdf8b64c41c44766946a09..d9dc6a87ea08cbfd43233dcaeb32614103af66f9 100644 --- a/src/main/webapp/WEB-INF/jsp/accession/details.jsp +++ b/src/main/webapp/WEB-INF/jsp/accession/details.jsp @@ -103,16 +103,6 @@
- -
-
-
-
-
-
-
-
-
+ + +
+
+
urn:uuid:
+
+
+ diff --git a/src/main/webapp/WEB-INF/jsp/admin/index.jsp b/src/main/webapp/WEB-INF/jsp/admin/index.jsp index 95dac61c7db2fb71626e78dc36b576e5fb6b3b67..a5afba86333a95cf046d735d2b1b2b27eb0bccc9 100644 --- a/src/main/webapp/WEB-INF/jsp/admin/index.jsp +++ b/src/main/webapp/WEB-INF/jsp/admin/index.jsp @@ -8,119 +8,124 @@ <spring:message code="admin.page.title" /> -

- -

- - <%@ include file="/WEB-INF/jsp/admin/menu.jsp" %> - -

Full-text Search

-
"> - - - - - - -
- -
"> - - - -
- -

Country data

-
"> - - - -
-
"> - - - -
-
"> - - - -
- - - -

WIEWS

-
"> - - - -
- -

Svalbard Global Seed Vault

-
"> - - - -
- -

Accession

-
"> - - - -
-
"> - - - -
-
"> - - - -
-
"> - - - -
-

C&E

-
"> - - - -
- -

Content

-
"> - - - -
- -

Full-text Search

-
"> - - - -
- -
"> - - - -
+

+ +

+ + <%@ include file="/WEB-INF/jsp/admin/menu.jsp"%> + +
"> + + + +
+ + +

Full-text Search

+
"> + + + +
+ +
"> + + + +
+ +

Country data

+
"> + + + +
+
"> + + + +
+
"> + + + +
+ + + +

WIEWS

+
"> + + + +
+ +

Svalbard Global Seed Vault

+
"> + + + +
+ +

Accession

+
"> + + + +
+
"> + + + +
+
"> + + + +
+
"> + + + +
+

C&E

+
"> + + + +
+ +

Content

+
"> + + + +
+ +

Full-text Search

+
"> + + + +
+ +
"> + + + +
\ No newline at end of file