pulse - the web application framework Get pulse at SourceForge.net. Fast, secure and Free Open Source software downloads Ohloh project report for pulse-java

org.torweg.pulse.accesscontrol.attributes
Class AbstractAttribute<T>

java.lang.Object
  extended by org.torweg.pulse.util.entity.AbstractBasicEntity
      extended by org.torweg.pulse.util.entity.Node
          extended by org.torweg.pulse.accesscontrol.attributes.AbstractAttribute<T>
Type Parameters:
T - the type of the attribute's value
All Implemented Interfaces:
java.io.Serializable, JDOMable, INamed
Direct Known Subclasses:
BooleanAttribute, BundleAttribute, SectionAttribute, SelectionAttribute, StringAttribute

@Entity
public abstract class AbstractAttribute<T>
extends Node
implements INamed, JDOMable, java.io.Serializable

base class for all attributes.

Version:
$Revision: 1809 $
Author:
Thomas Weber, Christian Schatt, Daniel Dietz
See Also:
Serialized Form

Field Summary
protected static org.slf4j.Logger LOGGER
          the logger.
 
Constructor Summary
protected AbstractAttribute()
          Deprecated. 
protected AbstractAttribute(boolean isSystemAttribute)
          protected constructor to be called by the constructors of all subclasses.
 
Method Summary
 boolean addAdminEditRole(Role r)
          adds a given Role to the admin-edit-roles.
 boolean addAdminViewRole(Role r)
          adds a given Role to the admin-view-roles.
 boolean addSelfEditRole(Role r)
          adds a given Role to the self-edit-roles.
 boolean addSelfViewRole(Role r)
          adds a given Role to the self-view-roles.
 boolean addTriggeredRole(Role r)
          adds a given Role to the triggered-roles.
 org.jdom.Element deserializeToJDOM()
          returns a JDOM representation of the attribute.
 org.jdom.Element deserializeToJDOM(java.util.Map<java.lang.Long,AbstractValue<?>> valueMap)
          used during deserialization of a User.
 java.util.Set<Role> getAdminEditRoles()
          returns the Roles which allow editing the attribute for arbitrary Users in the administration interface.
 java.util.Set<Role> getAdminViewRoles()
          returns the Roles which allow viewing the attribute for arbitrary Users in the administration interface.
abstract  AbstractAttribute<T> getAttributeInstance(java.lang.String name, boolean isSystem)
          creator-method.
abstract  AbstractTypedCheck<T> getCheck()
          returns the attribute's check.
abstract  java.lang.String getName()
          returns the name of the attribute.
 java.util.Set<Role> getSelfEditRoles()
          returns the Roles which allow editing the attribute for one's own User.
 java.util.Set<Role> getSelfViewRoles()
          returns the Roles which allow viewing the attribute for one's own User.
 java.util.Set<Role> getTriggeredRoles()
          returns the Roles which get assigned to Users, when the attribute and all its sub-attributes are valid.
 java.util.Set<java.lang.Class<AbstractTypedCheck<?>>> getTypedChecks()
          returns a set with the available typed checks for the attribute.
 AbstractValue<T> getValue(User user)
          returns the value of the attribute for the given user.
 boolean isRequired()
          returns whether the attribute is required.
 boolean isSystemAttribute()
          returns whether the attribute is a system attribute.
 boolean isValid(User user)
          returns whether the value of the user's attribute is valid according to the attribute's check.
 boolean removeAdminEditRole(Role r)
          removes a given Role from the admin-edit-roles.
 boolean removeAdminViewRole(Role r)
          removes a given Role from the admin-view-roles.
 boolean removeSelfEditRole(Role r)
          removes a given Role from the self-edit-roles.
 boolean removeSelfViewRole(Role r)
          removes a given Role from the self-view-roles.
 boolean removeTriggeredRole(Role r)
          removes a given Role from the triggered-roles.
 void setAdminEditRoles(java.util.Set<Role> r)
          sets the Roles which allow editing the attribute for arbitrary Users in the administration interface.
 void setAdminViewRoles(java.util.Set<Role> r)
          sets the Roles which allow viewing the attribute for arbitrary Users in the administration interface.
abstract  void setCheck(AbstractTypedCheck<T> c)
          sets the attrubite's check.
 void setRequired(boolean r)
          sets, whether the attribute is required.
 void setSelfEditRoles(java.util.Set<Role> r)
          sets the Roles which allow editing the attribute for one's own User.
 void setSelfViewRoles(java.util.Set<Role> r)
          sets the Roles which allow viewing the attribute for one's own User.
 void setTriggeredRoles(java.util.Set<Role> r)
          sets the Roles which get assigned to Users, when the attribute and all its sub-attributes are valid.
 User setValue(AbstractValue<T> value, User user)
          sets the value of the attribute for the given user.
 net.sf.json.JSONObject toJSON()
          returns a representation of the attribute for the attribute-tree in the web-site-administration.
abstract  AbstractAttribute<T> updateSettingsFromCommand(Command command, org.hibernate.Session session)
          updates the attribute's settings from the given command.
abstract  AbstractValue<T> valueFromCommand(Command c)
          initialises a value of this attribute from the given command.
 
Methods inherited from class org.torweg.pulse.util.entity.Node
addChild, addChild, getChild, getChildIndex, getChildren, getParent, hasChildren, removeChild, setChildren
 
Methods inherited from class org.torweg.pulse.util.entity.AbstractBasicEntity
compareTo, equals, getFullQualifiedClassNameJAXB, getId, hashCode
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOGGER

protected static final org.slf4j.Logger LOGGER
the logger.

Constructor Detail

AbstractAttribute

@Deprecated
protected AbstractAttribute()
Deprecated. 

used by JAXB.


AbstractAttribute

protected AbstractAttribute(boolean isSystemAttribute)
protected constructor to be called by the constructors of all subclasses.

Parameters:
isSystemAttribute - flag, indicating whether the attribute is a system attribute
Method Detail

setSelfViewRoles

public final void setSelfViewRoles(java.util.Set<Role> r)
sets the Roles which allow viewing the attribute for one's own User.

Parameters:
r - the roles to set

addSelfViewRole

public final boolean addSelfViewRole(Role r)
adds a given Role to the self-view-roles.

Parameters:
r - the role to add
Returns:
boolean

removeSelfViewRole

public final boolean removeSelfViewRole(Role r)
removes a given Role from the self-view-roles.

Parameters:
r - the role to remove
Returns:
boolean

getSelfViewRoles

public final java.util.Set<Role> getSelfViewRoles()
returns the Roles which allow viewing the attribute for one's own User.

Returns:
the roles

getSelfEditRoles

public final java.util.Set<Role> getSelfEditRoles()
returns the Roles which allow editing the attribute for one's own User.

Returns:
the roles

setSelfEditRoles

public final void setSelfEditRoles(java.util.Set<Role> r)
sets the Roles which allow editing the attribute for one's own User.

Parameters:
r - the roles to set

addSelfEditRole

public final boolean addSelfEditRole(Role r)
adds a given Role to the self-edit-roles.

Parameters:
r - the role to add
Returns:
boolean

removeSelfEditRole

public final boolean removeSelfEditRole(Role r)
removes a given Role from the self-edit-roles.

Parameters:
r - the role to remove
Returns:
boolean

setAdminViewRoles

public final void setAdminViewRoles(java.util.Set<Role> r)
sets the Roles which allow viewing the attribute for arbitrary Users in the administration interface.

Parameters:
r - the roles to set

addAdminViewRole

public final boolean addAdminViewRole(Role r)
adds a given Role to the admin-view-roles.

Parameters:
r - the role to add
Returns:
boolean

removeAdminViewRole

public final boolean removeAdminViewRole(Role r)
removes a given Role from the admin-view-roles.

Parameters:
r - the role to remove
Returns:
boolean

getAdminViewRoles

public final java.util.Set<Role> getAdminViewRoles()
returns the Roles which allow viewing the attribute for arbitrary Users in the administration interface.

Returns:
the roles

setAdminEditRoles

public final void setAdminEditRoles(java.util.Set<Role> r)
sets the Roles which allow editing the attribute for arbitrary Users in the administration interface.

Parameters:
r - the roles to set

addAdminEditRole

public final boolean addAdminEditRole(Role r)
adds a given Role to the admin-edit-roles.

Parameters:
r - the role to add
Returns:
boolean

removeAdminEditRole

public final boolean removeAdminEditRole(Role r)
removes a given Role from the admin-edit-roles.

Parameters:
r - the role to remove
Returns:
boolean

getAdminEditRoles

public final java.util.Set<Role> getAdminEditRoles()
returns the Roles which allow editing the attribute for arbitrary Users in the administration interface.

Returns:
the roles

setTriggeredRoles

public final void setTriggeredRoles(java.util.Set<Role> r)
sets the Roles which get assigned to Users, when the attribute and all its sub-attributes are valid.

Parameters:
r - the roles to set

addTriggeredRole

public final boolean addTriggeredRole(Role r)
adds a given Role to the triggered-roles.

Parameters:
r - the role to add
Returns:
boolean

removeTriggeredRole

public final boolean removeTriggeredRole(Role r)
removes a given Role from the triggered-roles.

Parameters:
r - the role to remove
Returns:
boolean

getTriggeredRoles

public final java.util.Set<Role> getTriggeredRoles()
returns the Roles which get assigned to Users, when the attribute and all its sub-attributes are valid.

Returns:
the triggered roles

isSystemAttribute

public final boolean isSystemAttribute()
returns whether the attribute is a system attribute.

Returns:
true, if the attribute is a system attribute

isRequired

public final boolean isRequired()
returns whether the attribute is required.

Returns:
true, if the attribute is required.

setRequired

public final void setRequired(boolean r)
sets, whether the attribute is required.

Parameters:
r - true, if the attribute is required.

isValid

public final boolean isValid(User user)
returns whether the value of the user's attribute is valid according to the attribute's check.

If the AbstractTypedCheck is null, the value is considered valid. A null value is considered invalid.

Parameters:
user - the user
Returns:
whether the value of the attribute is valid

getName

public abstract java.lang.String getName()
returns the name of the attribute.

Specified by:
getName in interface INamed
Returns:
the name of the attribute

getValue

public final AbstractValue<T> getValue(User user)
returns the value of the attribute for the given user.

Parameters:
user - the user
Returns:
the value

setValue

public final User setValue(AbstractValue<T> value, User user)
sets the value of the attribute for the given user.

Parameters:
value - the value to be set
user - the user
Returns:
the modified user

getTypedChecks

public final java.util.Set<java.lang.Class<AbstractTypedCheck<?>>> getTypedChecks()
returns a set with the available typed checks for the attribute.

Returns:
a set with the available checks

setCheck

public abstract void setCheck(AbstractTypedCheck<T> c)
sets the attrubite's check.

Parameters:
c - the check to set

getCheck

public abstract AbstractTypedCheck<T> getCheck()
returns the attribute's check.

Returns:
the attribute's check

getAttributeInstance

public abstract AbstractAttribute<T> getAttributeInstance(java.lang.String name,
                                                          boolean isSystem)
creator-method.

Used by AttributeFactory.

Parameters:
name - the name of the new attribute
isSystem - indicates if new attribute is system-attribute
Returns:
a new attribute

valueFromCommand

public abstract AbstractValue<T> valueFromCommand(Command c)
initialises a value of this attribute from the given command.

Parameters:
c - the command
Returns:
a value of this attribute initialised from the given command

updateSettingsFromCommand

public abstract AbstractAttribute<T> updateSettingsFromCommand(Command command,
                                                               org.hibernate.Session session)
updates the attribute's settings from the given command.

This method assumes that it is part of a larger transaction, thus the changes to the session are neither encapsulated in a separate transaction nor commited.

Parameters:
command - the command
session - the session for persisting the updates
Returns:
the modified attribute

deserializeToJDOM

public org.jdom.Element deserializeToJDOM()
returns a JDOM representation of the attribute.

Classes extending AbstractAttribute are recommended, but not required to call this method via super.deserializeToJDOM() and just add their result to the returned element in a separate value-element.

If <T> is an instance of JDOMable, the value is also added by this method.

Specified by:
deserializeToJDOM in interface JDOMable
Returns:
a JDOM representation of the attribute
See Also:
JDOMable.deserializeToJDOM()

deserializeToJDOM

public org.jdom.Element deserializeToJDOM(java.util.Map<java.lang.Long,AbstractValue<?>> valueMap)
used during deserialization of a User.

Does not add the roles!

Parameters:
valueMap - maps attribute-ids a Users attribute-values
Returns:
a representation of the attribute which is required for the User.

toJSON

public net.sf.json.JSONObject toJSON()
returns a representation of the attribute for the attribute-tree in the web-site-administration.

Overrides:
toJSON in class Node
Returns:
a JSONObject