From 78d650512c2ca271090819f33050c705410eae09 Mon Sep 17 00:00:00 2001 From: Costantino Perciante Date: Sun, 19 Feb 2017 15:41:36 +0000 Subject: [PATCH] improved set of information shown by the widget: title, short title, semantic id, grsf type, type, source(s) git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/widgets/grsf-manage-widget@142737 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../client/GRSFManageWidgetService.java | 2 +- .../client/view/ManageProductWidget.java | 30 +++++-- .../client/view/ManageProductWidget.ui.xml | 88 ++++++++++++++----- .../manage/GRSFNotificationService.java | 79 +++++++++++------ 4 files changed, 144 insertions(+), 55 deletions(-) diff --git a/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/client/GRSFManageWidgetService.java b/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/client/GRSFManageWidgetService.java index cbc30ba..1be9497 100644 --- a/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/client/GRSFManageWidgetService.java +++ b/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/client/GRSFManageWidgetService.java @@ -23,7 +23,7 @@ public interface GRSFManageWidgetService extends RemoteService { ManageProductBean getProductBeanById(String identifier) throws Exception; /** - * check if the user has the role to manage the item + * check if the user has the rights to manage the item */ boolean isAdminUser(); } diff --git a/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/client/view/ManageProductWidget.java b/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/client/view/ManageProductWidget.java index 12b5cbd..5616761 100644 --- a/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/client/view/ManageProductWidget.java +++ b/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/client/view/ManageProductWidget.java @@ -51,7 +51,22 @@ public class ManageProductWidget extends Composite{ AlertBlock infoBlock; @UiField - TextArea nameTextArea; + TextArea titleTextArea; + + @UiField + TextBox productType; + + @UiField + TextBox productGrsfType; + + @UiField + TextBox productSemanticId; + + @UiField + TextBox productShortTitle; + + @UiField + TextBox productSource; @UiField TextBox currentStatus; @@ -77,9 +92,6 @@ public class ManageProductWidget extends Composite{ @UiField Form formUpdate; - @UiField - TextBox productType; - @UiField Image loadingImage; @@ -141,9 +153,15 @@ public class ManageProductWidget extends Composite{ bean = result; annotationArea.setText(""); infoBlock.setVisible(false); - nameTextArea.setText(bean.getItemTitle()); + + titleTextArea.setText(bean.getItemTitle()); currentStatus.setText(bean.getCurrentStatus().toString()); - productType.setText(bean.getGrsfType()); + productGrsfType.setText(bean.getGrsfType()); + productType.setText(bean.getType()); + productSemanticId.setText(bean.getSemanticId()); + productShortTitle.setText(bean.getShortTitle()); + productSource.setText(bean.getSource()); + List statusToShow = new ArrayList(STATUS); statusToShow.remove(bean.getCurrentStatus()); listBoxStatus.addItem("Select the new status"); diff --git a/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/client/view/ManageProductWidget.ui.xml b/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/client/view/ManageProductWidget.ui.xml index be8e9ba..da707c4 100644 --- a/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/client/view/ManageProductWidget.ui.xml +++ b/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/client/view/ManageProductWidget.ui.xml @@ -20,23 +20,75 @@ - + - - Item Name: + + Item title: - + + + + + + + Item GRSF Type: + + + + + + + + + Item Semantic Id: + + + + + + + + + Item Short Title: + + + + + + + + + Item Sources: + + + + + + + + + Item Type: + + + - Item Current Status: + Item Current Status: + - - Item New Status: + + Item New Status: + - - - - - - Item Type: - - + width="97%" title="Select a new status" enabled="true" ui:field="listBoxStatus"> - Annotation: + Annotation: + extras = product.getExtrasAsHashMap(); - String status = extras.get("Status"); - String uuidKB = extras.get("UUID Knowledge Base"); - String productType = extras.get("Product type"); - String recordType = extras.get("Record type"); - String title = product.getTitle(); - // it cannot be enabled in this case ... - if(recordType == null || recordType.equals("Source")) - throw new NoGRSFRecordException("This is not a GRSF Item"); + if(product == null) + throw new Exception("Unable to retrieve information for the selected item, sorry"); + else{ - if(status == null || uuidKB == null || productType == null) - throw new Exception("Some information is missing in this record: Status = " + status + ", knowledge_base_uuid = " + uuidKB + - ", and product type is = " + productType); + // check it is a grsf item, else.. + List groups = product.getGroups(); + boolean isGrsf = false; + + for (CkanGroup ckanGroup : groups) { + if(ckanGroup.getName().contains("grsf")){ + isGrsf = true; + break; + } + } - toReturn = new ManageProductBean(); - toReturn.setCatalogueIdentifier(productIdentifier); - toReturn.setCurrentStatus(GRSFStatus.fromString(status)); - toReturn.setKnowledgeBaseIdentifier(uuidKB); - toReturn.setItemTitle(title); - toReturn.setGrsfType(productType); + if(!isGrsf) + throw new NoGRSFRecordException("This is not a GRSF Item"); - logger.info("Returning item bean " + toReturn); + // get extras + Map extras = product.getExtrasAsHashMap(); + String status = extras.get(STATUS_CUSTOM_FIELD_KEY); + String uuidKB = extras.get(KB_UUID_FIELD_KEY); + String productType = extras.get(TYPE_FIELD_KEY); + String productGRSFType = extras.get(GRSF_TYPE_FIELD_KEY); + String semanticId = extras.get(productGRSFType + " id"); // i.e "Stock id" or "Fishery id" + String shortTitle = extras.get(SHORT_TITLE_FIELD_KEY); + String sources = extras.get(SOURCES_TITLE_FIELD_KEY); + String title = product.getTitle(); + if(status == null || uuidKB == null || productGRSFType == null) + throw new Exception("Some information is missing in this record: Status = " + status + ", knowledge_base_uuid = " + uuidKB + + ", and grsf type is = " + productType); - return toReturn; + toReturn = new ManageProductBean(); + toReturn.setCatalogueIdentifier(productIdentifier); + toReturn.setCurrentStatus(GRSFStatus.fromString(status)); + toReturn.setKnowledgeBaseIdentifier(uuidKB); + toReturn.setItemTitle(title); + toReturn.setGrsfType(productGRSFType); + toReturn.setType(productType); + toReturn.setSemanticId(semanticId); + toReturn.setShortTitle(shortTitle); + toReturn.setSource(sources); + + logger.info("Returning item bean " + toReturn); + + return toReturn; + } } /** @@ -432,7 +461,7 @@ public class GRSFNotificationService extends RemoteServiceServlet implements GRS return httpServletRequest.getHeader(GCUBE_REQUEST_URL); } - + /** * Retrieve the current scope by using the portal manager * @param b