321 lines
8.5 KiB
Java
321 lines
8.5 KiB
Java
package org.gcube.data_catalogue.grsf_publish_ws.json.input.record;
|
|
|
|
import java.util.List;
|
|
|
|
import javax.validation.Valid;
|
|
import javax.validation.constraints.NotNull;
|
|
import javax.validation.constraints.Size;
|
|
|
|
import org.gcube.data_catalogue.grsf_publish_ws.custom_annotations.CkanResource;
|
|
import org.gcube.data_catalogue.grsf_publish_ws.custom_annotations.CustomField;
|
|
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.custom_annotations.TimeSeries;
|
|
import org.gcube.data_catalogue.grsf_publish_ws.json.input.others.RefersToBean;
|
|
import org.gcube.data_catalogue.grsf_publish_ws.json.input.others.Resource;
|
|
import org.gcube.data_catalogue.grsf_publish_ws.json.input.others.SimilarRecordBean;
|
|
import org.gcube.data_catalogue.grsf_publish_ws.json.input.others.TimeSeriesBean;
|
|
import org.gcube.data_catalogue.grsf_publish_ws.utils.CommonServiceUtils;
|
|
import org.gcube.data_catalogue.grsf_publish_ws.utils.groups.Sources;
|
|
import org.gcube.data_catalogue.grsf_publish_ws.utils.groups.Status;
|
|
|
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
|
|
|
/**
|
|
* Information that both Stock and Fishery records must contain.
|
|
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
|
|
*/
|
|
@JsonIgnoreProperties(value = {"grsf_type", "source"})
|
|
public class Common extends Base{
|
|
|
|
public static final String UUID_KB_KEY = "GRSF UUID";
|
|
public static final String DOMAIN = "Domain";
|
|
|
|
// it is added in case of GRSF record
|
|
@JsonProperty("data_owner")
|
|
@CustomField(key="Data owner")
|
|
private List<String> dataOwner;
|
|
|
|
@JsonProperty("database_sources")
|
|
@CkanResource
|
|
@Valid
|
|
private List<Resource<Sources>> databaseSources;
|
|
|
|
@JsonProperty("source_of_information")
|
|
@CkanResource
|
|
@Valid
|
|
private List<Resource<String>> sourceOfInformation;
|
|
|
|
@JsonProperty("refers_to")
|
|
@Valid
|
|
private List<RefersToBean> refersTo;
|
|
|
|
@JsonProperty("short_name")
|
|
@CustomField(key="Short Name")
|
|
private String shortName;
|
|
|
|
@JsonProperty("traceability_flag")
|
|
@CustomField(key="Traceability Flag")
|
|
@Group(condition="true", groupNameOverValue="traceability-flag") // record is added to group traceability-flag if Traceability Flag is true
|
|
private Boolean traceabilityFlag;
|
|
|
|
@JsonProperty("status_grsf_record")
|
|
@CustomField(key="Status of the GRSF record")
|
|
@Tag
|
|
private Status status;
|
|
|
|
// automatically compiled
|
|
@CustomField(key=CommonServiceUtils.SYSTEM_TYPE)
|
|
private String systemType;
|
|
|
|
@JsonProperty("catches")
|
|
@CustomField(key="Catches")
|
|
@TimeSeries
|
|
@Valid
|
|
private List<TimeSeriesBean<String, String>> catches;
|
|
|
|
@JsonProperty("landings")
|
|
@CustomField(key="Landings")
|
|
@TimeSeries
|
|
@Valid
|
|
private List<TimeSeriesBean<String, String>> landings;
|
|
|
|
@JsonProperty("species")
|
|
@CustomField(key="Species")
|
|
@Tag
|
|
private List<String> species;
|
|
|
|
@JsonProperty("similar_grsf_records")
|
|
@CustomField(key="Similar GRSF Records")
|
|
private List<SimilarRecordBean> similarGRSFRecords;
|
|
|
|
@JsonProperty("similar_source_records")
|
|
@CustomField(key="Similar Source Records")
|
|
private List<SimilarRecordBean> similarSourceRecords;
|
|
|
|
// automatically set
|
|
@CustomField(key=DOMAIN)
|
|
private String domain;
|
|
|
|
@JsonProperty("grsf_uuid")
|
|
@CustomField(key=UUID_KB_KEY)
|
|
@NotNull(message="grsf_uuid cannot be null")
|
|
@Size(min=1, message="grsf_uuid cannot be empty")
|
|
private String uuid;
|
|
|
|
public Common() {
|
|
super();
|
|
}
|
|
|
|
/**
|
|
* @param dataOwner
|
|
* @param databaseSources
|
|
* @param sourceOfInformation
|
|
* @param refersTo
|
|
* @param shortName
|
|
* @param traceabilityFlag
|
|
* @param status
|
|
* @param systemType
|
|
* @param catches
|
|
* @param landings
|
|
* @param species
|
|
* @param similarGRSFRecords
|
|
* @param similarSourceRecords
|
|
* @param domain
|
|
* @param uuid
|
|
*/
|
|
public Common(List<String> dataOwner,
|
|
List<Resource<Sources>> databaseSources,
|
|
List<Resource<String>> sourceOfInformation,
|
|
List<RefersToBean> refersTo, String shortName,
|
|
Boolean traceabilityFlag, Status status, String systemType,
|
|
List<TimeSeriesBean<String, String>> catches,
|
|
List<TimeSeriesBean<String, String>> landings,
|
|
List<String> species, List<SimilarRecordBean> similarGRSFRecords,
|
|
List<SimilarRecordBean> similarSourceRecords, String domain,
|
|
String uuid) {
|
|
super();
|
|
this.dataOwner = dataOwner;
|
|
this.databaseSources = databaseSources;
|
|
this.sourceOfInformation = sourceOfInformation;
|
|
this.refersTo = refersTo;
|
|
this.shortName = shortName;
|
|
this.traceabilityFlag = traceabilityFlag;
|
|
this.status = status;
|
|
this.systemType = systemType;
|
|
this.catches = catches;
|
|
this.landings = landings;
|
|
this.species = species;
|
|
this.similarGRSFRecords = similarGRSFRecords;
|
|
this.similarSourceRecords = similarSourceRecords;
|
|
this.domain = domain;
|
|
this.uuid = uuid;
|
|
}
|
|
|
|
public String getDomain() {
|
|
return domain;
|
|
}
|
|
|
|
public void setDomain(String domain) {
|
|
this.domain = domain;
|
|
}
|
|
|
|
public String getUuid() {
|
|
return uuid;
|
|
}
|
|
|
|
public void setUuid(String uuid) {
|
|
this.uuid = uuid;
|
|
}
|
|
|
|
public String getSystemType() {
|
|
return systemType;
|
|
}
|
|
|
|
public void setSystemType(String systemType) {
|
|
this.systemType = systemType;
|
|
}
|
|
|
|
public Boolean getTraceabilityFlag() {
|
|
return traceabilityFlag;
|
|
}
|
|
|
|
public List<RefersToBean> getRefersTo() {
|
|
return refersTo;
|
|
}
|
|
|
|
public void setRefersTo(List<RefersToBean> refersTo) {
|
|
this.refersTo = refersTo;
|
|
}
|
|
public List<Resource<Sources>> getDatabaseSources() {
|
|
return databaseSources;
|
|
}
|
|
|
|
public void setDatabaseSources(List<Resource<Sources>> databaseSources) {
|
|
this.databaseSources = databaseSources;
|
|
}
|
|
|
|
public List<Resource<String>> getSourceOfInformation() {
|
|
return sourceOfInformation;
|
|
}
|
|
|
|
public void setSourceOfInformation(List<Resource<String>> sourceOfInformation) {
|
|
this.sourceOfInformation = sourceOfInformation;
|
|
}
|
|
|
|
public String getShortName() {
|
|
return shortName;
|
|
}
|
|
|
|
public void setShortName(String shortName) {
|
|
this.shortName = shortName;
|
|
}
|
|
|
|
public Boolean isTraceabilityFlag() {
|
|
return traceabilityFlag;
|
|
}
|
|
|
|
public void setTraceabilityFlag(Boolean traceabilityFlag) {
|
|
this.traceabilityFlag = traceabilityFlag;
|
|
}
|
|
|
|
public Status getStatus() {
|
|
return status;
|
|
}
|
|
|
|
public void setStatus(Status status) {
|
|
this.status = status;
|
|
}
|
|
|
|
public List<String> getSpecies() {
|
|
return species;
|
|
}
|
|
|
|
public void setSpecies(List<String> species) {
|
|
this.species = species;
|
|
}
|
|
|
|
public List<TimeSeriesBean<String, String>> getCatches() {
|
|
return catches;
|
|
}
|
|
|
|
public void setCatches(List<TimeSeriesBean<String, String>> catches) {
|
|
this.catches = catches;
|
|
}
|
|
|
|
public List<TimeSeriesBean<String, String>> getLandings() {
|
|
return landings;
|
|
}
|
|
|
|
public void setLandings(List<TimeSeriesBean<String, String>> landings) {
|
|
this.landings = landings;
|
|
}
|
|
|
|
public List<String> getDataOwner() {
|
|
return dataOwner;
|
|
}
|
|
|
|
public void setDataOwner(List<String> dataOwner) {
|
|
this.dataOwner = dataOwner;
|
|
}
|
|
|
|
public List<SimilarRecordBean> getSimilarGRSFRecords() {
|
|
return similarGRSFRecords;
|
|
}
|
|
|
|
public void setSimilarGRSFRecords(List<SimilarRecordBean> similarGRSFRecords) {
|
|
this.similarGRSFRecords = similarGRSFRecords;
|
|
}
|
|
|
|
public List<SimilarRecordBean> getSimilarSourceRecords() {
|
|
return similarSourceRecords;
|
|
}
|
|
|
|
public void setSimilarSourceRecords(List<SimilarRecordBean> similarSourceRecords) {
|
|
this.similarSourceRecords = similarSourceRecords;
|
|
}
|
|
|
|
/**
|
|
* Clean the semantic id
|
|
* @param id
|
|
* @return
|
|
*/
|
|
public static String cleanSemanticId(String id){
|
|
|
|
if(id == null)
|
|
return null;
|
|
else{
|
|
String idmodified = "";
|
|
if(id != null){
|
|
|
|
String[] splitCodesValues = id.split("\\+");
|
|
for (int i = 0; i < splitCodesValues.length; i++) {
|
|
String prefixAndCode = splitCodesValues[i];
|
|
String prefix = prefixAndCode.split(":")[0];
|
|
String code = prefixAndCode.split(":")[1];
|
|
idmodified += prefix.toLowerCase() + ":" + code.toUpperCase();
|
|
if(splitCodesValues.length > 1 && i < (splitCodesValues.length - 1))
|
|
idmodified += "+";
|
|
}
|
|
}
|
|
return idmodified;
|
|
}
|
|
|
|
}
|
|
|
|
@Override
|
|
public String toString() {
|
|
return "Common [dataOwner=" + dataOwner + ", databaseSources="
|
|
+ databaseSources + ", sourceOfInformation="
|
|
+ sourceOfInformation + ", refersTo=" + refersTo
|
|
+ ", shortName=" + shortName + ", traceabilityFlag="
|
|
+ traceabilityFlag + ", status=" + status + ", systemType="
|
|
+ systemType + ", catches=" + catches + ", landings="
|
|
+ landings + ", species=" + species + ", similarGRSFRecords="
|
|
+ similarGRSFRecords + ", similarSourceRecords="
|
|
+ similarSourceRecords + ", domain=" + domain + ", uuid="
|
|
+ uuid + "]";
|
|
}
|
|
|
|
} |