com.im.df.api 5.9

com.im.df.api
Interface DFSchemaProvider


public interface DFSchemaProvider

This interface should be used as primary source of connected and activated DFSchema objects and all its subelements (DFEntity/DFField/...). The typical usage is to get somewhere instance of DFSchemaProvider (perhaps through some factory) and then do these steps:


        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
            }

            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;

 
Notes about events:


Nested Class Summary
static interface DFSchemaProvider.State
          State description
static interface DFSchemaProvider.StepInfo
          Return code of "Proceed to next state".
 
Field Summary
static String PROP_STATE
          This property is fired whenever state changes
 
Method Summary
 void addPropertyChangeListener(PropertyChangeListener listener)
           
 void closeSchema(DFEnvironmentRW env)
          Closes the schema and invalidates DFSchema and all its subitems (property "valid" of DFItem).
 void deleteSchema(DFEnvironmentRW env, boolean deleteMetaDataTables)
          Deletes the schema metadata items from the database.
 Map<String,String> getAllSchemas(DFEnvironmentRO env)
          Retrieves all schemas available at the database connection.
 DFLockable getLockable()
          Provides lockable for state operations.
 SchemaType getSchemaType()
          Provides a schema type.
 DFSchemaProvider.State getState()
          Get current state
 void proceedToNextState(DFEnvironmentRW env)
          Continue to next phase.
 void removePropertyChangeListener(PropertyChangeListener listener)
           
 

Field Detail

PROP_STATE

static final String PROP_STATE
This property is fired whenever state changes

See Also:
Constant Field Values
Method Detail

getState

DFSchemaProvider.State getState()
Get current state


getLockable

DFLockable getLockable()
Provides lockable for state operations. This prevents more threads or components to start connecting at the same moment.


getSchemaType

SchemaType getSchemaType()
Provides a schema type. Returned value never change during DFSchemaProvider life time.

Returns:
The type of schema provided by this DFSchemaProvider. Never returns null

proceedToNextState

void proceedToNextState(DFEnvironmentRW env)
Continue to next phase. Options should be customised before calling this method. This method should not throw exception. If there are any problems it should be presented in next state description or


closeSchema

void closeSchema(DFEnvironmentRW env)
Closes the schema and invalidates DFSchema and all its subitems (property "valid" of DFItem).


deleteSchema

void deleteSchema(DFEnvironmentRW env,
                  boolean deleteMetaDataTables)
                  throws 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 f eedback environment
deleteMetaDataTables - Whether IJC_* tables should be deleted as well.
Throws:
IOException - if the schema is not open, or on schema-manipulation error.

getAllSchemas

Map<String,String> getAllSchemas(DFEnvironmentRO env)
Retrieves all schemas available at the database connection. The returned Map is indexed by schema IDs. Values are schema names. Note: schemaIDs served by the provider are always unique.

Returns:
The map of schemaID -> schema name

addPropertyChangeListener

void addPropertyChangeListener(PropertyChangeListener listener)

removePropertyChangeListener

void removePropertyChangeListener(PropertyChangeListener listener)

com.im.df.api 5.9