Search in sources :

Example 1 with MergerTokenFactoryProvider

use of org.apache.cayenne.dbsync.merge.factory.MergerTokenFactoryProvider in project cayenne by apache.

the class MigrateAction method performAction.

public void performAction(ActionEvent e) {
    DataSourceWizard connectWizard = getDataSourceWizard("Migrate DB Schema: Connect to Database");
    if (connectWizard == null) {
        return;
    }
    DataMap map = getProjectController().getCurrentDataMap();
    if (map == null) {
        throw new IllegalStateException("No current DataMap selected.");
    }
    dialogShown = false;
    DbActionOptionsDialog optionsDialog = loaderOptionDialog(connectWizard);
    if (dialogShown && optionsDialog == null) {
        return;
    }
    String selectedCatalog = optionsDialog == null ? null : optionsDialog.getSelectedCatalog();
    String selectedSchema = optionsDialog == null ? null : optionsDialog.getSelectedSchema();
    MergerTokenFactoryProvider mergerTokenFactoryProvider = getApplication().getInjector().getInstance(MergerTokenFactoryProvider.class);
    // ... show dialog...
    new MergerOptions(getProjectController(), "Migrate DB Schema: Options", connectWizard.getConnectionInfo(), map, selectedCatalog, selectedSchema, mergerTokenFactoryProvider).startupAction();
}
Also used : DataSourceWizard(org.apache.cayenne.modeler.dialog.db.DataSourceWizard) MergerTokenFactoryProvider(org.apache.cayenne.dbsync.merge.factory.MergerTokenFactoryProvider) MergerOptions(org.apache.cayenne.modeler.dialog.db.merge.MergerOptions) DbActionOptionsDialog(org.apache.cayenne.modeler.dialog.db.DbActionOptionsDialog) DataMap(org.apache.cayenne.map.DataMap)

Example 2 with MergerTokenFactoryProvider

use of org.apache.cayenne.dbsync.merge.factory.MergerTokenFactoryProvider in project cayenne by apache.

the class DefaultDbImportActionTest method buildDbImportAction.

private DefaultDbImportAction buildDbImportAction(FileProjectSaver projectSaver, DataMapLoader mapLoader, final DbLoader dbLoader) throws Exception {
    Logger log = mock(Logger.class);
    when(log.isDebugEnabled()).thenReturn(true);
    when(log.isInfoEnabled()).thenReturn(true);
    DbAdapter dbAdapter = mock(DbAdapter.class);
    DbAdapterFactory adapterFactory = mock(DbAdapterFactory.class);
    when(adapterFactory.createAdapter((DataNodeDescriptor) any(), (DataSource) any())).thenReturn(dbAdapter);
    DataSourceFactory dataSourceFactory = mock(DataSourceFactory.class);
    DataSource mock = mock(DataSource.class);
    when(dataSourceFactory.getDataSource((DataNodeDescriptor) any())).thenReturn(mock);
    DataChannelMetaData metaData = mock(DataChannelMetaData.class);
    MergerTokenFactoryProvider mergerTokenFactoryProvider = mock(MergerTokenFactoryProvider.class);
    when(mergerTokenFactoryProvider.get((DbAdapter) any())).thenReturn(new DefaultMergerTokenFactory());
    DataChannelDescriptorLoader dataChannelDescriptorLoader = mock(DataChannelDescriptorLoader.class);
    return new DefaultDbImportAction(log, projectSaver, dataSourceFactory, adapterFactory, mapLoader, mergerTokenFactoryProvider, dataChannelDescriptorLoader, metaData) {

        protected DbLoader createDbLoader(DbAdapter adapter, Connection connection, DbImportConfiguration config) {
            return dbLoader;
        }
    };
}
Also used : DbAdapterFactory(org.apache.cayenne.configuration.server.DbAdapterFactory) DataSourceFactory(org.apache.cayenne.configuration.server.DataSourceFactory) DbAdapter(org.apache.cayenne.dba.DbAdapter) DataChannelMetaData(org.apache.cayenne.configuration.xml.DataChannelMetaData) DefaultMergerTokenFactory(org.apache.cayenne.dbsync.merge.factory.DefaultMergerTokenFactory) DataChannelDescriptorLoader(org.apache.cayenne.configuration.DataChannelDescriptorLoader) Connection(java.sql.Connection) Logger(org.slf4j.Logger) MergerTokenFactoryProvider(org.apache.cayenne.dbsync.merge.factory.MergerTokenFactoryProvider) DataSource(javax.sql.DataSource)

Aggregations

MergerTokenFactoryProvider (org.apache.cayenne.dbsync.merge.factory.MergerTokenFactoryProvider)2 Connection (java.sql.Connection)1 DataSource (javax.sql.DataSource)1 DataChannelDescriptorLoader (org.apache.cayenne.configuration.DataChannelDescriptorLoader)1 DataSourceFactory (org.apache.cayenne.configuration.server.DataSourceFactory)1 DbAdapterFactory (org.apache.cayenne.configuration.server.DbAdapterFactory)1 DataChannelMetaData (org.apache.cayenne.configuration.xml.DataChannelMetaData)1 DbAdapter (org.apache.cayenne.dba.DbAdapter)1 DefaultMergerTokenFactory (org.apache.cayenne.dbsync.merge.factory.DefaultMergerTokenFactory)1 DataMap (org.apache.cayenne.map.DataMap)1 DataSourceWizard (org.apache.cayenne.modeler.dialog.db.DataSourceWizard)1 DbActionOptionsDialog (org.apache.cayenne.modeler.dialog.db.DbActionOptionsDialog)1 MergerOptions (org.apache.cayenne.modeler.dialog.db.merge.MergerOptions)1 Logger (org.slf4j.Logger)1