de.nava.informa.utils.manager.memory
Class PersistenceManager

java.lang.Object
  extended by de.nava.informa.utils.manager.memory.PersistenceManager
All Implemented Interfaces:
PersistenceManagerIF

public class PersistenceManager
extends Object
implements PersistenceManagerIF

In-memory implementation of persistence manager. Uses local memory to store data.

Author:
Aleksey Gureev (spyromus@noizeramp.com)

Constructor Summary
PersistenceManager()
          Creates persistence manager.
 
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.
(package private)  void moveChannels(ChannelGroupIF src, ChannelGroupIF dest)
          Moves channels from source to destination 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

PersistenceManager

public PersistenceManager()
Creates persistence manager.

Method Detail

createGroup

public final ChannelGroupIF createGroup(String title)
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.

updateGroup

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

Specified by:
updateGroup in interface PersistenceManagerIF
Parameters:
group - group object

deleteGroup

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

Specified by:
deleteGroup in interface PersistenceManagerIF
Parameters:
group - group to delete.

mergeGroups

public final void mergeGroups(ChannelGroupIF first,
                              ChannelGroupIF second)
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.

getGroups

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

Specified by:
getGroups in interface PersistenceManagerIF
Returns:
list of groups.

createChannel

public final ChannelIF createChannel(String title,
                                     URL location)
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.

updateChannel

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

Specified by:
updateChannel in interface PersistenceManagerIF
Parameters:
channel - channel object.

addChannelToGroup

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

Specified by:
addChannelToGroup in interface PersistenceManagerIF
Parameters:
channel - channel to add.
group - group to use.

removeChannelFromGroup

public final void removeChannelFromGroup(ChannelIF channel,
                                         ChannelGroupIF group)
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.

deleteChannel

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

Specified by:
deleteChannel in interface PersistenceManagerIF
Parameters:
channel - channel to delete.

createItem

public final ItemIF createItem(ChannelIF channel,
                               String title)
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.

createItem

public final ItemIF createItem(ChannelIF channel,
                               ItemIF ethalon)
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.

updateItem

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

Specified by:
updateItem in interface PersistenceManagerIF
Parameters:
item - item object.

deleteItem

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

Specified by:
deleteItem in interface PersistenceManagerIF
Parameters:
item - item to delete.

moveChannels

final void moveChannels(ChannelGroupIF src,
                        ChannelGroupIF dest)
Moves channels from source to destination group.

Parameters:
src - source group to take channels from.
dest - destination group to put channel into.


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