Package 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 sub-elements (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
                }
    
                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;
     
    Notes about events:
    • the PROP_STATE is fired whenever the state changes. When the provider will start to return DFSchema instance, the schema initialization has completed.
    • the PROP_LOCKED is fired on getLockable() 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
    • 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 same DFSchemaProvider 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 last proceedToNextState 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 environment
        deleteMetaDataTables - 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)