org.springframework.extensions.surf.site
Class Model

java.lang.Object
  extended by org.springframework.extensions.surf.site.Model

public class Model
extends Object

Default implementation of the model.

Author:
muzquiano

Constructor Summary
Model(ModelObjectManager manager)
          Instantiates a new default model.
 
Method Summary
protected static void addPropertyConstraint(Map propertyConstraintMap, String propertyName, Object propertyValue)
          Adds the property constraint.
 void associateContent(String sourceId, String sourceType, String destId, String assocType, String formatId)
          Associates content to a given presentation object.
 void associatePage(String sourceId, String destId)
          Associates a source Page instance to a destination Page instance.
 void associatePage(String sourceId, String destId, String associationType)
          Associates a source Page instance to a destination Page instance.
 void associateTemplate(String templateId, String pageId)
          Associates a Template to a Page given their respective ids.
 void associateTemplate(String templateId, String pageId, String formatId)
          Associates a Template to a Page given their respective ids.
 void bindComponent(Component component, String scope, String regionId, String sourceId)
          Binds a Component to a given scope, region id and source id.
 void bindComponent(String componentId, String scope, String regionId, String sourceId)
          Binds a Component to a given scope, region id and source id.
 ModelObject clone(String objectTypeId, String objectId)
          Clones a given model object
 ModelObject clone(String objectTypeId, String objectId, String newObjectId)
          Clones a given model object
 Map<String,ModelObject> findChrome()
          Returns a map of Chrome instances
 Map<String,ModelObject> findChrome(String chromeType)
          Returns a filtered map of Chrome instances.
 Map<String,ModelObject> findComponents()
          Returns a map of Component instances.
 Map<String,ModelObject> findComponents(String componentTypeId)
          Returns a filtered map of Component instances.
 Map<String,ModelObject> findComponents(String scope, String regionId, String sourceId, String componentTypeId)
          Returns a filtered map of Component instances.
 Map<String,ModelObject> findComponentTypes()
          Returns a map of Component Type instances.
 Map<String,ModelObject> findComponentTypes(String uri)
          Returns a fitlered map of Component Type instances.
 Map<String,ModelObject> findConfigurations()
          Returns a map of Configuration instances.
 Map<String,ModelObject> findConfigurations(String sourceId)
          Returns a filtered map of Configuration instances.
 Map<String,ModelObject> findContentAssociations()
          Returns a map of Content Association instances.
 Map<String,ModelObject> findContentAssociations(String sourceId, String sourceType, String destId, String assocType, String formatId)
          Returns a filtered map of Content Association instances.
 Map<String,ModelObject> findObjects(String objectTypeId)
          Returns a map of objects of the given type
