@Override public Engine createEngine() throws Exception { testFile = "jpa-test." + JpaH2DataStore.FILE_EXT; try { // File temp = Files.createTempFile("jpa-test", "." + JpaH2DataStore.FILE_EXT).toFile(); // temp.deleteOnExit(); testFile = Files.createTempFile("jpa-test", "." + JpaH2DataStore.FILE_EXT).toString(); } catch (final IOException ex) { Logger.getLogger(JpaH2EngineTest.class.getName()) .log(Level.SEVERE, ex.getLocalizedMessage(), ex); fail(); } EngineFactory.deleteDatabase(testFile); try { return EngineFactory.bootLocalEngine( testFile, EngineFactory.DEFAULT, PASSWORD, DataStoreType.H2_DATABASE); } catch (final Exception e) { fail(e.getMessage()); return null; } }
@Override public Engine createEngine() throws Exception { testFile = "xml-account-test.xml"; EngineFactory.deleteDatabase(testFile); return EngineFactory.bootLocalEngine( testFile, EngineFactory.DEFAULT, PASSWORD, DataStoreType.XML); }
@Test public void dumpTableAndColumnNames() { EngineFactory.closeEngine(EngineFactory.DEFAULT); Set<String> tableNames = SqlUtils.getTableAndColumnNames(testFile, PASSWORD); tableNames.forEach(System.out::println); }
@FXML private void handleDeleteAccountAction() { if (getSelectedAccount().isPresent()) { final Engine engine = EngineFactory.getEngine(EngineFactory.DEFAULT); Objects.requireNonNull(engine); if (!engine.removeAccount(getSelectedAccount().get())) { StaticUIMethods.displayError(resources.getString("Message.Error.AccountRemove")); } } }
@Test public void testVersion() { try { RootAccount account = e.getRootAccount(); Account temp = e.getStoredObjectByUuid(RootAccount.class, account.getUuid()); assertEquals(account, temp); // close and reopen to force check for persistence EngineFactory.closeEngine(EngineFactory.DEFAULT); float version = EngineFactory.getFileVersion(new File(testFile), PASSWORD); System.out.println(version); assertEquals(version, Engine.CURRENT_VERSION, DELTA); } catch (final Exception e) { fail(e.getMessage()); } }
private void loadAccountTree() { final Engine engine = EngineFactory.getEngine(EngineFactory.DEFAULT); if (engine != null) { RootAccount r = engine.getRootAccount(); final TreeItem<Account> root = new TreeItem<>(r); root.setExpanded(true); treeTableView.setRoot(root); loadChildren(root); } else { treeTableView.setRoot(null); } }
private void updateAccountCode(final Account account, final Integer code) { final Engine engine = EngineFactory.getEngine(EngineFactory.DEFAULT); if (engine != null) { try { final Account template = (Account) account.clone(); template.setAccountCode(code); engine.modifyAccount(template, account); } catch (final CloneNotSupportedException e) { Logger.getLogger(AccountsViewController.class.getName()) .log(Level.SEVERE, e.getLocalizedMessage(), e); } } }
@FXML private void convertAction() { final Optional<Account> accountOptional = StaticAccountsMethods.selectAccount(null, accountProperty.get()); if (accountOptional.isPresent()) { final Account opp = accountOptional.get(); final Transaction t = new Transaction(); t.setDate(datePicker.getValue()); t.setNumber(numberComboBox.getValue()); t.setPayee(payeeTextField.getText()); final TransactionEntry entry = new TransactionEntry(); entry.setMemo(memoTextField.getText()); if (amountField.getDecimal().signum() >= 0) { entry.setCreditAccount(accountProperty.get()); entry.setDebitAccount(opp); } else { entry.setDebitAccount(accountProperty.get()); entry.setCreditAccount(opp); } entry.setCreditAmount(amountField.getDecimal().abs()); entry.setDebitAmount(amountField.getDecimal().abs().negate()); t.addTransactionEntry(entry); ReconcileManager.reconcileTransaction(accountProperty.get(), t, getReconciledState()); TransactionDialog.showAndWait( accountProperty.get(), t, optional -> { if (optional.isPresent()) { final Transaction tran = optional.get(); final Engine engine = EngineFactory.getEngine(EngineFactory.DEFAULT); Objects.requireNonNull(engine); if (engine.removeTransaction(modTrans)) { engine.addTransaction(tran); } clearForm(); } }); } }
/** * @param queryResult * @param template * @param vars * @return una lista de Sugerencias-- no de Strings */ public Set<Suggest> getSuggests(ResultSet queryResultSet, String template, List<Var> vars) { Set<Suggest> suggests = new HashSet<Suggest>(); QueryResult queryResult; Suggest newSuggest; while (queryResultSet.hasMoreElements()) { queryResult = queryResultSet.next(); List<String> values = new LinkedList<String>(); for (Var var : vars) { String value = queryResult.getValueOfVar(var.getVarText()); if (!value.equals("")) { values.add(value); } } String suggest = parseSuggest(vars, values, template); newSuggest = EngineFactory.createSuggest(); newSuggest.setResult(queryResult); newSuggest.setSuggest(suggest); suggests.add(newSuggest); } return suggests; }
@AfterClass public static void cleanup() { EngineFactory.deleteDatabase("xml-account-test.xml"); EngineFactory.deleteDatabase("xml-account-test.xml.backup"); }