com.jalios.jstore
Class StoreCleaner

java.lang.Object
  extended by com.jalios.jstore.StoreCleaner

public class StoreCleaner
extends Object

Write clean line of Store.
- Use a file as a new Store (do not load it)
- Write Create Operation of Collection Storable or single Storable to the new Store
- Write Update Operation needed of Collection Storable or single Storable to the new Store
- Can Optimize Collection
- Can Override Id
- Can Override Stamp

Version:
$Revision: 27753 $
Author:
Jean-Philippe Encausse

Field Summary
protected  String convLang
           
protected  boolean doClean
           
protected  String mainLang
           
protected  boolean overrideId
           
static String REVISION
           
protected  Store store
           
protected  Set<Storable> toCreate
           
protected  Map<Storable,Storable> toUpdate
           
 
Constructor Summary
StoreCleaner(String file)
          Create a Store Cleaner that will not override IDs
StoreCleaner(String file, boolean overrideId)
          Create a Store Cleaner that may override IDs of objects
StoreCleaner(String file, boolean overrideId, boolean doClean)
          Create a Store Cleaner that may override IDs of objects
StoreCleaner(String file, Stamp stamp)
          Create a StoreCleaner with a starting specific stamp
StoreCleaner(String file, Stamp stamp, boolean overrideId)
          Create a Store Cleaner that may override IDs of objects and with starting Stamp
StoreCleaner(String file, Stamp stamp, boolean overrideId, boolean doClean)
          Create a Store Cleaner that may override IDs of objects and with starting Stamp
StoreCleaner(String file, Stamp stamp, boolean overrideId, boolean doClean, String mainLang, String convLang)
           
 
Method Summary
 void addClassTag(String tag, Class<?> clazz)
           
 boolean cleanUnknownLinks(Storable storable, Field field, Set<Storable> storableSet)
          Clean all unknown Storable from the given field of the given storable
 boolean cleanUnknownLinks(Storable storable, Map<Field,Set<Storable>> referencedLinkMap)
          Clean all unknown Storable from the given field map of the given storable
 void convertLang(Storable data)
           
 Set<Field> getFieldSet(Storable storable)
          Return all the fields of a given storable
 Map<Field,Set<Storable>> getReferencedLinkMap(Storable storable, Set<Field> fieldSet)
          Return all storable referenced by the given storable fields
 Set<Storable> getReferencedLinkSet(Storable storable, Field field)
          Return all storable referenced by the given storable field
 Set<Storable> getReferencedLinkSet(Storable storable, Set<Field> fieldSet)
          Return all storable referenced by the given storable fields
 List<Storable> sortCreate(Collection<Storable> toSortCollection)
          Sort a Collection by less update probability
protected  void sortCreate(Storable storable, Collection<Storable> toSortCollection, Collection<Storable> isVisitedCollection, List<Storable> sortedList)
          Recursive call to sort storables collection by less update probability.
 void updateStore()
          Write all updates
 void updateStore(Collection<Storable> collection)
          Write all updates for the given collection
 void updateStore(Collection<Storable> collection, Stamp stamp)
          Write all updates for the given collection
 void updateStore(Storable storable)
          Write an update of a given Storable already created
If the Storable need an Update then doUpdate and remove it from the Update Table
If the Storable doesn't need an update but exist in the Store (warning retrieve it by it's Id) then do an update.
 void updateStore(Storable storable, Stamp stamp)
          Write an update of a given Storable already created
If the Storable need an Update then doUpdate and remove it from the Update Table
If the Storable doesn't need an update but exist in the Store (warning retrieve it by it's Id) then do an update.
 void writeComment()
           
 void writeComment(String str)
          Write a comment in the Store.
 void writeStore(Collection<Storable> collection)
          Write create of a collection of Storable then prepare update
 void writeStore(Collection<Storable> collection, boolean sort)
          Write create of a collection of Storable then prepare update
 void writeStore(Collection<Storable> collection, boolean sort, boolean overrideId)
          Write create of a collection of Storable then prepare update
 void writeStore(Collection<Storable> collection, Stamp stamp)
          Write create of a collection of Storable then prepare update
 void writeStore(Collection<Storable> collection, Stamp stamp, boolean sort)
          Write create of a collection of Storable then prepare update
 void writeStore(Collection<Storable> collection, Stamp stamp, boolean sort, boolean overrideId)
          Write create of a collection of Storable then prepare update
 void writeStore(Storable storable)
          Write create of a Storable then prepare update
 void writeStore(Storable storable, boolean overrideId)
          Write create of a Storable then prepare update
 void writeStore(Storable storable, Stamp stamp)
          Write create of a Storable then prepare update
 void writeStore(Storable storable, Stamp stamp, boolean overrideId)
          Write create of a Storable then prepare update
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REVISION

