Package com.jalios.jstore
Class StoreCleaner
- java.lang.Object
-
- com.jalios.jstore.StoreCleaner
-
public class StoreCleaner extends java.lang.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- Author:
- Jean-Philippe Encausse
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.String
convLang
protected boolean
doClean
protected java.lang.String
mainLang
protected boolean
overrideId
protected Store
store
protected java.util.Set<Storable>
toCreate
protected java.util.Map<Storable,Storable>
toUpdate
-
Constructor Summary
Constructors Constructor Description StoreCleaner(java.lang.String file)
Create a Store Cleaner that will not override IDsStoreCleaner(java.lang.String file, boolean overrideId)
Create a Store Cleaner that may override IDs of objectsStoreCleaner(java.lang.String file, boolean overrideId, boolean doClean)
Create a Store Cleaner that may override IDs of objectsStoreCleaner(java.lang.String file, Stamp stamp)
Create a StoreCleaner with a starting specific stampStoreCleaner(java.lang.String file, Stamp stamp, boolean overrideId)
Create a Store Cleaner that may override IDs of objects and with starting StampStoreCleaner(java.lang.String file, Stamp stamp, boolean overrideId, boolean doClean)
Create a Store Cleaner that may override IDs of objects and with starting StampStoreCleaner(java.lang.String file, Stamp stamp, boolean overrideId, boolean doClean, java.lang.String mainLang, java.lang.String convLang)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addClassTag(java.lang.String tag, java.lang.Class<?> clazz)
boolean
cleanUnknownLinks(Storable storable, java.lang.reflect.Field field, java.util.Set<Storable> storableSet)
Clean all unknown Storable from the given field of the given storableboolean
cleanUnknownLinks(Storable storable, java.util.Map<java.lang.reflect.Field,java.util.Set<Storable>> referencedLinkMap)
Clean all unknown Storable from the given field map of the given storablevoid
convertLang(Storable data)
java.util.Set<java.lang.reflect.Field>
getFieldSet(Storable storable)
Return all the fields of a given storablejava.util.Map<java.lang.reflect.Field,java.util.Set<Storable>>
getReferencedLinkMap(Storable storable, java.util.Set<java.lang.reflect.Field> fieldSet)
Return all storable referenced by the given storable fieldsjava.util.Set<Storable>
getReferencedLinkSet(Storable storable, java.lang.reflect.Field field)
Return all storable referenced by the given storable fieldjava.util.Set<Storable>
getReferencedLinkSet(Storable storable, java.util.Set<java.lang.reflect.Field> fieldSet)
Return all storable referenced by the given storable fieldsprotected void
sortCreate(Storable storable, java.util.Collection<Storable> toSortCollection, java.util.Collection<Storable> isVisitedCollection, java.util.List<Storable> sortedList)
Recursive call to sort storables collection by less update probability.java.util.List<Storable>
sortCreate(java.util.Collection<Storable> toSortCollection)
Sort a Collection by less update probabilityvoid
updateStore()
Write all updatesvoid
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
updateStore(java.util.Collection<Storable> collection)
Write all updates for the given collectionvoid
updateStore(java.util.Collection<Storable> collection, Stamp stamp)
Write all updates for the given collectionvoid
writeComment()
void
writeComment(java.lang.String str)
Write a comment in the Store.void
writeStore(Storable storable)
Write create of a Storable then prepare updatevoid
writeStore(Storable storable, boolean overrideId)
Write create of a Storable then prepare updatevoid
writeStore(Storable storable, Stamp stamp)
Write create of a Storable then prepare updatevoid
writeStore(Storable storable, Stamp stamp, boolean overrideId)
Write create of a Storable then prepare updatevoid
writeStore(java.util.Collection<Storable> collection)
Write create of a collection of Storable then prepare updatevoid
writeStore(java.util.Collection<Storable> collection, boolean sort)
Write create of a collection of Storable then prepare updatevoid
writeStore(java.util.Collection<Storable> collection, boolean sort, boolean overrideId)
Write create of a collection of Storable then prepare updatevoid
writeStore(java.util.Collection<Storable> collection, Stamp stamp)
Write create of a collection of Storable then prepare updatevoid
writeStore(java.util.Collection<Storable> collection, Stamp stamp, boolean sort)
Write create of a collection of Storable then prepare updatevoid
writeStore(java.util.Collection<Storable> collection, Stamp stamp, boolean sort, boolean overrideId)
Write create of a collection of Storable then prepare update
-
-
-
Constructor Detail
-
StoreCleaner
public StoreCleaner(java.lang.String file) throws java.io.IOException, LogException
Create a Store Cleaner that will not override IDs- Parameters:
file
-- Throws:
java.io.IOException
LogException
-
StoreCleaner
public StoreCleaner(java.lang.String file, boolean overrideId) throws java.io.IOException, LogException
Create a Store Cleaner that may override IDs of objects- Parameters:
file
-overrideId
-- Throws:
java.io.IOException
LogException
-
StoreCleaner
public StoreCleaner(java.lang.String file, boolean overrideId, boolean doClean) throws java.io.IOException, LogException
Create a Store Cleaner that may override IDs of objects- Parameters:
file
-overrideId
-doClean
-- Throws:
java.io.IOException
LogException
-
StoreCleaner
public StoreCleaner(java.lang.String file, Stamp stamp) throws java.io.IOException, LogException
Create a StoreCleaner with a starting specific stamp- Parameters:
file
-stamp
-- Throws:
java.io.IOException
LogException
-
StoreCleaner
public StoreCleaner(java.lang.String file, Stamp stamp, boolean overrideId) throws java.io.IOException, LogException
Create a Store Cleaner that may override IDs of objects and with starting Stamp- Parameters:
file
-stamp
-overrideId
-- Throws:
java.io.IOException
LogException
-
StoreCleaner
public StoreCleaner(java.lang.String file, Stamp stamp, boolean overrideId, boolean doClean) throws java.io.IOException, LogException
Create a Store Cleaner that may override IDs of objects and with starting Stamp- Parameters:
file
-stamp
-overrideId
-doClean
-- Throws:
java.io.IOException
LogException
-
StoreCleaner
public StoreCleaner(java.lang.String file, Stamp stamp, boolean overrideId, boolean doClean, java.lang.String mainLang, java.lang.String convLang) throws java.io.IOException, LogException
- Throws:
java.io.IOException
LogException
-
-
Method Detail
-
writeComment
public void writeComment() throws java.io.IOException
- Throws:
java.io.IOException
-
writeComment
public void writeComment(java.lang.String str) throws java.io.IOException
Write a comment in the Store.- Parameters:
str
-- Throws:
java.io.IOException
-
writeStore
public void writeStore(java.util.Collection<Storable> collection) throws java.io.IOException
Write create of a collection of Storable then prepare update- Parameters:
collection
-- Throws:
java.io.IOException
- Since:
- jcms-4.0
-
writeStore
public void writeStore(java.util.Collection<Storable> collection, boolean sort) throws java.io.IOException
Write create of a collection of Storable then prepare update- Parameters:
collection
-sort
-- Throws:
java.io.IOException
- Since:
- jcms-4.0
-
writeStore
public void writeStore(java.util.Collection<Storable> collection, boolean sort, boolean overrideId) throws java.io.IOException
Write create of a collection of Storable then prepare update- Parameters:
collection
-sort
-overrideId
-- Throws:
java.io.IOException
- Since:
- jcms-4.0
-
writeStore
public void writeStore(java.util.Collection<Storable> collection, Stamp stamp) throws java.io.IOException
Write create of a collection of Storable then prepare update- Parameters:
collection
-stamp
-- Throws:
java.io.IOException
- Since:
- jcms-4.0
-
writeStore
public void writeStore(java.util.Collection<Storable> collection, Stamp stamp, boolean sort) throws java.io.IOException
Write create of a collection of Storable then prepare update- Parameters:
collection
-stamp
-sort
-- Throws:
java.io.IOException
- Since:
- jcms-4.0
-
writeStore
public void writeStore(java.util.Collection<Storable> collection, Stamp stamp, boolean sort, boolean overrideId) throws java.io.IOException
Write create of a collection of Storable then prepare update- Parameters:
collection
-stamp
-sort
-overrideId
-- Throws:
java.io.IOException
- Since:
- jcms-4.0
-
writeStore
public void writeStore(Storable storable) throws java.io.IOException
Write create of a Storable then prepare update- Parameters:
storable
-- Throws:
java.io.IOException
- Since:
- jcms-4.0
-
writeStore
public void writeStore(Storable storable, boolean overrideId) throws java.io.IOException
Write create of a Storable then prepare update- Parameters:
storable
-overrideId
-- Throws:
java.io.IOException
- Since:
- jcms-4.0
-
writeStore
public void writeStore(Storable storable, Stamp stamp) throws java.io.IOException
Write create of a Storable then prepare update- Parameters:
storable
-stamp
-- Throws:
java.io.IOException
- Since:
- jcms-4.0
-
writeStore
public void writeStore(Storable storable, Stamp stamp, boolean overrideId) throws java.io.IOException
Write create of a Storable then prepare update- Parameters:
storable
-stamp
-overrideId
-- Throws:
java.io.IOException
- Since:
- jcms-4.0
-
updateStore
public void updateStore() throws java.io.IOException
Write all updates- Throws:
java.io.IOException
- Since:
- jcms-4.0
-
updateStore
public void updateStore(java.util.Collection<Storable> collection) throws java.io.IOException
Write all updates for the given collection- Parameters:
collection
-- Throws:
java.io.IOException
- Since:
- jcms-4.0
-
updateStore
public void updateStore(java.util.Collection<Storable> collection, Stamp stamp) throws java.io.IOException
Write all updates for the given collection- Parameters:
collection
-stamp
-- Throws:
java.io.IOException
- Since:
- jcms-4.0
-
updateStore
public void updateStore(Storable storable, Stamp stamp) throws java.io.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:
java.io.IOException
- Since:
- jcms-4.0
-
updateStore
public void updateStore(Storable storable) throws java.io.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:
java.io.IOException
- Since:
- jcms-4.0
-
addClassTag
public void addClassTag(java.lang.String tag, java.lang.Class<?> clazz)
-
sortCreate
public java.util.List<Storable> sortCreate(java.util.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, java.util.Collection<Storable> toSortCollection, java.util.Collection<Storable> isVisitedCollection, java.util.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, java.lang.reflect.Field field, java.util.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, java.util.Map<java.lang.reflect.Field,java.util.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 java.util.Map<java.lang.reflect.Field,java.util.Set<Storable>> getReferencedLinkMap(Storable storable, java.util.Set<java.lang.reflect.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 java.util.Set<Storable> getReferencedLinkSet(Storable storable, java.util.Set<java.lang.reflect.Field> fieldSet)
Return all storable referenced by the given storable fields- Parameters:
storable
-fieldSet
-- Returns:
- Set of Storable
- Since:
- jcms-4.0
-
getReferencedLinkSet
public java.util.Set<Storable> getReferencedLinkSet(Storable storable, java.lang.reflect.Field field)
Return all storable referenced by the given storable field- Parameters:
storable
-field
-- Returns:
- Set of Storable
- Since:
- jcms-4.0
-
getFieldSet
public java.util.Set<java.lang.reflect.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)
-
-