de.nava.informa.utils.manager.hibernate
Class NonCachingPersistenceManager

java.lang.Object
  extended by de.nava.informa.utils.manager.hibernate.NonCachingPersistenceManager
All Implemented Interfaces:
PersistenceManagerIF
Direct Known Subclasses:
PersistenceManager

 class NonCachingPersistenceManager
extends Object
implements PersistenceManagerIF

Implementation of persistence manager interface, talking with Hibernate. This implementation is not 100% usable becase it isn't confirming to the rule of using the same instances. This means that each time it looks for object (for example, using method getGroups()) it returns new instances of group objects (group1 != group2, but group1.getId() == group2.getId()). Persistence Manager implementation should operate with the same instances all the way and it's carefully checked by acceptance test.

There's another implementation wrapping this one -- PersistenceManager. It conforms to the rule.

Author:
Aleksey Gureev (spyromus@noizeramp.com)
See Also:
PersistenceManager

Constructor Summary
NonCachingPersistenceManager()
           
 
Method Summary
 void addChannelToGroup(ChannelIF channel, ChannelGroupIF group)
          Adds channel to the group.
 ChannelIF createChannel(String title, URL location)
          Creates new channel object and persists it into storage.
 ChannelGroupIF createGroup(String title)
          Creates new group of channels in persistent storage.
 ItemIF createItem(ChannelIF channel, ItemIF ethalon)
          Creates new item using specified object as ethalon.
 ItemIF createItem(ChannelIF channel, String title)
          Creates new item in the channel.
 void deleteChannel(ChannelIF channel)
          Deletes channel from persistent storage.
 void deleteGroup(ChannelGroupIF group)
          Deletes group from persistent storage.
 void deleteItem(ItemIF item)
          Deletes the item from the persistent storage.
 ChannelGroupIF[] getGroups()
          Returns the list of groups available in database.
 void mergeGroups(ChannelGroupIF first, ChannelGroupIF second)
          Takes channels from the second group and put them all in first group.
 void removeChannelFromGroup(ChannelIF channel, ChannelGroupIF group)
          Deletes channel from the group.
 void updateChannel(ChannelIF channel)
          Updates data in database with data from channel object.
 void updateGroup(ChannelGroupIF group)
          Updates data in storage with data from the group object.
 void updateItem(ItemIF item)
          Updates data in database with data from item object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NonCachingPersistenceManager

NonCachingPersistenceManager()
Method Detail

createGroup

public ChannelGroupIF createGroup(String title)
                           throws PersistenceManagerException
Creates new group of channels in persistent storage.

Specified by:
createGroup in interface PersistenceManagerIF
Parameters:
title - title of the group.
Returns:
initialized and persisted group object.
Throws:
PersistenceManagerException - in case of any problems.

updateGroup

public void updateGroup(ChannelGroupIF group)
                 throws PersistenceManagerException
Updates data in storage with data from the group object.

Specified by:
updateGroup in interface PersistenceManagerIF
Parameters:
group - group object
Throws:
PersistenceManagerException - in case of any problems.

deleteGroup

public void deleteGroup(ChannelGroupIF group)
                 throws PersistenceManagerException
Deletes group from persistent storage.

Specified by:
deleteGroup in interface PersistenceManagerIF
Parameters:
group - group to delete.
Throws:
PersistenceManagerException - in case of any problems.

mergeGroups

public void mergeGroups(ChannelGroupIF first,
                        ChannelGroupIF second)
                 throws PersistenceManagerException
Takes channels from the second group and put them all in first group. Then second group is deleted.

Specified by:
mergeGroups in interface PersistenceManagerIF
Parameters:
first - first group of channels.
second - second group of channels.
Throws:
PersistenceManagerException - in case of any problems.

getGroups

public ChannelGroupIF[] getGroups()
                           throws PersistenceManagerException
Returns the list of groups available in database.

Specified by:
getGroups in interface PersistenceManagerIF
Returns:
list of groups.
Throws:
PersistenceManagerException - in case of any problems.

createChannel

public ChannelIF createChannel(String title,
                               URL location)
                        throws PersistenceManagerException
Creates new channel object and persists it into storage.

Specified by:
createChannel in interface PersistenceManagerIF
Parameters:
title - title of the channel.
location - location of channel data resource.
Returns:
newly created object.
Throws:
PersistenceManagerException - in case of any problems.

updateChannel

public void updateChannel(ChannelIF channel)
                   throws PersistenceManagerException
Updates data in database with data from channel object.

Specified by:
updateChannel in interface PersistenceManagerIF
Parameters:
channel - channel object.
Throws:
PersistenceManagerException - in case of any problems.

addChannelToGroup

public void addChannelToGroup(ChannelIF channel,
                              ChannelGroupIF group)
                       throws PersistenceManagerException
Adds channel to the group.

Specified by:
addChannelToGroup in interface PersistenceManagerIF
Parameters:
channel - channel to add.
group - group to use.
Throws:
PersistenceManagerException - in case of any problems.

removeChannelFromGroup

public void removeChannelFromGroup(ChannelIF channel,
                                   ChannelGroupIF group)
                            throws PersistenceManagerException
Deletes channel from the group. This method doesn't delete channel from persistent storage. It only breaks the association between channel and group.

Specified by:
removeChannelFromGroup in interface PersistenceManagerIF
Parameters:
channel - channel to delete.
group - group to use.
Throws:
PersistenceManagerException - in case of any problems.

deleteChannel

public void deleteChannel(ChannelIF channel)
                   throws PersistenceManagerException
Deletes channel from persistent storage.

Specified by:
deleteChannel in interface PersistenceManagerIF
Parameters:
channel - channel to delete.
Throws:
PersistenceManagerException - in case of any problems.

createItem

public ItemIF createItem(ChannelIF channel,
                         String title)
                  throws PersistenceManagerException
Creates new item in the channel.

Specified by:
createItem in interface PersistenceManagerIF
Parameters:
channel - channel to put new item into.
title - title of new item.
Returns:
new item object.
Throws:
PersistenceManagerException - in case of any problems.

createItem

public ItemIF createItem(ChannelIF channel,
                         ItemIF ethalon)
                  throws PersistenceManagerException
Creates new item using specified object as ethalon. Note that application could already add object to the channel and only persistent modifications required.

Specified by:
createItem in interface PersistenceManagerIF
Parameters:
channel - channel to put new item into.
ethalon - object to copy properties values from.
Returns:
new item object.
Throws:
PersistenceManagerException - in case of any problems.

updateItem

public void updateItem(ItemIF item)
                throws PersistenceManagerException
Updates data in database with data from item object.

Specified by:
updateItem in interface PersistenceManagerIF
Parameters:
item - item object.
Throws:
PersistenceManagerException - in case of any errors.

deleteItem

public void deleteItem(ItemIF item)
                throws PersistenceManagerException
Deletes the item from the persistent storage.

Specified by:
deleteItem in interface PersistenceManagerIF
Parameters:
item - item to delete.
Throws:
PersistenceManagerException - in case of any problems.


Copyright © 2002-2007 Niko Schmuck. All Rights Reserved.