task_21363 #1

Closed
francesco.mangiacrapa wants to merge 53 commits from task_21363 into master
5 changed files with 111 additions and 27 deletions
Showing only changes of commit 2ea8dee474 - Show all commits

View File

@ -30,11 +30,11 @@
<properties> <properties>
<!-- Convenience property to set the GWT version --> <!-- Convenience property to set the GWT version -->
<gwtVersion>2.8.2</gwtVersion> <gwtVersion>2.7.0</gwtVersion>
<distroDirectory>distro</distroDirectory> <distroDirectory>distro</distroDirectory>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target> <maven.compiler.target>1.8</maven.compiler.target>
<webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory> <webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory>
<gwt-material.version>2.4.0</gwt-material.version> <gwt-material.version>2.4.0</gwt-material.version>

View File

@ -3,44 +3,107 @@ package org.gcube.portlets.widgets.ckancontentmoderator.client;
import java.util.List; import java.util.List;
import org.gcube.datacatalogue.utillibrary.shared.ItemStatus; import org.gcube.datacatalogue.utillibrary.shared.ItemStatus;
import org.gcube.portlets.widgets.ckancontentmoderator.client.ui.ContentModeratorSystemPanel;
import org.gcube.portlets.widgets.ckancontentmoderator.client.ui.table.ItemsTable; 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.ItemsTable.DISPLAY_FIELD;
import org.gcube.portlets.widgets.ckancontentmoderator.shared.CatalogueDataset; import org.gcube.portlets.widgets.ckancontentmoderator.shared.CatalogueDataset;
import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.ScrollPanel;
import com.google.gwt.view.client.ListDataProvider;
/** /**
* Entry point classes define <code>onModuleLoad()</code>. * The Class CkanContentModeratorWidget.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Jun 15, 2021
*/ */
public class CkanContentModeratorWidget { public class CkanContentModeratorWidget {
public final CkanContentModeratorServiceAsync contentModeratorService = GWT.create(CkanContentModeratorService.class); public final CkanContentModeratorServiceAsync contentModeratorService = GWT
.create(CkanContentModeratorService.class);
ItemsTable<CatalogueDataset> itemsTable; private ItemsTable<CatalogueDataset> itemsTable;
private ContentModeratorSystemPanel cmsPanel = new ContentModeratorSystemPanel();
private Boolean isContentModeratorEnabled = null;
CkanContentModeratorWidget(DISPLAY_FIELD[] displayFields, DISPLAY_FIELD sortByField){ /**
* Instantiates a new ckan content moderator widget.
*
* @param displayFields the display fields
* @param sortByField the sort by field
*/
public CkanContentModeratorWidget(DISPLAY_FIELD[] displayFields, DISPLAY_FIELD sortByField) {
itemsTable = new ItemsTable<CatalogueDataset>(null, displayFields, sortByField); itemsTable = new ItemsTable<CatalogueDataset>(null, displayFields, sortByField);
itemsTable.initTable(null, null, new ListDataProvider<CatalogueDataset>());
cmsPanel.add(itemsTable.getCellTable());
} }
/**
* Load items for status.
*
* @param status the status
* @throws Exception the exception
*/
public void loadItemsForStatus(ItemStatus status) throws Exception {
public void loadItemsForStatus(ItemStatus status){ if (isContentModeratorEnabled == null)
throw new Exception("Please, first check if the content moderator is enabled in this context");
if (!isContentModeratorEnabled)
throw new Exception("Content Moderator is not enabled in this context");
contentModeratorService.getListItemsForStatus(status, ContentModeratorWidgetConstants.ITEMS_PER_PAGE, ContentModeratorWidgetConstants.ITEM_START_INDEX, new AsyncCallback<List<CatalogueDataset>>() { contentModeratorService.getListItemsForStatus(status, ContentModeratorWidgetConstants.ITEMS_PER_PAGE,
ContentModeratorWidgetConstants.ITEM_START_INDEX, new AsyncCallback<List<CatalogueDataset>>() {
@Override
public void onSuccess(List<CatalogueDataset> result) {
itemsTable.updateItems(result, true);
}
@Override
public void onFailure(Throwable caught) {
// TODO Auto-generated method stub
}
});
}
/**
* Checks if is content moderator enabled.
*
* @param onCompletation the on completation
*/
public void isContentModeratorEnabled(final Command onCompletation) {
contentModeratorService.isContentModeratorEnabled(new AsyncCallback<Boolean>() {
@Override @Override
public void onSuccess(List<CatalogueDataset> result) { public void onFailure(Throwable caught) {
itemsTable.updateItems(result, true); onCompletation.execute();
} }
@Override @Override
public void onFailure(Throwable caught) { public void onSuccess(Boolean result) {
// TODO Auto-generated method stub isContentModeratorEnabled = result;
onCompletation.execute();
} }
}); });
} }
public ItemsTable<CatalogueDataset> getItemsTable() {
return itemsTable;
}
public ScrollPanel getPanel(){
return cmsPanel;
}
} }

View File

@ -0,0 +1,20 @@
package org.gcube.portlets.widgets.ckancontentmoderator.client.ui;
import com.google.gwt.user.client.ui.ScrollPanel;
/**
* The Class ContentModeratorSystemPanel.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Jun 15, 2021
*/
public class ContentModeratorSystemPanel extends ScrollPanel {
public ContentModeratorSystemPanel(){
}
}

View File

@ -33,7 +33,7 @@ import com.google.gwt.user.client.ui.Label;
import com.google.gwt.view.client.AbstractDataProvider; import com.google.gwt.view.client.AbstractDataProvider;
import com.google.gwt.view.client.ListDataProvider; import com.google.gwt.view.client.ListDataProvider;
// TODO: Auto-generated Javadoc
/** /**
* The Class ItemsTable. * The Class ItemsTable.
* *

View File

@ -26,8 +26,9 @@ public class CkanContentModeratorServiceImpl extends RemoteServiceServlet implem
@Override @Override
public boolean isContentModeratorEnabled() { public boolean isContentModeratorEnabled() {
// TODO Auto-generated method stub LOG.info("called isContentModeratorEnabled");
return false; LOG.warn("isContentModeratorEnabled METHOD MUST BE IMPLEMENTED!!!");
return true;
} }
@Override @Override