From 65d417e2553b3290d28506c9a4acc1e5d32c0ad9 Mon Sep 17 00:00:00 2001 From: Patel Date: Tue, 28 Nov 2017 16:14:05 -0500 Subject: [PATCH 1/8] #17 flyway database migration --- .../main/resources/migrations/V1.0.1__BasicAdvance_version.sql | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 src/metalnx-tools/src/main/resources/migrations/V1.0.1__BasicAdvance_version.sql diff --git a/src/metalnx-tools/src/main/resources/migrations/V1.0.1__BasicAdvance_version.sql b/src/metalnx-tools/src/main/resources/migrations/V1.0.1__BasicAdvance_version.sql new file mode 100644 index 000000000..9486a81c6 --- /dev/null +++ b/src/metalnx-tools/src/main/resources/migrations/V1.0.1__BasicAdvance_version.sql @@ -0,0 +1,3 @@ +ALTER TABLE users +ADD COLUMN advanced_view BOOLEAN NOT NULL +DEFAULT FALSE; \ No newline at end of file From b376b48fa3b2b170e21e0b6459f4063959bc889b Mon Sep 17 00:00:00 2001 From: Patel Date: Thu, 30 Nov 2017 10:26:16 -0500 Subject: [PATCH 2/8] #17 added advanced view logic --- .../emc/metalnx/core/domain/dao/UserDao.java | 9 +++++++++ .../core/domain/entity/DataGridUser.java | 20 ++++++++++++++++++- .../services/irods/UserServiceImpl.java | 1 + .../controller/PreferencesController.java | 1 + .../preferences/UserPreferences.java | 9 ++++++++- .../resources/i18n/messages_en.properties | 1 + .../resources/views/preferences/index.html | 5 +++++ 7 files changed, 44 insertions(+), 2 deletions(-) diff --git a/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/dao/UserDao.java b/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/dao/UserDao.java index 090758468..fd1337446 100755 --- a/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/dao/UserDao.java +++ b/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/dao/UserDao.java @@ -73,4 +73,13 @@ public interface UserDao extends GenericDao { * @return list of users */ public List findByQueryString(String query); + + /** + * Update advancedView by username + * @param username + * @param zone + * @return boolean that is true for advanced view, otherwise is normal view + */ + //boolean updateAdvancedView(DataGridUser user); + } diff --git a/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridUser.java b/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridUser.java index 095c9c76b..f152bfe34 100755 --- a/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridUser.java +++ b/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridUser.java @@ -82,6 +82,9 @@ public class DataGridUser implements Serializable, Comparable { @Column(name = "user_title", nullable = true, length = 60) private String title; + + @Column(name = "advanced_view", nullable =false) + private boolean advancedView; @OneToMany(mappedBy = "user", fetch = FetchType.EAGER, cascade = CascadeType.DETACH, orphanRemoval = true) private Set bookmarks; @@ -194,6 +197,13 @@ public String getAdditionalInfo() { public boolean isEnabled() { return enabled; } + + /** + * @return the advanced_view + */ + public boolean isAdvancedView() { + return advancedView; + } /** * @param id @@ -234,7 +244,15 @@ public void setAdditionalInfo(String additionalInfo) { public void setEnabled(boolean enabled) { this.enabled = enabled; } - + + /** + * @param advancedView + * to set + */ + public void setAdvanceView(boolean advancedView) { + this.advancedView = advancedView; + } + /** * @return the firstName */ diff --git a/src/emc-metalnx-services/src/main/java/com/emc/metalnx/services/irods/UserServiceImpl.java b/src/emc-metalnx-services/src/main/java/com/emc/metalnx/services/irods/UserServiceImpl.java index 060f46507..05981c8c6 100755 --- a/src/emc-metalnx-services/src/main/java/com/emc/metalnx/services/irods/UserServiceImpl.java +++ b/src/emc-metalnx-services/src/main/java/com/emc/metalnx/services/irods/UserServiceImpl.java @@ -196,6 +196,7 @@ public boolean modifyUser(DataGridUser modifyUser) throws DataGridConnectionRefu applicationUser.setOrganizationalRole(modifyUser.getOrganizationalRole()); applicationUser.setUserType(modifyUser.getUserType()); applicationUser.setForceFileOverwriting(modifyUser.isForceFileOverwriting()); + applicationUser.setAdvanceView(modifyUser.isAdvancedView()); userDao.merge(applicationUser); // Changing password if a new password is set diff --git a/src/emc-metalnx-shared/src/main/java/com/emc/metalnx/controller/PreferencesController.java b/src/emc-metalnx-shared/src/main/java/com/emc/metalnx/controller/PreferencesController.java index 5eca9719e..a0b8e5cbc 100755 --- a/src/emc-metalnx-shared/src/main/java/com/emc/metalnx/controller/PreferencesController.java +++ b/src/emc-metalnx-shared/src/main/java/com/emc/metalnx/controller/PreferencesController.java @@ -88,6 +88,7 @@ public String action(final Model model, @ModelAttribute final UserPreferences pr DataGridUser loggedUser = loggedUserUtils.getLoggedDataGridUser(); loggedUser.setLocale(preferences.getLocaleLanguage()); loggedUser.setForceFileOverwriting(preferences.isForceFileOverwriting()); + loggedUser.setAdvanceView(preferences.isAdvancedView()); userService.modifyUser(loggedUser); localeResolver.setLocale(request, response, StringUtils.parseLocaleString(preferences.getLocaleLanguage())); diff --git a/src/emc-metalnx-shared/src/main/java/com/emc/metalnx/modelattribute/preferences/UserPreferences.java b/src/emc-metalnx-shared/src/main/java/com/emc/metalnx/modelattribute/preferences/UserPreferences.java index ec19dfafb..837c7af38 100755 --- a/src/emc-metalnx-shared/src/main/java/com/emc/metalnx/modelattribute/preferences/UserPreferences.java +++ b/src/emc-metalnx-shared/src/main/java/com/emc/metalnx/modelattribute/preferences/UserPreferences.java @@ -20,6 +20,7 @@ public class UserPreferences { private String localeLanguage; private boolean forceFileOverwriting; + private boolean advancedView; /** * Returns whether forceFileOverwriting is set or not @@ -53,5 +54,11 @@ public String getLocaleLanguage() { public void setLocaleLanguage(final String localeLanguage) { this.localeLanguage = localeLanguage; } - + + /** + * @return the boolean that is true for advanced view, otherwise is normal view + */ + public boolean isAdvancedView() { + return advancedView; + } } diff --git a/src/emc-metalnx-shared/src/main/resources/i18n/messages_en.properties b/src/emc-metalnx-shared/src/main/resources/i18n/messages_en.properties index df0e9e23a..b35c60f8f 100644 --- a/src/emc-metalnx-shared/src/main/resources/i18n/messages_en.properties +++ b/src/emc-metalnx-shared/src/main/resources/i18n/messages_en.properties @@ -820,6 +820,7 @@ login.copyright=© 2015-2017 DELL EMC All rights reserved. #prefrences refrences.index.overwrite.duplicates=Overwrite duplicate files by default +refrences.index.advanced.view=Change to advanced view #template template.management.not.modified=Sorry. The template could not be modified. diff --git a/src/emc-metalnx-shared/src/main/resources/views/preferences/index.html b/src/emc-metalnx-shared/src/main/resources/views/preferences/index.html index b6217f274..b96888776 100755 --- a/src/emc-metalnx-shared/src/main/resources/views/preferences/index.html +++ b/src/emc-metalnx-shared/src/main/resources/views/preferences/index.html @@ -51,9 +51,14 @@

+ +

+

+

+ From 0ce3055bf85b6596453ce9553da5490a20165464 Mon Sep 17 00:00:00 2001 From: Mike Conway Date: Thu, 30 Nov 2017 10:32:59 -0500 Subject: [PATCH 3/8] #17 extra div tag --- .../src/main/resources/views/preferences/index.html | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/emc-metalnx-shared/src/main/resources/views/preferences/index.html b/src/emc-metalnx-shared/src/main/resources/views/preferences/index.html index b96888776..5f282aec6 100755 --- a/src/emc-metalnx-shared/src/main/resources/views/preferences/index.html +++ b/src/emc-metalnx-shared/src/main/resources/views/preferences/index.html @@ -51,16 +51,15 @@

- +

- +

- + -
From df3cea515dda1bf0f8a97211ee3c85e35651fe58 Mon Sep 17 00:00:00 2001 From: Patel Date: Thu, 30 Nov 2017 10:40:56 -0500 Subject: [PATCH 4/8] #17 message fixed --- .../src/main/resources/views/preferences/index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/emc-metalnx-shared/src/main/resources/views/preferences/index.html b/src/emc-metalnx-shared/src/main/resources/views/preferences/index.html index 5f282aec6..765981e25 100755 --- a/src/emc-metalnx-shared/src/main/resources/views/preferences/index.html +++ b/src/emc-metalnx-shared/src/main/resources/views/preferences/index.html @@ -51,11 +51,11 @@

- +

- +

From 76d7fe7c0947f76c798c05bce9778e37444c4c9c Mon Sep 17 00:00:00 2001 From: Mike Conway Date: Thu, 30 Nov 2017 10:56:53 -0500 Subject: [PATCH 5/8] #17 fix msg --- .../src/main/resources/i18n/messages_en.properties | 5 ++--- .../src/main/resources/views/preferences/index.html | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/emc-metalnx-shared/src/main/resources/i18n/messages_en.properties b/src/emc-metalnx-shared/src/main/resources/i18n/messages_en.properties index 04d12d9a3..96a002056 100644 --- a/src/emc-metalnx-shared/src/main/resources/i18n/messages_en.properties +++ b/src/emc-metalnx-shared/src/main/resources/i18n/messages_en.properties @@ -388,6 +388,8 @@ preferences.page.title=Preferences preferences.panel.title=System Settings preferences.language.label=Language preferences.save.button.label=Save +preferences.index.advanced.view=Advanced View (If not indicated shows normal view) +preferences.index.overwrite.duplicates=Overwrite duplicate files #Collections collections.menu.title=Collections @@ -820,9 +822,6 @@ login.copyright=© 2015-2017 DELL EMC All rights reserved. #permissions #It has title and text - test and update if needed -#prefrences -refrences.index.overwrite.duplicates=Overwrite duplicate files by default -refrences.index.advanced.view=Change to advanced view #template template.management.not.modified=Sorry. The template could not be modified. diff --git a/src/emc-metalnx-shared/src/main/resources/views/preferences/index.html b/src/emc-metalnx-shared/src/main/resources/views/preferences/index.html index 765981e25..460d41126 100755 --- a/src/emc-metalnx-shared/src/main/resources/views/preferences/index.html +++ b/src/emc-metalnx-shared/src/main/resources/views/preferences/index.html @@ -51,11 +51,11 @@

- +

- +

