task_21363 #1
|
@ -1,11 +1,15 @@
|
|||
package org.gcube.portlets.widgets.ckancontentmoderator.client;
|
||||
|
||||
import org.gcube.datacatalogue.utillibrary.shared.ItemStatus;
|
||||
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.ClickItemEvent;
|
||||
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.ClickItemEventHandler;
|
||||
import org.gcube.portlets.widgets.ckancontentmoderator.client.ui.ContentModeratorPaginatedView;
|
||||
import org.gcube.portlets.widgets.ckancontentmoderator.client.ui.ContentModeratorSystemBaseView;
|
||||
import org.gcube.portlets.widgets.ckancontentmoderator.client.ui.table.ItemsTable.DISPLAY_FIELD;
|
||||
import org.gcube.portlets.widgets.ckancontentmoderator.shared.CatalogueDataset;
|
||||
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.event.shared.HandlerManager;
|
||||
import com.google.gwt.user.client.Command;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.google.gwt.user.client.ui.Composite;
|
||||
|
@ -26,6 +30,7 @@ public class CkanContentModeratorWidget {
|
|||
private ContentModeratorSystemBaseView cmsPanel = new ContentModeratorSystemBaseView();
|
||||
private Boolean isContentModeratorEnabled = null;
|
||||
private ContentModeratorPaginatedView paginatedView;
|
||||
public final static HandlerManager eventBus = new HandlerManager(null);
|
||||
|
||||
/**
|
||||
* Instantiates a new ckan content moderator widget.
|
||||
|
@ -38,10 +43,28 @@ public class CkanContentModeratorWidget {
|
|||
// itemsTable.initTable(null, null, new ListDataProvider<CatalogueDataset>());
|
||||
// cmsPanel.add(itemsTable.getCellTable());
|
||||
|
||||
paginatedView = new ContentModeratorPaginatedView(status, displayFields, sortByField);
|
||||
paginatedView = new ContentModeratorPaginatedView(eventBus, status, displayFields, sortByField);
|
||||
//cmsPanel.addToTop(new LoadingPanel(new HTML("Loading...")));
|
||||
cmsPanel.addToCenter(paginatedView.getCellPanel());
|
||||
cmsPanel.addToBottom(paginatedView.getPagerPanel());
|
||||
bindEvents();
|
||||
}
|
||||
|
||||
private void bindEvents() {
|
||||
|
||||
|
||||
eventBus.addHandler(ClickItemEvent.TYPE, new ClickItemEventHandler() {
|
||||
|
||||
@Override
|
||||
public <T> void onClick(ClickItemEvent<T> clickItemEvent) {
|
||||
|
||||
if(clickItemEvent.getItem() instanceof CatalogueDataset) {
|
||||
CatalogueDataset clickedDataset = (CatalogueDataset) clickItemEvent.getItem();
|
||||
//Window.open(clickedDataset.getUrl(), null, "_blank");
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// /**
|
||||
|
|
|
@ -13,6 +13,7 @@ import org.gcube.portlets.widgets.ckancontentmoderator.shared.CatalogueDataset;
|
|||
import org.gcube.portlets.widgets.ckancontentmoderator.shared.SearchedData;
|
||||
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.event.shared.HandlerManager;
|
||||
import com.google.gwt.user.cellview.client.SimplePager;
|
||||
import com.google.gwt.user.cellview.client.SimplePager.TextLocation;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
|
@ -27,37 +28,46 @@ import com.google.gwt.view.client.Range;
|
|||
import com.google.gwt.view.client.SelectionModel;
|
||||
import com.google.gwt.view.client.SingleSelectionModel;
|
||||
|
||||
/**
|
||||
* The Class ContentModeratorPaginatedView.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Jun 16, 2021
|
||||
*/
|
||||
public class ContentModeratorPaginatedView {
|
||||
|
||||
private static final int ITEM_START_INDEX = ContentModeratorWidgetConstants.ITEM_START_INDEX;
|
||||
|
||||
private static final int ITEMS_PER_PAGE = ContentModeratorWidgetConstants.ITEMS_PER_PAGE;
|
||||
|
||||
private VerticalPanel vPanel = new VerticalPanel();
|
||||
|
||||
private FlowPanel pagerPanel = new FlowPanel();
|
||||
|
||||
private Boolean newLoading = false;
|
||||
private ItemsTable<CatalogueDataset> itemsTable;
|
||||
private MyCustomDataProvider<CatalogueDataset> dataProvider = new MyCustomDataProvider<CatalogueDataset>();
|
||||
protected Widget orginalLoadingIndicator = null;
|
||||
private LoadingPanel loadingPanel = new LoadingPanel(new HTML("Loading data..."));
|
||||
// private int serverStartIndex = 0;
|
||||
|
||||
private ItemStatus itemStatus;
|
||||
|
||||
private int serverStartIndex;
|
||||
|
||||
public ContentModeratorPaginatedView(ItemStatus theStatus, DISPLAY_FIELD[] displayFields,
|
||||
/**
|
||||
* Instantiates a new content moderator paginated view.
|
||||
*
|
||||
* @param eventbus
|
||||
*
|
||||
* @param theStatus the the status
|
||||
* @param displayFields the display fields
|
||||
* @param sortByField the sort by field
|
||||
*/
|
||||
public ContentModeratorPaginatedView(HandlerManager eventbus, ItemStatus theStatus, DISPLAY_FIELD[] displayFields,
|
||||
DISPLAY_FIELD sortByField) {
|
||||
this.itemStatus = theStatus;
|
||||
this.newLoading = true;
|
||||
itemsTable = new ItemsTable<CatalogueDataset>(null, displayFields, sortByField);
|
||||
itemsTable = new ItemsTable<CatalogueDataset>(eventbus, displayFields, sortByField);
|
||||
itemsTable.initTable(null, null, dataProvider);
|
||||
|
||||
orginalLoadingIndicator = itemsTable.getCellTable().getLoadingIndicator();
|
||||
initPagination(ITEMS_PER_PAGE);
|
||||
loadNewPage(ITEM_START_INDEX, ITEMS_PER_PAGE,false);
|
||||
loadNewPage(ITEM_START_INDEX, ITEMS_PER_PAGE, false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -107,6 +117,8 @@ public class ContentModeratorPaginatedView {
|
|||
|
||||
/**
|
||||
* Set the panel in loading mode.
|
||||
*
|
||||
* @param show the show
|
||||
*/
|
||||
protected void showLoading(boolean show) {
|
||||
loadingPanel.setVisible(show);
|
||||
|
@ -121,16 +133,17 @@ public class ContentModeratorPaginatedView {
|
|||
return pagerPanel;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.gcube.portlets.widgets.wsexplorer.client.view.WorkspaceExplorer#
|
||||
* loadFolder(org.gcube.portlets.widgets.wsexplorer.shared.Item, boolean, int,
|
||||
* int, boolean)
|
||||
/**
|
||||
* Load new page.
|
||||
*
|
||||
* @param startIdx the start idx
|
||||
* @param limit the limit
|
||||
* @param resetStore the reset store
|
||||
*/
|
||||
public void loadNewPage(final int startIdx, final int limit, final boolean resetStore) {
|
||||
newLoading = resetStore;
|
||||
GWT.log("loading data with parameters [startIdx: "+startIdx+", limit: " + limit + ", resetStore:" + resetStore + "]");
|
||||
GWT.log("loading data with parameters [startIdx: " + startIdx + ", limit: " + limit + ", resetStore:"
|
||||
+ resetStore + "]");
|
||||
// showLoading(true);
|
||||
|
||||
int newStartIndex = startIdx;
|
||||
|
@ -141,13 +154,84 @@ public class ContentModeratorPaginatedView {
|
|||
serverStartIndex = 0;
|
||||
GWT.log("Store reset performed start index is: " + newStartIndex);
|
||||
getAsycnDataProvider().updateRowCount(ITEMS_PER_PAGE, false);
|
||||
//newLoading = false;
|
||||
// newLoading = false;
|
||||
}
|
||||
|
||||
loadItemsForStatus(itemStatus, newStartIndex, limit, serverStartIndex);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the new page result.
|
||||
*
|
||||
* @param result the new new page result
|
||||
*/
|
||||
private void setNewPageResult(SearchedData result) {
|
||||
|
||||
serverStartIndex = result.getServerEndIndex();
|
||||
|
||||
if (newLoading) {
|
||||
getCellTable().setVisibleRangeAndClearData(new Range(result.getClientStartIndex(), ITEMS_PER_PAGE), false);
|
||||
}
|
||||
|
||||
SelectionModel<? super CatalogueDataset> sm = getCellTable().getSelectionModel();
|
||||
|
||||
if (sm instanceof SingleSelectionModel) {
|
||||
SingleSelectionModel<CatalogueDataset> ssm = (SingleSelectionModel<CatalogueDataset>) sm;
|
||||
ssm.clear();
|
||||
}
|
||||
|
||||
getAsycnDataProvider().updateRowCount((int) result.getTotalItems(), true);
|
||||
getAsycnDataProvider().updateRowData(result.getClientStartIndex(), result.getData());
|
||||
|
||||
if (result.getData().size() == 0) {
|
||||
getCellTable().setLoadingIndicator(new Label("No data"));
|
||||
} else {
|
||||
getCellTable().setLoadingIndicator(orginalLoadingIndicator);
|
||||
}
|
||||
|
||||
GWT.log("Updating row data startIndex: " + result.getClientStartIndex() + " children size: "
|
||||
+ result.getData().size());
|
||||
GWT.log("getAsycnDataProvider().getDataDisplays().size(): " + getCellTable().getRowCount());
|
||||
|
||||
if (result.isServerSearchFinished()) {
|
||||
GWT.log("Search finished!!!");
|
||||
getAsycnDataProvider().updateRowCount(getCellTable().getRowCount(), true);
|
||||
}
|
||||
newLoading = false;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Load items for status.
|
||||
*
|
||||
* @param status the status
|
||||
* @param offset the offset
|
||||
* @param limit the limit
|
||||
* @param serverIndex the server index
|
||||
*/
|
||||
private void loadItemsForStatus(ItemStatus status, int offset, int limit, int serverIndex) {
|
||||
showLoading(true);
|
||||
|
||||
GWT.log("calling getDataForStatus with parameters [startIndex: " + offset + ", limit: " + limit
|
||||
+ ", serverIndex:" + serverIndex + "]");
|
||||
CkanContentModeratorWidget.contentModeratorService.getDataForStatus(status, offset, limit, serverIndex,
|
||||
new AsyncCallback<SearchedData>() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(SearchedData result) {
|
||||
showLoading(false);
|
||||
setNewPageResult(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
showLoading(false);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* A custom {@link AsyncDataProvider}.
|
||||
*
|
||||
|
@ -176,95 +260,12 @@ public class ContentModeratorPaginatedView {
|
|||
GWT.log("OnLoading is true.. returning");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
GWT.log("Range changed: " + start + " " + length + " visible count: " + display.getVisibleItemCount());
|
||||
// GWT.log("Server start index: " + serverStartIndex);
|
||||
// int newStart = start < serverStartIndex? serverStartIndex : start;
|
||||
// GWT.log("newStart index: "+newStart);
|
||||
loadNewPage(start, length, false);
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
GWT.log("Range changed: " + start + " " + length + " visible count: " + display.getVisibleItemCount());
|
||||
loadNewPage(start, length, false);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the new page result.
|
||||
*
|
||||
* @param result the new new page result
|
||||
*/
|
||||
private void setNewPageResult(SearchedData result){
|
||||
|
||||
serverStartIndex = result.getServerEndIndex();
|
||||
|
||||
if(newLoading){
|
||||
getCellTable().setVisibleRangeAndClearData(new Range(result.getClientStartIndex(), ITEMS_PER_PAGE), false);
|
||||
}
|
||||
|
||||
SelectionModel<? super CatalogueDataset> sm = getCellTable().getSelectionModel();
|
||||
|
||||
if(sm instanceof SingleSelectionModel){
|
||||
SingleSelectionModel<CatalogueDataset> ssm = (SingleSelectionModel<CatalogueDataset>) sm;
|
||||
ssm.clear();
|
||||
}
|
||||
|
||||
getAsycnDataProvider().updateRowCount((int) result.getTotalItems(), true);
|
||||
getAsycnDataProvider().updateRowData(result.getClientStartIndex(), result.getData());
|
||||
|
||||
if(result.getData().size()==0){
|
||||
getCellTable().setLoadingIndicator(new Label("No data"));
|
||||
}else{
|
||||
getCellTable().setLoadingIndicator(orginalLoadingIndicator);
|
||||
}
|
||||
|
||||
//getCellTable().setVisibleRangeAndClearData(new Range(startIdx, result.getChildren()).), false);
|
||||
//getAsycnDataProvider().getDataDisplays().
|
||||
GWT.log("Updating row data startIndex: "+result.getClientStartIndex() + " children size: "+result.getData().size());
|
||||
GWT.log("getAsycnDataProvider().getDataDisplays().size(): "+getCellTable().getRowCount());
|
||||
|
||||
if(result.isServerSearchFinished()){
|
||||
GWT.log("Search finished!!!");
|
||||
getAsycnDataProvider().updateRowCount(getCellTable().getRowCount(), true);
|
||||
}
|
||||
//getCellTable().setPageSize(result.getChildren().size()+1);
|
||||
//getCellTable().setVisibleRange(startIdx, result.getChildren().size());
|
||||
//getCellTable().redraw();
|
||||
//GWT.log("cellTable size: "+getCellTable().getRowCount());
|
||||
newLoading = false;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Load items for status.
|
||||
*
|
||||
* @param status the status
|
||||
* @param offset
|
||||
* @param limit
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
private void loadItemsForStatus(ItemStatus status, int offset, int limit, int serverIndex) {
|
||||
showLoading(true);
|
||||
|
||||
//TODO implement new method
|
||||
GWT.log("calling getDataForStatus with parameters [startIndex: "+offset+", limit: " + limit + ", serverIndex:" + serverIndex + "]");
|
||||
CkanContentModeratorWidget.contentModeratorService.getDataForStatus(status, offset, limit, serverIndex,
|
||||
new AsyncCallback<SearchedData>() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(SearchedData result) {
|
||||
showLoading(false);
|
||||
setNewPageResult(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
showLoading(false);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -24,7 +24,10 @@ public class CatalogueBeansConverter {
|
|||
|
||||
myDataset.setAuthor(t.getAuthor());
|
||||
myDataset.setAuthorEmail(t.getAuthorEmail());
|
||||
myDataset.setCkanDatasetURL(null);
|
||||
|
||||
//is it needed??
|
||||
myDataset.setD4ScienceItemURL(null);
|
||||
|
||||
myDataset.setId(t.getId());
|
||||
myDataset.setLicenseId(t.getLicenseId());
|
||||
myDataset.setMaintainer(t.getMaintainer());
|
||||
|
@ -34,6 +37,7 @@ public class CatalogueBeansConverter {
|
|||
myDataset.setOwnerOrg(t.getOwnerOrg());
|
||||
myDataset.setTitle(t.getTitle());
|
||||
myDataset.setType(t.getType());
|
||||
//here is always null
|
||||
myDataset.setUrl(t.getUrl());
|
||||
myDataset.setCreated(t.getMetadataCreated().getTime());
|
||||
return myDataset;
|
||||
|
|
|
@ -7,12 +7,13 @@ import org.gcube.datacatalogue.utillibrary.server.cms.CatalogueContentModeratorS
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
||||
/**
|
||||
* A factory for getting CatalogueContentModeratorSystem objects.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Jun 14, 2021
|
||||
* Jun 14, 2021
|
||||
*/
|
||||
public class CatalogueCMSFactory {
|
||||
|
||||
|
@ -26,21 +27,21 @@ public class CatalogueCMSFactory {
|
|||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Jun 14, 2021
|
||||
* Jun 16, 2021
|
||||
*/
|
||||
private class CacheBean {
|
||||
CatalogueContentModeratorSystem cmsInstance;
|
||||
DataCatalogueImpl dataCatalogueImpl;
|
||||
long ttl;
|
||||
|
||||
/**
|
||||
* Instantiates a new cache bean.
|
||||
*
|
||||
* @param ttl the ttl
|
||||
* @param cmsInstance the cms instance
|
||||
* @param ttl the ttl
|
||||
* @param dataCatalogueImpl the data catalogue impl
|
||||
*/
|
||||
public CacheBean(long ttl, CatalogueContentModeratorSystem cmsInstance) {
|
||||
public CacheBean(long ttl, DataCatalogueImpl dataCatalogueImpl) {
|
||||
this.ttl = ttl;
|
||||
this.cmsInstance = cmsInstance;
|
||||
this.dataCatalogueImpl = dataCatalogueImpl;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -73,17 +74,29 @@ public class CatalogueCMSFactory {
|
|||
*/
|
||||
public CatalogueContentModeratorSystem getCMSPerScope(String scope) throws Exception {
|
||||
|
||||
DataCatalogueImpl dataCatalogueImpl = getCatalogueImplPerScope(scope);
|
||||
return dataCatalogueImpl.getCatalogueContentModerator();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the catalogue impl per scope.
|
||||
*
|
||||
* @param scope the scope
|
||||
* @return the catalogue impl per scope
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public DataCatalogueImpl getCatalogueImplPerScope(String scope) throws Exception {
|
||||
|
||||
if (scope == null || scope.isEmpty())
|
||||
throw new IllegalArgumentException("Invalid scope given!");
|
||||
|
||||
if (cache.containsKey(scope) && !expired(cache.get(scope))) {
|
||||
return cache.get(scope).cmsInstance;
|
||||
return cache.get(scope).dataCatalogueImpl;
|
||||
} else {
|
||||
logger.info("Creating "+CatalogueCMSFactory.class.getSimpleName()+" for scope " + scope);
|
||||
logger.info("Creating " + CatalogueCMSFactory.class.getSimpleName() + " for scope " + scope);
|
||||
DataCatalogueImpl dci = new DataCatalogueImpl(scope);
|
||||
CatalogueContentModeratorSystem cmsInstance = dci.getCatalogueContentModerator();
|
||||
cache.put(scope, new CacheBean(System.currentTimeMillis(), cmsInstance));
|
||||
return cmsInstance;
|
||||
cache.put(scope, new CacheBean(System.currentTimeMillis(), dci));
|
||||
return dci;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ import java.util.List;
|
|||
|
||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.datacatalogue.utillibrary.server.DataCatalogueImpl;
|
||||
import org.gcube.datacatalogue.utillibrary.server.cms.CatalogueContentModeratorSystem;
|
||||
import org.gcube.datacatalogue.utillibrary.shared.ItemStatus;
|
||||
import org.gcube.datacatalogue.utillibrary.shared.jackan.model.CkanDataset;
|
||||
|
@ -59,7 +60,8 @@ public class CkanContentModeratorServiceImpl extends RemoteServiceServlet implem
|
|||
String token = WsUtil.getCurrentToken(scope, user.getUsername());
|
||||
ScopeProvider.instance.set(scope);
|
||||
SecurityTokenProvider.instance.set(token);
|
||||
CatalogueContentModeratorSystem cmsInstance = CatalogueCMSFactory.getFactory().getCMSPerScope(scope);
|
||||
DataCatalogueImpl catalogueImpl = CatalogueCMSFactory.getFactory().getCatalogueImplPerScope(scope);
|
||||
CatalogueContentModeratorSystem cmsInstance = catalogueImpl.getCatalogueContentModerator();
|
||||
List<CkanDataset> datasets = cmsInstance.getListItemsForStatus(theStatus, limit, offset);
|
||||
if (datasets != null) {
|
||||
int size = datasets.size();
|
||||
|
@ -67,6 +69,8 @@ public class CkanContentModeratorServiceImpl extends RemoteServiceServlet implem
|
|||
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);
|
||||
LOG.debug("converted dataset is: " + ds);
|
||||
datasetList.add(ds);
|
||||
}
|
||||
|
@ -101,8 +105,10 @@ public class CkanContentModeratorServiceImpl extends RemoteServiceServlet implem
|
|||
}
|
||||
|
||||
@Override
|
||||
public SearchedData getDataForStatus(ItemStatus status, int offset, int limit, int serverStartIndex) throws Exception {
|
||||
LOG.info("called getDataForStatus [status: "+status+", offset: "+offset+", limit: "+limit+", serverIndex: "+serverStartIndex);
|
||||
public SearchedData getDataForStatus(ItemStatus status, int offset, int limit, int serverStartIndex)
|
||||
throws Exception {
|
||||
LOG.info("called getDataForStatus [status: " + status + ", offset: " + offset + ", limit: " + limit
|
||||
+ ", serverIndex: " + serverStartIndex);
|
||||
|
||||
try {
|
||||
String scope = WsUtil.getCurrentScope(this.getThreadLocalRequest());
|
||||
|
@ -110,64 +116,61 @@ public class CkanContentModeratorServiceImpl extends RemoteServiceServlet implem
|
|||
String token = WsUtil.getCurrentToken(scope, user.getUsername());
|
||||
ScopeProvider.instance.set(scope);
|
||||
SecurityTokenProvider.instance.set(token);
|
||||
//int searchStartIndex = limit < serverStartIndex? serverStartIndex : offset;
|
||||
|
||||
// int searchStartIndex = limit < serverStartIndex? serverStartIndex : offset;
|
||||
|
||||
int searchStartIndex = offset;
|
||||
|
||||
CatalogueContentModeratorSystem cmsInstance = CatalogueCMSFactory.getFactory().getCMSPerScope(scope);
|
||||
SearchedData searchedData = new SearchedData(offset, limit, searchStartIndex, false);
|
||||
long totalItemsForStatus = cmsInstance.countListItemsForStatus(status);
|
||||
LOG.info("totalItemsForStatus "+status+" are : "+totalItemsForStatus);
|
||||
LOG.info("totalItemsForStatus " + status + " are : " + totalItemsForStatus);
|
||||
List<CatalogueDataset> listDataset = new ArrayList<CatalogueDataset>();
|
||||
try {
|
||||
LOG.debug("getListItemsForStatus with searchStartIndex: "+searchStartIndex+", limit: "+limit);
|
||||
LOG.debug("getListItemsForStatus with searchStartIndex: " + searchStartIndex + ", limit: " + limit);
|
||||
listDataset = getListItemsForStatus(status, searchStartIndex, limit);
|
||||
}catch (Exception e) {
|
||||
LOG.error("Error occurred on gettin items for status: "+status,e);
|
||||
} catch (Exception e) {
|
||||
LOG.error("Error occurred on gettin items for status: " + status, e);
|
||||
}
|
||||
|
||||
|
||||
int listDatasetSize = listDataset.size();
|
||||
LOG.debug("Returned "+listDatasetSize+" with above parameters");
|
||||
LOG.debug("Returned " + listDatasetSize + " with above parameters");
|
||||
searchedData.setData(listDataset);
|
||||
searchedData.setTotalItems(totalItemsForStatus);
|
||||
|
||||
if(listDatasetSize == limit || listDatasetSize==0){
|
||||
LOG.debug("Page completed returning "+listDatasetSize+ " items");
|
||||
int newOffset = searchStartIndex+offset;
|
||||
searchedData.setServerSearchFinished(newOffset>totalItemsForStatus || listDatasetSize == 0);
|
||||
LOG.debug("is Search finished: "+searchedData.isServerSearchFinished());
|
||||
if (listDatasetSize == limit || listDatasetSize == 0) {
|
||||
LOG.debug("Page completed returning " + listDatasetSize + " items");
|
||||
int newOffset = searchStartIndex + offset;
|
||||
searchedData.setServerSearchFinished(newOffset > totalItemsForStatus || listDatasetSize == 0);
|
||||
LOG.debug("is Search finished: " + searchedData.isServerSearchFinished());
|
||||
return searchedData;
|
||||
}
|
||||
|
||||
/*int offsetStartIndex = searchStartIndex;
|
||||
boolean pageOffsetOut = false;
|
||||
while(listDatasetSize < offset && !searchedData.isServerSearchFinished() && !pageOffsetOut){ //&& SEARCH NOT ULTIMATED
|
||||
LOG.debug("MyLg new WHILE Items count: "+totalItemsForStatus+" is less than limit..");
|
||||
|
||||
int newOffsetStartIndex = offsetStartIndex+limit+1;
|
||||
LOG.debug("MyLg NewStartIndex is startIndex+limit: "+newOffsetStartIndex);
|
||||
|
||||
//THERE ARE OTHER CHILDREN OVER NEW START INDEX
|
||||
if(newOffsetStartIndex < totalItemsForStatus){
|
||||
//newLimit = limit - childrenToReturn.size();
|
||||
LOG.debug("MyLg getting items with index start: "+newOffsetStartIndex + ", limit: "+offset);
|
||||
|
||||
int diff = (int) (offset - totalItemsForStatus); //How items are remaining
|
||||
//int offset = 0;
|
||||
LOG.debug("MyLg new search start: "+newOffsetStartIndex + ", diff: "+diff+ ", retrieved: "+listDatasetSize);
|
||||
if(diff >= listDatasetSize){
|
||||
}else{
|
||||
pageOffsetOut = true;
|
||||
}
|
||||
offsetStartIndex = newOffsetStartIndex;
|
||||
LOG.debug("MyLg items count is: "+totalItemsForStatus + " serverEndIndex: "+offsetStartIndex);
|
||||
searchedData.setServerEndIndex(offsetStartIndex);
|
||||
}else{
|
||||
LOG.debug("New start index (oldStartIndex+limit) is grather than total items count, search is finished");
|
||||
searchedData.setServerSearchFinished(true);
|
||||
}
|
||||
}*/
|
||||
LOG.debug("Returning: "+searchedData);
|
||||
/*
|
||||
* int offsetStartIndex = searchStartIndex; boolean pageOffsetOut = false;
|
||||
* while(listDatasetSize < offset && !searchedData.isServerSearchFinished() &&
|
||||
* !pageOffsetOut){ //&& SEARCH NOT ULTIMATED
|
||||
* LOG.debug("MyLg new WHILE Items count: "
|
||||
* +totalItemsForStatus+" is less than limit..");
|
||||
*
|
||||
* int newOffsetStartIndex = offsetStartIndex+limit+1;
|
||||
* LOG.debug("MyLg NewStartIndex is startIndex+limit: "+newOffsetStartIndex);
|
||||
*
|
||||
* //THERE ARE OTHER CHILDREN OVER NEW START INDEX if(newOffsetStartIndex <
|
||||
* totalItemsForStatus){ //newLimit = limit - childrenToReturn.size();
|
||||
* LOG.debug("MyLg getting items with index start: "+newOffsetStartIndex +
|
||||
* ", limit: "+offset);
|
||||
*
|
||||
* int diff = (int) (offset - totalItemsForStatus); //How items are remaining
|
||||
* //int offset = 0; LOG.debug("MyLg new search start: "+newOffsetStartIndex +
|
||||
* ", diff: "+diff+ ", retrieved: "+listDatasetSize); if(diff >=
|
||||
* listDatasetSize){ }else{ pageOffsetOut = true; } offsetStartIndex =
|
||||
* newOffsetStartIndex; LOG.debug("MyLg items count is: "+totalItemsForStatus +
|
||||
* " serverEndIndex: "+offsetStartIndex);
|
||||
* searchedData.setServerEndIndex(offsetStartIndex); }else{ LOG.
|
||||
* debug("New start index (oldStartIndex+limit) is grather than total items count, search is finished"
|
||||
* ); searchedData.setServerSearchFinished(true); } }
|
||||
*/
|
||||
LOG.debug("Returning: " + searchedData);
|
||||
return searchedData;
|
||||
|
||||
} catch (Exception e) {
|
||||
|
|
|
@ -6,7 +6,7 @@ import org.gcube.datacatalogue.utillibrary.shared.ItemStatus;
|
|||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
|
||||
/**
|
||||
* The Class CatalogueDataset.
|
||||
*
|
||||
|
@ -34,7 +34,7 @@ public class CatalogueDataset implements Serializable, IsSerializable {
|
|||
private String type;
|
||||
private String url;
|
||||
private String version;
|
||||
private String ckanDatasetURL;
|
||||
private String d4scienceItemURL;
|
||||
private long created;
|
||||
|
||||
/**
|
||||
|
@ -99,8 +99,12 @@ public class CatalogueDataset implements Serializable, IsSerializable {
|
|||
return version;
|
||||
}
|
||||
|
||||
public String getCkanDatasetURL() {
|
||||
return ckanDatasetURL;
|
||||
public String getD4scienceItemURL() {
|
||||
return d4scienceItemURL;
|
||||
}
|
||||
|
||||
public long getCreated() {
|
||||
return created;
|
||||
}
|
||||
|
||||
public void setAuthor(String author) {
|
||||
|
@ -159,16 +163,12 @@ public class CatalogueDataset implements Serializable, IsSerializable {
|
|||
this.version = version;
|
||||
}
|
||||
|
||||
public void setCkanDatasetURL(String ckanDatasetURL) {
|
||||
this.ckanDatasetURL = ckanDatasetURL;
|
||||
public void setD4ScienceItemURL(String d4scienceItemURL) {
|
||||
this.d4scienceItemURL = d4scienceItemURL;
|
||||
}
|
||||
|
||||
public void setCreated(long creationTime) {
|
||||
this.created = creationTime;
|
||||
}
|
||||
|
||||
public long getCreated() {
|
||||
return created;
|
||||
|
||||
public void setCreated(long created) {
|
||||
this.created = created;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -202,8 +202,8 @@ public class CatalogueDataset implements Serializable, IsSerializable {
|
|||
builder.append(url);
|
||||
builder.append(", version=");
|
||||
builder.append(version);
|
||||
builder.append(", ckanDatasetURL=");
|
||||
builder.append(ckanDatasetURL);
|
||||
builder.append(", d4scienceItemURL=");
|
||||
builder.append(d4scienceItemURL);
|
||||
builder.append(", created=");
|
||||
builder.append(created);
|
||||
builder.append("]");
|
||||
|
|
Loading…
Reference in New Issue