protected  Map<String,ModelObject> findObjects(String objectTypeId, Map<String,Object> propertyConstraintMap)
          Filtering function that looks up objects of a given type id and then applies the provided property constraint map.
 Map<String,ModelObject> findPageAssociations()
          Returns a map of Page Association instances.
 Map<String,ModelObject> findPageAssociations(String sourceId, String destId, String associationType)
          Returns a filtered map of Page Association instances.
 Map<String,ModelObject> findPages()
          Returns a map of Page instances.
 Map<String,ModelObject> findPages(String templateId, String pageTypeId)
          Returns a filtered map of Page instances.
 Map<String,ModelObject> findPageTypes()
          Returns a map of Page Type instances.
 Map<String,ModelObject> findTemplates()
          Returns a map of Template instances.
 Map<String,ModelObject> findTemplates(String templateType)
          Returns a filtered map of Template instances.
 Map<String,ModelObject> findTemplateTypes()
          Returns a map of Template Type instances.
 Map<String,ModelObject> findTemplateTypes(String uri)
          Returns a filtered map of Template Type instances.
 Map<String,ModelObject> findThemes()
          Returns a map of Theme instances.
 Map<String,ModelObject> getAllObjects(String objectTypeId)
          Returns a map with all object instances of the given type.
 Map<String,ModelObject> getAllObjects(String objectTypeId, String objectIdPattern)
          Returns a map with all object instances of the given type filtered by the given object ID filter pattern.
 Chrome getChrome(String objectId)
          Gets the Chrome instance with the given id.
 Component getComponent(String objectId)
          Gets the component instance with the given id.
 Component getComponent(String scope, String regionId, String sourceId)
          Gets the component instance by its binding
 ComponentType getComponentType(String objectId)
          Gets the Component Type instance with the given id
 Configuration getConfiguration(String objectId)
          Gets the Configuration instance with the given id
 ContentAssociation getContentAssociation(String objectId)
          Gets the Content Association instance with the given id
 ModelObject getObject(String objectTypeId, String objectId)
          Gets an object instance of the given type and with the given id.
 ModelObjectManager getObjectManager()
          Gets the object manager.
 Page getPage(String objectId)
          Gets the Page instance with the given id
 PageAssociation getPageAssociation(String objectId)
          Gets the Page Association instance with the given id
 PageType getPageType(String objectId)
          Gets the Page Type instance with the given id.
 TemplateInstance getTemplate(String objectId)
          Gets the Template instance with the given id
 TemplateType getTemplateType(String objectId)
          Gets the Template Type instance with the given id.
 Theme getTheme(String objectId)
          Gets the Theme instance with the given id.
 Chrome newChrome()
          Creates a new Chrome instance.
 Chrome newChrome(String objectId)
          Creates a new Chrome instance with the given id.
 Component newComponent()
          Creates a new Component instance.
 Component newComponent(String objectId)
          Creates a new Component instance with the given id.
 Component newComponent(String scope, String regionId, String sourceId)
          Creates a new Component instance with the given binding properties.
 ComponentType newComponentType()
          Creates a new Component Type instance.
 ComponentType newComponentType(String objectId)
          Creates a new Component Type instance with the given id.
 Configuration newConfiguration()
          Creates a new Configuration instance.
 Configuration newConfiguration(String objectId)
          Creates a new Configuration instance with the given id.
 ContentAssociation newContentAssociation()
          Creates a new Content Association instance.
 ContentAssociation newContentAssociation(String objectId)
          Creates a new Content Association instance with the given id.
 ModelObject newObject(String objectTypeId)
          Creates a new object instance with the given object type id.
 ModelObject newObject(String objectTypeId, String objectId)
          Creates new object instance with teh given object type id and object id.
 Page newPage()
          Creates a new Page instance.
 Page newPage(String objectId)
          Creates a new Page instance with the given id.
 PageAssociation newPageAssociation()
          Creates a new Page Association instance.
 PageAssociation newPageAssociation(String objectId)
          Creates a new Page Association instance with the given id.
 PageType newPageType()
          Creates a new Page Type instance.
 PageType newPageType(String objectId)
          Creates a new Page Type instance with the given id.
protected  Map<String,Object> newPropertyConstraintMap()
          Creates a new property constraint map.
 TemplateInstance newTemplate()
          Creates a new Template instance.
 TemplateInstance newTemplate(String objectId)
          Creates a new Template instance with the given id.
 TemplateType newTemplateType()
          Creates a new Template Type instance.
 TemplateType newTemplateType(String objectId)
          Creates a new Template Type instance with the given id.
 Theme newTheme()
          Creates a new Theme instance.
 Theme newTheme(String objectId)
          Creates a new Theme instance with the given id.
 boolean removeObject(ModelObject object)
          Removes the given object.
 boolean removeObject(String objectTypeId, String objectId)
          Removes the object with the given object type and object id.
 boolean saveObject(ModelObject object)
          Saves the given object.
 void unassociateContent(String objectAssociationId)
          Unassociates content given a Content Association instance id.
 void unassociateContent(String sourceId, String sourceType, String destId, String assocType, String formatId)
          Unassociates content from a given presentation object.
 void unassociatePage(String pageAssociationId)
          Unassociates a page given its Page Association instance id.
 void unassociatePage(String sourceId, String destId)
          Unassociates a destination Page instance from a source Page instance.
 void unassociatePage(String sourceId, String destId, String associationTypeId)
          Unassociates a destination Page instance from a source Page instance.
 void unassociateTemplate(String pageId)
          Unassociates a Template from a Page.
 void unassociateTemplate(String pageId, String formatId)
          Unassociates a Template from a Page.
 void unbindComponent(String componentId)
          Removes a Component binding with the given Component id.
 void unbindComponent(String scope, String regionId, String sourceId)
          Removes a Component binding with the given binding properties.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Model

