com.bowstreet.profiles
Class ProfileSet

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

public class ProfileSet
extends ProfileSetDescription
implements IProfileDefines

Class that represents a single ProfileSet.

The following is an example that sets up a ProfileSet structure and add profiles with sample data

// The name of the Profileset, must be unique
String profileSetName = "regionTest";

// create a ProfileSetStorageManager to read/write ProfileSets
ProfileSetStorageManager profileStorage = new ProfileSetStorageManager("Test User");

// create the ProfileSet with a name, description and specify to use qualified (e.g. "acme.hr.gold") profile names.
ProfileSet profileSet = new ProfileSet(profileSetName, "Sample ProfileSet", true);

// create the ProfileSet structure by adding each ProfileDefEntry to the ProfileDef

// create the profile definition
ProfileDef profileDef = new ProfileDef();

// add the the ProfileDef to the new ProfileSet
profileSet.setProfileDef(profileDef);

// create the individual entries(structure) and add them to the definition ProfileDefEntry profileDefEntry = new ProfileDefEntry("ManagerName", "TextInput", "Set Manager's Name","");
profileDef.addEntry(profileDefEntry);

profileDefEntry = new ProfileDefEntry("ManagerPhone", "TextInput", "Set Manager's Phone Number", "");
profileDef.addEntry(profileDefEntry);

profileDefEntry = new ProfileDefEntry("DisplayPhone", "CheckBox", "Display Manager's Phone Number","");
profileDef.addEntry(profileDefEntry);

profileDefEntry = new ProfileDefEntry("Commission", "TextInput", "Percent Commission on Sales", "");
profileDef.addEntry(profileDefEntry);

// create the mandatory Default Profile
Profile profile = new Profile(Profile.DEFAULT);

// add the values to the Default Profile
ProfileValue value = new ProfileValue("ManagerName", "None");
profile.addValue(value);
value = new ProfileValue("ManagerPhone", "0000-0000");
profile.addValue(value);
value = new ProfileValue("Commission", "10.0");
profile.addValue(value);
value = new ProfileValue("DisplayPhone", "true");
profile.addValue(value);

// add the profile to the ProfileSet
profileSet.addProfile(profile);

// create the "EastCoast" Profile where the parent will default to "Default"
profile = new Profile("EastCoast");

// create values and add them to the Profile
value = new ProfileValue("ManagerName", "Frank R.");
profile.addValue(value);
value = new ProfileValue("ManagerPhone", "123-4567");
profile.addValue(value);
value = new ProfileValue("Commission", "25.0");
value.setFinal(true);
profile.addValue(value);

// add the profile to the ProfileSet
profileSet.addProfile(profile);

// create the "NH" Profile with a parent of "EastCoast"
profile = new Profile("NH", profile.getName());

// create values and add them to the Profile
value = new ProfileValue("ManagerName", "Sol R.");
profile.addValue(value);
value = new ProfileValue("ManagerPhone", "555-1212");
profile.addValue(value);

profile.addRole("Role1");
profile.addRole("Role2");

// add the profile to the Profileset
profileSet.addProfile(profile);

// save the new ProfileSet to the storage device
profileStorage.saveProfileSet(profileSet, false);

See Also:
ProfileSetDescription, ProfileSetStorageManager, Profile, ProfileDef, ProfileDefEntry, 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
ProfileSet()
          Constructs a ProfileSet.
ProfileSet(java.lang.String name, java.lang.String description)
          Constructs a ProfileSet with the specified description information.
 