public static final String REVISION
See Also:
Constant Field Values

store

protected Store store

toCreate

protected Set<Storable> toCreate

toUpdate

protected Map<Storable,Storable> toUpdate

overrideId

protected boolean overrideId

doClean

protected boolean doClean

mainLang

protected String mainLang

convLang

protected String convLang
Constructor Detail

StoreCleaner

public StoreCleaner(String file)
             throws IOException,
                    LogException
Create a Store Cleaner that will not override IDs

Parameters:
file -
Throws:
IOException
LogException

StoreCleaner

public StoreCleaner(String file,
                    boolean overrideId)
             throws IOException,
                    LogException
Create a Store Cleaner that may override IDs of objects

Parameters:
file -
overrideId -
Throws:
IOException
LogException

StoreCleaner

public StoreCleaner(String file,
                    boolean overrideId,
                    boolean doClean)
             throws IOException,
                    LogException
Create a Store Cleaner that may override IDs of objects

Parameters:
file -
overrideId -
doClean -
Throws:
IOException
LogException

StoreCleaner

public StoreCleaner(String file,
                    Stamp stamp)
             throws IOException,
                    LogException
Create a StoreCleaner with a starting specific stamp

Parameters:
file -
stamp -
Throws:
IOException
LogException

StoreCleaner

public StoreCleaner(String file,
                    Stamp stamp,
                    boolean overrideId)
             throws IOException,
                    LogException
Create a Store Cleaner that may override IDs of objects and with starting Stamp

Parameters:
file -
stamp -
overrideId -
Throws:
IOException
LogException

StoreCleaner

public StoreCleaner(String file,
                    Stamp stamp,
                    boolean overrideId,
                    boolean doClean)
             throws IOException,
                    LogException
Create a Store Cleaner that may override IDs of objects and with starting Stamp

Parameters:
file -
stamp -
overrideId -
doClean -
Throws:
IOException
LogException

StoreCleaner

public StoreCleaner(String file,
                    Stamp stamp,
                    boolean overrideId,
                    boolean doClean,
                    String mainLang,
                    String convLang)
             throws IOException,
                    LogException
Throws:
IOException
LogException
Method Detail

writeComment

public void writeComment()
                  throws IOException
Throws:
IOException

writeComment

public void writeComment(String str)
                  throws IOException
Write a comment in the Store.

Parameters:
str -
Throws:
IOException

writeStore

public void writeStore(Collection<Storable> collection)
                throws IOException
Write create of a collection of Storable then prepare update

Parameters:
collection -
Throws:
IOException
Since:
jcms-4.0

writeStore

public void writeStore(Collection<Storable> collection,
                       boolean sort)
                throws IOException
Write create of a collection of Storable then prepare update

Parameters:
collection -
sort -
Throws:
IOException
Since:
jcms-4.0

writeStore

public void writeStore(Collection<Storable> collection,
                       boolean sort,
                       boolean overrideId)
                throws IOException
Write create of a collection of Storable then prepare update

Parameters:
collection -
sort -
overrideId -
Throws:
IOException
Since:
jcms-4.0

writeStore

public void writeStore(Collection<Storable> collection,
                       Stamp stamp)
                throws IOException
Write create of a collection of Storable then prepare update

Parameters:
collection -
stamp -
Throws:
IOException
Since:
jcms-4.0

writeStore

public void writeStore(Collection<Storable> collection,
                       Stamp stamp,
                       boolean sort)
                throws IOException
Write create of a collection of Storable then prepare update

Parameters:
collection -
stamp -
sort -
Throws:
IOException
Since:
jcms-4.0

writeStore

public void writeStore(Collection<Storable> collection,
                       Stamp stamp,
                       boolean sort,
                       boolean overrideId)
                throws IOException
Write create of a collection of Storable then prepare update

Parameters:
collection -
stamp -
sort -
overrideId -
Throws:
IOException
Since:
jcms-4.0

writeStore

public void writeStore(Storable storable)
                throws IOException
Write create of a Storable then prepare update