From 9698fa0aa29f71bba7a322a8371b5d264fdde47b Mon Sep 17 00:00:00 2001 From: Mike Conway Date: Thu, 30 Nov 2017 11:21:58 -0500 Subject: [PATCH 6/8] #17 add tostring to entity --- .../domain/entity/DataGridFilePermission.java | 99 +- .../entity/DataGridFilePropertySearch.java | 14 +- .../core/domain/entity/DataGridGroup.java | 304 +++--- .../domain/entity/DataGridGroupBookmark.java | 352 ++++--- .../entity/DataGridGroupPermission.java | 101 +- .../domain/entity/DataGridMSIPkgInfo.java | 67 +- .../core/domain/entity/DataGridMetadata.java | 46 +- .../domain/entity/DataGridMetadataFields.java | 84 +- .../domain/entity/DataGridMetadataSearch.java | 180 ++-- .../domain/entity/DataGridPageContext.java | 26 +- .../core/domain/entity/DataGridResource.java | 981 +++++++++--------- .../domain/entity/DataGridResourceType.java | 125 ++- .../core/domain/entity/DataGridRule.java | 369 +++---- .../core/domain/entity/DataGridServer.java | 350 ++++--- .../domain/entity/DataGridSpecificQuery.java | 30 +- .../core/domain/entity/DataGridTemplate.java | 562 +++++----- .../domain/entity/DataGridTemplateField.java | 554 +++++----- .../core/domain/entity/DataGridTicket.java | 519 ++++----- .../core/domain/entity/DataGridUser.java | 891 +++++++++------- .../domain/entity/DataGridUserBookmark.java | 355 ++++--- .../domain/entity/DataGridUserFavorite.java | 364 ++++--- .../domain/entity/DataGridUserPermission.java | 132 ++- .../core/domain/entity/DataGridZone.java | 73 +- .../core/domain/entity/UserProfile.java | 99 +- .../controller/PreferencesController.java | 13 +- .../preferences/UserPreferences.java | 21 +- .../src/main/resources/log4j.properties | 2 +- 27 files changed, 3803 insertions(+), 2910 deletions(-) diff --git a/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridFilePermission.java b/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridFilePermission.java index 842d574c1..3e32c3a76 100755 --- a/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridFilePermission.java +++ b/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridFilePermission.java @@ -18,55 +18,78 @@ import java.io.Serializable; public class DataGridFilePermission implements Serializable { - private String userId; - private String username; - private String permission; - private String userType; - private String userZone; - private static final long serialVersionUID = 1L; + private String userId; + private String username; + private String permission; + private String userType; + private String userZone; + private static final long serialVersionUID = 1L; - public DataGridFilePermission() { + public DataGridFilePermission() { - } + } - public String getPermission() { - return permission; - } + public String getPermission() { + return permission; + } - public void setPermission(String permission) { - this.permission = permission; - } + public void setPermission(String permission) { + this.permission = permission; + } - public String getUsername() { - return username; - } + public String getUsername() { + return username; + } - public void setUsername(String username) { - this.username = username; - } + public void setUsername(String username) { + this.username = username; + } - public String getUserId() { - return userId; - } + public String getUserId() { + return userId; + } - public void setUserId(String userId) { - this.userId = userId; - } + public void setUserId(String userId) { + this.userId = userId; + } - public String getUserZone() { - return userZone; - } + public String getUserZone() { + return userZone; + } - public void setUserZone(String userZone) { - this.userZone = userZone; - } + public void setUserZone(String userZone) { + this.userZone = userZone; + } - public String getUserType() { - return userType; - } + public String getUserType() { + return userType; + } - public void setUserType(String userType) { - this.userType = userType; - } + public void setUserType(String userType) { + this.userType = userType; + } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("DataGridFilePermission ["); + if (userId != null) { + builder.append("userId=").append(userId).append(", "); + } + if (username != null) { + builder.append("username=").append(username).append(", "); + } + if (permission != null) { + builder.append("permission=").append(permission).append(", "); + } + if (userType != null) { + builder.append("userType=").append(userType).append(", "); + } + if (userZone != null) { + builder.append("userZone=").append(userZone); + } + builder.append("]"); + return builder.toString(); + } } \ No newline at end of file diff --git a/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridFilePropertySearch.java b/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridFilePropertySearch.java index b0b3d32d1..29b488693 100755 --- a/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridFilePropertySearch.java +++ b/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridFilePropertySearch.java @@ -42,7 +42,19 @@ public DataGridFilePropertySearch(FilePropertyField filePropertyField, DataGridS @Override public String toString() { - return String.format("%s %s %s", attribute.getFieldName(), operator.toString(), value); + StringBuilder builder = new StringBuilder(); + builder.append("DataGridFilePropertySearch ["); + if (attribute != null) { + builder.append("attribute=").append(attribute).append(", "); + } + if (operator != null) { + builder.append("operator=").append(operator).append(", "); + } + if (value != null) { + builder.append("value=").append(value); + } + builder.append("]"); + return builder.toString(); } /** diff --git a/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridGroup.java b/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridGroup.java index 8e3d92bae..8f7868f36 100755 --- a/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridGroup.java +++ b/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridGroup.java @@ -15,140 +15,190 @@ */ package com.emc.metalnx.core.domain.entity; -import com.fasterxml.jackson.annotation.JsonIgnore; +import java.io.Serializable; +import java.util.Collection; +import java.util.Iterator; +import java.util.Set; + +import javax.persistence.CascadeType; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.JoinTable; +import javax.persistence.ManyToMany; +import javax.persistence.OneToMany; +import javax.persistence.Table; + import org.hibernate.envers.Audited; import org.hibernate.envers.NotAudited; -import javax.persistence.*; -import java.io.Serializable; -import java.util.Set; +import com.fasterxml.jackson.annotation.JsonIgnore; @Entity @Audited @Table(name = "groups") public class DataGridGroup implements Serializable, Comparable { - private static final long serialVersionUID = 1L; - - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - @NotAudited - @Column(name = "id", unique = true, nullable = false) - private Long id; - - @Column(name = "data_grid_id", unique = true, nullable = false) - private long dataGridId; - - @Column(name = "groupname", unique = true, nullable = false, length = 60) - private String groupname; - - @Column(name = "additional_info", nullable = true, length = 60) - private String additional_info; - - @ManyToMany(fetch = FetchType.EAGER, cascade = { CascadeType.PERSIST }) - @JoinTable(name = "user_profile_groups", joinColumns = { @JoinColumn(name = "group_id") }, inverseJoinColumns = { @JoinColumn(name = "profile_id") }) - private Set userProfiles; - - @JsonIgnore - @OneToMany(mappedBy = "group", fetch = FetchType.EAGER, cascade = CascadeType.DETACH, orphanRemoval = true) - private Set groupBookmarks; - - public DataGridGroup() { - - } - - public DataGridGroup(String groupname, String additional_info) { - this.groupname = groupname; - this.additional_info = additional_info; - } - - public String getDisplayName() { - - return groupname; - } - - /** - * @return the id - */ - public long getId() { - return id; - } - - /** - * @return the dataGridId - */ - public long getDataGridId() { - return dataGridId; - } - - /** - * @param id - * the id to set - */ - public void setId(long id) { - this.id = id; - } - - /** - * @param dataGridId - * the dataGridId to set - */ - public void setDataGridId(long dataGridId) { - this.dataGridId = dataGridId; - } - - /** - * @return the groupName - */ - public String getGroupname() { - return groupname; - } - - /** - * @param the - * groupName to set - */ - public void setGroupname(String groupName) { - groupname = groupName; - } - - /** - * @return group's zone - */ - public String getAdditionalInfo() { - return additional_info; - } - - /** - * @param the - * zone to set - */ - public void setAdditionalInfo(String additional_info) { - this.additional_info = additional_info; - } - - /** - * @return the groupBookmarks - */ - public Set getGroupBookmarks() { - return groupBookmarks; - } - - /** - * @param groupBookmarks - * the groupBookmarks to set - */ - public void setGroupBookmarks(Set groupBookmarks) { - this.groupBookmarks = groupBookmarks; - } - - @Override - public int compareTo(DataGridGroup dgg) { - return groupname.compareTo(dgg.getGroupname()); - } - - @Override - public String toString() { - return groupname; - } + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @NotAudited + @Column(name = "id", unique = true, nullable = false) + private Long id; + + @Column(name = "data_grid_id", unique = true, nullable = false) + private long dataGridId; + + @Column(name = "groupname", unique = true, nullable = false, length = 60) + private String groupname; + + @Column(name = "additional_info", nullable = true, length = 60) + private String additional_info; + + @ManyToMany(fetch = FetchType.EAGER, cascade = { CascadeType.PERSIST }) + @JoinTable(name = "user_profile_groups", joinColumns = { @JoinColumn(name = "group_id") }, inverseJoinColumns = { + @JoinColumn(name = "profile_id") }) + private Set userProfiles; + + @JsonIgnore + @OneToMany(mappedBy = "group", fetch = FetchType.EAGER, cascade = CascadeType.DETACH, orphanRemoval = true) + private Set groupBookmarks; + + public DataGridGroup() { + + } + + public DataGridGroup(String groupname, String additional_info) { + this.groupname = groupname; + this.additional_info = additional_info; + } + + public String getDisplayName() { + + return groupname; + } + + /** + * @return the id + */ + public long getId() { + return id; + } + + /** + * @return the dataGridId + */ + public long getDataGridId() { + return dataGridId; + } + + /** + * @param id + * the id to set + */ + public void setId(long id) { + this.id = id; + } + + /** + * @param dataGridId + * the dataGridId to set + */ + public void setDataGridId(long dataGridId) { + this.dataGridId = dataGridId; + } + + /** + * @return the groupName + */ + public String getGroupname() { + return groupname; + } + + /** + * @param the + * groupName to set + */ + public void setGroupname(String groupName) { + groupname = groupName; + } + + /** + * @return group's zone + */ + public String getAdditionalInfo() { + return additional_info; + } + + /** + * @param the + * zone to set + */ + public void setAdditionalInfo(String additional_info) { + this.additional_info = additional_info; + } + + /** + * @return the groupBookmarks + */ + public Set getGroupBookmarks() { + return groupBookmarks; + } + + /** + * @param groupBookmarks + * the groupBookmarks to set + */ + public void setGroupBookmarks(Set groupBookmarks) { + this.groupBookmarks = groupBookmarks; + } + + @Override + public int compareTo(DataGridGroup dgg) { + return groupname.compareTo(dgg.getGroupname()); + } + + @Override + public String toString() { + final int maxLen = 10; + StringBuilder builder = new StringBuilder(); + builder.append("DataGridGroup ["); + if (id != null) { + builder.append("id=").append(id).append(", "); + } + builder.append("dataGridId=").append(dataGridId).append(", "); + if (groupname != null) { + builder.append("groupname=").append(groupname).append(", "); + } + if (additional_info != null) { + builder.append("additional_info=").append(additional_info).append(", "); + } + if (userProfiles != null) { + builder.append("userProfiles=").append(toString(userProfiles, maxLen)).append(", "); + } + if (groupBookmarks != null) { + builder.append("groupBookmarks=").append(toString(groupBookmarks, maxLen)); + } + builder.append("]"); + return builder.toString(); + } + + private String toString(Collection collection, int maxLen) { + StringBuilder builder = new StringBuilder(); + builder.append("["); + int i = 0; + for (Iterator iterator = collection.iterator(); iterator.hasNext() && i < maxLen; i++) { + if (i > 0) { + builder.append(", "); + } + builder.append(iterator.next()); + } + builder.append("]"); + return builder.toString(); + } } diff --git a/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridGroupBookmark.java b/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridGroupBookmark.java index a8451a848..fafe95111 100755 --- a/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridGroupBookmark.java +++ b/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridGroupBookmark.java @@ -15,171 +15,209 @@ */ package com.emc.metalnx.core.domain.entity; -import com.emc.metalnx.core.domain.utils.DataGridCoreUtils; -import org.hibernate.envers.Audited; -import org.hibernate.envers.NotAudited; - -import javax.persistence.*; import java.io.Serializable; import java.text.SimpleDateFormat; import java.util.Date; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + +import org.hibernate.envers.Audited; +import org.hibernate.envers.NotAudited; + +import com.emc.metalnx.core.domain.utils.DataGridCoreUtils; + @Entity @Audited @Table(name = "group_bookmarks") public class DataGridGroupBookmark implements Serializable, Comparable { - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - @NotAudited - @Column(name = "id", unique = true, nullable = false) - private Long id; - - @ManyToOne(fetch = FetchType.EAGER, optional = true) - @JoinColumn(name = "group_id", nullable = false, updatable = true) - private DataGridGroup group; - - @Column(name = "path", nullable = false, length = 512) - private String path; - - @Column(name = "is_notified", nullable = true) - private Boolean isNotified; - - @Column(name = "is_collection", nullable = true) - private Boolean isCollection; - - @Temporal(TemporalType.TIMESTAMP) - @Column(name = "created_at", nullable = false, length = 60, updatable = false) - private Date createTs; - - private static final long serialVersionUID = -229875209906357557L; - - /** - * @return the id - */ - public Long getId() { - return id; - } - - /** - * @return the group - */ - public DataGridGroup getGroup() { - return group; - } - - /** - * @return the path - */ - public String getPath() { - return path; - } - - /** - * @return the isNotified - */ - public Boolean getIsNotified() { - return isNotified; - } - - /** - * @return the createTs - */ - public Date getCreateTs() { - return createTs; - } - - /** - * @param id - * the id to set - */ - public void setId(Long id) { - this.id = id; - } - - /** - * @param group - * the group to set - */ - public void setGroup(DataGridGroup group) { - this.group = group; - } - - /** - * @param path - * the path to set - */ - public void setPath(String path) { - this.path = path; - } - - /** - * @param isNotified - * the isNotified to set - */ - public void setIsNotified(Boolean isNotified) { - this.isNotified = isNotified; - } - - /** - * @return the isCollection - */ - public Boolean getIsCollection() { - return isCollection; - } - - /** - * @param isCollection - * the isCollection to set - */ - public void setIsCollection(Boolean isCollection) { - this.isCollection = isCollection; - } - - /** - * @param createTs - * the createTs to set - */ - public void setCreateTs(Date createTs) { - this.createTs = createTs; - } - - /** - * Finds the file name based on its path - * - * @return file name - */ - public String getFileName() { - if (getPath() == null) { - return new String(); - } - - String fileName = getPath() != null ? getPath() : ""; - fileName = fileName.substring(fileName.lastIndexOf("/") + 1, fileName.length()); - return fileName; - } - - /** - * Gets the icon to be displayed for a bookmarks based on its extension - * - * @return String containing the icon name to be displayed - */ - public String getDisplayIcon() { - return DataGridCoreUtils.getIconToDisplay(getPath()); - } - - /** - * Formats the date when a collection/data object was modified - * - * @return String in the format MM/DD/YYYY HH:MM - */ - public String getCreatedAtFormatted() { - return new SimpleDateFormat("MMM dd yyyy, HH:mm").format(createTs); - } - - @Override - public int compareTo(DataGridGroupBookmark dgub) { - return getFileName().compareTo(dgub.getFileName()); - } + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @NotAudited + @Column(name = "id", unique = true, nullable = false) + private Long id; + + @ManyToOne(fetch = FetchType.EAGER, optional = true) + @JoinColumn(name = "group_id", nullable = false, updatable = true) + private DataGridGroup group; + + @Column(name = "path", nullable = false, length = 512) + private String path; + + @Column(name = "is_notified", nullable = true) + private Boolean isNotified; + + @Column(name = "is_collection", nullable = true) + private Boolean isCollection; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name = "created_at", nullable = false, length = 60, updatable = false) + private Date createTs; + + private static final long serialVersionUID = -229875209906357557L; + + /** + * @return the id + */ + public Long getId() { + return id; + } + + /** + * @return the group + */ + public DataGridGroup getGroup() { + return group; + } + + /** + * @return the path + */ + public String getPath() { + return path; + } + + /** + * @return the isNotified + */ + public Boolean getIsNotified() { + return isNotified; + } + + /** + * @return the createTs + */ + public Date getCreateTs() { + return createTs; + } + + /** + * @param id + * the id to set + */ + public void setId(Long id) { + this.id = id; + } + + /** + * @param group + * the group to set + */ + public void setGroup(DataGridGroup group) { + this.group = group; + } + + /** + * @param path + * the path to set + */ + public void setPath(String path) { + this.path = path; + } + + /** + * @param isNotified + * the isNotified to set + */ + public void setIsNotified(Boolean isNotified) { + this.isNotified = isNotified; + } + + /** + * @return the isCollection + */ + public Boolean getIsCollection() { + return isCollection; + } + + /** + * @param isCollection + * the isCollection to set + */ + public void setIsCollection(Boolean isCollection) { + this.isCollection = isCollection; + } + + /** + * @param createTs + * the createTs to set + */ + public void setCreateTs(Date createTs) { + this.createTs = createTs; + } + + /** + * Finds the file name based on its path + * + * @return file name + */ + public String getFileName() { + if (getPath() == null) { + return new String(); + } + + String fileName = getPath() != null ? getPath() : ""; + fileName = fileName.substring(fileName.lastIndexOf("/") + 1, fileName.length()); + return fileName; + } + + /** + * Gets the icon to be displayed for a bookmarks based on its extension + * + * @return String containing the icon name to be displayed + */ + public String getDisplayIcon() { + return DataGridCoreUtils.getIconToDisplay(getPath()); + } + + /** + * Formats the date when a collection/data object was modified + * + * @return String in the format MM/DD/YYYY HH:MM + */ + public String getCreatedAtFormatted() { + return new SimpleDateFormat("MMM dd yyyy, HH:mm").format(createTs); + } + + @Override + public int compareTo(DataGridGroupBookmark dgub) { + return getFileName().compareTo(dgub.getFileName()); + } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("DataGridGroupBookmark ["); + if (id != null) { + builder.append("id=").append(id).append(", "); + } + if (group != null) { + builder.append("group=").append(group).append(", "); + } + if (path != null) { + builder.append("path=").append(path).append(", "); + } + if (isNotified != null) { + builder.append("isNotified=").append(isNotified).append(", "); + } + if (isCollection != null) { + builder.append("isCollection=").append(isCollection).append(", "); + } + if (createTs != null) { + builder.append("createTs=").append(createTs); + } + builder.append("]"); + return builder.toString(); + } } diff --git a/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridGroupPermission.java b/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridGroupPermission.java index 74512bde3..263205ec8 100755 --- a/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridGroupPermission.java +++ b/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridGroupPermission.java @@ -17,53 +17,70 @@ public class DataGridGroupPermission { - private Integer dataGridId; - private String groupName; - private String permission; + private Integer dataGridId; + private String groupName; + private String permission; - /** - * @return the dataGridId - */ - public Integer getDataGridId() { - return dataGridId; - } + /** + * @return the dataGridId + */ + public Integer getDataGridId() { + return dataGridId; + } - /** - * @return the groupName - */ - public String getGroupName() { - return groupName; - } + /** + * @return the groupName + */ + public String getGroupName() { + return groupName; + } - /** - * @return the permission - */ - public String getPermission() { - return permission; - } + /** + * @return the permission + */ + public String getPermission() { + return permission; + } - /** - * @param dataGridId - * the dataGridId to set - */ - public void setDataGridId(Integer dataGridId) { - this.dataGridId = dataGridId; - } + /** + * @param dataGridId + * the dataGridId to set + */ + public void setDataGridId(Integer dataGridId) { + this.dataGridId = dataGridId; + } - /** - * @param groupName - * the groupName to set - */ - public void setGroupName(String groupName) { - this.groupName = groupName; - } + /** + * @param groupName + * the groupName to set + */ + public void setGroupName(String groupName) { + this.groupName = groupName; + } - /** - * @param permission - * the permission to set - */ - public void setPermission(String permission) { - this.permission = permission; - } + /** + * @param permission + * the permission to set + */ + public void setPermission(String permission) { + this.permission = permission; + } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("DataGridGroupPermission ["); + if (dataGridId != null) { + builder.append("dataGridId=").append(dataGridId).append(", "); + } + if (groupName != null) { + builder.append("groupName=").append(groupName).append(", "); + } + if (permission != null) { + builder.append("permission=").append(permission); + } + builder.append("]"); + return builder.toString(); + } } diff --git a/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridMSIPkgInfo.java b/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridMSIPkgInfo.java index 6d523fc41..40f8b2206 100755 --- a/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridMSIPkgInfo.java +++ b/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridMSIPkgInfo.java @@ -16,43 +16,58 @@ package com.emc.metalnx.core.domain.entity; -import com.emc.metalnx.core.domain.utils.DataGridCoreUtils; - import java.util.List; +import com.emc.metalnx.core.domain.utils.DataGridCoreUtils; + /** * Represents the status of the MSI package on the grid. */ public class DataGridMSIPkgInfo { - private List servers; - private boolean isThereAnyPkgMissing; // MSI pkg is not installed in one or more servers - private boolean isThereAnyPkgNotSupported; // MSI Pkg is installed but out-of-date + private List servers; + private boolean isThereAnyPkgMissing; // MSI pkg is not installed in one or more servers + private boolean isThereAnyPkgNotSupported; // MSI Pkg is installed but out-of-date + + public DataGridMSIPkgInfo(List servers, String msiVersionSupported) { + this.servers = servers; + String versionSupported = DataGridCoreUtils.getAPIVersion(msiVersionSupported); - public DataGridMSIPkgInfo(List servers, String msiVersionSupported) { - this.servers = servers; - String versionSupported = DataGridCoreUtils.getAPIVersion(msiVersionSupported); + for (DataGridServer server : servers) { + String versionInstalled = DataGridCoreUtils.getAPIVersion(server.getMSIVersion()); - for(DataGridServer server: servers) { - String versionInstalled = DataGridCoreUtils.getAPIVersion(server.getMSIVersion()); + if (versionInstalled.isEmpty()) + isThereAnyPkgMissing = true; + else if (!versionInstalled.equalsIgnoreCase(versionSupported)) + isThereAnyPkgNotSupported = true; + } + } - if(versionInstalled.isEmpty()) isThereAnyPkgMissing = true; - else if(!versionInstalled.equalsIgnoreCase(versionSupported)) isThereAnyPkgNotSupported = true; - } - } + public List getServers() { + return servers; + } - public List getServers() { - return servers; - } + public void setServers(List servers) { + this.servers = servers; + } - public void setServers(List servers) { - this.servers = servers; - } + public boolean isThereAnyPkgMissing() { + return isThereAnyPkgMissing; + } - public boolean isThereAnyPkgMissing() { - return isThereAnyPkgMissing; - } + public boolean isThereAnyPkgNotSupported() { + return isThereAnyPkgNotSupported; + } - public boolean isThereAnyPkgNotSupported() { - return isThereAnyPkgNotSupported; - } + @Override + public String toString() { + final int maxLen = 10; + StringBuilder builder = new StringBuilder(); + builder.append("DataGridMSIPkgInfo ["); + if (servers != null) { + builder.append("servers=").append(servers.subList(0, Math.min(servers.size(), maxLen))).append(", "); + } + builder.append("isThereAnyPkgMissing=").append(isThereAnyPkgMissing).append(", isThereAnyPkgNotSupported=") + .append(isThereAnyPkgNotSupported).append("]"); + return builder.toString(); + } } diff --git a/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridMetadata.java b/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridMetadata.java index 66fef5c14..51bb9c75d 100755 --- a/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridMetadata.java +++ b/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridMetadata.java @@ -18,28 +18,29 @@ public class DataGridMetadata implements Comparable { private String attribute; - + private String value; - + private String unit; - - public DataGridMetadata(){ - + + public DataGridMetadata() { + } - - public DataGridMetadata(String attribute, String value, String unit){ + + public DataGridMetadata(String attribute, String value, String unit) { this.attribute = attribute; this.value = value; this.unit = unit; } - @Override - public boolean equals(Object obj){ - if(obj == null || !(obj instanceof DataGridMetadata)) return false; + @Override + public boolean equals(Object obj) { + if (obj == null || !(obj instanceof DataGridMetadata)) + return false; - DataGridMetadata m = (DataGridMetadata) obj; - return attribute.equals(m.getAttribute()) && value.equals(m.getValue()) && unit.equals(m.getUnit()); - } + DataGridMetadata m = (DataGridMetadata) obj; + return attribute.equals(m.getAttribute()) && value.equals(m.getValue()) && unit.equals(m.getUnit()); + } public String getAttribute() { return attribute; @@ -69,5 +70,22 @@ public void setUnit(String unit) { public int compareTo(DataGridMetadata o) { return this.attribute.compareToIgnoreCase(o.getAttribute()); } - + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("DataGridMetadata ["); + if (attribute != null) { + builder.append("attribute=").append(attribute).append(", "); + } + if (value != null) { + builder.append("value=").append(value).append(", "); + } + if (unit != null) { + builder.append("unit=").append(unit); + } + builder.append("]"); + return builder.toString(); + } + } diff --git a/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridMetadataFields.java b/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridMetadataFields.java index 189ae9950..d6f91e5d9 100755 --- a/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridMetadataFields.java +++ b/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridMetadataFields.java @@ -15,66 +15,76 @@ */ package com.emc.metalnx.core.domain.entity; +import java.io.Serializable; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.Table; + import org.hibernate.envers.Audited; import org.hibernate.envers.NotAudited; -import javax.persistence.*; -import java.io.Serializable; - @Entity @Audited @Table(name = "metadata_fields") public class DataGridMetadataFields implements Serializable, Comparable { - + private static final long serialVersionUID = 1L; @Id @NotAudited - @GeneratedValue(strategy=GenerationType.IDENTITY) + @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "id", unique = true, nullable = false) private Long id; - + @Column(name = "attribute", length = 60) private String attribute; - + @Column(name = "attribute_value", length = 60) private String attributeValue; - + @Column(name = "attribute_unit", length = 60) private String attributeUnit; - + @Column(name = "start_range") private float startRange; @Column(name = "end_range") private float endRange; - + @Column(name = "field_order") private int order; - - @ManyToOne(fetch = FetchType.EAGER, optional=true) + + @ManyToOne(fetch = FetchType.EAGER, optional = true) @JoinColumn(name = "template_id", nullable = false, updatable = true) private DataGridTemplate template; - + public DataGridMetadataFields() { - + } - + public DataGridMetadataFields(String attribute, String value, String unit) { this.attribute = attribute; this.attributeValue = value; this.attributeUnit = unit; } - + /** * @return the id */ public long getId() { return id; } - + /** - * @param id the id to set + * @param id + * the id to set */ public void setId(long id) { this.id = id; @@ -88,7 +98,8 @@ public String getAttribute() { } /** - * @param attribute the attribute to set + * @param attribute + * the attribute to set */ public void setAttribute(String attribute) { this.attribute = attribute; @@ -102,7 +113,8 @@ public String getValue() { } /** - * @param value the value to set + * @param value + * the value to set */ public void setValue(String value) { this.attributeValue = value; @@ -116,7 +128,8 @@ public String getUnit() { } /** - * @param unit the unit to set + * @param unit + * the unit to set */ public void setUnit(String unit) { this.attributeUnit = unit; @@ -126,7 +139,30 @@ public void setUnit(String unit) { public int compareTo(DataGridMetadataFields dgmf) { return this.attributeValue.compareTo(dgmf.getValue()); } - - - + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("DataGridMetadataFields ["); + if (id != null) { + builder.append("id=").append(id).append(", "); + } + if (attribute != null) { + builder.append("attribute=").append(attribute).append(", "); + } + if (attributeValue != null) { + builder.append("attributeValue=").append(attributeValue).append(", "); + } + if (attributeUnit != null) { + builder.append("attributeUnit=").append(attributeUnit).append(", "); + } + builder.append("startRange=").append(startRange).append(", endRange=").append(endRange).append(", order=") + .append(order).append(", "); + if (template != null) { + builder.append("template=").append(template); + } + builder.append("]"); + return builder.toString(); + } + } diff --git a/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridMetadataSearch.java b/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridMetadataSearch.java index 5aa2857b4..6ad511516 100755 --- a/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridMetadataSearch.java +++ b/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridMetadataSearch.java @@ -18,95 +18,121 @@ import com.emc.metalnx.core.domain.entity.enums.DataGridSearchOperatorEnum; /** - * This is a definition of metadata search criteria. A search criteria is broken into an object to - * manipulate its attribute, operator, and value. + * This is a definition of metadata search criteria. A search criteria is broken + * into an object to manipulate its attribute, operator, and value. * */ public class DataGridMetadataSearch { - private String attribute; - private DataGridSearchOperatorEnum operator; - private String value; - private String unit; - private String regex = "([^A-Za-z0-9-_.,:=! ]+)"; - private String attrColName = "m.meta_attr_name"; - private String valueColName = "m.meta_attr_value"; - private String unitColName = "m.meta_attr_unit"; + private String attribute; + private DataGridSearchOperatorEnum operator; + private String value; + private String unit; + private String regex = "([^A-Za-z0-9-_.,:=! ]+)"; + private String attrColName = "m.meta_attr_name"; + private String valueColName = "m.meta_attr_value"; + private String unitColName = "m.meta_attr_unit"; - public DataGridMetadataSearch(String attribute, String value, String unit, - DataGridSearchOperatorEnum operator) { - this.attribute = attribute; - this.operator = operator; - this.value = value; - this.unit = unit; - } + public DataGridMetadataSearch(String attribute, String value, String unit, DataGridSearchOperatorEnum operator) { + this.attribute = attribute; + this.operator = operator; + this.value = value; + this.unit = unit; + } - /** - * Builds a SQL query string to look for a piece of metadata (attribute, operator, and value). - * - * @return SQL query string - */ - public String getSpecQueryAsString() { - String attr = this.attribute.replaceAll(regex, ""); - String opt = this.operator.toString().replaceAll(regex, ""); - String val = this.value.replaceAll(regex, ""); - String unit = this.unit.replaceAll(regex, ""); + /** + * Builds a SQL query string to look for a piece of metadata (attribute, + * operator, and value). + * + * @return SQL query string + */ + public String getSpecQueryAsString() { + String attr = this.attribute.replaceAll(regex, ""); + String opt = this.operator.toString().replaceAll(regex, ""); + String val = this.value.replaceAll(regex, ""); + String unit = this.unit.replaceAll(regex, ""); - boolean hasAttr = !attr.isEmpty(); - boolean hasVal = !val.isEmpty(); - boolean hasUnit = !unit.isEmpty(); + boolean hasAttr = !attr.isEmpty(); + boolean hasVal = !val.isEmpty(); + boolean hasUnit = !unit.isEmpty(); - val = addSQLCharToQueryParamBasedOnOperator(val); - unit = addSQLCharToQueryParamBasedOnOperator(unit); + val = addSQLCharToQueryParamBasedOnOperator(val); + unit = addSQLCharToQueryParamBasedOnOperator(unit); - String attrQuery = hasAttr ? String.format(" LOWER( %s ) = LOWER( '%s' ) ", attrColName, attr) : ""; - String valueQuery = hasVal ? String.format(" LOWER( %s ) %s LOWER( %s ) ", valueColName, opt, val) : ""; - String unitQuery = hasUnit ? String.format(" LOWER( %s ) %s LOWER( %s ) ", unitColName, opt, unit) : ""; + String attrQuery = hasAttr ? String.format(" LOWER( %s ) = LOWER( '%s' ) ", attrColName, attr) : ""; + String valueQuery = hasVal ? String.format(" LOWER( %s ) %s LOWER( %s ) ", valueColName, opt, val) : ""; + String unitQuery = hasUnit ? String.format(" LOWER( %s ) %s LOWER( %s ) ", unitColName, opt, unit) : ""; - if (hasAttr && (hasVal || hasUnit)) { - attrQuery = String.format(" %s AND ", attrQuery); - } + if (hasAttr && (hasVal || hasUnit)) { + attrQuery = String.format(" %s AND ", attrQuery); + } - if (hasVal && hasUnit) { - valueQuery = String.format(" %s AND ", valueQuery); - } + if (hasVal && hasUnit) { + valueQuery = String.format(" %s AND ", valueQuery); + } - StringBuilder sb = new StringBuilder(); - sb.append(" SELECT map.object_id AS map_object_id "); - sb.append(" FROM r_objt_metamap map "); - sb.append(" JOIN ( "); - sb.append(" SELECT m.meta_id, m.meta_attr_name, m.meta_attr_value"); - sb.append(" FROM r_meta_main m "); - sb.append(" WHERE "); - sb.append(attrQuery); - sb.append(valueQuery); - sb.append(unitQuery); - sb.append(" )"); - sb.append(" AS metadata ON (metadata.meta_id = map.meta_id)"); - sb.append(" GROUP BY map.object_id"); - sb.append(" HAVING COUNT(map.meta_id) > 0 "); - return sb.toString(); - } + StringBuilder sb = new StringBuilder(); + sb.append(" SELECT map.object_id AS map_object_id "); + sb.append(" FROM r_objt_metamap map "); + sb.append(" JOIN ( "); + sb.append(" SELECT m.meta_id, m.meta_attr_name, m.meta_attr_value"); + sb.append(" FROM r_meta_main m "); + sb.append(" WHERE "); + sb.append(attrQuery); + sb.append(valueQuery); + sb.append(unitQuery); + sb.append(" )"); + sb.append(" AS metadata ON (metadata.meta_id = map.meta_id)"); + sb.append(" GROUP BY map.object_id"); + sb.append(" HAVING COUNT(map.meta_id) > 0 "); + return sb.toString(); + } - @Override - public String toString() { - return String.format("%s %s %s", this.attribute, this.operator.toString(), this.value); - } + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("DataGridMetadataSearch ["); + if (attribute != null) { + builder.append("attribute=").append(attribute).append(", "); + } + if (operator != null) { + builder.append("operator=").append(operator).append(", "); + } + if (value != null) { + builder.append("value=").append(value).append(", "); + } + if (unit != null) { + builder.append("unit=").append(unit).append(", "); + } + if (regex != null) { + builder.append("regex=").append(regex).append(", "); + } + if (attrColName != null) { + builder.append("attrColName=").append(attrColName).append(", "); + } + if (valueColName != null) { + builder.append("valueColName=").append(valueColName).append(", "); + } + if (unitColName != null) { + builder.append("unitColName=").append(unitColName); + } + builder.append("]"); + return builder.toString(); + } - /** - * Based on the operator applied to the query (LIKE or NOT LIKE), this method checks if any - * SQL special character needs to be added to the parameter in order for the query to run - * properly. - * - * @param param - * @return String representing the given parameters along with the proper SQL character for the - * query. - */ - private String addSQLCharToQueryParamBasedOnOperator(String param) { - if (this.operator == DataGridSearchOperatorEnum.LIKE - || this.operator == DataGridSearchOperatorEnum.NOT_LIKE) { - return String.format(" '%%%s%%' ", param); - } - return String.format(" '%s' ", param); - } + /** + * Based on the operator applied to the query (LIKE or NOT LIKE), this method + * checks if any SQL special character needs to be added to the parameter in + * order for the query to run properly. + * + * @param param + * @return String representing the given parameters along with the proper SQL + * character for the query. + */ + private String addSQLCharToQueryParamBasedOnOperator(String param) { + if (this.operator == DataGridSearchOperatorEnum.LIKE || this.operator == DataGridSearchOperatorEnum.NOT_LIKE) { + return String.format(" '%%%s%%' ", param); + } + return String.format(" '%s' ", param); + } } diff --git a/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridPageContext.java b/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridPageContext.java index b3832b78f..23521d91a 100755 --- a/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridPageContext.java +++ b/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridPageContext.java @@ -20,42 +20,58 @@ public class DataGridPageContext { private int startItemNumber; private int endItemNumber; private int totalNumberOfItems; - + /** * @return the startItemNumber */ public int getStartItemNumber() { return startItemNumber; } + /** - * @param startItemNumber the startItemNumber to set + * @param startItemNumber + * the startItemNumber to set */ public void setStartItemNumber(int startItemNumber) { this.startItemNumber = startItemNumber; } + /** * @return the endItemNumber */ public int getEndItemNumber() { return endItemNumber; } + /** - * @param endItemNumber the endItemNumber to set + * @param endItemNumber + * the endItemNumber to set */ public void setEndItemNumber(int endItemNumber) { this.endItemNumber = endItemNumber; } + /** * @return the totalNumberOfItems */ public int getTotalNumberOfItems() { return totalNumberOfItems; } + /** - * @param totalNumberOfItems the totalNumberOfItems to set + * @param totalNumberOfItems + * the totalNumberOfItems to set */ public void setTotalNumberOfItems(int totalNumberOfItems) { this.totalNumberOfItems = totalNumberOfItems; } - + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("DataGridPageContext [startItemNumber=").append(startItemNumber).append(", endItemNumber=") + .append(endItemNumber).append(", totalNumberOfItems=").append(totalNumberOfItems).append("]"); + return builder.toString(); + } + } diff --git a/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridResource.java b/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridResource.java index d2c02c53b..dc0b12567 100755 --- a/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridResource.java +++ b/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridResource.java @@ -22,471 +22,520 @@ public class DataGridResource implements Serializable, Comparable { - // resource id in the data grid - private long id; - - // resource name ("demoResc") - private String name; - - // resource zone name - private String zone; - - // resource type ("unix file system", "replication", etc) - private String type; - - // resource path - private String path; - - // resource free space - private long freeSpace; - - // when the free space was calculated - private Date freeSpaceTimeStamp; - - // other resources existing inside this resource - private List children; - - // resource parent name - private String parent; - - // resource status ("up", "down") - private String status; - - // resource host name - private String host; - - // when the resource was created - private Date createTime; - - // last time the resource was modified - private Date modifyTime; - - // any information related to this resource - private String info; - - // number of records existing in the resource - private int totalRecords; - - // comment about a resource - private String comment; - - // Context string of a resource - private String contextString; - - private static final long serialVersionUID = 1L; - - public DataGridResource(long id, String name, String zone, String type, String path, long freeSpace, Date freeSpaceTimeStamp, - List children, String parent, String status, String host, Date createTime, Date modifyTime, String info, int totalRecords, - String contextString) { - super(); - this.id = id; - this.name = name; - this.zone = zone; - this.type = type; - this.path = path; - this.freeSpace = freeSpace; - this.freeSpaceTimeStamp = freeSpaceTimeStamp; - this.children = children; - this.parent = parent; - this.status = status; - this.host = host; - this.contextString = contextString; - } - - public DataGridResource(long id, String name, String zone, String type, String path) { - this(id, name, zone, type, "unknown", -1, null, null, "unknown", "unknown", "unknown", new Date(), new Date(), "unknown", 0, null); - } - - public DataGridResource() { - // empty constructor - } - - @Override - public String toString() { - return "Resource Info" + "\n id=" + id + "\n name= " + name + "\n zone= " + zone + "\n type= " + type + "\n path= " + path + "\n freeSpace= " - + freeSpace + "\n freeSpaceDate= " + freeSpaceTimeStamp + "\n children= " + children + "\n parent= " + parent + "\n status= " - + status + "\n host= " + host + "\n context= " + contextString; - } - - /** - * @return the id - */ - public long getId() { - return id; - } - - /** - * @param id - * the id to set - */ - public void setId(long id) { - this.id = id; - } - - /** - * @return the name - */ - public String getName() { - return name; - } - - /** - * @param name - * the name to set - */ - public void setName(String name) { - this.name = name; - } - - /** - * @return the zone - */ - public String getZone() { - return zone; - } - - /** - * @param zone - * the zone to set - */ - public void setZone(String zone) { - this.zone = zone; - } - - /** - * @return the type - */ - public String getType() { - return type; - } - - /** - * @param type - * the type to set - */ - public void setType(String type) { - this.type = type; - } - - /** - * @return the path - */ - public String getPath() { - return path; - } - - /** - * @param path - * the path to set - */ - public void setPath(String path) { - this.path = path; - } - - /** - * @return the freeSpace - */ - public long getFreeSpace() { - return freeSpace; - } - - /** - * @param freeSpace - * the freeSpace to set - */ - public void setFreeSpace(long freeSpace) { - this.freeSpace = freeSpace; - } - - /** - * @return the freeSpaceDate - */ - public Date getFreeSpaceDate() { - return freeSpaceTimeStamp; - } - - /** - * @param freeSpaceDate - * the freeSpaceDate to set - */ - public void setFreeSpaceDate(Date freeSpaceDate) { - freeSpaceTimeStamp = freeSpaceDate; - } - - /** - * @return the children - */ - public List getChildren() { - if (children == null) return new ArrayList<>(); - return children; - } - - /** - * @param children - * the children to set - */ - public void setChildren(List children) { - this.children = children; - } - - public void addChildResc(String childResc) { - if (children == null) children = new ArrayList<>(); - children.add(childResc); - } - - /** - * @return the parent - */ - public String getParent() { - if (parent == null) return ""; - return parent; - } - - /** - * @param parent - * the parent to set - */ - public void setParent(String parent) { - this.parent = parent; - } - - /** - * @return the status - */ - public String getStatus() { - return status; - } - - /** - * @param status - * the status to set - */ - public void setStatus(String status) { - this.status = status; - } - - /** - * @return the host - */ - public String getHost() { - return host; - } - - /** - * @param host - * the host to set - */ - public void setHost(String host) { - this.host = host; - } - - /** - * @return the freeSpaceTimeStamp - */ - public Date getFreeSpaceTimeStamp() { - return freeSpaceTimeStamp; - } - - /** - * @param freeSpaceTimeStamp - * the freeSpaceTimeStamp to set - */ - public void setFreeSpaceTimeStamp(Date freeSpaceTimeStamp) { - this.freeSpaceTimeStamp = freeSpaceTimeStamp; - } - - /** - * @return the createTime - */ - public Date getCreateTime() { - return createTime; - } - - /** - * @param createTime - * the createTime to set - */ - public void setCreateTime(Date createTime) { - this.createTime = createTime; - } - - /** - * @return the modifyTime - */ - public Date getModifyTime() { - return modifyTime; - } - - /** - * @param modifyTime - * the modifyTime to set - */ - public void setModifyTime(Date modifyTime) { - this.modifyTime = modifyTime; - } - - /** - * @return the info - */ - public String getInfo() { - return info; - } - - /** - * @param info - * the info to set - */ - public void setInfo(String info) { - this.info = info; - } - - /** - * @return the totalRecords - */ - public int getTotalRecords() { - return totalRecords; - } - - /** - * @param totalRecords - * the totalRecords to set - */ - public void setTotalRecords(int totalRecords) { - this.totalRecords = totalRecords; - } - - /** - * @return the comment - */ - public String getComment() { - return comment; - } - - /** - * @param comment - * the comment to set - */ - public void setComment(String comment) { - this.comment = comment; - } - - /** - * @return the contextString - */ - public String getContextString() { - return contextString; - } - - /** - * @param contextString - * the contextString to set - */ - public void setContextString(String contextString) { - this.contextString = contextString; - } - - /** - * @return the isiHost - */ - public String getIsiHost() { - String isiHost = ""; - - if (contextString == null || contextString.isEmpty()) { - return ""; - } - - if (contextString.contains("isi_host")) { - String[] contextStringSplitted = contextString.split(";"); - // checking if after splitting we have the parts: isi_host, isi_port, isi_user - if (contextStringSplitted.length == 3) { - // isi_host=, getting the host_ip value - if (contextStringSplitted[0].length() == 2) { - isiHost = contextStringSplitted[0].split("=")[1]; - } - else { - isiHost = null; - } - } - } - - return isiHost; - } - - /** - * @return the isiPort - */ - public String getIsiPort() { - String isiPort = ""; - - if (contextString == null || contextString.isEmpty()) { - return ""; - } - - if (contextString.contains("isi_port")) { - String[] contextStringSplitted = contextString.split(";"); - // checking if after splitting we have the parts: isi_host, isi_port, isi_user - if (contextStringSplitted.length == 3) { - // isi_port=, getting the port value - isiPort = contextStringSplitted[1].split("=")[1]; - } - } - - return isiPort; - } - - /** - * @return the isiUser - */ - public String getIsiUser() { - String isiUser = ""; - - if (contextString == null || contextString.isEmpty()) { - return ""; - } - - if (contextString.contains("isi_user")) { - String[] contextStringSplitted = contextString.split(";"); - // checking if after splitting we have the parts: isi_host, isi_port, isi_user - if (contextStringSplitted.length == 3) { - // isi_user=, getting the username value - isiUser = contextStringSplitted[2].split("=")[1]; - } - } - - return isiUser; - } - - /** - * Checks whether the resource is a root resource or not. Root resource is a resource - * that is not a child of any other resource. - * - * @return - */ - public boolean isFirstLevelResc() { - String parent = getParent(); - boolean isFirstLevel = false; - - if (parent == null || parent.isEmpty() || parent.equals(zone)) { - isFirstLevel = true; - } - - return isFirstLevel; - } - - @Override - public int compareTo(DataGridResource dataGridResource) { - return getName().toLowerCase().compareTo(dataGridResource.getName().toLowerCase()); - } - - @Override - public boolean equals(Object object) { - boolean isEqual = false; - - if (object != null && object instanceof DataGridResource) { - isEqual = id == ((DataGridResource) object).getId(); - } - - return isEqual; - } + // resource id in the data grid + private long id; + + // resource name ("demoResc") + private String name; + + // resource zone name + private String zone; + + // resource type ("unix file system", "replication", etc) + private String type; + + // resource path + private String path; + + // resource free space + private long freeSpace; + + // when the free space was calculated + private Date freeSpaceTimeStamp; + + // other resources existing inside this resource + private List children; + + // resource parent name + private String parent; + + // resource status ("up", "down") + private String status; + + // resource host name + private String host; + + // when the resource was created + private Date createTime; + + // last time the resource was modified + private Date modifyTime; + + // any information related to this resource + private String info; + + // number of records existing in the resource + private int totalRecords; + + // comment about a resource + private String comment; + + // Context string of a resource + private String contextString; + + private static final long serialVersionUID = 1L; + + public DataGridResource(long id, String name, String zone, String type, String path, long freeSpace, + Date freeSpaceTimeStamp, List children, String parent, String status, String host, Date createTime, + Date modifyTime, String info, int totalRecords, String contextString) { + super(); + this.id = id; + this.name = name; + this.zone = zone; + this.type = type; + this.path = path; + this.freeSpace = freeSpace; + this.freeSpaceTimeStamp = freeSpaceTimeStamp; + this.children = children; + this.parent = parent; + this.status = status; + this.host = host; + this.contextString = contextString; + } + + public DataGridResource(long id, String name, String zone, String type, String path) { + this(id, name, zone, type, "unknown", -1, null, null, "unknown", "unknown", "unknown", new Date(), new Date(), + "unknown", 0, null); + } + + public DataGridResource() { + // empty constructor + } + + @Override + public String toString() { + final int maxLen = 10; + StringBuilder builder = new StringBuilder(); + builder.append("DataGridResource [id=").append(id).append(", "); + if (name != null) { + builder.append("name=").append(name).append(", "); + } + if (zone != null) { + builder.append("zone=").append(zone).append(", "); + } + if (type != null) { + builder.append("type=").append(type).append(", "); + } + if (path != null) { + builder.append("path=").append(path).append(", "); + } + builder.append("freeSpace=").append(freeSpace).append(", "); + if (freeSpaceTimeStamp != null) { + builder.append("freeSpaceTimeStamp=").append(freeSpaceTimeStamp).append(", "); + } + if (children != null) { + builder.append("children=").append(children.subList(0, Math.min(children.size(), maxLen))).append(", "); + } + if (parent != null) { + builder.append("parent=").append(parent).append(", "); + } + if (status != null) { + builder.append("status=").append(status).append(", "); + } + if (host != null) { + builder.append("host=").append(host).append(", "); + } + if (createTime != null) { + builder.append("createTime=").append(createTime).append(", "); + } + if (modifyTime != null) { + builder.append("modifyTime=").append(modifyTime).append(", "); + } + if (info != null) { + builder.append("info=").append(info).append(", "); + } + builder.append("totalRecords=").append(totalRecords).append(", "); + if (comment != null) { + builder.append("comment=").append(comment).append(", "); + } + if (contextString != null) { + builder.append("contextString=").append(contextString); + } + builder.append("]"); + return builder.toString(); + } + + /** + * @return the id + */ + public long getId() { + return id; + } + + /** + * @param id + * the id to set + */ + public void setId(long id) { + this.id = id; + } + + /** + * @return the name + */ + public String getName() { + return name; + } + + /** + * @param name + * the name to set + */ + public void setName(String name) { + this.name = name; + } + + /** + * @return the zone + */ + public String getZone() { + return zone; + } + + /** + * @param zone + * the zone to set + */ + public void setZone(String zone) { + this.zone = zone; + } + + /** + * @return the type + */ + public String getType() { + return type; + } + + /** + * @param type + * the type to set + */ + public void setType(String type) { + this.type = type; + } + + /** + * @return the path + */ + public String getPath() { + return path; + } + + /** + * @param path + * the path to set + */ + public void setPath(String path) { + this.path = path; + } + + /** + * @return the freeSpace + */ + public long getFreeSpace() { + return freeSpace; + } + + /** + * @param freeSpace + * the freeSpace to set + */ + public void setFreeSpace(long freeSpace) { + this.freeSpace = freeSpace; + } + + /** + * @return the freeSpaceDate + */ + public Date getFreeSpaceDate() { + return freeSpaceTimeStamp; + } + + /** + * @param freeSpaceDate + * the freeSpaceDate to set + */ + public void setFreeSpaceDate(Date freeSpaceDate) { + freeSpaceTimeStamp = freeSpaceDate; + } + + /** + * @return the children + */ + public List getChildren() { + if (children == null) + return new ArrayList<>(); + return children; + } + + /** + * @param children + * the children to set + */ + public void setChildren(List children) { + this.children = children; + } + + public void addChildResc(String childResc) { + if (children == null) + children = new ArrayList<>(); + children.add(childResc); + } + + /** + * @return the parent + */ + public String getParent() { + if (parent == null) + return ""; + return parent; + } + + /** + * @param parent + * the parent to set + */ + public void setParent(String parent) { + this.parent = parent; + } + + /** + * @return the status + */ + public String getStatus() { + return status; + } + + /** + * @param status + * the status to set + */ + public void setStatus(String status) { + this.status = status; + } + + /** + * @return the host + */ + public String getHost() { + return host; + } + + /** + * @param host + * the host to set + */ + public void setHost(String host) { + this.host = host; + } + + /** + * @return the freeSpaceTimeStamp + */ + public Date getFreeSpaceTimeStamp() { + return freeSpaceTimeStamp; + } + + /** + * @param freeSpaceTimeStamp + * the freeSpaceTimeStamp to set + */ + public void setFreeSpaceTimeStamp(Date freeSpaceTimeStamp) { + this.freeSpaceTimeStamp = freeSpaceTimeStamp; + } + + /** + * @return the createTime + */ + public Date getCreateTime() { + return createTime; + } + + /** + * @param createTime + * the createTime to set + */ + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + /** + * @return the modifyTime + */ + public Date getModifyTime() { + return modifyTime; + } + + /** + * @param modifyTime + * the modifyTime to set + */ + public void setModifyTime(Date modifyTime) { + this.modifyTime = modifyTime; + } + + /** + * @return the info + */ + public String getInfo() { + return info; + } + + /** + * @param info + * the info to set + */ + public void setInfo(String info) { + this.info = info; + } + + /** + * @return the totalRecords + */ + public int getTotalRecords() { + return totalRecords; + } + + /** + * @param totalRecords + * the totalRecords to set + */ + public void setTotalRecords(int totalRecords) { + this.totalRecords = totalRecords; + } + + /** + * @return the comment + */ + public String getComment() { + return comment; + } + + /** + * @param comment + * the comment to set + */ + public void setComment(String comment) { + this.comment = comment; + } + + /** + * @return the contextString + */ + public String getContextString() { + return contextString; + } + + /** + * @param contextString + * the contextString to set + */ + public void setContextString(String contextString) { + this.contextString = contextString; + } + + /** + * @return the isiHost + */ + public String getIsiHost() { + String isiHost = ""; + + if (contextString == null || contextString.isEmpty()) { + return ""; + } + + if (contextString.contains("isi_host")) { + String[] contextStringSplitted = contextString.split(";"); + // checking if after splitting we have the parts: isi_host, isi_port, isi_user + if (contextStringSplitted.length == 3) { + // isi_host=, getting the host_ip value + if (contextStringSplitted[0].length() == 2) { + isiHost = contextStringSplitted[0].split("=")[1]; + } else { + isiHost = null; + } + } + } + + return isiHost; + } + + /** + * @return the isiPort + */ + public String getIsiPort() { + String isiPort = ""; + + if (contextString == null || contextString.isEmpty()) { + return ""; + } + + if (contextString.contains("isi_port")) { + String[] contextStringSplitted = contextString.split(";"); + // checking if after splitting we have the parts: isi_host, isi_port, isi_user + if (contextStringSplitted.length == 3) { + // isi_port=, getting the port value + isiPort = contextStringSplitted[1].split("=")[1]; + } + } + + return isiPort; + } + + /** + * @return the isiUser + */ + public String getIsiUser() { + String isiUser = ""; + + if (contextString == null || contextString.isEmpty()) { + return ""; + } + + if (contextString.contains("isi_user")) { + String[] contextStringSplitted = contextString.split(";"); + // checking if after splitting we have the parts: isi_host, isi_port, isi_user + if (contextStringSplitted.length == 3) { + // isi_user=, getting the username value + isiUser = contextStringSplitted[2].split("=")[1]; + } + } + + return isiUser; + } + + /** + * Checks whether the resource is a root resource or not. Root resource is a + * resource that is not a child of any other resource. + * + * @return + */ + public boolean isFirstLevelResc() { + String parent = getParent(); + boolean isFirstLevel = false; + + if (parent == null || parent.isEmpty() || parent.equals(zone)) { + isFirstLevel = true; + } + + return isFirstLevel; + } + + @Override + public int compareTo(DataGridResource dataGridResource) { + return getName().toLowerCase().compareTo(dataGridResource.getName().toLowerCase()); + } + + @Override + public boolean equals(Object object) { + boolean isEqual = false; + + if (object != null && object instanceof DataGridResource) { + isEqual = id == ((DataGridResource) object).getId(); + } + + return isEqual; + } } diff --git a/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridResourceType.java b/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridResourceType.java index cce6e794d..926b12646 100755 --- a/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridResourceType.java +++ b/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridResourceType.java @@ -18,68 +18,85 @@ import com.emc.metalnx.core.domain.entity.enums.DataGridResourceTypeEnum; public class DataGridResourceType implements Comparable { - private DataGridResourceTypeEnum dataGridType; - private String dataGridResourceTypeName; - private String dataGridResourceTypeNamePrettified; + private DataGridResourceTypeEnum dataGridType; + private String dataGridResourceTypeName; + private String dataGridResourceTypeNamePrettified; - public DataGridResourceType() { + public DataGridResourceType() { - } + } - public DataGridResourceType(String dataGridResourceTypeNamePrettified, - String dataGridResourceTypeName, DataGridResourceTypeEnum dataGridType) { - this.dataGridResourceTypeNamePrettified = dataGridResourceTypeNamePrettified; - this.dataGridType = dataGridType; - this.dataGridResourceTypeName = dataGridResourceTypeName; - } + public DataGridResourceType(String dataGridResourceTypeNamePrettified, String dataGridResourceTypeName, + DataGridResourceTypeEnum dataGridType) { + this.dataGridResourceTypeNamePrettified = dataGridResourceTypeNamePrettified; + this.dataGridType = dataGridType; + this.dataGridResourceTypeName = dataGridResourceTypeName; + } - @Override - public int compareTo(DataGridResourceType dgrt) { - return this.getDataGridResourceTypeName().compareTo(dgrt.getDataGridResourceTypeName()); - } + @Override + public int compareTo(DataGridResourceType dgrt) { + return this.getDataGridResourceTypeName().compareTo(dgrt.getDataGridResourceTypeName()); + } - /** - * @return the dataGridType - */ - public DataGridResourceTypeEnum getDataGridType() { - return dataGridType; - } + /** + * @return the dataGridType + */ + public DataGridResourceTypeEnum getDataGridType() { + return dataGridType; + } - /** - * @param dataGridType - * the dataGridType to set - */ - public void setDataGridType(DataGridResourceTypeEnum dataGridType) { - this.dataGridType = dataGridType; - } + /** + * @param dataGridType + * the dataGridType to set + */ + public void setDataGridType(DataGridResourceTypeEnum dataGridType) { + this.dataGridType = dataGridType; + } - /** - * @return the dataGridTypeName - */ - public String getDataGridResourceTypeName() { - return dataGridResourceTypeName; - } + /** + * @return the dataGridTypeName + */ + public String getDataGridResourceTypeName() { + return dataGridResourceTypeName; + } - /** - * @param dataGridTypeName - * the dataGridTypeName to set - */ - public void setDataGridResourceTypeName(String dataGridResourceTypeName) { - this.dataGridResourceTypeName = dataGridResourceTypeName; - } + /** + * @param dataGridTypeName + * the dataGridTypeName to set + */ + public void setDataGridResourceTypeName(String dataGridResourceTypeName) { + this.dataGridResourceTypeName = dataGridResourceTypeName; + } - /** - * @return the dataGridResourceTypeNamePrettified - */ - public String getDataGridResourceTypeNamePrettified() { - return dataGridResourceTypeNamePrettified; - } + /** + * @return the dataGridResourceTypeNamePrettified + */ + public String getDataGridResourceTypeNamePrettified() { + return dataGridResourceTypeNamePrettified; + } - /** - * @param dataGridResourceTypeNamePrettified - * the dataGridResourceTypeNamePrettified to set - */ - public void setDataGridResourceTypeNamePrettified(String dataGridResourceTypeNamePrettified) { - this.dataGridResourceTypeNamePrettified = dataGridResourceTypeNamePrettified; - } + /** + * @param dataGridResourceTypeNamePrettified + * the dataGridResourceTypeNamePrettified to set + */ + public void setDataGridResourceTypeNamePrettified(String dataGridResourceTypeNamePrettified) { + this.dataGridResourceTypeNamePrettified = dataGridResourceTypeNamePrettified; + } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("DataGridResourceType ["); + if (dataGridType != null) { + builder.append("dataGridType=").append(dataGridType).append(", "); + } + if (dataGridResourceTypeName != null) { + builder.append("dataGridResourceTypeName=").append(dataGridResourceTypeName).append(", "); + } + if (dataGridResourceTypeNamePrettified != null) { + builder.append("dataGridResourceTypeNamePrettified=").append(dataGridResourceTypeNamePrettified); + } + builder.append("]"); + return builder.toString(); + } } diff --git a/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridRule.java b/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridRule.java index 8a7991801..0a3ef953a 100755 --- a/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridRule.java +++ b/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridRule.java @@ -16,187 +16,206 @@ package com.emc.metalnx.core.domain.entity; -import org.springframework.beans.factory.annotation.Value; - +import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.Map; +import org.springframework.beans.factory.annotation.Value; + /** * iRODS Rule. */ public class DataGridRule { - @Value("${irods.host}") - private String iCATHost; - private String[] inputRuleParams; // rule input parameters - - private String[] outputRuleParams; // rule output parameters - private String host; - private String rule; - private boolean declareRuleOutputParams; - private static final String INPUT = "INPUT"; - - private static final String OUTPUT = "OUTPUT"; - private static final String RULE_EXEC_OUT = "ruleExecOut"; - private static final String RULE_INPUT_NULL = "null"; - public static final String GET_VERSION_RULE = "getVersion"; - - public static final String POPULATE_RULE = "populateMetadataForFile"; - public static final String JPG_RULE = "automaticJpgMetadataExtraction"; - public static final String VCF_RULE = "automaticVcfMetadataExtraction"; - public static final String BAM_CRAM_RULE = "automaticBamMetadataExtraction"; - public static final String XML_MANIFEST_RULE = "automaticExtractMetadataFromXMLManifest"; - public static final String REPL_DATA_OBJ_RULE = "replicateDataObjInAdminMode"; - public static final String ILLUMINA_RULE = "illuminaMetadataForFile"; - public static final String TAR_RULE = "extractTar"; - public static final String GET_MSIS_RULE = "getMicroservices"; - public static final String EMPTY_TRASH_RULE = "emptyTrash"; - public static final String DEPLOYMENT_RULE = "deploymentRule"; - - // Maps rules for their respective microservices - private static final Map rulesMap; - - static { - Map map = new HashMap<>(); - map.put(POPULATE_RULE, "msiobjput_populate"); - map.put(JPG_RULE, "msiobjjpeg_extract"); - map.put(VCF_RULE, "msiobjput_mdvcf"); - map.put(BAM_CRAM_RULE, "msiobjput_mdbam"); - map.put(XML_MANIFEST_RULE, "msiobjput_mdmanifest"); - map.put(REPL_DATA_OBJ_RULE, "msiDataObjRepl"); - map.put(GET_VERSION_RULE, "msiobjget_version"); - map.put(ILLUMINA_RULE, "msiget_illumina_meta"); - map.put(TAR_RULE, "msiTarFileExtract"); - map.put(GET_MSIS_RULE, "msiobjget_microservices"); - map.put(EMPTY_TRASH_RULE, "msiRmColl"); - map.put(DEPLOYMENT_RULE, "msirule_deployment"); - rulesMap = Collections.unmodifiableMap(map); - } - - public DataGridRule(String rule, String host, boolean declareRuleOutputParams) { - this.host = host; - this.rule = rule; - this.declareRuleOutputParams = declareRuleOutputParams; - } - - public DataGridRule(String rule, String host) { - this(rule, host, true); - } - - public void setInputRuleParams(String... params) { this.inputRuleParams = params; } - - public void setOutputRuleParams(String... params) { this.outputRuleParams = params; } - - public boolean declareRuleOutputParams() { - return declareRuleOutputParams; - } - - private String getInputParamsAsString() { - StringBuilder sb = new StringBuilder(); - - sb.append(INPUT); - if(inputRuleParams != null) { - String[] params = inputRuleParams; - for (int i = 0; i < params.length - 1; i++) sb.append(String.format(" *p%d=\"%s\",", i, params[i])); - sb.append(String.format(" *p%d=\"%s\"\n", params.length - 1, params[params.length - 1])); - } - else { - sb.append(" "); - sb.append(RULE_INPUT_NULL); - sb.append("\n"); - } - - return sb.toString(); - } - - private String getOutputParamsAsString() { - StringBuilder sb = new StringBuilder(); - - sb.append(OUTPUT); - - if(outputRuleParams != null) { - String[] params = outputRuleParams; - for (int i = 0; i < params.length - 1; i++) sb.append(String.format(" *%s,", params[i])); - sb.append(String.format(" *%s\n", params[params.length - 1])); - } - else { - sb.append(" "); - sb.append(RULE_EXEC_OUT); - sb.append("\n"); - } - - return sb.toString(); - } - - private String getMSIParamsAsString() { - StringBuilder paramsEscaped = new StringBuilder(); - paramsEscaped.append(" "); - paramsEscaped.append(rulesMap.get(rule)); - paramsEscaped.append("("); - - if(inputRuleParams != null) { - for (int i = 0; i < inputRuleParams.length - 1; i++) paramsEscaped.append(String.format("*p%d, ", i)); - paramsEscaped.append(String.format("*p%d", inputRuleParams.length - 1)); - - if(outputRuleParams != null) paramsEscaped.append(", "); - } - - if(outputRuleParams != null) { - for (int i = 0; i < outputRuleParams.length - 1; i++) paramsEscaped.append(String.format("*%s, ", outputRuleParams[i])); - paramsEscaped.append(String.format("*%s", outputRuleParams[outputRuleParams.length - 1])); - } - - paramsEscaped.append(");\n"); - - return paramsEscaped.toString(); - } - - private String initializeOutputParams() { - if(outputRuleParams == null) return ""; - - StringBuilder outputParams = new StringBuilder(); - outputParams.append(" "); - - for (int i = 0; i < outputRuleParams.length - 1; i++) outputParams.append(String.format("*%s=\"\",", outputRuleParams[i])); - outputParams.append(String.format("*%s=\"\";", outputRuleParams[outputRuleParams.length - 1])); - - return outputParams.toString(); - } - - public String toString() { - RemoteRuleHeader header = new RemoteRuleHeader(host); - StringBuilder ruleString = new StringBuilder(); - ruleString.append("\n"); - ruleString.append(rule); - ruleString.append("{"); - ruleString.append("\n"); - if(declareRuleOutputParams) ruleString.append(initializeOutputParams() + "\n"); - ruleString.append(header.getRemoteRuleHeader()); - ruleString.append(getMSIParamsAsString()); - ruleString.append(header.getRemoteRuleFooter()); - ruleString.append("}"); - ruleString.append("\n"); - ruleString.append(getInputParamsAsString()); - ruleString.append(getOutputParamsAsString()); - - return ruleString.toString(); - } - - private class RemoteRuleHeader { - private String remoteHeader = null; - private String remoteFooter = null; - - RemoteRuleHeader(String host) { - remoteHeader = String.format(" remote(\"%s\", \"\") {\n", host); - remoteFooter = " }\n"; - } - - String getRemoteRuleHeader() { - return this.remoteHeader; - } - - String getRemoteRuleFooter() { - return this.remoteFooter; - } - } + @Value("${irods.host}") + private String iCATHost; + private String[] inputRuleParams; // rule input parameters + + private String[] outputRuleParams; // rule output parameters + private String host; + private String rule; + private boolean declareRuleOutputParams; + private static final String INPUT = "INPUT"; + + private static final String OUTPUT = "OUTPUT"; + private static final String RULE_EXEC_OUT = "ruleExecOut"; + private static final String RULE_INPUT_NULL = "null"; + public static final String GET_VERSION_RULE = "getVersion"; + + public static final String POPULATE_RULE = "populateMetadataForFile"; + public static final String JPG_RULE = "automaticJpgMetadataExtraction"; + public static final String VCF_RULE = "automaticVcfMetadataExtraction"; + public static final String BAM_CRAM_RULE = "automaticBamMetadataExtraction"; + public static final String XML_MANIFEST_RULE = "automaticExtractMetadataFromXMLManifest"; + public static final String REPL_DATA_OBJ_RULE = "replicateDataObjInAdminMode"; + public static final String ILLUMINA_RULE = "illuminaMetadataForFile"; + public static final String TAR_RULE = "extractTar"; + public static final String GET_MSIS_RULE = "getMicroservices"; + public static final String EMPTY_TRASH_RULE = "emptyTrash"; + public static final String DEPLOYMENT_RULE = "deploymentRule"; + + // Maps rules for their respective microservices + private static final Map rulesMap; + + static { + Map map = new HashMap<>(); + map.put(POPULATE_RULE, "msiobjput_populate"); + map.put(JPG_RULE, "msiobjjpeg_extract"); + map.put(VCF_RULE, "msiobjput_mdvcf"); + map.put(BAM_CRAM_RULE, "msiobjput_mdbam"); + map.put(XML_MANIFEST_RULE, "msiobjput_mdmanifest"); + map.put(REPL_DATA_OBJ_RULE, "msiDataObjRepl"); + map.put(GET_VERSION_RULE, "msiobjget_version"); + map.put(ILLUMINA_RULE, "msiget_illumina_meta"); + map.put(TAR_RULE, "msiTarFileExtract"); + map.put(GET_MSIS_RULE, "msiobjget_microservices"); + map.put(EMPTY_TRASH_RULE, "msiRmColl"); + map.put(DEPLOYMENT_RULE, "msirule_deployment"); + rulesMap = Collections.unmodifiableMap(map); + } + + public DataGridRule(String rule, String host, boolean declareRuleOutputParams) { + this.host = host; + this.rule = rule; + this.declareRuleOutputParams = declareRuleOutputParams; + } + + public DataGridRule(String rule, String host) { + this(rule, host, true); + } + + public void setInputRuleParams(String... params) { + this.inputRuleParams = params; + } + + public void setOutputRuleParams(String... params) { + this.outputRuleParams = params; + } + + public boolean declareRuleOutputParams() { + return declareRuleOutputParams; + } + + private String getInputParamsAsString() { + StringBuilder sb = new StringBuilder(); + + sb.append(INPUT); + if (inputRuleParams != null) { + String[] params = inputRuleParams; + for (int i = 0; i < params.length - 1; i++) + sb.append(String.format(" *p%d=\"%s\",", i, params[i])); + sb.append(String.format(" *p%d=\"%s\"\n", params.length - 1, params[params.length - 1])); + } else { + sb.append(" "); + sb.append(RULE_INPUT_NULL); + sb.append("\n"); + } + + return sb.toString(); + } + + private String getOutputParamsAsString() { + StringBuilder sb = new StringBuilder(); + + sb.append(OUTPUT); + + if (outputRuleParams != null) { + String[] params = outputRuleParams; + for (int i = 0; i < params.length - 1; i++) + sb.append(String.format(" *%s,", params[i])); + sb.append(String.format(" *%s\n", params[params.length - 1])); + } else { + sb.append(" "); + sb.append(RULE_EXEC_OUT); + sb.append("\n"); + } + + return sb.toString(); + } + + private String getMSIParamsAsString() { + StringBuilder paramsEscaped = new StringBuilder(); + paramsEscaped.append(" "); + paramsEscaped.append(rulesMap.get(rule)); + paramsEscaped.append("("); + + if (inputRuleParams != null) { + for (int i = 0; i < inputRuleParams.length - 1; i++) + paramsEscaped.append(String.format("*p%d, ", i)); + paramsEscaped.append(String.format("*p%d", inputRuleParams.length - 1)); + + if (outputRuleParams != null) + paramsEscaped.append(", "); + } + + if (outputRuleParams != null) { + for (int i = 0; i < outputRuleParams.length - 1; i++) + paramsEscaped.append(String.format("*%s, ", outputRuleParams[i])); + paramsEscaped.append(String.format("*%s", outputRuleParams[outputRuleParams.length - 1])); + } + + paramsEscaped.append(");\n"); + + return paramsEscaped.toString(); + } + + private String initializeOutputParams() { + if (outputRuleParams == null) + return ""; + + StringBuilder outputParams = new StringBuilder(); + outputParams.append(" "); + + for (int i = 0; i < outputRuleParams.length - 1; i++) + outputParams.append(String.format("*%s=\"\",", outputRuleParams[i])); + outputParams.append(String.format("*%s=\"\";", outputRuleParams[outputRuleParams.length - 1])); + + return outputParams.toString(); + } + + @Override + public String toString() { + final int maxLen = 10; + StringBuilder builder = new StringBuilder(); + builder.append("DataGridRule ["); + if (iCATHost != null) { + builder.append("iCATHost=").append(iCATHost).append(", "); + } + if (inputRuleParams != null) { + builder.append("inputRuleParams=") + .append(Arrays.asList(inputRuleParams).subList(0, Math.min(inputRuleParams.length, maxLen))) + .append(", "); + } + if (outputRuleParams != null) { + builder.append("outputRuleParams=") + .append(Arrays.asList(outputRuleParams).subList(0, Math.min(outputRuleParams.length, maxLen))) + .append(", "); + } + if (host != null) { + builder.append("host=").append(host).append(", "); + } + if (rule != null) { + builder.append("rule=").append(rule).append(", "); + } + builder.append("declareRuleOutputParams=").append(declareRuleOutputParams).append("]"); + return builder.toString(); + } + + private class RemoteRuleHeader { + private String remoteHeader = null; + private String remoteFooter = null; + + RemoteRuleHeader(String host) { + remoteHeader = String.format(" remote(\"%s\", \"\") {\n", host); + remoteFooter = " }\n"; + } + + String getRemoteRuleHeader() { + return this.remoteHeader; + } + + String getRemoteRuleFooter() { + return this.remoteFooter; + } + } } diff --git a/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridServer.java b/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridServer.java index 9f2428fa3..b4e036481 100755 --- a/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridServer.java +++ b/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridServer.java @@ -15,12 +15,18 @@ */ package com.emc.metalnx.core.domain.entity; -import com.emc.metalnx.core.domain.entity.enums.DataGridServerType; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; -import java.util.*; +import com.emc.metalnx.core.domain.entity.enums.DataGridServerType; public class DataGridServer implements Comparable { - + private DataGridServerType type; private String hostname; private String ip; @@ -36,23 +42,23 @@ public class DataGridServer implements Comparable { private String rmdPackageRelease; private String rmdPackageVersion; private String msiVersion; - private List msisInstaleld; + private List msisInstaleld; private List mlxMSIsExpected; private List irodsMSIsExpected; private List otherMSIsExpected; - private Map metalnxMSIs; - private Map irodsMSIs; - private Map otherMSIs; + private Map metalnxMSIs; + private Map irodsMSIs; + private Map otherMSIs; - public DataGridServer() { - metalnxMSIs = new HashMap<>(); - irodsMSIs = new HashMap<>(); - otherMSIs = new HashMap<>(); - } + public DataGridServer() { + metalnxMSIs = new HashMap<>(); + irodsMSIs = new HashMap<>(); + otherMSIs = new HashMap<>(); + } - /** + /** * @return the type */ public DataGridServerType getType() { @@ -68,10 +74,12 @@ public String getHostname() { /** * Gets the resources of this server sorted by resource name + * * @return the resources */ public List getResources() { - if(resources != null) Collections.sort(resources); + if (resources != null) + Collections.sort(resources); return resources; } @@ -98,10 +106,12 @@ public void setHostname(String hostname) { public void setResources(List resources) { this.resources = resources; } - + /** * Adds resource to the server - * @param resource to be added + * + * @param resource + * to be added */ public void addResource(DataGridResource resource) { if (this.resources == null) { @@ -117,7 +127,7 @@ public String getIp() { public void setIp(String ip) { this.ip = ip; } - + /** * @return the machineStatus */ @@ -147,28 +157,32 @@ public String getDiskStatus() { } /** - * @param machineStatus the machineStatus to set + * @param machineStatus + * the machineStatus to set */ public void setMachineStatus(String machineStatus) { this.machineStatus = machineStatus; } /** - * @param dataGridStatus the dataGridStatus to set + * @param dataGridStatus + * the dataGridStatus to set */ public void setDataGridStatus(String dataGridStatus) { this.dataGridStatus = dataGridStatus; } /** - * @param memoryStatus the memoryStatus to set + * @param memoryStatus + * the memoryStatus to set */ public void setMemoryStatus(String memoryStatus) { this.memoryStatus = memoryStatus; } /** - * @param diskStatus the diskStatus to set + * @param diskStatus + * the diskStatus to set */ public void setDiskStatus(String diskStatus) { this.diskStatus = diskStatus; @@ -196,21 +210,24 @@ public long getTotalStorage() { } /** - * @param totalStorageUsed the totalStorageUsed to set + * @param totalStorageUsed + * the totalStorageUsed to set */ public void setTotalStorageUsed(long totalStorageUsed) { this.totalStorageUsed = totalStorageUsed; } /** - * @param totalStorageAvailable the totalStorageAvailable to set + * @param totalStorageAvailable + * the totalStorageAvailable to set */ public void setTotalStorageAvailable(long totalStorageAvailable) { this.totalStorageAvailable = totalStorageAvailable; } /** - * @param totalStorage the totalStorage to set + * @param totalStorage + * the totalStorage to set */ public void setTotalStorage(long totalStorage) { this.totalStorage = totalStorage; @@ -224,45 +241,48 @@ public boolean isRmdPackageRunning() { } /** - * @param isRmdPackageRunning the isRmdPackageRunning to set + * @param isRmdPackageRunning + * the isRmdPackageRunning to set */ public void setRmdPackageRunning(boolean isRmdPackageRunning) { this.isRmdPackageRunning = isRmdPackageRunning; } /** - * This method compares if two DataGridServer objects are the same. They will be the same - * if they have the same host name. + * This method compares if two DataGridServer objects are the same. They will be + * the same if they have the same host name. + * * @return true, if they are equal. False, otherwise. */ @Override public boolean equals(Object obj) { - if(obj == null) { + if (obj == null) { return false; } - - if(this == obj) { + + if (this == obj) { return true; } - - if(obj instanceof DataGridServer) { + + if (obj instanceof DataGridServer) { String hostName = ((DataGridServer) obj).getHostname(); - return this.getHostname().equals(hostName) ; + return this.getHostname().equals(hostName); } - - return false; + + return false; } - + /** - * This method provides consistent results for the equals method. If two DataGridServer objects - * are equal, they both must have the same hash code. + * This method provides consistent results for the equals method. If two + * DataGridServer objects are equal, they both must have the same hash code. + * * @return a hash code based on the host name */ @Override public int hashCode() { - return this.getHostname().hashCode(); + return this.getHostname().hashCode(); } - + @Override public int compareTo(DataGridServer dgs) { return this.ip.compareTo(dgs.getIp()); @@ -276,7 +296,8 @@ public String getRmdPackageRelease() { } /** - * @param rmdPackageRelease the rmdPackageRelease to set + * @param rmdPackageRelease + * the rmdPackageRelease to set */ public void setRmdPackageRelease(String rmdPackageRelease) { this.rmdPackageRelease = rmdPackageRelease; @@ -290,102 +311,193 @@ public String getRmdPackageVersion() { } /** - * @param rmdPackageVersion the rmdPackageVersion to set + * @param rmdPackageVersion + * the rmdPackageVersion to set */ public void setRmdPackageVersion(String rmdPackageVersion) { this.rmdPackageVersion = rmdPackageVersion; } - public void setMSIVersion(String msiVersion) { this.msiVersion = msiVersion; } + public void setMSIVersion(String msiVersion) { + this.msiVersion = msiVersion; + } - public String getMSIVersion() { - if(msiVersion == null ){ + public String getMSIVersion() { + if (msiVersion == null) { return ""; } return msiVersion; } - @Override + @Override public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append(getHostname()); - sb.append(" - "); - sb.append(getIp()); - sb.append(" - "); - sb.append(getMSIVersion()); - return sb.toString(); - } - - public void setMSIInstalledList(List msisInstalled) { - if(msisInstalled == null || msisInstalled.isEmpty()) return; - - this.msisInstaleld = msisInstalled; - - // classifying MSIs by their type - for(String msi: msisInstalled) { - if(mlxMSIsExpected.contains(msi)) addToMsiMetalnx(msi); - else if(irodsMSIsExpected.contains(msi)) addToMsiIRODS(msi); - else addToMsiOther(msi); - } - } - - public List getMSIInstalledList() { - return this.msisInstaleld != null ? this.msisInstaleld : new ArrayList<>(); - } - - public void setMetalnxExpectedMSIs(List mlxMSIsExpected) { - if(mlxMSIsExpected == null || mlxMSIsExpected.isEmpty()) return; - - this.mlxMSIsExpected = mlxMSIsExpected; - for(String msi: mlxMSIsExpected) { - if (!msi.isEmpty()) metalnxMSIs.put(msi, false); - } - } - - public void setIRodsExpectedMSIs(List irodsMSIsExpected) { - if(irodsMSIsExpected == null || irodsMSIsExpected.isEmpty()) return; - - this.irodsMSIsExpected = irodsMSIsExpected; - for(String msi: irodsMSIsExpected) { - if (!msi.isEmpty()) irodsMSIs.put(msi, false); - } - } - - public void setOtherExpectedMSIs(List otherMSIsExpected) { - if(otherMSIsExpected == null || otherMSIsExpected.isEmpty()) return; - - this.otherMSIsExpected = otherMSIsExpected; - for(String msi: otherMSIsExpected) { - if (!msi.isEmpty()) otherMSIs.put(msi, false); - } - } + final int maxLen = 10; + StringBuilder builder = new StringBuilder(); + builder.append("DataGridServer ["); + if (type != null) { + builder.append("type=").append(type).append(", "); + } + if (hostname != null) { + builder.append("hostname=").append(hostname).append(", "); + } + if (ip != null) { + builder.append("ip=").append(ip).append(", "); + } + if (machineStatus != null) { + builder.append("machineStatus=").append(machineStatus).append(", "); + } + if (dataGridStatus != null) { + builder.append("dataGridStatus=").append(dataGridStatus).append(", "); + } + if (memoryStatus != null) { + builder.append("memoryStatus=").append(memoryStatus).append(", "); + } + if (diskStatus != null) { + builder.append("diskStatus=").append(diskStatus).append(", "); + } + builder.append("totalStorageUsed=").append(totalStorageUsed).append(", totalStorageAvailable=") + .append(totalStorageAvailable).append(", totalStorage=").append(totalStorage).append(", "); + if (resources != null) { + builder.append("resources=").append(toString(resources, maxLen)).append(", "); + } + builder.append("isRmdPackageRunning=").append(isRmdPackageRunning).append(", "); + if (rmdPackageRelease != null) { + builder.append("rmdPackageRelease=").append(rmdPackageRelease).append(", "); + } + if (rmdPackageVersion != null) { + builder.append("rmdPackageVersion=").append(rmdPackageVersion).append(", "); + } + if (msiVersion != null) { + builder.append("msiVersion=").append(msiVersion).append(", "); + } + if (msisInstaleld != null) { + builder.append("msisInstaleld=").append(toString(msisInstaleld, maxLen)).append(", "); + } + if (mlxMSIsExpected != null) { + builder.append("mlxMSIsExpected=").append(toString(mlxMSIsExpected, maxLen)).append(", "); + } + if (irodsMSIsExpected != null) { + builder.append("irodsMSIsExpected=").append(toString(irodsMSIsExpected, maxLen)).append(", "); + } + if (otherMSIsExpected != null) { + builder.append("otherMSIsExpected=").append(toString(otherMSIsExpected, maxLen)).append(", "); + } + if (metalnxMSIs != null) { + builder.append("metalnxMSIs=").append(toString(metalnxMSIs.entrySet(), maxLen)).append(", "); + } + if (irodsMSIs != null) { + builder.append("irodsMSIs=").append(toString(irodsMSIs.entrySet(), maxLen)).append(", "); + } + if (otherMSIs != null) { + builder.append("otherMSIs=").append(toString(otherMSIs.entrySet(), maxLen)); + } + builder.append("]"); + return builder.toString(); + } + + public void setMSIInstalledList(List msisInstalled) { + if (msisInstalled == null || msisInstalled.isEmpty()) + return; + + this.msisInstaleld = msisInstalled; + + // classifying MSIs by their type + for (String msi : msisInstalled) { + if (mlxMSIsExpected.contains(msi)) + addToMsiMetalnx(msi); + else if (irodsMSIsExpected.contains(msi)) + addToMsiIRODS(msi); + else + addToMsiOther(msi); + } + } + + public List getMSIInstalledList() { + return this.msisInstaleld != null ? this.msisInstaleld : new ArrayList<>(); + } + + public void setMetalnxExpectedMSIs(List mlxMSIsExpected) { + if (mlxMSIsExpected == null || mlxMSIsExpected.isEmpty()) + return; + + this.mlxMSIsExpected = mlxMSIsExpected; + for (String msi : mlxMSIsExpected) { + if (!msi.isEmpty()) + metalnxMSIs.put(msi, false); + } + } + + public void setIRodsExpectedMSIs(List irodsMSIsExpected) { + if (irodsMSIsExpected == null || irodsMSIsExpected.isEmpty()) + return; + + this.irodsMSIsExpected = irodsMSIsExpected; + for (String msi : irodsMSIsExpected) { + if (!msi.isEmpty()) + irodsMSIs.put(msi, false); + } + } + + public void setOtherExpectedMSIs(List otherMSIsExpected) { + if (otherMSIsExpected == null || otherMSIsExpected.isEmpty()) + return; + + this.otherMSIsExpected = otherMSIsExpected; + for (String msi : otherMSIsExpected) { + if (!msi.isEmpty()) + otherMSIs.put(msi, false); + } + } + + // used by frontend + public Map getMetalnxMSIs() { + return metalnxMSIs; + } // used by frontend - public Map getMetalnxMSIs() { return metalnxMSIs; } + public Map getIRODSMSIs() { + return irodsMSIs; + } - // used by frontend - public Map getIRODSMSIs() { return irodsMSIs; } + // used by frontend + public Map getOtherMSIs() { + return otherMSIs; + } - // used by frontend - public Map getOtherMSIs() { return otherMSIs; } + // used by frontend + public boolean isThereAnyMSI() { + return !getMSIInstalledList().isEmpty(); + } - // used by frontend - public boolean isThereAnyMSI() { - return !getMSIInstalledList().isEmpty(); - } + private void addToMsiMetalnx(String msi) { + if (msi == null || msi.isEmpty()) + return; + this.metalnxMSIs.put(msi, true); + } - private void addToMsiMetalnx(String msi) { - if(msi == null || msi.isEmpty()) return; - this.metalnxMSIs.put(msi, true); - } + private void addToMsiIRODS(String msi) { + if (msi == null || msi.isEmpty()) + return; + this.irodsMSIs.put(msi, true); + } - private void addToMsiIRODS(String msi) { - if(msi == null || msi.isEmpty()) return; - this.irodsMSIs.put(msi, true); - } + private void addToMsiOther(String msi) { + if (msi == null || msi.isEmpty()) + return; + this.otherMSIs.put(msi, true); + } - private void addToMsiOther(String msi) { - if(msi == null || msi.isEmpty()) return; - this.otherMSIs.put(msi, true); - } + private String toString(Collection collection, int maxLen) { + StringBuilder builder = new StringBuilder(); + builder.append("["); + int i = 0; + for (Iterator iterator = collection.iterator(); iterator.hasNext() && i < maxLen; i++) { + if (i > 0) { + builder.append(", "); + } + builder.append(iterator.next()); + } + builder.append("]"); + return builder.toString(); + } } diff --git a/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridSpecificQuery.java b/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridSpecificQuery.java index a2008381f..33482d708 100755 --- a/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridSpecificQuery.java +++ b/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridSpecificQuery.java @@ -19,33 +19,49 @@ public class DataGridSpecificQuery { private String alias; private String query; - + /** * @return the alias */ public String getAlias() { return alias; } - + /** * @return the query */ public String getQuery() { return query; } - + /** - * @param alias the alias to set + * @param alias + * the alias to set */ public void setAlias(String alias) { this.alias = alias; } - + /** - * @param query the query to set + * @param query + * the query to set */ public void setQuery(String query) { this.query = query; } - + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("DataGridSpecificQuery ["); + if (alias != null) { + builder.append("alias=").append(alias).append(", "); + } + if (query != null) { + builder.append("query=").append(query); + } + builder.append("]"); + return builder.toString(); + } + } diff --git a/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridTemplate.java b/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridTemplate.java index 6d83069c6..84eeddbf9 100755 --- a/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridTemplate.java +++ b/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridTemplate.java @@ -15,270 +15,320 @@ */ package com.emc.metalnx.core.domain.entity; -import com.emc.metalnx.core.domain.exceptions.DataGridTooLongTemplateNameException; -import org.hibernate.envers.Audited; -import org.hibernate.envers.NotAudited; - -import javax.persistence.*; import java.io.Serializable; +import java.util.Collection; import java.util.Date; +import java.util.Iterator; import java.util.Set; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.OneToMany; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + +import org.hibernate.envers.Audited; +import org.hibernate.envers.NotAudited; + +import com.emc.metalnx.core.domain.exceptions.DataGridTooLongTemplateNameException; + @Entity @Audited @Table(name = "templates") public class DataGridTemplate implements Serializable, Comparable { - private static final long serialVersionUID = 1L; - - @Id - @NotAudited - @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column(name = "template_id", unique = true, nullable = false) - private Long id; - - @Column(name = "template_name", unique = true, nullable = false, length = 100) - private String templateName; - - @Column(name = "owner", nullable = false, length = 100) - private String owner; - - @Column(name = "description", nullable = false, length = 512) - private String description; - - @Column(name = "usage_info", length = 100) - private String usageInformation; - - @Column(name = "access_type", length = 32) - private String accessType; - - @Column(name = "version") - private Integer version; - - @Temporal(TemporalType.TIMESTAMP) - @Column(name = "create_ts", nullable = false, length = 60, updatable = false) - private Date createTs; - - @Temporal(TemporalType.TIMESTAMP) - @Column(name = "modify_ts", nullable = false, length = 60) - private Date modifyTs; - - @OneToMany(mappedBy = "template", fetch = FetchType.EAGER) - private Set fields; - - private static final int TEMPLATE_NAME_MAX_LENGTH = 100; - private static final int TEMPLATE_DESC_MAX_LENGTH = 100; - - private boolean isModified = false; - - public DataGridTemplate() { - // empty constructor - } - - public DataGridTemplate(String templateName) throws DataGridTooLongTemplateNameException { - if (templateName.length() > TEMPLATE_NAME_MAX_LENGTH) { - throw new DataGridTooLongTemplateNameException("Template name exceeded " + TEMPLATE_NAME_MAX_LENGTH + " characters."); - } - - this.templateName = templateName; - } - - /** - * @return the owner - */ - public String getOwner() { - return owner; - } - - /** - * @param owner - * the owner to set - */ - public void setOwner(String owner) { - this.owner = owner; - } - - /** - * @return the description - */ - public String getDescription() { - return description; - } - - /** - * @param description - * the description to set - * @throws DataGridTooLongTemplateNameException - */ - public void setDescription(String description) throws DataGridTooLongTemplateNameException { - if (description.length() > TEMPLATE_NAME_MAX_LENGTH) { - throw new DataGridTooLongTemplateNameException("Template description exceeded " + TEMPLATE_DESC_MAX_LENGTH + " characters."); - } - this.description = description; - } - - /** - * @return the createTs - */ - public Date getCreateTs() { - return createTs; - } - - /** - * @param createTs - * the createTs to set - */ - public void setCreateTs(Date createTs) { - this.createTs = createTs; - } - - /** - * @return the modifyTs - */ - public Date getModifyTs() { - return modifyTs; - } - - /** - * @param modifyTs - * the modifyTs to set - */ - public void setModifyTs(Date modifyTs) { - this.modifyTs = modifyTs; - } - - /** - * @return the id - */ - public long getId() { - return id; - } - - /** - * @param id - * the id to set - */ - public void setId(long id) { - this.id = id; - } - - /** - * @return the templateName - */ - public String getTemplateName() { - return templateName; - } - - /** - * @param the - * templateName to set - * @throws DataGridTooLongTemplateNameException - */ - public void setTemplateName(String templateName) throws DataGridTooLongTemplateNameException { - if (templateName.length() > TEMPLATE_NAME_MAX_LENGTH) { - throw new DataGridTooLongTemplateNameException("Template name exceeded " + TEMPLATE_NAME_MAX_LENGTH + " characters."); - } - - this.templateName = templateName; - } - - /** - * @return the usageInformation - */ - public String getUsageInformation() { - return usageInformation; - } - - /** - * @param usageInformation - * the usageInformation to set - */ - public void setUsageInformation(String usageInformation) { - this.usageInformation = usageInformation; - } - - /** - * @return the accessType - */ - public String getAccessType() { - return accessType; - } - - /** - * @param accessType - * the accessType to set - */ - public void setAccessType(String accessType) { - this.accessType = accessType; - } - - /** - * @return the fields - */ - public Set getFields() { - return fields; - } - - /** - * @param fields - * the fields to set - */ - public void setFields(Set fields) { - this.fields = fields; - } - - /** - * @return the version - */ - public Integer getVersion() { - return version; - } - - /** - * @param version - * the version to set - */ - public void setVersion(Integer version) { - this.version = version; - } - - /** - * @return the isModified - */ - public boolean isModified() { - return isModified; - } - - /** - * @param isModified - * the isModified to set - */ - public void setModified(boolean isModified) { - this.isModified = isModified; - } - - @Override - public int compareTo(DataGridTemplate dgt) { - return templateName.compareTo(dgt.getTemplateName()); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("Template: "); - sb.append(templateName); - sb.append("\nDescription: "); - sb.append(description); - sb.append("\nOwner: "); - sb.append(owner); - sb.append("\nAccess Type: "); - sb.append(accessType); - sb.append("\nCreated: "); - sb.append(createTs); - sb.append("\nModified: "); - sb.append(modifyTs); - sb.append("\n"); - return sb.toString(); - } + private static final long serialVersionUID = 1L; + + @Id + @NotAudited + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "template_id", unique = true, nullable = false) + private Long id; + + @Column(name = "template_name", unique = true, nullable = false, length = 100) + private String templateName; + + @Column(name = "owner", nullable = false, length = 100) + private String owner; + + @Column(name = "description", nullable = false, length = 512) + private String description; + + @Column(name = "usage_info", length = 100) + private String usageInformation; + + @Column(name = "access_type", length = 32) + private String accessType; + + @Column(name = "version") + private Integer version; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name = "create_ts", nullable = false, length = 60, updatable = false) + private Date createTs; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name = "modify_ts", nullable = false, length = 60) + private Date modifyTs; + + @OneToMany(mappedBy = "template", fetch = FetchType.EAGER) + private Set fields; + + private static final int TEMPLATE_NAME_MAX_LENGTH = 100; + private static final int TEMPLATE_DESC_MAX_LENGTH = 100; + + private boolean isModified = false; + + public DataGridTemplate() { + // empty constructor + } + + public DataGridTemplate(String templateName) throws DataGridTooLongTemplateNameException { + if (templateName.length() > TEMPLATE_NAME_MAX_LENGTH) { + throw new DataGridTooLongTemplateNameException( + "Template name exceeded " + TEMPLATE_NAME_MAX_LENGTH + " characters."); + } + + this.templateName = templateName; + } + + /** + * @return the owner + */ + public String getOwner() { + return owner; + } + + /** + * @param owner + * the owner to set + */ + public void setOwner(String owner) { + this.owner = owner; + } + + /** + * @return the description + */ + public String getDescription() { + return description; + } + + /** + * @param description + * the description to set + * @throws DataGridTooLongTemplateNameException + */ + public void setDescription(String description) throws DataGridTooLongTemplateNameException { + if (description.length() > TEMPLATE_NAME_MAX_LENGTH) { + throw new DataGridTooLongTemplateNameException( + "Template description exceeded " + TEMPLATE_DESC_MAX_LENGTH + " characters."); + } + this.description = description; + } + + /** + * @return the createTs + */ + public Date getCreateTs() { + return createTs; + } + + /** + * @param createTs + * the createTs to set + */ + public void setCreateTs(Date createTs) { + this.createTs = createTs; + } + + /** + * @return the modifyTs + */ + public Date getModifyTs() { + return modifyTs; + } + + /** + * @param modifyTs + * the modifyTs to set + */ + public void setModifyTs(Date modifyTs) { + this.modifyTs = modifyTs; + } + + /** + * @return the id + */ + public long getId() { + return id; + } + + /** + * @param id + * the id to set + */ + public void setId(long id) { + this.id = id; + } + + /** + * @return the templateName + */ + public String getTemplateName() { + return templateName; + } + + /** + * @param the + * templateName to set + * @throws DataGridTooLongTemplateNameException + */ + public void setTemplateName(String templateName) throws DataGridTooLongTemplateNameException { + if (templateName.length() > TEMPLATE_NAME_MAX_LENGTH) { + throw new DataGridTooLongTemplateNameException( + "Template name exceeded " + TEMPLATE_NAME_MAX_LENGTH + " characters."); + } + + this.templateName = templateName; + } + + /** + * @return the usageInformation + */ + public String getUsageInformation() { + return usageInformation; + } + + /** + * @param usageInformation + * the usageInformation to set + */ + public void setUsageInformation(String usageInformation) { + this.usageInformation = usageInformation; + } + + /** + * @return the accessType + */ + public String getAccessType() { + return accessType; + } + + /** + * @param accessType + * the accessType to set + */ + public void setAccessType(String accessType) { + this.accessType = accessType; + } + + /** + * @return the fields + */ + public Set getFields() { + return fields; + } + + /** + * @param fields + * the fields to set + */ + public void setFields(Set fields) { + this.fields = fields; + } + + /** + * @return the version + */ + public Integer getVersion() { + return version; + } + + /** + * @param version + * the version to set + */ + public void setVersion(Integer version) { + this.version = version; + } + + /** + * @return the isModified + */ + public boolean isModified() { + return isModified; + } + + /** + * @param isModified + * the isModified to set + */ + public void setModified(boolean isModified) { + this.isModified = isModified; + } + + @Override + public int compareTo(DataGridTemplate dgt) { + return templateName.compareTo(dgt.getTemplateName()); + } + + @Override + public String toString() { + final int maxLen = 10; + StringBuilder builder = new StringBuilder(); + builder.append("DataGridTemplate ["); + if (id != null) { + builder.append("id=").append(id).append(", "); + } + if (templateName != null) { + builder.append("templateName=").append(templateName).append(", "); + } + if (owner != null) { + builder.append("owner=").append(owner).append(", "); + } + if (description != null) { + builder.append("description=").append(description).append(", "); + } + if (usageInformation != null) { + builder.append("usageInformation=").append(usageInformation).append(", "); + } + if (accessType != null) { + builder.append("accessType=").append(accessType).append(", "); + } + if (version != null) { + builder.append("version=").append(version).append(", "); + } + if (createTs != null) { + builder.append("createTs=").append(createTs).append(", "); + } + if (modifyTs != null) { + builder.append("modifyTs=").append(modifyTs).append(", "); + } + if (fields != null) { + builder.append("fields=").append(toString(fields, maxLen)).append(", "); + } + builder.append("isModified=").append(isModified).append("]"); + return builder.toString(); + } + + private String toString(Collection collection, int maxLen) { + StringBuilder builder = new StringBuilder(); + builder.append("["); + int i = 0; + for (Iterator iterator = collection.iterator(); iterator.hasNext() && i < maxLen; i++) { + if (i > 0) { + builder.append(", "); + } + builder.append(iterator.next()); + } + builder.append("]"); + return builder.toString(); + } } diff --git a/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridTemplateField.java b/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridTemplateField.java index fd96c80a6..c6e2da037 100755 --- a/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridTemplateField.java +++ b/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridTemplateField.java @@ -15,281 +15,299 @@ */ package com.emc.metalnx.core.domain.entity; -import com.emc.metalnx.core.domain.exceptions.DataGridTemplateAttrException; -import com.emc.metalnx.core.domain.exceptions.DataGridTemplateUnitException; -import com.emc.metalnx.core.domain.exceptions.DataGridTemplateValueException; +import java.io.Serializable; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.Table; + import org.hibernate.envers.Audited; import org.hibernate.envers.NotAudited; -import javax.persistence.*; -import java.io.Serializable; +import com.emc.metalnx.core.domain.exceptions.DataGridTemplateAttrException; +import com.emc.metalnx.core.domain.exceptions.DataGridTemplateUnitException; +import com.emc.metalnx.core.domain.exceptions.DataGridTemplateValueException; @Entity @Audited @Table(name = "template_fields") public class DataGridTemplateField implements Serializable, Comparable { - private static final long serialVersionUID = 1L; - - private final int MAX_ATTR_LENGTH = 100; - private final int MAX_VAL_LENGTH = 100; - private final int MAX_UNT_LENGTH = 100; - - @Id - @NotAudited - @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column(name = "template_field_id", unique = true, nullable = false) - private Long id; - - @Column(name = "attribute", length = MAX_ATTR_LENGTH) - private String attribute; - - @Column(name = "attribute_value", length = MAX_VAL_LENGTH) - private String attributeValue; - - @Column(name = "attribute_unit", length = MAX_UNT_LENGTH) - private String attributeUnit; - - @Column(name = "start_range") - private float startRange; - - @Column(name = "end_range") - private float endRange; - - @Column(name = "field_order") - private int order; - - @ManyToOne(fetch = FetchType.EAGER, optional = true) - @JoinColumn(name = "template_id", nullable = false, updatable = true) - private DataGridTemplate template; - - public DataGridTemplateField() { - - } - - public DataGridTemplateField(String attribute, String value, String unit, DataGridTemplate template) throws DataGridTemplateAttrException, - DataGridTemplateValueException, DataGridTemplateUnitException { - if (attribute == null || attribute.length() > MAX_ATTR_LENGTH) { - throw new DataGridTemplateAttrException("Template attribute is null or exceed " + MAX_ATTR_LENGTH + " characters."); - } - - if (value == null || value.length() > MAX_VAL_LENGTH) { - throw new DataGridTemplateValueException("Template attribute is null or exceed " + MAX_ATTR_LENGTH + " characters."); - } - - if (unit == null || unit.length() > MAX_UNT_LENGTH) { - throw new DataGridTemplateUnitException("Template attribute is null or exceed " + MAX_ATTR_LENGTH + " characters."); - } - - this.attribute = attribute; - attributeValue = value; - attributeUnit = unit; - this.template = template; - } - - public DataGridTemplateField(String attribute, String value, String unit) throws DataGridTemplateAttrException, DataGridTemplateValueException, - DataGridTemplateUnitException { - this(attribute, value, unit, null); - } - - /** - * @return the id - */ - public Long getId() { - return id; - } - - /** - * @param id - * the id to set - */ - public void setId(long id) { - this.id = id; - } - - /** - * @return the attribute - */ - public String getAttribute() { - return attribute; - } - - /** - * @param attribute - * the attribute to set - * @throws DataGridTemplateAttrException - */ - public void setAttribute(String attribute) throws DataGridTemplateAttrException { - if (attribute == null || attribute.length() > MAX_ATTR_LENGTH) { - throw new DataGridTemplateAttrException("Template attribute is null or exceed " + MAX_ATTR_LENGTH + " characters."); - } - - this.attribute = attribute; - } - - /** - * @return the value - */ - public String getValue() { - return attributeValue; - } - - /** - * @param value - * the value to set - * @throws DataGridTemplateValueException - */ - public void setValue(String value) throws DataGridTemplateValueException { - if (value == null || value.length() > MAX_VAL_LENGTH) { - throw new DataGridTemplateValueException("Template attribute is null or exceed " + MAX_ATTR_LENGTH + " characters."); - } - - attributeValue = value; - } - - /** - * @return the unit - */ - public String getUnit() { - return attributeUnit; - } - - /** - * @param unit - * the unit to set - * @throws DataGridTemplateUnitException - */ - public void setUnit(String unit) throws DataGridTemplateUnitException { - if (unit == null || unit.length() > MAX_UNT_LENGTH) { - throw new DataGridTemplateUnitException("Template attribute is null or exceed " + MAX_ATTR_LENGTH + " characters."); - } - - attributeUnit = unit; - } - - /** - * @return the template - */ - public DataGridTemplate getTemplate() { - return template; - } - - /** - * @param template - * the template to set - */ - public void setTemplate(DataGridTemplate template) { - this.template = template; - } - - /** - * @return the startRange - */ - public float getStartRange() { - return startRange; - } - - /** - * @param startRange - * the startRange to set - */ - public void setStartRange(float startRange) { - this.startRange = startRange; - } - - /** - * @return the endRange - */ - public float getEndRange() { - return endRange; - } - - /** - * @param endRange - * the endRange to set - */ - public void setEndRange(float endRange) { - this.endRange = endRange; - } - - /** - * @return the order - */ - public int getOrder() { - return order; - } - - /** - * @param order - * the order to set - */ - public void setOrder(int order) { - this.order = order; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("Id: "); - sb.append(id); - sb.append("\nAttribute: "); - sb.append(getAttribute()); - sb.append("\nValue: "); - sb.append(getValue()); - sb.append("\nUnit: "); - sb.append(getUnit()); - sb.append("\nOrder: "); - sb.append(getOrder()); - sb.append("\nStart Range: "); - sb.append(getStartRange()); - sb.append("\nEnd Range: "); - sb.append(getEndRange()); - sb.append("\nTemplate: "); - sb.append(getTemplate().getTemplateName()); - return sb.toString(); - } - - @Override - public int compareTo(DataGridTemplateField dgmf) { - if (attribute != null) { - return attribute.compareTo(dgmf.getAttribute()); - } - else if (attributeValue != null) { - return attributeValue.compareTo(dgmf.getValue()); - } - else if (attributeUnit != null) { - return attributeUnit.compareTo(dgmf.getUnit()); - } - - return 0; - } - - @Override - public boolean equals(Object obj) { - if (obj == null) { - return false; - } - - if (obj instanceof DataGridTemplateField) { - DataGridTemplateField dgmf = (DataGridTemplateField) obj; - - if (dgmf.getAttribute() == null || dgmf.getValue() == null) { - return false; - } - - boolean areAttributesEqual = getAttribute().equals(dgmf.getAttribute()); - boolean areValuesEqual = getValue().equals(dgmf.getValue()); - - if (areAttributesEqual && areValuesEqual) { - return true; - } - } - - return false; - } - - @Override - public int hashCode() { - return (getAttribute() + getValue()).hashCode(); - } + private static final long serialVersionUID = 1L; + + private final int MAX_ATTR_LENGTH = 100; + private final int MAX_VAL_LENGTH = 100; + private final int MAX_UNT_LENGTH = 100; + + @Id + @NotAudited + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "template_field_id", unique = true, nullable = false) + private Long id; + + @Column(name = "attribute", length = MAX_ATTR_LENGTH) + private String attribute; + + @Column(name = "attribute_value", length = MAX_VAL_LENGTH) + private String attributeValue; + + @Column(name = "attribute_unit", length = MAX_UNT_LENGTH) + private String attributeUnit; + + @Column(name = "start_range") + private float startRange; + + @Column(name = "end_range") + private float endRange; + + @Column(name = "field_order") + private int order; + + @ManyToOne(fetch = FetchType.EAGER, optional = true) + @JoinColumn(name = "template_id", nullable = false, updatable = true) + private DataGridTemplate template; + + public DataGridTemplateField() { + + } + + public DataGridTemplateField(String attribute, String value, String unit, DataGridTemplate template) + throws DataGridTemplateAttrException, DataGridTemplateValueException, DataGridTemplateUnitException { + if (attribute == null || attribute.length() > MAX_ATTR_LENGTH) { + throw new DataGridTemplateAttrException( + "Template attribute is null or exceed " + MAX_ATTR_LENGTH + " characters."); + } + + if (value == null || value.length() > MAX_VAL_LENGTH) { + throw new DataGridTemplateValueException( + "Template attribute is null or exceed " + MAX_ATTR_LENGTH + " characters."); + } + + if (unit == null || unit.length() > MAX_UNT_LENGTH) { + throw new DataGridTemplateUnitException( + "Template attribute is null or exceed " + MAX_ATTR_LENGTH + " characters."); + } + + this.attribute = attribute; + attributeValue = value; + attributeUnit = unit; + this.template = template; + } + + public DataGridTemplateField(String attribute, String value, String unit) + throws DataGridTemplateAttrException, DataGridTemplateValueException, DataGridTemplateUnitException { + this(attribute, value, unit, null); + } + + /** + * @return the id + */ + public Long getId() { + return id; + } + + /** + * @param id + * the id to set + */ + public void setId(long id) { + this.id = id; + } + + /** + * @return the attribute + */ + public String getAttribute() { + return attribute; + } + + /** + * @param attribute + * the attribute to set + * @throws DataGridTemplateAttrException + */ + public void setAttribute(String attribute) throws DataGridTemplateAttrException { + if (attribute == null || attribute.length() > MAX_ATTR_LENGTH) { + throw new DataGridTemplateAttrException( + "Template attribute is null or exceed " + MAX_ATTR_LENGTH + " characters."); + } + + this.attribute = attribute; + } + + /** + * @return the value + */ + public String getValue() { + return attributeValue; + } + + /** + * @param value + * the value to set + * @throws DataGridTemplateValueException + */ + public void setValue(String value) throws DataGridTemplateValueException { + if (value == null || value.length() > MAX_VAL_LENGTH) { + throw new DataGridTemplateValueException( + "Template attribute is null or exceed " + MAX_ATTR_LENGTH + " characters."); + } + + attributeValue = value; + } + + /** + * @return the unit + */ + public String getUnit() { + return attributeUnit; + } + + /** + * @param unit + * the unit to set + * @throws DataGridTemplateUnitException + */ + public void setUnit(String unit) throws DataGridTemplateUnitException { + if (unit == null || unit.length() > MAX_UNT_LENGTH) { + throw new DataGridTemplateUnitException( + "Template attribute is null or exceed " + MAX_ATTR_LENGTH + " characters."); + } + + attributeUnit = unit; + } + + /** + * @return the template + */ + public DataGridTemplate getTemplate() { + return template; + } + + /** + * @param template + * the template to set + */ + public void setTemplate(DataGridTemplate template) { + this.template = template; + } + + /** + * @return the startRange + */ + public float getStartRange() { + return startRange; + } + + /** + * @param startRange + * the startRange to set + */ + public void setStartRange(float startRange) { + this.startRange = startRange; + } + + /** + * @return the endRange + */ + public float getEndRange() { + return endRange; + } + + /** + * @param endRange + * the endRange to set + */ + public void setEndRange(float endRange) { + this.endRange = endRange; + } + + /** + * @return the order + */ + public int getOrder() { + return order; + } + + /** + * @param order + * the order to set + */ + public void setOrder(int order) { + this.order = order; + } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("DataGridTemplateField [MAX_ATTR_LENGTH=").append(MAX_ATTR_LENGTH).append(", MAX_VAL_LENGTH=") + .append(MAX_VAL_LENGTH).append(", MAX_UNT_LENGTH=").append(MAX_UNT_LENGTH).append(", "); + if (id != null) { + builder.append("id=").append(id).append(", "); + } + if (attribute != null) { + builder.append("attribute=").append(attribute).append(", "); + } + if (attributeValue != null) { + builder.append("attributeValue=").append(attributeValue).append(", "); + } + if (attributeUnit != null) { + builder.append("attributeUnit=").append(attributeUnit).append(", "); + } + builder.append("startRange=").append(startRange).append(", endRange=").append(endRange).append(", order=") + .append(order).append(", "); + if (template != null) { + builder.append("template=").append(template); + } + builder.append("]"); + return builder.toString(); + } + + @Override + public int compareTo(DataGridTemplateField dgmf) { + if (attribute != null) { + return attribute.compareTo(dgmf.getAttribute()); + } else if (attributeValue != null) { + return attributeValue.compareTo(dgmf.getValue()); + } else if (attributeUnit != null) { + return attributeUnit.compareTo(dgmf.getUnit()); + } + + return 0; + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + + if (obj instanceof DataGridTemplateField) { + DataGridTemplateField dgmf = (DataGridTemplateField) obj; + + if (dgmf.getAttribute() == null || dgmf.getValue() == null) { + return false; + } + + boolean areAttributesEqual = getAttribute().equals(dgmf.getAttribute()); + boolean areValuesEqual = getValue().equals(dgmf.getValue()); + + if (areAttributesEqual && areValuesEqual) { + return true; + } + } + + return false; + } + + @Override + public int hashCode() { + return (getAttribute() + getValue()).hashCode(); + } } diff --git a/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridTicket.java b/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridTicket.java index 82f872833..d9d9f88b0 100755 --- a/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridTicket.java +++ b/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridTicket.java @@ -16,11 +16,6 @@ package com.emc.metalnx.core.domain.entity; -import com.emc.metalnx.core.domain.utils.DataGridJsonDateDeserializer; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.io.Serializable; import java.text.ParseException; import java.text.SimpleDateFormat; @@ -28,239 +23,291 @@ import java.util.Date; import java.util.List; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.emc.metalnx.core.domain.utils.DataGridJsonDateDeserializer; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + /** * Class that represents a ticket. */ public class DataGridTicket implements Serializable { - private static final Logger logger = LoggerFactory.getLogger(DataGridTicket.class); - public static final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); - - private String ticketString, path, owner; - private TicketType type; - private boolean isCollection; - private int usesLimit; - private int usesCount; - private long writeByteLimit; - private long writeByteCount; - private int writeFileLimit; - private int writeFileCount; - - @JsonDeserialize(using = DataGridJsonDateDeserializer.class) - private Date expirationDate; - - private String expirationDateStr; - - // Ticket restrictions - private List hosts; - private List users; - private List groups; - - public enum TicketType { - READ, WRITE, UNKNOWN; - } - - /** - * Empty constructor - */ - public DataGridTicket() { - this(""); - } - - /** - * Constructor. - * @param path path in the grid that the ticket - */ - public DataGridTicket(String path) { - this.path = path; - ticketString = ""; - owner = ""; - expirationDateStr = ""; - type = TicketType.READ; - usesLimit = 0; - writeByteLimit = 0; - hosts = new ArrayList<>(); - users = new ArrayList<>(); - groups = new ArrayList<>(); - } - - public void addHost(String newHost) { - if(hosts == null) hosts = new ArrayList<>(); - if(!hosts.contains(newHost)) hosts.add(newHost); - } - - public void addUser(String user) { - if(users == null) users = new ArrayList<>(); - if(!users.contains(user)) users.add(user); - } - - public void addGroup(String group) { - if(groups == null) groups = new ArrayList<>(); - if(!groups.contains(group)) groups.add(group); - } - - public void setGroups(List groups) { - this.groups = groups; - } - - public void setUsers(List users) { - this.users = users; - } - - public void setHosts(List hosts) { - this.hosts = hosts; - } - - public void setWriteFileLimit(int writeFileLimit) { - this.writeFileLimit = writeFileLimit; - } - - public void setWriteFileCount(int writeFileCount) { - this.writeFileCount = writeFileCount; - } - - public void setWriteByteLimit(long writeByteLimit) { - this.writeByteLimit = writeByteLimit; - } - - public void setWriteByteCount(long writeByteCount) { - this.writeByteCount = writeByteCount; - } - - public void setUsesCount(int usesCount) { - this.usesCount = usesCount; - } - - public void setExpirationDate(Date expirationDate) { - this.expirationDate = expirationDate; - } - - public void setExpirationDateStr(String expirationDateStr) { - if (expirationDateStr == null) { - this.expirationDateStr = ""; - return; - } - this.expirationDateStr = expirationDateStr; - } - - public void setUsesLimit(int usesLimit) { - this.usesLimit = usesLimit; - } - - public void setTicketString(String ticketString) { - this.ticketString = ticketString; - } - - public void setPath(String path) { - this.path = path; - } - - public void setOwner(String owner) { - this.owner = owner; - } - - public void setType(TicketType type) { - this.type = type; - } - - /** - * Tells whether or not the ticket is for a collection. - * @param isTicketForCollection True if the path associated to the ticket is a collection. False, otherwise. - */ - public void setIsCollection(boolean isTicketForCollection) { - isCollection = isTicketForCollection; - } - - public List getGroups() { - if(groups == null) users = new ArrayList<>(); - return groups; - } - - public List getUsers() { - if(users == null) users = new ArrayList<>(); - return users; - } - - public List getHosts() { - if(hosts == null) users = new ArrayList<>(); - return hosts; - } - - public int getWriteFileLimit() { - return writeFileLimit; - } - - public int getWriteFileCount() { - return writeFileCount; - } - - public long getWriteByteCount() { - return writeByteCount; - } - - public long getWriteByteLimit() { - return writeByteLimit; - } - - public int getUsesCount() { - return usesCount; - } - - public String getExpirationDateStr() { - if (expirationDate != null) { - expirationDateStr = dateFormat.format(expirationDate); - } else if (expirationDateStr.isEmpty()) { - expirationDateStr = ""; - } - return expirationDateStr; - } - - public Date getExpirationDate() { - if (!expirationDateStr.isEmpty()) { - try { - expirationDate = dateFormat.parse(expirationDateStr); - } catch (ParseException e) { - logger.error("Could not parse expiration date"); - } - } - - return expirationDate; - } - - public int getUsesLimit() { - return usesLimit; - } - - public String getTicketString() { - if(ticketString == null) ticketString = ""; - return ticketString; - } - - public String getPath() { - if(path == null) path = ""; - return path; - } - - public String getOwner() { - if(owner == null) owner = ""; - return owner; - } - - public TicketType getType() { - return type; - } - - public boolean isCollection() { - return isCollection; - } - - @Override - public String toString() { - return "DataGridTicket{" + - "ticketString='" + ticketString + '\'' + - ", path='" + path + '\'' + - ", owner='" + owner + '\'' + - ", type=" + type + - ", isCollection=" + isCollection + - '}'; - } + private static final Logger logger = LoggerFactory.getLogger(DataGridTicket.class); + public static final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); + + private String ticketString, path, owner; + private TicketType type; + private boolean isCollection; + private int usesLimit; + private int usesCount; + private long writeByteLimit; + private long writeByteCount; + private int writeFileLimit; + private int writeFileCount; + + @JsonDeserialize(using = DataGridJsonDateDeserializer.class) + private Date expirationDate; + + private String expirationDateStr; + + // Ticket restrictions + private List hosts; + private List users; + private List groups; + + public enum TicketType { + READ, WRITE, UNKNOWN; + } + + /** + * Empty constructor + */ + public DataGridTicket() { + this(""); + } + + /** + * Constructor. + * + * @param path + * path in the grid that the ticket + */ + public DataGridTicket(String path) { + this.path = path; + ticketString = ""; + owner = ""; + expirationDateStr = ""; + type = TicketType.READ; + usesLimit = 0; + writeByteLimit = 0; + hosts = new ArrayList<>(); + users = new ArrayList<>(); + groups = new ArrayList<>(); + } + + public void addHost(String newHost) { + if (hosts == null) + hosts = new ArrayList<>(); + if (!hosts.contains(newHost)) + hosts.add(newHost); + } + + public void addUser(String user) { + if (users == null) + users = new ArrayList<>(); + if (!users.contains(user)) + users.add(user); + } + + public void addGroup(String group) { + if (groups == null) + groups = new ArrayList<>(); + if (!groups.contains(group)) + groups.add(group); + } + + public void setGroups(List groups) { + this.groups = groups; + } + + public void setUsers(List users) { + this.users = users; + } + + public void setHosts(List hosts) { + this.hosts = hosts; + } + + public void setWriteFileLimit(int writeFileLimit) { + this.writeFileLimit = writeFileLimit; + } + + public void setWriteFileCount(int writeFileCount) { + this.writeFileCount = writeFileCount; + } + + public void setWriteByteLimit(long writeByteLimit) { + this.writeByteLimit = writeByteLimit; + } + + public void setWriteByteCount(long writeByteCount) { + this.writeByteCount = writeByteCount; + } + + public void setUsesCount(int usesCount) { + this.usesCount = usesCount; + } + + public void setExpirationDate(Date expirationDate) { + this.expirationDate = expirationDate; + } + + public void setExpirationDateStr(String expirationDateStr) { + if (expirationDateStr == null) { + this.expirationDateStr = ""; + return; + } + this.expirationDateStr = expirationDateStr; + } + + public void setUsesLimit(int usesLimit) { + this.usesLimit = usesLimit; + } + + public void setTicketString(String ticketString) { + this.ticketString = ticketString; + } + + public void setPath(String path) { + this.path = path; + } + + public void setOwner(String owner) { + this.owner = owner; + } + + public void setType(TicketType type) { + this.type = type; + } + + /** + * Tells whether or not the ticket is for a collection. + * + * @param isTicketForCollection + * True if the path associated to the ticket is a collection. False, + * otherwise. + */ + public void setIsCollection(boolean isTicketForCollection) { + isCollection = isTicketForCollection; + } + + public List getGroups() { + if (groups == null) + users = new ArrayList<>(); + return groups; + } + + public List getUsers() { + if (users == null) + users = new ArrayList<>(); + return users; + } + + public List getHosts() { + if (hosts == null) + users = new ArrayList<>(); + return hosts; + } + + public int getWriteFileLimit() { + return writeFileLimit; + } + + public int getWriteFileCount() { + return writeFileCount; + } + + public long getWriteByteCount() { + return writeByteCount; + } + + public long getWriteByteLimit() { + return writeByteLimit; + } + + public int getUsesCount() { + return usesCount; + } + + public String getExpirationDateStr() { + if (expirationDate != null) { + expirationDateStr = dateFormat.format(expirationDate); + } else if (expirationDateStr.isEmpty()) { + expirationDateStr = ""; + } + return expirationDateStr; + } + + public Date getExpirationDate() { + if (!expirationDateStr.isEmpty()) { + try { + expirationDate = dateFormat.parse(expirationDateStr); + } catch (ParseException e) { + logger.error("Could not parse expiration date"); + } + } + + return expirationDate; + } + + public int getUsesLimit() { + return usesLimit; + } + + public String getTicketString() { + if (ticketString == null) + ticketString = ""; + return ticketString; + } + + public String getPath() { + if (path == null) + path = ""; + return path; + } + + public String getOwner() { + if (owner == null) + owner = ""; + return owner; + } + + public TicketType getType() { + return type; + } + + public boolean isCollection() { + return isCollection; + } + + @Override + public String toString() { + final int maxLen = 10; + StringBuilder builder = new StringBuilder(); + builder.append("DataGridTicket ["); + if (ticketString != null) { + builder.append("ticketString=").append(ticketString).append(", "); + } + if (path != null) { + builder.append("path=").append(path).append(", "); + } + if (owner != null) { + builder.append("owner=").append(owner).append(", "); + } + if (type != null) { + builder.append("type=").append(type).append(", "); + } + builder.append("isCollection=").append(isCollection).append(", usesLimit=").append(usesLimit) + .append(", usesCount=").append(usesCount).append(", writeByteLimit=").append(writeByteLimit) + .append(", writeByteCount=").append(writeByteCount).append(", writeFileLimit=").append(writeFileLimit) + .append(", writeFileCount=").append(writeFileCount).append(", "); + if (expirationDate != null) { + builder.append("expirationDate=").append(expirationDate).append(", "); + } + if (expirationDateStr != null) { + builder.append("expirationDateStr=").append(expirationDateStr).append(", "); + } + if (hosts != null) { + builder.append("hosts=").append(hosts.subList(0, Math.min(hosts.size(), maxLen))).append(", "); + } + if (users != null) { + builder.append("users=").append(users.subList(0, Math.min(users.size(), maxLen))).append(", "); + } + if (groups != null) { + builder.append("groups=").append(groups.subList(0, Math.min(groups.size(), maxLen))); + } + builder.append("]"); + return builder.toString(); + } } diff --git a/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridUser.java b/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridUser.java index f152bfe34..0290bc5b7 100755 --- a/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridUser.java +++ b/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridUser.java @@ -15,424 +15,513 @@ */ package com.emc.metalnx.core.domain.entity; -import org.hibernate.envers.Audited; -import org.hibernate.envers.NotAudited; - -import javax.persistence.*; import java.io.Serializable; import java.util.ArrayList; +import java.util.Collection; import java.util.Collections; +import java.util.Iterator; import java.util.List; import java.util.Set; +import javax.persistence.CascadeType; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.OneToMany; +import javax.persistence.Table; +import javax.persistence.UniqueConstraint; + +import org.hibernate.envers.Audited; +import org.hibernate.envers.NotAudited; + @Entity @Audited -@Table(name = "users", uniqueConstraints = @UniqueConstraint(columnNames = { "username", "additional_info" }) ) +@Table(name = "users", uniqueConstraints = @UniqueConstraint(columnNames = { "username", "additional_info" })) public class DataGridUser implements Serializable, Comparable { - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - @NotAudited - private Long id; + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @NotAudited + private Long id; + + @Column(name = "data_grid_id", unique = true, nullable = false) + private long dataGridId; + + @Column(name = "username", nullable = false, length = 60, unique = true) + private String username; - @Column(name = "data_grid_id", unique = true, nullable = false) - private long dataGridId; + private String password; - @Column(name = "username", nullable = false, length = 60, unique = true) - private String username; + @Column(name = "additional_info", nullable = true, length = 128) + private String additionalInfo; - private String password; + @Column(name = "enabled", nullable = false) + private boolean enabled; - @Column(name = "additional_info", nullable = true, length = 128) - private String additionalInfo; + @Column(name = "first_name") + private String firstName; - @Column(name = "enabled", nullable = false) - private boolean enabled; + @Column(name = "last_name") + private String lastName; - @Column(name = "first_name") - private String firstName; + @Column(name = "email", nullable = true) + private String email; - @Column(name = "last_name") - private String lastName; + @Column(name = "locale") + private String locale = "en"; + + @Column(name = "forceFileOverwriting", nullable = false) + private boolean forceFileOverwriting = false; - @Column(name = "email", nullable = true) - private String email; - - @Column(name = "locale") - private String locale = "en"; - - @Column(name = "forceFileOverwriting", nullable = false) - private boolean forceFileOverwriting = false; - - @Column(name = "user_type", nullable = false, length = 60) - private String userType; - - @Column(name = "organizational_role", nullable = true, length = 60) - private String organizationalRole; - - @ManyToOne(fetch = FetchType.EAGER, optional = true) - @JoinColumn(name = "userProfile_id", nullable = true, updatable = true) - private UserProfile userProfile; - - @Column(name = "user_company", nullable = true, length = 60) - private String company; - - @Column(name = "user_department", nullable = true, length = 60) - private String department; - - @Column(name = "user_title", nullable = true, length = 60) - private String title; - - @Column(name = "advanced_view", nullable =false) - private boolean advancedView; - - @OneToMany(mappedBy = "user", fetch = FetchType.EAGER, cascade = CascadeType.DETACH, orphanRemoval = true) - private Set bookmarks; - - @OneToMany(mappedBy = "user", fetch = FetchType.EAGER, cascade = CascadeType.DETACH, orphanRemoval = true) - private Set favorites; - - private static final long serialVersionUID = -500578459147421831L; - - public DataGridUser() { - - } - - public DataGridUser(String username, String password, boolean enabled) { - this.username = username; - this.enabled = enabled; - } - - public String getDisplayName() { - if (firstName != null && !firstName.isEmpty()) { - return firstName; - } - - return username; - } - - /** - * Gets the user bookmarks sorted in ascending order - * - * @return the userBookmarks - */ - public List getBookmarksSorted() { - List bookmarksSorted = new ArrayList(bookmarks); - Collections.sort(bookmarksSorted); - return bookmarksSorted; - } - - /** - * @return the userBookmarks - */ - public Set getBookmarks() { - return bookmarks; - } - - /** - * @param userBookmarks - * the userBookmarks to set - */ - public void setUserBookmarks(Set userBookmarks) { - bookmarks = userBookmarks; - } - - /** - * Gets the user favorites sorted in ascending order - * - * @return the userFavorites - */ - public List getFavoritesSorted() { - List favoritesSorted = new ArrayList(favorites); - Collections.sort(favoritesSorted); - return favoritesSorted; - } - - /** - * @return the userFavorites - */ - public Set getFavorites() { - return favorites; - } - - /** - * @param userFavorites - * the userFavorites to set - */ - public void setUserFavorites(Set userFavorites) { - favorites = userFavorites; - } - - /** - * @return the id - */ - public long getId() { - return id; - } - - /** - * @return the dataGridId - */ - public long getDataGridId() { - return dataGridId; - } - - /** - * @return the username - */ - public String getUsername() { - return username; - } - - /** - * @return the additionalInfo - */ - public String getAdditionalInfo() { - return additionalInfo; - } - - /** - * @return the enabled - */ - public boolean isEnabled() { - return enabled; - } - - /** - * @return the advanced_view - */ - public boolean isAdvancedView() { - return advancedView; - } - - /** - * @param id - * the id to set - */ - public void setId(long id) { - this.id = id; - } - - /** - * @param dataGridId - * the dataGridId to set - */ - public void setDataGridId(long dataGridId) { - this.dataGridId = dataGridId; - } - - /** - * @param username - * the username to set - */ - public void setUsername(String username) { - this.username = username; - } - - /** - * @param additionalInfo - * the additionalInfo to set - */ - public void setAdditionalInfo(String additionalInfo) { - this.additionalInfo = additionalInfo; - } - - /** - * @param enabled - * the enabled to set - */ - public void setEnabled(boolean enabled) { - this.enabled = enabled; - } - - /** - * @param advancedView - * to set - */ - public void setAdvanceView(boolean advancedView) { - this.advancedView = advancedView; - } - - /** - * @return the firstName - */ - public String getFirstName() { - return firstName; - } - - /** - * @return the lastName - */ - public String getLastName() { - return lastName; - } - - /** - * @param firstName - * the firstName to set - */ - public void setFirstName(String firstName) { - this.firstName = firstName; - } - - /** - * @param lastName - * the lastName to set - */ - public void setLastName(String lastName) { - this.lastName = lastName; - } - - /** - * @return the email - */ - public String getEmail() { - return email; - } - - /** - * @param email - * the email to set - */ - public void setEmail(String email) { - this.email = email; - } - - /** - * @return the userProfile - */ - public UserProfile getUserProfile() { - return userProfile; - } - - /** - * @param userProfile - * the userProfile to set - */ - public void setUserProfile(UserProfile userProfile) { - this.userProfile = userProfile; - } - - /** - * @return the locale - */ - public String getLocale() { - return locale; - } - - /** - * @param locale - * the locale to set - */ - public void setLocale(String locale) { - this.locale = locale; - } - - public String getUserType() { - return userType; - } - - public void setUserType(String userType) { - this.userType = userType; - } - - /** - * @return the organizationalRole - */ - public String getOrganizationalRole() { - return organizationalRole; - } - - /** - * @param organizationalRole - * the organizationalRole to set - */ - public void setOrganizationalRole(String organizationalRole) { - this.organizationalRole = organizationalRole; - } - - /** - * @return the company - */ - public String getCompany() { - return company; - } - - /** - * @return the department - */ - public String getDepartment() { - return department; - } - - /** - * @return the title - */ - public String getTitle() { - return title; - } - - /** - * @param company - * the company to set - */ - public void setCompany(String company) { - this.company = company; - } - - /** - * @param department - * the department to set - */ - public void setDepartment(String department) { - this.department = department; - } - - /** - * @param title - * the title to set - */ - public void setTitle(String title) { - this.title = title; - } - - @Override - public int compareTo(DataGridUser o) { - return username.compareTo(o.getUsername()); - } - - public boolean isAdmin() { - return userType.compareTo("rodsadmin") == 0; - } - - /** - * @return the forceFileOverwriting - */ - public boolean isForceFileOverwriting() { - return forceFileOverwriting; - } - - /** - * @param forceFileOverwriting - * the forceFileOverwriting to set - */ - public void setForceFileOverwriting(boolean forceFileOverwriting) { - this.forceFileOverwriting = forceFileOverwriting; - } - - /** - * @return the password - */ - public String getPassword() { - return password; - } - - /** - * @param password - * the password to set - */ - public void setPassword(String password) { - this.password = password; - } + @Column(name = "user_type", nullable = false, length = 60) + private String userType; + + @Column(name = "organizational_role", nullable = true, length = 60) + private String organizationalRole; + + @ManyToOne(fetch = FetchType.EAGER, optional = true) + @JoinColumn(name = "userProfile_id", nullable = true, updatable = true) + private UserProfile userProfile; + + @Column(name = "user_company", nullable = true, length = 60) + private String company; + + @Column(name = "user_department", nullable = true, length = 60) + private String department; + + @Column(name = "user_title", nullable = true, length = 60) + private String title; + + @Column(name = "advanced_view", nullable = false) + private boolean advancedView; + + @OneToMany(mappedBy = "user", fetch = FetchType.EAGER, cascade = CascadeType.DETACH, orphanRemoval = true) + private Set bookmarks; + + @OneToMany(mappedBy = "user", fetch = FetchType.EAGER, cascade = CascadeType.DETACH, orphanRemoval = true) + private Set favorites; + + private static final long serialVersionUID = -500578459147421831L; + + public DataGridUser() { + + } + + public DataGridUser(String username, String password, boolean enabled) { + this.username = username; + this.enabled = enabled; + } + + public String getDisplayName() { + if (firstName != null && !firstName.isEmpty()) { + return firstName; + } + + return username; + } + + /** + * Gets the user bookmarks sorted in ascending order + * + * @return the userBookmarks + */ + public List getBookmarksSorted() { + List bookmarksSorted = new ArrayList(bookmarks); + Collections.sort(bookmarksSorted); + return bookmarksSorted; + } + + /** + * @return the userBookmarks + */ + public Set getBookmarks() { + return bookmarks; + } + + /** + * @param userBookmarks + * the userBookmarks to set + */ + public void setUserBookmarks(Set userBookmarks) { + bookmarks = userBookmarks; + } + + /** + * Gets the user favorites sorted in ascending order + * + * @return the userFavorites + */ + public List getFavoritesSorted() { + List favoritesSorted = new ArrayList(favorites); + Collections.sort(favoritesSorted); + return favoritesSorted; + } + + /** + * @return the userFavorites + */ + public Set getFavorites() { + return favorites; + } + + /** + * @param userFavorites + * the userFavorites to set + */ + public void setUserFavorites(Set userFavorites) { + favorites = userFavorites; + } + + /** + * @return the id + */ + public long getId() { + return id; + } + + /** + * @return the dataGridId + */ + public long getDataGridId() { + return dataGridId; + } + + /** + * @return the username + */ + public String getUsername() { + return username; + } + + /** + * @return the additionalInfo + */ + public String getAdditionalInfo() { + return additionalInfo; + } + + /** + * @return the enabled + */ + public boolean isEnabled() { + return enabled; + } + + /** + * @return the advanced_view + */ + public boolean isAdvancedView() { + return advancedView; + } + + /** + * @param id + * the id to set + */ + public void setId(long id) { + this.id = id; + } + + /** + * @param dataGridId + * the dataGridId to set + */ + public void setDataGridId(long dataGridId) { + this.dataGridId = dataGridId; + } + + /** + * @param username + * the username to set + */ + public void setUsername(String username) { + this.username = username; + } + + /** + * @param additionalInfo + * the additionalInfo to set + */ + public void setAdditionalInfo(String additionalInfo) { + this.additionalInfo = additionalInfo; + } + + /** + * @param enabled + * the enabled to set + */ + public void setEnabled(boolean enabled) { + this.enabled = enabled; + } + + /** + * @param advancedView + * to set + */ + public void setAdvanceView(boolean advancedView) { + this.advancedView = advancedView; + } + + /** + * @return the firstName + */ + public String getFirstName() { + return firstName; + } + + /** + * @return the lastName + */ + public String getLastName() { + return lastName; + } + + /** + * @param firstName + * the firstName to set + */ + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + /** + * @param lastName + * the lastName to set + */ + public void setLastName(String lastName) { + this.lastName = lastName; + } + + /** + * @return the email + */ + public String getEmail() { + return email; + } + + /** + * @param email + * the email to set + */ + public void setEmail(String email) { + this.email = email; + } + + /** + * @return the userProfile + */ + public UserProfile getUserProfile() { + return userProfile; + } + + /** + * @param userProfile + * the userProfile to set + */ + public void setUserProfile(UserProfile userProfile) { + this.userProfile = userProfile; + } + + /** + * @return the locale + */ + public String getLocale() { + return locale; + } + + /** + * @param locale + * the locale to set + */ + public void setLocale(String locale) { + this.locale = locale; + } + + public String getUserType() { + return userType; + } + + public void setUserType(String userType) { + this.userType = userType; + } + + /** + * @return the organizationalRole + */ + public String getOrganizationalRole() { + return organizationalRole; + } + + /** + * @param organizationalRole + * the organizationalRole to set + */ + public void setOrganizationalRole(String organizationalRole) { + this.organizationalRole = organizationalRole; + } + + /** + * @return the company + */ + public String getCompany() { + return company; + } + + /** + * @return the department + */ + public String getDepartment() { + return department; + } + + /** + * @return the title + */ + public String getTitle() { + return title; + } + + /** + * @param company + * the company to set + */ + public void setCompany(String company) { + this.company = company; + } + + /** + * @param department + * the department to set + */ + public void setDepartment(String department) { + this.department = department; + } + + /** + * @param title + * the title to set + */ + public void setTitle(String title) { + this.title = title; + } + + @Override + public int compareTo(DataGridUser o) { + return username.compareTo(o.getUsername()); + } + + public boolean isAdmin() { + return userType.compareTo("rodsadmin") == 0; + } + + /** + * @return the forceFileOverwriting + */ + public boolean isForceFileOverwriting() { + return forceFileOverwriting; + } + + /** + * @param forceFileOverwriting + * the forceFileOverwriting to set + */ + public void setForceFileOverwriting(boolean forceFileOverwriting) { + this.forceFileOverwriting = forceFileOverwriting; + } + + /** + * @return the password + */ + public String getPassword() { + return password; + } + + /** + * @param password + * the password to set + */ + public void setPassword(String password) { + this.password = password; + } + + @Override + public String toString() { + final int maxLen = 10; + StringBuilder builder = new StringBuilder(); + builder.append("DataGridUser ["); + if (id != null) { + builder.append("id=").append(id).append(", "); + } + builder.append("dataGridId=").append(dataGridId).append(", "); + if (username != null) { + builder.append("username=").append(username).append(", "); + } + if (password != null) { + builder.append("password=").append(password).append(", "); + } + if (additionalInfo != null) { + builder.append("additionalInfo=").append(additionalInfo).append(", "); + } + builder.append("enabled=").append(enabled).append(", "); + if (firstName != null) { + builder.append("firstName=").append(firstName).append(", "); + } + if (lastName != null) { + builder.append("lastName=").append(lastName).append(", "); + } + if (email != null) { + builder.append("email=").append(email).append(", "); + } + if (locale != null) { + builder.append("locale=").append(locale).append(", "); + } + builder.append("forceFileOverwriting=").append(forceFileOverwriting).append(", "); + if (userType != null) { + builder.append("userType=").append(userType).append(", "); + } + if (organizationalRole != null) { + builder.append("organizationalRole=").append(organizationalRole).append(", "); + } + if (userProfile != null) { + builder.append("userProfile=").append(userProfile).append(", "); + } + if (company != null) { + builder.append("company=").append(company).append(", "); + } + if (department != null) { + builder.append("department=").append(department).append(", "); + } + if (title != null) { + builder.append("title=").append(title).append(", "); + } + builder.append("advancedView=").append(advancedView).append(", "); + if (bookmarks != null) { + builder.append("bookmarks=").append(toString(bookmarks, maxLen)).append(", "); + } + if (favorites != null) { + builder.append("favorites=").append(toString(favorites, maxLen)); + } + builder.append("]"); + return builder.toString(); + } + + private String toString(Collection collection, int maxLen) { + StringBuilder builder = new StringBuilder(); + builder.append("["); + int i = 0; + for (Iterator iterator = collection.iterator(); iterator.hasNext() && i < maxLen; i++) { + if (i > 0) { + builder.append(", "); + } + builder.append(iterator.next()); + } + builder.append("]"); + return builder.toString(); + } } diff --git a/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridUserBookmark.java b/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridUserBookmark.java index 7ed6f68b3..4148f0f7f 100755 --- a/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridUserBookmark.java +++ b/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridUserBookmark.java @@ -15,170 +15,211 @@ */ package com.emc.metalnx.core.domain.entity; -import com.emc.metalnx.core.domain.utils.DataGridCoreUtils; -import com.fasterxml.jackson.annotation.JsonIgnore; -import org.hibernate.envers.Audited; -import org.hibernate.envers.NotAudited; - -import javax.persistence.*; import java.io.Serializable; import java.text.SimpleDateFormat; import java.util.Date; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + +import org.hibernate.envers.Audited; +import org.hibernate.envers.NotAudited; + +import com.emc.metalnx.core.domain.utils.DataGridCoreUtils; +import com.fasterxml.jackson.annotation.JsonIgnore; + @Entity @Audited @Table(name = "user_bookmarks") public class DataGridUserBookmark implements Serializable, Comparable { - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - @NotAudited - @Column(name = "id", unique = true, nullable = false) - private Long id; - - @ManyToOne(fetch = FetchType.EAGER, optional = true) - @JoinColumn(name = "user_id", nullable = false, updatable = true) - private DataGridUser user; - - @Column(name = "path", nullable = false, length = 512) - private String path; - - @Column(name = "name", nullable = false, length = 512) - private String name; - - @Column(name = "is_notified", nullable = true) - private Boolean isNotified; - - @Column(name = "is_collection", nullable = false) - private Boolean isCollection; - - @Temporal(TemporalType.TIMESTAMP) - @Column(name = "created_at", nullable = false, length = 60, updatable = false) - private Date createTs; - - private static final long serialVersionUID = -229875209906357557L; - - /** - * @return the id - */ - public Long getId() { - return id; - } - - /** - * @return the user - */ - @JsonIgnore - public DataGridUser getUser() { - return user; - } - - /** - * @return the path - */ - public String getPath() { - return path; - } - - /** - * @return the isNotified - */ - public Boolean getIsNotified() { - return isNotified; - } - - /** - * @return the createTs - */ - public Date getCreateTs() { - return createTs; - } - - public String getCreateTsFormatted() { - return new SimpleDateFormat("MMM dd yyyy, HH:mm").format(createTs); - } - - /** - * @return the name - */ - public String getName() { - return name; - } - - /** - * @param name - * the name to set - */ - public void setName(String name) { - this.name = name; - } - - /** - * @return the isCollection - */ - public Boolean getIsCollection() { - return isCollection; - } - - /** - * @param isCollection - * the isCollection to set - */ - public void setIsCollection(Boolean isCollection) { - this.isCollection = isCollection; - } - - /** - * @param id - * the id to set - */ - public void setId(Long id) { - this.id = id; - } - - /** - * @param user - * the user to set - */ - public void setUser(DataGridUser user) { - this.user = user; - } - - /** - * @param path - * the path to set - */ - public void setPath(String path) { - this.path = path; - } - - /** - * @param isNotified - * the isNotified to set - */ - public void setIsNotified(Boolean isNotified) { - this.isNotified = isNotified; - } - - /** - * @param createTs - * the createTs to set - */ - public void setCreateTs(Date createTs) { - this.createTs = createTs; - } - - /** - * Gets the icon to be displayed for a bookmarks based on its extension - * - * @return String containing the icon name to be displayed - */ - public String getDisplayIcon() { - return DataGridCoreUtils.getIconToDisplay(this.getPath()); - } - - @Override - public int compareTo(DataGridUserBookmark dgub) { - return this.getName().compareTo(dgub.getName()); - } + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @NotAudited + @Column(name = "id", unique = true, nullable = false) + private Long id; + + @ManyToOne(fetch = FetchType.EAGER, optional = true) + @JoinColumn(name = "user_id", nullable = false, updatable = true) + private DataGridUser user; + + @Column(name = "path", nullable = false, length = 512) + private String path; + + @Column(name = "name", nullable = false, length = 512) + private String name; + + @Column(name = "is_notified", nullable = true) + private Boolean isNotified; + + @Column(name = "is_collection", nullable = false) + private Boolean isCollection; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name = "created_at", nullable = false, length = 60, updatable = false) + private Date createTs; + + private static final long serialVersionUID = -229875209906357557L; + + /** + * @return the id + */ + public Long getId() { + return id; + } + + /** + * @return the user + */ + @JsonIgnore + public DataGridUser getUser() { + return user; + } + + /** + * @return the path + */ + public String getPath() { + return path; + } + + /** + * @return the isNotified + */ + public Boolean getIsNotified() { + return isNotified; + } + + /** + * @return the createTs + */ + public Date getCreateTs() { + return createTs; + } + + public String getCreateTsFormatted() { + return new SimpleDateFormat("MMM dd yyyy, HH:mm").format(createTs); + } + + /** + * @return the name + */ + public String getName() { + return name; + } + + /** + * @param name + * the name to set + */ + public void setName(String name) { + this.name = name; + } + + /** + * @return the isCollection + */ + public Boolean getIsCollection() { + return isCollection; + } + + /** + * @param isCollection + * the isCollection to set + */ + public void setIsCollection(Boolean isCollection) { + this.isCollection = isCollection; + } + + /** + * @param id + * the id to set + */ + public void setId(Long id) { + this.id = id; + } + + /** + * @param user + * the user to set + */ + public void setUser(DataGridUser user) { + this.user = user; + } + + /** + * @param path + * the path to set + */ + public void setPath(String path) { + this.path = path; + } + + /** + * @param isNotified + * the isNotified to set + */ + public void setIsNotified(Boolean isNotified) { + this.isNotified = isNotified; + } + + /** + * @param createTs + * the createTs to set + */ + public void setCreateTs(Date createTs) { + this.createTs = createTs; + } + + /** + * Gets the icon to be displayed for a bookmarks based on its extension + * + * @return String containing the icon name to be displayed + */ + public String getDisplayIcon() { + return DataGridCoreUtils.getIconToDisplay(this.getPath()); + } + + @Override + public int compareTo(DataGridUserBookmark dgub) { + return this.getName().compareTo(dgub.getName()); + } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("DataGridUserBookmark ["); + if (id != null) { + builder.append("id=").append(id).append(", "); + } + if (user != null) { + builder.append("user=").append(user).append(", "); + } + if (path != null) { + builder.append("path=").append(path).append(", "); + } + if (name != null) { + builder.append("name=").append(name).append(", "); + } + if (isNotified != null) { + builder.append("isNotified=").append(isNotified).append(", "); + } + if (isCollection != null) { + builder.append("isCollection=").append(isCollection).append(", "); + } + if (createTs != null) { + builder.append("createTs=").append(createTs); + } + builder.append("]"); + return builder.toString(); + } } diff --git a/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridUserFavorite.java b/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridUserFavorite.java index bc7aca9b2..501724737 100755 --- a/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridUserFavorite.java +++ b/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridUserFavorite.java @@ -15,176 +15,214 @@ */ package com.emc.metalnx.core.domain.entity; -import com.emc.metalnx.core.domain.utils.DataGridCoreUtils; -import com.fasterxml.jackson.annotation.JsonIgnore; -import org.hibernate.envers.Audited; -import org.hibernate.envers.NotAudited; - -import javax.persistence.*; import java.io.Serializable; import java.text.SimpleDateFormat; import java.util.Date; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; +import javax.persistence.UniqueConstraint; + +import org.hibernate.envers.Audited; +import org.hibernate.envers.NotAudited; + +import com.emc.metalnx.core.domain.utils.DataGridCoreUtils; +import com.fasterxml.jackson.annotation.JsonIgnore; + @Entity @Audited -@Table(name = "user_favorites", uniqueConstraints = @UniqueConstraint(columnNames = { "user_id", - "path_hash" })) +@Table(name = "user_favorites", uniqueConstraints = @UniqueConstraint(columnNames = { "user_id", "path_hash" })) public class DataGridUserFavorite implements Serializable, Comparable { - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - @NotAudited - @Column(name = "id", unique = true, nullable = false) - private Long id; - - @ManyToOne(fetch = FetchType.EAGER, optional = true) - @JoinColumn(name = "user_id", nullable = false, updatable = true) - private DataGridUser user; - - @Column(name = "path", nullable = false, length = 512) - private String path; - - @Column(name = "name", nullable = false, length = 512) - private String name; - - @Column(name = "is_collection", nullable = true) - private Boolean isCollection; - - @Temporal(TemporalType.TIMESTAMP) - @Column(name = "created_at", nullable = false, length = 60, updatable = false) - private Date createTs; - - @Column(name = "path_hash", nullable = false) - private int pathHash; - - private static final long serialVersionUID = -7923823760209937080L; - - /** - * @return the id - */ - @JsonIgnore - public Long getId() { - return id; - } - - /** - * @return the user - */ - @JsonIgnore - public DataGridUser getUser() { - return user; - } - - /** - * @return the path - */ - public String getPath() { - return path; - } - - /** - * @return the isCollection - */ - public boolean getIsCollection() { - return isCollection; - } - - /** - * @return the createTs - */ - @JsonIgnore - public Date getCreateTs() { - return createTs; - } - - public String getCreateTsFormatted() { - return new SimpleDateFormat("MMM dd yyyy, HH:mm").format(createTs); - } - - /** - * @param id - * the id to set - */ - public void setId(Long id) { - this.id = id; - } - - /** - * @param user - * the user to set - */ - public void setUser(DataGridUser user) { - this.user = user; - } - - /** - * @param path - * the path to set - */ - public void setPath(String path) { - this.path = path; - } - - /** - * @param fileName - * the fileName to set - */ - public void setName(String name) { - this.name = name; - } - - /** - * @param isNotified - * the isCollection to set - */ - public void setIsCollection(Boolean isCollection) { - this.isCollection = isCollection; - } - - /** - * @param createTs - * the createTs to set - */ - public void setCreateTs(Date createTs) { - this.createTs = createTs; - } - - /** - * Finds the file name based on its path - * - * @return file name - */ - public String getName() { - return this.name; - } - - /** - * @return the pathHash - */ - public int getPathHash() { - return pathHash; - } - - /** - * @param pathHash - * the pathHash to set - */ - public void setPathHash(int pathHash) { - this.pathHash = pathHash; - } - - /** - * Gets the icon to be displayed for a bookmarks based on its extension - * - * @return String containing the icon name to be displayed - */ - public String getDisplayIcon() { - return DataGridCoreUtils.getIconToDisplay(this.getPath()); - } - - @Override - public int compareTo(DataGridUserFavorite dgub) { - return this.getName().compareTo(dgub.getName()); - } + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @NotAudited + @Column(name = "id", unique = true, nullable = false) + private Long id; + + @ManyToOne(fetch = FetchType.EAGER, optional = true) + @JoinColumn(name = "user_id", nullable = false, updatable = true) + private DataGridUser user; + + @Column(name = "path", nullable = false, length = 512) + private String path; + + @Column(name = "name", nullable = false, length = 512) + private String name; + + @Column(name = "is_collection", nullable = true) + private Boolean isCollection; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name = "created_at", nullable = false, length = 60, updatable = false) + private Date createTs; + + @Column(name = "path_hash", nullable = false) + private int pathHash; + + private static final long serialVersionUID = -7923823760209937080L; + + /** + * @return the id + */ + @JsonIgnore + public Long getId() { + return id; + } + + /** + * @return the user + */ + @JsonIgnore + public DataGridUser getUser() { + return user; + } + + /** + * @return the path + */ + public String getPath() { + return path; + } + + /** + * @return the isCollection + */ + public boolean getIsCollection() { + return isCollection; + } + + /** + * @return the createTs + */ + @JsonIgnore + public Date getCreateTs() { + return createTs; + } + + public String getCreateTsFormatted() { + return new SimpleDateFormat("MMM dd yyyy, HH:mm").format(createTs); + } + + /** + * @param id + * the id to set + */ + public void setId(Long id) { + this.id = id; + } + + /** + * @param user + * the user to set + */ + public void setUser(DataGridUser user) { + this.user = user; + } + + /** + * @param path + * the path to set + */ + public void setPath(String path) { + this.path = path; + } + + /** + * @param fileName + * the fileName to set + */ + public void setName(String name) { + this.name = name; + } + + /** + * @param isNotified + * the isCollection to set + */ + public void setIsCollection(Boolean isCollection) { + this.isCollection = isCollection; + } + + /** + * @param createTs + * the createTs to set + */ + public void setCreateTs(Date createTs) { + this.createTs = createTs; + } + + /** + * Finds the file name based on its path + * + * @return file name + */ + public String getName() { + return this.name; + } + + /** + * @return the pathHash + */ + public int getPathHash() { + return pathHash; + } + + /** + * @param pathHash + * the pathHash to set + */ + public void setPathHash(int pathHash) { + this.pathHash = pathHash; + } + + /** + * Gets the icon to be displayed for a bookmarks based on its extension + * + * @return String containing the icon name to be displayed + */ + public String getDisplayIcon() { + return DataGridCoreUtils.getIconToDisplay(this.getPath()); + } + + @Override + public int compareTo(DataGridUserFavorite dgub) { + return this.getName().compareTo(dgub.getName()); + } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("DataGridUserFavorite ["); + if (id != null) { + builder.append("id=").append(id).append(", "); + } + if (user != null) { + builder.append("user=").append(user).append(", "); + } + if (path != null) { + builder.append("path=").append(path).append(", "); + } + if (name != null) { + builder.append("name=").append(name).append(", "); + } + if (isCollection != null) { + builder.append("isCollection=").append(isCollection).append(", "); + } + if (createTs != null) { + builder.append("createTs=").append(createTs).append(", "); + } + builder.append("pathHash=").append(pathHash).append("]"); + return builder.toString(); + } } diff --git a/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridUserPermission.java b/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridUserPermission.java index cd88d59ca..560dbe142 100755 --- a/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridUserPermission.java +++ b/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridUserPermission.java @@ -17,69 +17,89 @@ public class DataGridUserPermission { - private Integer dataGridId; - private String userName; - private String userSystemRole; - private String permission; + private Integer dataGridId; + private String userName; + private String userSystemRole; + private String permission; - /** - * @return the dataGridId - */ - public Integer getDataGridId() { - return dataGridId; - } + /** + * @return the dataGridId + */ + public Integer getDataGridId() { + return dataGridId; + } - /** - * @return the userName - */ - public String getUserName() { - return userName; - } + /** + * @return the userName + */ + public String getUserName() { + return userName; + } - /** - * @return the permission - */ - public String getPermission() { - return permission; - } + /** + * @return the permission + */ + public String getPermission() { + return permission; + } - /** - * @param dataGridId - * the dataGridId to set - */ - public void setDataGridId(Integer dataGridId) { - this.dataGridId = dataGridId; - } + /** + * @param dataGridId + * the dataGridId to set + */ + public void setDataGridId(Integer dataGridId) { + this.dataGridId = dataGridId; + } - /** - * @param userName - * the userName to set - */ - public void setUserName(String userName) { - this.userName = userName; - } + /** + * @param userName + * the userName to set + */ + public void setUserName(String userName) { + this.userName = userName; + } - /** - * @param permission - * the permission to set - */ - public void setPermission(String permission) { - this.permission = permission; - } + /** + * @param permission + * the permission to set + */ + public void setPermission(String permission) { + this.permission = permission; + } - /** - * @return the userSystemRole - */ - public String getUserSystemRole() { - return userSystemRole; - } + /** + * @return the userSystemRole + */ + public String getUserSystemRole() { + return userSystemRole; + } - /** - * @param userSystemRole - * the userSystemRole to set - */ - public void setUserSystemRole(String userSystemRole) { - this.userSystemRole = userSystemRole; - } + /** + * @param userSystemRole + * the userSystemRole to set + */ + public void setUserSystemRole(String userSystemRole) { + this.userSystemRole = userSystemRole; + } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("DataGridUserPermission ["); + if (dataGridId != null) { + builder.append("dataGridId=").append(dataGridId).append(", "); + } + if (userName != null) { + builder.append("userName=").append(userName).append(", "); + } + if (userSystemRole != null) { + builder.append("userSystemRole=").append(userSystemRole).append(", "); + } + if (permission != null) { + builder.append("permission=").append(permission); + } + builder.append("]"); + return builder.toString(); + } } diff --git a/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridZone.java b/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridZone.java index 3b6012796..aba9e69d2 100755 --- a/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridZone.java +++ b/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridZone.java @@ -19,11 +19,12 @@ /** * Represents an abstraction of a Zone in a data grid system + * * @author guerra * */ public class DataGridZone { - + private long id; private String name; private String type; @@ -31,101 +32,145 @@ public class DataGridZone { private String comment; private Date createTime; private Date modifyTime; - + public DataGridZone() { - //empty constructor + // empty constructor } - + public DataGridZone(String name, String type) { this.name = name; this.type = type; } - + /** * @return the id */ public long getId() { return id; } + /** - * @param id the id to set + * @param id + * the id to set */ public void setId(long id) { this.id = id; } + /** * @return the name */ public String getName() { return name; } + /** - * @param name the name to set + * @param name + * the name to set */ public void setName(String name) { this.name = name; } + /** * @return the type */ public String getType() { return type; } + /** - * @param type the type to set + * @param type + * the type to set */ public void setType(String type) { this.type = type; } + /** * @return the connectionString */ public String getConnectionString() { return connectionString; } + /** - * @param connectionString the connectionString to set + * @param connectionString + * the connectionString to set */ public void setConnectionString(String connectionString) { this.connectionString = connectionString; } + /** * @return the comment */ public String getComment() { return comment; } + /** - * @param comment the comment to set + * @param comment + * the comment to set */ public void setComment(String comment) { this.comment = comment; } + /** * @return the createTime */ public Date getCreateTime() { return createTime; } + /** - * @param createTime the createTime to set + * @param createTime + * the createTime to set */ public void setCreateTime(Date createTime) { this.createTime = createTime; } + /** * @return the modifyTime */ public Date getModifyTime() { return modifyTime; } + /** - * @param modifyTime the modifyTime to set + * @param modifyTime + * the modifyTime to set */ public void setModifyTime(Date modifyTime) { this.modifyTime = modifyTime; } - - + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("DataGridZone [id=").append(id).append(", "); + if (name != null) { + builder.append("name=").append(name).append(", "); + } + if (type != null) { + builder.append("type=").append(type).append(", "); + } + if (connectionString != null) { + builder.append("connectionString=").append(connectionString).append(", "); + } + if (comment != null) { + builder.append("comment=").append(comment).append(", "); + } + if (createTime != null) { + builder.append("createTime=").append(createTime).append(", "); + } + if (modifyTime != null) { + builder.append("modifyTime=").append(modifyTime); + } + builder.append("]"); + return builder.toString(); + } } diff --git a/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/UserProfile.java b/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/UserProfile.java index 6b1b887b6..14fffb153 100755 --- a/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/UserProfile.java +++ b/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/UserProfile.java @@ -15,52 +15,66 @@ */ package com.emc.metalnx.core.domain.entity; +import java.util.Collection; +import java.util.Iterator; +import java.util.Set; + +import javax.persistence.CascadeType; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.JoinTable; +import javax.persistence.ManyToMany; +import javax.persistence.OneToMany; +import javax.persistence.Table; + import org.hibernate.envers.Audited; import org.hibernate.envers.NotAudited; -import javax.persistence.*; -import java.util.Set; - @Entity @Audited @Table(name = "user_profile") public class UserProfile { - + @Id - @Column(name="id") + @Column(name = "id") @NotAudited @GeneratedValue private Long profileId; - + @Column(name = "profile_name", nullable = false, length = 64) private String profileName; - + @Column(name = "description", nullable = false, length = 512) private String description; - - @ManyToMany(fetch = FetchType.EAGER, cascade = {CascadeType.PERSIST}) - @JoinTable(name="user_profile_groups", joinColumns={@JoinColumn(name="profile_id")}, inverseJoinColumns={@JoinColumn(name="group_id")}) + + @ManyToMany(fetch = FetchType.EAGER, cascade = { CascadeType.PERSIST }) + @JoinTable(name = "user_profile_groups", joinColumns = { @JoinColumn(name = "profile_id") }, inverseJoinColumns = { + @JoinColumn(name = "group_id") }) private Set groups; - + @OneToMany(mappedBy = "userProfile", fetch = FetchType.EAGER) private Set users; - + public UserProfile() { - + } - + public UserProfile(String profileName, String description) { this.profileName = profileName; this.description = description; } - + public UserProfile(String profileName, String description, Set groups, Set users) { this.profileName = profileName; this.description = description; this.groups = groups; this.users = users; } - + /** * @return the profileId */ @@ -69,7 +83,8 @@ public Long getProfileId() { } /** - * @param profileId the profileId to set + * @param profileId + * the profileId to set */ public void setProfileId(Long profileId) { this.profileId = profileId; @@ -83,7 +98,8 @@ public String getProfileName() { } /** - * @param profileName the profileName to set + * @param profileName + * the profileName to set */ public void setProfileName(String profileName) { this.profileName = profileName; @@ -97,7 +113,8 @@ public String getDescription() { } /** - * @param description the description to set + * @param description + * the description to set */ public void setDescription(String description) { this.description = description; @@ -111,7 +128,8 @@ public Set getGroups() { } /** - * @param groups the groups to set + * @param groups + * the groups to set */ public void setGroups(Set groups) { this.groups = groups; @@ -125,13 +143,48 @@ public Set getUsers() { } /** - * @param users the users to set + * @param users + * the users to set */ public void setUsers(Set users) { this.users = users; } - + + @Override public String toString() { - return this.profileName; + final int maxLen = 10; + StringBuilder builder = new StringBuilder(); + builder.append("UserProfile ["); + if (profileId != null) { + builder.append("profileId=").append(profileId).append(", "); + } + if (profileName != null) { + builder.append("profileName=").append(profileName).append(", "); + } + if (description != null) { + builder.append("description=").append(description).append(", "); + } + if (groups != null) { + builder.append("groups=").append(toString(groups, maxLen)).append(", "); + } + if (users != null) { + builder.append("users=").append(toString(users, maxLen)); + } + builder.append("]"); + return builder.toString(); + } + + private String toString(Collection collection, int maxLen) { + StringBuilder builder = new StringBuilder(); + builder.append("["); + int i = 0; + for (Iterator iterator = collection.iterator(); iterator.hasNext() && i < maxLen; i++) { + if (i > 0) { + builder.append(", "); + } + builder.append(iterator.next()); + } + builder.append("]"); + return builder.toString(); } } diff --git a/src/emc-metalnx-shared/src/main/java/com/emc/metalnx/controller/PreferencesController.java b/src/emc-metalnx-shared/src/main/java/com/emc/metalnx/controller/PreferencesController.java index a0b8e5cbc..17ac17ce1 100755 --- a/src/emc-metalnx-shared/src/main/java/com/emc/metalnx/controller/PreferencesController.java +++ b/src/emc-metalnx-shared/src/main/java/com/emc/metalnx/controller/PreferencesController.java @@ -19,6 +19,8 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Controller; @@ -47,6 +49,8 @@ public class PreferencesController { @Autowired LoggedUserUtils loggedUserUtils; + public final static Logger logger = LoggerFactory.getLogger(PreferencesController.class); + // ui mode that will be shown when the rods user switches mode from admin to // user and vice-versa public static final String UI_USER_MODE = "user"; @@ -85,14 +89,21 @@ public String action(final Model model, @ModelAttribute final UserPreferences pr final HttpServletRequest request, final HttpServletResponse response) throws DataGridConnectionRefusedException { + logger.info("action()"); + logger.info("preferences:{}", preferences); + DataGridUser loggedUser = loggedUserUtils.getLoggedDataGridUser(); + logger.debug("current logged in user:{}", loggedUser); loggedUser.setLocale(preferences.getLocaleLanguage()); loggedUser.setForceFileOverwriting(preferences.isForceFileOverwriting()); loggedUser.setAdvanceView(preferences.isAdvancedView()); + logger.debug("modified logged in user:{}", loggedUser); + userService.modifyUser(loggedUser); + logger.info("preferences were saved"); localeResolver.setLocale(request, response, StringUtils.parseLocaleString(preferences.getLocaleLanguage())); - return "redirect:/dashboard/"; + return "redirect:/preferences/"; } @RequestMapping(value = "/chat/") diff --git a/src/emc-metalnx-shared/src/main/java/com/emc/metalnx/modelattribute/preferences/UserPreferences.java b/src/emc-metalnx-shared/src/main/java/com/emc/metalnx/modelattribute/preferences/UserPreferences.java index 837c7af38..769e42701 100755 --- a/src/emc-metalnx-shared/src/main/java/com/emc/metalnx/modelattribute/preferences/UserPreferences.java +++ b/src/emc-metalnx-shared/src/main/java/com/emc/metalnx/modelattribute/preferences/UserPreferences.java @@ -54,11 +54,28 @@ public String getLocaleLanguage() { public void setLocaleLanguage(final String localeLanguage) { this.localeLanguage = localeLanguage; } - + /** - * @return the boolean that is true for advanced view, otherwise is normal view + * @return the boolean that is true for advanced view, otherwise is + * normal view */ public boolean isAdvancedView() { return advancedView; } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("UserPreferences ["); + if (localeLanguage != null) { + builder.append("localeLanguage=").append(localeLanguage).append(", "); + } + builder.append("forceFileOverwriting=").append(forceFileOverwriting).append(", advancedView=") + .append(advancedView).append("]"); + return builder.toString(); + } + + public void setAdvancedView(boolean advancedView) { + this.advancedView = advancedView; + } } diff --git a/src/emc-metalnx-web/src/main/resources/log4j.properties b/src/emc-metalnx-web/src/main/resources/log4j.properties index 40e27151a..8c7d6f0c2 100644 --- a/src/emc-metalnx-web/src/main/resources/log4j.properties +++ b/src/emc-metalnx-web/src/main/resources/log4j.properties @@ -33,4 +33,4 @@ log4j.logger.org.hibernate.SQL=ERROR # Logs the JDBC parameters passed to a query - set TRACE for detailed info log4j.logger.org.hibernate.type=INFO -log4j.logger.com.emc.metalnx.context=DEBUG \ No newline at end of file +log4j.logger.com.emc.metalnx=DEBUG \ No newline at end of file From ac3e85721e9ac91b78cc723d91cba82280d3f0a2 Mon Sep 17 00:00:00 2001 From: Mike Conway Date: Thu, 30 Nov 2017 11:25:08 -0500 Subject: [PATCH 7/8] #17 add tostring to entity --- .../core/domain/entity/DataGridUser.java | 20 ++----------------- 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridUser.java b/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridUser.java index 0290bc5b7..661ff70d9 100755 --- a/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridUser.java +++ b/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridUser.java @@ -17,9 +17,7 @@ import java.io.Serializable; import java.util.ArrayList; -import java.util.Collection; import java.util.Collections; -import java.util.Iterator; import java.util.List; import java.util.Set; @@ -501,24 +499,10 @@ public String toString() { } builder.append("advancedView=").append(advancedView).append(", "); if (bookmarks != null) { - builder.append("bookmarks=").append(toString(bookmarks, maxLen)).append(", "); + builder.append("bookmarks=").append(bookmarks.toString()).append(", "); } if (favorites != null) { - builder.append("favorites=").append(toString(favorites, maxLen)); - } - builder.append("]"); - return builder.toString(); - } - - private String toString(Collection collection, int maxLen) { - StringBuilder builder = new StringBuilder(); - builder.append("["); - int i = 0; - for (Iterator iterator = collection.iterator(); iterator.hasNext() && i < maxLen; i++) { - if (i > 0) { - builder.append(", "); - } - builder.append(iterator.next()); + builder.append("favorites=").append(favorites.toString()); } builder.append("]"); return builder.toString(); From 5d20e8ee90d44f38df4f761a6eafdb82c5b550e3 Mon Sep 17 00:00:00 2001 From: Mike Conway Date: Thu, 30 Nov 2017 11:45:39 -0500 Subject: [PATCH 8/8] #17 works --- .../com/emc/metalnx/core/domain/entity/DataGridUser.java | 5 ++--- .../metalnx/core/domain/entity/DataGridUserFavorite.java | 3 --- .../emc/metalnx/services/configuration/GlobalConfig.java | 7 +++++++ .../com/emc/metalnx/controller/PreferencesController.java | 2 ++ 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridUser.java b/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridUser.java index 661ff70d9..c98234fc7 100755 --- a/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridUser.java +++ b/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridUser.java @@ -449,7 +449,6 @@ public void setPassword(String password) { @Override public String toString() { - final int maxLen = 10; StringBuilder builder = new StringBuilder(); builder.append("DataGridUser ["); if (id != null) { @@ -499,10 +498,10 @@ public String toString() { } builder.append("advancedView=").append(advancedView).append(", "); if (bookmarks != null) { - builder.append("bookmarks=").append(bookmarks.toString()).append(", "); + builder.append("bookmarks=").append(bookmarks).append(", "); } if (favorites != null) { - builder.append("favorites=").append(favorites.toString()); + builder.append("favorites=").append(favorites); } builder.append("]"); return builder.toString(); diff --git a/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridUserFavorite.java b/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridUserFavorite.java index 501724737..809d394fb 100755 --- a/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridUserFavorite.java +++ b/src/emc-metalnx-core/src/main/java/com/emc/metalnx/core/domain/entity/DataGridUserFavorite.java @@ -206,9 +206,6 @@ public String toString() { if (id != null) { builder.append("id=").append(id).append(", "); } - if (user != null) { - builder.append("user=").append(user).append(", "); - } if (path != null) { builder.append("path=").append(path).append(", "); } diff --git a/src/emc-metalnx-services/src/main/java/com/emc/metalnx/services/configuration/GlobalConfig.java b/src/emc-metalnx-services/src/main/java/com/emc/metalnx/services/configuration/GlobalConfig.java index 624bfe00e..bd772e30e 100644 --- a/src/emc-metalnx-services/src/main/java/com/emc/metalnx/services/configuration/GlobalConfig.java +++ b/src/emc-metalnx-services/src/main/java/com/emc/metalnx/services/configuration/GlobalConfig.java @@ -27,4 +27,11 @@ public void setTicketsEnabled(boolean ticketsEnabled) { this.ticketsEnabled = ticketsEnabled; } + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("GlobalConfig [ticketsEnabled=").append(ticketsEnabled).append("]"); + return builder.toString(); + } + } diff --git a/src/emc-metalnx-shared/src/main/java/com/emc/metalnx/controller/PreferencesController.java b/src/emc-metalnx-shared/src/main/java/com/emc/metalnx/controller/PreferencesController.java index 17ac17ce1..b53555193 100755 --- a/src/emc-metalnx-shared/src/main/java/com/emc/metalnx/controller/PreferencesController.java +++ b/src/emc-metalnx-shared/src/main/java/com/emc/metalnx/controller/PreferencesController.java @@ -61,6 +61,7 @@ public class PreferencesController { @RequestMapping(value = "/") public String index(final Model model, final HttpServletRequest request) { + logger.info("index()"); DataGridUser loggedUser = loggedUserUtils.getLoggedDataGridUser(); String locale = loggedUser.getLocale(); @@ -77,6 +78,7 @@ public String index(final Model model, final HttpServletRequest request) { UserPreferences userPreferences = new UserPreferences(); userPreferences.setLocaleLanguage(locale); userPreferences.setForceFileOverwriting(loggedUser.isForceFileOverwriting()); + userPreferences.setAdvancedView(loggedUser.isAdvancedView()); model.addAttribute("preferences", userPreferences); model.addAttribute("uiMode", uiMode);