Method Summary
 void addModel(java.lang.String modelName)
          Adds a single Model to this ProfileSet.
 void addProfile(Profile profile)
          Adds a Profile to this ProfileSet.
 void calculateProfileValues()
          Calculates all of the values from the profile hierarchy.
 void calculateProfileValues(boolean forceRecalc)
          Calculates all of the values from the profile hierarchy.
 java.lang.Object clone()
          Creates and returns a copy of this ProfileSet.
 ProfileSet cloneStructure()
          Creates and returns a copy of the ProfileSet structure.
 boolean containsModel(java.lang.String modelName)
          Checks to see if a specified Model exists for this ProfileSet.
 boolean containsProfile(Profile profile)
          Checks if there is an existing profile with the same name.
 boolean equals(java.lang.Object obj)
          Compare two ProfileSet's.
 IXml getAsIXml()
          Gets the entire Profile Set as IXml.
 IXml getAsIXml(boolean getAll)
          Gets the entire ProfileSet as IXml.
 Profile getDefaultProfile()
          Gets the default Profile from this Profile Set.
 java.util.Iterator getModels()
          Gets an Iterator to a list of all of the Models for this ProfileSet.
 Profile getProfile(java.lang.String profileName)
          Gets the specified Profile by name from this ProfileSet.
 ProfileDef getProfileDef()
          Gets the ProfileDef field of this ProfileSet.
 java.util.Iterator getProfiles()
          Gets an Iterator to the entire list of Profile objects from within this ProfileSet.
 java.lang.String getProfileSelectionClass()
          Gets the name of the class to be used to calculate the Profile selection.
 java.lang.String getValueClass()
          Gets the name of the class to be used to create the values associated with a Profile.
 boolean isChild(java.lang.String profileName, java.lang.String childProfileName)
          Checks to see the specified child is child of the specified profile.
 void mergeChangedProfiles(ProfileSet updatedProfileSet)
          Merges changes using the hasChanged data member of the Profiles from the source ProfileSet to this ProfileSet.
 void mergeProfileDefData(ProfileSet updatedProfileSet)
          Merges changes of the ProfilesDef, strProfileSelectionClass and strValueClass from the source ProfileSet to this ProfileSet.
 void modifyProfile(Profile profile)
          Modifies an existing Profile in this ProfileSet.
 void removeDefEntry(java.lang.String defEntryName)
          Removes a Profile Definition Entry on this Profileset.
 void removeModel(java.lang.String modelName)
          Removes the specified Model from this ProfileSet.
 void removeProfile(java.lang.String profileName)
          Removes the specified Profile from this Profile Set.
 void renameDefEntry(java.lang.String defEntryName, java.lang.String newDefEntryName)
          Rename a Profile Definition Entry on this Profileset.
 void renameParent(java.lang.String profileName, java.lang.String newParentName)
          Changes the parent of the specified Profile.
 void setFromIXml(IXml tdProfileSet)
          Sets the entire Profile Set from a IXml.
 void setModels(java.util.List models)
          Sets a list of all of the Models for this ProfileSet.
 void setProfileDef(ProfileDef profileDef)
          Sets the ProfileDef field of this Profile Set.
 void setProfileSelectionClass(java.lang.String name)
          Sets the name of the class or handler to be used to perform the Profile selection.
 void setProfilesLastModified()
          Sets all of the Profiles in this ProfileSet to the current time if they are currently not set.
 void setValueClass(java.lang.String className)
          Sets the name of the class to be used to create the values associated with a Profile.
 java.lang.String toString()
          Gets a String of all the Profile data for debugging.
 void update(com.bowstreet.profiles.IXmlDataAccess item)
          Updates from an existing ProfileSet.
 void updateProfilesChanged(ProfileSet originalProfileSet)
          Compares the individual Profiles of this ProfileSet to the specified original ProfileSet and sets the Profile hasChanged accordingly.
 
Methods inherited from class com.bowstreet.profiles.ProfileSetDescription
getDescription, getLastModifiedBy, getLastTimeModified, setDescription, setLastModifiedBy, setLastTimeModified, setUseQualifiedProfileNames, useQualifiedProfileNames
 
Methods inherited from class com.bowstreet.profiles.NamedObject
getName, setName
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ProfileSet

public ProfileSet()
Constructs a ProfileSet.


ProfileSet

public ProfileSet(java.lang.String name,
                  java.lang.String description)
Constructs a ProfileSet with the specified description information.

Parameters:
name - The ProfileSet name.
description - The ProfileSet description.
Method Detail

addModel

public void addModel(java.lang.String modelName)
Adds a single Model to this ProfileSet. If the Model already exists this will do nothing.

Parameters:
modelName - A Model unique ID to add.

addProfile

public void addProfile(Profile profile)
                throws ProfileException
Adds a Profile to this ProfileSet.

Parameters:
profile - The Profile to add.
Throws:
ProfileException - if duplicate name in entry.
See Also:
Profile

calculateProfileValues

public void calculateProfileValues()
                            throws ProfileException
Calculates all of the values from the profile hierarchy. This is used by regeneration of the model. once the value is calculated it should NOT be saved in that state.

