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());
}
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...");
}
}
Aggregations