Search in sources :

Example 11 with DataSourceInfo

use of org.apache.cayenne.conn.DataSourceInfo in project cayenne by apache.

the class DriverDataSourceFactory method getDataSource.

public DataSource getDataSource(DataNodeDescriptor nodeDescriptor) throws Exception {
    DataSourceInfo properties = nodeDescriptor.getDataSourceDescriptor();
    if (properties == null) {
        throw new IllegalArgumentException("'nodeDescriptor' contains no datasource descriptor");
    }
    Driver driver = objectFactory.newInstance(Driver.class, properties.getJdbcDriver());
    return new DriverDataSource(driver, properties.getDataSourceUrl(), properties.getUserName(), properties.getPassword());
}
Also used : DataSourceInfo(org.apache.cayenne.conn.DataSourceInfo) DriverDataSource(org.apache.cayenne.datasource.DriverDataSource) Driver(java.sql.Driver)

Example 12 with DataSourceInfo

use of org.apache.cayenne.conn.DataSourceInfo in project cayenne by apache.

the class JDBCDataSourceEditor method syncDataSourceAction.

/**
 * This action is called whenever the password location is changed
 * in the GUI pulldown.  It changes labels and editability of the
 * password fields depending on the option that was selected.
 */
public void syncDataSourceAction() {
    CayenneModelerController mainController = getApplication().getFrameController();
    if (getNode() == null || getNode().getDataSourceDescriptor() == null) {
        return;
    }
    DataSourceInfo projectDSI = getNode().getDataSourceDescriptor();
    ProjectController parent = (ProjectController) getParent();
    String key = parent.getDataNodePreferences().getLocalDataSource();
    if (key == null) {
        mainController.updateStatus("No Local DataSource selected for node...");
        return;
    }
    DBConnectionInfo dataSource = (DBConnectionInfo) getApplication().getCayenneProjectPreferences().getDetailObject(DBConnectionInfo.class).getObject(key);
    if (dataSource != null) {
        if (dataSource.copyTo(projectDSI)) {
            refreshView();
            super.nodeChangeProcessor.modelUpdated(null, null, null);
            mainController.updateStatus(null);
        } else {
            mainController.updateStatus("DataNode is up to date...");
        }
    } else {
        mainController.updateStatus("Invalid Local DataSource selected for node...");
    }
}
Also used : DataSourceInfo(org.apache.cayenne.conn.DataSourceInfo) CayenneModelerController(org.apache.cayenne.modeler.CayenneModelerController) ProjectController(org.apache.cayenne.modeler.ProjectController) DBConnectionInfo(org.apache.cayenne.modeler.pref.DBConnectionInfo)

Aggregations

DataSourceInfo (org.apache.cayenne.conn.DataSourceInfo)12 DataNodeDescriptor (org.apache.cayenne.configuration.DataNodeDescriptor)4 DataChannelDescriptor (org.apache.cayenne.configuration.DataChannelDescriptor)3 Driver (java.sql.Driver)2 ConfigurationException (org.apache.cayenne.ConfigurationException)2 XMLPoolingDataSourceFactory (org.apache.cayenne.configuration.server.XMLPoolingDataSourceFactory)2 ProjectController (org.apache.cayenne.modeler.ProjectController)2 Test (org.junit.Test)2 Map (java.util.Map)1 SkipSchemaUpdateStrategy (org.apache.cayenne.access.dbsync.SkipSchemaUpdateStrategy)1 DataNodeEvent (org.apache.cayenne.configuration.event.DataNodeEvent)1 JNDIDataSourceFactory (org.apache.cayenne.configuration.server.JNDIDataSourceFactory)1 DriverDataSource (org.apache.cayenne.datasource.DriverDataSource)1 DbAdapter (org.apache.cayenne.dba.DbAdapter)1 DataMap (org.apache.cayenne.map.DataMap)1 CayenneModelerController (org.apache.cayenne.modeler.CayenneModelerController)1 DataNodeDisplayEvent (org.apache.cayenne.modeler.event.DataNodeDisplayEvent)1 DBConnectionInfo (org.apache.cayenne.modeler.pref.DBConnectionInfo)1 AdapterMapping (org.apache.cayenne.modeler.util.AdapterMapping)1 BuildException (org.apache.tools.ant.BuildException)1