| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
package org.kuali.rice.kim.bo.impl; |
| 17 | |
|
| 18 | |
import java.util.Iterator; |
| 19 | |
import java.util.LinkedHashMap; |
| 20 | |
|
| 21 | |
import javax.persistence.Column; |
| 22 | |
import javax.persistence.Entity; |
| 23 | |
import javax.persistence.Id; |
| 24 | |
import javax.persistence.PrePersist; |
| 25 | |
import javax.persistence.PreUpdate; |
| 26 | |
import javax.persistence.Table; |
| 27 | |
|
| 28 | |
import org.apache.commons.lang.StringUtils; |
| 29 | |
import org.apache.ojb.broker.PersistenceBroker; |
| 30 | |
import org.apache.ojb.broker.PersistenceBrokerException; |
| 31 | |
import org.kuali.rice.kim.bo.role.KimPermission; |
| 32 | |
import org.kuali.rice.kim.bo.types.dto.AttributeSet; |
| 33 | |
import org.kuali.rice.kns.bo.PersistableBusinessObjectBase; |
| 34 | |
|
| 35 | |
|
| 36 | |
|
| 37 | |
|
| 38 | |
@Entity |
| 39 | |
@Table(name="KRIM_PERM_T") |
| 40 | |
public class GenericPermission extends PersistableBusinessObjectBase { |
| 41 | |
|
| 42 | |
|
| 43 | |
private static final long serialVersionUID = 1L; |
| 44 | |
|
| 45 | |
@Id |
| 46 | |
@Column(name="PERM_ID") |
| 47 | |
protected String permissionId; |
| 48 | |
protected String namespaceCode; |
| 49 | |
protected String name; |
| 50 | |
protected String description; |
| 51 | |
protected boolean active; |
| 52 | |
protected String templateId; |
| 53 | |
protected String detailValues; |
| 54 | |
protected AttributeSet details; |
| 55 | |
|
| 56 | |
|
| 57 | |
|
| 58 | |
|
| 59 | |
|
| 60 | 0 | public GenericPermission() { |
| 61 | 0 | } |
| 62 | |
|
| 63 | 0 | public GenericPermission( KimPermission perm ) { |
| 64 | 0 | loadFromKimPermission( perm ); |
| 65 | 0 | } |
| 66 | |
public void loadFromKimPermission( KimPermission perm ) { |
| 67 | 0 | setPermissionId( perm.getPermissionId() ); |
| 68 | 0 | setNamespaceCode( perm.getNamespaceCode() ); |
| 69 | 0 | setName( perm.getName() ); |
| 70 | 0 | setTemplateId( perm.getTemplateId() ); |
| 71 | 0 | setDescription( perm.getDescription() ); |
| 72 | 0 | setActive( perm.isActive() ); |
| 73 | 0 | setDetails( perm.getDetails() ); |
| 74 | 0 | } |
| 75 | |
|
| 76 | |
public String getDetailValues() { |
| 77 | |
|
| 78 | |
|
| 79 | |
|
| 80 | |
|
| 81 | |
|
| 82 | |
|
| 83 | |
|
| 84 | |
|
| 85 | |
|
| 86 | |
|
| 87 | |
|
| 88 | |
|
| 89 | 0 | return detailValues; |
| 90 | |
} |
| 91 | |
|
| 92 | |
public void setDetailValues( String detailValues ) { |
| 93 | 0 | this.detailValues = detailValues; |
| 94 | 0 | String detailValuesTemp = detailValues; |
| 95 | 0 | AttributeSet details = new AttributeSet(); |
| 96 | 0 | if ( detailValuesTemp != null ) { |
| 97 | |
|
| 98 | 0 | detailValuesTemp = detailValuesTemp.replace( "\r\n", "\n" ); |
| 99 | 0 | detailValuesTemp = detailValuesTemp.replace( '\r', '\n' ); |
| 100 | 0 | if ( StringUtils.isNotBlank( detailValuesTemp ) ) { |
| 101 | 0 | String[] values = detailValuesTemp.split( "\n" ); |
| 102 | 0 | for ( String attrib : values ) { |
| 103 | 0 | if ( attrib.indexOf( '=' ) != -1 ) { |
| 104 | 0 | String[] keyValueArray = attrib.split( "=", 2 ); |
| 105 | 0 | details.put( keyValueArray[0].trim(), keyValueArray[1].trim() ); |
| 106 | |
} |
| 107 | |
} |
| 108 | |
} |
| 109 | |
} |
| 110 | 0 | this.details = details; |
| 111 | 0 | } |
| 112 | |
|
| 113 | |
public void setDetailValues( AttributeSet detailsAttribs ) { |
| 114 | 0 | StringBuffer sb = new StringBuffer(); |
| 115 | 0 | if ( detailsAttribs != null ) { |
| 116 | 0 | Iterator<String> keyIter = detailsAttribs.keySet().iterator(); |
| 117 | 0 | while ( keyIter.hasNext() ) { |
| 118 | 0 | String key = keyIter.next(); |
| 119 | 0 | sb.append( key ).append( '=' ).append( detailsAttribs.get( key ) ); |
| 120 | 0 | if ( keyIter.hasNext() ) { |
| 121 | 0 | sb.append( '\n' ); |
| 122 | |
} |
| 123 | 0 | } |
| 124 | |
} |
| 125 | 0 | detailValues = sb.toString(); |
| 126 | 0 | } |
| 127 | |
|
| 128 | |
|
| 129 | |
|
| 130 | |
|
| 131 | |
public boolean isActive() { |
| 132 | 0 | return active; |
| 133 | |
} |
| 134 | |
|
| 135 | |
|
| 136 | |
|
| 137 | |
|
| 138 | |
public void setActive(boolean active) { |
| 139 | 0 | this.active = active; |
| 140 | 0 | } |
| 141 | |
|
| 142 | |
|
| 143 | |
|
| 144 | |
|
| 145 | |
public String getDescription() { |
| 146 | 0 | return description; |
| 147 | |
} |
| 148 | |
|
| 149 | |
|
| 150 | |
|
| 151 | |
|
| 152 | |
public String getPermissionId() { |
| 153 | 0 | return permissionId; |
| 154 | |
} |
| 155 | |
|
| 156 | |
|
| 157 | |
|
| 158 | |
|
| 159 | |
public String getName() { |
| 160 | 0 | return name; |
| 161 | |
} |
| 162 | |
|
| 163 | |
public void setDescription(String permissionDescription) { |
| 164 | 0 | this.description = permissionDescription; |
| 165 | 0 | } |
| 166 | |
|
| 167 | |
public void setName(String permissionName) { |
| 168 | 0 | this.name = permissionName; |
| 169 | 0 | } |
| 170 | |
|
| 171 | |
|
| 172 | |
|
| 173 | |
|
| 174 | |
@SuppressWarnings("unchecked") |
| 175 | |
@Override |
| 176 | |
protected LinkedHashMap toStringMapper() { |
| 177 | 0 | LinkedHashMap m = new LinkedHashMap(); |
| 178 | 0 | m.put( "permissionId", permissionId ); |
| 179 | 0 | m.put( "name", name ); |
| 180 | 0 | m.put( "details", getDetails() ); |
| 181 | 0 | return m; |
| 182 | |
} |
| 183 | |
|
| 184 | |
public void setDetails( AttributeSet details ) { |
| 185 | 0 | this.details = details; |
| 186 | 0 | setDetailValues(details); |
| 187 | 0 | } |
| 188 | |
|
| 189 | |
public String getTemplateId() { |
| 190 | 0 | return this.templateId; |
| 191 | |
} |
| 192 | |
|
| 193 | |
public void setTemplateId(String templateId) { |
| 194 | 0 | this.templateId = templateId; |
| 195 | 0 | } |
| 196 | |
|
| 197 | |
public AttributeSet getDetails() { |
| 198 | 0 | return details; |
| 199 | |
} |
| 200 | |
|
| 201 | |
public String getNamespaceCode() { |
| 202 | 0 | return this.namespaceCode; |
| 203 | |
} |
| 204 | |
|
| 205 | |
public void setNamespaceCode(String namespaceCode) { |
| 206 | 0 | this.namespaceCode = namespaceCode; |
| 207 | 0 | } |
| 208 | |
|
| 209 | |
public void setPermissionId(String permissionId) { |
| 210 | 0 | this.permissionId = permissionId; |
| 211 | 0 | } |
| 212 | |
|
| 213 | |
|
| 214 | |
public void refresh() { |
| 215 | |
|
| 216 | 0 | } |
| 217 | |
|
| 218 | |
@Override |
| 219 | |
public void refreshNonUpdateableReferences() { |
| 220 | |
|
| 221 | 0 | } |
| 222 | |
@Override |
| 223 | |
public void refreshReferenceObject(String referenceObjectName) { |
| 224 | |
|
| 225 | 0 | } |
| 226 | |
|
| 227 | |
|
| 228 | |
|
| 229 | |
|
| 230 | |
|
| 231 | |
|
| 232 | |
@Override |
| 233 | |
@PrePersist |
| 234 | |
public void beforeInsert() { |
| 235 | 0 | throw new UnsupportedOperationException( "This object should never be persisted."); |
| 236 | |
} |
| 237 | |
|
| 238 | |
|
| 239 | |
|
| 240 | |
|
| 241 | |
|
| 242 | |
|
| 243 | |
@Override |
| 244 | |
@PreUpdate |
| 245 | |
public void beforeUpdate() { |
| 246 | 0 | throw new UnsupportedOperationException( "This object should never be persisted."); |
| 247 | |
} |
| 248 | |
|
| 249 | |
|
| 250 | |
|
| 251 | |
|
| 252 | |
|
| 253 | |
|
| 254 | |
@Override |
| 255 | |
public void beforeInsert(PersistenceBroker persistenceBroker) |
| 256 | |
throws PersistenceBrokerException { |
| 257 | 0 | throw new UnsupportedOperationException( "This object should never be persisted."); |
| 258 | |
} |
| 259 | |
|
| 260 | |
|
| 261 | |
|
| 262 | |
|
| 263 | |
|
| 264 | |
|
| 265 | |
@Override |
| 266 | |
public void beforeUpdate(PersistenceBroker persistenceBroker) { |
| 267 | 0 | throw new UnsupportedOperationException( "This object should never be persisted."); |
| 268 | |
} |
| 269 | |
|
| 270 | |
|
| 271 | |
|
| 272 | |
|
| 273 | |
|
| 274 | |
|
| 275 | |
@Override |
| 276 | |
public void beforeDelete(PersistenceBroker persistenceBroker) |
| 277 | |
throws PersistenceBrokerException { |
| 278 | 0 | throw new UnsupportedOperationException( "This object should never be persisted."); |
| 279 | |
} |
| 280 | |
|
| 281 | |
} |