diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/model/FileDetailsModel.java b/src/main/java/org/gcube/portlets/user/workspace/client/model/FileDetailsModel.java index 484829c..1ba59a1 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/model/FileDetailsModel.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/model/FileDetailsModel.java @@ -32,10 +32,10 @@ public class FileDetailsModel extends FileGridModel { set(ConstantsExplorer.LASTMODIFIED, lastModified); } - private Date getLastModified() { - return (Date) get(ConstantsExplorer.LASTMODIFIED); - } - +// private Date getLastModified() { +// return (Date) get(ConstantsExplorer.LASTMODIFIED); +// } +// public String getDescription(){ return get(ConstantsExplorer.DESCRIPTION); } diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/model/FileGridModel.java b/src/main/java/org/gcube/portlets/user/workspace/client/model/FileGridModel.java index 20d66e4..deab992 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/model/FileGridModel.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/model/FileGridModel.java @@ -5,7 +5,9 @@ import java.util.Date; import org.gcube.portlets.user.workspace.client.ConstantsExplorer; /** + * * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it + * @Nov 14, 2013 * */ public class FileGridModel extends FileModel { @@ -18,18 +20,18 @@ public class FileGridModel extends FileModel { protected FileGridModel(){ } - public FileGridModel(String identifier, String name, String path, Date creationDate, FileModel parent, long size, boolean isDirectory, boolean isShared) { + public FileGridModel(String identifier, String name, String path, Date lastUpdate, FileModel parent, long size, boolean isDirectory, boolean isShared) { super(identifier, name, parent, isDirectory, isShared); - setCreationDate(creationDate); + setLastModification(lastUpdate); setSize(size); } - public FileGridModel(String identifier, String name, Date creationDate, FileModel parent, long size, boolean isDirectory, boolean isShared) { + public FileGridModel(String identifier, String name, Date lastUpdate, FileModel parent, long size, boolean isDirectory, boolean isShared) { super(identifier, name, parent, isDirectory, isShared); - setCreationDate(creationDate); + setLastModification(lastUpdate); setSize(size); } @@ -41,15 +43,25 @@ public class FileGridModel extends FileModel { return (Long) get(ConstantsExplorer.SIZE); } - private void setCreationDate(Date creationDate) { - set(ConstantsExplorer.GRIDCOLUMNCREATIONDATE, creationDate); +// private void setCreationDate(Date creationDate) { +// set(ConstantsExplorer.GRIDCOLUMNCREATIONDATE, creationDate); +// +// } + + private void setLastModification(Date lastUpdate) { + set(ConstantsExplorer.LASTMODIFIED, lastUpdate); } - public Date getCreationDate(){ - return (Date) get(ConstantsExplorer.GRIDCOLUMNCREATIONDATE); + public Date getLastModification() { + return (Date) get(ConstantsExplorer.LASTMODIFIED); + } +// public Date getCreationDate(){ +// return (Date) get(ConstantsExplorer.GRIDCOLUMNCREATIONDATE); +// } + @Override public boolean equals(Object obj) { if (obj != null && obj instanceof FileGridModel) { diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/view/windows/DialogGetInfo.java b/src/main/java/org/gcube/portlets/user/workspace/client/view/windows/DialogGetInfo.java index 86cc1e1..7fbcb49 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/view/windows/DialogGetInfo.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/view/windows/DialogGetInfo.java @@ -108,17 +108,25 @@ public class DialogGetInfo extends Dialog { txtCreated = new TextField(); txtCreated.setFieldLabel("Created"); txtCreated.setReadOnly(true); - if(fileModel instanceof FileGridModel) - textFieldSetValue(txtCreated, ((FileGridModel) fileModel).getCreationDate().toString()); - else - loadCreationDate(fileModel.getIdentifier()); +// if(fileModel instanceof FileGridModel) +// textFieldSetValue(txtCreated, ((FileGridModel) fileModel).getCreationDate().toString()); +// else +// loadCreationDate(fileModel.getIdentifier()); + + loadCreationDate(fileModel.getIdentifier()); + add(txtCreated); txtLastMofication = new TextField(); txtLastMofication.setFieldLabel("Last Mofication"); txtLastMofication.setReadOnly(true); - loadLastModificationDate(fileModel.getIdentifier()); + if(fileModel instanceof FileGridModel) + textFieldSetValue(txtLastMofication, ((FileGridModel) fileModel).getLastModification().toString()); + else + loadLastModificationDate(fileModel.getIdentifier()); + +// loadLastModificationDate(fileModel.getIdentifier()); add(txtLastMofication); txtSize = new TextField(); diff --git a/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceBuilder.java b/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceBuilder.java index e48d9cd..e7a9067 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceBuilder.java +++ b/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceBuilder.java @@ -982,11 +982,13 @@ public class GWTWorkspaceBuilder { } - protected List buildGXTListFileGridModelItemForSearch(List listSearchItems, FileModel parentFileModel) throws InternalErrorException + protected List buildGXTListFileGridModelItemForSearch(List listSearchItems) throws InternalErrorException { List listFileGridModel = new ArrayList(); + FileModel parentFileModel = null; + for (SearchItem item : listSearchItems) listFileGridModel.add(buildGXTFileGridModelItemForSearch(item,parentFileModel)); @@ -1001,7 +1003,8 @@ public class GWTWorkspaceBuilder { switch (item.getType()) { case FOLDER: - fileGridModel = (FolderGridModel) new FolderGridModel(item.getId(), item.getName(), toDate(item.getCreationDate()), parentFileModel, -1, true, false); +// fileGridModel = (FolderGridModel) new FolderGridModel(item.getId(), item.getName(), toDate(item.getCreationDate()), parentFileModel, -1, true, false); + fileGridModel = (FolderGridModel) new FolderGridModel(item.getId(), item.getName(), toDate(item.getLastModified()), parentFileModel, -1, true, false); fileGridModel.setType(GXTFolderItemTypeEnum.FOLDER.toString()); fileGridModel.setShortcutCategory(GXTCategoryItemInterface.SMF_DOCUMENTS); fileGridModel.setShareable(true); @@ -1009,14 +1012,16 @@ public class GWTWorkspaceBuilder { case FOLDER_ITEM: SearchFolderItem folderItem = (SearchFolderItem) item; - fileGridModel = new FileGridModel(item.getId(), item.getName(), toDate(item.getCreationDate()), parentFileModel, folderItem.getSize(), false, false); +// fileGridModel = new FileGridModel(item.getId(), item.getName(), toDate(item.getCreationDate()), parentFileModel, folderItem.getSize(), false, false); + fileGridModel = new FileGridModel(item.getId(), item.getName(), toDate(item.getLastModified()), parentFileModel, folderItem.getSize(), false, false); // FolderItem folderItem = (FolderItem) item; fileGridModel = (FileGridModel) setFolderItemTypeForSearch(fileGridModel, folderItem); break; case SHARED_FOLDER: - fileGridModel = (FolderGridModel) new FolderGridModel(item.getId(), item.getName(), toDate(item.getCreationDate()), parentFileModel, -1, true, false); +// fileGridModel = (FolderGridModel) new FolderGridModel(item.getId(), item.getName(), toDate(item.getCreationDate()), parentFileModel, -1, true, false); + fileGridModel = (FolderGridModel) new FolderGridModel(item.getId(), item.getName(), toDate(item.getLastModified()), parentFileModel, -1, true, true); fileGridModel.setType(GXTFolderItemTypeEnum.SHARED_FOLDER.toString()); fileGridModel.setShortcutCategory(GXTCategoryItemInterface.SMF_DOCUMENTS); fileGridModel.setShareable(true); @@ -1032,11 +1037,29 @@ public class GWTWorkspaceBuilder { } - //TODO SETTING OWNER, ISSHARED IN SEARCH ITEM + //TODO ISSHARED IN SEARCH ITEM IN HL //ACCOUNTING // fileGridModel.setMarkAsRead(item.isMarkedAsRead()); + + //OWNER + if(fileGridModel.isShared()){ //IS READ FROM HL ONLY IF THE ITEM IS SHARED + String portalLogin = item.getOwner(); + if(portalLogin!=null){ + String fullName = portalLogin; + + if(!WsUtil.withoutPortal) //INTO PORTAL + fullName = UserUtil.getUserFullName(portalLogin); + + fileGridModel.setOwnerFullName(fullName); + } + } + else{ + if(userLogged!=null) + fileGridModel.setOwnerFullName(userLogged.getName()); + } + return fileGridModel; } @@ -1067,7 +1090,9 @@ public class GWTWorkspaceBuilder { switch (item.getType()) { case FOLDER: - fileGridModel = (FolderGridModel) new FolderGridModel(item.getId(), item.getName(), toDate(item.getCreationTime()), parentFileModel, -1, true, false); +// fileGridModel = (FolderGridModel) new FolderGridModel(item.getId(), item.getName(), toDate(item.getCreationTime()), parentFileModel, -1, true, false); + + fileGridModel = (FolderGridModel) new FolderGridModel(item.getId(), item.getName(), toDate(item.getLastModificationTime()), parentFileModel, -1, true, false); fileGridModel.setType(GXTFolderItemTypeEnum.FOLDER.toString()); fileGridModel.setShortcutCategory(GXTCategoryItemInterface.SMF_DOCUMENTS); fileGridModel.setShareable(true); @@ -1077,12 +1102,14 @@ public class GWTWorkspaceBuilder { case FOLDER_ITEM: FolderItem folderItem = (FolderItem) item; - fileGridModel = new FileGridModel(item.getId(), item.getName(), toDate(item.getCreationTime()), parentFileModel, folderItem.getLength(), false, false); +// fileGridModel = new FileGridModel(item.getId(), item.getName(), toDate(item.getCreationTime()), parentFileModel, folderItem.getLength(), false, false); + fileGridModel = new FileGridModel(item.getId(), item.getName(), toDate(item.getLastModificationTime()), parentFileModel, folderItem.getLength(), false, false); fileGridModel = (FileGridModel) setFolderItemType(fileGridModel, folderItem); break; case SHARED_FOLDER: - fileGridModel = (FolderGridModel) new FolderGridModel(item.getId(), item.getName(), toDate(item.getCreationTime()), parentFileModel, -1, true, true); +// fileGridModel = (FolderGridModel) new FolderGridModel(item.getId(), item.getName(), toDate(item.getCreationTime()), parentFileModel, -1, true, true); + fileGridModel = (FolderGridModel) new FolderGridModel(item.getId(), item.getName(), toDate(item.getLastModificationTime()), parentFileModel, -1, true, true); fileGridModel.setType(GXTFolderItemTypeEnum.SHARED_FOLDER.toString()); fileGridModel.setShortcutCategory(GXTCategoryItemInterface.SMF_DOCUMENTS); fileGridModel.setShareable(true); 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 1b0ae56..935fe21 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 @@ -211,7 +211,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT workspaceLogger.trace("Call search HL.."); - listFileGridModels = builder.buildGXTListFileGridModelItemForSearch(listSearchItems, null); + listFileGridModels = builder.buildGXTListFileGridModelItemForSearch(listSearchItems); workspaceLogger.trace("Search converted, completed..."); return listFileGridModels; @@ -963,7 +963,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT workspaceLogger.trace(" children size "+wsSmartFolder.getSearchItems().size()); - return builder.buildGXTListFileGridModelItemForSearch((List) wsSmartFolder.getSearchItems(), null); + return builder.buildGXTListFileGridModelItemForSearch((List) wsSmartFolder.getSearchItems()); } catch (Exception e) { workspaceLogger.error("Error in get server smart folder by id", e); diff --git a/src/main/java/org/gcube/portlets/user/workspace/server/util/WsUtil.java b/src/main/java/org/gcube/portlets/user/workspace/server/util/WsUtil.java index 361aec3..a35254a 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/server/util/WsUtil.java +++ b/src/main/java/org/gcube/portlets/user/workspace/server/util/WsUtil.java @@ -74,10 +74,10 @@ public class WsUtil { /*USE ANOTHER ACCOUNT (OTHERWHISE BY TEST_USER) FOR RUNNING * COMMENT THIS IN DEVELOP ENVIROMENT (UNCOMMENT IN PRODUCTION)*/ - user=TEST_USER; +// user=TEST_USER; //UNCOMMENT THIS IN DEVELOP ENVIROMENT -// user = "francesco.mangiacrapa"; + user = "francesco.mangiacrapa"; logger.warn("WORKSPACE PORTLET STARTING IN TEST MODE - NO USER FOUND - PORTLETS STARTING WITH FOLLOWING SETTINGS:"); logger.warn("session id: "+sessionID); diff --git a/src/test/java/org/gcube/portlets/user/workspace/SearchTextTest.java b/src/test/java/org/gcube/portlets/user/workspace/SearchTextTest.java new file mode 100644 index 0000000..b813d20 --- /dev/null +++ b/src/test/java/org/gcube/portlets/user/workspace/SearchTextTest.java @@ -0,0 +1,76 @@ +/** + * + */ +package org.gcube.portlets.user.workspace; + +import java.util.List; + +import org.apache.log4j.Logger; +import org.gcube.common.homelibrary.home.HomeLibrary; +import org.gcube.common.homelibrary.home.workspace.Workspace; +import org.gcube.common.homelibrary.home.workspace.WorkspaceItemType; +import org.gcube.common.homelibrary.home.workspace.search.SearchFolder; +import org.gcube.common.homelibrary.home.workspace.search.SearchFolderItem; +import org.gcube.common.homelibrary.home.workspace.search.SearchItem; +import org.gcube.common.scope.api.ScopeProvider; +import org.gcube.common.scope.impl.ScopeBean; + +/** + * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it + * @Jul 3, 2013 + * + */ +public class SearchTextTest { + + + protected static Logger logger = Logger.getLogger(SearchTextTest.class); + private static String text = "test"; + + public static void main(String[] args) { + + try { + + ScopeBean scope = new ScopeBean("/gcube/devsec"); + ScopeProvider.instance.set(scope.toString()); + + Workspace ws = HomeLibrary + .getHomeManagerFactory() + .getHomeManager() + .getHome("francesco.mangiacrapa") + .getWorkspace(); + // + + List listSearchItems = ws.searchByName(text); + + System.out.println("Total item founds: "+listSearchItems.size()); + + int i=0; + for (SearchItem searchItem : listSearchItems) { + + + if(searchItem.getType().equals(WorkspaceItemType.FOLDER) || searchItem.getType().equals(WorkspaceItemType.SHARED_FOLDER)){ + + SearchFolder folder = (SearchFolder) searchItem; + + System.out.println(++i+") folder name: "+folder.getName() + " type: "+folder.getType()); + }else{ + + + if(searchItem.getType().equals(WorkspaceItemType.FOLDER_ITEM)){ + + SearchFolderItem folderItem = (SearchFolderItem) searchItem; + + System.out.println(++i+") folderItem id: "+folderItem.getId() +", name: "+folderItem.getName()+", type: "+folderItem.getType()); + } + + } + } + System.out.println("end"); + } catch (Exception e) { + e.printStackTrace(); + } + } + + + +}