From 359f2fbddde86ebdf13d346e68a3b281274812b5 Mon Sep 17 00:00:00 2001 From: Costantino Perciante Date: Wed, 2 Aug 2017 10:11:47 +0000 Subject: [PATCH] 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 --- .../grsf_publish_ws/json/input/Common.java | 1 + .../json/input/TimeSeriesBean.java | 4 ++-- .../services/CommonServiceUtils.java | 17 ++++++++++++++--- .../services/GrsfPublisherFisheryService.java | 7 ++++--- .../services/GrsfPublisherStockService.java | 5 +++-- .../utils/threads/ManageTimeSeriesThread.java | 2 +- 6 files changed, 25 insertions(+), 11 deletions(-) diff --git a/src/main/java/org/gcube/data_catalogue/grsf_publish_ws/json/input/Common.java b/src/main/java/org/gcube/data_catalogue/grsf_publish_ws/json/input/Common.java index 24603ac..96a2839 100644 --- a/src/main/java/org/gcube/data_catalogue/grsf_publish_ws/json/input/Common.java +++ b/src/main/java/org/gcube/data_catalogue/grsf_publish_ws/json/input/Common.java @@ -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") diff --git a/src/main/java/org/gcube/data_catalogue/grsf_publish_ws/json/input/TimeSeriesBean.java b/src/main/java/org/gcube/data_catalogue/grsf_publish_ws/json/input/TimeSeriesBean.java index f51f56f..99c0576 100644 --- a/src/main/java/org/gcube/data_catalogue/grsf_publish_ws/json/input/TimeSeriesBean.java +++ b/src/main/java/org/gcube/data_catalogue/grsf_publish_ws/json/input/TimeSeriesBean.java @@ -19,7 +19,7 @@ public class TimeSeriesBean implements Comparable>{ 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 implements Comparable>{ 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; diff --git a/src/main/java/org/gcube/data_catalogue/grsf_publish_ws/services/CommonServiceUtils.java b/src/main/java/org/gcube/data_catalogue/grsf_publish_ws/services/CommonServiceUtils.java index 3158481..fcc18bd 100644 --- a/src/main/java/org/gcube/data_catalogue/grsf_publish_ws/services/CommonServiceUtils.java +++ b/src/main/java/org/gcube/data_catalogue/grsf_publish_ws/services/CommonServiceUtils.java @@ -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 sourcesList = new ArrayList(); + 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 namespaces, Set 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> addField = new HashMap>(); 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 diff --git a/src/main/java/org/gcube/data_catalogue/grsf_publish_ws/services/GrsfPublisherFisheryService.java b/src/main/java/org/gcube/data_catalogue/grsf_publish_ws/services/GrsfPublisherFisheryService.java index 1edc8ca..7a09a37 100644 --- a/src/main/java/org/gcube/data_catalogue/grsf_publish_ws/services/GrsfPublisherFisheryService.java +++ b/src/main/java/org/gcube/data_catalogue/grsf_publish_ws/services/GrsfPublisherFisheryService.java @@ -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(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"); diff --git a/src/main/java/org/gcube/data_catalogue/grsf_publish_ws/services/GrsfPublisherStockService.java b/src/main/java/org/gcube/data_catalogue/grsf_publish_ws/services/GrsfPublisherStockService.java index e619fa7..1f65ab3 100644 --- a/src/main/java/org/gcube/data_catalogue/grsf_publish_ws/services/GrsfPublisherStockService.java +++ b/src/main/java/org/gcube/data_catalogue/grsf_publish_ws/services/GrsfPublisherStockService.java @@ -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{ diff --git a/src/main/java/org/gcube/data_catalogue/grsf_publish_ws/utils/threads/ManageTimeSeriesThread.java b/src/main/java/org/gcube/data_catalogue/grsf_publish_ws/utils/threads/ManageTimeSeriesThread.java index 981a10e..04034e3 100644 --- a/src/main/java/org/gcube/data_catalogue/grsf_publish_ws/utils/threads/ManageTimeSeriesThread.java +++ b/src/main/java/org/gcube/data_catalogue/grsf_publish_ws/utils/threads/ManageTimeSeriesThread.java @@ -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;