Throws:
ProfileException - On error.

calculateProfileValues

public void calculateProfileValues(boolean forceRecalc)
                            throws ProfileException
Calculates all of the values from the profile hierarchy.

Parameters:
forceRecalc - true to force a recalculate. This can be used by the UI if a value changes.
Throws:
ProfileException - On error.

clone

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

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

cloneStructure

public ProfileSet cloneStructure()
Creates and returns a copy of the ProfileSet structure. Clones everything but the Profiles

Returns:
A clone of this ProfileSets structure.

containsModel

public boolean containsModel(java.lang.String modelName)
Checks to see if a specified Model exists for this ProfileSet.

Parameters:
modelName - The unique ID of the Model to check.
Returns:
true if found, else false

containsProfile

public boolean containsProfile(Profile profile)
Checks if there is an existing profile with the same name.

Parameters:
profile - The Profile to check if exists.
Returns:
true if already exists, else false.
See Also:
Profile

equals

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

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

getAsIXml

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

Returns:
The XML data representation of this ProfileSet.
Throws:
ProfileException - On error.
See Also:
IXml

getAsIXml

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

Specified by:
getAsIXml in interface com.bowstreet.profiles.IXmlDataAccess
Overrides:
getAsIXml in class ProfileSetDescription
Parameters:
getAll - true to get all of the calculated inherited data, else false.
Returns:
The XML data representation of this Profile Set.
Throws:
ProfileException - On error.
See Also:
IXml

getDefaultProfile

public Profile getDefaultProfile()
Gets the default Profile from this Profile Set.

Returns:
The default Profile.
See Also:
Profile

getModels

public java.util.Iterator getModels()
Gets an Iterator to a list of all of the Models for this ProfileSet.

Returns:
A List of Strings that represent the Model unique ID's.

getProfile

public Profile getProfile(java.lang.String profileName)
Gets the specified Profile by name from this ProfileSet. If using qualified profile names the name specified must be the full name of the Profile (e.g. "acme.hr.gold"). If not using qualified profile names the name specified must be the just the name of the profile itself (e.g. "gold").

Parameters:
profileName - The name of the profile to get.
Returns:
The specified Profile, or null if it does not exist in this ProfileSet.
See Also:
Profile

getProfileDef

public ProfileDef getProfileDef()
Gets the ProfileDef field of this ProfileSet.

Returns:
The ProfileDef.
See Also:
ProfileDef

getProfiles

public java.util.Iterator getProfiles()
Gets an Iterator to the entire list of Profile objects from within this ProfileSet.

Returns:
The Iterator of Profiles.
See Also:
Profile

getProfileSelectionClass

public java.lang.String getProfileSelectionClass()
Gets the name of the class to be used to calculate the Profile selection. Example: "com.bowstreet.profiles.MyProfileSelection"

Returns:
The name of the class.

getValueClass

public java.lang.String getValueClass()
Gets the name of the class to be used to create the values associated with a Profile. Example: "com.bowstreet.profiles.MyProfileValues"

Returns:
The name of the class.

isChild

public boolean isChild(java.lang.String profileName,
                       java.lang.String childProfileName)
                throws ProfileException
Checks to see the specified child is child of the specified profile. If using qualified profile names the name specified must be the full name of the Profile (e.g. "acme.hr.gold"). If not using qualified profile names the name specified must be the just the name of the profile itself (e.g. "gold").

Parameters:
profileName - The name of the Profile who's children to check.
childProfileName - The name of the child Profile.
Returns:
boolean true if found anywhere in the parent lineage
Throws:
ProfileException - On error.

mergeChangedProfiles

public void mergeChangedProfiles(ProfileSet updatedProfileSet)
                          throws ProfileException
Merges changes using the hasChanged data member of the Profiles from the source ProfileSet to this ProfileSet. This only merges the Profile data.

Parameters:
updatedProfileSet - The source ProfileSet to merge from.
Throws:
ProfileException - On error.

mergeProfileDefData

public void mergeProfileDefData(ProfileSet updatedProfileSet)
                         throws ProfileException
Merges changes of the ProfilesDef, strProfileSelectionClass and strValueClass from the source ProfileSet to this ProfileSet.

