created package for input and output json. Created response bean and resource bean. Common has been extended with spatial, extras and resources fields
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-catalogue/grsf-publisher-ws@132951 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
79d1ebd486
commit
34aabbcf27
|
@ -1,5 +1,11 @@
|
|||
package org.gcube.data_catalogue.grsf_publish_ws.json;
|
||||
package org.gcube.data_catalogue.grsf_publish_ws.json.input;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.custom_annotations.Group;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.custom_annotations.Tag;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.utils.groups.Source;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.utils.groups.Status;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.utils.groups.Type;
|
||||
|
@ -37,6 +43,7 @@ public class Common {
|
|||
private String catchesOrLandings;
|
||||
|
||||
@JsonProperty("database_sources")
|
||||
@Group
|
||||
private Source databaseSources;
|
||||
|
||||
@JsonProperty("source_of_information")
|
||||
|
@ -46,35 +53,34 @@ public class Common {
|
|||
private String dataOwner;
|
||||
|
||||
@JsonProperty("type")
|
||||
@Tag
|
||||
@Group
|
||||
private Type type;
|
||||
|
||||
@JsonProperty("status")
|
||||
@Tag
|
||||
private Status status;
|
||||
|
||||
@JsonProperty("resources")
|
||||
private List<Resource> resources;
|
||||
|
||||
@JsonProperty("extras")
|
||||
private Map<String, Object> properties = new HashMap<>();
|
||||
|
||||
@JsonProperty("spatial")
|
||||
private String spatial;
|
||||
|
||||
public Common() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param description
|
||||
* @param license
|
||||
* @param author
|
||||
* @param version
|
||||
* @param authorContact
|
||||
* @param maintainer
|
||||
* @param maintainerContact
|
||||
* @param catchesOrLandings
|
||||
* @param databaseSources
|
||||
* @param sourceOfInformation
|
||||
* @param dataOwner
|
||||
* @param type
|
||||
* @param status
|
||||
*/
|
||||
public Common(String description, String license, String author,
|
||||
long version, String authorContact, String maintainer,
|
||||
String maintainerContact, String catchesOrLandings,
|
||||
Source databaseSources, String sourceOfInformation,
|
||||
String dataOwner, Type type, Status status) {
|
||||
String dataOwner, Type type, Status status,
|
||||
List<Resource> resources, Map<String, Object> properties,
|
||||
String spatial) {
|
||||
super();
|
||||
this.description = description;
|
||||
this.license = license;
|
||||
|
@ -89,6 +95,17 @@ public class Common {
|
|||
this.dataOwner = dataOwner;
|
||||
this.type = type;
|
||||
this.status = status;
|
||||
this.resources = resources;
|
||||
this.properties = properties;
|
||||
this.spatial = spatial;
|
||||
}
|
||||
|
||||
public String getSpatial() {
|
||||
return spatial;
|
||||
}
|
||||
|
||||
public void setSpatial(String spatial) {
|
||||
this.spatial = spatial;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
|
@ -195,6 +212,22 @@ public class Common {
|
|||
this.status = status;
|
||||
}
|
||||
|
||||
public List<Resource> getResources() {
|
||||
return resources;
|
||||
}
|
||||
|
||||
public void setResources(List<Resource> resources) {
|
||||
this.resources = resources;
|
||||
}
|
||||
|
||||
public void setProperties(Map<String, Object> properties) {
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
public Map<String, Object> getProperties() {
|
||||
return properties;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Common [description=" + description + ", license=" + license
|
||||
|
@ -205,6 +238,8 @@ public class Common {
|
|||
+ ", databaseSources=" + databaseSources
|
||||
+ ", sourceOfInformation=" + sourceOfInformation
|
||||
+ ", dataOwner=" + dataOwner + ", type=" + type + ", status="
|
||||
+ status + "]";
|
||||
+ status + ", resources=" + resources + ", properties="
|
||||
+ properties + ", spatial=" + spatial + "]";
|
||||
}
|
||||
|
||||
}
|
|
@ -1,5 +1,7 @@
|
|||
package org.gcube.data_catalogue.grsf_publish_ws.json;
|
||||
package org.gcube.data_catalogue.grsf_publish_ws.json.input;
|
||||
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.custom_annotations.Group;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.custom_annotations.Tag;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.utils.groups.Production_System_Type;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
@ -17,6 +19,7 @@ public class FisheryRecord extends Common{
|
|||
private String fisheryId;
|
||||
|
||||
@JsonProperty("scientific_name")
|
||||
@Tag
|
||||
private String scientificName;
|
||||
|
||||
@JsonProperty("fishing_area")
|
||||
|
@ -26,18 +29,22 @@ public class FisheryRecord extends Common{
|
|||
private String exploitingStocks;
|
||||
|
||||
@JsonProperty("management_entity")
|
||||
@Tag
|
||||
private String managementEntity;
|
||||
|
||||
@JsonProperty("jurisdiction_area")
|
||||
private String jurisdictionArea;
|
||||
|
||||
@JsonProperty("production_system_type")
|
||||
@Group
|
||||
private Production_System_Type productionSystemType;
|
||||
|
||||
@JsonProperty("flag_state")
|
||||
@Tag
|
||||
private String flagState;
|
||||
|
||||
@JsonProperty("fishing_gear")
|
||||
@Tag
|
||||
private String fishingGear;
|
||||
|
||||
public FisheryRecord() {
|
|
@ -0,0 +1,61 @@
|
|||
package org.gcube.data_catalogue.grsf_publish_ws.json.input;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/**
|
||||
* A resource object bean
|
||||
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
|
||||
*/
|
||||
public class Resource {
|
||||
|
||||
@JsonProperty("url")
|
||||
private String url;
|
||||
|
||||
@JsonProperty("description")
|
||||
private String description;
|
||||
|
||||
@JsonProperty("name")
|
||||
private String name;
|
||||
|
||||
public Resource() {
|
||||
super();
|
||||
}
|
||||
|
||||
public Resource(String url, String description, String name) {
|
||||
super();
|
||||
this.url = url;
|
||||
this.description = description;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Resource [url=" + url + ", description=" + description
|
||||
+ ", name=" + name + "]";
|
||||
}
|
||||
|
||||
}
|
|
@ -1,5 +1,7 @@
|
|||
package org.gcube.data_catalogue.grsf_publish_ws.json;
|
||||
package org.gcube.data_catalogue.grsf_publish_ws.json.input;
|
||||
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.custom_annotations.Group;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.custom_annotations.Tag;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.utils.groups.Abundance_Level;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.utils.groups.Exploitation_Rate;
|
||||
|
||||
|
@ -18,6 +20,7 @@ public class StockRecord extends Common{
|
|||
private String stockID;
|
||||
|
||||
@JsonProperty("species_scientific_name")
|
||||
@Tag
|
||||
private String speciesScientificName;
|
||||
|
||||
@JsonProperty("area")
|
||||
|
@ -36,9 +39,11 @@ public class StockRecord extends Common{
|
|||
private String stateOfMarineResource;
|
||||
|
||||
@JsonProperty("exploitation_rate")
|
||||
@Group
|
||||
private Exploitation_Rate exploitationRate;
|
||||
|
||||
@JsonProperty("abundance_level")
|
||||
@Group
|
||||
private Abundance_Level abundanceLevel;
|
||||
|
||||
@JsonProperty("narrative_state_and_trend")
|
|
@ -0,0 +1,43 @@
|
|||
package org.gcube.data_catalogue.grsf_publish_ws.json.output;
|
||||
|
||||
|
||||
/**
|
||||
* A bean used to reply to a product creation method.
|
||||
* @author Costantino Perciante at ISTI-CNR
|
||||
*/
|
||||
public class ResponseCreationBean {
|
||||
|
||||
private String id;
|
||||
private String error; // in case of error
|
||||
|
||||
public ResponseCreationBean() {
|
||||
super();
|
||||
}
|
||||
|
||||
public ResponseCreationBean(String id, String error) {
|
||||
super();
|
||||
this.id = id;
|
||||
this.error = error;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getError() {
|
||||
return error;
|
||||
}
|
||||
|
||||
public void setError(String error) {
|
||||
this.error = error;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ResponseCreationBean [id=" + id + ", error=" + error + "]";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package org.gcube.data_catalogue.grsf_publish_ws.services;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.json.input.FisheryRecord;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Fishery web service methods
|
||||
* @author Costantino Perciante at ISTI-CNR
|
||||
*/
|
||||
@Path("fishery/")
|
||||
public class GrsfPublisherFisheryService {
|
||||
|
||||
// Logger
|
||||
private static final org.slf4j.Logger logger = LoggerFactory.getLogger(GrsfPublisherFisheryService.class);
|
||||
|
||||
@POST
|
||||
@Path("publish-product")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public Response publishFishery(FisheryRecord record){
|
||||
|
||||
logger.info("Incoming request for creating a fishery record");
|
||||
|
||||
// TODO
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package org.gcube.data_catalogue.grsf_publish_ws.services;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.json.input.StockRecord;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Stock web service methods
|
||||
* @author Costantino Perciante at ISTI-CNR
|
||||
*/
|
||||
@Path("stock/")
|
||||
public class GrsfPublisherStockService {
|
||||
|
||||
// Logger
|
||||
private static final org.slf4j.Logger logger = LoggerFactory.getLogger(GrsfPublisherStockService.class);
|
||||
|
||||
@POST
|
||||
@Path("publish-product")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public Response publishStock(StockRecord record){
|
||||
|
||||
logger.info("Incoming request for creating a stock record");
|
||||
|
||||
// TODO
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -7,7 +7,7 @@ import java.lang.reflect.InvocationTargetException;
|
|||
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.custom_annotations.Group;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.custom_annotations.Tag;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.json.FisheryRecord;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.json.input.FisheryRecord;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.utils.groups.Source;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.utils.groups.Type;
|
||||
import org.junit.Test;
|
||||
|
|
Loading…
Reference in New Issue