Commit 8d739fef authored by Matija Obreza's avatar Matija Obreza

Merge branch 'ui-173-server-redirect-accession-by-id-to-uuid' into 'master'

added endpoint to convert accession id to uuid

See merge request genesys-pgr/genesys-server!326
parents c6fb463c 5dd8b6ef
...@@ -126,6 +126,12 @@ public class AccessionController { ...@@ -126,6 +126,12 @@ public class AccessionController {
private ObjectMapper objectMapper = new ObjectMapper(); private ObjectMapper objectMapper = new ObjectMapper();
@GetMapping(value = "/id/{id}", produces = { MediaType.APPLICATION_JSON_VALUE })
public UUID uuidFromId(@PathVariable("id") final long id) {
return accessionService.uuidFromId(id);
}
/** /**
* Gets the accession * Gets the accession
* *
......
...@@ -42,6 +42,8 @@ public interface AccessionService { ...@@ -42,6 +42,8 @@ public interface AccessionService {
*/ */
long countAccessions(AccessionFilter filter); long countAccessions(AccessionFilter filter);
UUID uuidFromId(long id);
/** /**
* List accessions by filter * List accessions by filter
* *
......
...@@ -36,6 +36,7 @@ import org.genesys.filerepository.model.ImageGallery; ...@@ -36,6 +36,7 @@ import org.genesys.filerepository.model.ImageGallery;
import org.genesys.filerepository.model.RepositoryFolder; import org.genesys.filerepository.model.RepositoryFolder;
import org.genesys.filerepository.service.ImageGalleryService; import org.genesys.filerepository.service.ImageGalleryService;
import org.genesys.filerepository.service.RepositoryService; import org.genesys.filerepository.service.RepositoryService;
import org.genesys2.server.exception.NotFoundElement;
import org.genesys2.server.model.genesys.Accession; import org.genesys2.server.model.genesys.Accession;
import org.genesys2.server.model.genesys.AccessionData; import org.genesys2.server.model.genesys.AccessionData;
import org.genesys2.server.model.genesys.AccessionId; import org.genesys2.server.model.genesys.AccessionId;
...@@ -243,6 +244,17 @@ public class AccessionServiceImpl implements AccessionService { ...@@ -243,6 +244,17 @@ public class AccessionServiceImpl implements AccessionService {
return total; return total;
} }
@Override
public UUID uuidFromId(long id) {
Accession accession = accessionRepository.getOne(id);
if (accession == null) {
throw new NotFoundElement("No accession with id " + id);
}
return accession.getUuid();
}
@Override @Override
public Set<Long> filterAvailableForDistributionByUuid(Set<UUID> accessionUuids) { public Set<Long> filterAvailableForDistributionByUuid(Set<UUID> accessionUuids) {
if (accessionUuids == null || accessionUuids.size() == 0) { if (accessionUuids == null || accessionUuids.size() == 0) {
......
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