Parameters:
updatedProfileSet - The source ProfileSet to merge from.
Throws:
ProfileException - On error.

modifyProfile

public void modifyProfile(Profile profile)
                   throws ProfileException
Modifies an existing Profile in this ProfileSet.

Parameters:
profile - The Profile to modify or add.
Throws:
ProfileException - On error.
See Also:
Profile

removeDefEntry

public void removeDefEntry(java.lang.String defEntryName)
                    throws ProfileException
Removes a Profile Definition Entry on this Profileset. This will also remove all of the Value names that referenced the removed definition in the Profiles.

Parameters:
defEntryName - The name of the Profile Definition Entry to remove.
Throws:
ProfileException - On error.

removeModel

public void removeModel(java.lang.String modelName)
Removes the specified Model from this ProfileSet. If the Model does not exist this will do nothing.

Parameters:
modelName - The unique ID of the Model to remove.

removeProfile

public void removeProfile(java.lang.String profileName)
                   throws ProfileException
Removes the specified Profile from this Profile Set. If the Profile deleted has children they will also be deleted. If using qualified profile names the name specified must be the full name of the Profile (e.g. "acme.hr.gold"). If not using qualified profile names the name specified must be the just the name of the profile itself (e.g. "gold").

Parameters:
profileName - The name of the Profile to be removed.
Throws:
ProfileException - On error.
See Also:
Profile

renameDefEntry

public void renameDefEntry(java.lang.String defEntryName,
                           java.lang.String newDefEntryName)
                    throws ProfileException
Rename a Profile Definition Entry on this Profileset. This will also rename all of the Value names that referenced the renamed definition in the Profiles.

Parameters:
defEntryName - The name of the existing Definition entry.
newDefEntryName - The new name of the Definition entry..
Throws:
ProfileException - On error.

renameParent

public void renameParent(java.lang.String profileName,
                         java.lang.String newParentName)
                  throws ProfileException
Changes the parent of the specified Profile. This will also fix up parent references if the new parent is a child of mine. If using qualified profile names the name specified must be the full name of the Profile (e.g. "acme.hr.gold"). If not using qualified profile names the name specified must be the just the name of the profile itself (e.g. "gold").

Parameters:
profileName - The name of the Profile for the parent to be change.
newParentName - The name of the new parent Profile.
Throws:
ProfileException - On error.

setFromIXml

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

Specified by:
setFromIXml in interface com.bowstreet.profiles.IXmlDataAccess
Overrides:
setFromIXml in class ProfileSetDescription
Parameters:
tdProfileSet - The IXml representation of a ProfileSet.
Throws:
ProfileException - On error.
See Also:
IXml

setModels

public void setModels(java.util.List models)
Sets a list of all of the Models for this ProfileSet.

Parameters:
models - A List of Strings that represent the Model unique ID's.

setProfileDef

public void setProfileDef(ProfileDef profileDef)
Sets the ProfileDef field of this Profile Set.

Parameters:
profileDef - The ProfileDef to set on this ProfileSet.
See Also:
ProfileDef

setProfileSelectionClass

public void setProfileSelectionClass(java.lang.String name)
Sets the name of the class or handler to be used to perform the Profile selection. Example: "Pet Center Segment Handler" or "com.bowstreet.profiles.MyProfileSelection"

Parameters:
name - The name of the handler or class.

setProfilesLastModified

public void setProfilesLastModified()
                             throws ProfileException
Sets all of the Profiles in this ProfileSet to the current time if they are currently not set. This is used when creating new Profiles Profiles.

Throws:
ProfileException - On error.

setValueClass

public void setValueClass(java.lang.String className)
Sets the name of the class to be used to create the values associated with a Profile. Example: "com.bowstreet.profiles.MyProfileValues"

Parameters:
className - The name of the class.

toString

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

Overrides:
toString in class ProfileSetDescription
Returns:
The String value for the entire ProfileCollection.

update

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

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

updateProfilesChanged

public void updateProfilesChanged(ProfileSet originalProfileSet)
Compares the individual Profiles of this ProfileSet to the specified original ProfileSet and sets the Profile hasChanged accordingly. It is the callers responsibility to save an original copy of the ProfileSet before modifications are made.

Parameters:
originalProfileSet - The original ProfileSet to compare against or null if there was no original.


Copyright © 2009 IBM. All Rights Reserved.