From 57096696ac4329e380e10cd4a2a490aad6e41d61 Mon Sep 17 00:00:00 2001 From: Costantino Perciante Date: Wed, 2 Aug 2017 12:09:02 +0000 Subject: [PATCH] minor fixes git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/widgets/grsf-manage-widget@152418 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../client/view/ManageProductWidget.java | 10 +-- .../client/view/ManageProductWidget.ui.xml | 62 +++++-------- .../manage/GRSFNotificationService.java | 33 +------ .../grsf_manage_widget/shared/Constants.java | 13 ++- .../shared/ManageProductBean.java | 87 +++++++------------ 5 files changed, 62 insertions(+), 143 deletions(-) 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 8a77243..1a9fcd9 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 @@ -54,18 +54,12 @@ public class ManageProductWidget extends Composite{ @UiField AlertBlock infoBlock; - @UiField - TextArea titleTextArea; - @UiField TextBox shortNameTextBox; @UiField TextBox productGrsfType; - @UiField - TextArea descriptionTextArea; - @UiField CheckBox traceabilityFlag; @@ -170,14 +164,12 @@ public class ManageProductWidget extends Composite{ annotationArea.setText(""); infoBlock.setVisible(false); - titleTextArea.setText(bean.getItemTitle()); - shortNameTextBox.setText(bean.getShortTitle()); + shortNameTextBox.setText(bean.getShortName()); currentStatus.setText(bean.getCurrentStatus().toString()); productGrsfType.setText(bean.getGrsfType()); GRSFNameTexBox.setText(bean.getGrsfName()); semanticIdentifierTextBox.setText(bean.getSemanticId()); sources.setText(bean.getSources()); - descriptionTextArea.setText(bean.getDescription()); traceabilityFlag.setValue(bean.isTraceabilityFlag()); // check if we need to show more 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 046fe15..12fba39 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 @@ -23,38 +23,6 @@ - - - Title: - - - - - - - - - Description: - - - - - - - - - Short Name: - - - - - - GRSF Name: @@ -66,13 +34,24 @@ - - - Semantic Identifier: + + + GRSF Short Name: - + + + + + + GRSF Semantic Identifier: + + + @@ -83,7 +62,8 @@ + placeholder="GRSF Type" width="97%" title="GRSF Type" readOnly="true" + ui:field="productGrsfType"> @@ -102,7 +82,8 @@ Traceability Flag: - + @@ -140,7 +121,6 @@ title="An annotation message to send along the update" ui:field="annotationArea"> - @@ -149,7 +129,7 @@ Cancel - Send + Apply diff --git a/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/server/manage/GRSFNotificationService.java b/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/server/manage/GRSFNotificationService.java index 34367be..6a30696 100644 --- a/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/server/manage/GRSFNotificationService.java +++ b/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/server/manage/GRSFNotificationService.java @@ -163,18 +163,15 @@ public class GRSFNotificationService extends RemoteServiceServlet implements GRS String grsfDomain = extrasWithoutNamespaces.get(Constants.GRSF_DOMAIN); String grsfName = extrasWithoutNamespaces.get(grsfDomain.equals(Constants.STOCK) ? Constants.STOCK_GRSF_NAME : Constants.FISHERY_GRSF_NAME); String traceabilityFlag = extrasWithoutNamespaces.get(Constants.TRACEABILITY_FLAG); - String title = record.getTitle(); - String description = record.getNotes(); + String sources = extrasWithoutNamespaces.get(Constants.GRSF_DATABASE_SOURCE); if(status == null || uuidKB == null) throw new Exception("Some information is missing in this record: Status = " + status + ", knowledge base uuid = " + uuidKB + ", and grsf domain is = " + grsfDomain); - - String sources = getSourcesFromGroups(record); - + // set the values - toReturn = new ManageProductBean(title, semanticId, productIdentifier, - uuidKB, grsfType, grsfDomain, sources, description, grsfName, null, GRSFStatus.fromString(status), null, null, shortName, traceabilityFlag.equalsIgnoreCase("true")); + toReturn = new ManageProductBean(semanticId, productIdentifier, uuidKB, + grsfType, grsfDomain, sources, grsfName, traceabilityFlag.equalsIgnoreCase("true"), GRSFStatus.fromString(status), null, null, shortName, null); logger.info("Returning item bean " + toReturn); @@ -182,28 +179,6 @@ public class GRSFNotificationService extends RemoteServiceServlet implements GRS } } - /** - * Get sources from record - * @param record - * @return - */ - private String getSourcesFromGroups(CkanDataset record) { - if(record == null) - return null; - else{ - - List groups = record.getGroups(); - - for (CkanGroup ckanGroup : groups) { - String title = ckanGroup.getTitle(); - if(title.contains(Constants.RAM) || title.contains(Constants.FISHSOURCE) || title.contains(Constants.FIRMS)) - return title; - } - - } - return null; - } - /** * Discover the service endpoint and return its url * @param context diff --git a/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/shared/Constants.java b/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/shared/Constants.java index 8483439..f761fd6 100644 --- a/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/shared/Constants.java +++ b/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/shared/Constants.java @@ -13,8 +13,13 @@ public class Constants { public static final String SOURCES_TITLE_FIELD_KEY = "Sources"; public static final String GRSF_DOMAIN = "GRSF Domain"; public static final String TRACEABILITY_FLAG = "Traceability Flag"; - + public static final String SYSTEM_TYPE = "system:type"; + public static final String GRSF = "GRSF"; + public static final String FIRMS = "FIRMS"; + public static final String RAM = "RAM"; + public static final String FISHSOURCE = "FishSource"; public static final String ANNOTATION_KEY = "Annotation on update"; + public static final String GRSF_DATABASE_SOURCE = "Database Source"; // stock or fishery public static final String STOCK = "Stock"; @@ -45,11 +50,5 @@ public class Constants { // session info for user public static final String GRSF_ADMIN_SESSION_KEY = "IS_GRSF_ADMIN"; public static final String GRSF_CATALOGUE_MANAGER_ROLE = "Catalogue Manager"; // managed as Team Role - public static final String SYSTEM_TYPE = "system:type"; - public static final String GRSF = "GRSF"; - public static final String FIRMS = "FIRMS"; - public static final String RAM = "RAM"; - public static final String FISHSOURCE = "FishSource"; - } diff --git a/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/shared/ManageProductBean.java b/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/shared/ManageProductBean.java index da6f581..a0b3762 100644 --- a/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/shared/ManageProductBean.java +++ b/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/shared/ManageProductBean.java @@ -10,76 +10,58 @@ import java.util.Map; public class ManageProductBean implements Serializable{ private static final long serialVersionUID = -4882608487467259326L; - private String itemTitle; // title private String semanticId; // Stock id or Fishery id private String catalogueIdentifier; // catalogue id private String knowledgeBaseIdentifier; // GRSF UUID private String grsfType; // Fishery or Stock type (e.g., Assessment_Unit, Marine Resource and so on) private String grsfDomain; // fishery/stock private String sources; // sources for this record - private String description; private String grsfName; // Fishery name or stock name - private Map extrasIfAvailable; // read from GRSFManageEntries resource - - // info that could change + private boolean traceabilityFlag; //from false to true etc private GRSFStatus currentStatus; private GRSFStatus newStatus; private String annotation; // added by the administrator - private String shortTitle; - private boolean traceabilityFlag; //from false to true etc + private String shortName; + private Map extrasIfAvailable; // read from GRSFManageEntries resource public ManageProductBean() { super(); } /** - * @param itemTitle * @param semanticId * @param catalogueIdentifier * @param knowledgeBaseIdentifier * @param grsfType * @param grsfDomain * @param sources - * @param description * @param grsfName - * @param extrasIfAvailable + * @param traceabilityFlag * @param currentStatus * @param newStatus * @param annotation - * @param shortTitle - * @param traceabilityFlag + * @param shortName + * @param extrasIfAvailable */ - public ManageProductBean(String itemTitle, String semanticId, - String catalogueIdentifier, String knowledgeBaseIdentifier, - String grsfType, String grsfDomain, String sources, - String description, String grsfName, - Map extrasIfAvailable, GRSFStatus currentStatus, - GRSFStatus newStatus, String annotation, String shortTitle, - boolean traceabilityFlag) { + public ManageProductBean(String semanticId, String catalogueIdentifier, + String knowledgeBaseIdentifier, String grsfType, String grsfDomain, + String sources, String grsfName, boolean traceabilityFlag, + GRSFStatus currentStatus, GRSFStatus newStatus, String annotation, + String shortName, Map extrasIfAvailable) { super(); - this.itemTitle = itemTitle; this.semanticId = semanticId; this.catalogueIdentifier = catalogueIdentifier; this.knowledgeBaseIdentifier = knowledgeBaseIdentifier; this.grsfType = grsfType; this.grsfDomain = grsfDomain; this.sources = sources; - this.description = description; this.grsfName = grsfName; - this.extrasIfAvailable = extrasIfAvailable; + this.traceabilityFlag = traceabilityFlag; this.currentStatus = currentStatus; this.newStatus = newStatus; this.annotation = annotation; - this.shortTitle = shortTitle; - this.traceabilityFlag = traceabilityFlag; - } - - public String getItemTitle() { - return itemTitle; - } - - public void setItemTitle(String itemTitle) { - this.itemTitle = itemTitle; + this.shortName = shortName; + this.extrasIfAvailable = extrasIfAvailable; } public String getSemanticId() { @@ -130,14 +112,6 @@ public class ManageProductBean implements Serializable{ this.sources = sources; } - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - public String getGrsfName() { return grsfName; } @@ -177,15 +151,7 @@ public class ManageProductBean implements Serializable{ public void setAnnotation(String annotation) { this.annotation = annotation; } - - public String getShortTitle() { - return shortTitle; - } - - public void setShortTitle(String shortTitle) { - this.shortTitle = shortTitle; - } - + public boolean isTraceabilityFlag() { return traceabilityFlag; } @@ -194,18 +160,25 @@ public class ManageProductBean implements Serializable{ this.traceabilityFlag = traceabilityFlag; } + public String getShortName() { + return shortName; + } + + public void setShortName(String shortName) { + this.shortName = shortName; + } + @Override public String toString() { - return "ManageProductBean [itemTitle=" + itemTitle + ", semanticId=" - + semanticId + ", catalogueIdentifier=" + catalogueIdentifier + return "ManageProductBean [semanticId=" + semanticId + + ", catalogueIdentifier=" + catalogueIdentifier + ", knowledgeBaseIdentifier=" + knowledgeBaseIdentifier + ", grsfType=" + grsfType + ", grsfDomain=" + grsfDomain - + ", sources=" + sources + ", description=" + description - + ", grsfName=" + grsfName + ", extrasIfAvailable=" - + extrasIfAvailable + ", currentStatus=" + currentStatus - + ", newStatus=" + newStatus + ", annotation=" + annotation - + ", shortTitle=" + shortTitle + ", traceabilityFlag=" - + traceabilityFlag + "]"; + + ", sources=" + sources + ", grsfName=" + grsfName + + ", traceabilityFlag=" + traceabilityFlag + ", currentStatus=" + + currentStatus + ", newStatus=" + newStatus + ", annotation=" + + annotation + ", shortName=" + shortName + + ", extrasIfAvailable=" + extrasIfAvailable + "]"; } }