public Model(ModelObjectManager manager)
Instantiates a new default model.

Parameters:
manager - the ModelObjectManager
Method Detail

getObjectManager

public final ModelObjectManager getObjectManager()
Gets the object manager.

Returns:
the object responsible for managing persistence and caching of model objects

getChrome

public Chrome getChrome(String objectId)
Gets the Chrome instance with the given id.

Parameters:
objectId - the object id
Returns:
the chrome

getComponent

public Component getComponent(String objectId)
Gets the component instance with the given id.

Parameters:
objectId - the object id
Returns:
the component

getComponent

public Component getComponent(String scope,
                              String regionId,
                              String sourceId)
Gets the component instance by its binding

Parameters:
scope - the scope
regionId - the region id
sourceId - the source id
Returns:
the component

getComponentType

public ComponentType getComponentType(String objectId)
Gets the Component Type instance with the given id

Parameters:
objectId - the object id
Returns:
the component type

getConfiguration

public Configuration getConfiguration(String objectId)
Gets the Configuration instance with the given id

Parameters:
objectId - the object id
Returns:
the configuration

getContentAssociation

public ContentAssociation getContentAssociation(String objectId)
Gets the Content Association instance with the given id

Parameters:
objectId - the object id
Returns:
the content association

getPage

public Page getPage(String objectId)
Gets the Page instance with the given id

Parameters:
objectId - the object id
Returns:
the page

getPageType

public PageType getPageType(String objectId)
Gets the Page Type instance with the given id.

Parameters:
objectId - the object id
Returns:
the page type

getPageAssociation

public PageAssociation getPageAssociation(String objectId)
Gets the Page Association instance with the given id

Parameters:
objectId - the object id
Returns:
the page association

getTemplate

public TemplateInstance getTemplate(String objectId)
Gets the Template instance with the given id

Parameters:
objectId - the object id
Returns:
the template

getTemplateType

public TemplateType getTemplateType(String objectId)
Gets the Template Type instance with the given id.

Parameters:
objectId - the object id
Returns:
the template type

getTheme

public Theme getTheme(String objectId)
Gets the Theme instance with the given id.

Parameters:
objectId - the object id
Returns:
the theme

newChrome

public Chrome newChrome()
Creates a new Chrome instance.

Returns:
the chrome

newChrome

public Chrome newChrome(String objectId)
Creates a new Chrome instance with the given id.

Parameters:
objectId - the object id
Returns:
the chrome

newComponent

public Component newComponent()
Creates a new Component instance.

Returns:
the component

newComponent

public Component newComponent(String objectId)
Creates a new Component instance with the given id.

Parameters:
objectId - the object id
Returns:
the component

newComponent

public Component newComponent(String scope,
                              String regionId,
                              String sourceId)
Creates a new Component instance with the given binding properties.

Parameters:
scope - the scope
regionId - the region id
sourceId - the source id
Returns:
the object

newComponentType

public ComponentType newComponentType()
Creates a new Component Type instance.

Returns:
the component type

newComponentType

public ComponentType newComponentType(String objectId)
Creates a new Component Type instance with the given id.

Parameters:
objectId - the object id
Returns:
the component type

newConfiguration

public Configuration newConfiguration()
Creates a new Configuration instance.

Returns:
the configuration

newConfiguration

public Configuration newConfiguration(String objectId)
Creates a new Configuration instance with the given id.

Parameters:
objectId - the object id
Returns:
the configuration

newContentAssociation

public ContentAssociation newContentAssociation()
Creates a new Content Association instance.

Returns:
the content association

newContentAssociation

public ContentAssociation newContentAssociation(String objectId)
Creates a new Content Association instance with the given id.

Parameters:
objectId - the object id
Returns:
the content association

newPage

public Page newPage()
Creates a new Page instance.

Returns:
the page

newPage

public Page newPage(String objectId)
Creates a new Page instance with the given id.

Parameters:
objectId - the object id
Returns:
the page

newPageType

public PageType newPageType()
Creates a new Page Type instance.

Returns:
the page type

newPageType

public PageType newPageType(String objectId)
Creates a new Page Type instance with the given id.

Parameters:
objectId - the object id
Returns:
the page type

newPageAssociation

public PageAssociation newPageAssociation()
Creates a new Page Association instance.

Returns:
the page association

newPageAssociation

public PageAssociation newPageAssociation(String objectId)
Creates a new Page Association instance with the given id.

Parameters:
objectId - the object id
Returns:
the page association

newTemplate

public TemplateInstance newTemplate()
Creates a new Template instance.

Returns:
the template instance

newTemplate

public TemplateInstance newTemplate(String objectId)
Creates a new Template instance with the given id.

Parameters:
objectId - the object id
Returns:
the template instance

newTemplateType

public TemplateType newTemplateType()
Creates a new Template Type instance.

Returns:
the template type

newTemplateType

public TemplateType newTemplateType(String objectId)
Creates a new Template Type instance with the given id.

Parameters:
objectId - the object id
Returns:
the template type

newTheme

public Theme newTheme()
Creates a new Theme instance.

Returns:
the theme

newTheme

public Theme newTheme(String objectId)
Creates a new Theme instance with the given id.

Parameters:
objectId - the object id
Returns:
the theme

saveObject

public boolean saveObject(ModelObject object)
Saves the given object.

Parameters:
object - the object
Returns:
true, if successful

getObject

public ModelObject getObject(String objectTypeId,
                             String objectId)
Gets an object instance of the given type and with the given id.

Parameters:
objectTypeId - the object type id
objectId - the object id
Returns:
the object

removeObject

public boolean removeObject(ModelObject object)
Removes the given object.

Parameters:
object - the object
Returns:
true, if successful

removeObject

public boolean removeObject(String objectTypeId,
                            String objectId)
Removes the object with the given object type and object id.

Parameters:
objectTypeId - the object type id
objectId - the object id
Returns:
true, if successful

newObject

public ModelObject newObject(String objectTypeId)
Creates a new object instance with the given object type id.

Parameters:
objectTypeId - the object type id
Returns:
the model object

newObject

public ModelObject newObject(String objectTypeId,
                             String objectId)
Creates new object instance with teh given object type id and object id.

Parameters:
objectTypeId - the object type id
objectId - the object id
Returns:
the model object

getAllObjects

public Map<String,ModelObject> getAllObjects(String objectTypeId)
Returns a map with all object instances of the given type.

Parameters:
objectTypeId - the object type id
Returns:
the map

getAllObjects

public Map<String,ModelObject> getAllObjects(String objectTypeId,
                                             String objectIdPattern)
Returns a map with all object instances of the given type filtered by the given object ID filter pattern. This mechanism can be used for all model object types that persist themselves with a deterministically generated path from their respective object IDs, such as pages and components.

Object ID patterns support wildcard '*' only i.e. "page.*.dashboard"

Parameters:
objectTypeId - the object type id
filter - the object id filter pattern
Returns:
the map

findChrome

public Map<String,ModelObject> findChrome()
Returns a map of Chrome instances

Returns:
the map< string, model object>

findChrome

public Map<String,ModelObject> findChrome(String chromeType)
Returns a filtered map of Chrome instances.

Parameters:
chromeType - the chrome type
Returns:
the map< string, model object>

findConfigurations

public Map<String,ModelObject> findConfigurations()
Returns a map of Configuration instances.

Returns:
the map< string, model object>

findConfigurations

public Map<String,ModelObject> findConfigurations(String sourceId)
Returns a filtered map of Configuration instances.

Parameters:
sourceId - the source id
Returns:
the map< string, model object>

findPageAssociations

public Map<String,ModelObject> findPageAssociations()
Returns a map of Page Association instances.

Returns:
the map< string, model object>

