ru.biosoft.access
Class LocalRepository

java.lang.Object
  extended byru.biosoft.access.DataElementSupport
      extended byru.biosoft.access.AbstractDataCollection
          extended byru.biosoft.access.VectorDataCollection
              extended byru.biosoft.access.LocalRepository
All Implemented Interfaces:
DataCollection, DataElement, Repository

public class LocalRepository
extends VectorDataCollection
implements Repository

LocalRepository creates hierarchical DataCollection. The information about used in a tree nodes is extracted from files, which are organized in a tree. In other words each subdirectory contains one DataCollection. DataCollection is described by the special configuration files ("default.config" and *.node.config) It is the standard file of a java.util.Properties . This file contains key-value lines, which describes concrete DataCollection. Key values constants are defined in DataCollection

See Also:
Properties.load(InputStream )
To do:
sorting order

Field Summary
static java.lang.String PARENT_COLLECTION
           
protected  java.io.File root
          Repository root subdirectory.
 
Fields inherited from class ru.biosoft.access.VectorDataCollection
INITIAL_SIZE, vector
 
Fields inherited from class ru.biosoft.access.AbstractDataCollection
cat, info, notificationEnabled, path, propagationEnabled, v_cache
 
Fields inherited from interface ru.biosoft.access.DataCollection
CHILDREN_NODE_IMAGE, CHILDREN_NODE_VISIBLE, CLASS_PROPERTY, CLASSPATH_JAR_PROPERTY, COMPARATOR_OBJECT, CONFIG_FILE_PROPERTY, CONFIG_PATH_PROPERTY, DATA_ELEMENT_CLASS_PROPERTY, DEFAULT_CONFIG_FILE, DEFAULT_CONFIG_SUFFIX, DEFAULT_FILTER_CONFIG_SUFFIX, DEFAULT_FORMAT_CONFIG_SUFFIX, DEFAULT_NODE_CONFIG_SUFFIX, DEFAULT_REPOSITORY, DESCRIPTION_PROPERTY, DISPLAY_NAME_PROPERTY, FILE_PATH_PROPERTY, FILE_PROPERTY, FILTER_PROPERTY, ID_FORMAT, IS_ROOT, JOB_CONTROL_PROPERTY, LATE_CHILDREN_INITIALIZATION, MUTABLE, NAME_PROPERTY, NEXT_CONFIG, NODE_IMAGE, NODE_VISIBLE, PRIMARY_COLLECTION, REMOVE_CHILDREN, TRANSFORMER_CLASS
 
Constructor Summary
LocalRepository(DataCollection parent, java.util.Properties properties)
          Constructs LocalRepository.
 
Method Summary
 void close()
          Removes all of the elements from this data collection.
protected  void createCollection(java.io.File file, boolean isNotify, FunctionJobControl fjc)
          Creates DataCollection using specified config file and adds it to this DataCollection
 DataCollection createDataCollection(java.lang.String name, java.util.Properties properties, java.lang.String subDir, java.lang.String configName, java.io.File[] files, boolean copy, CreateDataCollectionController controller)
          Creates new DataCollection with specified subdir (if not null) and config file name.
protected  DataElement doGet(java.lang.String name)
          Returns the element with the specified name from this data collection.
protected  void doRemove(java.lang.String name)
          Remove DataElement from data collection.
 java.lang.String getAbsolutePath()
           
 DataElement getAt(int index)
          Returns the element at the specified position in this data collection.
 java.lang.Class getDataElementType()
          Returns DataCollection.class
 java.util.List getNameList()
          Returns an unmodifiable list of the data element names contained in this data collection.
 java.io.File getRootDirectory()
           
 int getSize()
          Returns the number of data elements in this data collection.
protected  void init()
          Scans files in root subdirectory.
 java.util.Iterator iterator()
          Returns an iterator over the elements in this list in alphabetically sorted sequence.
 
Methods inherited from class ru.biosoft.access.VectorDataCollection
doPut, put, toArray
 
Methods inherited from class ru.biosoft.access.AbstractDataCollection
addDataCollectionListener, cachePut, checkMutable, contains, contains, doAddPostNotify, doAddPreNotify, doRemovePostNotify, doRemovePreNotify, finalize, fireElementAdded, fireElementChanged, fireElementRemoved, fireElementWillAdd, fireElementWillChange, fireElementWillRemove, get, getCompleteName, getDescription, getInfo, initLog, isMutable, isNotificationEnabled, isPropagationEnabled, makeInfo, propagateElementChanged, propagateElementWillChange, registerRoot, release, remove, removeDataCollectionListener, setNotificationEnabled, setPropagationEnabled, toString
 
Methods inherited from class ru.biosoft.access.DataElementSupport
getName, getOrigin, registerConstructorWithBadEqual
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface ru.biosoft.access.DataElement
getName, getOrigin
 

Field Detail

PARENT_COLLECTION

public static final java.lang.String PARENT_COLLECTION
See Also:
Constant Field Values

root

