in plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/wizards/DBPoolWizard.java [124:263]
public boolean performFinish() {
JAXBElement plan = this.section.getRootElement();
// all pages
ExternalPathPage page0 = (ExternalPathPage) getPages()[0];
DBPoolBasicPage page1 = (DBPoolBasicPage) getPages()[1];
DBPoolAdvancedPage page2 = (DBPoolAdvancedPage) getPages()[2];
ConnectionPoolPage page3 = (ConnectionPoolPage) getPages()[3];
// check necessary info has been filled
if (page1.getPoolName() == null
|| page1.getPoolName().trim().length() == 0
|| page1.getPoolName().contains(" ")) {
MessageDialog.openWarning(this.getShell(), Messages.poolNameInvalidTitle,
Messages.poolNameInvalidDesc);
return false;
}
if (page1.getDBPooolType() == null
|| page1.getDBPooolType().trim().length() == 0) {
MessageDialog.openWarning(this.getShell(), Messages.poolTypeInvalidTitle,
Messages.poolTypeInvalidDesc);
return false;
}
if (page1.getDBName() == null || page1.getDBName().trim().length() == 0
|| page1.getDBName().contains(" ")) {
MessageDialog.openWarning(this.getShell(), Messages.dbNameInvalidTitle,
Messages.dbNameInvalidDesc);
return false;
}
if (page1.getDrivers() == null || page1.getDrivers().length == 0) {
MessageDialog.openWarning(this.getShell(), Messages.dbDriverInvalidTitle,
Messages.dbDriverInvalidDesc);
return false;
}
// add the dependencies and ext-module to plan
if (Application.class.isInstance(plan.getValue())) {
Application application = (Application) plan.getValue();
Environment env = application.getEnvironment();
if (env == null) {
env = new Environment();
application.setEnvironment(env);
}
Dependencies dependencies = env.getDependencies();
if (dependencies == null) {
dependencies = new Dependencies();
env.setDependencies(dependencies);
}
// if there are no same dependencies in plan,then add them
for (int i = 0; i < page1.getDrivers().length; i++) {
Dependency selectedDependency = (Dependency) page1.getDrivers()[i];
if (!dependencies.getDependency().contains(selectedDependency)) {
dependencies.getDependency().add(selectedDependency);
}
}
ExtModule extModule;
if (eObject == null) {
eObject = getEFactory().create(ExtModule.class);
extModule = (ExtModule) eObject;
java.util.List<ExtModule> extModuleList = application
.getExtModule();
extModuleList.add(extModule);
} else {
extModule = (ExtModule) eObject;
}
// NOTE!! this replaces the call to processEAttributes (page);
Path path = (Path) getEFactory().create(Path.class);
path.setValue(page0.text[0].getText());
extModule.setConnector(path);
Pattern pattern = (Pattern) getEFactory().create(Pattern.class);
extModule.setExternalPath(pattern);
pattern.setGroupId(page0.text[1].getText());
pattern.setArtifactId(page0.text[2].getText());
//empty version element will cause deploy failure
String version = page0.text[3].getText();
if (version!=null && version.length()!=0)
pattern.setVersion(page0.text[3].getText());
pattern.setType(page0.text[4].getText().trim());
Connector conn = new Connector();
// attention here <connector/> is unmashalled as a JAXBElement
JAXBElement<Connector> connElement = (new org.apache.geronimo.jee.connector.ObjectFactory())
.createConnector(conn);
extModule.setAny(connElement);
Resourceadapter adapter = new Resourceadapter();
conn.getResourceadapter().add(adapter);
OutboundResourceadapter outboundAdpater = new OutboundResourceadapter();
ConnectionDefinition definition = new ConnectionDefinition();
definition.setConnectionfactoryInterface("javax.sql.DataSource");
ConnectiondefinitionInstance instance = new ConnectiondefinitionInstance();
instance.setName(page1.getPoolName());
String[] loginData = page2.getLoginData();
if (!loginData[1].equals(loginData[2])) {
Status status = new Status(IStatus.WARNING, "Login Error", 0,
Messages.dbLoginError0, null);
ErrorDialog.openError(this.getShell(), "Login Error",
Messages.dbLoginError1, status);
return false;
}
ConfigPropertySetting setting1 = new ConfigPropertySetting();
setting1.setName(Messages.dbWizardPwd);
setting1.setValue(loginData[1]);
instance.getConfigPropertySetting().add(setting1);
ConfigPropertySetting setting2 = new ConfigPropertySetting();
setting2.setName(Messages.dbWizardLoginTimeout);
setting2.setValue(page2.getLoginTimeout());
instance.getConfigPropertySetting().add(setting2);
ConfigPropertySetting setting3 = new ConfigPropertySetting();
setting3.setName(Messages.dbWizardDbName);
setting3.setValue(page1.getDBName());
instance.getConfigPropertySetting().add(setting3);
ConfigPropertySetting setting4 = new ConfigPropertySetting();
setting4.setName(Messages.dbWizardCreateDb);
setting4.setValue(page2.getCreateDatabase());
instance.getConfigPropertySetting().add(setting4);
ConfigPropertySetting setting5 = new ConfigPropertySetting();
setting5.setName(Messages.dbWizardUserName);
setting5.setValue(loginData[0]);
instance.getConfigPropertySetting().add(setting5);
instance.setConnectionmanager(page3.getConnectionManager());
definition.getConnectiondefinitionInstance().add(instance);
outboundAdpater.getConnectionDefinition().add(definition);
adapter.setOutboundResourceadapter(outboundAdpater);
if (section.getViewer().getInput() == section.getRootElement()) {
section.getViewer().setInput(section.getInput());
}
return true;
}
return true;
}