This is an automated email from the git hooks/post-receive script. New commit to branch feature/1197-modularisation in repository lima. See http://git.chorem.org/lima.git commit fea2115409ca9e536a63db6281ee45a3c2296b5c Author: Arnaud Thimel <thimel@codelutin.com> Date: Wed Mar 18 02:01:17 2015 +0100 Fix *ConfigOption naming ; remove some of the unused config options --- .../chorem/lima/business/api/OptionsService.java | 4 +- .../chorem/lima/business/LimaBusinessConfig.java | 68 ++--- .../lima/business/ejb/OptionsServiceImpl.java | 16 +- .../org/chorem/lima/business/LimaMiscTest.java | 2 +- .../accountingrules/ImportServiceRuleFrTest.java | 2 +- .../org/chorem/lima/report/LimaReportConfig.java | 163 ++++------- .../lima/report/service/DocumentService.java | 4 +- .../src/main/java/org.chorem.lima/LimaServer.java | 26 +- .../org.chorem.lima/server/HttpServerService.java | 18 +- .../org.chorem.lima/server/LimaServerConfig.java | 316 +-------------------- .../main/java/org/chorem/lima/LimaSwingConfig.java | 2 - .../src/main/java/org/chorem/lima/ui/MainView.jaxx | 2 +- .../java/org/chorem/lima/ui/MainViewHandler.java | 6 +- .../java/org/chorem/lima/ui/AbstractLimaTest.java | 2 +- 14 files changed, 147 insertions(+), 484 deletions(-) diff --git a/lima-business-api/src/main/java/org/chorem/lima/business/api/OptionsService.java b/lima-business-api/src/main/java/org/chorem/lima/business/api/OptionsService.java index 9942002..1902938 100644 --- a/lima-business-api/src/main/java/org/chorem/lima/business/api/OptionsService.java +++ b/lima-business-api/src/main/java/org/chorem/lima/business/api/OptionsService.java @@ -54,8 +54,8 @@ public interface OptionsService extends BigDecimalToString.Config { LimaConfigOptionDef getThousandSeparatorOption(); - String getLimaReportHost(); + String getLimaHttpHost(); - int getLimaReportPort(); + int getLimaHttpPort(); } diff --git a/lima-business/src/main/java/org/chorem/lima/business/LimaBusinessConfig.java b/lima-business/src/main/java/org/chorem/lima/business/LimaBusinessConfig.java index 951af46..6463992 100644 --- a/lima-business/src/main/java/org/chorem/lima/business/LimaBusinessConfig.java +++ b/lima-business/src/main/java/org/chorem/lima/business/LimaBusinessConfig.java @@ -68,8 +68,8 @@ public class LimaBusinessConfig { private LimaBusinessConfig(String configFileName) { try { - ApplicationConfig defaultConfig = new ApplicationConfig(ServiceConfigOption.CONFIG_FILE.getDefaultValue()); - defaultConfig.loadDefaultOptions(ServiceConfigOption.values()); + ApplicationConfig defaultConfig = new ApplicationConfig(BusinessConfigOption.CONFIG_FILE.getDefaultValue()); + defaultConfig.loadDefaultOptions(BusinessConfigOption.values()); defaultConfig.parse(); if (StringUtils.isNotBlank(configFileName)) { @@ -91,14 +91,14 @@ public class LimaBusinessConfig { private LimaBusinessConfig(final ApplicationConfig config) { try { - ApplicationConfig defaultConfig = new ApplicationConfig(ServiceConfigOption.CONFIG_FILE.getDefaultValue()); - defaultConfig.loadDefaultOptions(ServiceConfigOption.values()); + ApplicationConfig defaultConfig = new ApplicationConfig(BusinessConfigOption.CONFIG_FILE.getDefaultValue()); + defaultConfig.loadDefaultOptions(BusinessConfigOption.values()); defaultConfig.parse(); if (config != null) { Properties flatOptions = defaultConfig.getFlatOptions(); flatOptions.putAll(config.getFlatOptions(true)); - this.config = new ApplicationConfig(flatOptions, ServiceConfigOption.CONFIG_FILE.getDefaultValue()); + this.config = new ApplicationConfig(flatOptions, BusinessConfigOption.CONFIG_FILE.getDefaultValue()); this.config.parse(); } else { if (log.isWarnEnabled()) { @@ -185,10 +185,10 @@ public class LimaBusinessConfig { } protected static void loadAccountingRules() { - Class<?> accountingRulesClass = getInstance().config.getOptionAsClass(ServiceConfigOption.RULES_NATIONALTY.key); + Class<?> accountingRulesClass = getInstance().config.getOptionAsClass(BusinessConfigOption.RULES_NATIONALTY.key); if (accountingRulesClass == null) { if (log.isErrorEnabled()) { - log.error("No accounting rules defined for:" + ServiceConfigOption.RULES_NATIONALTY.key); + log.error("No accounting rules defined for:" + BusinessConfigOption.RULES_NATIONALTY.key); } accountingRules = new FranceAccountingRules(); } else { @@ -208,19 +208,19 @@ public class LimaBusinessConfig { } public String getConfigFile() { - return config.getOption(ServiceConfigOption.CONFIG_FILE.key); + return config.getOption(BusinessConfigOption.CONFIG_FILE.key); } public void setConfigFile(String configFile) { - LimaBusinessConfig.getInstance().config.setOption(ServiceConfigOption.CONFIG_FILE.key, configFile); + LimaBusinessConfig.getInstance().config.setOption(BusinessConfigOption.CONFIG_FILE.key, configFile); } public String getApplicationVersion() { - return config.getOption(ServiceConfigOption.APPLICATION_VERSION.key); + return config.getOption(BusinessConfigOption.APPLICATION_VERSION.key); } public void setAccountingRule(String accountingRule) { - LimaBusinessConfig.getInstance().config.setOption(ServiceConfigOption.RULES_NATIONALTY.key, accountingRule); + LimaBusinessConfig.getInstance().config.setOption(BusinessConfigOption.RULES_NATIONALTY.key, accountingRule); // clear cache loadAccountingRules(); } @@ -228,59 +228,59 @@ public class LimaBusinessConfig { public int getScale() { - return config.getOptionAsInt(ServiceConfigOption.SCALE.key); + return config.getOptionAsInt(BusinessConfigOption.SCALE.key); } public void setScale(String locale) { - config.setOption(ServiceConfigOption.SCALE.key, locale); + config.setOption(BusinessConfigOption.SCALE.key, locale); config.saveForUser(); } public boolean getCurrency() { - return config.getOptionAsBoolean(ServiceConfigOption.CURRENCY.key); + return config.getOptionAsBoolean(BusinessConfigOption.CURRENCY.key); } public void setCurrency(String locale) { - config.setOption(ServiceConfigOption.CURRENCY.key, locale); + config.setOption(BusinessConfigOption.CURRENCY.key, locale); config.saveForUser(); } public char getDecimalSeparator() { - char decimalSeparator = config.getOption(ServiceConfigOption.DECIMAL_SEPARATOR.key).charAt(0); + char decimalSeparator = config.getOption(BusinessConfigOption.DECIMAL_SEPARATOR.key).charAt(0); return decimalSeparator; } public void setDecimalSeparator(String locale) { - config.setOption(ServiceConfigOption.DECIMAL_SEPARATOR.key, locale); + config.setOption(BusinessConfigOption.DECIMAL_SEPARATOR.key, locale); config.saveForUser(); } public char getThousandSeparator() { - return config.getOption(ServiceConfigOption.THOUSAND_SEPARATOR.key).charAt(0); + return config.getOption(BusinessConfigOption.THOUSAND_SEPARATOR.key).charAt(0); } public void setThousandSeparator(String locale) { - config.setOption(ServiceConfigOption.THOUSAND_SEPARATOR.key, locale); + config.setOption(BusinessConfigOption.THOUSAND_SEPARATOR.key, locale); config.saveForUser(); } - public String getReportHost() { - String host = config.getOption(ServiceConfigOption.REPORT_HOST.getKey()); + public String getHttpHost() { + String host = config.getOption(BusinessConfigOption.HTTP_HOST.getKey()); return host; } - public void setReportHost(String serverAddress) { - config.setOption(ServiceConfigOption.REPORT_HOST.key, serverAddress); + public void setHttpHost(String serverAddress) { + config.setOption(BusinessConfigOption.HTTP_HOST.key, serverAddress); config.saveForUser(); } - public int getReportPort() { - int port = config.getOptionAsInt(ServiceConfigOption.REPORT_PORT.getKey()); + public int getHttpPort() { + int port = config.getOptionAsInt(BusinessConfigOption.HTTP_PORT.getKey()); return port; } - public void setReportPort(int port) { - config.setOption(ServiceConfigOption.REPORT_PORT.key, String.valueOf(port)); + public void setHttpPort(int port) { + config.setOption(BusinessConfigOption.HTTP_PORT.key, String.valueOf(port)); config.saveForUser(); } @@ -291,7 +291,7 @@ public class LimaBusinessConfig { * information for jaxx configuration frame ({@code #type}, * {@code #transientBoolean}, {@code #finalBoolean}...) */ - public enum ServiceConfigOption implements LimaConfigOptionDef { + public enum BusinessConfigOption implements LimaConfigOptionDef { CONFIG_FILE(ApplicationConfig.CONFIG_FILE_NAME, n("lima.configFileName.description"), "lima-business.config", String.class, true, true), @@ -306,8 +306,8 @@ public class LimaBusinessConfig { DATA_DIR("lima.data.dir", n("lima.config.data.dir.description"), "${user.home}/.lima", File.class, false, false), RULES_NATIONALTY("lima.rules", n("lima.config.rulesnationality.description"), FranceAccountingRules.class.getName(), String.class, false, false), - REPORT_HOST("lima.serveraddress", n("lima.config.serveraddress.description"), "localhost", String.class, false, false), - REPORT_PORT("lima.httpport", n("lima.config.httpport.description"), "5462", Integer.class, false, false), + HTTP_HOST("lima.serveraddress", n("lima.config.serveraddress.description"), "localhost", String.class, false, false), + HTTP_PORT("lima.httpport", n("lima.config.httpport.description"), "5462", Integer.class, false, false), SCALE("lima.data.bigDecimal.scale", t("lima.config.scale.label"), n("lima.config.scale.description"), "2", String.class, false, false), CURRENCY("lima.config.currency", t("lima.config.currency.label"), n("lima.config.currency.description"), "false", Boolean.class, false, false), @@ -328,8 +328,8 @@ public class LimaBusinessConfig { private boolean finalBoolean; - ServiceConfigOption(String key, String label, String description, String defaultValue, - Class<?> type, boolean transientBoolean, boolean finalBoolean) { + BusinessConfigOption(String key, String label, String description, String defaultValue, + Class<?> type, boolean transientBoolean, boolean finalBoolean) { this.key = key; this.label = label; this.description = description; @@ -339,8 +339,8 @@ public class LimaBusinessConfig { this.transientBoolean = transientBoolean; } - ServiceConfigOption(String key, String description, String defaultValue, - Class<?> type, boolean transientBoolean, boolean finalBoolean) { + BusinessConfigOption(String key, String description, String defaultValue, + Class<?> type, boolean transientBoolean, boolean finalBoolean) { this(key, null, description, defaultValue, type, transientBoolean, finalBoolean); } diff --git a/lima-business/src/main/java/org/chorem/lima/business/ejb/OptionsServiceImpl.java b/lima-business/src/main/java/org/chorem/lima/business/ejb/OptionsServiceImpl.java index 635bf98..13d10d6 100644 --- a/lima-business/src/main/java/org/chorem/lima/business/ejb/OptionsServiceImpl.java +++ b/lima-business/src/main/java/org/chorem/lima/business/ejb/OptionsServiceImpl.java @@ -74,32 +74,32 @@ public class OptionsServiceImpl extends AbstractLimaService implements OptionsSe @Override public LimaConfigOptionDef getScaleOption() { - return LimaBusinessConfig.ServiceConfigOption.SCALE; + return LimaBusinessConfig.BusinessConfigOption.SCALE; } @Override public LimaConfigOptionDef getCurrencyOption() { - return LimaBusinessConfig.ServiceConfigOption.CURRENCY; + return LimaBusinessConfig.BusinessConfigOption.CURRENCY; } @Override public LimaConfigOptionDef getDecimalSeparatorOption() { - return LimaBusinessConfig.ServiceConfigOption.DECIMAL_SEPARATOR; + return LimaBusinessConfig.BusinessConfigOption.DECIMAL_SEPARATOR; } @Override public LimaConfigOptionDef getThousandSeparatorOption() { - return LimaBusinessConfig.ServiceConfigOption.THOUSAND_SEPARATOR; + return LimaBusinessConfig.BusinessConfigOption.THOUSAND_SEPARATOR; } @Override - public String getLimaReportHost() { - return LimaBusinessConfig.getInstance().getReportHost(); + public String getLimaHttpHost() { + return LimaBusinessConfig.getInstance().getHttpHost(); } @Override - public int getLimaReportPort() { - return LimaBusinessConfig.getInstance().getReportPort(); + public int getLimaHttpPort() { + return LimaBusinessConfig.getInstance().getHttpPort(); } } diff --git a/lima-business/src/test/java/org/chorem/lima/business/LimaMiscTest.java b/lima-business/src/test/java/org/chorem/lima/business/LimaMiscTest.java index 27ef0d5..8ebe9cf 100644 --- a/lima-business/src/test/java/org/chorem/lima/business/LimaMiscTest.java +++ b/lima-business/src/test/java/org/chorem/lima/business/LimaMiscTest.java @@ -41,7 +41,7 @@ public class LimaMiscTest extends AbstractLimaTest { protected Properties getTestConfiguration() { Properties config = super.getTestConfiguration(); - config.setProperty(LimaBusinessConfig.ServiceConfigOption.RULES_NATIONALTY.getKey(), DefaultAccountingRules.class.getName()); + config.setProperty(LimaBusinessConfig.BusinessConfigOption.RULES_NATIONALTY.getKey(), DefaultAccountingRules.class.getName()); return config; } /** diff --git a/lima-business/src/test/java/org/chorem/lima/business/accountingrules/ImportServiceRuleFrTest.java b/lima-business/src/test/java/org/chorem/lima/business/accountingrules/ImportServiceRuleFrTest.java index 8ad9ecf..26e5111 100644 --- a/lima-business/src/test/java/org/chorem/lima/business/accountingrules/ImportServiceRuleFrTest.java +++ b/lima-business/src/test/java/org/chorem/lima/business/accountingrules/ImportServiceRuleFrTest.java @@ -47,7 +47,7 @@ public class ImportServiceRuleFrTest extends AbstractLimaTest { protected Properties getTestConfiguration() { Properties config = super.getTestConfiguration(); - config.setProperty(LimaBusinessConfig.ServiceConfigOption.RULES_NATIONALTY.getKey(), FranceAccountingRules.class.getName()); + config.setProperty(LimaBusinessConfig.BusinessConfigOption.RULES_NATIONALTY.getKey(), FranceAccountingRules.class.getName()); return config; } diff --git a/lima-report/src/main/java/org/chorem/lima/report/LimaReportConfig.java b/lima-report/src/main/java/org/chorem/lima/report/LimaReportConfig.java index dc43493..1bdc932 100644 --- a/lima-report/src/main/java/org/chorem/lima/report/LimaReportConfig.java +++ b/lima-report/src/main/java/org/chorem/lima/report/LimaReportConfig.java @@ -3,7 +3,6 @@ package org.chorem.lima.report; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.LimaTechnicalException; -import org.chorem.lima.business.utils.BigDecimalToString; import org.nuiton.config.ApplicationConfig; import org.nuiton.config.ArgumentsParserException; import org.nuiton.config.ConfigOptionDef; @@ -19,18 +18,20 @@ import static org.nuiton.i18n.I18n.t; /** * Created by davidcosse on 13/03/15. */ -public class LimaReportConfig implements BigDecimalToString.Config { +public class LimaReportConfig { protected static final Log log = LogFactory.getLog(LimaReportConfig.class); + protected static final String DEFAULT_CONFIG_FILE_NAME = "lima-report.config"; + protected ApplicationConfig config; protected static LimaReportConfig instance; private LimaReportConfig(ApplicationConfig config) { try { - ApplicationConfig defaultConfig = new ApplicationConfig(ServiceConfigOption.CONFIG_FILE.getDefaultValue()); - defaultConfig.loadDefaultOptions(ServiceConfigOption.values()); + ApplicationConfig defaultConfig = new ApplicationConfig(DEFAULT_CONFIG_FILE_NAME); + defaultConfig.loadDefaultOptions(ReportConfigOption.values()); defaultConfig.parse(); if (config != null) { @@ -71,41 +72,30 @@ public class LimaReportConfig implements BigDecimalToString.Config { public File getDataDir() { - File datadir = config.getOptionAsFile(ServiceConfigOption.DATA_DIR.getKey()); + File datadir = config.getOptionAsFile(ReportConfigOption.DATA_DIR.getKey()); return datadir; } - public String getAddressServer() { - String serverAddress = config.getOption(ServiceConfigOption.SERVER_ADDRESS.getKey()); - return serverAddress; - } - - public int getHttpPort() { - String httpPort = config.getOption(ServiceConfigOption.HTTP_PORT.getKey()); - Integer port = Integer.valueOf(httpPort); - return port; - } - // ** REPORT PART ** public File getReportsModelDir() { - String reportsDirPath = config.getOption(ServiceConfigOption.REPORTS_MODEL_DIR.key); + String reportsDirPath = config.getOption(ReportConfigOption.REPORTS_MODEL_DIR.key); File result = new File(reportsDirPath); return result; } public void setReportsModelDir(String url) { - config.setOption(ServiceConfigOption.REPORTS_MODEL_DIR.key, url); + config.setOption(ReportConfigOption.REPORTS_MODEL_DIR.key, url); config.saveForUser(); } public String getAccountReportModelPath() { - String vatPDFUrl = config.getOption(ServiceConfigOption.ACCOUNT_DOCUMENT_REPORT_MODEL_PATH.getKey()); + String vatPDFUrl = config.getOption(ReportConfigOption.ACCOUNT_DOCUMENT_REPORT_MODEL_PATH.getKey()); return vatPDFUrl; } public void setAccountReportModelPath(String path) { - config.setOption(ServiceConfigOption.ACCOUNT_DOCUMENT_REPORT_MODEL_PATH.key, path); + config.setOption(ReportConfigOption.ACCOUNT_DOCUMENT_REPORT_MODEL_PATH.key, path); config.saveForUser(); } @@ -137,230 +127,188 @@ public class LimaReportConfig implements BigDecimalToString.Config { URL mainReportBuilderPath = null; switch (documentType) { case ACCOUNT: - mainReportBuilderPath = getReportModelUrl(ServiceConfigOption.ACCOUNT_DOCUMENT_REPORT_MODEL_PATH.getKey()); + mainReportBuilderPath = getReportModelUrl(ReportConfigOption.ACCOUNT_DOCUMENT_REPORT_MODEL_PATH.getKey()); break; case BALANCE: - mainReportBuilderPath = getReportModelUrl(ServiceConfigOption.BALANCE_DOCUMENT_REPORT_MODEL_PATH.key); + mainReportBuilderPath = getReportModelUrl(ReportConfigOption.BALANCE_DOCUMENT_REPORT_MODEL_PATH.key); break; case BALANCE_MAIN_ACCOUNTS: - mainReportBuilderPath = getReportModelUrl(ServiceConfigOption.BALANCE_ACCOUNT_REPORT_MODEL_PATH.key); + mainReportBuilderPath = getReportModelUrl(ReportConfigOption.BALANCE_ACCOUNT_REPORT_MODEL_PATH.key); break; case BALANCE_SUB_ACCOUNTS: - mainReportBuilderPath = getReportModelUrl(ServiceConfigOption.BALANCE_SUB_ACCOUNT_REPORT_MODEL_PATH.key); + mainReportBuilderPath = getReportModelUrl(ReportConfigOption.BALANCE_SUB_ACCOUNT_REPORT_MODEL_PATH.key); break; case ENTRY_BOOKS: - mainReportBuilderPath = getReportModelUrl(ServiceConfigOption.ENTRY_BOOK_DOCUMENT_REPORT_MODEL_PATH.key); + mainReportBuilderPath = getReportModelUrl(ReportConfigOption.ENTRY_BOOK_DOCUMENT_REPORT_MODEL_PATH.key); break; case ENTRY_BOOKS_ENTRY_BOOKS: - mainReportBuilderPath = getReportModelUrl(ServiceConfigOption.ENTRY_BOOK_ENTRY_BOOK_REPORT_MODEL_PATH.key); + mainReportBuilderPath = getReportModelUrl(ReportConfigOption.ENTRY_BOOK_ENTRY_BOOK_REPORT_MODEL_PATH.key); break; case ENTRY_BOOKS_FINANCIAL_PERIODS: - mainReportBuilderPath = getReportModelUrl(ServiceConfigOption.ENTRY_BOOK_FINANCIAL_PERIOD_REPORT_MODEL_PATH.key); + mainReportBuilderPath = getReportModelUrl(ReportConfigOption.ENTRY_BOOK_FINANCIAL_PERIOD_REPORT_MODEL_PATH.key); break; case ENTRY_BOOKS_TRANSACTION: - mainReportBuilderPath = getReportModelUrl(ServiceConfigOption.ENTRY_BOOK_TRANSACTION_REPORT_MODEL_PATH.key); + mainReportBuilderPath = getReportModelUrl(ReportConfigOption.ENTRY_BOOK_TRANSACTION_REPORT_MODEL_PATH.key); break; case GENERAL_ENTRY_BOOK: - mainReportBuilderPath = getReportModelUrl(ServiceConfigOption.GENERAL_ENTRY_BOOK_DOCUMENT_REPORT_MODEL_PATH.key); + mainReportBuilderPath = getReportModelUrl(ReportConfigOption.GENERAL_ENTRY_BOOK_DOCUMENT_REPORT_MODEL_PATH.key); break; case GENERAL_ENTRY_BOOK_GENERAL_ENTRY_BOOKS: - mainReportBuilderPath = getReportModelUrl(ServiceConfigOption.GENERAL_ENTRY_BOOK_REPORT_MODEL_PATH.key); + mainReportBuilderPath = getReportModelUrl(ReportConfigOption.GENERAL_ENTRY_BOOK_REPORT_MODEL_PATH.key); break; case GENERAL_ENTRY_BOOK_ENTRIES: - mainReportBuilderPath = getReportModelUrl(ServiceConfigOption.GENERAL_ENTRY_BOOK_ENTRY_REPORT_MODEL_PATH.key); + mainReportBuilderPath = getReportModelUrl(ReportConfigOption.GENERAL_ENTRY_BOOK_ENTRY_REPORT_MODEL_PATH.key); break; case LEDGER: - mainReportBuilderPath = getReportModelUrl(ServiceConfigOption.GENERAL_LEDGER_DOCUMENT_REPORT_MODEL_PATH.key); + mainReportBuilderPath = getReportModelUrl(ReportConfigOption.GENERAL_LEDGER_DOCUMENT_REPORT_MODEL_PATH.key); break; case LEDGER_GENERAL_LEDGERS: - mainReportBuilderPath = getReportModelUrl(ServiceConfigOption.GENERAL_LEDGER_MODEL_PATH.key); + mainReportBuilderPath = getReportModelUrl(ReportConfigOption.GENERAL_LEDGER_MODEL_PATH.key); break; case LEDGER_ENTRIES: - mainReportBuilderPath = getReportModelUrl(ServiceConfigOption.GENERAL_LEDGER_ENTRY_MODEL_PATH.key); + mainReportBuilderPath = getReportModelUrl(ReportConfigOption.GENERAL_LEDGER_ENTRY_MODEL_PATH.key); break; } return mainReportBuilderPath; } public void setBalanceDocumentReportModelPath(String path) { - config.setOption(ServiceConfigOption.BALANCE_DOCUMENT_REPORT_MODEL_PATH.key, path); + config.setOption(ReportConfigOption.BALANCE_DOCUMENT_REPORT_MODEL_PATH.key, path); config.saveForUser(); } public String getBalanceAccountReportModelPath() { - String result = config.getOption(ServiceConfigOption.BALANCE_ACCOUNT_REPORT_MODEL_PATH.getKey()); + String result = config.getOption(ReportConfigOption.BALANCE_ACCOUNT_REPORT_MODEL_PATH.getKey()); return result; } public void setBalanceAccountReportModelPath(String path) { - config.setOption(ServiceConfigOption.BALANCE_ACCOUNT_REPORT_MODEL_PATH.key, path); + config.setOption(ReportConfigOption.BALANCE_ACCOUNT_REPORT_MODEL_PATH.key, path); config.saveForUser(); } public String getBalanceSubAccountReportModelPath() { - String result = config.getOption(ServiceConfigOption.BALANCE_SUB_ACCOUNT_REPORT_MODEL_PATH.getKey()); + String result = config.getOption(ReportConfigOption.BALANCE_SUB_ACCOUNT_REPORT_MODEL_PATH.getKey()); return result; } public void setBalanceSubAccountReportModelPath(String path) { - config.setOption(ServiceConfigOption.BALANCE_SUB_ACCOUNT_REPORT_MODEL_PATH.key, path); + config.setOption(ReportConfigOption.BALANCE_SUB_ACCOUNT_REPORT_MODEL_PATH.key, path); config.saveForUser(); } public String getEntryBookDocumentReportModelPath() { - String result = config.getOption(ServiceConfigOption.ENTRY_BOOK_DOCUMENT_REPORT_MODEL_PATH.getKey()); + String result = config.getOption(ReportConfigOption.ENTRY_BOOK_DOCUMENT_REPORT_MODEL_PATH.getKey()); return result; } public void setEntryBookDocumentReportModelPath(String path) { - config.setOption(ServiceConfigOption.ENTRY_BOOK_DOCUMENT_REPORT_MODEL_PATH.key, path); + config.setOption(ReportConfigOption.ENTRY_BOOK_DOCUMENT_REPORT_MODEL_PATH.key, path); config.saveForUser(); } public String getEntryBookEntryBookReportModelPath() { - String result = config.getOption(ServiceConfigOption.ENTRY_BOOK_ENTRY_BOOK_REPORT_MODEL_PATH.getKey()); + String result = config.getOption(ReportConfigOption.ENTRY_BOOK_ENTRY_BOOK_REPORT_MODEL_PATH.getKey()); return result; } public void setEntryBookEntryBookReportModelPath(String path) { - config.setOption(ServiceConfigOption.ENTRY_BOOK_ENTRY_BOOK_REPORT_MODEL_PATH.key, path); + config.setOption(ReportConfigOption.ENTRY_BOOK_ENTRY_BOOK_REPORT_MODEL_PATH.key, path); config.saveForUser(); } public String getEntryBookFinancialPeriodReportModelPath() { - String result = config.getOption(ServiceConfigOption.ENTRY_BOOK_FINANCIAL_PERIOD_REPORT_MODEL_PATH.getKey()); + String result = config.getOption(ReportConfigOption.ENTRY_BOOK_FINANCIAL_PERIOD_REPORT_MODEL_PATH.getKey()); return result; } public void setEntryBookFinancialPeriodReportModelPath(String path) { - config.setOption(ServiceConfigOption.ENTRY_BOOK_FINANCIAL_PERIOD_REPORT_MODEL_PATH.key, path); + config.setOption(ReportConfigOption.ENTRY_BOOK_FINANCIAL_PERIOD_REPORT_MODEL_PATH.key, path); config.saveForUser(); } public String getEntryBookTransactionReportModelPath() { - String result = config.getOption(ServiceConfigOption.ENTRY_BOOK_TRANSACTION_REPORT_MODEL_PATH.getKey()); + String result = config.getOption(ReportConfigOption.ENTRY_BOOK_TRANSACTION_REPORT_MODEL_PATH.getKey()); return result; } public void setEntryBookTransactionReportModelPath(String path) { - config.setOption(ServiceConfigOption.ENTRY_BOOK_TRANSACTION_REPORT_MODEL_PATH.key, path); + config.setOption(ReportConfigOption.ENTRY_BOOK_TRANSACTION_REPORT_MODEL_PATH.key, path); config.saveForUser(); } public String getGeneralEntryBookDocumentReportModelPath() { - String result = config.getOption(ServiceConfigOption.GENERAL_ENTRY_BOOK_DOCUMENT_REPORT_MODEL_PATH.getKey()); + String result = config.getOption(ReportConfigOption.GENERAL_ENTRY_BOOK_DOCUMENT_REPORT_MODEL_PATH.getKey()); return result; } public void setGeneralEntryBookDocumentReportModelPath(String path) { - config.setOption(ServiceConfigOption.GENERAL_ENTRY_BOOK_DOCUMENT_REPORT_MODEL_PATH.key, path); + config.setOption(ReportConfigOption.GENERAL_ENTRY_BOOK_DOCUMENT_REPORT_MODEL_PATH.key, path); config.saveForUser(); } public String getGeneralEntryBookReportModelPath() { - String result = config.getOption(ServiceConfigOption.GENERAL_ENTRY_BOOK_REPORT_MODEL_PATH.getKey()); + String result = config.getOption(ReportConfigOption.GENERAL_ENTRY_BOOK_REPORT_MODEL_PATH.getKey()); return result; } public void setGeneralEntryBookReportModelPath(String path) { - config.setOption(ServiceConfigOption.GENERAL_ENTRY_BOOK_REPORT_MODEL_PATH.key, path); + config.setOption(ReportConfigOption.GENERAL_ENTRY_BOOK_REPORT_MODEL_PATH.key, path); config.saveForUser(); } public String getGeneralEntryBookEntryReportModelPath() { - String result = config.getOption(ServiceConfigOption.GENERAL_ENTRY_BOOK_ENTRY_REPORT_MODEL_PATH.getKey()); + String result = config.getOption(ReportConfigOption.GENERAL_ENTRY_BOOK_ENTRY_REPORT_MODEL_PATH.getKey()); return result; } public void setGeneralEntryBookEntryReportModelPath(String path) { - config.setOption(ServiceConfigOption.GENERAL_ENTRY_BOOK_ENTRY_REPORT_MODEL_PATH.key, path); + config.setOption(ReportConfigOption.GENERAL_ENTRY_BOOK_ENTRY_REPORT_MODEL_PATH.key, path); config.saveForUser(); } public String getGeneralLedgerDocumentReportModelPath() { - String result = config.getOption(ServiceConfigOption. + String result = config.getOption(ReportConfigOption. GENERAL_LEDGER_DOCUMENT_REPORT_MODEL_PATH.getKey()); return result; } public void setGeneralLedgerDocumentReportModelPath(String path) { - config.setOption(ServiceConfigOption. + config.setOption(ReportConfigOption. GENERAL_LEDGER_DOCUMENT_REPORT_MODEL_PATH.key, path); config.saveForUser(); } public String getGeneralLedgerModelPath() { - String result = config.getOption(ServiceConfigOption. + String result = config.getOption(ReportConfigOption. GENERAL_LEDGER_MODEL_PATH.getKey()); return result; } public void setGeneralLedgerModelPath(String path) { - config.setOption(ServiceConfigOption. + config.setOption(ReportConfigOption. GENERAL_LEDGER_MODEL_PATH.key, path); config.saveForUser(); } public String getGeneralLedgerEntryModelPath() { - String result = config.getOption(ServiceConfigOption. + String result = config.getOption(ReportConfigOption. GENERAL_LEDGER_ENTRY_MODEL_PATH.getKey()); return result; } public void setGeneralLedgerEntryModelPath(String path) { - config.setOption(ServiceConfigOption. + config.setOption(ReportConfigOption. GENERAL_LEDGER_ENTRY_MODEL_PATH.key, path); config.saveForUser(); } - public int getScale() { - return config.getOptionAsInt(ServiceConfigOption.SCALE.key); - } - - public void setScale(String locale) { - config.setOption(ServiceConfigOption.SCALE.key, locale); - config.saveForUser(); - } - - public boolean getCurrency() { - return config.getOptionAsBoolean(ServiceConfigOption.CURRENCY.key); - } - - public void setCurrency(String locale) { - config.setOption(ServiceConfigOption.CURRENCY.key, locale); - config.saveForUser(); - } - - public char getDecimalSeparator() { - char decimalSeparator = config.getOption(ServiceConfigOption.DECIMAL_SEPARATOR.key).charAt(0); - return decimalSeparator; - } - - public void setDecimalSeparator(String locale) { - config.setOption(ServiceConfigOption.DECIMAL_SEPARATOR.key, locale); - config.saveForUser(); - } - - public char getThousandSeparator() { - return config.getOption(ServiceConfigOption.THOUSAND_SEPARATOR.key).charAt(0); - } - - public void setThousandSeparator(String locale) { - config.setOption(ServiceConfigOption.THOUSAND_SEPARATOR.key, locale); - config.saveForUser(); - } - - - public enum ServiceConfigOption implements ConfigOptionDef { - - CONFIG_FILE(ApplicationConfig.CONFIG_FILE_NAME, n("lima.configFileName.description"), "lima-report.config", String.class, true, true), + public enum ReportConfigOption implements ConfigOptionDef { DATA_DIR("lima.data.dir", n("lima.config.data.dir.description"), "${user.home}/.lima", File.class, false, false), - HTTP_PORT("lima.httpport", n("lima.config.httpport.description"), "5462", String.class, false, false), - SERVER_ADDRESS("lima.serveraddress", n("lima.config.serveraddress.description"), "localhost", String.class, false, false), REPORTS_MODEL_DIR("lima.reports.dir",n("lima.config.reports.dir.description"),"${lima.data.dir}/reports", File.class, false, false), @@ -381,12 +329,7 @@ public class LimaReportConfig implements BigDecimalToString.Config { GENERAL_LEDGER_DOCUMENT_REPORT_MODEL_PATH("lima.config.documentReport.generalLedger.documentReportModelPath", n("lima.config.documentReport.generalLedger.documentReportModelPath.description"), "/jasperreports/generalLedger/DocumentReport.jrxml", String.class, false, false), GENERAL_LEDGER_MODEL_PATH("lima.config.documentReport.generalLedger.generalLedgerModelPath", n("lima.config.documentReport.generalLedger.generalLedgerModelPath.description"), "/jasperreports/generalLedger/GeneralLedgerReport.jrxml", String.class, false, false), - GENERAL_LEDGER_ENTRY_MODEL_PATH("lima.config.documentReport.generalLedger.generalLedgerEntryModelPath", n("lima.config.documentReport.generalLedger.generalLedgerEntryModelPath.description"), "/jasperreports/generalLedger/GeneralLedgerEntryReport.jrxml", String.class, false, false), - - SCALE("lima.scale", n("lima.config.scale.description"), "2", String.class, false, false), // FIXME AThimel 16/03/15 This should be the same as lima-swing module - CURRENCY("lima.config.currency", "", "false", Boolean.class, false, false), // FIXME AThimel 16/03/15 This should be the same as lima-swing module - DECIMAL_SEPARATOR("lima.data.bigDecimal.decimalSeparator", "", ",", Character.class, false, false), // FIXME AThimel 16/03/15 This should be the same as lima-swing module - THOUSAND_SEPARATOR("lima.thousandSeparator", "", " ", Character.class, false, false); // FIXME AThimel 16/03/15 This should be the same as lima-swing module + GENERAL_LEDGER_ENTRY_MODEL_PATH("lima.config.documentReport.generalLedger.generalLedgerEntryModelPath", n("lima.config.documentReport.generalLedger.generalLedgerEntryModelPath.description"), "/jasperreports/generalLedger/GeneralLedgerEntryReport.jrxml", String.class, false, false); private final String key; @@ -400,8 +343,8 @@ public class LimaReportConfig implements BigDecimalToString.Config { private boolean finalBoolean; - ServiceConfigOption(String key, String description, String defaultValue, - Class<?> type, boolean transientBoolean, boolean finalBoolean) { + ReportConfigOption(String key, String description, String defaultValue, + Class<?> type, boolean transientBoolean, boolean finalBoolean) { this.key = key; this.description = description; this.defaultValue = defaultValue; diff --git a/lima-report/src/main/java/org/chorem/lima/report/service/DocumentService.java b/lima-report/src/main/java/org/chorem/lima/report/service/DocumentService.java index 32eea02..1fc3395 100644 --- a/lima-report/src/main/java/org/chorem/lima/report/service/DocumentService.java +++ b/lima-report/src/main/java/org/chorem/lima/report/service/DocumentService.java @@ -38,6 +38,7 @@ import org.chorem.lima.business.api.EntryService; import org.chorem.lima.business.api.FinancialPeriodService; import org.chorem.lima.business.api.FinancialStatementService; import org.chorem.lima.business.api.IdentityService; +import org.chorem.lima.business.api.OptionsService; import org.chorem.lima.business.api.ReportService; import org.chorem.lima.business.api.report.BalanceReportService; import org.chorem.lima.business.api.report.GeneralEntryBookReportService; @@ -541,7 +542,8 @@ public class DocumentService { protected DecimalFormat getDecimalFormat() { if (decimalFormat == null) { - decimalFormat = BigDecimalToString.newDecimalFormat(LimaReportConfig.getInstance()); + OptionsService optionsService = LimaServiceFactory.getService(OptionsService.class); + decimalFormat = BigDecimalToString.newDecimalFormat(optionsService); } return decimalFormat; } diff --git a/lima-server/src/main/java/org.chorem.lima/LimaServer.java b/lima-server/src/main/java/org.chorem.lima/LimaServer.java index fd76fc1..04c716d 100644 --- a/lima-server/src/main/java/org.chorem.lima/LimaServer.java +++ b/lima-server/src/main/java/org.chorem.lima/LimaServer.java @@ -90,20 +90,25 @@ public class LimaServer { } } - public static void launch(ApplicationConfig config) { + public static void launch(ApplicationConfig moduleConfig) { - // push all configs - LimaServerConfig.getInstance(config); - ApplicationConfig serverConfig = LimaServerConfig.getInstance().getConfig(); - LimaBusinessConfig.getInstance(serverConfig); - ApplicationConfig businessConfig = LimaBusinessConfig.getInstance().getConfig(); - LimaReportConfig.getInstance(businessConfig); + boolean mustStartServer = StringUtils.isBlank(moduleConfig.getOption(Context.PROVIDER_URL)) || + moduleConfig.getOptionAsBoolean("openejb.embedded.remotable"); - // start EJB container - LimaServiceFactory.initFactory(businessConfig); + ApplicationConfig initConfig = moduleConfig; + + if (mustStartServer) { + // push all configs + initConfig = LimaServerConfig.getInstance(initConfig).getConfig(); + initConfig = LimaBusinessConfig.getInstance(initConfig).getConfig(); + initConfig = LimaReportConfig.getInstance(initConfig).getConfig(); + } + + // start EJB container (either local or remote) + LimaServiceFactory.initFactory(initConfig); // start web server only if it's on server mode - if (StringUtils.isBlank(businessConfig.getOption(Context.PROVIDER_URL)) || Boolean.valueOf(serverConfig.getOption("openejb.embedded.remotable"))) { + if (mustStartServer) { httpServerService = new HttpServerService(); httpServerService.start(); } @@ -112,4 +117,5 @@ public class LimaServer { public static HttpServerService getHttpServerService() { return httpServerService; } + } diff --git a/lima-server/src/main/java/org.chorem.lima/server/HttpServerService.java b/lima-server/src/main/java/org.chorem.lima/server/HttpServerService.java index 6daf877..e0002f8 100644 --- a/lima-server/src/main/java/org.chorem.lima/server/HttpServerService.java +++ b/lima-server/src/main/java/org.chorem.lima/server/HttpServerService.java @@ -73,8 +73,8 @@ public class HttpServerService { //protected String path; - protected String limaReportHost; - protected int limaReportPort; + protected String limaHttpHost; + protected int limaHttpPort; private static final SimpleDateFormat DATEFORMAT = new SimpleDateFormat("yyyy-MM-dd"); @@ -85,8 +85,8 @@ public class HttpServerService { OptionsService optionsService = LimaServiceFactory.getService(OptionsService.class); accountService = LimaServiceFactory.getService(AccountService.class); - limaReportHost = optionsService.getLimaReportHost(); - limaReportPort = optionsService.getLimaReportPort(); + limaHttpHost = optionsService.getLimaHttpHost(); + limaHttpPort = optionsService.getLimaHttpPort(); documentService = new DocumentService(); reportBuilder = new ReportBuilder(); } @@ -99,7 +99,7 @@ public class HttpServerService { FileUtil.createDirectoryIfNecessary(reportDir); - server = new Server(limaReportPort); + server = new Server(limaHttpPort); ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS); context.setContextPath("/"); @@ -108,7 +108,7 @@ public class HttpServerService { server.start(); if (log.isInfoEnabled()) { - log.info("Web server running on port: " + limaReportPort); + log.info("Web server running on port: " + limaHttpPort); } } catch (Exception eee) { @@ -118,7 +118,7 @@ public class HttpServerService { } public int getHttpPort() { - return limaReportPort; + return limaHttpPort; } /** @@ -225,10 +225,10 @@ public class HttpServerService { log.info("Page load"); /** create server Address : static config if exist or dynamical adress */ - if (limaReportHost.equals("")) { + if (limaHttpHost.equals("")) { serverAddress += req.getServerName() + ":" + req.getServerPort(); } else { - serverAddress += limaReportHost + ":" + getHttpPort(); + serverAddress += limaHttpHost + ":" + getHttpPort(); } Calendar calendar = Calendar.getInstance(); diff --git a/lima-server/src/main/java/org.chorem.lima/server/LimaServerConfig.java b/lima-server/src/main/java/org.chorem.lima/server/LimaServerConfig.java index afea90b..7d1936c 100644 --- a/lima-server/src/main/java/org.chorem.lima/server/LimaServerConfig.java +++ b/lima-server/src/main/java/org.chorem.lima/server/LimaServerConfig.java @@ -5,16 +5,13 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.openejb.core.LocalInitialContextFactory; import org.chorem.lima.LimaTechnicalException; -import org.chorem.lima.business.accountingrules.FranceAccountingRules; -import org.chorem.lima.report.DocumentReportTypes; import org.nuiton.config.ApplicationConfig; import org.nuiton.config.ArgumentsParserException; import org.nuiton.config.ConfigOptionDef; import javax.naming.Context; + import java.io.File; -import java.net.MalformedURLException; -import java.net.URL; import java.util.Properties; import static org.nuiton.i18n.I18n.n; @@ -31,10 +28,12 @@ public class LimaServerConfig { protected static LimaServerConfig instance; + public static final String DEFAULT_CONFIG_FILE_NAME = "lima-server.config"; + private LimaServerConfig(String configFileName) { try { - ApplicationConfig defaultConfig = new ApplicationConfig(ServiceConfigOption.CONFIG_FILE.getDefaultValue()); - defaultConfig.loadDefaultOptions(ServiceConfigOption.values()); + ApplicationConfig defaultConfig = new ApplicationConfig(DEFAULT_CONFIG_FILE_NAME); + defaultConfig.loadDefaultOptions(ServerConfigOption.values()); defaultConfig.parse(); if (StringUtils.isNotBlank(configFileName)) { @@ -57,14 +56,14 @@ public class LimaServerConfig { private LimaServerConfig(final ApplicationConfig config) { try { - ApplicationConfig defaultConfig = new ApplicationConfig(ServiceConfigOption.CONFIG_FILE.getDefaultValue()); - defaultConfig.loadDefaultOptions(ServiceConfigOption.values()); + ApplicationConfig defaultConfig = new ApplicationConfig(DEFAULT_CONFIG_FILE_NAME); + defaultConfig.loadDefaultOptions(ServerConfigOption.values()); defaultConfig.parse(); if (config != null) { Properties flatOptions = defaultConfig.getFlatOptions(); flatOptions.putAll(config.getFlatOptions(true)); - this.config = new ApplicationConfig(flatOptions, ServiceConfigOption.CONFIG_FILE.getDefaultValue()); + this.config = new ApplicationConfig(flatOptions, DEFAULT_CONFIG_FILE_NAME); this.config.parse(); } else { if (log.isWarnEnabled()) { @@ -104,306 +103,21 @@ public class LimaServerConfig { return config.getFlatOptions(); } - - public File getDataDir() { - File dataDir = config.getOptionAsFile(ServiceConfigOption.DATA_DIR.getKey()); - return dataDir; - } - - public String getVatPDFUrl() { - String vatPDFUrl = config.getOption(ServiceConfigOption.VAT_PDF_URL.getKey()); - return vatPDFUrl; - } - - public void setVatPDFUrl(String url) { - config.setOption(ServiceConfigOption.VAT_PDF_URL.key, url); - config.saveForUser(); - } - - // ** REPORT PART ** - public File getReportsModelDir() { - String reportsDirPath = config.getOption(ServiceConfigOption.REPORTS_MODEL_DIR.key); - File result = new File(reportsDirPath); - return result; - } - - public void setReportsModelDir(String url) { - config.setOption(ServiceConfigOption.REPORTS_MODEL_DIR.key, url); - config.saveForUser(); - } - - public String getAccountReportModelPath() { - String vatPDFUrl = config.getOption(ServiceConfigOption.ACCOUNT_DOCUMENT_REPORT_MODEL_PATH.getKey()); - return vatPDFUrl; - } - - public void setAccountReportModelPath(String path) { - config.setOption(ServiceConfigOption.ACCOUNT_DOCUMENT_REPORT_MODEL_PATH.key, path); - config.saveForUser(); - } - - protected URL getReportModelUrl(String documentReportKey) { - - String optionValue = config.getOption(documentReportKey); - File file = new File(optionValue); - - URL result; - if (file.exists()) { - try { - result = file.toURI().toURL(); - } catch (MalformedURLException e) { - throw new LimaTechnicalException("Could not get url of file: "+file); - } - } else { - result = getClass().getResource(optionValue); - } - - if (result == null) { - throw new LimaTechnicalException(String.format("Could not find option: %s", documentReportKey)); - } - - return result; - - } - - public URL getReportModelUrl(DocumentReportTypes documentType) { - URL mainReportBuilderPath = null; - switch (documentType) { - case ACCOUNT: - mainReportBuilderPath = getReportModelUrl(ServiceConfigOption.ACCOUNT_DOCUMENT_REPORT_MODEL_PATH.getKey()); - break; - - case BALANCE: - mainReportBuilderPath = getReportModelUrl(ServiceConfigOption.BALANCE_DOCUMENT_REPORT_MODEL_PATH.key); - break; - case BALANCE_MAIN_ACCOUNTS: - mainReportBuilderPath = getReportModelUrl(ServiceConfigOption.BALANCE_ACCOUNT_REPORT_MODEL_PATH.key); - break; - case BALANCE_SUB_ACCOUNTS: - mainReportBuilderPath = getReportModelUrl(ServiceConfigOption.BALANCE_SUB_ACCOUNT_REPORT_MODEL_PATH.key); - break; - - case ENTRY_BOOKS: - mainReportBuilderPath = getReportModelUrl(ServiceConfigOption.ENTRY_BOOK_DOCUMENT_REPORT_MODEL_PATH.key); - break; - case ENTRY_BOOKS_ENTRY_BOOKS: - mainReportBuilderPath = getReportModelUrl(ServiceConfigOption.ENTRY_BOOK_ENTRY_BOOK_REPORT_MODEL_PATH.key); - break; - case ENTRY_BOOKS_FINANCIAL_PERIODS: - mainReportBuilderPath = getReportModelUrl(ServiceConfigOption.ENTRY_BOOK_FINANCIAL_PERIOD_REPORT_MODEL_PATH.key); - break; - case ENTRY_BOOKS_TRANSACTION: - mainReportBuilderPath = getReportModelUrl(ServiceConfigOption.ENTRY_BOOK_TRANSACTION_REPORT_MODEL_PATH.key); - break; - - case GENERAL_ENTRY_BOOK: - mainReportBuilderPath = getReportModelUrl(ServiceConfigOption.GENERAL_ENTRY_BOOK_DOCUMENT_REPORT_MODEL_PATH.key); - break; - case GENERAL_ENTRY_BOOK_GENERAL_ENTRY_BOOKS: - mainReportBuilderPath = getReportModelUrl(ServiceConfigOption.GENERAL_ENTRY_BOOK_REPORT_MODEL_PATH.key); - break; - case GENERAL_ENTRY_BOOK_ENTRIES: - mainReportBuilderPath = getReportModelUrl(ServiceConfigOption.GENERAL_ENTRY_BOOK_ENTRY_REPORT_MODEL_PATH.key); - break; - - case LEDGER: - mainReportBuilderPath = getReportModelUrl(ServiceConfigOption.GENERAL_LEDGER_DOCUMENT_REPORT_MODEL_PATH.key); - break; - case LEDGER_GENERAL_LEDGERS: - mainReportBuilderPath = getReportModelUrl(ServiceConfigOption.GENERAL_LEDGER_MODEL_PATH.key); - break; - case LEDGER_ENTRIES: - mainReportBuilderPath = getReportModelUrl(ServiceConfigOption.GENERAL_LEDGER_ENTRY_MODEL_PATH.key); - break; - } - return mainReportBuilderPath; - } - - public void setBalanceDocumentReportModelPath(String path) { - config.setOption(ServiceConfigOption.BALANCE_DOCUMENT_REPORT_MODEL_PATH.key, path); - config.saveForUser(); - } - - public String getBalanceAccountReportModelPath() { - String result = config.getOption(ServiceConfigOption.BALANCE_ACCOUNT_REPORT_MODEL_PATH.getKey()); - return result; - } - - public void setBalanceAccountReportModelPath(String path) { - config.setOption(ServiceConfigOption.BALANCE_ACCOUNT_REPORT_MODEL_PATH.key, path); - config.saveForUser(); - } - - public String getBalanceSubAccountReportModelPath() { - String result = config.getOption(ServiceConfigOption.BALANCE_SUB_ACCOUNT_REPORT_MODEL_PATH.getKey()); - return result; - } - - public void setBalanceSubAccountReportModelPath(String path) { - config.setOption(ServiceConfigOption.BALANCE_SUB_ACCOUNT_REPORT_MODEL_PATH.key, path); - config.saveForUser(); - } - - public String getEntryBookDocumentReportModelPath() { - String result = config.getOption(ServiceConfigOption.ENTRY_BOOK_DOCUMENT_REPORT_MODEL_PATH.getKey()); - return result; - } - - public void setEntryBookDocumentReportModelPath(String path) { - config.setOption(ServiceConfigOption.ENTRY_BOOK_DOCUMENT_REPORT_MODEL_PATH.key, path); - config.saveForUser(); - } - public String getEntryBookEntryBookReportModelPath() { - String result = config.getOption(ServiceConfigOption.ENTRY_BOOK_ENTRY_BOOK_REPORT_MODEL_PATH.getKey()); - return result; + return config.getOptionAsFile(ServerConfigOption.REPORTS_MODEL_DIR.getKey()); } - public void setEntryBookEntryBookReportModelPath(String path) { - config.setOption(ServiceConfigOption.ENTRY_BOOK_ENTRY_BOOK_REPORT_MODEL_PATH.key, path); - config.saveForUser(); - } - - public String getEntryBookFinancialPeriodReportModelPath() { - String result = config.getOption(ServiceConfigOption.ENTRY_BOOK_FINANCIAL_PERIOD_REPORT_MODEL_PATH.getKey()); - return result; - } - - public void setEntryBookFinancialPeriodReportModelPath(String path) { - config.setOption(ServiceConfigOption.ENTRY_BOOK_FINANCIAL_PERIOD_REPORT_MODEL_PATH.key, path); - config.saveForUser(); - } - - public String getEntryBookTransactionReportModelPath() { - String result = config.getOption(ServiceConfigOption.ENTRY_BOOK_TRANSACTION_REPORT_MODEL_PATH.getKey()); - return result; - } - - public void setEntryBookTransactionReportModelPath(String path) { - config.setOption(ServiceConfigOption.ENTRY_BOOK_TRANSACTION_REPORT_MODEL_PATH.key, path); - config.saveForUser(); - } - - public String getGeneralEntryBookDocumentReportModelPath() { - String result = config.getOption(ServiceConfigOption.GENERAL_ENTRY_BOOK_DOCUMENT_REPORT_MODEL_PATH.getKey()); - return result; - } - - public void setGeneralEntryBookDocumentReportModelPath(String path) { - config.setOption(ServiceConfigOption.GENERAL_ENTRY_BOOK_DOCUMENT_REPORT_MODEL_PATH.key, path); - config.saveForUser(); - } - - public String getGeneralEntryBookReportModelPath() { - String result = config.getOption(ServiceConfigOption.GENERAL_ENTRY_BOOK_REPORT_MODEL_PATH.getKey()); - return result; - } - - public void setGeneralEntryBookReportModelPath(String path) { - config.setOption(ServiceConfigOption.GENERAL_ENTRY_BOOK_REPORT_MODEL_PATH.key, path); - config.saveForUser(); - } - - public String getGeneralEntryBookEntryReportModelPath() { - String result = config.getOption(ServiceConfigOption.GENERAL_ENTRY_BOOK_ENTRY_REPORT_MODEL_PATH.getKey()); - return result; - } - - public void setGeneralEntryBookEntryReportModelPath(String path) { - config.setOption(ServiceConfigOption.GENERAL_ENTRY_BOOK_ENTRY_REPORT_MODEL_PATH.key, path); - config.saveForUser(); - } - - public String getGeneralLedgerDocumentReportModelPath() { - String result = config.getOption(ServiceConfigOption. - GENERAL_LEDGER_DOCUMENT_REPORT_MODEL_PATH.getKey()); - return result; - } - - public void setGeneralLedgerDocumentReportModelPath(String path) { - config.setOption(ServiceConfigOption. - GENERAL_LEDGER_DOCUMENT_REPORT_MODEL_PATH.key, path); - config.saveForUser(); - } - - public String getGeneralLedgerModelPath() { - String result = config.getOption(ServiceConfigOption. - GENERAL_LEDGER_MODEL_PATH.getKey()); - return result; - } - - public void setGeneralLedgerModelPath(String path) { - config.setOption(ServiceConfigOption. - GENERAL_LEDGER_MODEL_PATH.key, path); - config.saveForUser(); - } - - public String getGeneralLedgerEntryModelPath() { - String result = config.getOption(ServiceConfigOption. - GENERAL_LEDGER_ENTRY_MODEL_PATH.getKey()); - return result; - } - - public void setGeneralLedgerEntryModelPath(String path) { - config.setOption(ServiceConfigOption. - GENERAL_LEDGER_ENTRY_MODEL_PATH.key, path); - config.saveForUser(); - } - public String getHostAddress() { - String result = config.getOption(ServiceConfigOption. - LIMA_HOST_ADDRESS.getKey()); - return result; - } - - public enum ServiceConfigOption implements ConfigOptionDef { + public enum ServerConfigOption implements ConfigOptionDef { EJB_INITIAL_CONTEXT_FACTORY(Context.INITIAL_CONTEXT_FACTORY, "", LocalInitialContextFactory.class.getName(), String.class, false, true), - EJB_REMOTABLE("openejb.embedded.remotable", "", "true", String.class, false, true), - EJB_PORT("ejbd.port", "", "4202", String.class, false, false), + EJB_REMOTABLE("openejb.embedded.remotable", "", "true", Boolean.class, false, true), + EJB_PORT("ejbd.port", "", "4202", Integer.class, false, false), EJB_BIND("ejbd.bind", "", "0.0.0.0", String.class, false, false), - CONFIG_FILE(ApplicationConfig.CONFIG_FILE_NAME, n("lima.configFileName.description"), "lima-server.config", String.class, true, true), - - DB_DIALECT("hibernate.dialect","", "org.hibernate.dialect.H2Dialect", String.class, false, false), - DB_USER_NAME("hibernate.connection.username","", "sa", String.class, false, false), - DB_PASSWORD("hibernate.connection.password","", "", String.class, false, false), - DB_DRIVER("hibernate.connection.driver_class","", "org.h2.Driver", String.class, false, false), - DB_URL("hibernate.connection.url","", "jdbc:h2:file:${lima.data.dir}/limadb", String.class, false, false), - DB_BATCH_SIZE("hibernate.jdbc.batch_size","", "50", String.class, false, false), - - APPLICATION_VERSION("application.version", n("application.version"), null, String.class, false, false), DATA_DIR("lima.data.dir", n("lima.config.data.dir.description"), "${user.home}/.lima", File.class, false, false), - RULES_NATIONALTY("lima.rules", n("lima.config.rulesnationality.description"), FranceAccountingRules.class.getName(), String.class, false, false), - VAT_PDF_URL("lima.report.vatpdfurl", n("lima.config.reportvatpdfurl.description"), "default", String.class, false, false), - - REPORTS_MODEL_DIR("lima.reports.dir",n("lima.config.reports.dir.description"),"${lima.data.dir}/reports", File.class, false, false), - - ACCOUNT_DOCUMENT_REPORT_MODEL_PATH("lima.config.documentReport.account.documentReportModelPath", n("lima.config.documentReport.account.documentReportModelPath.description"), "/jasperreports/accounts/DocumentReport.jrxml",String.class, false, false), - - BALANCE_DOCUMENT_REPORT_MODEL_PATH("lima.config.documentReport.balance.documentReportModelPath", n("lima.config.documentReport.balance.documentReportModelPath.description"), "/jasperreports/balance/DocumentReport.jrxml", String.class, false, false), - BALANCE_ACCOUNT_REPORT_MODEL_PATH("lima.config.documentReport.balance.balanceAccountReportModelPath", n("lima.config.documentReport.balance.balanceAccountReportModelPath.description"), "/jasperreports/balance/BalanceReportAccountReport.jrxml", String.class, false, false), - BALANCE_SUB_ACCOUNT_REPORT_MODEL_PATH("lima.config.documentReport.balance.balanceSubAccountReportModelPath", n("lima.config.documentReport.balance.balanceSubAccountReportModelPath.description"), "/jasperreports/balance/BalanceSubAccountsReport.jrxml", String.class, false, false), - - GENERAL_ENTRY_BOOK_DOCUMENT_REPORT_MODEL_PATH("lima.config.documentReport.generalEntrybook.documentReportModelPath", n("lima.config.documentReport.generalEntrybook.documentReportModelPath.description"), "/jasperreports/generalEntryBook/DocumentReport.jrxml", String.class, false, false), - GENERAL_ENTRY_BOOK_REPORT_MODEL_PATH("lima.config.documentReport.generalEntrybook.generalEntryBookModelPath", n("lima.config.documentReport.generalEntrybook.generalEntryBookModelPath.description"), "/jasperreports/generalEntryBook/EntryBookPeriodReport.jrxml", String.class, false, false), - GENERAL_ENTRY_BOOK_ENTRY_REPORT_MODEL_PATH("lima.config.documentReport.generalEntrybook.generalEntryBookEntryModelPath", n("blima.config.documentReport.generalEntrybook.generalEntryBookEntryModelPath.description"), "/jasperreports/generalEntryBook/GeneralEntryBookEntryReport.jrxml", String.class, false, false), - - ENTRY_BOOK_DOCUMENT_REPORT_MODEL_PATH("lima.config.documentReport.entrybook.documentReportModelPath", n("lima.config.documentReport.entrybook.documentReportModelPath.description"), "/jasperreports/entryBook/DocumentReport.jrxml", String.class, false, false), - ENTRY_BOOK_ENTRY_BOOK_REPORT_MODEL_PATH("lima.config.documentReport.entrybook.entryBookModelPath", n("lima.config.documentReport.entrybook.entryBookModelPath.description"), "/jasperreports/entryBook/EntryBookReport.jrxml", String.class, false, false), - ENTRY_BOOK_FINANCIAL_PERIOD_REPORT_MODEL_PATH("lima.config.documentReport.entrybook.financialPeriodModelPath", n("lima.config.documentReport.entrybook.financialPeriodModelPath.description"), "/jasperreports/entryBook/FinancialPeriodReport.jrxml", String.class, false, false), - ENTRY_BOOK_TRANSACTION_REPORT_MODEL_PATH("lima.config.documentReport.entrybook.transactionReportModelPath", n("lima.config.documentReport.entrybook.transactionReportModelPath.description"), "/jasperreports/entryBook/TransactionReport.jrxml", String.class, false, false), - - GENERAL_LEDGER_DOCUMENT_REPORT_MODEL_PATH("lima.config.documentReport.generalLedger.documentReportModelPath", n("lima.config.documentReport.generalLedger.documentReportModelPath.description"), "/jasperreports/generalLedger/DocumentReport.jrxml", String.class, false, false), - GENERAL_LEDGER_MODEL_PATH("lima.config.documentReport.generalLedger.generalLedgerModelPath", n("lima.config.documentReport.generalLedger.generalLedgerModelPath.description"), "/jasperreports/generalLedger/GeneralLedgerReport.jrxml", String.class, false, false), - GENERAL_LEDGER_ENTRY_MODEL_PATH("lima.config.documentReport.generalLedger.generalLedgerEntryModelPath", n("lima.config.documentReport.generalLedger.generalLedgerEntryModelPath.description"), "/jasperreports/generalLedger/GeneralLedgerEntryReport.jrxml", String.class, false, false), - - SCALE("lima.scale", n("lima.config.scale.description"), "2", String.class, false, false), - CURRENCY("lima.config.currency", "", "false", Boolean.class, false, false), - DECIMAL_SEPARATOR("lima.data.bigDecimal.decimalSeparator", "", ",", Character.class, false, false), - THOUSAND_SEPARATOR("lima.thousandSeparator", "", " ", Character.class, false, false), - LIMA_HOST_ADDRESS("lima.host.address",n("lima.config.host.address.description"),"localhost",String.class, false, false); + REPORTS_MODEL_DIR("lima.reports.dir",n("lima.config.reports.dir.description"),"${lima.data.dir}/reports", File.class, false, false); private final String key; @@ -418,8 +132,8 @@ public class LimaServerConfig { private boolean finalBoolean; - ServiceConfigOption(String key, String description, String defaultValue, - Class<?> type, boolean transientBoolean, boolean finalBoolean) { + ServerConfigOption(String key, String description, String defaultValue, + Class<?> type, boolean transientBoolean, boolean finalBoolean) { this.key = key; this.description = description; this.defaultValue = defaultValue; diff --git a/lima-swing/src/main/java/org/chorem/lima/LimaSwingConfig.java b/lima-swing/src/main/java/org/chorem/lima/LimaSwingConfig.java index 18a0d79..4c4f2bb 100644 --- a/lima-swing/src/main/java/org/chorem/lima/LimaSwingConfig.java +++ b/lima-swing/src/main/java/org/chorem/lima/LimaSwingConfig.java @@ -131,8 +131,6 @@ public class LimaSwingConfig extends ApplicationConfig implements BigDecimalToSt log.error("Can't read configuration", ex); } } - instance.setOption(TopiaConfigurationConstants.CONFIG_PERSISTENCE_CLASSES, - LimaCallaoEntityEnum.getImplementationClassesAsString()); } @Override diff --git a/lima-swing/src/main/java/org/chorem/lima/ui/MainView.jaxx b/lima-swing/src/main/java/org/chorem/lima/ui/MainView.jaxx index 7e1d4ac..1a01d00 100644 --- a/lima-swing/src/main/java/org/chorem/lima/ui/MainView.jaxx +++ b/lima-swing/src/main/java/org/chorem/lima/ui/MainView.jaxx @@ -107,7 +107,7 @@ </JMenu> <JSeparator/> <JMenuItem id="documents" - onActionPerformed="getHandler().openLimaReport(this)"/> + onActionPerformed="getHandler().openLimaHttpUi(this)"/> <JSeparator/> <JMenuItem id="identity" onActionPerformed="getHandler().showIdentity(this)"/> diff --git a/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java b/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java index 8acea8b..10cb2da 100644 --- a/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java +++ b/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java @@ -490,12 +490,12 @@ public class MainViewHandler { importExport.processImportExport(type, true); } - public void openLimaReport(MainView ui) { + public void openLimaHttpUi(MainView ui) { OptionsService optionsService = LimaServiceFactory.getService(OptionsService.class); - String host = optionsService.getLimaReportHost(); - int port = optionsService.getLimaReportPort(); + String host = optionsService.getLimaHttpHost(); + int port = optionsService.getLimaHttpPort(); String url; if (port == 80) { diff --git a/lima-swing/src/test/java/org/chorem/lima/ui/AbstractLimaTest.java b/lima-swing/src/test/java/org/chorem/lima/ui/AbstractLimaTest.java index 6415f87..ac2e0e7 100644 --- a/lima-swing/src/test/java/org/chorem/lima/ui/AbstractLimaTest.java +++ b/lima-swing/src/test/java/org/chorem/lima/ui/AbstractLimaTest.java @@ -150,7 +150,7 @@ public abstract class AbstractLimaTest { Properties testProperties = new Properties(); // override somes String testDir = System.getProperty("java.io.tmpdir") + File.separator + "lima-business-" + UUID.randomUUID().toString(); - testProperties.setProperty(LimaServerConfig.ServiceConfigOption.DATA_DIR.getKey(), testDir); + testProperties.setProperty(LimaServerConfig.ServerConfigOption.DATA_DIR.getKey(), testDir); testProperties.setProperty(Environment.URL, "jdbc:h2:file:" + testDir + File.separator + "data"); testProperties.setProperty(Environment.CURRENT_SESSION_CONTEXT_CLASS, "thread"); testProperties.setProperty("topia.persistence.classes", LimaCallaoEntityEnum.getImplementationClassesAsString()); -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.