task_21363 #1
|
@ -29,11 +29,14 @@ public interface CkanContentModeratorService extends RemoteService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the status.
|
* Sets the status.
|
||||||
|
* Currently, this only used to change the status from Rejected to Pending
|
||||||
*
|
*
|
||||||
* @param theStatus the the status
|
* @param theStatus the the status
|
||||||
* @param itemNames the item names
|
* @param itemNames the item names
|
||||||
|
* @return the operation report
|
||||||
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public void setStatus(ItemStatus theStatus, List<String> itemNames);
|
public OperationReport setStatus(ItemStatus theStatus, List<String> itemNames) throws Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reject item.
|
* Reject item.
|
||||||
|
|
|
@ -9,7 +9,6 @@ import org.gcube.portlets.widgets.ckancontentmoderator.shared.SearchedData;
|
||||||
|
|
||||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Interface CkanContentModeratorServiceAsync.
|
* The Interface CkanContentModeratorServiceAsync.
|
||||||
*
|
*
|
||||||
|
@ -86,6 +85,6 @@ public interface CkanContentModeratorServiceAsync {
|
||||||
* @param itemNames the item names
|
* @param itemNames the item names
|
||||||
* @param callback the callback
|
* @param callback the callback
|
||||||
*/
|
*/
|
||||||
void setStatus(ItemStatus theStatus, List<String> itemNames, AsyncCallback<Void> callback);
|
void setStatus(ItemStatus theStatus, List<String> itemNames, AsyncCallback<OperationReport> callback);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -173,7 +173,7 @@ public class CkanContentModeratorWidgetController {
|
||||||
|
|
||||||
if(statusSelectedEvent.getDisplayMessage()!=null) {
|
if(statusSelectedEvent.getDisplayMessage()!=null) {
|
||||||
final Alert alert = new Alert(statusSelectedEvent.getDisplayMessage());
|
final Alert alert = new Alert(statusSelectedEvent.getDisplayMessage());
|
||||||
alert.setType(AlertType.INFO);
|
alert.setType(statusSelectedEvent.getAlertType());
|
||||||
alert.setClose(true);
|
alert.setClose(true);
|
||||||
alert.setAnimation(true);
|
alert.setAnimation(true);
|
||||||
infoPanel.add(alert);
|
infoPanel.add(alert);
|
||||||
|
|
|
@ -2,6 +2,7 @@ package org.gcube.portlets.widgets.ckancontentmoderator.client.events;
|
||||||
|
|
||||||
import org.gcube.datacatalogue.utillibrary.shared.ItemStatus;
|
import org.gcube.datacatalogue.utillibrary.shared.ItemStatus;
|
||||||
|
|
||||||
|
import com.github.gwtbootstrap.client.ui.constants.AlertType;
|
||||||
import com.google.gwt.event.shared.GwtEvent;
|
import com.google.gwt.event.shared.GwtEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -15,16 +16,19 @@ public class SelectItemsWithItemStatusEvent extends GwtEvent<SelectItemsWithItem
|
||||||
public static Type<SelectItemsWithItemStatusEventHandler> TYPE = new Type<SelectItemsWithItemStatusEventHandler>();
|
public static Type<SelectItemsWithItemStatusEventHandler> TYPE = new Type<SelectItemsWithItemStatusEventHandler>();
|
||||||
private ItemStatus itemStatus;
|
private ItemStatus itemStatus;
|
||||||
private String displayMessage;
|
private String displayMessage;
|
||||||
|
private AlertType alertType = AlertType.INFO;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new click item event.
|
* Instantiates a new click item event.
|
||||||
*
|
*
|
||||||
* @param itemStatus the item status
|
* @param itemStatus the item status
|
||||||
* @param displayMessage the display message
|
* @param displayMessage the display message
|
||||||
|
* @param alerType the aler type
|
||||||
*/
|
*/
|
||||||
public SelectItemsWithItemStatusEvent(ItemStatus itemStatus, String displayMessage) {
|
public SelectItemsWithItemStatusEvent(ItemStatus itemStatus, String displayMessage, AlertType alerType) {
|
||||||
this.itemStatus = itemStatus;
|
this.itemStatus = itemStatus;
|
||||||
this.displayMessage = displayMessage;
|
this.displayMessage = displayMessage;
|
||||||
|
this.alertType = alerType;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -65,4 +69,13 @@ public class SelectItemsWithItemStatusEvent extends GwtEvent<SelectItemsWithItem
|
||||||
return displayMessage;
|
return displayMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the alert type.
|
||||||
|
*
|
||||||
|
* @return the alert type
|
||||||
|
*/
|
||||||
|
public AlertType getAlertType() {
|
||||||
|
return alertType;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,9 +65,9 @@ public class ContentModeratorToolbar extends Composite {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(ClickEvent event) {
|
public void onClick(ClickEvent event) {
|
||||||
GWT.log("clicked: "+status);
|
GWT.log("clicked: " + status);
|
||||||
setActiveStatus(status);
|
setActiveStatus(status);
|
||||||
eventBus.fireEvent(new SelectItemsWithItemStatusEvent(status, null));
|
eventBus.fireEvent(new SelectItemsWithItemStatusEvent(status, null, null));
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -19,6 +19,7 @@ import com.github.gwtbootstrap.client.ui.Dropdown;
|
||||||
import com.github.gwtbootstrap.client.ui.Heading;
|
import com.github.gwtbootstrap.client.ui.Heading;
|
||||||
import com.github.gwtbootstrap.client.ui.NavLink;
|
import com.github.gwtbootstrap.client.ui.NavLink;
|
||||||
import com.github.gwtbootstrap.client.ui.base.AlertBase;
|
import com.github.gwtbootstrap.client.ui.base.AlertBase;
|
||||||
|
import com.github.gwtbootstrap.client.ui.constants.AlertType;
|
||||||
import com.github.gwtbootstrap.client.ui.event.ClosedEvent;
|
import com.github.gwtbootstrap.client.ui.event.ClosedEvent;
|
||||||
import com.github.gwtbootstrap.client.ui.event.ClosedHandler;
|
import com.github.gwtbootstrap.client.ui.event.ClosedHandler;
|
||||||
import com.google.gwt.core.client.GWT;
|
import com.google.gwt.core.client.GWT;
|
||||||
|
@ -29,6 +30,7 @@ import com.google.gwt.event.logical.shared.ValueChangeHandler;
|
||||||
import com.google.gwt.event.shared.HandlerManager;
|
import com.google.gwt.event.shared.HandlerManager;
|
||||||
import com.google.gwt.uibinder.client.UiBinder;
|
import com.google.gwt.uibinder.client.UiBinder;
|
||||||
import com.google.gwt.uibinder.client.UiField;
|
import com.google.gwt.uibinder.client.UiField;
|
||||||
|
import com.google.gwt.user.client.Window;
|
||||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||||
import com.google.gwt.user.client.ui.Composite;
|
import com.google.gwt.user.client.ui.Composite;
|
||||||
import com.google.gwt.user.client.ui.HTMLPanel;
|
import com.google.gwt.user.client.ui.HTMLPanel;
|
||||||
|
@ -246,7 +248,7 @@ public class HomeView extends Composite {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
DoActionCMSView doActionCMS = new DoActionCMSView();
|
final DoActionCMSView doActionCMS = new DoActionCMSView();
|
||||||
final List<CatalogueDataset> selectedItems = paginatedView.getSelectItems();
|
final List<CatalogueDataset> selectedItems = paginatedView.getSelectItems();
|
||||||
doActionCMS.updateStatus(fromStatus, toStatus, selectedItems);
|
doActionCMS.updateStatus(fromStatus, toStatus, selectedItems);
|
||||||
|
|
||||||
|
@ -266,21 +268,21 @@ public class HomeView extends Composite {
|
||||||
public void onClick(ClickEvent event) {
|
public void onClick(ClickEvent event) {
|
||||||
confirmPanelContainer.clear();
|
confirmPanelContainer.clear();
|
||||||
|
|
||||||
|
performCMSAction(doActionCMS);
|
||||||
|
// TODO DO ACTION UPDATE STATUS OR DELETE PERMANENTLY
|
||||||
|
|
||||||
//TODO DO ACTION UPDATE STATUS OR DELETE PERMANENTLY
|
// int count = selectedItems.size();
|
||||||
|
// String msg = "";
|
||||||
int count = selectedItems.size();
|
// if (count > 0) {
|
||||||
String msg = "";
|
// if (count == 1) {
|
||||||
if (count > 0) {
|
// msg += "One item";
|
||||||
if (count == 1) {
|
// } else {
|
||||||
msg += "One item";
|
// msg += count + " items";
|
||||||
} else {
|
// }
|
||||||
msg += count + " items";
|
//
|
||||||
}
|
// msg += " moved to " + toStatus + " status";
|
||||||
|
// }
|
||||||
msg += " moved to " + toStatus + " status";
|
// eventBus.fireEvent(new SelectItemsWithItemStatusEvent(displayingItemStatus, msg));
|
||||||
}
|
|
||||||
eventBus.fireEvent(new SelectItemsWithItemStatusEvent(displayingItemStatus, msg));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -324,10 +326,7 @@ public class HomeView extends Composite {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(ClickEvent event) {
|
public void onClick(ClickEvent event) {
|
||||||
confirmPanelContainer.clear();
|
confirmPanelContainer.clear();
|
||||||
|
AlertType alert = AlertType.SUCCESS;
|
||||||
|
|
||||||
//TODO DO ACTION DELETE PERMANENTLY
|
|
||||||
|
|
||||||
int count = selectedItems.size();
|
int count = selectedItems.size();
|
||||||
String msg = "Deleted permanently";
|
String msg = "Deleted permanently";
|
||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
|
@ -339,7 +338,7 @@ public class HomeView extends Composite {
|
||||||
|
|
||||||
msg += " from Catalogue";
|
msg += " from Catalogue";
|
||||||
}
|
}
|
||||||
eventBus.fireEvent(new SelectItemsWithItemStatusEvent(displayingItemStatus, msg));
|
eventBus.fireEvent(new SelectItemsWithItemStatusEvent(displayingItemStatus, msg, alert));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -382,25 +381,46 @@ public class HomeView extends Composite {
|
||||||
*
|
*
|
||||||
* @param doActionCMSView the do action CMS view
|
* @param doActionCMSView the do action CMS view
|
||||||
*/
|
*/
|
||||||
public void performCMSAction(DoActionCMSView doActionCMSView) {
|
private void performCMSAction(DoActionCMSView doActionCMSView) {
|
||||||
|
|
||||||
ItemStatus toStatus = doActionCMSView.getToStatus();
|
final ItemStatus toStatus = doActionCMSView.getToStatus();
|
||||||
List<String> listDatasetNames = UtilFunct.toListDatasetNames(doActionCMSView.getListSelectItems());
|
List<String> listDatasetNames = UtilFunct.toListDatasetNames(doActionCMSView.getListSelectItems());
|
||||||
switch (toStatus) {
|
switch (toStatus) {
|
||||||
case PENDING:
|
case PENDING:
|
||||||
|
|
||||||
CkanContentModeratorWidgetController.contentModeratorService.setStatus(toStatus, listDatasetNames,
|
CkanContentModeratorWidgetController.contentModeratorService.setStatus(toStatus, listDatasetNames,
|
||||||
new AsyncCallback<Void>() {
|
new AsyncCallback<OperationReport>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(Void result) {
|
public void onSuccess(OperationReport result) {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
|
AlertType alert = AlertType.SUCCESS;
|
||||||
|
int count = result.getPassedListItems().size();
|
||||||
|
String msg = "";
|
||||||
|
if (count > 0) {
|
||||||
|
if (count == 1) {
|
||||||
|
msg += "One item";
|
||||||
|
} else {
|
||||||
|
msg += count + " items";
|
||||||
|
}
|
||||||
|
|
||||||
|
msg += " moved to " + toStatus + " status.";
|
||||||
|
}
|
||||||
|
|
||||||
|
int errorCount = result.getErrorListItems().size();
|
||||||
|
if (errorCount > 0) {
|
||||||
|
msg += " <br/>Error occurred on updating status to " + errorCount + " item/s";
|
||||||
|
alert = AlertType.WARNING;
|
||||||
|
}
|
||||||
|
|
||||||
|
eventBus.fireEvent(new SelectItemsWithItemStatusEvent(displayingItemStatus, msg, alert));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Throwable caught) {
|
public void onFailure(Throwable caught) {
|
||||||
// TODO Auto-generated method stub
|
Window.alert(caught.getMessage());
|
||||||
|
eventBus.fireEvent(new SelectItemsWithItemStatusEvent(displayingItemStatus,
|
||||||
|
"Sorry an error occurred. Please, refresh and try again", AlertType.ERROR));
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -409,17 +429,40 @@ public class HomeView extends Composite {
|
||||||
|
|
||||||
case APPROVED:
|
case APPROVED:
|
||||||
|
|
||||||
CkanContentModeratorWidgetController.contentModeratorService.approveItem(listDatasetNames, doActionCMSView.getTxtReasonMsg(), new AsyncCallback<OperationReport>() {
|
CkanContentModeratorWidgetController.contentModeratorService.approveItem(listDatasetNames,
|
||||||
|
doActionCMSView.getTxtReasonMsg(), new AsyncCallback<OperationReport>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Throwable caught) {
|
public void onFailure(Throwable caught) {
|
||||||
// TODO Auto-generated method stub
|
Window.alert(caught.getMessage());
|
||||||
|
eventBus.fireEvent(new SelectItemsWithItemStatusEvent(displayingItemStatus,
|
||||||
|
"Sorry an error occurred. Please, refresh and try again", AlertType.ERROR));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(OperationReport result) {
|
public void onSuccess(OperationReport result) {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
AlertType alert = AlertType.SUCCESS;
|
||||||
|
int count = result.getPassedListItems().size();
|
||||||
|
String msg = "";
|
||||||
|
if (count > 0) {
|
||||||
|
if (count == 1) {
|
||||||
|
msg += "One item";
|
||||||
|
} else {
|
||||||
|
msg += count + " items";
|
||||||
|
}
|
||||||
|
|
||||||
|
msg += " moved to " + toStatus + " status.";
|
||||||
|
}
|
||||||
|
|
||||||
|
int errorCount = result.getErrorListItems().size();
|
||||||
|
if (errorCount > 0) {
|
||||||
|
msg += " <br/>Error occurred on approving " + errorCount + " item/s";
|
||||||
|
alert = AlertType.WARNING;
|
||||||
|
}
|
||||||
|
|
||||||
|
eventBus.fireEvent(new SelectItemsWithItemStatusEvent(displayingItemStatus, msg, alert));
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -428,17 +471,40 @@ public class HomeView extends Composite {
|
||||||
|
|
||||||
case REJECTED:
|
case REJECTED:
|
||||||
|
|
||||||
CkanContentModeratorWidgetController.contentModeratorService.rejectItem(listDatasetNames, doActionCMSView.isPermanentlyDelete(), doActionCMSView.getTxtReasonMsg(), new AsyncCallback<OperationReport>() {
|
CkanContentModeratorWidgetController.contentModeratorService.rejectItem(listDatasetNames,
|
||||||
|
doActionCMSView.isPermanentlyDelete(), doActionCMSView.getTxtReasonMsg(),
|
||||||
|
new AsyncCallback<OperationReport>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Throwable caught) {
|
public void onFailure(Throwable caught) {
|
||||||
// TODO Auto-generated method stub
|
Window.alert(caught.getMessage());
|
||||||
|
eventBus.fireEvent(new SelectItemsWithItemStatusEvent(displayingItemStatus,
|
||||||
|
"Sorry an error occurred. Please, refresh and try again", AlertType.ERROR));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(OperationReport result) {
|
public void onSuccess(OperationReport result) {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
AlertType alert = AlertType.SUCCESS;
|
||||||
|
int count = result.getPassedListItems().size();
|
||||||
|
String msg = "";
|
||||||
|
if (count > 0) {
|
||||||
|
if (count == 1) {
|
||||||
|
msg += "One item";
|
||||||
|
} else {
|
||||||
|
msg += count + " items";
|
||||||
|
}
|
||||||
|
|
||||||
|
msg += " moved to " + toStatus + " status.";
|
||||||
|
}
|
||||||
|
|
||||||
|
int errorCount = result.getErrorListItems().size();
|
||||||
|
if (errorCount > 0) {
|
||||||
|
msg += " <br/>Error occurred on rejecting " + errorCount + " item/s";
|
||||||
|
alert = AlertType.WARNING;
|
||||||
|
}
|
||||||
|
|
||||||
|
eventBus.fireEvent(new SelectItemsWithItemStatusEvent(displayingItemStatus, msg, alert));
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -66,18 +66,6 @@ public class CkanContentModeratorServiceImpl extends RemoteServiceServlet implem
|
||||||
return scope;
|
return scope;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the status.
|
|
||||||
*
|
|
||||||
* @param theStatus the the status
|
|
||||||
* @param itemNames the item names
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void setStatus(ItemStatus theStatus, List<String> itemNames) {
|
|
||||||
LOG.info("Called set status " + theStatus + " for Items with name: " + itemNames);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the list items for status.
|
* Gets the list items for status.
|
||||||
*
|
*
|
||||||
|
@ -120,6 +108,43 @@ public class CkanContentModeratorServiceImpl extends RemoteServiceServlet implem
|
||||||
return datasetList;
|
return datasetList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the status.
|
||||||
|
*
|
||||||
|
* @param theStatus the the status
|
||||||
|
* @param itemNames the item names
|
||||||
|
* @return the operation report
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public OperationReport setStatus(ItemStatus theStatus, List<String> itemNames) throws Exception {
|
||||||
|
LOG.info("Called set status " + theStatus + " for Items with name: " + itemNames);
|
||||||
|
|
||||||
|
try {
|
||||||
|
String scope = setContexts();
|
||||||
|
DataCatalogueImpl catalogueImpl = CatalogueCMSFactory.getFactory().getCatalogueImplPerScope(scope);
|
||||||
|
List<String> errorListItems = new ArrayList<String>();
|
||||||
|
List<String> approvedListItems = new ArrayList<String>();
|
||||||
|
for (String itemName : itemNames) {
|
||||||
|
try {
|
||||||
|
catalogueImpl.refreshDataset(itemName);
|
||||||
|
approvedListItems.add(itemName);
|
||||||
|
} catch (Exception e) {
|
||||||
|
LOG.warn("Error when setting status (updating) the itemName: " + itemName, e);
|
||||||
|
errorListItems.add(itemName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return new OperationReport(theStatus.getLabel(), errorListItems, approvedListItems);
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
LOG.error(e.getMessage(), e);
|
||||||
|
throw new Exception("Error occurred on updating the status for item/s: " + itemNames + ". Caused by: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Approve item.
|
* Approve item.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue