1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.kim.bo.role.dto; |
17 | |
|
18 | |
import java.io.Serializable; |
19 | |
import java.util.Map; |
20 | |
|
21 | |
import org.apache.commons.lang.StringUtils; |
22 | |
import org.apache.commons.lang.builder.ToStringBuilder; |
23 | |
import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader; |
24 | |
import org.kuali.rice.kim.bo.role.KimPermission; |
25 | |
import org.kuali.rice.kim.service.PermissionService; |
26 | |
import org.kuali.rice.kim.util.KimConstants; |
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | 0 | public class KimPermissionInfo extends PermissionDetailsInfo implements KimPermission, Serializable { |
35 | |
|
36 | |
private static final long serialVersionUID = 1L; |
37 | |
protected String namespaceCode; |
38 | |
protected String name; |
39 | |
protected String description; |
40 | |
protected String templateId; |
41 | |
protected KimPermissionTemplateInfo template; |
42 | |
|
43 | |
protected boolean active; |
44 | |
|
45 | |
public String getName() { |
46 | 0 | return this.name; |
47 | |
} |
48 | |
public void setName(String name) { |
49 | 0 | this.name = name; |
50 | 0 | } |
51 | |
public String getDescription() { |
52 | 0 | return this.description; |
53 | |
} |
54 | |
public void setDescription(String description) { |
55 | 0 | this.description = description; |
56 | 0 | } |
57 | |
public boolean isActive() { |
58 | 0 | return this.active; |
59 | |
} |
60 | |
public void setActive(boolean active) { |
61 | 0 | this.active = active; |
62 | 0 | } |
63 | |
public String getNamespaceCode() { |
64 | 0 | return this.namespaceCode; |
65 | |
} |
66 | |
public void setNamespaceCode(String namespaceCode) { |
67 | 0 | this.namespaceCode = namespaceCode; |
68 | 0 | } |
69 | |
public KimPermissionTemplateInfo getTemplate() { |
70 | 0 | return this.template; |
71 | |
} |
72 | |
public void setTemplate(KimPermissionTemplateInfo template) { |
73 | 0 | this.template = template; |
74 | 0 | } |
75 | |
|
76 | |
|
77 | |
|
78 | |
public String toString() { |
79 | 0 | return new ToStringBuilder(this).append("details", this.details).append("template", this.template).append("namespaceCode", this.namespaceCode).append("name", this.name).toString(); |
80 | |
} |
81 | |
|
82 | |
|
83 | |
|
84 | |
|
85 | |
@Override |
86 | |
public int hashCode() { |
87 | 0 | if ( getPermissionId() == null ) { |
88 | 0 | return 0; |
89 | |
} |
90 | 0 | return getPermissionId().hashCode(); |
91 | |
} |
92 | |
|
93 | |
|
94 | |
|
95 | |
|
96 | |
@Override |
97 | |
public boolean equals(Object obj) { |
98 | 0 | if ( obj == null || !(obj instanceof KimPermissionInfo) ) { |
99 | 0 | return false; |
100 | |
} |
101 | 0 | return StringUtils.equals( getPermissionId(), ((KimPermissionInfo)obj).getPermissionId() ); |
102 | |
} |
103 | |
|
104 | |
public String getNameToDisplay(){ |
105 | 0 | return (StringUtils.isBlank(getName()) && getTemplate()!=null)?getTemplate().getName():getName(); |
106 | |
} |
107 | |
|
108 | |
public String getDetailObjectsValues(){ |
109 | 0 | StringBuffer detailObjectsToDisplay = new StringBuffer(); |
110 | 0 | for( Map.Entry<String,String> entry: getDetails().entrySet() ){ |
111 | 0 | detailObjectsToDisplay.append(entry.getKey()+KimConstants.KimUIConstants.COMMA_SEPARATOR); |
112 | |
} |
113 | 0 | return StringUtils.chomp(detailObjectsToDisplay.toString(), KimConstants.KimUIConstants.COMMA_SEPARATOR ); |
114 | |
} |
115 | |
|
116 | |
public String getDetailObjectsToDisplay() { |
117 | 0 | StringBuffer detailObjectsToDisplay = new StringBuffer(); |
118 | 0 | for( Map.Entry<String,String> entry: getDetails().entrySet() ){ |
119 | 0 | detailObjectsToDisplay.append(getAttributeDetailToDisplay(entry)); |
120 | |
} |
121 | 0 | return StringUtils.chomp(detailObjectsToDisplay.toString(), KimConstants.KimUIConstants.COMMA_SEPARATOR ); |
122 | |
} |
123 | |
|
124 | |
public String getAttributeDetailToDisplay(Map.Entry<String,String> entry){ |
125 | 0 | return getKimAttributeLabelFromDD(entry.getKey())+KimConstants.KimUIConstants.NAME_VALUE_SEPARATOR+ |
126 | |
entry.getValue()+KimConstants.KimUIConstants.COMMA_SEPARATOR; |
127 | |
} |
128 | |
|
129 | |
|
130 | |
protected String getKimAttributeLabelFromDD(String attributeName){ |
131 | 0 | return getPermissionService().getPermissionDetailLabel(permissionId, template.getKimTypeId(), attributeName ); |
132 | |
} |
133 | |
|
134 | |
private transient static PermissionService permissionService; |
135 | |
protected PermissionService getPermissionService() { |
136 | 0 | if(permissionService == null){ |
137 | 0 | permissionService = (PermissionService)GlobalResourceLoader.getService( "kimPermissionService" ); |
138 | |
} |
139 | 0 | return permissionService; |
140 | |
} |
141 | |
public String getTemplateId() { |
142 | 0 | return this.templateId; |
143 | |
} |
144 | |
public void setTemplateId(String templateId) { |
145 | 0 | this.templateId = templateId; |
146 | 0 | } |
147 | |
|
148 | |
} |