implemnted support for optimised recent query
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/workspace-widget-portlet@169132 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
bba88e750c
commit
f4a30c6afc
|
@ -13,18 +13,10 @@ import org.gcube.common.portal.PortalContext;
|
|||
import org.gcube.common.storagehub.client.plugins.AbstractPlugin;
|
||||
import org.gcube.common.storagehub.client.proxies.ItemManagerClient;
|
||||
import org.gcube.common.storagehub.client.proxies.WorkspaceManagerClient;
|
||||
import org.gcube.common.storagehub.model.Paths;
|
||||
import org.gcube.common.storagehub.model.expressions.GenericSearchableItem;
|
||||
import org.gcube.common.storagehub.model.expressions.OrderField;
|
||||
import org.gcube.common.storagehub.model.expressions.SearchableItem;
|
||||
import org.gcube.common.storagehub.model.expressions.logical.ISDescendant;
|
||||
import org.gcube.common.storagehub.model.items.AbstractFileItem;
|
||||
import org.gcube.common.storagehub.model.items.Item;
|
||||
import org.gcube.common.storagehub.model.query.Queries;
|
||||
import org.gcube.common.storagehub.model.query.Query;
|
||||
import org.gcube.portlets.user.wswidget.shared.AuthorizedUser;
|
||||
import org.gcube.portlets.user.wswidget.shared.WSItem;
|
||||
import org.gcube.common.storagehub.model.expressions.OrderField.MODE;
|
||||
|
||||
import com.liferay.portal.kernel.log.Log;
|
||||
import com.liferay.portal.kernel.log.LogFactoryUtil;
|
||||
|
||||
|
@ -104,20 +96,14 @@ public class StorageHubServiceUtil {
|
|||
* @param limit
|
||||
* @return
|
||||
*/
|
||||
public static List<WSItem> getRecentItems(AuthorizedUser authUser, int limit, Item vreFolder) {
|
||||
public static List<WSItem> getRecentItems(AuthorizedUser authUser) {
|
||||
WSItem toReturn = new WSItem("recents", "Recent Documents", true);
|
||||
_log.debug("getRecentItems ");
|
||||
ArrayList<WSItem> children = new ArrayList<>();
|
||||
SecurityTokenProvider.instance.set(authUser.getSecurityToken());
|
||||
Query<SearchableItem<?>> query = Queries.queryFor(AbstractFileItem.class);
|
||||
|
||||
//query.setExpression(new ISDescendant(Paths.getPath(vreFolder.getPath())));
|
||||
query.setExpression(new ISDescendant(Paths.getPath("/Home/"+authUser.getUser().getUsername()+"/Workspace/MySpecialFolders/"+vreFolder.getTitle())));
|
||||
WorkspaceManagerClient wsclient = AbstractPlugin.workspace().build();
|
||||
List<? extends Item> theChildren = wsclient.getRecentModifiedFilePerVre();
|
||||
|
||||
query.setLimit(limit);
|
||||
query.setOrder(new OrderField(GenericSearchableItem.get().lastModification, MODE.DESC));
|
||||
WorkspaceManagerClient wsclient = AbstractPlugin.workspace().build();
|
||||
List<? extends Item> theChildren = wsclient.search(query, "hl:accounting");
|
||||
|
||||
if (theChildren == null || theChildren.isEmpty()) {
|
||||
toReturn.setChildren(children);
|
||||
|
|
|
@ -103,12 +103,11 @@ public class WorkspaceWidget extends MVCPortlet {
|
|||
count = StorageHubServiceUtil.getItemChildrenCount(request, itemId);
|
||||
}
|
||||
else if (itemId.compareTo("recents") == 0) { //is in a VRE and asking for recents files
|
||||
WorkspaceManagerClient wsclient = AbstractPlugin.workspace().build();
|
||||
Item vreFolder = wsclient.getVreFolder("hl:accounting");
|
||||
itemsList = StorageHubServiceUtil.getRecentItems(authUser, offset, vreFolder);
|
||||
|
||||
itemsList = StorageHubServiceUtil.getRecentItems(authUser);
|
||||
count = offset;
|
||||
toSet = (Breadcrumb) request.getPortletSession().getAttribute(BREADCRUMB_ATTR, PortletSession.APPLICATION_SCOPE);
|
||||
toSet.setChild(new Breadcrumb(vreFolder.getId(), "Recent"));
|
||||
toSet.setChild(new Breadcrumb("", "Top 10 Recent"));
|
||||
request.getPortletSession().setAttribute(BREADCRUMB_ATTR, toSet, PortletSession.APPLICATION_SCOPE);
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -94,11 +94,15 @@ function loadItemsListIntoTable(itemId, itemName, hideVreFolders) {
|
|||
} else {
|
||||
$('#vreFoldersDiv').show();
|
||||
}
|
||||
$('#userTable_info').show();
|
||||
$('#userTable_length').show();
|
||||
}
|
||||
|
||||
function loadRecentItemsListIntoTable(itemId, itemName) {
|
||||
var table = $('#userTable').DataTable();
|
||||
table.ajax.url('<%=usersCustomDataSourceURL%>'+itemId+'_selectedName='+itemName).load();
|
||||
$('#userTable_info').hide();
|
||||
$('#userTable_length').hide();
|
||||
}
|
||||
|
||||
function downloadItem(itemId) {
|
||||
|
|
Loading…
Reference in New Issue