Package com.im.df.api
Interface DFSchemaProvider
-
public interface DFSchemaProvider
This interface should be used as primary source of connected and activatedDFSchema
objects and all its sub-elements (DFEntity
/DFField
/...). The typical usage is to get somewhere instance ofDFSchemaProvider
(perhaps through some factory) and then do these steps:
Notes about events:DFSchemaProvider schemaProvider = new SomeSchemaProviderImpl(); DFLock lock = schemaProvider.getLockable().obtainLock("Connect to schema"); DFEnvironmentRW env = EnvUtils.createDefaultEnvironmentRW(lock, "Connecting to schema", true); for (;;) { SchemaProvider.State state = schemaProvider.getState(); if (state.isSchemaReady()) break; Object options = state.getOptions(); if (options != null) { // customize options: find customizer and present to user. // The dialog with customizer should have cancel button to stop connecting anytime } StepInfo result = schemaProvider.proceedToNextState(env); } // Close the environment and release the lock - the best approach is to do this in finally block // => and return the activated schema instance DFSchema schema = schemaProvider.getState().isSchemaReady() ? schemaProvider.getSchema() : null;
- the
PROP_STATE
is fired whenever the state changes. When the provider will start to returnDFSchema
instance, the schema initialization has completed. - the
PROP_LOCKED
is fired ongetLockable()
when the lock is released. This should happen either after the initialization completes successfully (DFSchema
is returned from the provider) or fails (no schema is returned).
- Author:
- Petr Hamernik
- the
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
DFSchemaProvider.State
The schema init step interface.static interface
DFSchemaProvider.StepInfo
This is a result of each schema init step (DFSchemaProvider.State
) operations.
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
PROP_STATE
This property is fired whenever state changes.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
addPropertyChangeListener(java.beans.PropertyChangeListener listener)
void
closeSchema(com.im.commons.progress.DFEnvironmentRW env)
Closes the schema.void
deleteSchema(com.im.commons.progress.DFEnvironmentRW env, boolean deleteMetaDataTables)
Deletes the schema metadata items from the database.DFSchemaProvider.StepInfo
getLastStateResult()
Gets the result of the last performed step.com.im.commons.progress.DFLockable
getLockable()
Gets lockable for state operations.SchemaType
getSchemaType()
Gets the IJC schema type.DFSchemaProvider.State
getState()
Gets the current state.DFSchemaProvider.StepInfo
proceedToNextState(com.im.commons.progress.DFEnvironmentRW env)
Performs operations implemented in this schema init step.void
removePropertyChangeListener(java.beans.PropertyChangeListener listener)
-
-
-
Field Detail
-
PROP_STATE
static final java.lang.String PROP_STATE
This property is fired whenever state changes.- See Also:
- Constant Field Values
-
-
Method Detail
-
getState
DFSchemaProvider.State getState()
Gets the current state.- Returns:
- The
State
implementation for the current step in the schema init process.
-
getLockable
com.im.commons.progress.DFLockable getLockable()
Gets lockable for state operations. This prevents more threads or components to start connecting at the same moment.- Returns:
DFLockable
-
getSchemaType
SchemaType getSchemaType()
Gets the IJC schema type. The value never changes for the sameDFSchemaProvider
instance.- Returns:
SchemaType
-
proceedToNextState
DFSchemaProvider.StepInfo proceedToNextState(com.im.commons.progress.DFEnvironmentRW env)
Performs operations implemented in this schema init step. The step options should be customized before calling this method. This method should never throw an exception. Any problems encountered while performing the operations should be reported via the return value.- Parameters:
env
-DFEnvironmentRW
- Returns:
- The
StepInfo
instance that describes the result of this step operations.
-
getLastStateResult
DFSchemaProvider.StepInfo getLastStateResult()
Gets the result of the last performed step.- Returns:
- The
StepInfo
instance that was returned from the lastproceedToNextState
call.
-
closeSchema
void closeSchema(com.im.commons.progress.DFEnvironmentRW env)
Closes the schema. This method will also invalidate DFSchema and all its sub-items (property "valid" of DFItem).- Parameters:
env
-DFEnvironmentRW
-
deleteSchema
void deleteSchema(com.im.commons.progress.DFEnvironmentRW env, boolean deleteMetaDataTables) throws java.io.IOException
Deletes the schema metadata items from the database. If deleteSystemTables is set, it will also delete the IJC_ system tables; that is ALL schemas, users, views etc. The system tables can be deleted only if this is the last schema.- Parameters:
env
- The feedback environmentdeleteMetaDataTables
- Whether IJC_* tables should be deleted as well.- Throws:
java.io.IOException
- if the schema is not open, or on schema-manipulation error.
-
addPropertyChangeListener
void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
-
removePropertyChangeListener
void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
-
-