protected java.io.File root
Repository root subdirectory.

Constructor Detail

LocalRepository

public LocalRepository(DataCollection parent,
                       java.util.Properties properties)
                throws java.lang.Exception
Constructs LocalRepository. Root subdirectory is defined by DataCollection#PATH_PROPERTY

Parameters:
parent - parent DataCollection
properties - DataCollection properties
Throws:
java.lang.Exception - If any error
Method Detail

getRootDirectory

public java.io.File getRootDirectory()

getAbsolutePath

public java.lang.String getAbsolutePath()

init

protected void init()
Scans files in root subdirectory. If the subdirectory contains other subdirectories, they are considered as the challengers for creation nested DataCollection-s. DataCollection is created, if in the nested subdirectory is found "default.config" file. Also DataCollection is created, if a root subdirectory contains a file with ".node.config" suffix All DataCollections are added to the this DataCollection

See Also:
#createCollection(File file,boolean isNotify)

createCollection

protected void createCollection(java.io.File file,
                                boolean isNotify,
                                FunctionJobControl fjc)
                         throws java.lang.Exception
Creates DataCollection using specified config file and adds it to this DataCollection

Parameters:
file - config file
isNotify - If this flag false the listeners will not be notified of add event
Throws:
java.lang.Exception - If any error
To do:
log message, whether it should check that there is no collection with such name?

doRemove

protected void doRemove(java.lang.String name)
                 throws java.lang.Exception
Remove DataElement from data collection. If DataElement that should be removed is DataCollection, then all files used by this data collection permanently deleted.

Overrides:
doRemove in class VectorDataCollection
Throws:
java.lang.Exception - If base version of doRemove throws Exception.
See Also:
mgl3.access.DataCollectionInfo#getUsedFiles(), mgl3.access.DataCollection

getSize

public int getSize()
Description copied from class: VectorDataCollection
Returns the number of data elements in this data collection.

Specified by:
getSize in interface DataCollection
Overrides:
getSize in class VectorDataCollection
Returns:
the number of data elements in this data collection.

doGet

protected DataElement doGet(java.lang.String name)
Description copied from class: VectorDataCollection
Returns the element with the specified name from this data collection.

Overrides:
doGet in class VectorDataCollection
Parameters:
name - name of element to return.
Returns:
the element with the specified name in this data collection.
See Also:
AbstractDataCollection.get(String)

getAt

public DataElement getAt(int index)
Description copied from class: VectorDataCollection
Returns the element at the specified position in this data collection.

Overrides:
getAt in class VectorDataCollection
Parameters:
index - index of element to return.
Returns:
the element at the specified position in this data collection.

iterator

public java.util.Iterator iterator()
Description copied from class: VectorDataCollection
Returns an iterator over the elements in this list in alphabetically sorted sequence.

Specified by:
iterator in interface DataCollection
Overrides:
iterator in class VectorDataCollection
Returns:
an iterator over the elements in this list in alphabetically sorted sequence.

getNameList

public java.util.List getNameList()
Description copied from class: VectorDataCollection
Returns an unmodifiable list of the data element names contained in this data collection. Query operations on the returned list "read through" to the internal name list, and attempts to modify the returned list, whether direct or via its iterator, result in an UnsupportedOperationException. The returned list is backed by the data collection, so changes to the data collection are reflected in the returned list.

Specified by:
getNameList in interface DataCollection
Overrides:
getNameList in class VectorDataCollection
Returns:
Names of all elements in this data collection in alphabetically sorted order.

getDataElementType

public java.lang.Class getDataElementType()
Returns DataCollection.class

Specified by:
getDataElementType in interface DataCollection
Overrides:
getDataElementType in class AbstractDataCollection
Returns:
DataCollection.class.

close

public void close()
           throws java.lang.Exception
Description copied from class: VectorDataCollection
Removes all of the elements from this data collection.

Specified by:
close in interface DataCollection
Overrides:
close in class VectorDataCollection
Throws:
java.lang.Exception
To do:
Document

createDataCollection

public DataCollection createDataCollection(java.lang.String name,
                                           java.util.Properties properties,
                                           java.lang.String subDir,
                                           java.lang.String configName,
                                           java.io.File[] files,
                                           boolean copy,
                                           CreateDataCollectionController controller)
                                    throws java.lang.Exception
Creates new DataCollection with specified subdir (if not null) and config file name. If config file already exists, specified controler is used. If controler permits to override existing config file, then DataCollection is created.

Specified by:
createDataCollection in interface Repository
Parameters:
name - DataCollection name
properties - DataCollection properties
subDir - Sub directory for new collection.
configName - Name of configuration file
files - Files to be moved or copied into repository
copy - Indicates whether files should be copied.
controller - Object for special control functions (dialogs for example).
Returns:
Created data collection, or null.
Throws:
java.lang.Exception - If error occured.
To do:
high Change processing of file overwriting!!!


Copyright © 2001-2003 Biosof.Ru. All Rights Reserved.