findPageAssociations

public Map<String,ModelObject> findPageAssociations(String sourceId,
                                                    String destId,
                                                    String associationType)
Returns a filtered map of Page Association instances.

Parameters:
sourceId - the source id
destId - the dest id
associationType - the association type
Returns:
the map< string, model object>

findContentAssociations

public Map<String,ModelObject> findContentAssociations()
Returns a map of Content Association instances.

Returns:
the map< string, model object>

findContentAssociations

public Map<String,ModelObject> findContentAssociations(String sourceId,
                                                       String sourceType,
                                                       String destId,
                                                       String assocType,
                                                       String formatId)
Returns a filtered map of Content Association instances.

Parameters:
sourceId - the source id
sourceType - the source type
destId - the dest id
assocType - the assoc type
formatId - the format id
Returns:
the map< string, model object>

findComponents

public Map<String,ModelObject> findComponents()
Returns a map of Component instances.

Returns:
the map< string, model object>

findComponents

public Map<String,ModelObject> findComponents(String componentTypeId)
Returns a filtered map of Component instances.

Parameters:
componentTypeId - the component type id
Returns:
the map< string, model object>

findComponents

public Map<String,ModelObject> findComponents(String scope,
                                              String regionId,
                                              String sourceId,
                                              String componentTypeId)
Returns a filtered map of Component instances.

Parameters:
scope - the scope
regionId - the region id
sourceId - the source id
componentTypeId - the component type id
Returns:
the map< string, model object>

findTemplates

public Map<String,ModelObject> findTemplates()
Returns a map of Template instances.

Returns:
the map< string, model object>

findTemplates

public Map<String,ModelObject> findTemplates(String templateType)
Returns a filtered map of Template instances.

Parameters:
templateType - the template type
Returns:
the map< string, model object>

findTemplateTypes

public Map<String,ModelObject> findTemplateTypes()
Returns a map of Template Type instances.

Returns:
the map< string, model object>

findTemplateTypes

public Map<String,ModelObject> findTemplateTypes(String uri)
Returns a filtered map of Template Type instances.

Parameters:
uri - the uri
Returns:
the map< string, model object>

findComponentTypes

public Map<String,ModelObject> findComponentTypes()
Returns a map of Component Type instances.

Returns:
the map< string, model object>

findComponentTypes

public Map<String,ModelObject> findComponentTypes(String uri)
Returns a fitlered map of Component Type instances.

Parameters:
uri - the uri
Returns:
the map< string, model object>

findPages

public Map<String,ModelObject> findPages()
Returns a map of Page instances.

Returns:
the map< string, model object>

findPages

public Map<String,ModelObject> findPages(String templateId,
                                         String pageTypeId)
Returns a filtered map of Page instances.

Parameters:
templateId - the template id
pageTypeId - the page type id
Returns:
the map< string, model object>

findPageTypes

public Map<String,ModelObject> findPageTypes()
Returns a map of Page Type instances.

Returns:
the map< string, model object>

findThemes

public Map<String,ModelObject> findThemes()
Returns a map of Theme instances.

Returns:
the map< string, model object>

findObjects

public Map<String,ModelObject> findObjects(String objectTypeId)
Returns a map of objects of the given type

Parameters:
objectTypeId - the object type id
Returns:
A map of objects keyed by id

associatePage

public void associatePage(String sourceId,
                          String destId)
Associates a source Page instance to a destination Page instance. The type of the association is set to "child".

Parameters:
sourceId - the source id
destId - the dest id

associatePage

public void associatePage(String sourceId,
                          String destId,
                          String associationType)
Associates a source Page instance to a destination Page instance.

Parameters:
sourceId - the source id
destId - the dest id
associationType - the association type

unassociatePage

public void unassociatePage(String sourceId,
                            String destId)
Unassociates a destination Page instance from a source Page instance. The association type is assumed to be "child".

Parameters:
sourceId - the source id
destId - the dest id

unassociatePage

public void unassociatePage(String sourceId,
                            String destId,
                            String associationTypeId)
Unassociates a destination Page instance from a source Page instance.

