parent
4542ef599b
commit
d3954ecd71
|
@ -11,3 +11,4 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
|
|||
- [#20650] Provided moderator skills to Catalogue Moderator(s)
|
||||
- [#23108] Provided Moderation facility accessible to Catalogue Editor/Admin (only) in read only mode
|
||||
- [#23197] Revised the query passed to gCat with the moderation states
|
||||
- [#23258] Implemented the requirement described in #23156
|
||||
|
|
|
@ -37,21 +37,27 @@ public class CheckConfigsUxController {
|
|||
|
||||
private DISPLAY_FIELD[] displayFields;
|
||||
|
||||
private String initOnItemName;
|
||||
|
||||
/**
|
||||
* Instantiates a new check configs ux controller.
|
||||
*
|
||||
* @param mainPanel the main panel
|
||||
* @param initItemStatus the init item status
|
||||
* @param initOnItemName
|
||||
* @param displayFields the display fields
|
||||
* @param sortByFields the sort by fields
|
||||
* @param moderatorcheckConfig the moderatorcheck config
|
||||
*/
|
||||
protected CheckConfigsUxController(MainPanel mainPanel, ItemStatus initItemStatus, DISPLAY_FIELD[] displayFields,
|
||||
DISPLAY_FIELD[] sortByFields, CkanContentModeratorCheckConfigs moderatorcheckConfig) {
|
||||
protected CheckConfigsUxController(MainPanel mainPanel, ItemStatus initItemStatus, String initOnItemName,
|
||||
DISPLAY_FIELD[] displayFields, DISPLAY_FIELD[] sortByFields,
|
||||
CkanContentModeratorCheckConfigs moderatorcheckConfig) {
|
||||
|
||||
this.mainPanel = mainPanel;
|
||||
this.basePanelContainer = mainPanel.getMainPanelContainer();
|
||||
this.moderatorCheckConfig = moderatorcheckConfig;
|
||||
this.initItemStatus = initItemStatus;
|
||||
this.initOnItemName = initOnItemName;
|
||||
this.displayFields = displayFields;
|
||||
this.orderByFields = sortByFields;
|
||||
|
||||
|
@ -146,8 +152,8 @@ public class CheckConfigsUxController {
|
|||
} catch (Exception e) {
|
||||
}
|
||||
|
||||
cmsController = new CkanContentModeratorWidgetController(initItemStatus, displayFields, orderByFields,
|
||||
false, false);
|
||||
cmsController = new CkanContentModeratorWidgetController(initItemStatus, initOnItemName, displayFields,
|
||||
orderByFields, false, false);
|
||||
basePanelContainer.add(cmsController.getMainPanel());
|
||||
|
||||
mainPanel.setLoggedLabelText("Logged in as Moderator");
|
||||
|
@ -178,11 +184,10 @@ public class CheckConfigsUxController {
|
|||
GWT.log("readOnlyMode is enabled? " + readOnlyMode);
|
||||
GWT.log("restrictDataToLoggedInUser is? " + restrictDataToLoggedInUser);
|
||||
|
||||
cmsController = new CkanContentModeratorWidgetController(initItemStatus, displayFields, orderByFields,
|
||||
readOnlyMode, restrictDataToLoggedInUser);
|
||||
cmsController = new CkanContentModeratorWidgetController(initItemStatus, initOnItemName, displayFields,
|
||||
orderByFields, readOnlyMode, restrictDataToLoggedInUser);
|
||||
|
||||
basePanelContainer.add(cmsController.getMainPanel());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -124,4 +124,13 @@ public interface CkanContentModeratorService extends RemoteService {
|
|||
* @throws Exception the exception
|
||||
*/
|
||||
public Boolean existsMyItemInModeration() throws Exception;
|
||||
|
||||
/**
|
||||
* Gets the item for name.
|
||||
*
|
||||
* @param itemName the item name
|
||||
* @return the item for name
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
CatalogueDataset getItemForName(String itemName) throws Exception;
|
||||
}
|
||||
|
|
|
@ -30,9 +30,32 @@ 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 sortForField the sort for field
|
||||
* @param callback the callback
|
||||
* @return the list items for status
|
||||
*/
|
||||
void getListItemsForStatus(ItemStatus theStatus, int offset, int limit, boolean restrictedToLoggedInUser,
|
||||
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 sortForField the sort for field
|
||||
* @param asyncCallback the async callback
|
||||
* @return the data for status
|
||||
*/
|
||||
void getDataForStatus(ItemStatus status, int offset, int limit, int serverStartIndex,
|
||||
boolean restrictedToLoggedInUser, String sortForField, AsyncCallback<SearchedData> asyncCallback);
|
||||
|
||||
|
@ -94,4 +117,13 @@ public interface CkanContentModeratorServiceAsync {
|
|||
*/
|
||||
void existsMyItemInModeration(AsyncCallback<Boolean> callback);
|
||||
|
||||
/**
|
||||
* Gets the item for name.
|
||||
*
|
||||
* @param itemName the item name
|
||||
* @param callback the callback
|
||||
* @return the item for name
|
||||
*/
|
||||
void getItemForName(String itemName, AsyncCallback<CatalogueDataset> callback);
|
||||
|
||||
}
|
||||
|
|
|
@ -33,22 +33,18 @@ public class CkanContentModeratorWidget {
|
|||
public CkanContentModeratorWidget(ItemStatus initItemStatus, String initOnItemName, DISPLAY_FIELD[] displayFields,
|
||||
DISPLAY_FIELD[] sortByFields) {
|
||||
mainPanel.setWidth("100%");
|
||||
ccux = new CheckConfigsUxController(mainPanel, initItemStatus, displayFields, sortByFields, null);
|
||||
ccux = new CheckConfigsUxController(mainPanel, initItemStatus, initOnItemName, displayFields, sortByFields, null);
|
||||
|
||||
boolean iamModerator = false;
|
||||
boolean isModeratorRoleAssigned = false;
|
||||
try {
|
||||
iamModerator = ccux.getModeratorCheckConfig().isModeratorRoleAssigned();
|
||||
isModeratorRoleAssigned = ccux.getModeratorCheckConfig().isModeratorRoleAssigned();
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
|
||||
if (iamModerator) {
|
||||
if (isModeratorRoleAssigned) {
|
||||
mainPanel.setLoggedLabelText("Logged in as Moderator");
|
||||
}
|
||||
|
||||
if(initOnItemName!=null) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -34,7 +34,10 @@ 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.core.client.Scheduler;
|
||||
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
|
||||
import com.google.gwt.event.shared.HandlerManager;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.google.gwt.user.client.ui.ComplexPanel;
|
||||
import com.google.gwt.user.client.ui.FlowPanel;
|
||||
|
||||
|
@ -67,13 +70,15 @@ public class CkanContentModeratorWidgetController {
|
|||
* Instantiates a new ckan content moderator widget.
|
||||
*
|
||||
* @param status the status
|
||||
* @param initOnItemName the init on item name
|
||||
* @param displayFields the display fields
|
||||
* @param sortByField the sort by field
|
||||
* @param sortByFields the sort by fields
|
||||
* @param readOnlyMode the read only mode
|
||||
* @param restrictDataToLoggedInUser
|
||||
* @param restrictDataToLoggedInUser the restrict data to logged in user
|
||||
*/
|
||||
protected CkanContentModeratorWidgetController(ItemStatus status, DISPLAY_FIELD[] displayFields,
|
||||
DISPLAY_FIELD[] sortByFields, boolean readOnlyMode, boolean restrictDataToLoggedInUser) {
|
||||
protected CkanContentModeratorWidgetController(ItemStatus status, final String initOnItemName,
|
||||
DISPLAY_FIELD[] displayFields, DISPLAY_FIELD[] sortByFields, boolean readOnlyMode,
|
||||
boolean restrictDataToLoggedInUser) {
|
||||
|
||||
DISPLAY_FIELD firstSortField = null;
|
||||
if (sortByFields == null || sortByFields.length == 0) {
|
||||
|
@ -101,6 +106,40 @@ public class CkanContentModeratorWidgetController {
|
|||
howeView.hideUpdateStatusAction(readOnlyMode);
|
||||
howeView.hideSelectableRow(readOnlyMode);
|
||||
bindEvents();
|
||||
|
||||
if (initOnItemName != null) {
|
||||
|
||||
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
|
||||
CkanContentModeratorWidgetController.contentModeratorService.getItemForName(initOnItemName,
|
||||
new AsyncCallback<CatalogueDataset>() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(CatalogueDataset result) {
|
||||
GWT.log("CatalogueDataset read is: " + result);
|
||||
|
||||
if (result != null) {
|
||||
eventBus.fireEvent(new ShowItemEvent<CatalogueDataset>(Arrays.asList(result),true));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
GWT.log("Error on reading " + initOnItemName + ". Either the item with name: "
|
||||
+ initOnItemName + " is not valid dataset or not readable");
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -156,7 +195,7 @@ public class CkanContentModeratorWidgetController {
|
|||
|
||||
@Override
|
||||
public <T> void onShowItemClicked(ShowItemEvent<T> showItemEvent) {
|
||||
|
||||
GWT.log("onShowItemClicked fired");
|
||||
if (showItemEvent.getSelectItems() != null) {
|
||||
List<T> items = showItemEvent.getSelectItems();
|
||||
|
||||
|
@ -164,7 +203,7 @@ public class CkanContentModeratorWidgetController {
|
|||
CatalogueDataset clickedDataset = (CatalogueDataset) t;
|
||||
CkanShowItemFrame csif = new CkanShowItemFrame(eventBus);
|
||||
csif.instanceFrame(clickedDataset.getUrl());
|
||||
mainTabPanel.addTab(clickedDataset.getTitle(), csif);
|
||||
mainTabPanel.addTab(clickedDataset.getTitle(), csif, showItemEvent.isFocusOnDisplaying());
|
||||
mapOfItemsTabDisplayed.put(clickedDataset.getUrl(), csif);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ public class CkanContentModeratorWidgetTrusted {
|
|||
GWT.log("CkanContentModeratorWidget called. CkanContentModeratorCheckConfigs: "
|
||||
+ ckanContentModeratorCheckConfig);
|
||||
mainPanel.setWidth("100%");
|
||||
ccux = new CheckConfigsUxController(mainPanel, initItemStatus, displayFields, sortByFields, ckanContentModeratorCheckConfig);
|
||||
ccux = new CheckConfigsUxController(mainPanel, initItemStatus, null, displayFields, sortByFields, ckanContentModeratorCheckConfig);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -15,14 +15,17 @@ import com.google.gwt.event.shared.GwtEvent;
|
|||
public class ShowItemEvent<T> extends GwtEvent<ShowItemEventHandler> {
|
||||
public static Type<ShowItemEventHandler> TYPE = new Type<ShowItemEventHandler>();
|
||||
private List<T> selectItems;
|
||||
private boolean focusOnDisplaying = false;
|
||||
|
||||
/**
|
||||
* Instantiates a new click item event.
|
||||
*
|
||||
* @param selectItems the select items
|
||||
* @param focusOnDisplaying the focus on displaying
|
||||
*/
|
||||
public ShowItemEvent(List<T> selectItems) {
|
||||
public ShowItemEvent(List<T> selectItems, boolean focusOnDisplaying) {
|
||||
this.selectItems = selectItems;
|
||||
this.focusOnDisplaying = focusOnDisplaying;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -65,4 +68,13 @@ public class ShowItemEvent<T> extends GwtEvent<ShowItemEventHandler> {
|
|||
public List<T> getSelectItems() {
|
||||
return selectItems;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if is focus on displaying.
|
||||
*
|
||||
* @return true, if is focus on displaying
|
||||
*/
|
||||
public boolean isFocusOnDisplaying() {
|
||||
return focusOnDisplaying;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@ public class MainTabPanel extends Composite {
|
|||
* @param w the w
|
||||
* @return the tab
|
||||
*/
|
||||
public Tab addTab(String heading, Widget w) {
|
||||
public Tab addTab(String heading, Widget w, boolean selectTab) {
|
||||
final Tab tab = new Tab();
|
||||
|
||||
if (w instanceof CkanShowItemFrame) {
|
||||
|
@ -108,14 +108,15 @@ public class MainTabPanel extends Composite {
|
|||
mainTabPanel.add(tab);
|
||||
// activeTabPanels(false);
|
||||
|
||||
if (selectTab) {
|
||||
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
// mainTabPanel.selectTab(results.size() - 1);
|
||||
|
||||
mainTabPanel.selectTab(results.size() - 1);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return tab;
|
||||
}
|
||||
|
|
|
@ -139,7 +139,7 @@ public class ItemsTable<T extends CatalogueDataset> extends AbstractItemsCellTab
|
|||
@Override
|
||||
public void update(int index, T object, String value) {
|
||||
GWT.log("clicked show");
|
||||
eventBus.fireEvent(new ShowItemEvent<T>(Arrays.asList(object)));
|
||||
eventBus.fireEvent(new ShowItemEvent<T>(Arrays.asList(object), false));
|
||||
}
|
||||
});
|
||||
sortedCellTable.addColumn(showdItemColumn);
|
||||
|
|
|
@ -39,6 +39,12 @@ public class CkanContentModeratorServiceImpl extends RemoteServiceServlet implem
|
|||
|
||||
private static Logger LOG = LoggerFactory.getLogger(CkanContentModeratorServiceImpl.class);
|
||||
|
||||
/**
|
||||
* Checks if is moderation enabled.
|
||||
*
|
||||
* @param reloadConfig the reload config
|
||||
* @return the boolean
|
||||
*/
|
||||
@Override
|
||||
public Boolean isModerationEnabled(boolean reloadConfig) {
|
||||
LOG.info("called isContentModeratorEnabled");
|
||||
|
@ -154,10 +160,13 @@ public class CkanContentModeratorServiceImpl extends RemoteServiceServlet implem
|
|||
*/
|
||||
private String setContexts() {
|
||||
String scope = GcubeContextUtil.getCurrentScope(this.getThreadLocalRequest());
|
||||
GCubeUser user = GcubeContextUtil.getCurrentUser(this.getThreadLocalRequest());
|
||||
String token = GcubeContextUtil.getCurrentToken(scope, user.getUsername());
|
||||
ScopeProvider.instance.set(scope);
|
||||
|
||||
GCubeUser user = GcubeContextUtil.getCurrentUser(this.getThreadLocalRequest());
|
||||
if (user != null) {
|
||||
String token = GcubeContextUtil.getCurrentToken(scope, user.getUsername());
|
||||
SecurityTokenProvider.instance.set(token);
|
||||
}
|
||||
return scope;
|
||||
}
|
||||
|
||||
|
@ -192,15 +201,14 @@ public class CkanContentModeratorServiceImpl extends RemoteServiceServlet implem
|
|||
filters.put(ContentModeratorWidgetConstants.CKAN_FIELD_NAME_AUTHOR_MAIL, valueOfQueryEmails);
|
||||
}
|
||||
|
||||
List<CkanDataset> datasets = cmsInstance.getListItemsForStatus(theStatus, limit, offset, filters, sortForField);
|
||||
List<CkanDataset> datasets = cmsInstance.getListItemsForStatus(theStatus, limit, offset, filters,
|
||||
sortForField);
|
||||
if (datasets != null) {
|
||||
int size = datasets.size();
|
||||
datasetList = new ArrayList<CatalogueDataset>(size);
|
||||
LOG.info("datasetList for input parameters returned by CMS has size: " + size);
|
||||
for (CkanDataset ckanDataset : datasets) {
|
||||
CatalogueDataset ds = CatalogueBeansConverter.toCatalogueDataset.apply(ckanDataset);
|
||||
String datasetURL = String.format("%s/dataset/%s", catalogueImpl.getCatalogueUrl(), ds.getName());
|
||||
ds.setUrl(datasetURL);
|
||||
CatalogueDataset ds = toPatchedCatalogueDataset(ckanDataset, catalogueImpl.getCatalogueUrl());
|
||||
LOG.trace("converted dataset is: " + ds);
|
||||
datasetList.add(ds);
|
||||
}
|
||||
|
@ -215,6 +223,48 @@ public class CkanContentModeratorServiceImpl extends RemoteServiceServlet implem
|
|||
return datasetList;
|
||||
}
|
||||
|
||||
private CatalogueDataset toPatchedCatalogueDataset(CkanDataset ckanDataset, String catalogueURL) {
|
||||
if (ckanDataset == null)
|
||||
return null;
|
||||
|
||||
CatalogueDataset ds = CatalogueBeansConverter.toCatalogueDataset.apply(ckanDataset);
|
||||
String datasetURL = String.format("%s/dataset/%s", catalogueURL, ds.getName());
|
||||
ds.setUrl(datasetURL);
|
||||
return ds;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the item for name.
|
||||
*
|
||||
* @param itemName the item name
|
||||
* @return the item for name
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Override
|
||||
public CatalogueDataset getItemForName(String itemName) throws Exception {
|
||||
LOG.info("called getItemForName for: " + itemName);
|
||||
CatalogueDataset ds = null;
|
||||
try {
|
||||
String scope = setContexts();
|
||||
DataCatalogueImpl catalogueImpl = CatalogueCMSFactory.getFactory().getCatalogueImplPerScope(scope);
|
||||
GCubeUser user = GcubeContextUtil.getCurrentUser(this.getThreadLocalRequest());
|
||||
if (user != null) {
|
||||
CkanDataset ckanDataset = catalogueImpl.getDataset(itemName, user.getUsername());
|
||||
ds = null;
|
||||
if (ckanDataset != null) {
|
||||
ds = toPatchedCatalogueDataset(ckanDataset, catalogueImpl.getCatalogueUrl());
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
LOG.error("Error occurred on reading item for name: " + itemName, e);
|
||||
throw e;
|
||||
}
|
||||
|
||||
LOG.info("returning: " + ds);
|
||||
return ds;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the status.
|
||||
*
|
||||
|
@ -400,7 +450,8 @@ 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, sortForField);
|
||||
listDataset = getListItemsForStatus(status, searchStartIndex, limit, restrictedToLoggedInUser,
|
||||
sortForField);
|
||||
} catch (Exception e) {
|
||||
String error = "Error occurred on getting items for status: " + status;
|
||||
LOG.error(error, e);
|
||||
|
@ -423,4 +474,5 @@ public class CkanContentModeratorServiceImpl extends RemoteServiceServlet implem
|
|||
LOG.debug("Returning: " + searchedData);
|
||||
return searchedData;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue