2017-01-26 18:21:33 +01:00
|
|
|
package org.gcube.datacatalogue.grsf_manage_widget.client.view;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Arrays;
|
|
|
|
import java.util.List;
|
|
|
|
|
2017-10-27 17:48:51 +02:00
|
|
|
import org.gcube.datacatalogue.common.enums.Status;
|
2017-01-26 18:21:33 +01:00
|
|
|
import org.gcube.datacatalogue.grsf_manage_widget.client.GRSFManageWidgetService;
|
2017-01-27 16:14:14 +01:00
|
|
|
import org.gcube.datacatalogue.grsf_manage_widget.client.GRSFManageWidgetServiceAsync;
|
2017-11-14 18:37:07 +01:00
|
|
|
import org.gcube.datacatalogue.grsf_manage_widget.client.events.HideManagementPanelEvent;
|
2017-11-09 22:11:10 +01:00
|
|
|
import org.gcube.datacatalogue.grsf_manage_widget.client.view.subwidgets.ConnectToWidget;
|
|
|
|
import org.gcube.datacatalogue.grsf_manage_widget.client.view.subwidgets.SimilarGRSFRecordWidget;
|
|
|
|
import org.gcube.datacatalogue.grsf_manage_widget.client.view.subwidgets.SourceWidget;
|
2018-01-23 18:25:16 +01:00
|
|
|
import org.gcube.datacatalogue.grsf_manage_widget.client.view.subwidgets.SuggestMerges;
|
2017-01-26 18:21:33 +01:00
|
|
|
import org.gcube.datacatalogue.grsf_manage_widget.shared.ManageProductBean;
|
2017-11-09 22:11:10 +01:00
|
|
|
import org.gcube.datacatalogue.grsf_manage_widget.shared.SimilarGRSFRecord;
|
|
|
|
import org.gcube.datacatalogue.grsf_manage_widget.shared.SourceRecord;
|
2017-01-26 18:21:33 +01:00
|
|
|
import org.gcube.datacatalogue.grsf_manage_widget.shared.ex.NoGRSFRecordException;
|
|
|
|
|
|
|
|
import com.github.gwtbootstrap.client.ui.AlertBlock;
|
|
|
|
import com.github.gwtbootstrap.client.ui.Button;
|
2017-08-01 18:18:29 +02:00
|
|
|
import com.github.gwtbootstrap.client.ui.CheckBox;
|
2017-01-26 18:21:33 +01:00
|
|
|
import com.github.gwtbootstrap.client.ui.ControlGroup;
|
|
|
|
import com.github.gwtbootstrap.client.ui.Form;
|
|
|
|
import com.github.gwtbootstrap.client.ui.Icon;
|
|
|
|
import com.github.gwtbootstrap.client.ui.Image;
|
|
|
|
import com.github.gwtbootstrap.client.ui.ListBox;
|
|
|
|
import com.github.gwtbootstrap.client.ui.Modal;
|
|
|
|
import com.github.gwtbootstrap.client.ui.TextArea;
|
|
|
|
import com.github.gwtbootstrap.client.ui.TextBox;
|
|
|
|
import com.github.gwtbootstrap.client.ui.constants.AlertType;
|
|
|
|
import com.google.gwt.core.client.GWT;
|
|
|
|
import com.google.gwt.dom.client.SelectElement;
|
2018-01-23 18:25:16 +01:00
|
|
|
import com.google.gwt.dom.client.Style.Unit;
|
2017-01-26 18:21:33 +01:00
|
|
|
import com.google.gwt.event.dom.client.ClickEvent;
|
2017-11-09 14:49:07 +01:00
|
|
|
import com.google.gwt.event.shared.HandlerManager;
|
2017-01-26 18:21:33 +01:00
|
|
|
import com.google.gwt.uibinder.client.UiBinder;
|
|
|
|
import com.google.gwt.uibinder.client.UiField;
|
|
|
|
import com.google.gwt.uibinder.client.UiHandler;
|
|
|
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
|
|
|
import com.google.gwt.user.client.ui.Composite;
|
|
|
|
import com.google.gwt.user.client.ui.HTML;
|
2017-11-09 22:11:10 +01:00
|
|
|
import com.google.gwt.user.client.ui.VerticalPanel;
|
2017-01-26 18:21:33 +01:00
|
|
|
import com.google.gwt.user.client.ui.Widget;
|
|
|
|
|
2017-11-09 22:11:10 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Management widget main panel.
|
|
|
|
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
|
|
|
|
*/
|
2017-01-26 18:21:33 +01:00
|
|
|
public class ManageProductWidget extends Composite{
|
|
|
|
|
2017-01-27 16:14:14 +01:00
|
|
|
private static GRSFManageWidgetServiceAsync service = GWT.create(GRSFManageWidgetService.class);
|
2017-01-26 18:21:33 +01:00
|
|
|
|
2018-02-04 17:42:34 +01:00
|
|
|
private static ManageProductWidgetUiBinder uiBinder = GWT.create(ManageProductWidgetUiBinder.class);
|
2017-01-26 18:21:33 +01:00
|
|
|
|
|
|
|
interface ManageProductWidgetUiBinder extends
|
|
|
|
UiBinder<Widget, ManageProductWidget> {
|
|
|
|
}
|
|
|
|
|
2017-12-22 12:28:24 +01:00
|
|
|
@UiField
|
|
|
|
VerticalPanel container;
|
2018-01-23 18:25:16 +01:00
|
|
|
|
2017-01-26 18:21:33 +01:00
|
|
|
@UiField
|
|
|
|
Modal manageProductModal;
|
|
|
|
|
|
|
|
@UiField
|
|
|
|
AlertBlock infoBlock;
|
|
|
|
|
2017-08-01 18:00:19 +02:00
|
|
|
@UiField
|
2017-08-02 15:35:51 +02:00
|
|
|
TextArea shortNameTextBox;
|
2017-02-20 16:16:57 +01:00
|
|
|
|
2017-02-19 16:41:36 +01:00
|
|
|
@UiField
|
|
|
|
TextBox productGrsfType;
|
2017-11-09 22:11:10 +01:00
|
|
|
|
2017-08-01 18:18:29 +02:00
|
|
|
@UiField
|
|
|
|
CheckBox traceabilityFlag;
|
2017-11-09 22:11:10 +01:00
|
|
|
|
2017-08-01 18:00:19 +02:00
|
|
|
@UiField
|
2017-08-02 15:35:51 +02:00
|
|
|
TextArea GRSFNameTexBox;
|
2017-11-09 22:11:10 +01:00
|
|
|
|
2017-08-01 18:00:19 +02:00
|
|
|
@UiField
|
2017-08-02 15:35:51 +02:00
|
|
|
TextArea semanticIdentifierTextBox;
|
2017-02-19 16:41:36 +01:00
|
|
|
|
2017-08-01 18:00:19 +02:00
|
|
|
@UiField
|
2017-11-09 22:11:10 +01:00
|
|
|
VerticalPanel panelForSourceItems;
|
|
|
|
|
2018-02-03 19:17:37 +01:00
|
|
|
@UiField
|
|
|
|
ControlGroup similarGRSFRecordGroup;
|
|
|
|
|
2017-11-09 22:11:10 +01:00
|
|
|
@UiField
|
|
|
|
VerticalPanel panelForSimilarGRSFRecords;
|
2018-02-02 17:32:30 +01:00
|
|
|
|
2018-01-23 18:25:16 +01:00
|
|
|
@UiField
|
|
|
|
VerticalPanel panelForFurtherMerges;
|
2017-11-09 22:11:10 +01:00
|
|
|
|
|
|
|
@UiField
|
|
|
|
VerticalPanel panelForConnectOtherRecords;
|
2017-01-26 18:21:33 +01:00
|
|
|
|
|
|
|
@UiField
|
|
|
|
TextBox currentStatus;
|
|
|
|
|
|
|
|
@UiField
|
|
|
|
ListBox listBoxStatus;
|
|
|
|
|
|
|
|
@UiField
|
|
|
|
TextArea annotationArea;
|
|
|
|
|
|
|
|
@UiField
|
|
|
|
Button cancelButton;
|
|
|
|
|
|
|
|
@UiField
|
|
|
|
Button confirmButton;
|
|
|
|
|
|
|
|
@UiField
|
|
|
|
Icon loaderIcon;
|
|
|
|
|
|
|
|
@UiField
|
|
|
|
ControlGroup listBoxStatusGroup;
|
2017-02-20 16:16:57 +01:00
|
|
|
|
2017-02-20 12:21:52 +01:00
|
|
|
@UiField
|
|
|
|
ControlGroup annotationAreaGroup;
|
2017-02-20 16:16:57 +01:00
|
|
|
|
2017-02-20 12:21:52 +01:00
|
|
|
@UiField
|
2017-02-20 16:16:57 +01:00
|
|
|
ControlGroup productGrsfTypeGroup;
|
2017-01-26 18:21:33 +01:00
|
|
|
|
|
|
|
@UiField
|
|
|
|
Form formUpdate;
|
|
|
|
|
|
|
|
@UiField
|
|
|
|
Image loadingImage;
|
|
|
|
|
|
|
|
public static final String LOADING_IMAGE_URL = GWT.getModuleBaseURL() + "../images/loader.gif";
|
2017-11-09 22:11:10 +01:00
|
|
|
|
|
|
|
// messages used here and there
|
2017-12-07 12:37:21 +01:00
|
|
|
private final static String STATUS_UPDATE_SUCCESS = "The record has been correctly updated. Thanks for your collaboration!";
|
|
|
|
private final static String STATUS_UPDATE_ERROR = "Sorry, there was a problem while trying to update the status of this record";
|
2017-01-26 18:21:33 +01:00
|
|
|
protected static final String ERROR_ON_RETRIEVING_BEAN = "It seems there was a problem while contacting the service...";
|
2017-12-07 12:37:21 +01:00
|
|
|
protected static final String NO_GRSF_RECORD_BEAN = "This record is not a GRSF record, thus it cannot be managed";
|
|
|
|
protected static final String NO_ADMIN_ROLE = "Sorry but it seems you do not have the rights to manage records."
|
2018-02-03 19:17:37 +01:00
|
|
|
+ " You are suggested to contact the VRE Manager if something is wrong with this.";
|
2017-01-26 18:21:33 +01:00
|
|
|
|
2017-11-09 22:11:10 +01:00
|
|
|
// event bus shared with the portlet
|
2017-11-09 14:49:07 +01:00
|
|
|
private HandlerManager eventBus = null;
|
2017-11-09 22:11:10 +01:00
|
|
|
|
|
|
|
// the objects to be managed
|
|
|
|
private ManageProductBean bean;
|
|
|
|
private final static List<Status> STATUS = new ArrayList<Status>(Arrays.asList(Status.values()));
|
2017-12-07 12:37:21 +01:00
|
|
|
|
|
|
|
// similar records and to connect widgets references
|
2017-11-23 20:04:47 +01:00
|
|
|
private SimilarGRSFRecordWidget similarRecordPanel;
|
2018-01-23 18:25:16 +01:00
|
|
|
private SuggestMerges suggestedMergesPanel;
|
2017-11-23 20:04:47 +01:00
|
|
|
private ConnectToWidget connectWidget;
|
2017-11-09 22:11:10 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Build a ManageProduct widget for the product with the specified id.
|
|
|
|
* @param productIdentifier
|
|
|
|
* @param eventBus
|
|
|
|
*/
|
2017-11-09 14:49:07 +01:00
|
|
|
public ManageProductWidget(String productIdentifier, HandlerManager eventBus) {
|
2017-01-26 18:21:33 +01:00
|
|
|
initWidget(uiBinder.createAndBindUi(this));
|
2017-11-09 14:49:07 +01:00
|
|
|
this.eventBus = eventBus;
|
2017-11-09 22:11:10 +01:00
|
|
|
|
2017-02-16 18:32:19 +01:00
|
|
|
GWT.log("item identifier is " + productIdentifier);
|
2017-01-26 18:21:33 +01:00
|
|
|
|
2017-11-09 22:11:10 +01:00
|
|
|
if(productIdentifier == null || productIdentifier.isEmpty())
|
|
|
|
return;
|
|
|
|
|
2017-01-26 18:21:33 +01:00
|
|
|
// start loader service
|
|
|
|
loadingImage.setUrl(LOADING_IMAGE_URL);
|
|
|
|
loadingImage.setVisible(true);
|
2017-08-03 17:21:26 +02:00
|
|
|
formUpdate.setVisible(false);
|
2017-11-09 22:11:10 +01:00
|
|
|
|
|
|
|
// show modal
|
2017-12-18 11:26:32 +01:00
|
|
|
manageProductModal.addStyleName("management-metadata-modal-style");
|
2018-02-04 17:42:34 +01:00
|
|
|
manageProductModal.getElement().getStyle().setWidth(60, Unit.PCT);
|
2017-12-22 11:43:26 +01:00
|
|
|
manageProductModal.show();
|
2017-02-20 16:16:57 +01:00
|
|
|
|
2017-01-26 18:21:33 +01:00
|
|
|
// async request to fetch the product
|
|
|
|
retrieveProductBean(productIdentifier);
|
|
|
|
}
|
|
|
|
|
2017-11-09 22:11:10 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Actually builds the widget... asks for details about the record
|
|
|
|
* @param productIdentifier
|
|
|
|
*/
|
2017-02-16 18:32:19 +01:00
|
|
|
private void retrieveProductBean(final String productIdentifier) {
|
2017-01-26 18:21:33 +01:00
|
|
|
|
2017-02-16 18:32:19 +01:00
|
|
|
// check if it is an administrator
|
|
|
|
service.isAdminUser(new AsyncCallback<Boolean>() {
|
2017-01-26 18:21:33 +01:00
|
|
|
|
|
|
|
@Override
|
2017-02-16 18:32:19 +01:00
|
|
|
public void onSuccess(Boolean result) {
|
|
|
|
|
|
|
|
if(!result){
|
2017-02-20 16:16:57 +01:00
|
|
|
|
2017-02-16 18:38:37 +01:00
|
|
|
showInfo(NO_ADMIN_ROLE, AlertType.ERROR);
|
2017-02-20 16:16:57 +01:00
|
|
|
|
2017-02-16 18:32:19 +01:00
|
|
|
// hide the form and disable the send button
|
2017-01-26 18:21:33 +01:00
|
|
|
formUpdate.setVisible(false);
|
|
|
|
confirmButton.setEnabled(false);
|
2017-02-16 18:32:19 +01:00
|
|
|
loadingImage.setVisible(false);
|
2017-11-09 22:11:10 +01:00
|
|
|
|
2017-11-09 14:49:07 +01:00
|
|
|
// ask to hide management panel
|
2017-12-18 11:08:02 +01:00
|
|
|
if(eventBus != null){
|
2017-11-09 22:11:10 +01:00
|
|
|
eventBus.fireEvent(new HideManagementPanelEvent());
|
2017-12-18 11:08:02 +01:00
|
|
|
GWT.log("Hide management panel event sent");
|
|
|
|
}
|
2017-02-16 18:32:19 +01:00
|
|
|
}else{
|
|
|
|
service.getProductBeanById(productIdentifier, new AsyncCallback<ManageProductBean>() {
|
|
|
|
|
|
|
|
@Override
|
2017-11-15 19:22:20 +01:00
|
|
|
public void onSuccess(ManageProductBean resBean) {
|
|
|
|
|
|
|
|
if(resBean == null){
|
2017-11-09 22:11:10 +01:00
|
|
|
showInfo(ERROR_ON_RETRIEVING_BEAN, AlertType.ERROR);
|
|
|
|
formUpdate.setVisible(false);
|
|
|
|
confirmButton.setEnabled(false);
|
|
|
|
}else{
|
2017-11-15 19:22:20 +01:00
|
|
|
bean = resBean;
|
2017-02-16 18:32:19 +01:00
|
|
|
infoBlock.setVisible(false);
|
2017-11-15 19:22:20 +01:00
|
|
|
|
2017-11-09 22:11:10 +01:00
|
|
|
// top: more or less fixed information
|
|
|
|
GRSFNameTexBox.setText(bean.getGrsfName());
|
2017-08-02 14:09:02 +02:00
|
|
|
shortNameTextBox.setText(bean.getShortName());
|
2017-11-09 22:11:10 +01:00
|
|
|
semanticIdentifierTextBox.setText(bean.getSemanticIdentifier());
|
2017-02-19 16:41:36 +01:00
|
|
|
productGrsfType.setText(bean.getGrsfType());
|
2017-11-09 22:11:10 +01:00
|
|
|
currentStatus.setText(bean.getCurrentStatus().toString());
|
2017-08-01 18:18:29 +02:00
|
|
|
traceabilityFlag.setValue(bean.isTraceabilityFlag());
|
2018-01-23 18:25:16 +01:00
|
|
|
traceabilityFlag.setText("Traceability");
|
|
|
|
traceabilityFlag.setTitle("Current value for this flag in the Knowledge Base is " + bean.isTraceabilityFlag());
|
2017-11-09 22:11:10 +01:00
|
|
|
|
|
|
|
// manage sources
|
|
|
|
List<SourceRecord> availableSources = bean.getSources();
|
|
|
|
panelForSourceItems.add(new SourceWidget(availableSources));
|
|
|
|
|
|
|
|
// manage similar GRSF records, if any
|
2018-02-03 19:17:37 +01:00
|
|
|
if(bean.getSimilarGrsfRecords() != null && !bean.getSimilarGrsfRecords().isEmpty()){
|
|
|
|
List<SimilarGRSFRecord> availableGRSFSimilarRecords = bean.getSimilarGrsfRecords();
|
|
|
|
similarRecordPanel = new SimilarGRSFRecordWidget(availableGRSFSimilarRecords);
|
|
|
|
panelForSimilarGRSFRecords.add(similarRecordPanel);
|
|
|
|
}else
|
|
|
|
similarGRSFRecordGroup.setVisible(false);
|
2018-02-02 17:32:30 +01:00
|
|
|
|
2018-01-23 18:25:16 +01:00
|
|
|
// further suggested merges
|
|
|
|
suggestedMergesPanel = new SuggestMerges(service);
|
|
|
|
panelForFurtherMerges.add(suggestedMergesPanel);
|
2017-11-09 22:11:10 +01:00
|
|
|
|
|
|
|
// prepare "connect" panel
|
2018-01-23 18:25:16 +01:00
|
|
|
connectWidget = new ConnectToWidget(bean, service);
|
2017-11-23 20:04:47 +01:00
|
|
|
panelForConnectOtherRecords.add(connectWidget);
|
2017-02-20 16:16:57 +01:00
|
|
|
|
2017-11-09 22:11:10 +01:00
|
|
|
// check for new status box
|
2017-10-27 17:48:51 +02:00
|
|
|
List<Status> statusToShow = new ArrayList<Status>(STATUS);
|
2017-02-16 18:32:19 +01:00
|
|
|
statusToShow.remove(bean.getCurrentStatus());
|
2018-02-03 19:17:37 +01:00
|
|
|
statusToShow.remove(Status.To_be_Merged); // it cannot be set by a user
|
2017-11-09 22:11:10 +01:00
|
|
|
|
2017-08-02 14:16:50 +02:00
|
|
|
// if the record isn't approved, then remove also archived
|
2017-10-27 17:48:51 +02:00
|
|
|
if(!bean.getCurrentStatus().equals(Status.Approved))
|
|
|
|
statusToShow.remove(Status.Archived);
|
2017-11-09 22:11:10 +01:00
|
|
|
|
2018-02-03 19:17:37 +01:00
|
|
|
listBoxStatus.addItem("Select a new status");
|
2017-02-16 18:32:19 +01:00
|
|
|
listBoxStatus.getElement().<SelectElement>cast().getOptions().getItem(0).setDisabled(true);
|
2017-10-27 17:48:51 +02:00
|
|
|
for (Status availableStatus : statusToShow) {
|
2017-02-16 18:32:19 +01:00
|
|
|
listBoxStatus.addItem(availableStatus.toString());
|
|
|
|
}
|
|
|
|
listBoxStatus.setSelectedIndex(0);
|
2017-11-09 22:11:10 +01:00
|
|
|
|
|
|
|
formUpdate.setVisible(true);
|
2017-02-16 18:32:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
loadingImage.setVisible(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onFailure(Throwable caught) {
|
|
|
|
|
|
|
|
if(caught instanceof NoGRSFRecordException)
|
|
|
|
showInfo(NO_GRSF_RECORD_BEAN, AlertType.WARNING);
|
|
|
|
else
|
2017-11-14 18:37:07 +01:00
|
|
|
showInfo("Error is " + caught, AlertType.ERROR);
|
2017-02-16 18:32:19 +01:00
|
|
|
|
|
|
|
// hide the form and disable the send button
|
|
|
|
formUpdate.setVisible(false);
|
|
|
|
confirmButton.setEnabled(false);
|
|
|
|
loadingImage.setVisible(false);
|
|
|
|
}
|
|
|
|
});
|
2017-01-26 18:21:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onFailure(Throwable caught) {
|
2017-02-20 16:16:57 +01:00
|
|
|
|
2017-02-16 18:38:37 +01:00
|
|
|
showInfo(NO_ADMIN_ROLE, AlertType.ERROR);
|
2017-02-20 16:16:57 +01:00
|
|
|
|
2017-01-26 18:21:33 +01:00
|
|
|
// hide the form and disable the send button
|
|
|
|
formUpdate.setVisible(false);
|
|
|
|
confirmButton.setEnabled(false);
|
|
|
|
loadingImage.setVisible(false);
|
2017-02-16 18:32:19 +01:00
|
|
|
|
2017-01-26 18:21:33 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
2017-02-20 16:16:57 +01:00
|
|
|
|
2017-01-26 18:21:33 +01:00
|
|
|
@UiHandler("confirmButton")
|
|
|
|
void onSaveButton(ClickEvent ce){
|
|
|
|
|
2018-02-03 19:17:37 +01:00
|
|
|
// if the status has not be changed ...
|
|
|
|
if(listBoxStatus.getSelectedIndex() <= 0)
|
|
|
|
bean.setNewStatus(bean.getCurrentStatus());
|
|
|
|
else
|
|
|
|
bean.setNewStatus(Status.fromString(listBoxStatus.getSelectedItemText()));
|
2018-02-03 20:44:21 +01:00
|
|
|
|
2017-01-26 18:21:33 +01:00
|
|
|
manageProductModal.setCloseVisible(false);
|
|
|
|
cancelButton.setEnabled(false);
|
|
|
|
confirmButton.setEnabled(false);
|
|
|
|
loaderIcon.setVisible(true);
|
2017-12-07 12:37:21 +01:00
|
|
|
|
|
|
|
// get short name
|
|
|
|
bean.setShortNameUpdated(shortNameTextBox.getText());
|
|
|
|
|
2018-02-02 17:32:30 +01:00
|
|
|
// evaluate the connections and the actions on them
|
|
|
|
bean.setConnections(connectWidget.getConnectList());
|
2018-02-03 19:17:37 +01:00
|
|
|
|
2017-11-23 20:04:47 +01:00
|
|
|
// update similar records and to connect
|
2018-02-03 19:17:37 +01:00
|
|
|
if(similarRecordPanel != null)
|
|
|
|
bean.setSimilarGrsfRecords(similarRecordPanel.getSimilarRecords());
|
2018-02-03 20:44:21 +01:00
|
|
|
else
|
2018-02-04 17:42:34 +01:00
|
|
|
bean.setSimilarGrsfRecords(new ArrayList<SimilarGRSFRecord>(0));
|
2018-02-03 19:17:37 +01:00
|
|
|
|
2018-02-03 20:44:21 +01:00
|
|
|
// add the suggested ones, if any
|
2018-01-23 18:25:16 +01:00
|
|
|
bean.getSimilarGrsfRecords().addAll(suggestedMergesPanel.getSimilarRecords());
|
2017-01-26 18:21:33 +01:00
|
|
|
|
2018-02-04 17:42:34 +01:00
|
|
|
// set the merge operator on the bean if there is at least one merge to be done
|
|
|
|
for(SimilarGRSFRecord sR: bean.getSimilarGrsfRecords()){
|
|
|
|
if(sR.isSuggestedMerge()){
|
|
|
|
bean.setMergesInvolved(true);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-26 18:21:33 +01:00
|
|
|
// set new values
|
|
|
|
bean.setAnnotation(new HTML(annotationArea.getText().trim()).getText());
|
2018-01-23 18:25:16 +01:00
|
|
|
|
2017-12-07 12:37:21 +01:00
|
|
|
// traceability flag
|
|
|
|
bean.setTraceabilityFlag(traceabilityFlag.getValue());
|
2017-01-26 18:21:33 +01:00
|
|
|
|
2018-02-03 19:17:37 +01:00
|
|
|
service.notifyProductUpdate(bean, new AsyncCallback<String>() {
|
2017-01-26 18:21:33 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onSuccess(String result) {
|
|
|
|
|
|
|
|
if(result == null){
|
|
|
|
showInfo(STATUS_UPDATE_SUCCESS, AlertType.SUCCESS);
|
|
|
|
confirmButton.removeFromParent();
|
|
|
|
formUpdate.setVisible(false);
|
|
|
|
|
|
|
|
}else{
|
|
|
|
showInfo(STATUS_UPDATE_ERROR + "(" + result + ")", AlertType.ERROR);
|
|
|
|
confirmButton.setEnabled(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
manageProductModal.setCloseVisible(true);
|
|
|
|
cancelButton.setEnabled(true);
|
|
|
|
loaderIcon.setVisible(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onFailure(Throwable caught) {
|
|
|
|
manageProductModal.setCloseVisible(true);
|
|
|
|
cancelButton.setEnabled(true);
|
|
|
|
confirmButton.setEnabled(true);
|
|
|
|
loaderIcon.setVisible(false);
|
2017-12-13 18:34:45 +01:00
|
|
|
showInfo(STATUS_UPDATE_ERROR + ": " + caught.getMessage(), AlertType.ERROR);
|
2017-01-26 18:21:33 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
2017-11-15 19:22:20 +01:00
|
|
|
|
2017-11-09 22:11:10 +01:00
|
|
|
@UiHandler("cancelButton")
|
|
|
|
void onCancelButton(ClickEvent ce){
|
|
|
|
manageProductModal.hide();
|
|
|
|
}
|
2017-01-26 18:21:33 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Show information
|
|
|
|
* @param statusUpdateError
|
|
|
|
*/
|
|
|
|
protected void showInfo(String statusUpdateError, AlertType type) {
|
|
|
|
infoBlock.setText(statusUpdateError);
|
|
|
|
infoBlock.setType(type);
|
|
|
|
infoBlock.setVisible(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|