Parameters:
storable -
Throws:
IOException
Since:
jcms-4.0

writeStore

public void writeStore(Storable storable,
                       boolean overrideId)
                throws IOException
Write create of a Storable then prepare update

Parameters:
storable -
overrideId -
Throws:
IOException
Since:
jcms-4.0

writeStore

public void writeStore(Storable storable,
                       Stamp stamp)
                throws IOException
Write create of a Storable then prepare update

Parameters:
storable -
stamp -
Throws:
IOException
Since:
jcms-4.0

writeStore

public void writeStore(Storable storable,
                       Stamp stamp,
                       boolean overrideId)
                throws IOException
Write create of a Storable then prepare update

Parameters:
storable -
stamp -
overrideId -
Throws:
IOException
Since:
jcms-4.0

updateStore

public void updateStore()
                 throws IOException
Write all updates

Throws:
IOException
Since:
jcms-4.0

updateStore

public void updateStore(Collection<Storable> collection)
                 throws IOException
Write all updates for the given collection

Parameters:
collection -
Throws:
IOException
Since:
jcms-4.0

updateStore

public void updateStore(Collection<Storable> collection,
                        Stamp stamp)
                 throws IOException
Write all updates for the given collection

Parameters:
collection -
stamp -
Throws:
IOException
Since:
jcms-4.0

updateStore

public void updateStore(Storable storable,
                        Stamp stamp)
                 throws IOException
Write an update of a given Storable already created
If the Storable need an Update then doUpdate and remove it from the Update Table
If the Storable doesn't need an update but exist in the Store (warning retrieve it by it's Id) then do an update. Write all updates for the given collection

Parameters:
storable -
stamp -
Throws:
IOException
Since:
jcms-4.0

updateStore

public void updateStore(Storable storable)
                 throws IOException
Write an update of a given Storable already created
If the Storable need an Update then doUpdate and remove it from the Update Table
If the Storable doesn't need an update but exist in the Store (warning retrieve it by it's Id) then do an update. Write all updates for the given collection

Parameters:
storable -
Throws:
IOException
Since:
jcms-4.0

addClassTag

public void addClassTag(String tag,
                        Class<?> clazz)

sortCreate

public List<Storable> sortCreate(Collection<Storable> toSortCollection)
Sort a Collection by less update probability

Parameters:
toSortCollection -
Returns:
a sorted collection
Since:
jcms-4.0

sortCreate

protected void sortCreate(Storable storable,
                          Collection<Storable> toSortCollection,
                          Collection<Storable> isVisitedCollection,
                          List<Storable> sortedList)
Recursive call to sort storables collection by less update probability.

Parameters:
storable -
toSortCollection -
isVisitedCollection -
sortedList -
Since:
jcms-4.0

cleanUnknownLinks

public boolean cleanUnknownLinks(Storable storable,
                                 Field field,
                                 Set<Storable> storableSet)
Clean all unknown Storable from the given field of the given storable

Returns:
true if a clean has be done
Since:
jcms-4.0

cleanUnknownLinks

public boolean cleanUnknownLinks(Storable storable,
                                 Map<Field,Set<Storable>> referencedLinkMap)
Clean all unknown Storable from the given field map of the given storable

Parameters:
storable -
referencedLinkMap -
Returns:
true if a clean has be done
Since:
jcms-4.0

getReferencedLinkMap

public Map<Field,Set<Storable>> getReferencedLinkMap(Storable storable,
                                                     Set<Field> fieldSet)
Return all storable referenced by the given storable fields

Parameters:
storable -
fieldSet -
Returns:
Map Fields / Set of Storable
Since:
jcms-4.0

getReferencedLinkSet

public Set<Storable> getReferencedLinkSet(Storable storable,
                                          Set<Field> fieldSet)
Return all storable referenced by the given storable fields

Parameters:
storable -
fieldSet -
Returns:
Set of Storable
Since:
jcms-4.0

getReferencedLinkSet

public Set<Storable> getReferencedLinkSet(Storable storable,
                                          Field field)
Return all storable referenced by the given storable field

Parameters:
storable -
field -
Returns:
Set of Storable
Since:
jcms-4.0

getFieldSet

public Set<Field> getFieldSet(Storable storable)
Return all the fields of a given storable

Returns:
Set of Field
Since:
jcms-4.0

convertLang

public void convertLang(Storable data)


Copyright © 2001-2010 Jalios SA. All Rights Reserved.