fixed business logic to get item paginated and filtered by indexing (start, limit)
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/widgets/workspace-explorer@151048 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
4a45f4bf85
commit
19b7ef4383
|
@ -9,6 +9,7 @@ import org.gcube.portlets.widgets.wsexplorer.shared.Item;
|
|||
import org.gcube.portlets.widgets.wsexplorer.shared.ItemCategory;
|
||||
import org.gcube.portlets.widgets.wsexplorer.shared.ItemInterface;
|
||||
import org.gcube.portlets.widgets.wsexplorer.shared.ItemType;
|
||||
import org.gcube.portlets.widgets.wsexplorer.shared.SearchedFolder;
|
||||
import org.gcube.portlets.widgets.wsexplorer.shared.WorkspaceNavigatorServiceException;
|
||||
|
||||
import com.google.gwt.user.client.rpc.RemoteService;
|
||||
|
@ -197,11 +198,34 @@ public interface WorkspaceExplorerService extends RemoteService {
|
|||
*/
|
||||
Map<String, String> getGcubePropertiesForWorspaceId(String id) throws Exception;
|
||||
|
||||
Item getFolder(
|
||||
|
||||
|
||||
/**
|
||||
* Gets the folder.
|
||||
*
|
||||
* @param item the item
|
||||
* @param showableTypesParam the showable types param
|
||||
* @param purgeEmpyFolders the purge empy folders
|
||||
* @param filterCriteria the filter criteria
|
||||
* @param loadGcubeProperties the load gcube properties
|
||||
* @param startIndex the start index
|
||||
* @param limit the limit
|
||||
* @param serverStartIndex the server start index
|
||||
* @return the folder
|
||||
* @throws WorkspaceNavigatorServiceException the workspace navigator service exception
|
||||
*/
|
||||
SearchedFolder getFolder(
|
||||
Item item, List<ItemType> showableTypesParam, boolean purgeEmpyFolders,
|
||||
FilterCriteria filterCriteria, boolean loadGcubeProperties,
|
||||
int startIndex, int limit) throws WorkspaceNavigatorServiceException;
|
||||
int startIndex, int limit, int serverStartIndex) throws WorkspaceNavigatorServiceException;
|
||||
|
||||
/**
|
||||
* Gets the folder children count.
|
||||
*
|
||||
* @param item the item
|
||||
* @return the folder children count
|
||||
* @throws WorkspaceNavigatorServiceException the workspace navigator service exception
|
||||
*/
|
||||
int getFolderChildrenCount(Item item) throws WorkspaceNavigatorServiceException;
|
||||
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ import org.gcube.portlets.widgets.wsexplorer.shared.Item;
|
|||
import org.gcube.portlets.widgets.wsexplorer.shared.ItemCategory;
|
||||
import org.gcube.portlets.widgets.wsexplorer.shared.ItemInterface;
|
||||
import org.gcube.portlets.widgets.wsexplorer.shared.ItemType;
|
||||
import org.gcube.portlets.widgets.wsexplorer.shared.SearchedFolder;
|
||||
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
|
||||
|
@ -199,6 +200,7 @@ public interface WorkspaceExplorerServiceAsync {
|
|||
void getGcubePropertiesForWorspaceId(String id, AsyncCallback<Map<String, String>> callback);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Gets the folder.
|
||||
*
|
||||
|
@ -209,16 +211,21 @@ public interface WorkspaceExplorerServiceAsync {
|
|||
* @param loadGcubeProperties the load gcube properties
|
||||
* @param startIndex the start index
|
||||
* @param limit the limit
|
||||
* @param serverStartIndex the server start index
|
||||
* @param asyncCallback the async callback
|
||||
* @return the folder
|
||||
*/
|
||||
public void getFolder(
|
||||
void getFolder(
|
||||
Item item, List<ItemType> showableTypesParam, boolean purgeEmpyFolders,
|
||||
FilterCriteria filterCriteria, boolean loadGcubeProperties,
|
||||
int startIndex, int limit, AsyncCallback<Item> asyncCallback);
|
||||
int startIndex, int limit, int serverStartIndex, AsyncCallback<SearchedFolder> asyncCallback);
|
||||
|
||||
/**
|
||||
* @param item
|
||||
* Gets the folder children count.
|
||||
*
|
||||
* @param item the item
|
||||
* @param asyncCallback the async callback
|
||||
* @return the folder children count
|
||||
*/
|
||||
public void getFolderChildrenCount(Item item, AsyncCallback<Integer> asyncCallback);
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ import org.gcube.portlets.widgets.wsexplorer.client.view.grid.SortedCellTable;
|
|||
import org.gcube.portlets.widgets.wsexplorer.shared.FilterCriteria;
|
||||
import org.gcube.portlets.widgets.wsexplorer.shared.Item;
|
||||
import org.gcube.portlets.widgets.wsexplorer.shared.ItemType;
|
||||
import org.gcube.portlets.widgets.wsexplorer.shared.SearchedFolder;
|
||||
|
||||
import com.github.gwtbootstrap.client.ui.constants.AlertType;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
|
@ -53,6 +54,8 @@ public class WorkspaceExplorerPaginated extends WorkspaceExplorer{
|
|||
|
||||
protected Widget orginalLoadingIndicator = null;
|
||||
|
||||
private int serverStartIndex = 0;
|
||||
|
||||
/**
|
||||
* Instantiates a new workspace explorer paginated.
|
||||
*
|
||||
|
@ -122,34 +125,45 @@ public class WorkspaceExplorerPaginated extends WorkspaceExplorer{
|
|||
|
||||
final boolean purgeEmpyFolders = !showEmptyFolders;
|
||||
|
||||
//IF IS INIT OR A DOUBLE CLICK
|
||||
if(getDisplayingFolderItem()==null || getDisplayingFolderItem().getId()!=item.getId()){
|
||||
GWT.log("Performing Get Folder Children Count ");
|
||||
WorkspaceExplorerConstants.workspaceNavigatorService.getFolderChildrenCount(item, new AsyncCallback<Integer>() {
|
||||
// //IF IS INIT OR A DOUBLE CLICK
|
||||
// if(getDisplayingFolderItem()==null || getDisplayingFolderItem().getId()!=item.getId()){
|
||||
// GWT.log("Performing Get Folder Children Count ");
|
||||
// WorkspaceExplorerConstants.workspaceNavigatorService.getFolderChildrenCount(item, new AsyncCallback<Integer>() {
|
||||
//
|
||||
// @Override
|
||||
// public void onFailure(Throwable caught) {
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onSuccess(final Integer result) {
|
||||
// GWT.log("Folder Children count: "+result);
|
||||
//
|
||||
// int newStartIndex = startIdx;
|
||||
// getAsycnDataProvider().updateRowCount(result, true);
|
||||
//
|
||||
// if(newLoading){
|
||||
// GWT.log("Cleaning all data...");
|
||||
// newStartIndex = 0;
|
||||
// GWT.log("Store reset performed start index is: "+newStartIndex);
|
||||
// }
|
||||
//
|
||||
// //final Range range = display.getVisibleRange();
|
||||
// perfomGetFolderChildren(item, loadGcubeProperties, newStartIndex, limit, purgeEmpyFolders, showableTypesParam);
|
||||
// }
|
||||
// });
|
||||
// }else
|
||||
// perfomGetFolderChildren(item, loadGcubeProperties, startIdx, limit, purgeEmpyFolders, showableTypesParam);
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
}
|
||||
int newStartIndex = startIdx;
|
||||
|
||||
@Override
|
||||
public void onSuccess(final Integer result) {
|
||||
GWT.log("Folder Children count: "+result);
|
||||
if(newLoading){
|
||||
GWT.log("Cleaning all data...");
|
||||
newStartIndex = 0;
|
||||
GWT.log("Store reset performed start index is: "+newStartIndex);
|
||||
getAsycnDataProvider().updateRowCount(WorkspaceExplorerConstants.ITEMS_PER_PAGE, false);
|
||||
}
|
||||
|
||||
int newStartIndex = startIdx;
|
||||
getAsycnDataProvider().updateRowCount(result, true);
|
||||
|
||||
if(newLoading){
|
||||
GWT.log("Cleaning all data...");
|
||||
newStartIndex = 0;
|
||||
GWT.log("Store reset performed start index is: "+newStartIndex);
|
||||
}
|
||||
|
||||
//final Range range = display.getVisibleRange();
|
||||
perfomGetFolderChildren(item, loadGcubeProperties, newStartIndex, limit, purgeEmpyFolders, showableTypesParam);
|
||||
}
|
||||
});
|
||||
}else
|
||||
perfomGetFolderChildren(item, loadGcubeProperties, startIdx, limit, purgeEmpyFolders, showableTypesParam);
|
||||
perfomGetFolderChildren(item, loadGcubeProperties, newStartIndex, limit, purgeEmpyFolders, showableTypesParam);
|
||||
|
||||
}
|
||||
|
||||
|
@ -167,9 +181,9 @@ public class WorkspaceExplorerPaginated extends WorkspaceExplorer{
|
|||
* @param purgeEmpyFolders the purge empy folders
|
||||
* @param showableTypesParam the showable types param
|
||||
*/
|
||||
private void perfomGetFolderChildren(final Item item, boolean loadGcubeProperties, final int startIdx, int limit, boolean purgeEmpyFolders, List<ItemType> showableTypesParam){
|
||||
private void perfomGetFolderChildren(final Item item, boolean loadGcubeProperties, final int startIdx, final int limit, boolean purgeEmpyFolders, List<ItemType> showableTypesParam){
|
||||
GWT.log("loading workspace folder by item id from server: "+item.getId());
|
||||
WorkspaceExplorerConstants.workspaceNavigatorService.getFolder(item, showableTypesParam, purgeEmpyFolders, filterCriteria, loadGcubeProperties, startIdx, limit, new AsyncCallback<Item>() {
|
||||
WorkspaceExplorerConstants.workspaceNavigatorService.getFolder(item, showableTypesParam, purgeEmpyFolders, filterCriteria, loadGcubeProperties, startIdx, limit, serverStartIndex, new AsyncCallback<SearchedFolder>() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
|
@ -180,28 +194,30 @@ public class WorkspaceExplorerPaginated extends WorkspaceExplorer{
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(Item result) {
|
||||
public void onSuccess(SearchedFolder result) {
|
||||
|
||||
serverStartIndex = result.getServerEndIndex();
|
||||
|
||||
if(item.getName()==null || item.getName().isEmpty())
|
||||
item.setName(result.getName());
|
||||
item.setName(result.getFolder().getName());
|
||||
|
||||
//GWT.log("Returned "+result.getChildren().size() +" children");
|
||||
//getItTables().updateItems(result.getChildren(), true);
|
||||
|
||||
if(newLoading){
|
||||
getCellTable().setVisibleRangeAndClearData(new Range(startIdx, WorkspaceExplorerConstants.ITEMS_PER_PAGE), false);
|
||||
getCellTable().setVisibleRangeAndClearData(new Range(result.getClientStartIndex(), WorkspaceExplorerConstants.ITEMS_PER_PAGE), false);
|
||||
}
|
||||
|
||||
SelectionModel<? super Item> sm = getCellTable().getSelectionModel();
|
||||
|
||||
if(sm instanceof SingleSelectionModel){
|
||||
SingleSelectionModel ssm = (SingleSelectionModel) sm;
|
||||
SingleSelectionModel<Item> ssm = (SingleSelectionModel<Item>) sm;
|
||||
ssm.clear();
|
||||
}
|
||||
|
||||
getAsycnDataProvider().updateRowData(startIdx, result.getChildren());
|
||||
getAsycnDataProvider().updateRowData(result.getClientStartIndex(), result.getFolder().getChildren());
|
||||
|
||||
if(result.getChildren().size()==0){
|
||||
if(result.getFolder().getChildren().size()==0){
|
||||
getCellTable().setLoadingIndicator(new Label("No data"));
|
||||
}else{
|
||||
getCellTable().setLoadingIndicator(orginalLoadingIndicator);
|
||||
|
@ -210,13 +226,18 @@ public class WorkspaceExplorerPaginated extends WorkspaceExplorer{
|
|||
|
||||
//getCellTable().setVisibleRangeAndClearData(new Range(startIdx, result.getChildren()).), false);
|
||||
//getAsycnDataProvider().getDataDisplays().
|
||||
GWT.log("Updating row data startIndex: "+startIdx + " size: "+result.getChildren().size());
|
||||
GWT.log("Updating row data startIndex: "+result.getClientStartIndex() + " children size: "+result.getFolder().getChildren().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());
|
||||
setDisplayingFolderItem(result);
|
||||
setDisplayingFolderItem(result.getFolder());
|
||||
newLoading = false;
|
||||
|
||||
}
|
||||
|
@ -281,13 +302,15 @@ public class WorkspaceExplorerPaginated extends WorkspaceExplorer{
|
|||
int start = range.getStart();
|
||||
int length = range.getLength();
|
||||
|
||||
GWT.log("Range changed: "+start +" "+length + " visible count: "+display.getVisibleItemCount());
|
||||
|
||||
if(newLoading){
|
||||
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);
|
||||
loadFolder(getDisplayingFolderItem(), loadGcubeProperties, start, length, false);
|
||||
}
|
||||
catch (Exception e) {
|
||||
|
|
|
@ -169,12 +169,16 @@ public class ItemsTable<T extends Item> extends AbstractItemsCellTable<T> implem
|
|||
name = new TextColumn<T>() {
|
||||
@Override
|
||||
public String getValue(T object) {
|
||||
if(object==null)
|
||||
return "";
|
||||
return ((Item) object).getName();
|
||||
}
|
||||
|
||||
//ADDING TOOLTIP
|
||||
@Override
|
||||
public void render(com.google.gwt.cell.client.Cell.Context context, T object, SafeHtmlBuilder sb) {
|
||||
if(object == null)
|
||||
return;
|
||||
sb.appendHtmlConstant("<div title=\""+((Item) object).getName()+"\">");
|
||||
super.render(context, object, sb);
|
||||
sb.appendHtmlConstant("</div>");
|
||||
|
@ -201,6 +205,8 @@ public class ItemsTable<T extends Item> extends AbstractItemsCellTable<T> implem
|
|||
owner = new TextColumn<T>() {
|
||||
@Override
|
||||
public String getValue(T object) {
|
||||
if(object==null)
|
||||
return "";
|
||||
return ((Item) object).getOwner() != null ? ((Item) object).getOwner() : "";
|
||||
}
|
||||
};
|
||||
|
@ -226,6 +232,8 @@ public class ItemsTable<T extends Item> extends AbstractItemsCellTable<T> implem
|
|||
|
||||
@Override
|
||||
public Date getValue(T object) {
|
||||
if(object==null)
|
||||
return null;
|
||||
return ((Item) object).getCreationDate();
|
||||
}
|
||||
};
|
||||
|
@ -255,9 +263,6 @@ public class ItemsTable<T extends Item> extends AbstractItemsCellTable<T> implem
|
|||
sortedCellTable.setComparator(dateColumn,c);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@ import org.gcube.portlets.widgets.wsexplorer.shared.Item;
|
|||
import org.gcube.portlets.widgets.wsexplorer.shared.ItemCategory;
|
||||
import org.gcube.portlets.widgets.wsexplorer.shared.ItemInterface;
|
||||
import org.gcube.portlets.widgets.wsexplorer.shared.ItemType;
|
||||
import org.gcube.portlets.widgets.wsexplorer.shared.SearchedFolder;
|
||||
import org.gcube.portlets.widgets.wsexplorer.shared.WorkspaceNavigatorServiceException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -696,10 +697,10 @@ public class WorkspaceExplorerServiceImpl extends RemoteServiceServlet implement
|
|||
* @see org.gcube.portlets.widgets.wsexplorer.client.rpc.WorkspaceExplorerService#getFolder(org.gcube.portlets.widgets.wsexplorer.shared.Item, java.util.List, boolean, org.gcube.portlets.widgets.wsexplorer.shared.FilterCriteria, boolean, int, int)
|
||||
*/
|
||||
@Override
|
||||
public Item getFolder(
|
||||
public SearchedFolder getFolder(
|
||||
Item item, List<ItemType> showableTypes, boolean purgeEmpyFolders,
|
||||
FilterCriteria filterCriteria, boolean loadGcubeProperties,
|
||||
int startIndex, int limit) throws WorkspaceNavigatorServiceException {
|
||||
final int startIndex, final int limit, final int serverStartIndex) throws WorkspaceNavigatorServiceException {
|
||||
|
||||
logger.trace("getFolder folderId: "+item.getId()+" showableTypes: "+showableTypes+" purgeEmpyFolders: "+purgeEmpyFolders+" filterCriteria: "+filterCriteria);
|
||||
|
||||
|
@ -707,30 +708,95 @@ public class WorkspaceExplorerServiceImpl extends RemoteServiceServlet implement
|
|||
|
||||
Workspace workspace = getWorkspace();
|
||||
WorkspaceItem folder = workspace.getItem(item.getId());
|
||||
logger.trace("GetFolder - Replyiing folder");
|
||||
long startTime = System.currentTimeMillis();
|
||||
logger.trace("start time - " + startTime);
|
||||
int searchStartIndex = startIndex < serverStartIndex? serverStartIndex : startIndex;
|
||||
//logger.trace("GetFolder - Replyiing folder");
|
||||
logger.debug("MyLg getFolder searchIndex: "+searchStartIndex+", limit: "+limit);
|
||||
//long startTime = System.currentTimeMillis();
|
||||
//logger.trace("start time - " + startTime);
|
||||
|
||||
//TO AVOID SLOW CALL getPATH()
|
||||
String folderPath = item.getPath()!=null && !item.getPath().isEmpty()?item.getPath():folder.getPath();
|
||||
Item itemFolderToReturn = ItemBuilder.getItem(null, folder, folderPath, showableTypes, filterCriteria, true, loadGcubeProperties, searchStartIndex, limit);
|
||||
|
||||
//folder.get
|
||||
SearchedFolder sf = new SearchedFolder(itemFolderToReturn, startIndex, limit, searchStartIndex, false);
|
||||
int currentListCount = sf.getFolder().getChildren().size();
|
||||
logger.debug("MyLg Total item returning is: "+currentListCount);
|
||||
|
||||
Item itemFolder = ItemBuilder.getItem(null, folder, folderPath, showableTypes, filterCriteria, true, loadGcubeProperties, startIndex, limit);
|
||||
// _log.trace("Only showable types:");
|
||||
WorkspaceFolder hlFolder = (WorkspaceFolder) folder;
|
||||
int folderChildrenCount = hlFolder.getChildrenCount(false);
|
||||
logger.debug("MyLg Folder children count is: "+folderChildrenCount);
|
||||
|
||||
if (purgeEmpyFolders) {
|
||||
itemFolder = ItemBuilder.purgeEmptyFolders(itemFolder);
|
||||
if(currentListCount == limit || folderChildrenCount==0){
|
||||
logger.debug("Page completed returning "+currentListCount+ " items");
|
||||
int offset = searchStartIndex+limit;
|
||||
|
||||
//Collections.sort(sf.getFolder().getChildren(), new ItemComparator());
|
||||
|
||||
sf.setServerSearchFinished(offset>folderChildrenCount || folderChildrenCount == 0);
|
||||
logger.debug("is Search finished: "+sf.isServerSearchFinished());
|
||||
return sf;
|
||||
}
|
||||
|
||||
logger.debug("Returning: "+itemFolder.getChildren().size() + " items");
|
||||
Long endTime = System.currentTimeMillis() - startTime;
|
||||
String time = String.format("%d msc %d sec", endTime, TimeUnit.MILLISECONDS.toSeconds(endTime));
|
||||
logger.debug("end time - " + time);
|
||||
ArrayList<Item> childrenToReturn = new ArrayList<Item>(limit);
|
||||
childrenToReturn.addAll(sf.getFolder().getChildren());
|
||||
|
||||
Collections.sort(itemFolder.getChildren(), new ItemComparator());
|
||||
int offsetStartIndex = searchStartIndex;
|
||||
boolean pageOffsetOut = false;
|
||||
while(currentListCount < limit && !sf.isServerSearchFinished() && !pageOffsetOut){ //&& SEARCH NOT ULTIMATED
|
||||
logger.debug("MyLg new WHILE Items count: "+currentListCount+" is less than limit..");
|
||||
|
||||
return itemFolder;
|
||||
int newstartIndex = offsetStartIndex+limit+1;
|
||||
logger.debug("MyLg NewStartIndex is startIndex+limit: "+newstartIndex);
|
||||
|
||||
//THERE ARE OTHER CHILDREN OVER NEW START INDEX
|
||||
if(newstartIndex < folderChildrenCount){
|
||||
//newLimit = limit - childrenToReturn.size();
|
||||
logger.debug("MyLg getting items with index start: "+newstartIndex + ", limit: "+limit);
|
||||
Item newItemFolder = ItemBuilder.getItem(null, folder, folderPath, showableTypes, filterCriteria, true, loadGcubeProperties, newstartIndex, limit);
|
||||
int diff = limit - currentListCount; //How items are remaining
|
||||
//int offset = 0;
|
||||
logger.debug("MyLg new search start: "+newstartIndex + ", diff: "+diff+ ", retrieved: "+newItemFolder.getChildren().size());
|
||||
if(diff >= newItemFolder.getChildren().size()){
|
||||
logger.debug("MyLg Adding sublist from 0 to 'diff' "+diff+" to children");
|
||||
childrenToReturn.addAll(newItemFolder.getChildren().subList(0, newItemFolder.getChildren().size()));
|
||||
//offset = diff;
|
||||
}else{
|
||||
logger.debug("MyLg PageOffsetOut, the sublist size: "+newItemFolder.getChildren().size()+ " is greather than (limit-currentListCount)"+diff+" leaving WHILE...");
|
||||
//childrenToReturn.addAll(newItemFolder.getChildren().subList(0, newItemFolder.getChildren().size()));
|
||||
//offset = newItemFolder.getChildren().size();
|
||||
pageOffsetOut = true;
|
||||
}
|
||||
offsetStartIndex = newstartIndex;
|
||||
currentListCount = childrenToReturn.size();
|
||||
//int realServerEndIndex = newstartIndex+offset;
|
||||
logger.debug("MyLg New items count is: "+currentListCount + " serverEndIndex: "+offsetStartIndex);
|
||||
sf.setServerEndIndex(offsetStartIndex);
|
||||
}else{
|
||||
logger.debug("MyLg New start index (oldStartIndex+limit) is grather than folder children count, search is finished");
|
||||
sf.setServerSearchFinished(true);
|
||||
}
|
||||
}
|
||||
|
||||
sf.getFolder().setChildren(childrenToReturn);
|
||||
//sf.setServerEndIndex(sf.getServerEndIndex());
|
||||
|
||||
if (purgeEmpyFolders) {
|
||||
itemFolderToReturn = ItemBuilder.purgeEmptyFolders(sf.getFolder());
|
||||
}
|
||||
|
||||
//logger.debug("Returning: "+itemFolder.getChildren().size() + " items");
|
||||
//Long endTime = System.currentTimeMillis() - startTime;
|
||||
//String time = String.format("%d msc %d sec", endTime, TimeUnit.MILLISECONDS.toSeconds(endTime));
|
||||
//logger.debug("end time - " + time);
|
||||
|
||||
int i = 0;
|
||||
for (Item item2 : sf.getFolder().getChildren()) {
|
||||
logger.debug(++i+") "+item2);
|
||||
}
|
||||
|
||||
//Collections.sort(itemFolderToReturn.getChildren(), new ItemComparator());
|
||||
logger.debug("Returning: "+sf);
|
||||
return sf;
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error("Error during folder retrieving", e);
|
||||
|
|
|
@ -51,6 +51,7 @@ public class Item implements IsSerializable, ItemInterface{
|
|||
this.isFolder = isFolder;
|
||||
this.name = name;
|
||||
this.type = isFolder?ItemType.FOLDER:ItemType.UNKNOWN_TYPE;
|
||||
this.children = new ArrayList<Item>();
|
||||
}
|
||||
|
||||
|
||||
|
@ -95,6 +96,16 @@ public class Item implements IsSerializable, ItemInterface{
|
|||
this.isRoot = isRoot;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the children.
|
||||
*
|
||||
* @param children the new children
|
||||
*/
|
||||
public void setChildren(ArrayList<Item> children) {
|
||||
|
||||
this.children = children;
|
||||
}
|
||||
/**
|
||||
* Sets the id.
|
||||
*
|
||||
|
@ -382,8 +393,8 @@ public class Item implements IsSerializable, ItemInterface{
|
|||
builder.append(type);
|
||||
builder.append(", path=");
|
||||
builder.append(path);
|
||||
builder.append(", children=");
|
||||
builder.append(children);
|
||||
builder.append(", children size=");
|
||||
builder.append(children.size());
|
||||
builder.append(", owner=");
|
||||
builder.append(owner);
|
||||
builder.append(", isFolder=");
|
||||
|
|
|
@ -0,0 +1,174 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.widgets.wsexplorer.shared;
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
|
||||
|
||||
/**
|
||||
* The Class SearchedFolder.
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* Jul 12, 2017
|
||||
*/
|
||||
public class SearchedFolder implements IsSerializable{
|
||||
|
||||
|
||||
private Item folder;
|
||||
private int clientStartIndex = 0;
|
||||
private int limit;
|
||||
private int serverEndIndex = 0;
|
||||
private boolean isServerSearchFinished = false;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public SearchedFolder() {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param folder
|
||||
* @param clientStartIndex
|
||||
* @param limit
|
||||
* @param serverEndIndex
|
||||
* @param isServerSearchFinished
|
||||
*/
|
||||
public SearchedFolder(Item folder, int clientStartIndex, int limit, int serverEndIndex, boolean isServerSearchFinished) {
|
||||
|
||||
super();
|
||||
this.folder = folder;
|
||||
this.clientStartIndex = clientStartIndex;
|
||||
this.limit = limit;
|
||||
this.serverEndIndex = serverEndIndex;
|
||||
this.isServerSearchFinished = isServerSearchFinished;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @return the folder
|
||||
*/
|
||||
public Item getFolder() {
|
||||
|
||||
return folder;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @return the clientStartIndex
|
||||
*/
|
||||
public int getClientStartIndex() {
|
||||
|
||||
return clientStartIndex;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @return the limit
|
||||
*/
|
||||
public int getLimit() {
|
||||
|
||||
return limit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @return the serverEndIndex
|
||||
*/
|
||||
public int getServerEndIndex() {
|
||||
|
||||
return serverEndIndex;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @return the isServerSearchFinished
|
||||
*/
|
||||
public boolean isServerSearchFinished() {
|
||||
|
||||
return isServerSearchFinished;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param folder the folder to set
|
||||
*/
|
||||
public void setFolder(Item folder) {
|
||||
|
||||
this.folder = folder;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param clientStartIndex the clientStartIndex to set
|
||||
*/
|
||||
public void setClientStartIndex(int clientStartIndex) {
|
||||
|
||||
this.clientStartIndex = clientStartIndex;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param limit the limit to set
|
||||
*/
|
||||
public void setLimit(int limit) {
|
||||
|
||||
this.limit = limit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param serverEndIndex the serverEndIndex to set
|
||||
*/
|
||||
public void setServerEndIndex(int serverEndIndex) {
|
||||
|
||||
this.serverEndIndex = serverEndIndex;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param isServerSearchFinished the isServerSearchFinished to set
|
||||
*/
|
||||
public void setServerSearchFinished(boolean isServerSearchFinished) {
|
||||
|
||||
this.isServerSearchFinished = isServerSearchFinished;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("SearchedFolder [folder=");
|
||||
builder.append(folder);
|
||||
builder.append(", clientStartIndex=");
|
||||
builder.append(clientStartIndex);
|
||||
builder.append(", limit=");
|
||||
builder.append(limit);
|
||||
builder.append(", serverEndIndex=");
|
||||
builder.append(serverEndIndex);
|
||||
builder.append(", isServerSearchFinished=");
|
||||
builder.append(isServerSearchFinished);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue