com.bowstreet.profiles
Class Profile

java.lang.Object
  extended by com.bowstreet.profiles.NamedObject
      extended by com.bowstreet.profiles.Profile
All Implemented Interfaces:
IProfileDefines, com.bowstreet.profiles.IXmlDataAccess, ProfileDescription, java.io.Serializable

public class Profile
extends NamedObject
implements IProfileDefines, ProfileDescription, java.io.Serializable

Class that represents a single Profile object from within a ProfileSet

See Also:
ProfileSet, Serialized Form

Field Summary
 
Fields inherited from interface com.bowstreet.profiles.IProfileDefines
CURRENT_CUSTOM_VALUE_PSET, CUSTOM_VALUE_MAP_KEY, DEFAULT, DESCRIPTION, EDIT_STATUS, EDITABLE, EFFECTS_CHILD, emptyIterator, ENTRIES, ENTRY, EXTRA_DATA, FALSE, FINAL_LOCKED, FINAL_LOCKED_STR, INHERITED_FROM, INHERITED_LOCKED, INHERITED_LOCKED_STR, IS_CONTAINER, IS_FINAL, IS_INHERITED, IS_RUNTIME, LAST_MODIFIED, LAST_MODIFIED_BY, MODEL, MODELS, NAME, PARENT, PC_ALREADY_CONVERTED, PC_INVALID_DATA, PC_NO_PROFILE, PC_OK, PROFILE, PROFILE_ATTR, PROFILE_DEF, PROFILE_SET, PROFILE_SET_MAP_PREVIEW_KEY, PROFILED, PROFILES, PROMPT, ROLE, ROLE_SELECTION_CLASS, ROLES, TRUE, TYPE, UI, USE_FULL_NAMES, VALUE, VALUE_CLASS, VALUES
 
Constructor Summary
Profile(IXml tdProfile)
          Constructs a Profile from an IXml object.
Profile(java.lang.String name)
          Constructs a new Profile and sets its name and its parents name to the Default profile.
Profile(java.lang.String name, java.lang.String parentName)
          Constructs a new Profile and sets its name and parent name.
 
Method Summary
 void addRole(java.lang.String role)
          Adds a single Role to this Profile.
 void addValue(ProfileValue profileValue)
          Adds a single ProfileValue to this Profile.
 java.lang.Object clone()
          Creates and returns a copy of this Profile.
 boolean containsRole(java.lang.String role)
          Checks to see if a specified role exists for this Profile.
 boolean containsValue(java.lang.String name)
          Checks to see if a value exists for the specified value name.
 boolean equals(java.lang.Object obj)
          Compare two Profile's.
 IXml getAsIXml(boolean getAll)
          Gets the entire Profile as IXml.
 int getDepth()
          Gets the hierarchy depth of this Profile.
 long getLastModified()
          Gets the last time this profile was modified.
 java.lang.String getParent()
          Gets the name of the parent Profile.
 java.util.Iterator getRoles()
          Gets a Iterator to a list of all of the Roles for this Profile.
 java.lang.String getShortName()
          Gets the non-qualified name of this Profile.
 ProfileValue getValue(java.lang.String name)
          Gets a specified ProfileValue object by name.
 java.util.Iterator getValues()
          Gets a Map Iterator of all of the ProfileValue's for this Profile.
 boolean hasChanged()
          Checks to see if this Profile different that the original.
 boolean isCalculated()
          Checks to see if the values have been calculated from profile hierarchy.
 boolean isContainer()
          Gets if this Profile is a container, which specifies that this Profile may have child Profile nodes.
 boolean isDefault()
          Checks if this profile is the default.
 void modifyValue(ProfileValue profileValue)
          Modifies an existing ProfileValue in this Profile.
 void removeAllRoles()
          Removes all of the Roles from this Profile.
 void removeRole(java.lang.String role)
          Removes the specified Role from this Profile.
 void removeValue(java.lang.String name)
          Removes the specified ProfileValue by name from this Profile.
 boolean rolesExist()
          Checks to see if there are any Roles associated with this Profile.
 void setCalculated(boolean isCalculated)
          Sets if the values have been calculated from profile hierarchy.
 void setFromIXml(IXml tdProfile)
          Sets the entire Profile from a IXml.
 void setIsContainer(boolean isContainer)
          Sets if this Profile is a container, which specifies that this Profile may have child Profile nodes.
 void setLastModified(long lastModified)
          Sets the last time this profile was modified.
 void setName(java.lang.String name)
          Sets the name of this Profile.
 void setParent(java.lang.String parentName)
          Sets the name of the parent for this Profile.
 void setRoles(java.util.Vector roles)
          Sets a list of all of the Roles for this Profile.
 java.lang.String toString()
          Gets a String of all the Profile data for debugging only
 void update(com.bowstreet.profiles.IXmlDataAccess item)
          Updates from an existing Profile.
 
Methods inherited from class com.bowstreet.profiles.NamedObject
getName
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.bowstreet.profiles.ProfileDescription
getName
 

Constructor Detail

Profile

public Profile(IXml tdProfile)
        throws ProfileException
Constructs a Profile from an IXml object.

Parameters:
tdProfile - An XML representation of a Profile Object.
Throws:
ProfileException - if duplicate name in entry.

Profile

public Profile(java.lang.String name)
Constructs a new Profile and sets its name and its parents name to the Default profile. By default the Profile is created with its isContainer flag set to true.

Parameters:
name - The name of the Profile being created (e.g. "gold"). This must always be the short name.
See Also:
ProfileSetStorageManager.getChildProfiles(String, String, boolean), setIsContainer(boolean)
Example:
Profile profile = new Profile("gold");

Profile

public Profile(java.lang.String name,
               java.lang.String parentName)
Constructs a new Profile and sets its name and parent name. By default the Profile is created with its isContainer flag set to true.

Parameters:
name - The name of the Profile being created (e.g. "gold"). This must always be the short name.
parentName - The name of parent for this profile. If using qualified profile names the parentName name specified must be the full name of the Profile (e.g. "acme.serviceLevel"). If not using qualified profile names the parentName specified must be the just the name of the profile itself (e.g. "serviceLevel").
See Also:
ProfileSetStorageManager.getChildProfiles(String, String, boolean), setIsContainer(boolean)
Example:
Profile profile = new Profile("gold", "acme.serviceLevel");
Profile profile = new Profile("gold", parentProfile.getName());
Method Detail

addRole

public void addRole(java.lang.String role)
Adds a single Role to this Profile. If the Role already exists this will do nothing.

Parameters:
role - A Role name to add.

addValue

public void addValue(ProfileValue profileValue)
              throws ProfileException
Adds a single ProfileValue to this Profile.

Parameters:
profileValue - The ProfileValue objects to add.
Throws:
ProfileException - if the ProfileValue name already exists.
See Also:
ProfileValue

clone

public java.lang.Object clone()
Creates and returns a copy of this Profile.

Specified by:
clone in interface com.bowstreet.profiles.IXmlDataAccess
Overrides:
clone in class NamedObject
Returns:
A copy of this Profile.

containsRole

public boolean containsRole(java.lang.String role)
Checks to see if a specified role exists for this Profile.

Parameters:
role - The nameof the Role to check.
Returns:
true if found, else false

containsValue

public boolean containsValue(java.lang.String name)
Checks to see if a value exists for the specified value name.

Parameters:
name - The name of the value.
Returns:
true if there is a values for the specified name, else false
See Also:
ProfileValue

equals

public boolean equals(java.lang.Object obj)
Compare two Profile's. This will just compare the values.

Overrides:
equals in class NamedObject
Parameters:
obj - The Profile to compare against.
Returns:
true if Profile is equal, else false

getAsIXml

public IXml getAsIXml(boolean getAll)
               throws ProfileException
Gets the entire Profile as IXml. The entire Profile will be represented as one block of XML(IXml).

Specified by:
getAsIXml in interface com.bowstreet.profiles.IXmlDataAccess
Parameters:
getAll - specifies if all of the data should be returned. This is used to remove any calculated of UI specific data.
Returns:
The XML data representation of this Profile.
Throws:
ProfileException - On error.
See Also:
IXml

getDepth

public final int getDepth()
Gets the hierarchy depth of this Profile.

Returns:
The Depth.

getLastModified

public long getLastModified()
Gets the last time this profile was modified.

Returns:
The last time this profile was modified.

getParent

public java.lang.String getParent()
Gets the name of the parent Profile. If using qualified profile names the name returned will be the fully qualified name of the Profile (e.g. "acme.hr.gold"). If not using qualified profile names the name returned will be the non-qualified name (e.g. "gold").

Specified by:
getParent in interface ProfileDescription
Returns:
The parent name.

getRoles

public java.util.Iterator getRoles()
Gets a Iterator to a list of all of the Roles for this Profile.

Returns:
A List of Strings that represent the Role names.

getShortName

public java.lang.String getShortName()
Gets the non-qualified name of this Profile.

Specified by:
getShortName in interface ProfileDescription
Returns:
The non-qualified Profile name (e.g. "gold").

getValue

public ProfileValue getValue(java.lang.String name)
Gets a specified ProfileValue object by name.

Parameters:
name - The name of the ProfileValue to get.
Returns:
The selected ProfileValue object or null if not found.
See Also:
ProfileValue

getValues

public java.util.Iterator getValues()
Gets a Map Iterator of all of the ProfileValue's for this Profile.

Returns:
An Iterator of ProfileValue objects.
See Also:
ProfileValue

hasChanged

public boolean hasChanged()
Checks to see if this Profile different that the original.

Returns:
true if the values of this Ptrofile are different, else false.

isCalculated

public boolean isCalculated()
Checks to see if the values have been calculated from profile hierarchy.

Returns:
true if the values have been for calculated, else false.

isContainer

public boolean isContainer()
Gets if this Profile is a container, which specifies that this Profile may have child Profile nodes. This is informational and is not enforced. It is used when retrieving Profile from the ProfileSetStorageManager, and also effects the Profile caching since containers are used when calculating profile values.

Specified by:
isContainer in interface ProfileDescription
Returns:
true if this Profile is a container, else false.
See Also:
ProfileSetStorageManager.getChildProfiles(String, String, boolean)

isDefault

public boolean isDefault()
Checks if this profile is the default. The default is the root of all of the profiles in this set.

Returns:
true if this is the default, else false.

modifyValue

public void modifyValue(ProfileValue profileValue)
                 throws ProfileException
Modifies an existing ProfileValue in this Profile. If the value does not exist then it will be added.

Parameters:
profileValue - The ProfileValue objects to modify.
Throws:
ProfileException - On error.
See Also:
ProfileValue

removeAllRoles

public void removeAllRoles()
Removes all of the Roles from this Profile.


removeRole

public void removeRole(java.lang.String role)
Removes the specified Role from this Profile. If the Role does not exist this will do nothing.

Parameters:
role - The name of the Role to remove.

removeValue

public void removeValue(java.lang.String name)
Removes the specified ProfileValue by name from this Profile.

Parameters:
name - The name of the value to be removed.
See Also:
ProfileValue

rolesExist

public boolean rolesExist()
Checks to see if there are any Roles associated with this Profile.

Returns:
true if there are any Roles, else false.

setCalculated

public void setCalculated(boolean isCalculated)
Sets if the values have been calculated from profile hierarchy.

Parameters:
isCalculated - true to specify that the values have been calculated, else false.

setFromIXml

public void setFromIXml(IXml tdProfile)
                 throws ProfileException
Sets the entire Profile from a IXml. The entire Profile will be overwritten with the XML(IXml) data.

Specified by:
setFromIXml in interface com.bowstreet.profiles.IXmlDataAccess
Parameters:
tdProfile - The IXml representation of a Profile.
Throws:
ProfileException - On error.
See Also:
IXml

setIsContainer

public void setIsContainer(boolean isContainer)
Sets if this Profile is a container, which specifies that this Profile may have child Profile nodes. This is informational and is not enforced. It is used when retrieving Profile from the ProfileSetStorageManager, and also effects the Profile caching since containers are used when calculating profile values.

Parameters:
isContainer - true if this Profile is a container, else false.
See Also:
ProfileSetStorageManager.getChildProfiles(String, String, boolean)

setLastModified

public void setLastModified(long lastModified)
Sets the last time this profile was modified.

Parameters:
lastModified - The last time this profile was modified.

setName

public void setName(java.lang.String name)
Sets the name of this Profile.

Specified by:
setName in interface com.bowstreet.profiles.IXmlDataAccess
Overrides:
setName in class NamedObject
Parameters:
name - The name of this Profile.

setParent

public void setParent(java.lang.String parentName)
Sets the name of the parent for this Profile. If using qualified profile names the name specified must be the full name of the Profile (e.g. "acme.hr"). If not using qualified profile names the name specified must be the just the name of the profile itself (e.g. "hr").

Parameters:
parentName - The parent name for this Profile.

setRoles

public void setRoles(java.util.Vector roles)
Sets a list of all of the Roles for this Profile.

Parameters:
roles - A List of Strings that represent the Role names.

toString

public java.lang.String toString()
Gets a String of all the Profile data for debugging only

Overrides:
toString in class java.lang.Object
Returns:
The Profile data as a String

update

public void update(com.bowstreet.profiles.IXmlDataAccess item)
Updates from an existing Profile.

Specified by:
update in interface com.bowstreet.profiles.IXmlDataAccess
Overrides:
update in class NamedObject
Parameters:
item - The IXmlDataAccess, which must be a Profile.


Copyright © 2009 IBM. All Rights Reserved.