task_21363 #1
|
@ -2,9 +2,9 @@ package org.gcube.portlets.widgets.ckancontentmoderator.client;
|
|||
|
||||
import org.gcube.datacatalogue.utillibrary.shared.ItemStatus;
|
||||
import org.gcube.portlets.widgets.ckancontentmoderator.client.ui.MainPanel;
|
||||
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.UtilUx;
|
||||
import org.gcube.portlets.widgets.ckancontentmoderator.shared.DISPLAY_FIELD;
|
||||
|
||||
import com.github.gwtbootstrap.client.ui.constants.AlertType;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
|
@ -31,16 +31,39 @@ public class CheckConfigsUxController {
|
|||
|
||||
private MainPanel mainPanel;
|
||||
|
||||
private DISPLAY_FIELD[] orderByFields;
|
||||
|
||||
private ItemStatus initItemStatus;
|
||||
|
||||
private DISPLAY_FIELD[] displayFields;
|
||||
|
||||
/**
|
||||
* Instantiates a new check configs ux controller.
|
||||
*
|
||||
* @param baseCP the base CP
|
||||
* @param moderatorCheckConfig the moderatorcheck config
|
||||
* @param mainPanel the main panel
|
||||
* @param initItemStatus the init item status
|
||||
* @param displayFields the display fields
|
||||
* @param sortByFields the sort by fields
|
||||
* @param moderatorcheckConfig the moderatorcheck config
|
||||
*/
|
||||
protected CheckConfigsUxController(MainPanel mainPanel, CkanContentModeratorCheckConfigs moderatorcheckConfig) {
|
||||
protected CheckConfigsUxController(MainPanel mainPanel, ItemStatus initItemStatus, DISPLAY_FIELD[] displayFields,
|
||||
DISPLAY_FIELD[] sortByFields, CkanContentModeratorCheckConfigs moderatorcheckConfig) {
|
||||
this.mainPanel = mainPanel;
|
||||
this.basePanelContainer = mainPanel.getMainPanelContainer();
|
||||
this.moderatorCheckConfig = moderatorcheckConfig;
|
||||
this.initItemStatus = initItemStatus;
|
||||
this.displayFields = displayFields;
|
||||
this.orderByFields = sortByFields;
|
||||
|
||||
if (this.initItemStatus == null)
|
||||
this.initItemStatus = ItemStatus.PENDING;
|
||||
|
||||
if (this.displayFields == null)
|
||||
this.displayFields = DISPLAY_FIELD.values();
|
||||
|
||||
if (this.orderByFields == null)
|
||||
this.orderByFields = DISPLAY_FIELD.values();
|
||||
|
||||
checkConfigs();
|
||||
}
|
||||
|
||||
|
@ -122,8 +145,9 @@ public class CheckConfigsUxController {
|
|||
basePanelContainer.remove(loader);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
cmsController = new CkanContentModeratorWidgetController(ItemStatus.PENDING, DISPLAY_FIELD.values(),
|
||||
DISPLAY_FIELD.NAME, false, false);
|
||||
|
||||
cmsController = new CkanContentModeratorWidgetController(initItemStatus, displayFields, orderByFields,
|
||||
false, false);
|
||||
basePanelContainer.add(cmsController.getMainPanel());
|
||||
|
||||
mainPanel.setLoggedLabelText("Logged in as Moderator");
|
||||
|
@ -154,13 +178,18 @@ public class CheckConfigsUxController {
|
|||
GWT.log("readOnlyMode is enabled? " + readOnlyMode);
|
||||
GWT.log("restrictDataToLoggedInUser is? " + restrictDataToLoggedInUser);
|
||||
|
||||
cmsController = new CkanContentModeratorWidgetController(ItemStatus.PENDING, DISPLAY_FIELD.values(),
|
||||
DISPLAY_FIELD.NAME, readOnlyMode, restrictDataToLoggedInUser);
|
||||
cmsController = new CkanContentModeratorWidgetController(initItemStatus, displayFields, orderByFields,
|
||||
readOnlyMode, restrictDataToLoggedInUser);
|
||||
|
||||
basePanelContainer.add(cmsController.getMainPanel());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the moderator check config.
|
||||
*
|
||||
* @return the moderator check config
|
||||
*/
|
||||
public CkanContentModeratorCheckConfigs getModeratorCheckConfig() {
|
||||
return moderatorCheckConfig;
|
||||
}
|
||||
|
|
|
@ -60,11 +60,12 @@ public interface CkanContentModeratorService extends RemoteService {
|
|||
* @param offset the offset
|
||||
* @param limit the limit
|
||||
* @param restrictedToLoggedInUser the restricted to logged in user
|
||||
* @param sortForField the sort for field
|
||||
* @return the list items for status
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public List<CatalogueDataset> getListItemsForStatus(ItemStatus theStatus, int offset, int limit,
|
||||
boolean restrictedToLoggedInUser) throws Exception;
|
||||
boolean restrictedToLoggedInUser, String sortForField) throws Exception;
|
||||
|
||||
/**
|
||||
* Gets the data for status.
|
||||
|
@ -74,11 +75,12 @@ public interface CkanContentModeratorService extends RemoteService {
|
|||
* @param limit the limit
|
||||
* @param serverStartIndex the server start index
|
||||
* @param restrictedToLoggedInUser the restricted to logged in user
|
||||
* @param sortForField the sort for field
|
||||
* @return the data for status
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public SearchedData getDataForStatus(ItemStatus status, int offset, int limit, int serverStartIndex,
|
||||
boolean restrictedToLoggedInUser) throws Exception;
|
||||
boolean restrictedToLoggedInUser, String sortForField) throws Exception;
|
||||
|
||||
/**
|
||||
* Approve item.
|
||||
|
|
|
@ -30,32 +30,11 @@ public interface CkanContentModeratorServiceAsync {
|
|||
void rejectItem(List<String> itemNames, boolean permanentlyDelete, String reasonMsg,
|
||||
AsyncCallback<OperationReport> callback);
|
||||
|
||||
/**
|
||||
* Gets the list items for status.
|
||||
*
|
||||
* @param theStatus the the status
|
||||
* @param offset the offset
|
||||
* @param limit the limit
|
||||
* @param restrictedToLoggedInUser the restricted to logged in user
|
||||
* @param callback the callback
|
||||
* @return the list items for status
|
||||
*/
|
||||
void getListItemsForStatus(ItemStatus theStatus, int offset, int limit, boolean restrictedToLoggedInUser,
|
||||
AsyncCallback<List<CatalogueDataset>> callback);
|
||||
String sortForField, AsyncCallback<List<CatalogueDataset>> callback);
|
||||
|
||||
/**
|
||||
* Gets the data for status.
|
||||
*
|
||||
* @param status the status
|
||||
* @param offset the offset
|
||||
* @param limit the limit
|
||||
* @param serverStartIndex the server start index
|
||||
* @param restrictedToLoggedInUser the restricted to logged in user
|
||||
* @param asyncCallback the async callback
|
||||
* @return the data for status
|
||||
*/
|
||||
void getDataForStatus(ItemStatus status, int offset, int limit, int serverStartIndex,
|
||||
boolean restrictedToLoggedInUser, AsyncCallback<SearchedData> asyncCallback);
|
||||
boolean restrictedToLoggedInUser, String sortForField, AsyncCallback<SearchedData> asyncCallback);
|
||||
|
||||
/**
|
||||
* Approve item.
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
package org.gcube.portlets.widgets.ckancontentmoderator.client;
|
||||
|
||||
import org.gcube.datacatalogue.utillibrary.shared.ItemStatus;
|
||||
import org.gcube.portlets.widgets.ckancontentmoderator.client.ui.MainPanel;
|
||||
import org.gcube.portlets.widgets.ckancontentmoderator.client.ui.util.ExtModal;
|
||||
import org.gcube.portlets.widgets.ckancontentmoderator.shared.DISPLAY_FIELD;
|
||||
|
||||
import com.github.gwtbootstrap.client.ui.Modal;
|
||||
import com.google.gwt.user.client.ui.Composite;
|
||||
|
@ -15,8 +17,6 @@ import com.google.gwt.user.client.ui.Composite;
|
|||
*/
|
||||
public class CkanContentModeratorWidget {
|
||||
|
||||
// private VerticalPanel baseVP = new VerticalPanel();
|
||||
|
||||
private MainPanel mainPanel = new MainPanel();
|
||||
|
||||
private CheckConfigsUxController ccux;
|
||||
|
@ -24,9 +24,10 @@ public class CkanContentModeratorWidget {
|
|||
/**
|
||||
* Instantiates a new ckan content moderator widget.
|
||||
*/
|
||||
public CkanContentModeratorWidget() {
|
||||
public CkanContentModeratorWidget(ItemStatus initItemStatus, DISPLAY_FIELD[] displayFields,
|
||||
DISPLAY_FIELD[] sortByFields) {
|
||||
mainPanel.setWidth("100%");
|
||||
ccux = new CheckConfigsUxController(mainPanel, null);
|
||||
ccux = new CheckConfigsUxController(mainPanel, initItemStatus, displayFields, sortByFields, null);
|
||||
|
||||
boolean iamModerator = false;
|
||||
try {
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package org.gcube.portlets.widgets.ckancontentmoderator.client;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -25,9 +27,11 @@ import org.gcube.portlets.widgets.ckancontentmoderator.client.ui.CkanShowItemFra
|
|||
import org.gcube.portlets.widgets.ckancontentmoderator.client.ui.ContentModeratorToolbar;
|
||||
import org.gcube.portlets.widgets.ckancontentmoderator.client.ui.HomeView;
|
||||
import org.gcube.portlets.widgets.ckancontentmoderator.client.ui.MainTabPanel;
|
||||
import org.gcube.portlets.widgets.ckancontentmoderator.client.ui.table.ItemsTable.DISPLAY_FIELD;
|
||||
import org.gcube.portlets.widgets.ckancontentmoderator.client.ui.util.UtilUx;
|
||||
import org.gcube.portlets.widgets.ckancontentmoderator.shared.CatalogueDataset;
|
||||
import org.gcube.portlets.widgets.ckancontentmoderator.shared.DISPLAY_FIELD;
|
||||
import org.gcube.portlets.widgets.ckancontentmoderator.shared.ItemFieldDV;
|
||||
import org.gcube.portlets.widgets.ckancontentmoderator.shared.SearchingFilter;
|
||||
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.event.shared.HandlerManager;
|
||||
|
@ -69,14 +73,25 @@ public class CkanContentModeratorWidgetController {
|
|||
* @param restrictDataToLoggedInUser
|
||||
*/
|
||||
protected CkanContentModeratorWidgetController(ItemStatus status, DISPLAY_FIELD[] displayFields,
|
||||
DISPLAY_FIELD sortByField, boolean readOnlyMode, boolean restrictDataToLoggedInUser) {
|
||||
toolbar = new ContentModeratorToolbar(eventBus, status);
|
||||
DISPLAY_FIELD[] sortByFields, boolean readOnlyMode, boolean restrictDataToLoggedInUser) {
|
||||
|
||||
DISPLAY_FIELD firstSortField = null;
|
||||
if (sortByFields == null || sortByFields.length == 0) {
|
||||
firstSortField = DISPLAY_FIELD.NAME;
|
||||
sortByFields[0] = firstSortField;
|
||||
} else
|
||||
firstSortField = sortByFields[0];
|
||||
|
||||
List<ItemFieldDV> sortBy = displayFieldsToItemFields(sortByFields);
|
||||
|
||||
toolbar = new ContentModeratorToolbar(eventBus, status, sortBy);
|
||||
|
||||
// GWT.log("***************** HARD CODED READONLY ********************** ");
|
||||
// readOnlyMode = true;
|
||||
// restrictDataToLoggedInUser = readOnlyMode;
|
||||
|
||||
howeView = new HomeView(eventBus, status, displayFields, sortByField, readOnlyMode, restrictDataToLoggedInUser);
|
||||
howeView = new HomeView(eventBus, status, displayFields, firstSortField, readOnlyMode,
|
||||
restrictDataToLoggedInUser);
|
||||
mainTabPanel.addHomeWidget(howeView.getPanel());
|
||||
mainPanel.add(toolbar);
|
||||
mainPanel.add(infoPanel);
|
||||
|
@ -88,6 +103,92 @@ public class CkanContentModeratorWidgetController {
|
|||
bindEvents();
|
||||
}
|
||||
|
||||
/**
|
||||
* TEMPORARY SOLUTION... IT SHOULD BE A CONFIGURATION
|
||||
*
|
||||
* @param sortByFields
|
||||
* @return
|
||||
*/
|
||||
|
||||
private List<ItemFieldDV> displayFieldsToItemFields(DISPLAY_FIELD[] sortByFields) {
|
||||
|
||||
List<ItemFieldDV> listSortByIF = new ArrayList<ItemFieldDV>(sortByFields.length);
|
||||
for (DISPLAY_FIELD display_FIELD : sortByFields) {
|
||||
for (SearchingFilter.ORDER order : SearchingFilter.ORDER.values()) {
|
||||
ItemFieldDV itemField = new ItemFieldDV();
|
||||
itemField.setDisplayName(display_FIELD.getLabel() + " - " + order);
|
||||
itemField.setJsonFields(Arrays.asList(display_FIELD.getJsonField() +" "+order.name().toLowerCase()));
|
||||
listSortByIF.add(itemField);
|
||||
}
|
||||
// ItemFieldDV itemField = new ItemFieldDV();
|
||||
// itemField.setDisplayName(display_FIELD.getLabel() + " - " + SearchingFilter.ORDER.ASC);
|
||||
// itemField.setJsonFields(
|
||||
// Arrays.asList("extras_systemtype " + SearchingFilter.ORDER.ASC.name().toLowerCase()));
|
||||
// listSortByIF.add(itemField);
|
||||
//
|
||||
// switch (display_FIELD) {
|
||||
// case TYPE: {
|
||||
// ItemFieldDV itemField = new ItemFieldDV();
|
||||
// itemField.setDisplayName(display_FIELD.name() + " " + SearchingFilter.ORDER.ASC);
|
||||
// itemField.setJsonFields(
|
||||
// Arrays.asList("extras_systemtype " + SearchingFilter.ORDER.ASC.name().toLowerCase()));
|
||||
// listSortByIF.add(itemField);
|
||||
//
|
||||
// ItemFieldDV itemField2 = new ItemFieldDV();
|
||||
// itemField2.setDisplayName(display_FIELD.name() + " " + SearchingFilter.ORDER.DESC);
|
||||
// itemField2.setJsonFields(
|
||||
// Arrays.asList("extras_systemtype " + SearchingFilter.ORDER.DESC.name().toLowerCase()));
|
||||
// listSortByIF.add(itemField2);
|
||||
// break;
|
||||
// }
|
||||
// case CREATED: {
|
||||
// ItemFieldDV itemField = new ItemFieldDV();
|
||||
// itemField.setDisplayName(display_FIELD.name() + " " + SearchingFilter.ORDER.ASC);
|
||||
// itemField.setJsonFields(
|
||||
// Arrays.asList("metadata_created " + SearchingFilter.ORDER.ASC.name().toLowerCase()));
|
||||
// listSortByIF.add(itemField);
|
||||
//
|
||||
// ItemFieldDV itemField2 = new ItemFieldDV();
|
||||
// itemField2.setDisplayName(display_FIELD.name() + " " + SearchingFilter.ORDER.DESC);
|
||||
// itemField2.setJsonFields(
|
||||
// Arrays.asList("metadata_created " + SearchingFilter.ORDER.DESC.name().toLowerCase()));
|
||||
// listSortByIF.add(itemField2);
|
||||
// break;
|
||||
// }
|
||||
// case LAST_UPDATE: {
|
||||
// ItemFieldDV itemField = new ItemFieldDV();
|
||||
// itemField.setDisplayName(display_FIELD.name() + " " + SearchingFilter.ORDER.ASC);
|
||||
// itemField.setJsonFields(
|
||||
// Arrays.asList("metadata_modified " + SearchingFilter.ORDER.ASC.name().toLowerCase()));
|
||||
// listSortByIF.add(itemField);
|
||||
//
|
||||
// ItemFieldDV itemField2 = new ItemFieldDV();
|
||||
// itemField2.setDisplayName(display_FIELD.name() + " " + SearchingFilter.ORDER.DESC);
|
||||
// itemField2.setJsonFields(
|
||||
// Arrays.asList("metadata_modified " + SearchingFilter.ORDER.DESC.name().toLowerCase()));
|
||||
// listSortByIF.add(itemField2);
|
||||
// break;
|
||||
// }
|
||||
// default:
|
||||
// ItemFieldDV itemField = new ItemFieldDV();
|
||||
// itemField.setDisplayName(display_FIELD.name() + " " + SearchingFilter.ORDER.ASC);
|
||||
// itemField.setJsonFields(
|
||||
// Arrays.asList(display_FIELD.name() + " " + SearchingFilter.ORDER.ASC.name().toLowerCase()));
|
||||
// listSortByIF.add(itemField);
|
||||
//
|
||||
// ItemFieldDV itemField2 = new ItemFieldDV();
|
||||
// itemField2.setDisplayName(display_FIELD.name() + " " + SearchingFilter.ORDER.DESC);
|
||||
// itemField2.setJsonFields(
|
||||
// Arrays.asList(display_FIELD.name() + " " + SearchingFilter.ORDER.DESC.name().toLowerCase()));
|
||||
// listSortByIF.add(itemField2);
|
||||
// break;
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
return listSortByIF;
|
||||
}
|
||||
|
||||
/**
|
||||
* Bind events.
|
||||
*/
|
||||
|
@ -190,7 +291,15 @@ public class CkanContentModeratorWidgetController {
|
|||
GWT.log("On value changed: " + statusSelectedEvent.getItemStatus());
|
||||
infoPanel.clear();
|
||||
if (statusSelectedEvent.getItemStatus() != null) {
|
||||
howeView.loadItemsWithStatus(statusSelectedEvent.getItemStatus());
|
||||
ItemFieldDV sortBy = statusSelectedEvent.getSortBy();
|
||||
|
||||
if(sortBy==null) {
|
||||
sortBy = toolbar.getActiveSortBy();
|
||||
|
||||
}
|
||||
String sortForField = sortBy.getJsonFields().get(0);
|
||||
GWT.log("sortForField is: "+sortForField);
|
||||
howeView.loadItemsWithStatus(statusSelectedEvent.getItemStatus(), sortForField);
|
||||
mainTabPanel.selectTab(0);
|
||||
}
|
||||
|
||||
|
|
|
@ -2,8 +2,8 @@ package org.gcube.portlets.widgets.ckancontentmoderator.client;
|
|||
|
||||
import org.gcube.datacatalogue.utillibrary.shared.ItemStatus;
|
||||
import org.gcube.portlets.widgets.ckancontentmoderator.client.ui.MainPanel;
|
||||
import org.gcube.portlets.widgets.ckancontentmoderator.client.ui.table.ItemsTable.DISPLAY_FIELD;
|
||||
import org.gcube.portlets.widgets.ckancontentmoderator.client.ui.util.ExtModal;
|
||||
import org.gcube.portlets.widgets.ckancontentmoderator.shared.DISPLAY_FIELD;
|
||||
|
||||
import com.github.gwtbootstrap.client.ui.Modal;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
|
@ -25,18 +25,18 @@ public class CkanContentModeratorWidgetTrusted {
|
|||
/**
|
||||
* Instantiates a new ckan content moderator widget trusted.
|
||||
*
|
||||
* @param status the status
|
||||
* @param initItemStatus the init item status
|
||||
* @param displayFields the display fields
|
||||
* @param sortByField the sort by field
|
||||
* @param ckanContentModeratorCheckConfig the ckan content moderator check
|
||||
* config
|
||||
*/
|
||||
public CkanContentModeratorWidgetTrusted(ItemStatus status, DISPLAY_FIELD[] displayFields,
|
||||
DISPLAY_FIELD sortByField, CkanContentModeratorCheckConfigs ckanContentModeratorCheckConfig) {
|
||||
public CkanContentModeratorWidgetTrusted(ItemStatus initItemStatus, DISPLAY_FIELD[] displayFields,
|
||||
DISPLAY_FIELD[] sortByFields, CkanContentModeratorCheckConfigs ckanContentModeratorCheckConfig) {
|
||||
GWT.log("CkanContentModeratorWidget called. CkanContentModeratorCheckConfigs: "
|
||||
+ ckanContentModeratorCheckConfig);
|
||||
mainPanel.setWidth("100%");
|
||||
ccux = new CheckConfigsUxController(mainPanel, ckanContentModeratorCheckConfig);
|
||||
ccux = new CheckConfigsUxController(mainPanel, initItemStatus, displayFields, sortByFields, ckanContentModeratorCheckConfig);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package org.gcube.portlets.widgets.ckancontentmoderator.client.events;
|
||||
|
||||
import org.gcube.datacatalogue.utillibrary.shared.ItemStatus;
|
||||
import org.gcube.portlets.widgets.ckancontentmoderator.shared.ItemFieldDV;
|
||||
|
||||
import com.github.gwtbootstrap.client.ui.constants.AlertType;
|
||||
import com.google.gwt.event.shared.GwtEvent;
|
||||
|
@ -17,6 +18,7 @@ public class SelectItemsWithItemStatusEvent extends GwtEvent<SelectItemsWithItem
|
|||
private ItemStatus itemStatus;
|
||||
private String displayMessage;
|
||||
private AlertType alertType = AlertType.INFO;
|
||||
private ItemFieldDV sortBy;
|
||||
|
||||
/**
|
||||
* Instantiates a new click item event.
|
||||
|
@ -24,6 +26,22 @@ public class SelectItemsWithItemStatusEvent extends GwtEvent<SelectItemsWithItem
|
|||
* @param itemStatus the item status
|
||||
* @param displayMessage the display message
|
||||
* @param alerType the aler type
|
||||
* @param sortBy the sort by
|
||||
*/
|
||||
public SelectItemsWithItemStatusEvent(ItemStatus itemStatus, String displayMessage, AlertType alerType,
|
||||
ItemFieldDV sortBy) {
|
||||
this.itemStatus = itemStatus;
|
||||
this.displayMessage = displayMessage;
|
||||
this.alertType = alerType;
|
||||
this.sortBy = sortBy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new select items with item status event.
|
||||
*
|
||||
* @param itemStatus the item status
|
||||
* @param displayMessage the display message
|
||||
* @param alerType the aler type
|
||||
*/
|
||||
public SelectItemsWithItemStatusEvent(ItemStatus itemStatus, String displayMessage, AlertType alerType) {
|
||||
this.itemStatus = itemStatus;
|
||||
|
@ -78,4 +96,13 @@ public class SelectItemsWithItemStatusEvent extends GwtEvent<SelectItemsWithItem
|
|||
return alertType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the sort by.
|
||||
*
|
||||
* @return the sort by
|
||||
*/
|
||||
public ItemFieldDV getSortBy() {
|
||||
return sortBy;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,10 +8,10 @@ import org.gcube.portlets.widgets.ckancontentmoderator.client.ContentModeratorWi
|
|||
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.ShowMessageEvent;
|
||||
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.TableRangeViewChangedEvent;
|
||||
import org.gcube.portlets.widgets.ckancontentmoderator.client.ui.table.ItemsTable;
|
||||
import org.gcube.portlets.widgets.ckancontentmoderator.client.ui.table.ItemsTable.DISPLAY_FIELD;
|
||||
import org.gcube.portlets.widgets.ckancontentmoderator.client.ui.table.SortedCellTable;
|
||||
import org.gcube.portlets.widgets.ckancontentmoderator.client.ui.util.LoadingPanel;
|
||||
import org.gcube.portlets.widgets.ckancontentmoderator.shared.CatalogueDataset;
|
||||
import org.gcube.portlets.widgets.ckancontentmoderator.shared.DISPLAY_FIELD;
|
||||
import org.gcube.portlets.widgets.ckancontentmoderator.shared.SearchedData;
|
||||
|
||||
import com.github.gwtbootstrap.client.ui.constants.AlertType;
|
||||
|
@ -56,6 +56,7 @@ public class ContentModeratorPaginatedView {
|
|||
private int serverStartIndex;
|
||||
private HandlerManager eventBus;
|
||||
private boolean restrictDataToLoggedInUser;
|
||||
private String sortForField;
|
||||
|
||||
/**
|
||||
* Instantiates a new content moderator paginated view.
|
||||
|
@ -65,6 +66,7 @@ public class ContentModeratorPaginatedView {
|
|||
* @param displayFields the display fields
|
||||
* @param sortByField the sort by field
|
||||
* @param restrictDataToLoggedInUser the restrict data to logged in user
|
||||
* @param sortForField
|
||||
*/
|
||||
public ContentModeratorPaginatedView(HandlerManager eventbus, ItemStatus theStatus, DISPLAY_FIELD[] displayFields,
|
||||
DISPLAY_FIELD sortByField, boolean restrictDataToLoggedInUser) {
|
||||
|
@ -78,7 +80,7 @@ public class ContentModeratorPaginatedView {
|
|||
orginalLoadingIndicator = itemsTable.getCellTable().getLoadingIndicator();
|
||||
initPagination(ITEMS_PER_PAGE);
|
||||
// loadNewPage(ITEM_START_INDEX, ITEMS_PER_PAGE, false);
|
||||
loadItemsForStatus(theStatus);
|
||||
loadItemsForStatus(theStatus, sortForField);
|
||||
|
||||
}
|
||||
|
||||
|
@ -155,6 +157,7 @@ public class ContentModeratorPaginatedView {
|
|||
* @param startIdx the start idx
|
||||
* @param limit the limit
|
||||
* @param resetStore the reset store
|
||||
* @param sortForField
|
||||
*/
|
||||
private void loadNewPage(final int startIdx, final int limit, final boolean resetStore) {
|
||||
// initFirstRangeChanged = resetStore;
|
||||
|
@ -172,7 +175,7 @@ public class ContentModeratorPaginatedView {
|
|||
getAsycnDataProvider().updateRowCount(ITEMS_PER_PAGE, false);
|
||||
}
|
||||
|
||||
loadItemsForStatus(itemStatus, newStartIndex, limit, serverStartIndex);
|
||||
loadItemsForStatus(itemStatus, newStartIndex, limit, serverStartIndex, sortForField);
|
||||
|
||||
}
|
||||
|
||||
|
@ -180,9 +183,11 @@ public class ContentModeratorPaginatedView {
|
|||
* Load items for status.
|
||||
*
|
||||
* @param itemStatus the item status
|
||||
* @param sortForField
|
||||
*/
|
||||
public void loadItemsForStatus(ItemStatus itemStatus) {
|
||||
public void loadItemsForStatus(ItemStatus itemStatus, String sortForField) {
|
||||
this.itemStatus = itemStatus;
|
||||
this.sortForField = sortForField;
|
||||
getCellTable().setVisibleRangeAndClearData(new Range(0, ITEMS_PER_PAGE), false);
|
||||
loadNewPage(ITEM_START_INDEX, ITEMS_PER_PAGE, true);
|
||||
}
|
||||
|
@ -247,15 +252,16 @@ public class ContentModeratorPaginatedView {
|
|||
* @param offset the offset
|
||||
* @param limit the limit
|
||||
* @param serverIndex the server index
|
||||
* @param sortForField
|
||||
*/
|
||||
private void loadItemsForStatus(ItemStatus status, int offset, int limit, int serverIndex) {
|
||||
private void loadItemsForStatus(ItemStatus status, int offset, int limit, int serverIndex, String sortForField) {
|
||||
showLoading(true);
|
||||
|
||||
GWT.log("calling getDataForStatus with parameters [startIndex: " + offset + ", limit: " + limit
|
||||
+ ", serverIndex:" + serverIndex + "]");
|
||||
|
||||
CkanContentModeratorWidgetController.contentModeratorService.getDataForStatus(status, offset, limit,
|
||||
serverIndex, restrictDataToLoggedInUser, new AsyncCallback<SearchedData>() {
|
||||
serverIndex, restrictDataToLoggedInUser, sortForField, new AsyncCallback<SearchedData>() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(SearchedData result) {
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
package org.gcube.portlets.widgets.ckancontentmoderator.client.ui;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.datacatalogue.utillibrary.shared.ItemStatus;
|
||||
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.CloseAllTabsEvent;
|
||||
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.SelectItemsWithItemStatusEvent;
|
||||
import org.gcube.portlets.widgets.ckancontentmoderator.shared.ItemFieldDV;
|
||||
|
||||
import com.github.gwtbootstrap.client.ui.Dropdown;
|
||||
import com.github.gwtbootstrap.client.ui.Label;
|
||||
|
@ -26,21 +29,33 @@ public class ContentModeratorToolbar extends Composite {
|
|||
@UiField
|
||||
Dropdown dropdownSelectStatus;
|
||||
|
||||
@UiField
|
||||
Dropdown dropdownSortBy;
|
||||
|
||||
@UiField
|
||||
NavLink closeAllTabs;
|
||||
|
||||
@UiField
|
||||
Label statusInfo;
|
||||
|
||||
@UiField
|
||||
Label orderInfo;
|
||||
|
||||
private HandlerManager eventBus;
|
||||
|
||||
private ItemStatus activeStatus;
|
||||
|
||||
public ContentModeratorToolbar(HandlerManager eventBus, ItemStatus status) {
|
||||
private List<ItemFieldDV> sortByList;
|
||||
|
||||
private ItemFieldDV activeSortBy;
|
||||
|
||||
public ContentModeratorToolbar(HandlerManager eventBus, ItemStatus status, List<ItemFieldDV> sortBy) {
|
||||
initWidget(uiBinder.createAndBindUi(this));
|
||||
this.eventBus = eventBus;
|
||||
this.sortByList = sortBy;
|
||||
setActiveStatus(status);
|
||||
fillItemStatusOptions();
|
||||
setActiveSortBy(sortBy.get(0));
|
||||
fillSelectionOptions();
|
||||
bindEvents();
|
||||
|
||||
}
|
||||
|
@ -56,7 +71,7 @@ public class ContentModeratorToolbar extends Composite {
|
|||
});
|
||||
}
|
||||
|
||||
private void fillItemStatusOptions() {
|
||||
private void fillSelectionOptions() {
|
||||
for (final ItemStatus status : ItemStatus.values()) {
|
||||
|
||||
NavLink navLink = new NavLink();
|
||||
|
@ -67,12 +82,34 @@ public class ContentModeratorToolbar extends Composite {
|
|||
public void onClick(ClickEvent event) {
|
||||
GWT.log("clicked: " + status);
|
||||
setActiveStatus(status);
|
||||
eventBus.fireEvent(new SelectItemsWithItemStatusEvent(status, null, null));
|
||||
eventBus.fireEvent(new SelectItemsWithItemStatusEvent(status, null, null, getActiveSortBy()));
|
||||
|
||||
}
|
||||
});
|
||||
dropdownSelectStatus.add(navLink);
|
||||
}
|
||||
|
||||
for (final ItemFieldDV itemField : sortByList) {
|
||||
|
||||
NavLink navLink = new NavLink();
|
||||
navLink.setText(itemField.getDisplayName());
|
||||
navLink.addClickHandler(new ClickHandler() {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
setActiveSortBy(itemField);
|
||||
eventBus.fireEvent(new SelectItemsWithItemStatusEvent(getActiveStatus(), null, null, itemField));
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
dropdownSortBy.add(navLink);
|
||||
}
|
||||
}
|
||||
|
||||
private void setActiveSortBy(ItemFieldDV itemField) {
|
||||
this.activeSortBy = itemField;
|
||||
this.orderInfo.setText(activeSortBy.getDisplayName());
|
||||
}
|
||||
|
||||
private void setActiveStatus(ItemStatus status) {
|
||||
|
@ -81,6 +118,23 @@ public class ContentModeratorToolbar extends Composite {
|
|||
|
||||
}
|
||||
|
||||
public ItemFieldDV getActiveSortBy() {
|
||||
|
||||
if (activeSortBy != null)
|
||||
return activeSortBy;
|
||||
|
||||
NavLink navLink = dropdownSortBy.getLastSelectedNavLink();
|
||||
String selectedText = navLink.getText();
|
||||
for (ItemFieldDV itemField : sortByList) {
|
||||
|
||||
if (itemField.getDisplayName().compareTo(selectedText) == 0) {
|
||||
return itemField;
|
||||
}
|
||||
}
|
||||
|
||||
return sortByList.get(0);
|
||||
}
|
||||
|
||||
public ItemStatus getActiveStatus() {
|
||||
return activeStatus;
|
||||
}
|
||||
|
|
|
@ -11,6 +11,10 @@
|
|||
.margin-top-12 {
|
||||
margin-top: 12px;
|
||||
}
|
||||
|
||||
.margin-left-20 {
|
||||
margin-left: 20px;
|
||||
}
|
||||
</ui:style>
|
||||
<g:HTMLPanel>
|
||||
<b:Navbar>
|
||||
|
@ -23,6 +27,14 @@
|
|||
<b:Label ui:field="statusInfo" type="INFO"
|
||||
addStyleNames="{style.margin-top-12}"></b:Label>
|
||||
</b:Nav>
|
||||
<b:Nav>
|
||||
<b:Dropdown text="Order By" ui:field="dropdownSortBy"
|
||||
addStyleNames="{style.margin-left-20}">
|
||||
</b:Dropdown>
|
||||
</b:Nav>
|
||||
<b:Nav>
|
||||
<b:Label ui:field="orderInfo" type="DEFAULT" addStyleNames="{style.margin-top-12}"></b:Label>
|
||||
</b:Nav>
|
||||
<b:Nav alignment="RIGHT">
|
||||
<b:NavLink ui:field="closeAllTabs">Close All Tabs
|
||||
</b:NavLink>
|
||||
|
|
|
@ -7,10 +7,10 @@ import org.gcube.datacatalogue.utillibrary.shared.ItemStatus;
|
|||
import org.gcube.portlets.widgets.ckancontentmoderator.client.CkanContentModeratorWidgetController;
|
||||
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.DISPLAY_FIELD;
|
||||
import org.gcube.portlets.widgets.ckancontentmoderator.shared.OperationReport;
|
||||
|
||||
import com.github.gwtbootstrap.client.ui.AlertBlock;
|
||||
|
@ -424,8 +424,9 @@ public class HomeView extends Composite {
|
|||
* Load form server the items with status.
|
||||
*
|
||||
* @param itemStatus the item status
|
||||
* @param sortForField
|
||||
*/
|
||||
public void loadItemsWithStatus(ItemStatus itemStatus) {
|
||||
public void loadItemsWithStatus(ItemStatus itemStatus, String sortForField) {
|
||||
GWT.log("loadItemsWithStatus started");
|
||||
setDisplayingWithStatus(itemStatus);
|
||||
setCheckedCheckboxSelectAll(false);
|
||||
|
@ -436,7 +437,7 @@ public class HomeView extends Composite {
|
|||
if (itemStatus.equals(ItemStatus.REJECTED))
|
||||
setVisiblePermanentlyDelete(true);
|
||||
|
||||
paginatedView.loadItemsForStatus(itemStatus);
|
||||
paginatedView.loadItemsForStatus(itemStatus, sortForField);
|
||||
|
||||
GWT.log("loadItemsWithStatus end");
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ import org.gcube.portlets.widgets.ckancontentmoderator.client.events.ShowItemEve
|
|||
import org.gcube.portlets.widgets.ckancontentmoderator.client.resources.ContentModeratorWidgetResources;
|
||||
import org.gcube.portlets.widgets.ckancontentmoderator.client.ui.SelectionItems;
|
||||
import org.gcube.portlets.widgets.ckancontentmoderator.shared.CatalogueDataset;
|
||||
import org.gcube.portlets.widgets.ckancontentmoderator.shared.DISPLAY_FIELD;
|
||||
|
||||
import com.github.gwtbootstrap.client.ui.Pagination;
|
||||
import com.google.gwt.cell.client.ButtonCell;
|
||||
|
@ -62,15 +63,6 @@ public class ItemsTable<T extends CatalogueDataset> extends AbstractItemsCellTab
|
|||
|
||||
private AbstractDataProvider<T> dataProvider;
|
||||
|
||||
/**
|
||||
* The Enum DISPLAY_FIELD.
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it Feb 1, 2016
|
||||
*/
|
||||
public static enum DISPLAY_FIELD {
|
||||
NAME, TITLE, AUTHOR, CREATED, TYPE, LAST_UPDATE
|
||||
};
|
||||
|
||||
private List<DISPLAY_FIELD> displayFields;
|
||||
private Column<T, Date> createdColumn;
|
||||
private Column<T, Date> lastUpdateColumn;
|
||||
|
|
|
@ -169,12 +169,13 @@ public class CkanContentModeratorServiceImpl extends RemoteServiceServlet implem
|
|||
* @param limit the limit
|
||||
* @param restrictedToLoggedInUser if true restricts the list of items to logged
|
||||
* in user
|
||||
* @param sortForField the sort for field
|
||||
* @return the list items for status
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Override
|
||||
public List<CatalogueDataset> getListItemsForStatus(ItemStatus theStatus, int offset, int limit,
|
||||
boolean restrictedToLoggedInUser) throws Exception {
|
||||
boolean restrictedToLoggedInUser, String sortForField) throws Exception {
|
||||
LOG.info("called getListItemsForStatus with [status: " + theStatus + ", offset: " + offset + ", limit: " + limit
|
||||
+ ", restrictedToLoggedInUser: " + restrictedToLoggedInUser + "]");
|
||||
List<CatalogueDataset> datasetList = null;
|
||||
|
@ -191,7 +192,7 @@ public class CkanContentModeratorServiceImpl extends RemoteServiceServlet implem
|
|||
filters.put(ContentModeratorWidgetConstants.CKAN_FIELD_NAME_AUTHOR_MAIL, valueOfQueryEmails);
|
||||
}
|
||||
|
||||
List<CkanDataset> datasets = cmsInstance.getListItemsForStatus(theStatus, limit, offset, filters);
|
||||
List<CkanDataset> datasets = cmsInstance.getListItemsForStatus(theStatus, limit, offset, filters, sortForField);
|
||||
if (datasets != null) {
|
||||
int size = datasets.size();
|
||||
datasetList = new ArrayList<CatalogueDataset>(size);
|
||||
|
@ -370,12 +371,14 @@ public class CkanContentModeratorServiceImpl extends RemoteServiceServlet implem
|
|||
* @param offset the offset
|
||||
* @param limit the limit
|
||||
* @param serverStartIndex the server start index
|
||||
* @param restrictedToLoggedInUser the restricted to logged in user
|
||||
* @param sortForField the sort for field
|
||||
* @return the data for status
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Override
|
||||
public SearchedData getDataForStatus(ItemStatus status, int offset, int limit, int serverStartIndex,
|
||||
boolean restrictedToLoggedInUser) throws Exception {
|
||||
boolean restrictedToLoggedInUser, String sortForField) throws Exception {
|
||||
LOG.info("called getDataForStatus [status: " + status + ", offset: " + offset + ", limit: " + limit
|
||||
+ ", serverIndex: " + serverStartIndex);
|
||||
|
||||
|
@ -397,7 +400,7 @@ public class CkanContentModeratorServiceImpl extends RemoteServiceServlet implem
|
|||
List<CatalogueDataset> listDataset = new ArrayList<CatalogueDataset>();
|
||||
try {
|
||||
LOG.debug("getListItemsForStatus with searchStartIndex: " + searchStartIndex + ", limit: " + limit);
|
||||
listDataset = getListItemsForStatus(status, searchStartIndex, limit, restrictedToLoggedInUser);
|
||||
listDataset = getListItemsForStatus(status, searchStartIndex, limit, restrictedToLoggedInUser, sortForField);
|
||||
} catch (Exception e) {
|
||||
String error = "Error occurred on getting items for status: " + status;
|
||||
LOG.error(error, e);
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
package org.gcube.portlets.widgets.ckancontentmoderator.shared;
|
||||
|
||||
/**
|
||||
* The Enum DISPLAY_FIELD.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Apr 22, 2022
|
||||
*/
|
||||
public enum DISPLAY_FIELD {
|
||||
NAME("Name", "name"), TITLE("Title", "title"), AUTHOR("Author", "author_mail"),
|
||||
CREATED("Created", "metadata_created"), LAST_UPDATE("Last Update", "metadata_modified"),
|
||||
TYPE("Type", "extras_systemtype");
|
||||
|
||||
String label;
|
||||
String jsonField;
|
||||
|
||||
/**
|
||||
* Instantiates a new display field.
|
||||
*
|
||||
* @param label the label
|
||||
* @param jsonField the json field
|
||||
*/
|
||||
private DISPLAY_FIELD(String label, String jsonField) {
|
||||
this.label = label;
|
||||
this.jsonField = jsonField;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the label.
|
||||
*
|
||||
* @return the label
|
||||
*/
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the json field.
|
||||
*
|
||||
* @return the json field
|
||||
*/
|
||||
public String getJsonField() {
|
||||
return jsonField;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,165 @@
|
|||
package org.gcube.portlets.widgets.ckancontentmoderator.shared;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* The Class ItemFieldDV.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Apr 22, 2022
|
||||
*/
|
||||
public class ItemFieldDV implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 563269286444442608L;
|
||||
private String displayName;
|
||||
private List<String> jsonFields;
|
||||
private String operator;
|
||||
private boolean displayAsResult;
|
||||
private boolean sortable;
|
||||
private boolean searchable;
|
||||
|
||||
/**
|
||||
* Instantiates a new item field.
|
||||
*/
|
||||
public ItemFieldDV() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the display name.
|
||||
*
|
||||
* @return the display name
|
||||
*/
|
||||
public String getDisplayName() {
|
||||
return displayName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the json fields.
|
||||
*
|
||||
* @return the json fields
|
||||
*/
|
||||
public List<String> getJsonFields() {
|
||||
return jsonFields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the operator.
|
||||
*
|
||||
* @return the operator
|
||||
*/
|
||||
public String getOperator() {
|
||||
return operator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if is display as result.
|
||||
*
|
||||
* @return true, if is display as result
|
||||
*/
|
||||
public boolean isDisplayAsResult() {
|
||||
return displayAsResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if is sortable.
|
||||
*
|
||||
* @return true, if is sortable
|
||||
*/
|
||||
public boolean isSortable() {
|
||||
return sortable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if is searchable.
|
||||
*
|
||||
* @return true, if is searchable
|
||||
*/
|
||||
public boolean isSearchable() {
|
||||
return searchable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the display name.
|
||||
*
|
||||
* @param displayName the new display name
|
||||
*/
|
||||
public void setDisplayName(String displayName) {
|
||||
this.displayName = displayName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the json fields.
|
||||
*
|
||||
* @param jsonFields the new json fields
|
||||
*/
|
||||
public void setJsonFields(List<String> jsonFields) {
|
||||
this.jsonFields = jsonFields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the operator.
|
||||
*
|
||||
* @param operator the new operator
|
||||
*/
|
||||
public void setOperator(String operator) {
|
||||
this.operator = operator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the display as result.
|
||||
*
|
||||
* @param displayAsResult the new display as result
|
||||
*/
|
||||
public void setDisplayAsResult(boolean displayAsResult) {
|
||||
this.displayAsResult = displayAsResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the sortable.
|
||||
*
|
||||
* @param sortable the new sortable
|
||||
*/
|
||||
public void setSortable(boolean sortable) {
|
||||
this.sortable = sortable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the searchable.
|
||||
*
|
||||
* @param searchable the new searchable
|
||||
*/
|
||||
public void setSearchable(boolean searchable) {
|
||||
this.searchable = searchable;
|
||||
}
|
||||
|
||||
/**
|
||||
* To string.
|
||||
*
|
||||
* @return the string
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("ItemFieldDV [displayName=");
|
||||
builder.append(displayName);
|
||||
builder.append(", jsonFields=");
|
||||
builder.append(jsonFields);
|
||||
builder.append(", operator=");
|
||||
builder.append(operator);
|
||||
builder.append(", displayAsResult=");
|
||||
builder.append(displayAsResult);
|
||||
builder.append(", sortable=");
|
||||
builder.append(sortable);
|
||||
builder.append(", searchable=");
|
||||
builder.append(searchable);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,191 @@
|
|||
package org.gcube.portlets.widgets.ckancontentmoderator.shared;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* The Class SearchingFilter.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Apr 22, 2022
|
||||
*/
|
||||
public class SearchingFilter implements Serializable {
|
||||
|
||||
/**
|
||||
* The Enum ORDER.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Apr 22, 2022
|
||||
*/
|
||||
public static enum ORDER {
|
||||
ASC("asc"), DESC("desc");
|
||||
|
||||
String label;
|
||||
|
||||
/**
|
||||
* Instantiates a new order.
|
||||
*
|
||||
* @param label the label
|
||||
*/
|
||||
ORDER(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the label.
|
||||
*
|
||||
* @return the label
|
||||
*/
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The Enum LOGICAL_OP.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Dec 15, 2021
|
||||
*/
|
||||
public static enum LOGICAL_OP {
|
||||
AND("AND"), OR("OR");
|
||||
|
||||
String operator;
|
||||
|
||||
/**
|
||||
* Instantiates a new order.
|
||||
*
|
||||
* @param operator the operator
|
||||
*/
|
||||
LOGICAL_OP(String operator) {
|
||||
this.operator = operator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the operator.
|
||||
*
|
||||
* @return the operator
|
||||
*/
|
||||
public String getOperator() {
|
||||
return operator;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -4004094263090373626L;
|
||||
|
||||
private List<ItemFieldDV> orderByFields;
|
||||
|
||||
private ORDER order = ORDER.ASC;
|
||||
|
||||
private List<WhereClause> conditions;
|
||||
|
||||
/**
|
||||
* Instantiates a new sort filter.
|
||||
*/
|
||||
public SearchingFilter() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new sort filter.
|
||||
*
|
||||
* @param orderByFields the order by fields
|
||||
* @param order the order
|
||||
*/
|
||||
public SearchingFilter(List<ItemFieldDV> orderByFields, ORDER order) {
|
||||
this.orderByFields = orderByFields;
|
||||
this.order = order;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new sort filter.
|
||||
*
|
||||
* @param orderByFields the order by fields
|
||||
* @param order the order
|
||||
* @param conditions the conditions
|
||||
*/
|
||||
public SearchingFilter(List<ItemFieldDV> orderByFields, ORDER order, List<WhereClause> conditions) {
|
||||
this.orderByFields = orderByFields;
|
||||
this.order = order;
|
||||
this.conditions = conditions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the conditions.
|
||||
*
|
||||
* @return the conditions
|
||||
*/
|
||||
public List<WhereClause> getConditions() {
|
||||
return conditions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the conditions.
|
||||
*
|
||||
* @param conditions the new conditions
|
||||
*/
|
||||
public void setConditions(List<WhereClause> conditions) {
|
||||
this.conditions = conditions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the order by fields.
|
||||
*
|
||||
* @return the order by fields
|
||||
*/
|
||||
public List<ItemFieldDV> getOrderByFields() {
|
||||
return orderByFields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the order.
|
||||
*
|
||||
* @return the order
|
||||
*/
|
||||
public ORDER getOrder() {
|
||||
return order;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the order by fields.
|
||||
*
|
||||
* @param orderByFields the new order by fields
|
||||
*/
|
||||
public void setOrderByFields(List<ItemFieldDV> orderByFields) {
|
||||
this.orderByFields = orderByFields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the order.
|
||||
*
|
||||
* @param order the new order
|
||||
*/
|
||||
public void setOrder(ORDER order) {
|
||||
this.order = order;
|
||||
}
|
||||
|
||||
/**
|
||||
* To string.
|
||||
*
|
||||
* @return the string
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("SearchingFilter [orderByFields=");
|
||||
builder.append(orderByFields);
|
||||
builder.append(", order=");
|
||||
builder.append(order);
|
||||
builder.append(", conditions=");
|
||||
builder.append(conditions);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,98 @@
|
|||
package org.gcube.portlets.widgets.ckancontentmoderator.shared;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
|
||||
import org.gcube.portlets.widgets.ckancontentmoderator.shared.SearchingFilter.LOGICAL_OP;
|
||||
|
||||
/**
|
||||
* The Class WhereClause.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Apr 22, 2022
|
||||
*/
|
||||
public class WhereClause implements Serializable {
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -3354004449129217444L;
|
||||
|
||||
private LOGICAL_OP operator = LOGICAL_OP.OR;
|
||||
|
||||
private Map<String, Object> searchInto;
|
||||
|
||||
/**
|
||||
* Instantiates a new where clause.
|
||||
*/
|
||||
public WhereClause() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new where clause.
|
||||
*
|
||||
* @param operator the operator
|
||||
* @param searchInto the search into
|
||||
*/
|
||||
public WhereClause(LOGICAL_OP operator, Map<String, Object> searchInto) {
|
||||
super();
|
||||
this.operator = operator;
|
||||
this.searchInto = searchInto;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the operator.
|
||||
*
|
||||
* @return the operator
|
||||
*/
|
||||
public LOGICAL_OP getOperator() {
|
||||
return operator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the search into.
|
||||
*
|
||||
* @return the search into
|
||||
*/
|
||||
public Map<String, Object> getSearchInto() {
|
||||
return searchInto;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the operator.
|
||||
*
|
||||
* @param operator the new operator
|
||||
*/
|
||||
public void setOperator(LOGICAL_OP operator) {
|
||||
this.operator = operator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the search into.
|
||||
*
|
||||
* @param searchInto the search into
|
||||
*/
|
||||
public void setSearchInto(Map<String, Object> searchInto) {
|
||||
this.searchInto = searchInto;
|
||||
}
|
||||
|
||||
/**
|
||||
* To string.
|
||||
*
|
||||
* @return the string
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("WhereClause [operator=");
|
||||
builder.append(operator);
|
||||
builder.append(", searchInto=");
|
||||
builder.append(searchInto);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -8,6 +8,7 @@ import java.util.Map;
|
|||
|
||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.datacatalogue.utillibrary.gcat.GCatCaller;
|
||||
import org.gcube.datacatalogue.utillibrary.server.cms.CatalogueContentModeratorSystem;
|
||||
import org.gcube.datacatalogue.utillibrary.shared.ItemStatus;
|
||||
import org.gcube.datacatalogue.utillibrary.shared.jackan.model.CkanDataset;
|
||||
|
@ -37,7 +38,7 @@ public class CkanContentModeratorServiceTest {
|
|||
CatalogueContentModeratorSystem cms = CatalogueCMSFactory.getFactory().getCMSPerScope(scope);
|
||||
Map<String, String> filters = new HashMap<String, String>(1);
|
||||
filters.put(ContentModeratorWidgetConstants.CKAN_FIELD_NAME_AUTHOR_MAIL, "francesco.mangiacrapa@isti.cnr.it");
|
||||
List<CkanDataset> items = cms.getListItemsForStatus(itemStatus, 20, 0, filters);
|
||||
List<CkanDataset> items = cms.getListItemsForStatus(itemStatus, 20, 0, filters, GCatCaller.DEFAULT_SORT_VALUE);
|
||||
int i = 0;
|
||||
System.out.println("Datasets with status "+itemStatus+" are: "+items.size());
|
||||
for (CkanDataset ckanDataset : items) {
|
||||
|
|
Loading…
Reference in New Issue