some minor changes: Product Type changed to GRSF Type, Record Type changed to Source

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-catalogue/grsf-publisher-ws@142718 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Costantino Perciante 2017-02-17 17:05:41 +00:00
parent 90a19689f5
commit 3c9b149d54
6 changed files with 56 additions and 68 deletions

View File

@ -8,7 +8,6 @@ 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.utils.groups.Record_Type;
import org.gcube.data_catalogue.grsf_publish_ws.utils.groups.Sources;
import org.gcube.data_catalogue.grsf_publish_ws.utils.groups.Status;
@ -19,12 +18,12 @@ 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 = {"product_type"})
@JsonIgnoreProperties(value = {"grsf_type", "source"})
public class Common extends Base{
public static final String PRODUCT_TYPE_KEY = "Product type"; // stock, fishery
public static final String RECORD_TYPE_KEY = "Record type"; // aggregated, source
public static final String GRSF_TYPE_KEY = "GRSF type"; // stock, fishery
public static final String SOURCE_KEY = "Source"; // in case it is a RAM/FIRMS/FishSource record it is not added
// it is added in case of GRSF record
@JsonProperty("data_owner")
@CustomField(key="Data owner")
@Tag
@ -64,16 +63,16 @@ public class Common extends Base{
private Long reportingYear;
// automatically compiled
@JsonProperty("product_type")
@CustomField(key=PRODUCT_TYPE_KEY)
@JsonProperty("grsf_type")
@CustomField(key=GRSF_TYPE_KEY)
//@Tag
//@Group
private String productType;
private String grsfType;
// automatically compiled
@JsonProperty("record_type")
@CustomField(key=RECORD_TYPE_KEY)
private Record_Type recordType;
@JsonProperty("source")
@CustomField(key=SOURCE_KEY)
private String sourceType;
public Common() {
super();
@ -84,7 +83,7 @@ public class Common extends Base{
List<Resource<String>> sourceOfInformation,
List<RefersToBean> refersTo, String shortTitle,
Boolean traceabilityFlag, Status status, Long reportingYear,
String productType, Record_Type recordType) {
String grsfType, String sourceType) {
super();
this.dataOwner = dataOwner;
this.databaseSources = databaseSources;
@ -94,18 +93,30 @@ public class Common extends Base{
this.traceabilityFlag = traceabilityFlag;
this.status = status;
this.reportingYear = reportingYear;
this.productType = productType;
this.recordType = recordType;
this.grsfType = grsfType;
this.sourceType = sourceType;
}
public Record_Type getRecordType() {
return recordType;
public String getGrsfType() {
return grsfType;
}
public void setRecordType(Record_Type recordType) {
this.recordType = recordType;
public void setGrsfType(String grsfType) {
this.grsfType = grsfType;
}
public String getSourceType() {
return sourceType;
}
public void setSourceType(String sourceType) {
this.sourceType = sourceType;
}
public Boolean getTraceabilityFlag() {
return traceabilityFlag;
}
@ -142,14 +153,6 @@ public class Common extends Base{
this.sourceOfInformation = sourceOfInformation;
}
public String getProductType() {
return productType;
}
public void setProductType(String productType) {
this.productType = productType;
}
public String getDataOwner() {
return dataOwner;
}
@ -182,6 +185,7 @@ public class Common extends Base{
this.status = status;
}
@Override
public String toString() {
return "Common [dataOwner=" + dataOwner + ", databaseSources="
@ -189,8 +193,7 @@ public class Common extends Base{
+ sourceOfInformation + ", refersTo=" + refersTo
+ ", shortTitle=" + shortTitle + ", traceabilityFlag="
+ traceabilityFlag + ", status=" + status + ", reportingYear="
+ reportingYear + ", productType=" + productType
+ ", recordType=" + recordType + "]";
+ reportingYear + ", grsfType=" + grsfType + ", sourceType="
+ sourceType + "]";
}
}

View File

@ -50,6 +50,7 @@ public class StockRecord extends Common{
@JsonProperty("management_entity")
@CustomField(key="Management entity")
@Tag
private String managementEntity;
@JsonProperty("assessment_methods")

View File

@ -32,11 +32,11 @@ import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.data_catalogue.grsf_publish_ws.json.input.DeleteProductBean;
import org.gcube.data_catalogue.grsf_publish_ws.json.input.FisheryRecord;
import org.gcube.data_catalogue.grsf_publish_ws.json.input.RefersToBean;
import org.gcube.data_catalogue.grsf_publish_ws.json.input.Resource;
import org.gcube.data_catalogue.grsf_publish_ws.json.output.ResponseBean;
import org.gcube.data_catalogue.grsf_publish_ws.json.output.ResponseCreationBean;
import org.gcube.data_catalogue.grsf_publish_ws.utils.HelperMethods;
import org.gcube.data_catalogue.grsf_publish_ws.utils.groups.Product_Type;
import org.gcube.data_catalogue.grsf_publish_ws.utils.groups.Record_Type;
import org.gcube.data_catalogue.grsf_publish_ws.utils.groups.Sources;
import org.gcube.data_catalogue.grsf_publish_ws.utils.threads.AssociationToGroupThread;
import org.gcube.data_catalogue.grsf_publish_ws.utils.threads.ManageTimeSeriesThread;
@ -159,14 +159,20 @@ public class GrsfPublisherFisheryService {
// Status field is needed only in the Manage context for GRSF records
if(context.equals((String)contextServlet.getInitParameter(HelperMethods.MANAGE_CONTEX_KEY))){
if(sourceInPath.equals(Sources.GRSF)){
record.setRecordType(Record_Type.AGGREGATED);
//Evaluate the sources
List<Resource<Sources>> recordSources = record.getDatabaseSources();
String sources = "";
for (Resource<Sources> resource : recordSources) {
sources += resource.getName() + ", ";
}
sources = sources.endsWith(", ") ? sources.substring(0, sources.length() -2) : sources;
record.setSourceType(sources);
CommonServiceUtils.validateAggregatedRecord(record);
}else
record.setRecordType(Record_Type.SOURCE);
}
}
// set the type
record.setProductType(Product_Type.FISHERY.getOrigName());
record.setGrsfType(Product_Type.FISHERY.getOrigName());
// product system type is a list of values for sources records, so remove it (so that no group is generated)
if(!sourceInPath.equals(Sources.GRSF))

View File

@ -31,12 +31,12 @@ import org.gcube.common.authorization.library.utils.Caller;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.data_catalogue.grsf_publish_ws.json.input.DeleteProductBean;
import org.gcube.data_catalogue.grsf_publish_ws.json.input.RefersToBean;
import org.gcube.data_catalogue.grsf_publish_ws.json.input.Resource;
import org.gcube.data_catalogue.grsf_publish_ws.json.input.StockRecord;
import org.gcube.data_catalogue.grsf_publish_ws.json.output.ResponseBean;
import org.gcube.data_catalogue.grsf_publish_ws.json.output.ResponseCreationBean;
import org.gcube.data_catalogue.grsf_publish_ws.utils.HelperMethods;
import org.gcube.data_catalogue.grsf_publish_ws.utils.groups.Product_Type;
import org.gcube.data_catalogue.grsf_publish_ws.utils.groups.Record_Type;
import org.gcube.data_catalogue.grsf_publish_ws.utils.groups.Sources;
import org.gcube.data_catalogue.grsf_publish_ws.utils.threads.AssociationToGroupThread;
import org.gcube.data_catalogue.grsf_publish_ws.utils.threads.ManageTimeSeriesThread;
@ -152,14 +152,20 @@ public class GrsfPublisherStockService {
// Status field is needed only in the Manage context for GRSF records
if(context.equals((String)contextServlet.getInitParameter(HelperMethods.MANAGE_CONTEX_KEY))){
if(sourceInPath.equals(Sources.GRSF)){
record.setRecordType(Record_Type.AGGREGATED);
//Evaluate the sources
List<Resource<Sources>> recordSources = record.getDatabaseSources();
String sources = "";
for (Resource<Sources> resource : recordSources) {
sources += resource.getName() + ", ";
}
sources = sources.endsWith(", ") ? sources.substring(0, sources.length() -2) : sources;
record.setSourceType(sources);
CommonServiceUtils.validateAggregatedRecord(record);
}else
record.setRecordType(Record_Type.SOURCE);
}
}
// set the type
record.setProductType(Product_Type.STOCK.getOrigName());
record.setGrsfType(Product_Type.STOCK.getOrigName());
// evaluate the custom fields/tags, resources and groups
Map<String, List<String>> customFields = record.getExtrasFields();

View File

@ -1,28 +0,0 @@
package org.gcube.data_catalogue.grsf_publish_ws.utils.groups;
/**
* The type of record, i.e. Aggregated or Original
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
*/
public enum Record_Type {
AGGREGATED("Aggregated"),
SOURCE("Source");
private String name;
private Record_Type(String name) {
this.name = name;
}
public String getRecordType(){
return name;
}
@Override
public String toString() {
return this.name;
}
}

View File

@ -158,7 +158,7 @@ public class ManageTimeSeriesThread extends Thread{
// - type of files (e.g., csv)
// -files (csv)
String recordTypeFolderName = record.getProductType().toLowerCase();
String recordTypeFolderName = record.getGrsfType().toLowerCase();
String productName = record.getClass().equals(StockRecord.class) ? ((StockRecord)record).getStockName() : ((FisheryRecord)record).getFisheryName();
char firstLetter = productName.charAt(0);