From e24efc16f6dfdf8f058a21dae03c0b2ecda29535 Mon Sep 17 00:00:00 2001 From: Costantino Perciante Date: Mon, 20 Feb 2017 15:16:57 +0000 Subject: [PATCH] improved generic resource usage git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/widgets/grsf-manage-widget@142777 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../client/view/FormEntryModel.java | 2 +- .../client/view/ManageProductWidget.java | 74 +++++++++---------- .../client/view/ManageProductWidget.ui.xml | 72 +++++++++--------- .../manage/GRSFNotificationService.java | 30 ++++---- .../shared/ManageProductBean.java | 70 ++++-------------- 5 files changed, 104 insertions(+), 144 deletions(-) diff --git a/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/client/view/FormEntryModel.java b/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/client/view/FormEntryModel.java index 44aa1a7..d4b26af 100644 --- a/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/client/view/FormEntryModel.java +++ b/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/client/view/FormEntryModel.java @@ -30,7 +30,7 @@ public class FormEntryModel extends Composite{ public FormEntryModel(String label, String value) { initWidget(uiBinder.createAndBindUi(this)); - labelEntry.add(new HTML("" + label + "")); + labelEntry.add(new HTML("Item " + label + ":")); entryValue.setText(value); } 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 cac2dcd..098b255 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 @@ -55,21 +55,21 @@ public class ManageProductWidget extends Composite{ @UiField TextArea titleTextArea; - - @UiField - TextBox productType; - - @UiField - TextBox productGrsfType; - - @UiField - TextBox productSemanticId; - - @UiField - TextBox productShortTitle; + + // @UiField + // TextBox productType; @UiField - TextBox productSource; + TextBox productGrsfType; + + // @UiField + // TextBox productSemanticId; + // + // @UiField + // TextBox productShortTitle; + // + // @UiField + // TextBox productSource; @UiField TextBox currentStatus; @@ -91,12 +91,12 @@ public class ManageProductWidget extends Composite{ @UiField ControlGroup listBoxStatusGroup; - + @UiField ControlGroup annotationAreaGroup; - + @UiField - ControlGroup productTypeGroup; + ControlGroup productGrsfTypeGroup; @UiField Form formUpdate; @@ -130,7 +130,7 @@ public class ManageProductWidget extends Composite{ loadingImage.setVisible(true); manageProductModal.show(); - + // async request to fetch the product retrieveProductBean(productIdentifier); } @@ -144,9 +144,9 @@ public class ManageProductWidget extends Composite{ public void onSuccess(Boolean result) { if(!result){ - + showInfo(NO_ADMIN_ROLE, AlertType.ERROR); - + // hide the form and disable the send button formUpdate.setVisible(false); confirmButton.setEnabled(false); @@ -162,19 +162,19 @@ public class ManageProductWidget extends Composite{ bean = result; annotationArea.setText(""); infoBlock.setVisible(false); - + titleTextArea.setText(bean.getItemTitle()); currentStatus.setText(bean.getCurrentStatus().toString()); productGrsfType.setText(bean.getGrsfType()); - productType.setText(bean.getType()); - productSemanticId.setText(bean.getSemanticId()); - productShortTitle.setText(bean.getShortTitle()); - productSource.setText(bean.getSource()); - + // productType.setText(bean.getType()); + // productSemanticId.setText(bean.getSemanticId()); + // productShortTitle.setText(bean.getShortTitle()); + // productSource.setText(bean.getSource()); + // check if we need to show more if(bean.getExtrasIfAvailable() != null && !bean.getExtrasIfAvailable().isEmpty()) - addExtrasAfter(bean, productTypeGroup); - + addExtrasAfter(bean, productGrsfTypeGroup); + List statusToShow = new ArrayList(STATUS); statusToShow.remove(bean.getCurrentStatus()); listBoxStatus.addItem("Select the new status"); @@ -213,9 +213,9 @@ public class ManageProductWidget extends Composite{ @Override public void onFailure(Throwable caught) { - + showInfo(NO_ADMIN_ROLE, AlertType.ERROR); - + // hide the form and disable the send button formUpdate.setVisible(false); confirmButton.setEnabled(false); @@ -225,7 +225,7 @@ public class ManageProductWidget extends Composite{ }); } - + /** * Add extras if available after controlGroupBefore * @param bean @@ -233,20 +233,20 @@ public class ManageProductWidget extends Composite{ */ private void addExtrasAfter(ManageProductBean bean, ControlGroup controlGroupBefore) { - + int index = formUpdate.getWidgetIndex(controlGroupBefore); - + Map extras = bean.getExtrasIfAvailable(); Iterator> iterator = extras.entrySet().iterator(); while (iterator.hasNext()) { Map.Entry entry = (Map.Entry) iterator .next(); - + formUpdate.insert(new FormEntryModel(entry.getKey(), entry.getValue()), index); index++; - + } - + } @UiHandler("cancelButton") @@ -266,9 +266,9 @@ public class ManageProductWidget extends Composite{ listBoxStatusGroup.setType(ControlGroupType.ERROR); return; } - + annotationAreaGroup.setType(ControlGroupType.NONE); - + if(annotationArea.getText() == null || annotationArea.getText().isEmpty()){ annotationArea.setPlaceholder("An annotation message to send along the update (mandatory)"); annotationAreaGroup.setType(ControlGroupType.ERROR); 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 da707c4..753661c 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 @@ -44,45 +44,45 @@ - - - Item Semantic Id: - - - - - + + + + + + + + + - - - Item Short Title: - - - - - + + + + + + + + + - - - Item Sources: - - - - - + + + + + + + + + - - - Item Type: - - - - - + + + + + + + + + groups = product.getGroups(); boolean isGrsf = false; @@ -177,13 +177,13 @@ public class GRSFNotificationService extends RemoteServiceServlet implements GRS 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 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 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(); - + // fetch extras GenericResourceReaderExtras entries = new GenericResourceReaderExtras(); Set extrasToShow = entries.getLookedUpExtrasKeys(); @@ -199,17 +199,17 @@ public class GRSFNotificationService extends RemoteServiceServlet implements GRS if(status == null || uuidKB == null) throw new Exception("Some information is missing in this record: Status = " + status + ", knowledge_base_uuid = " + uuidKB + - ", and grsf type is = " + productType); - + ", and grsf type is = " + productGRSFType); + 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); + // toReturn.setType(productType); + // toReturn.setSemanticId(semanticId); + // toReturn.setShortTitle(shortTitle); + // toReturn.setSource(sources); logger.info("Returning item bean " + toReturn); 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 9e3937b..02e92e4 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 @@ -11,13 +11,13 @@ public class ManageProductBean implements Serializable{ private static final long serialVersionUID = -4882608487467259326L; private String itemTitle; - private String semanticId; // Stock id or Fishery id - private String shortTitle; + // private String semanticId; // Stock id or Fishery id + // private String shortTitle; private String catalogueIdentifier; private String knowledgeBaseIdentifier; - private String type; // Fishery or Stock type (e.g., Assessment_Unit, Marine Resource and so on) + // private String type; // Fishery or Stock type (e.g., Assessment_Unit, Marine Resource and so on) private String grsfType; // fishery/stock - private String source; // the current source + // private String source; // the current source private Map extrasIfAvailable; // info that could change @@ -31,38 +31,31 @@ public class ManageProductBean implements Serializable{ /** * @param itemTitle - * @param semanticId - * @param shortTitle * @param catalogueIdentifier * @param knowledgeBaseIdentifier - * @param type * @param grsfType - * @param source * @param extrasIfAvailable * @param currentStatus * @param newStatus * @param annotation */ - public ManageProductBean(String itemTitle, String semanticId, - String shortTitle, String catalogueIdentifier, - String knowledgeBaseIdentifier, String type, String grsfType, - String source, Map extrasIfAvailable, - GRSFStatus currentStatus, GRSFStatus newStatus, String annotation) { + public ManageProductBean(String itemTitle, String catalogueIdentifier, + String knowledgeBaseIdentifier, String grsfType, + Map extrasIfAvailable, GRSFStatus currentStatus, + GRSFStatus newStatus, String annotation) { super(); this.itemTitle = itemTitle; - this.semanticId = semanticId; - this.shortTitle = shortTitle; this.catalogueIdentifier = catalogueIdentifier; this.knowledgeBaseIdentifier = knowledgeBaseIdentifier; - this.type = type; this.grsfType = grsfType; - this.source = source; this.extrasIfAvailable = extrasIfAvailable; this.currentStatus = currentStatus; this.newStatus = newStatus; this.annotation = annotation; } + + public String getCatalogueIdentifier() { return catalogueIdentifier; } @@ -110,14 +103,6 @@ public class ManageProductBean implements Serializable{ this.itemTitle = itemTitle; } - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - public String getGrsfType() { return grsfType; } @@ -126,30 +111,6 @@ public class ManageProductBean implements Serializable{ this.grsfType = grsfType; } - public String getSource() { - return source; - } - - public void setSource(String source) { - this.source = source; - } - - public String getSemanticId() { - return semanticId; - } - - public void setSemanticId(String semanticId) { - this.semanticId = semanticId; - } - - public String getShortTitle() { - return shortTitle; - } - - public void setShortTitle(String shortTitle) { - this.shortTitle = shortTitle; - } - public Map getExtrasIfAvailable() { return extrasIfAvailable; } @@ -160,14 +121,13 @@ public class ManageProductBean implements Serializable{ @Override public String toString() { - return "ManageProductBean [itemTitle=" + itemTitle + ", semanticId=" - + semanticId + ", shortTitle=" + shortTitle + return "ManageProductBean [itemTitle=" + itemTitle + ", catalogueIdentifier=" + catalogueIdentifier + ", knowledgeBaseIdentifier=" + knowledgeBaseIdentifier - + ", type=" + type + ", grsfType=" + grsfType + ", source=" - + source + ", extrasIfAvailable=" + extrasIfAvailable - + ", currentStatus=" + currentStatus + ", newStatus=" - + newStatus + ", annotation=" + annotation + "]"; + + ", grsfType=" + grsfType + ", extrasIfAvailable=" + + extrasIfAvailable + ", currentStatus=" + currentStatus + + ", newStatus=" + newStatus + ", annotation=" + annotation + + "]"; } }