Parameters:
sourceId - the source id
destId - the dest id
associationTypeId - the association type id

unassociatePage

public void unassociatePage(String pageAssociationId)
Unassociates a page given its Page Association instance id.

Parameters:
pageAssociationId - the page association id

associateContent

public void associateContent(String sourceId,
                             String sourceType,
                             String destId,
                             String assocType,
                             String formatId)
Associates content to a given presentation object. Normally, this is used to associate a content id to a template id.

Parameters:
sourceId - the source id
sourceType - the source type
destId - the dest id
assocType - the assoc type
formatId - the format id

unassociateContent

public void unassociateContent(String sourceId,
                               String sourceType,
                               String destId,
                               String assocType,
                               String formatId)
Unassociates content from a given presentation object.

Parameters:
sourceId - the source id
sourceType - the source type
destId - the dest id
assocType - the assoc type
formatId - the format id

unassociateContent

public void unassociateContent(String objectAssociationId)
Unassociates content given a Content Association instance id.

Parameters:
objectAssociationId - the object association id

associateTemplate

public void associateTemplate(String templateId,
                              String pageId)
Associates a Template to a Page given their respective ids. The format key is assumed to be the default format.

Parameters:
templateId - the template id
pageId - the page id

associateTemplate

public void associateTemplate(String templateId,
                              String pageId,
                              String formatId)
Associates a Template to a Page given their respective ids.

Parameters:
templateId - the template id
pageId - the page id
formatId - the format id

unassociateTemplate

public void unassociateTemplate(String pageId)
Unassociates a Template from a Page. The format key is assumed to be the default format.

Parameters:
pageId - the page id

unassociateTemplate

public void unassociateTemplate(String pageId,
                                String formatId)
Unassociates a Template from a Page.

Parameters:
pageId - the page id
formatId - the format id

bindComponent

public void bindComponent(String componentId,
                          String scope,
                          String regionId,
                          String sourceId)
Binds a Component to a given scope, region id and source id. If an existing Component has this binding, the existing Component is removed.

Parameters:
componentId - the component id
scope - the scope
regionId - the region id
sourceId - the source id

bindComponent

public void bindComponent(Component component,
                          String scope,
                          String regionId,
                          String sourceId)
Binds a Component to a given scope, region id and source id. If an existing Component has this binding, the existing Component is removed.

Parameters:
component - the component
scope - the scope
regionId - the region id
sourceId - the source id

unbindComponent

public void unbindComponent(String componentId)
Removes a Component binding with the given Component id.

Parameters:
componentId - the component id

unbindComponent

public void unbindComponent(String scope,
                            String regionId,
                            String sourceId)
Removes a Component binding with the given binding properties.

Parameters:
scope - the scope
regionId - the region id
sourceId - the source id

newPropertyConstraintMap

protected Map<String,Object> newPropertyConstraintMap()
Creates a new property constraint map. The map describes property constraints that should be applied when filtering the resultset.

Returns:
the map< string, object>

addPropertyConstraint

protected static void addPropertyConstraint(Map propertyConstraintMap,
                                            String propertyName,
                                            Object propertyValue)
Adds the property constraint.

Parameters:
propertyConstraintMap - the property constraint map
propertyName - the property name
propertyValue - the property value

findObjects

protected Map<String,ModelObject> findObjects(String objectTypeId,
                                              Map<String,Object> propertyConstraintMap)
Filtering function that looks up objects of a given type id and then applies the provided property constraint map.

Parameters:
propertyConstraintMap - the property constraint map
objectTypeId - the object type id
Returns:
the map of IDs to ModelObjects

clone

public ModelObject clone(String objectTypeId,
                         String objectId)
Clones a given model object

Parameters:
objectTypeId - the object type id
objectId - the object id
Returns:
the page

clone

public ModelObject clone(String objectTypeId,
                         String objectId,
                         String newObjectId)
Clones a given model object

Parameters:
objectTypeId - the object type id
objectId - the object id
newId - the id to set to the new object
Returns:
the page


Copyright © 2009 SpringSource, Inc. All Rights Reserved.