Minor fixes
git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/gcube-ckan-datacatalog@135100 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
001789ded1
commit
55907603bb
|
@ -28,6 +28,7 @@ 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;
|
||||
import com.google.gwt.user.client.ui.Widget;
|
||||
|
||||
public class ManageProductWidget extends Composite{
|
||||
|
@ -81,7 +82,7 @@ public class ManageProductWidget extends Composite{
|
|||
Image loadingImage;
|
||||
|
||||
public static final String LOADING_IMAGE_URL = GWT.getModuleBaseURL() + "../images/loader.gif";
|
||||
private final static List<String> STATUS = Arrays.asList("confirmed", "rejected", "pending");
|
||||
private final static List<String> STATUS = Arrays.asList("Confirmed", "Rejected", "Pending");
|
||||
private final static String STATUS_UPDATE_SUCCESS = "The product was 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 product";
|
||||
protected static final String ERROR_ON_RETRIEVING_BEAN = "It seems there is a problem while contacting the service...";
|
||||
|
@ -121,12 +122,13 @@ public class ManageProductWidget extends Composite{
|
|||
currentStatus.setText(bean.getCurrentStatus());
|
||||
productType.setText(bean.getProductType());
|
||||
List<String> statusToShow = new ArrayList<String>(STATUS);
|
||||
statusToShow.remove(bean.getCurrentStatus().toLowerCase());
|
||||
statusToShow.remove(bean.getCurrentStatus());
|
||||
listBoxStatus.addItem("Select the new status");
|
||||
listBoxStatus.getElement().<SelectElement>cast().getOptions().getItem(0).setDisabled(true);
|
||||
for (String availableStatus : statusToShow) {
|
||||
listBoxStatus.addItem(availableStatus);
|
||||
}
|
||||
listBoxStatus.setSelectedIndex(0);
|
||||
}
|
||||
else{
|
||||
showInfo(ERROR_ON_RETRIEVING_BEAN, AlertType.ERROR);
|
||||
|
@ -158,7 +160,7 @@ public class ManageProductWidget extends Composite{
|
|||
|
||||
listBoxStatusGroup.setType(ControlGroupType.NONE);
|
||||
|
||||
if(listBoxStatus.getSelectedIndex() < 0){
|
||||
if(listBoxStatus.getSelectedIndex() <= 0){
|
||||
listBoxStatusGroup.setType(ControlGroupType.ERROR);
|
||||
return;
|
||||
}
|
||||
|
@ -169,7 +171,7 @@ public class ManageProductWidget extends Composite{
|
|||
loaderIcon.setVisible(true);
|
||||
|
||||
// set new values
|
||||
bean.setAnnotation(annotationArea.getText());
|
||||
bean.setAnnotation(new HTML(annotationArea.getText()).getText());
|
||||
bean.setNewStatus(listBoxStatus.getSelectedItemText());
|
||||
|
||||
service.notifyProductUpdate(bean, new AsyncCallback<Boolean>() {
|
||||
|
|
|
@ -37,6 +37,7 @@ public class GRSFNotificationServices {
|
|||
private static final String PRODUCT_TYPE = "type";
|
||||
private static final String STATUS = "status";
|
||||
private static final String ANNOTATION = "annotation_msg";
|
||||
private static final String ERROR = "error";
|
||||
private static final int STATUS_SUCCESS = 200;
|
||||
|
||||
/**
|
||||
|
@ -72,7 +73,7 @@ public class GRSFNotificationServices {
|
|||
obj.put(CATALOGUE_ID, bean.getCatalogueIdentifier());
|
||||
obj.put(KB_ID, bean.getKnowledgeBaseIdentifier());
|
||||
obj.put(PRODUCT_TYPE, bean.getProductType().toLowerCase());
|
||||
obj.put(STATUS, bean.getNewStatus());
|
||||
obj.put(STATUS, bean.getNewStatus().toLowerCase());
|
||||
|
||||
String annotation = bean.getAnnotation();
|
||||
if(annotation != null)
|
||||
|
@ -96,7 +97,7 @@ public class GRSFNotificationServices {
|
|||
if(response.getStatusLine().getStatusCode() > STATUS_SUCCESS)
|
||||
throw new IllegalArgumentException(
|
||||
"Error while performing the update request: " + response.getStatusLine().getReasonPhrase() +
|
||||
"and error in the result bean is " + parsedJSON.get("error"));
|
||||
"and error in the result bean is " + parsedJSON.get(ERROR));
|
||||
|
||||
// patch the catalogue product
|
||||
Map<String, List<String>> statusMap = new HashMap<String, List<String>>();
|
||||
|
@ -116,7 +117,7 @@ public class GRSFNotificationServices {
|
|||
/**
|
||||
* Convert an input stream to a string
|
||||
* @param is
|
||||
* @return
|
||||
* @return the json string inside
|
||||
*/
|
||||
private static String convertStreamToString(InputStream is) {
|
||||
|
||||
|
@ -139,6 +140,5 @@ public class GRSFNotificationServices {
|
|||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue