still minor model improvements: removed some descriptions from resources, added back the Database Source field, description now is updated to show short name, semantic id and url. Also, time series have been slightly modified (field reference_year_or_assessment updated to reference_year_or_assessment_id)
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-catalogue/grsf-publisher-ws@152410 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
7df140537c
commit
359f2fbddd
|
@ -23,6 +23,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
|||
public class Common extends Base{
|
||||
|
||||
public static final String GRSF_DOMAIN_KEY = "GRSF Domain"; // stock, fishery
|
||||
public static final String GRSF_DATABASE_SOURCE = "Database Source";
|
||||
|
||||
// it is added in case of GRSF record
|
||||
@JsonProperty("data_owner")
|
||||
|
|
|
@ -19,7 +19,7 @@ public class TimeSeriesBean<T, T1> implements Comparable<TimeSeriesBean<T, T1>>{
|
|||
public static final String VALUE_FIELD = "value";
|
||||
public static final String UNIT_FIELD = "unit";
|
||||
public static final String SOURCE_FIELD = "source";
|
||||
public static final String ASSESSMENT_FIELD = "reporting_year_or_assessment";
|
||||
public static final String ASSESSMENT_FIELD = "reporting_year_or_assessment_id";
|
||||
|
||||
@JsonProperty(YEAR_FIELD)
|
||||
@NotNull(message="reference_year of a time series cannot be null")
|
||||
|
@ -126,7 +126,7 @@ public class TimeSeriesBean<T, T1> implements Comparable<TimeSeriesBean<T, T1>>{
|
|||
String unit = (this.unit != null ? " " + this.unit : "");
|
||||
String source = (this.source != null ? " (" + this.source + ")" : "");
|
||||
String referenceYear = " Ref. Year " + year;
|
||||
String reportingYearOrAssessment = (assessment != null ? " and Rep. Year or Assessment " + assessment + "" : "");
|
||||
String reportingYearOrAssessment = (assessment != null ? " and Rep. Year or Assessment Id " + assessment + "" : "");
|
||||
|
||||
return value + unit + source + referenceYear + reportingYearOrAssessment;
|
||||
|
||||
|
|
|
@ -36,6 +36,7 @@ import org.gcube.data_catalogue.grsf_publish_ws.utils.threads.WritePostCatalogue
|
|||
import org.gcube.datacatalogue.ckanutillibrary.server.DataCatalogue;
|
||||
import org.gcube.datacatalogue.ckanutillibrary.shared.ResourceBean;
|
||||
import org.gcube.datacatalogue.ckanutillibrary.shared.RolesCkanGroupOrOrg;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import eu.trentorise.opendata.jackan.model.CkanDataset;
|
||||
|
@ -421,12 +422,17 @@ public class CommonServiceUtils {
|
|||
|
||||
List<String> sourcesList = new ArrayList<String>();
|
||||
|
||||
String databaseSource = "";
|
||||
// we have the id within the catalog of this record. This means that we can retrieve the record and its system:type
|
||||
for (RefersToBean refersToBean : refersTo) {
|
||||
String sourceSysType = getSystemTypeValue(refersToBean.getId(), apiKey, context);
|
||||
resources.add(new ResourceBean(refersToBean.getUrl(), sourceSysType , "The source record has id " + refersToBean.getId() + " in the catalog", null, username, null, null));
|
||||
resources.add(new ResourceBean(refersToBean.getUrl(), sourceSysType , "", null, username, null, null));
|
||||
sourcesList.add(sourceSysType.toLowerCase());
|
||||
databaseSource += sourceSysType + " ";
|
||||
}
|
||||
|
||||
// create the Database Source information
|
||||
customFields.put(Common.GRSF_DATABASE_SOURCE, Arrays.asList(databaseSource.trim()));
|
||||
|
||||
// append to groups: we need to add this record to the correspondent group of the sources
|
||||
addRecordToGroupSources(groups, sourcesList, productType, sourceInPath);
|
||||
|
@ -499,21 +505,26 @@ public class CommonServiceUtils {
|
|||
* @param futureTitle
|
||||
* @param authorFullname
|
||||
* @param contextServlet
|
||||
* @param partialDescription
|
||||
* @throws InterruptedException
|
||||
*/
|
||||
public static void actionsPostCreateOrUpdate(
|
||||
String datasetId, String futureName, Common record, String apiKey, String username, String organization, String itemUrl,
|
||||
ResponseCreationBean responseBean, DataCatalogue catalogue,
|
||||
Map<String, String> namespaces, Set<String> groups, String context,
|
||||
String token, String futureTitle, String authorFullname, ServletContext contextServlet, boolean isUpdated) throws InterruptedException {
|
||||
String token, String futureTitle, String authorFullname, ServletContext contextServlet, boolean isUpdated, String description) throws InterruptedException {
|
||||
|
||||
// on create, we need to add the item url
|
||||
// on create, we need to add the item url and set the description
|
||||
if(!isUpdated){
|
||||
itemUrl = catalogue.getUnencryptedUrlFromDatasetIdOrName(futureName);
|
||||
Map<String, List<String>> addField = new HashMap<String, List<String>>();
|
||||
String modifiedUUIDKey = namespaces.containsKey(CommonServiceUtils.ITEM_URL_FIELD) ? namespaces.get(CommonServiceUtils.ITEM_URL_FIELD) : CommonServiceUtils.ITEM_URL_FIELD;
|
||||
addField.put(modifiedUUIDKey, Arrays.asList(itemUrl));
|
||||
catalogue.patchProductCustomFields(datasetId, apiKey, addField);
|
||||
description += ", GRSF Record URL: " + itemUrl;
|
||||
JSONObject obj = new JSONObject();
|
||||
obj.put("notes", description);
|
||||
catalogue.patchProductWithJSON(datasetId, obj, apiKey);
|
||||
}
|
||||
|
||||
// set info in the response bean
|
||||
|
|
|
@ -168,7 +168,7 @@ public class GrsfPublisherFisheryService {
|
|||
record.getMaintainer() == null? authorFullname : record.getMaintainer(),
|
||||
record.getMaintainerContact() == null? authorMail : record.getMaintainerContact(),
|
||||
version,
|
||||
HelperMethods.removeHTML(record.getDescription()),
|
||||
null,
|
||||
license,
|
||||
new ArrayList<String>(tags),
|
||||
customFields,
|
||||
|
@ -179,10 +179,11 @@ public class GrsfPublisherFisheryService {
|
|||
if(id != null){
|
||||
|
||||
logger.info("Created record with identifier " + id);
|
||||
String description = "Short Name: " + record.getShortName() + ", GRSF Semantic Identifier: " + record.getFisheryId();
|
||||
CommonServiceUtils.actionsPostCreateOrUpdate(
|
||||
id, futureName, record, apiKey, username, organization,
|
||||
null, responseBean, catalogue, namespaces, groups, context, token, futureTitle, authorFullname,
|
||||
contextServlet, false);
|
||||
contextServlet, false, description);
|
||||
status = Status.CREATED;
|
||||
|
||||
}else{
|
||||
|
@ -497,7 +498,7 @@ public class GrsfPublisherFisheryService {
|
|||
CommonServiceUtils.actionsPostCreateOrUpdate(
|
||||
id, name, record, apiKey, username, organization,
|
||||
itemUrl, responseBean, catalogue, namespaces, groups, context, token, title, authorFullname,
|
||||
contextServlet, false);
|
||||
contextServlet, false, null);
|
||||
status = Status.OK;
|
||||
}else{
|
||||
throw new Exception("There was an error during the item updated, sorry");
|
||||
|
|
|
@ -193,10 +193,11 @@ public class GrsfPublisherStockService {
|
|||
if(id != null){
|
||||
|
||||
logger.info("Product created! Id is " + id);
|
||||
String description = "Short Name: " + record.getShortName() + ", GRSF Semantic Identifier: " + record.getStockId();
|
||||
CommonServiceUtils.actionsPostCreateOrUpdate(
|
||||
id, futureName, record, apiKey, username, organization, null,
|
||||
responseBean, catalogue, namespaces, groups, context, token,
|
||||
futureTitle, authorFullname, contextServlet, false);
|
||||
futureTitle, authorFullname, contextServlet, false, description);
|
||||
status = Status.CREATED;
|
||||
|
||||
}else
|
||||
|
@ -506,7 +507,7 @@ public class GrsfPublisherStockService {
|
|||
CommonServiceUtils.actionsPostCreateOrUpdate(
|
||||
recordPublished.getId(), name, record, apiKey, username, organization, itemUrl,
|
||||
responseBean, catalogue, namespaces, groups, context, token,
|
||||
title, authorFullname, contextServlet, true);
|
||||
title, authorFullname, contextServlet, true, null);
|
||||
status = Status.OK;
|
||||
|
||||
}else{
|
||||
|
|
|
@ -190,7 +190,7 @@ public class ManageTimeSeriesThread extends Thread{
|
|||
CustomField customAnnotation = field.getAnnotation(CustomField.class);
|
||||
logger.debug("A time series has been just found (from field " + customAnnotation.key() + ")");
|
||||
String resourceToAttachOnCkanName = customAnnotation.key();
|
||||
String resourceToAttachOnCkanDescription = productName + " - " + resourceToAttachOnCkanName + " time series";
|
||||
String resourceToAttachOnCkanDescription = productName;
|
||||
|
||||
CkanResourceBase ckanResource = null;
|
||||
ExternalFile createdFileOnWorkspace = null;
|
||||
|
|
Loading…
Reference in New Issue