Commit eb2f50c3 authored by Matija Obreza's avatar Matija Obreza

Merge branch 'ui-18-doi-support' into 'master'

Ui 18 doi support

See merge request genesys-pgr/genesys-server!166
parents b72fe332 092f1bad
......@@ -21,6 +21,7 @@ import java.util.UUID;
import javax.servlet.http.HttpServletRequest;
import org.genesys.blocks.model.JsonViews;
import org.genesys.catalog.api.FilteredPage;
import org.genesys.catalog.service.ShortFilterService;
import org.genesys2.server.api.ApiBaseController;
......@@ -37,10 +38,13 @@ import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.HandlerMapping;
import com.fasterxml.jackson.annotation.JsonView;
import io.swagger.annotations.Api;
/**
......@@ -69,7 +73,8 @@ public class AccessionController {
* @param uuid the uuid
* @return the subset
*/
@GetMapping(value = "/{UUID}", produces = { MediaType.APPLICATION_JSON_VALUE })
@GetMapping(value = "/{UUID:\\w{8}\\-\\w{4}.+}", produces = { MediaType.APPLICATION_JSON_VALUE })
@JsonView({ JsonViews.Protected.class })
public Accession getByUuid(@PathVariable("UUID") final UUID uuid) {
return accessionService.getByUuid(uuid);
}
......@@ -81,10 +86,11 @@ public class AccessionController {
* @param uuid the uuid
* @return the subset
*/
@GetMapping(value = "/10.{dummy:[0-9]+}/**}", produces = { MediaType.APPLICATION_JSON_VALUE })
@RequestMapping(value = "/10.{dummy:[0-9]+}/**", method=RequestMethod.GET, produces = { MediaType.APPLICATION_JSON_VALUE })
@JsonView({ JsonViews.Protected.class })
public Accession getByDoi(HttpServletRequest request) {
final String fullpath = (String) request.getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE);
final String doi = fullpath.substring(1);
final String doi = fullpath.substring(API_BASE.length()+1);
return accessionService.getByDoi(doi);
}
......@@ -103,6 +109,7 @@ public class AccessionController {
* @throws IOException
*/
@PostMapping(value = "/list", produces = { MediaType.APPLICATION_JSON_VALUE })
@JsonView({ JsonViews.Public.class })
public FilteredPage<Accession> list(@RequestParam(name = "p", required = false, defaultValue = "0") final int page,
@RequestParam(name = "l", required = false, defaultValue = "50") final int pageSize,
@RequestParam(name = "d", required = false, defaultValue = "ASC") final Sort.Direction direction,
......
......@@ -104,7 +104,7 @@ public abstract class AccessionData extends AuditedVersionedModel implements IdU
@ManyToOne(cascade = {}, optional = true)
@JoinColumn(name = "orgCtyId", nullable = true)
@JsonView({ JsonViews.Minimal.class })
@JsonView({ JsonViews.Public.class })
private Country countryOfOrigin;
@Column(name = "sampStat", length = 3)
......
......@@ -92,7 +92,7 @@ public class Country extends BasicModel {
*/
@Lob
@Type(type = "org.hibernate.type.TextType")
@JsonView({ JsonViews.Public.class })
@JsonView({ JsonViews.Internal.class })
private String nameL;
@Lob
......@@ -106,7 +106,7 @@ public class Country extends BasicModel {
@ManyToOne(cascade = {}, optional = true)
@JoinColumn(name = "replacedBy")
@JsonView({ JsonViews.Public.class })
@JsonView({ JsonViews.Internal.class })
private Country replacedBy;
public Country() {
......
......@@ -40,10 +40,12 @@ import javax.persistence.Transient;
import javax.persistence.UniqueConstraint;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonView;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.commons.lang3.StringUtils;
import org.genesys.blocks.model.JsonViews;
import org.genesys.blocks.security.model.AclAwareModel;
import org.genesys2.server.model.GlobalVersionedAuditedModel;
import org.hibernate.annotations.Type;
......@@ -70,6 +72,7 @@ public class Crop extends GlobalVersionedAuditedModel implements AclAwareModel {
@ElementCollection(fetch = FetchType.LAZY)
@CollectionTable(name = "cropname", joinColumns = @JoinColumn(name = "cropId", referencedColumnName = "id"), uniqueConstraints = { @UniqueConstraint(columnNames = "otherName") })
@OrderBy("otherName")
@JsonView({ JsonViews.Public.class })
private List<String> otherNames;
@Column(nullable = false, length = 200)
......@@ -81,6 +84,7 @@ public class Crop extends GlobalVersionedAuditedModel implements AclAwareModel {
@Lob
@Type(type = "org.hibernate.type.TextType")
@JsonView({ JsonViews.Internal.class })
private String i18n;
/**
......
......@@ -84,7 +84,7 @@ public class FaoInstitute extends BasicModel implements GeoReferencedEntity, Acl
@ManyToOne(cascade = {}, optional = true)
@JoinColumn(name = "countryId")
@JsonView({ JsonViews.Minimal.class })
@JsonView({ JsonViews.Public.class })
private Country country;
@JsonView({ JsonViews.Protected.class })
......
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