public Object execute(ExecutionEvent event) throws ExecutionException { if (ApplicationControllers.getPatientController().getActivePatient() != null) { SerumGlucoseLaboratoryResult glucoseLabResult = new SerumGlucoseLaboratoryResult(); Shell shell = HandlerUtil.getActiveWorkbenchWindow(event).getShell(); GetExperimentalLaboratoryResult labResultWidget = new GetExperimentalLaboratoryResult(shell, glucoseLabResult, 0, 2000); labResultWidget.open(); if (glucoseLabResult.getConventionalTextResult() != EMPTY) { ApplicationControllers.getPatientController() .getActivePatient() .addExperimentalLabResult(glucoseLabResult); } updatePatient(ApplicationControllers.getPatientController().getActivePatient()); } else { MessageDialog.openInformation( null, "No active patient has been selected.", "Please select an active patient first."); } return null; }
public boolean performOk() { String oldDatabasePreference = ApplicationControllers.getApplication() .getPreferenceStore() .getString(DatabasePreferenceConstants.DATABASE_CHOICE); if (super.performOk()) { // super.performOk stores all the fields into the preference store String databasePreference = ApplicationControllers.getApplication() .getPreferenceStore() .getString(DatabasePreferenceConstants.DATABASE_CHOICE); if (oldDatabasePreference.equals(databasePreference)) { return true; } // Database preference has changed: HibernateUtil.injectDatabasePreference( ApplicationControllers.getDatabaseController().getDatabasePreferenceMap()); if (databasePreference.equals("hsqldb") && ApplicationControllers.getHsqldbController().getHsqldbIsRunning() == false) { ApplicationControllers.getApplication().startServer(); Session session = HibernateUtil.getSessionFactory().getCurrentSession(); try { session.beginTransaction(); SchemaUpdate su = new SchemaUpdate(HibernateUtil.getConfiguration()); su.execute(false, true); session.getTransaction().commit(); } catch (RuntimeException e) { throw new UtahToolboxException(ErrorCode.SCHEMA_UPDATE_ERROR, e); } } if (databasePreference.equals("mysql")) { if (ApplicationControllers.getApplication().testMySQLConnection(this)) { // mySQL is running Session session = HibernateUtil.getSessionFactory().getCurrentSession(); try { session.beginTransaction(); SchemaUpdate su = new SchemaUpdate(HibernateUtil.getConfiguration()); su.execute(false, true); session.getTransaction().commit(); } catch (RuntimeException e) { throw new UtahToolboxException(ErrorCode.SCHEMA_UPDATE_ERROR, e); } if (ApplicationControllers.getHsqldbController().getHsqldbIsRunning()) { // turn off HSQLDB if running try { ApplicationControllers.getApplication().stopHsqldb(); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (SQLException e) { e.printStackTrace(); } } } else { // mySQL is not running so revert to HSQLDB ApplicationControllers.getApplication() .getPreferenceStore() .setValue(DatabasePreferenceConstants.DATABASE_CHOICE, "hsqldb"); HibernateUtil.injectDatabasePreference( ApplicationControllers.getDatabaseController().getDatabasePreferenceMap()); if (ApplicationControllers.getHsqldbController().getHsqldbIsRunning() == false) { ApplicationControllers.getApplication().startServer(); Session session = HibernateUtil.getSessionFactory().getCurrentSession(); try { session.beginTransaction(); SchemaUpdate su = new SchemaUpdate(HibernateUtil.getConfiguration()); su.execute(false, true); session.getTransaction().commit(); } catch (RuntimeException e) { throw new UtahToolboxException(ErrorCode.SCHEMA_UPDATE_ERROR, e); } } } } ApplicationControllers.getDatabaseController().fireDatabaseChanged(); ApplicationControllers.getDecisionController() .addDecisionFiredListener(ApplicationControllers.getClockJob()); ApplicationControllers.getPatientController().updatePatientList(); ApplicationControllers.getPatientController().setActivePatient(null); ApplicationControllers.getPatientController().firePatientsChanged(null); return true; } return false; }