X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=ecomp-portal-BE-common%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fportalapp%2Fportal%2Fdomain%2FEPUserApp.java;h=d644c9980ea6e927ba48e36228b67f37a0009b3c;hb=8b67487fa29e61ad15ac961231ebb3b6621d39dc;hp=64ed4ac1adcf82b782e79b46276fdebe91fef987;hpb=24608a9e1450c409dc3870440d29e91cc3a26bb9;p=portal.git diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/domain/EPUserApp.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/domain/EPUserApp.java index 64ed4ac1..d644c998 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/domain/EPUserApp.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/domain/EPUserApp.java @@ -37,16 +37,20 @@ */ package org.onap.portalapp.portal.domain; +import javax.validation.Valid; +import org.onap.portalsdk.core.domain.support.DomainVo; @SuppressWarnings("rawtypes") -public class EPUserApp implements java.io.Serializable, Comparable { +public class EPUserApp extends DomainVo implements java.io.Serializable, Comparable { private static final long serialVersionUID = 1L; private Long userId; + @Valid private EPApp app; + @Valid private EPRole role; - private Short priority; + private Integer priority; public EPUserApp() { } @@ -60,13 +64,12 @@ public class EPUserApp implements java.io.Serializable, Comparable { } public Long getAppRoleId() { - return (role.getAppRoleId() == null) ? null : role.getAppRoleId(); + return this.role.getAppRoleId(); } @Override public String toString() { - String str = "[u: "+getUserId()+"; a: "+getAppId()+", r: "+getRoleId()+"; appRoleId: "+getAppRoleId()+"]"; - return str; + return "[u: "+getUserId()+"; a: "+getAppId()+", r: "+getRoleId()+"; appRoleId: "+getAppRoleId()+"]"; } public Long getUserId() { @@ -93,14 +96,15 @@ public class EPUserApp implements java.io.Serializable, Comparable { this.role = role; } - public Short getPriority() { - return this.priority; + public Integer getPriority() { + return (this.priority == null) ? 1 : priority; } - public void setPriority(Short priority) { + public void setPriority(Integer priority) { this.priority = priority; } + @Override public boolean equals(Object other) { if ((this == other)) return true; @@ -110,10 +114,10 @@ public class EPUserApp implements java.io.Serializable, Comparable { return false; EPUserApp castOther = (EPUserApp) other; - return (this.getUserId().equals(castOther.getUserId())) - && (this.getApp().getId().equals(castOther.getApp().getId())) - && (this.getRole().getId().equals(castOther.getRole().getId())) - && ((this.priority==null && castOther.getPriority()==null) || this.getPriority().equals(castOther.getPriority())); + return (otherUserIdIsSameAsThisUserId(castOther)) + && (otherAppIdIsSameAsThis(castOther)) + && (otherRoleIsSameAsThis(castOther)) + && (otherPriorityIsSameAsThis(castOther)); } public int hashCode() { @@ -134,4 +138,19 @@ public class EPUserApp implements java.io.Serializable, Comparable { return c1.compareTo(c2); } + private boolean otherPriorityIsSameAsThis(EPUserApp other){ + return (this.priority==null && other.getPriority()==null) || this.getPriority().equals(other.getPriority()); + } + + private boolean otherRoleIsSameAsThis(EPUserApp other){ + return this.getRole().getId().equals(other.getRole().getId()); + } + + private boolean otherAppIdIsSameAsThis(EPUserApp other){ + return this.getApp().getId().equals(other.getApp().getId()); + } + + private boolean otherUserIdIsSameAsThisUserId(EPUserApp other){ + return this.getUserId().equals(other.getUserId()); + } }