|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.uwyn.rife.database.querymanagers.generic.GenericQueryManagerDelegate<T>
com.uwyn.rife.cmf.dam.ContentQueryManager<T>
public class ContentQueryManager<T>
The ContentQueryManager simplifies working with content a lot.
It extends GenericQueryManager and is a drop-in replacement that can be used instead.
The ContentQueryManager class works hand-in-hand with
CMF-related constraints that are provided via the classes Validation and ConstrainedProperty. The additional constraints
allow you to provide CMF-related metadata for bean properties while still
having access to all regular constraints.
The most important additional constraint is 'mimeType'. Setting this
constraint directs RIFE to delegate the handling of that property's data to
the CMF instead of storing it as a regular column in a database table. The
property content location (i.e. its full path) is generated automatically
based on the bean class name, the instance's identifier value (i.e. the
primary key used by GenericQueryManager), and the property
name. So for example, if you have an instance of the NewsItem
class whose identifier is 23, then the full path that is
generated for a property named text is '/newsitem/23/text'.
Note that this always specifies the most recent version of the property,
but that older versions are also available from the content store.
Before being able to use the CMF and a ContentQueryManager,
you must install both of them, as in this example:
Datasource ds = Datasources.getRepInstance().getDatasource("datasource");
DatabaseContentFactory.getInstance(ds).install();
new ContentQueryManager(ds, NewsItem.class).install();
Apart from the handling of content, this query manager also integrates
the functionalities of the OrdinalManager class.
The new 'ordinal'
constraint indicates which bean property will be used to order that table
rows. When saving and deleting beans, the ordinal values will be
automatically updated in the entire table. The
ContentQueryManager also provides the move, up and down
methods to easily manipulate the order of existing rows.
| Constructor Summary | |
|---|---|
ContentQueryManager(Datasource datasource,
Class<T> klass)
Creates a new ContentQueryManager instance for a specific
class. |
|
ContentQueryManager(Datasource datasource,
Class<T> klass,
Class backendClass)
Creates a new ContentQueryManager instance for a specific
class. |
|
ContentQueryManager(Datasource datasource,
Class<T> klass,
ContentManager contentManager)
Creates a new ContentQueryManager instance for a specific
class. |
|
ContentQueryManager(Datasource datasource,
Class<T> klass,
String table)
Creates a new ContentQueryManager instance for a specific
class, but with a different table name for the database storage. |
|
| Method Summary | ||
|---|---|---|
String |
buildCmfPath(int objectId,
String propertyName)
Builds the path that is used by the ContentQueryManager
for a certain bean ID and property. |
|
String |
buildCmfPath(T bean,
String propertyName)
Builds the path that is used by the ContentQueryManager
for a certain bean and property. |
|
String |
buildServeContentPath(int objectId,
String propertyName)
Builds the path that is used by the ServeContent element
for a certain bean ID and property. |
|
String |
buildServeContentPath(T bean,
String propertyName)
Builds the path that is used by the ServeContent element
for a certain bean and property. |
|
Object |
clone()
Simply clones the instance with the default clone method. |
|
|
createNewManager(Class<OtherBeanType> type)
Create a new generic query manager of the same kind but for another bean class. |
|
boolean |
delete(int objectId)
Deletes a bean according to its ID. |
|
boolean |
down(Constrained bean,
String propertyName)
Moves the row that corresponds to the provided bean instance downwards according to a property with an ordinal constraint. |
|
String |
getContentForHtml(int objectId,
String propertyName,
Element element,
String serveContentExitName)
Retrieves a content data representation for use in html. |
|
String |
getContentForHtml(T bean,
String propertyName,
Element element,
String serveContentExitName)
Retrieves a content data representation for use in html. |
|
ContentManager |
getContentManager()
Returns the ContentManager that is used to store and
retrieve the content. |
|
String |
getRepository()
Retrieves the default repository that is used by this ContentQueryManager. |
|
boolean |
hasContent(int objectId,
String propertyName)
Checks if there's content available for a certain property of a bean. |
|
boolean |
hasContent(T bean,
String propertyName)
Checks if there's content available for a certain property of a bean. |
|
boolean |
move(Constrained bean,
String propertyName,
OrdinalManager.Direction direction)
Moves the row that corresponds to the provided bean instance according to a property with an ordinal constraint. |
|
ContentQueryManager<T> |
repository(String repository)
Sets the default repository that will be used by this ContentQueryManager. |
|
List<T> |
restore()
Restores all beans. |
|
T |
restore(int objectId)
Restores a bean according to its ID. |
|
List<T> |
restore(RestoreQuery query)
Restores all beans from a RestoreQuery. |
|
T |
restoreFirst(RestoreQuery query)
Restores the first bean from a RestoreQuery. |
|
int |
save(T bean)
Saves a bean. |
|
boolean |
storeEmptyContent(T bean,
String propertyName)
Empties the content of a certain bean property. |
|
boolean |
up(Constrained bean,
String propertyName)
Moves the row that corresponds to the provided bean instance upwards according to a property with an ordinal constraint. |
|
| Methods inherited from class com.uwyn.rife.database.querymanagers.generic.GenericQueryManagerDelegate |
|---|
addListener, count, count, delete, getBaseClass, getCountQuery, getDatasource, getDelegate, getDeleteQuery, getDeleteQuery, getIdentifierName, getIdentifierValue, getInstallTableQuery, getRestoreQuery, getRestoreQuery, getTable, insert, install, install, remove, removeListeners, restore, restore, update, validate |
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ContentQueryManager(Datasource datasource,
Class<T> klass,
Class backendClass)
ContentQueryManager instance for a specific
class.
All content will be stored in a DatabaseContent.
datasource - the datasource that indicates where the data will be
storedklass - the class of the bean that will be handled by this
ContentQueryManagerbackendClass - the class the will be used by this
ContentQueryManager to reference data in the backend
public ContentQueryManager(Datasource datasource,
Class<T> klass,
String table)
ContentQueryManager instance for a specific
class, but with a different table name for the database storage.
All content will be stored in a DatabaseContent.
datasource - the datasource that indicates where the data will be
storedklass - the class of the bean that will be handled by this
ContentQueryManagertable - the name of the database table in which the non CMF data will
be stored
public ContentQueryManager(Datasource datasource,
Class<T> klass)
ContentQueryManager instance for a specific
class.
All content will be stored in a DatabaseContent.
datasource - the datasource that indicates where the data will be
storedklass - the class of the bean that will be handled by this
ContentQueryManager
public ContentQueryManager(Datasource datasource,
Class<T> klass,
ContentManager contentManager)
ContentQueryManager instance for a specific
class.
All content will be stored in the provided
ContentManager instance. This constructor is handy if you
want to integrate a custom content manager implementation.
datasource - the datasource that indicates where the data will be
storedklass - the class of the bean that will be handled by this
ContentQueryManagercontentManager - a ContentManager instance| Method Detail |
|---|
public ContentQueryManager<T> repository(String repository)
ContentQueryManager.
ContentQueryManagergetRepository()public String getRepository()
ContentQueryManager.
ContentQueryManager's repositoryrepository(java.lang.String)public ContentManager getContentManager()
ContentManager that is used to store and
retrieve the content.
ContentManager
public boolean move(Constrained bean,
String propertyName,
OrdinalManager.Direction direction)
bean - the bean instance that corresponds to the row that has to
be movedpropertyName - the name of the property with an ordinal constraintdirection - OrdinalManager.UP or OrdinalManager.DOWN
true if the row was moved successfully; or
false otherwise
public boolean up(Constrained bean,
String propertyName)
bean - the bean instance that corresponds to the row that has to
be movedpropertyName - the name of the property with an ordinal constraint
true if the row was moved successfully; or
false otherwise
public boolean down(Constrained bean,
String propertyName)
bean - the bean instance that corresponds to the row that has to
be movedpropertyName - the name of the property with an ordinal constraint
true if the row was moved successfully; or
false otherwise
public boolean storeEmptyContent(T bean,
String propertyName)
When a bean is saved, null content properties are
simply ignored when the property hasn't got an autoRetrieved
constraint. This is needed to make it possible to only update a
bean's data without having to fetch the content from the back-end and
store it together with the other data just to make a simple update.
However, this makes it impossible to rely on null to
indicate empty content. This method has thus been added explicitly for
this purpose.
bean - the bean instance that contains the propertypropertyName - the name of the property whose content has to be
emptied in the database
true if the empty content was stored successfully;
or
false otherwise
public int save(T bean)
throws DatabaseException
This augments the regular GenericQueryManager's
save method with behaviour that correctly handles content
or ordinal properties.
When a bean is saved, null content properties are simply
ignored when the property hasn't got an autoRetrieved
constraint. This is needed to make it possible to only update a bean's
data without having to fetch the content from the back-end and store it
together with the other data just to make a simple update.
save in interface GenericQueryManager<T>save in class GenericQueryManagerDelegate<T>bean - the bean instance that has to be saved
true if the bean was stored successfully; or
false otherwise
DatabaseException
public T restore(int objectId)
throws DatabaseException
This augments the regular GenericQueryManager's
restore method with behaviour that correctly handles
content properties.
restore in interface GenericQueryManager<T>restore in class GenericQueryManagerDelegate<T>objectId - the ID of the bean that has to be restored
null if it couldn't be found
DatabaseException
public T restoreFirst(RestoreQuery query)
throws DatabaseException
RestoreQuery.
This augments the regular GenericQueryManager's
restore method with behaviour that correctly handles
content properties.
restoreFirst in interface GenericQueryManager<T>restoreFirst in class GenericQueryManagerDelegate<T>query - the query that will be used to restore the beans
null if no beans could be found
DatabaseExceptionGenericQueryManager.restore(RestoreQuery)
public List<T> restore()
throws DatabaseException
This augments the regular GenericQueryManager's
restore method with behaviour that correctly handles
content properties.
restore in interface GenericQueryManager<T>restore in class GenericQueryManagerDelegate<T>null if no beans could be found
DatabaseException
public List<T> restore(RestoreQuery query)
throws DatabaseException
RestoreQuery.
This augments the regular GenericQueryManager's
restore method with behaviour that correctly handles
content properties.
restore in interface GenericQueryManager<T>restore in class GenericQueryManagerDelegate<T>query - the query that will be used to restore the beans
null if no beans could be found
DatabaseExceptionGenericQueryManager.restore()
public boolean delete(int objectId)
throws DatabaseException
This augments the regular GenericQueryManager's
restore method with behaviour that correctly handles
content and ordinal properties.
delete in interface GenericQueryManager<T>delete in class GenericQueryManagerDelegate<T>objectId - the ID of the bean that has to be restored
true if the bean was deleted successfully; or
false if it couldn't be found
DatabaseException
public boolean hasContent(T bean,
String propertyName)
throws DatabaseException
bean - the bean instance that will be checkedpropertyName - the name of the property whose content availability
will be checked
true if content is available; or
false otherwise
DatabaseException
public boolean hasContent(int objectId,
String propertyName)
throws DatabaseException
objectId - the ID of the bean instance that will be checkedpropertyName - the name of the property whose content availability
will be checked
true if content is available; or
false otherwise
DatabaseException
public String buildCmfPath(T bean,
String propertyName)
ContentQueryManager
for a certain bean and property.
bean - the bean instance that will be used to construct the pathpropertyName - the name of the property that will be used to
construct the path
public String buildCmfPath(int objectId,
String propertyName)
ContentQueryManager
for a certain bean ID and property.
objectId - the bean ID that will be used to construct the pathpropertyName - the name of the property that will be used to
construct the path
public String buildServeContentPath(T bean,
String propertyName)
ServeContent element
for a certain bean and property.
Any declaration of the repository name will be ignore, since the
ServeContent element doesn't allow you to provide this
through the URL for safety reasons.
bean - the bean instance that will be used to construct the pathpropertyName - the name of the property that will be used to
construct the path
public String buildServeContentPath(int objectId,
String propertyName)
ServeContent element
for a certain bean ID and property.
Any declaration of the repository name will be ignore, since the
ServeContent element doesn't allow you to provide this
through the URL for safety reasons.
objectId - the bean ID that will be used to construct the pathpropertyName - the name of the property that will be used to
construct the path
public String getContentForHtml(T bean,
String propertyName,
Element element,
String serveContentExitName)
throws ContentManagerException
This is mainly used to integrate content data inside a html document. For instance, html content will be displayed as-is, while image content will cause an image tag to be generated with the correct source URL to serve the image.
bean - the bean instance that contains the datapropertyName - the name of the property whose html representation
will be providedelement - an active element instanceserveContentExitName - the exit name that leads to a ServeContent element. This will
be used to generate URLs for content that can't be directly displayed
in-line.
ContentManagerException - if an unexpected error occurred
public String getContentForHtml(int objectId,
String propertyName,
Element element,
String serveContentExitName)
throws ContentManagerException
This is mainly used to integrate content data inside a html document. For instance, html content will be displayed as-is, while image content will cause an image tag to be generated with the correct source URL to serve the image.
objectId - the ID of the bean that contains the datapropertyName - the name of the property whose html representation
will be providedelement - an active element instanceserveContentExitName - the exit name that leads to a ServeContent element. This will
be used to generate URLs for content that can't be directly displayed
in-line.
ContentManagerException - if an unexpected error occurredpublic Object clone()
clone in class Objectpublic <OtherBeanType> GenericQueryManager<OtherBeanType> createNewManager(Class<OtherBeanType> type)
GenericQueryManager
createNewManager in interface GenericQueryManager<T>createNewManager in class GenericQueryManagerDelegate<T>type - the class of the bean for which the new generic query
manager has to be created
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||