|
|
|
@ -8,6 +8,7 @@ import org.gcube.portlets.widgets.ckancontentmoderator.client.CkanContentModerat
|
|
|
|
|
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.CheckBoxSelectIemsEvent;
|
|
|
|
|
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.SelectItemsWithItemStatusEvent;
|
|
|
|
|
import org.gcube.portlets.widgets.ckancontentmoderator.client.ui.table.ItemsTable.DISPLAY_FIELD;
|
|
|
|
|
import org.gcube.portlets.widgets.ckancontentmoderator.client.ui.util.LoadingPanel;
|
|
|
|
|
import org.gcube.portlets.widgets.ckancontentmoderator.client.ui.util.UtilFunct;
|
|
|
|
|
import org.gcube.portlets.widgets.ckancontentmoderator.shared.CatalogueDataset;
|
|
|
|
|
import org.gcube.portlets.widgets.ckancontentmoderator.shared.OperationReport;
|
|
|
|
@ -33,6 +34,7 @@ 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.ui.Composite;
|
|
|
|
|
import com.google.gwt.user.client.ui.HTML;
|
|
|
|
|
import com.google.gwt.user.client.ui.HTMLPanel;
|
|
|
|
|
import com.google.gwt.user.client.ui.ScrollPanel;
|
|
|
|
|
import com.google.gwt.user.client.ui.Widget;
|
|
|
|
@ -61,6 +63,9 @@ public class HomeView extends Composite {
|
|
|
|
|
|
|
|
|
|
@UiField
|
|
|
|
|
Heading pageHeader;
|
|
|
|
|
|
|
|
|
|
@UiField
|
|
|
|
|
HTMLPanel actionLoaderPanel;
|
|
|
|
|
|
|
|
|
|
@UiField
|
|
|
|
|
HTMLPanel confirmPanel;
|
|
|
|
@ -75,6 +80,8 @@ public class HomeView extends Composite {
|
|
|
|
|
private ItemStatus displayingItemStatus;
|
|
|
|
|
|
|
|
|
|
private HandlerManager eventBus;
|
|
|
|
|
|
|
|
|
|
private LoadingPanel actionInProgressLoader = new LoadingPanel(new HTML("Performing action..."));
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The Interface HomeViewUiBinder.
|
|
|
|
@ -113,12 +120,20 @@ public class HomeView extends Composite {
|
|
|
|
|
setStatusOptions.add(nl);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
showActionLoader(false);
|
|
|
|
|
actionLoaderPanel.add(actionInProgressLoader);
|
|
|
|
|
|
|
|
|
|
setStatusOptions(status);
|
|
|
|
|
bindEvents();
|
|
|
|
|
confirmPanel.add(confirmPanelContainer);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void showActionLoader(boolean showActionInProgress) {
|
|
|
|
|
GWT.log("Show action in progress: "+showActionInProgress);
|
|
|
|
|
actionLoaderPanel.setVisible(showActionInProgress);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Sets the status options according to item status selected
|
|
|
|
@ -141,6 +156,11 @@ public class HomeView extends Composite {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Hiding the changing of any status from the APPROVED
|
|
|
|
|
if(selectedStatus.equals(ItemStatus.APPROVED)) {
|
|
|
|
|
navLink.setVisible(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -297,10 +317,11 @@ public class HomeView extends Composite {
|
|
|
|
|
* Show do action delete permanently.
|
|
|
|
|
*/
|
|
|
|
|
private void showDoActionViewDeletePermanently() {
|
|
|
|
|
|
|
|
|
|
confirmPanelContainer.clear();
|
|
|
|
|
GWT.log("showDoActionViewDeletePermanently...");
|
|
|
|
|
|
|
|
|
|
DoActionCMSView doActionCMS = new DoActionCMSView();
|
|
|
|
|
final DoActionCMSView doActionCMS = new DoActionCMSView();
|
|
|
|
|
final List<CatalogueDataset> selectedItems = paginatedView.getSelectItems();
|
|
|
|
|
doActionCMS.permanentlyDelete(selectedItems);
|
|
|
|
|
|
|
|
|
@ -319,19 +340,50 @@ public class HomeView extends Composite {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(ClickEvent event) {
|
|
|
|
|
confirmPanelContainer.clear();
|
|
|
|
|
AlertType alert = AlertType.SUCCESS;
|
|
|
|
|
int count = selectedItems.size();
|
|
|
|
|
String msg = "Deleted permanently";
|
|
|
|
|
if (count > 0) {
|
|
|
|
|
if (count == 1) {
|
|
|
|
|
msg += " one item";
|
|
|
|
|
} else {
|
|
|
|
|
msg += " " + count + " items";
|
|
|
|
|
showActionLoader(true);
|
|
|
|
|
|
|
|
|
|
List<String> listDatasetNames = UtilFunct.toListDatasetNames(doActionCMS.getListSelectItems());
|
|
|
|
|
CkanContentModeratorWidgetController.contentModeratorService.permanentlyDelete(listDatasetNames, new AsyncCallback<OperationReport>() {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onFailure(Throwable caught) {
|
|
|
|
|
showActionLoader(false);
|
|
|
|
|
Window.alert(caught.getMessage());
|
|
|
|
|
eventBus.fireEvent(new SelectItemsWithItemStatusEvent(displayingItemStatus,
|
|
|
|
|
"Sorry an error occurred. Please, refresh and try again", AlertType.ERROR));
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
msg += " from Catalogue";
|
|
|
|
|
}
|
|
|
|
|
eventBus.fireEvent(new SelectItemsWithItemStatusEvent(displayingItemStatus, msg, alert));
|
|
|
|
|
@Override
|
|
|
|
|
public void onSuccess(OperationReport result) {
|
|
|
|
|
showActionLoader(false);
|
|
|
|
|
AlertType alert = AlertType.SUCCESS;
|
|
|
|
|
int count = selectedItems.size();
|
|
|
|
|
String msg = "Deleted permanently";
|
|
|
|
|
if (count > 0) {
|
|
|
|
|
if (count == 1) {
|
|
|
|
|
msg += " one item";
|
|
|
|
|
} else {
|
|
|
|
|
msg += " " + count + " items";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
msg += " from Catalogue";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int errorCount = result.getErrorMapItems().size();
|
|
|
|
|
if (errorCount > 0) {
|
|
|
|
|
msg += " <br/>Error occurred on deleting permanently " + errorCount + " item/s:";
|
|
|
|
|
for (String key : result.getErrorMapItems().keySet()) {
|
|
|
|
|
msg += "<br/> "+ key+". Error: "+ result.getErrorMapItems().get(key);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
alert = AlertType.WARNING;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
eventBus.fireEvent(new SelectItemsWithItemStatusEvent(displayingItemStatus, msg, alert));
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
@ -374,8 +426,9 @@ public class HomeView extends Composite {
|
|
|
|
|
*
|
|
|
|
|
* @param doActionCMSView the do action CMS view
|
|
|
|
|
*/
|
|
|
|
|
private void performCMSAction(DoActionCMSView doActionCMSView) {
|
|
|
|
|
private void performCMSAction(final DoActionCMSView doActionCMSView) {
|
|
|
|
|
|
|
|
|
|
showActionLoader(true);
|
|
|
|
|
final ItemStatus toStatus = doActionCMSView.getToStatus();
|
|
|
|
|
List<String> listDatasetNames = UtilFunct.toListDatasetNames(doActionCMSView.getListSelectItems());
|
|
|
|
|
switch (toStatus) {
|
|
|
|
@ -386,7 +439,7 @@ public class HomeView extends Composite {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onSuccess(OperationReport result) {
|
|
|
|
|
|
|
|
|
|
showActionLoader(false);
|
|
|
|
|
AlertType alert = AlertType.SUCCESS;
|
|
|
|
|
int count = result.getPassedListItems().size();
|
|
|
|
|
String msg = "";
|
|
|
|
@ -415,6 +468,7 @@ public class HomeView extends Composite {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onFailure(Throwable caught) {
|
|
|
|
|
showActionLoader(false);
|
|
|
|
|
Window.alert(caught.getMessage());
|
|
|
|
|
eventBus.fireEvent(new SelectItemsWithItemStatusEvent(displayingItemStatus,
|
|
|
|
|
"Sorry an error occurred. Please, refresh and try again", AlertType.ERROR));
|
|
|
|
@ -431,6 +485,7 @@ public class HomeView extends Composite {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onFailure(Throwable caught) {
|
|
|
|
|
showActionLoader(false);
|
|
|
|
|
Window.alert(caught.getMessage());
|
|
|
|
|
eventBus.fireEvent(new SelectItemsWithItemStatusEvent(displayingItemStatus,
|
|
|
|
|
"Sorry an error occurred. Please, refresh and try again", AlertType.ERROR));
|
|
|
|
@ -439,7 +494,7 @@ public class HomeView extends Composite {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onSuccess(OperationReport result) {
|
|
|
|
|
|
|
|
|
|
showActionLoader(false);
|
|
|
|
|
AlertType alert = AlertType.SUCCESS;
|
|
|
|
|
int count = result.getPassedListItems().size();
|
|
|
|
|
String msg = "";
|
|
|
|
@ -459,6 +514,8 @@ public class HomeView extends Composite {
|
|
|
|
|
for (String key : result.getErrorMapItems().keySet()) {
|
|
|
|
|
msg += "<br/> "+ key+". Error: "+ result.getErrorMapItems().get(key);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
alert = AlertType.WARNING;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
eventBus.fireEvent(new SelectItemsWithItemStatusEvent(displayingItemStatus, msg, alert));
|
|
|
|
@ -476,6 +533,7 @@ public class HomeView extends Composite {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onFailure(Throwable caught) {
|
|
|
|
|
showActionLoader(false);
|
|
|
|
|
Window.alert(caught.getMessage());
|
|
|
|
|
eventBus.fireEvent(new SelectItemsWithItemStatusEvent(displayingItemStatus,
|
|
|
|
|
"Sorry an error occurred. Please, refresh and try again", AlertType.ERROR));
|
|
|
|
@ -483,7 +541,7 @@ public class HomeView extends Composite {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onSuccess(OperationReport result) {
|
|
|
|
|
|
|
|
|
|
showActionLoader(false);
|
|
|
|
|
AlertType alert = AlertType.SUCCESS;
|
|
|
|
|
int count = result.getPassedListItems().size();
|
|
|
|
|
String msg = "";
|
|
|
|
@ -493,8 +551,15 @@ public class HomeView extends Composite {
|
|
|
|
|
} else {
|
|
|
|
|
msg += count + " items";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
msg += " moved to " + toStatus + " status.";
|
|
|
|
|
|
|
|
|
|
boolean isPermanentlyDelete = doActionCMSView.isPermanentlyDelete();
|
|
|
|
|
|
|
|
|
|
if(isPermanentlyDelete) {
|
|
|
|
|
msg += " deleted permanently from Catalogue";
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
msg += " moved to " + toStatus + " status.";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int errorCount = result.getErrorMapItems().size();
|
|
|
|
@ -503,6 +568,8 @@ public class HomeView extends Composite {
|
|
|
|
|
for (String key : result.getErrorMapItems().keySet()) {
|
|
|
|
|
msg += "<br/> "+ key+". Error: "+ result.getErrorMapItems().get(key);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
alert = AlertType.WARNING;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
eventBus.fireEvent(new SelectItemsWithItemStatusEvent(displayingItemStatus, msg, alert));
|
|
|
|
@ -516,5 +583,9 @@ public class HomeView extends Composite {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ItemStatus getDisplayingItemStatus() {
|
|
|
|
|
return displayingItemStatus;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|