From 62bfa20b60694b478d14c41737429444efe69247 Mon Sep 17 00:00:00 2001 From: Francesco Mangiacrapa Date: Thu, 23 Feb 2017 14:42:16 +0000 Subject: [PATCH] Enhancement on file versioning #7006 git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace-tree-widget@144198 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../client/model/FileVersionModel.java | 30 ++++++++++++++++++- .../workspace/server/GWTWorkspaceBuilder.java | 2 +- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/model/FileVersionModel.java b/src/main/java/org/gcube/portlets/user/workspace/client/model/FileVersionModel.java index 9e8b194..1fdd24f 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/model/FileVersionModel.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/model/FileVersionModel.java @@ -19,6 +19,7 @@ public class FileVersionModel extends FileModel { public static final String PATH = "path"; public static final String USER_VERSIONING = "user_versioning"; public static final String CREATED = "created"; + public static final String IS_CURRENT_VERSION = "is_current_version"; /** * Instantiates a new file model. @@ -34,17 +35,30 @@ public class FileVersionModel extends FileModel { * @param path the path * @param userFullName the user full name * @param created the created + * @param isCurrentVersion the is current version */ - public FileVersionModel(String identifier, String name, String path, String userFullName, Date created) { + public FileVersionModel(String identifier, String name, String path, String userFullName, Date created, Boolean isCurrentVersion) { setIdentifier(identifier); setName(name); setPath(path); setUser(userFullName); setCreated(created); + setIsCurrentVersion(isCurrentVersion); super.initDefaultProperties(); } + /** + * Sets the checks if is current version. + * + * @param isCurrentVersion the new checks if is current version + */ + private void setIsCurrentVersion(Boolean isCurrentVersion) { + + set(IS_CURRENT_VERSION, isCurrentVersion); + + } + /** * Sets the created. * @@ -101,4 +115,18 @@ public class FileVersionModel extends FileModel { public String getUser(){ return get(USER_VERSIONING); } + + + /** + * Checks if is current version. + * + * @return the boolean + */ + public Boolean isCurrentVersion(){ + Object obj = get(IS_CURRENT_VERSION); + if(obj==null) + return false; + + return (Boolean) get(IS_CURRENT_VERSION); + } } 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 cbe368b..ab631d0 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 @@ -2246,7 +2246,7 @@ public class GWTWorkspaceBuilder { List listVersions = new ArrayList(versions.size()); for (WorkspaceVersion wsVersion : versions) { String user = UserUtil.getUserFullName(wsVersion.getUser()); - FileVersionModel file = new FileVersionModel(wsVersion.getName(), wsVersion.getName(), wsVersion.getRemotePath(), user, toDate(wsVersion.getCreated())); + FileVersionModel file = new FileVersionModel(wsVersion.getName(), wsVersion.getName(), wsVersion.getRemotePath(), user, toDate(wsVersion.getCreated()), wsVersion.isCurrentVersion()); listVersions.add(file); } return listVersions;