From 804df660796f539827fdb6fbcef11176e9215964 Mon Sep 17 00:00:00 2001 From: Francesco Mangiacrapa Date: Mon, 12 Oct 2015 13:30:59 +0000 Subject: [PATCH] Merged with branch version at 119580 git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace-tree-widget@119610 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../client/AppControllerExplorer.java | 6 +- .../client/event/AddSmartFolderEvent.java | 73 ++++++++++++++++--- .../workspace/client/resources/Icons.java | 3 + .../workspace/client/resources/Resources.java | 12 +++ .../client/rpc/GWTWorkspaceService.java | 21 +----- .../client/rpc/GWTWorkspaceServiceAsync.java | 4 +- .../server/GWTWorkspaceServiceImpl.java | 24 ++++-- .../user/workspace/SearchTextTest.java | 2 +- 8 files changed, 105 insertions(+), 40 deletions(-) diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/AppControllerExplorer.java b/src/main/java/org/gcube/portlets/user/workspace/client/AppControllerExplorer.java index f7d3d69..7a1a458 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/AppControllerExplorer.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/AppControllerExplorer.java @@ -1321,8 +1321,8 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt private void doSaveSmartFolder(final AddSmartFolderEvent saveSmartFolderEvent) { final String query = saveSmartFolderEvent.getSearchText(); - - + final String parentId = saveSmartFolderEvent.getParentId(); + final DialogAddFolderAndSmart dialogAddSmartFolder = new DialogAddFolderAndSmart("", AddType.SMARTFOLDER); dialogAddSmartFolder.getButtonById(Dialog.OK).addListener(Events.Select, new Listener() { @@ -1332,7 +1332,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt if(dialogAddSmartFolder.isValidForm()) - rpcWorkspaceService.createSmartFolder(dialogAddSmartFolder.getName(), dialogAddSmartFolder.getDescription(), query, new AsyncCallback() { + rpcWorkspaceService.createSmartFolder(dialogAddSmartFolder.getName(), dialogAddSmartFolder.getDescription(), query, parentId, new AsyncCallback() { @Override public void onFailure(Throwable caught) { diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/event/AddSmartFolderEvent.java b/src/main/java/org/gcube/portlets/user/workspace/client/event/AddSmartFolderEvent.java index a44716d..f0d8d88 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/event/AddSmartFolderEvent.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/event/AddSmartFolderEvent.java @@ -2,6 +2,12 @@ package org.gcube.portlets.user.workspace.client.event; import com.google.gwt.event.shared.GwtEvent; +/** + * The Class AddSmartFolderEvent. + * + * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it + * Oct 9, 2015 + */ public class AddSmartFolderEvent extends GwtEvent{ public static Type TYPE = new Type(); @@ -9,54 +15,103 @@ public class AddSmartFolderEvent extends GwtEvent{ private String searchText; private String workpaceFolderId; private String description; + private String parentId; -// public AddSmartFolderEvent(String smartFolderName, String searchText, String workpaceFolderId) { -// -// this.smartFolderName = smartFolderName; -// this.searchText = searchText; -// this.workpaceFolderId = workpaceFolderId; -// } - - public AddSmartFolderEvent(String searchText) { - this.searchText = searchText; + /** + * @return the parentId + */ + public String getParentId() { + return parentId; } + /** + * Instantiates a new adds the smart folder event. + * + * @param searchText the search text + * @param parentId the parent id + */ + public AddSmartFolderEvent(String searchText, String parentId) { + this.searchText = searchText; + this.parentId = parentId; + } + + /* (non-Javadoc) + * @see com.google.gwt.event.shared.GwtEvent#getAssociatedType() + */ @Override public Type getAssociatedType() { return TYPE; } + /* (non-Javadoc) + * @see com.google.gwt.event.shared.GwtEvent#dispatch(com.google.gwt.event.shared.EventHandler) + */ @Override protected void dispatch(AddSmartFolderEventHandler handler) { handler.onSaveSmartFolder(this); } + /** + * Gets the smart folder name. + * + * @return the smart folder name + */ public String getSmartFolderName() { return smartFolderName; } + /** + * Gets the search text. + * + * @return the search text + */ public String getSearchText() { return searchText; } + /** + * Gets the workpace folder id. + * + * @return the workpace folder id + */ public String getWorkpaceFolderId() { return workpaceFolderId; } + /** + * Sets the smart folder name. + * + * @param smartFolderName the new smart folder name + */ public void setSmartFolderName(String smartFolderName) { this.smartFolderName = smartFolderName; } + /** + * Sets the workpace folder id. + * + * @param workpaceFolderId the new workpace folder id + */ public void setWorkpaceFolderId(String workpaceFolderId) { this.workpaceFolderId = workpaceFolderId; } + /** + * Gets the description. + * + * @return the description + */ public String getDescription() { return description; } + /** + * Sets the description. + * + * @param description the new description + */ public void setDescription(String description) { this.description = description; } diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/resources/Icons.java b/src/main/java/org/gcube/portlets/user/workspace/client/resources/Icons.java index 5a30cbc..6ed689d 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/resources/Icons.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/resources/Icons.java @@ -88,6 +88,9 @@ public interface Icons extends ClientBundle { @Source("icons/mime/search16.png") ImageResource search(); + + @Source("icons/mime/search.png") + ImageResource search2(); @Source("icons/mime/harddisk.png") ImageResource hardDisk(); diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/resources/Resources.java b/src/main/java/org/gcube/portlets/user/workspace/client/resources/Resources.java index 1946f84..b6e5d6f 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/resources/Resources.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/resources/Resources.java @@ -686,6 +686,18 @@ public class Resources { return AbstractImagePrototype.create(ICONS.search()); } + + /** + * Gets the icon search ws. + * + * @return the icon search ws + */ + public static AbstractImagePrototype getIconSearchWs() { + + return AbstractImagePrototype.create(ICONS.search2()); + } + + /** * Gets the icon links. * diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/rpc/GWTWorkspaceService.java b/src/main/java/org/gcube/portlets/user/workspace/client/rpc/GWTWorkspaceService.java index b13d7ea..d2a3d1f 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/rpc/GWTWorkspaceService.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/rpc/GWTWorkspaceService.java @@ -132,16 +132,8 @@ public interface GWTWorkspaceService extends RemoteService{ */ public List getSmartFolderResultsByCategory(String category) throws Exception; - /** - * Creates the smart folder. - * - * @param name the name - * @param description the description - * @param query the query - * @return the smart folder model - * @throws Exception the exception - */ - public SmartFolderModel createSmartFolder(String name, String description, String query) throws Exception; + SmartFolderModel createSmartFolder(String name, String description, + String query, String parentId) throws Exception; /** * Gets the smart folder results by id. @@ -203,14 +195,7 @@ public interface GWTWorkspaceService extends RemoteService{ */ public void setValueInSession(String name, String value) throws Exception; - /** - * Gets the items by search name. - * - * @param text the text - * @return the items by search name - * @throws Exception the exception - */ - public List getItemsBySearchName(String text) throws Exception; + List getItemsBySearchName(String text, String folderId) throws Exception; /** * Move item. diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/rpc/GWTWorkspaceServiceAsync.java b/src/main/java/org/gcube/portlets/user/workspace/client/rpc/GWTWorkspaceServiceAsync.java index 51ea117..19283a3 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/rpc/GWTWorkspaceServiceAsync.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/rpc/GWTWorkspaceServiceAsync.java @@ -143,7 +143,7 @@ public interface GWTWorkspaceServiceAsync { * @param callback the callback * @return the items by search name */ - void getItemsBySearchName(String text, AsyncCallback> callback); + void getItemsBySearchName(String text, String folderId, AsyncCallback> callback); /** * Gets the smart folder results by category. @@ -162,7 +162,7 @@ public interface GWTWorkspaceServiceAsync { * @param query the query * @param callback the callback */ - void createSmartFolder(String name, String description, String query, AsyncCallback callback); + void createSmartFolder(String name, String description, String query, String parentId, AsyncCallback callback); /** * Gets the smart folder results by id. diff --git a/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceServiceImpl.java b/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceServiceImpl.java index fc49f14..2b63aba 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceServiceImpl.java +++ b/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceServiceImpl.java @@ -278,14 +278,17 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT * @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#getItemsBySearchName(java.lang.String) */ @Override - public List getItemsBySearchName(String text) throws Exception { + public List getItemsBySearchName(String text, String folderId) throws Exception { - workspaceLogger.info("searching by name: "+text); - try { Workspace workspace = getWorkspace(); - workspaceLogger.info("Calling search HL.."); - List listSearchItems = workspace.searchByName(text); + if(folderId==null || folderId.isEmpty()){ + workspaceLogger.trace("searching folderId is null, settings root Id"); + folderId = workspace.getRoot().getId(); + } + + workspaceLogger.info("searching by name: "+text +" in "+folderId); + List listSearchItems = workspace.searchByName(text, folderId); workspaceLogger.info("HL search returning "+listSearchItems.size()+" items"); workspaceLogger.info("Converting "+listSearchItems.size()+" items"); @@ -1141,7 +1144,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT * @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#createSmartFolder(java.lang.String, java.lang.String, java.lang.String) */ @Override - public SmartFolderModel createSmartFolder(String name, String description, String query) throws Exception { + public SmartFolderModel createSmartFolder(String name, String description, String query, String parentId) throws Exception { try { @@ -1149,7 +1152,14 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT workspaceLogger.trace("create smart folder by name: "+name); workspaceLogger.trace("description " + description); workspaceLogger.trace("query " + query); - WorkspaceSmartFolder wsSmartFolder = workspace.createSmartFolder(name, description, query); //create Smart Folder from workspace + workspaceLogger.trace("parentId " + parentId); + + if(parentId==null || parentId.isEmpty()){ + workspaceLogger.trace("parent id is null using root id"); + parentId = workspace.getRoot().getId(); + } + + WorkspaceSmartFolder wsSmartFolder = workspace.createSmartFolder(name, description, query, parentId); //create Smart Folder from workspace workspaceLogger.trace("create : " +wsSmartFolder.getName() + " id "+ wsSmartFolder.getId()); GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder(); return builder.buildGXTSmartFolderModel(wsSmartFolder,query); diff --git a/src/test/java/org/gcube/portlets/user/workspace/SearchTextTest.java b/src/test/java/org/gcube/portlets/user/workspace/SearchTextTest.java index 2d181c3..29d52c3 100644 --- a/src/test/java/org/gcube/portlets/user/workspace/SearchTextTest.java +++ b/src/test/java/org/gcube/portlets/user/workspace/SearchTextTest.java @@ -52,7 +52,7 @@ public class SearchTextTest { // List listSearchItems = ws.searchByName(text); logger.info("Calling search HL.."); - List listSearchItems = workspace.searchByName(text); + List listSearchItems = workspace.searchByName(text, workspace.getRoot().getId()); logger.info("HL search returning "+listSearchItems.size()+" items"); logger.info("Converting "+listSearchItems.size()+" items");