From a03399fd53f806fd79dd5399f2cb45d6b5f7ed7a Mon Sep 17 00:00:00 2001 From: Costantino Perciante Date: Tue, 18 Oct 2016 08:42:12 +0000 Subject: [PATCH] product type (i.e., "Fishery" and "Stock") is added as field and tag git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-catalogue/grsf-publisher-ws@133307 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../services/GrsfPublisherFisheryService.java | 5 +++++ .../services/GrsfPublisherStockService.java | 7 ++++++- .../grsf_publish_ws/utils/HelperMethods.java | 1 + 3 files changed, 12 insertions(+), 1 deletion(-) 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 aab960e..88a0344 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 @@ -45,6 +45,7 @@ import eu.trentorise.opendata.jackan.model.CkanDataset; public class GrsfPublisherFisheryService { private static final String DEFAULT_FISHERY_LICENSE = "CC-BY-SA-4.0"; + private static final String THIS_TYPE = "Fishery"; // the context @Context @@ -179,6 +180,7 @@ public class GrsfPublisherFisheryService { // evaluate the tags of the product List tags = new ArrayList(); HelperMethods.getTags(tags, record); + tags.add(THIS_TYPE); // evaluate the groups List groups = new ArrayList(); @@ -193,6 +195,9 @@ public class GrsfPublisherFisheryService { // automatically retrieve the other ones HelperMethods.getExtras(customFields, record); + // add the type + customFields.put(HelperMethods.PRODUCT_TYPE, THIS_TYPE); + // retrieve the user's email and fullname String authorMail = HelperMethods.getUserEmail(context, SecurityTokenProvider.instance.get()); String authorFullname = HelperMethods.getUserFullname(context, SecurityTokenProvider.instance.get()); 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 6c73b6b..031650c 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 @@ -45,6 +45,7 @@ import eu.trentorise.opendata.jackan.model.CkanDataset; public class GrsfPublisherStockService { private static final String DEFAULT_STOCK_LICENSE = "CC-BY-SA-4.0"; + private static final String THIS_TYPE = "Stock"; // the context @Context @@ -171,7 +172,8 @@ public class GrsfPublisherStockService { // evaluate the tags of the product List tags = new ArrayList(); HelperMethods.getTags(tags, record); - + tags.add(THIS_TYPE); + // evaluate the groups List groups = new ArrayList(); HelperMethods.getGroups(groups, record); @@ -184,6 +186,9 @@ public class GrsfPublisherStockService { // automatically retrieve the other ones HelperMethods.getExtras(customFields, record); + + // add the type + customFields.put(HelperMethods.PRODUCT_TYPE, THIS_TYPE); // retrieve the user's email and fullname String authorMail = HelperMethods.getUserEmail(context, SecurityTokenProvider.instance.get()); diff --git a/src/main/java/org/gcube/data_catalogue/grsf_publish_ws/utils/HelperMethods.java b/src/main/java/org/gcube/data_catalogue/grsf_publish_ws/utils/HelperMethods.java index e8d9c23..5cb918c 100644 --- a/src/main/java/org/gcube/data_catalogue/grsf_publish_ws/utils/HelperMethods.java +++ b/src/main/java/org/gcube/data_catalogue/grsf_publish_ws/utils/HelperMethods.java @@ -44,6 +44,7 @@ public abstract class HelperMethods { // to be retrieved from the web.xml private static final String PENDING_CONTEX_KEY = "PendingContext"; private static final String CONFIRMED_CONTEX_KEY = "ConfirmedContext"; + public static final String PRODUCT_TYPE = "Product type"; /** * Convert a group name to its id on ckan