From d6822cc466a907d41fd235a19c3cae6b2f4e9d0e Mon Sep 17 00:00:00 2001 From: jan thielemann Date: Wed, 29 Oct 2014 08:17:11 -0500 Subject: [PATCH] IDEMPIERE-2259 Add SysConfig keys to avoid using hardcoded values on login page --- .../src/org/compiere/Adempiere.java | 43 ++++++++++++++++++- .../src/org/compiere/model/MSysConfig.java | 11 ++++- .../theme/default/zul/login/version-info.zul | 24 +++++++---- 3 files changed, 68 insertions(+), 10 deletions(-) diff --git a/org.adempiere.base/src/org/compiere/Adempiere.java b/org.adempiere.base/src/org/compiere/Adempiere.java index 0dca4521e3..80695cda87 100644 --- a/org.adempiere.base/src/org/compiere/Adempiere.java +++ b/org.adempiere.base/src/org/compiere/Adempiere.java @@ -35,6 +35,7 @@ import javax.swing.event.EventListenerList; import org.adempiere.base.Core; import org.compiere.db.CConnection; import org.compiere.model.MClient; +import org.compiere.model.MSysConfig; import org.compiere.model.MSystem; import org.compiere.model.ModelValidationEngine; import org.compiere.model.ServerStateChangeEvent; @@ -153,6 +154,10 @@ public final class Adempiere */ public static String getVersion() { + String version = MSysConfig.getValue(MSysConfig.APPLICATION_MAIN_VERSION, null); + if(version != null) + return version; + IProduct product = Platform.getProduct(); if (product != null) { Bundle bundle = product.getDefiningBundle(); @@ -170,9 +175,40 @@ public final class Adempiere return "Unknown"; } // getVersion + public static boolean isVersionShown(){ + return MSysConfig.getBooleanValue(MSysConfig.APPLICATION_MAIN_VERSION_SHOWN, true); + } + + public static boolean isDBVersionShown(){ + boolean defaultVal = MSystem.get(Env.getCtx()).getSystemStatus().equalsIgnoreCase("P") ? false : true; + return MSysConfig.getBooleanValue(MSysConfig.APPLICATION_DATABASE_VERSION_SHOWN, defaultVal); + } + + public static boolean isVendorShown(){ + return MSysConfig.getBooleanValue(MSysConfig.APPLICATION_IMPLEMENTATION_VENDOR_SHOWN, true); + } + + public static boolean isJVMShown(){ + boolean defaultVal = MSystem.get(Env.getCtx()).getSystemStatus().equalsIgnoreCase("P") ? false : true; + return MSysConfig.getBooleanValue(MSysConfig.APPLICATION_JVM_VERSION_SHOWN, defaultVal); + } + + public static boolean isOSShown(){ + boolean defaultVal = MSystem.get(Env.getCtx()).getSystemStatus().equalsIgnoreCase("P") ? false : true; + return MSysConfig.getBooleanValue(MSysConfig.APPLICATION_OS_INFO_SHOWN, defaultVal); + } + + public static boolean isHostShown() + { + boolean defaultVal = MSystem.get(Env.getCtx()).getSystemStatus().equalsIgnoreCase("P") ? false : true; + return MSysConfig.getBooleanValue(MSysConfig.APPLICATION_HOST_SHOWN, defaultVal); + } + public static String getDatabaseVersion() { - return DB.getSQLValueString(null, "select lastmigrationscriptapplied from ad_system"); +// return DB.getSQLValueString(null, "select lastmigrationscriptapplied from ad_system"); + return MSysConfig.getValue(MSysConfig.APPLICATION_DATABASE_VERSION, + DB.getSQLValueString(null, "select lastmigrationscriptapplied from ad_system")); } /** @@ -238,6 +274,11 @@ public final class Adempiere */ public static String getImplementationVendor() { + if(DB.isConnected()){ + String vendor = MSysConfig.getValue(MSysConfig.APPLICATION_IMPLEMENTATION_VENDOR, null); + if(vendor != null) + return vendor; + } if (s_ImplementationVendor == null) setPackageInfo(); return s_ImplementationVendor; diff --git a/org.adempiere.base/src/org/compiere/model/MSysConfig.java b/org.adempiere.base/src/org/compiere/model/MSysConfig.java index 90d04f1041..a754a6bfdf 100644 --- a/org.adempiere.base/src/org/compiere/model/MSysConfig.java +++ b/org.adempiere.base/src/org/compiere/model/MSysConfig.java @@ -42,7 +42,7 @@ public class MSysConfig extends X_AD_SysConfig /** * */ - private static final long serialVersionUID = 1418216769489567455L; + private static final long serialVersionUID = -5622739157380126505L; public static final String ADDRESS_SAVE_REQUEST_RESPONSE_LOG = "ADDRESS_SAVE_REQUEST_RESPONSE_LOG"; public static final String ADDRESS_VALIDATION = "ADDRESS_VALIDATION"; @@ -50,6 +50,15 @@ public class MSysConfig extends X_AD_SysConfig public static final String ALLOW_APPLY_PAYMENT_TO_CREDITMEMO = "ALLOW_APPLY_PAYMENT_TO_CREDITMEMO"; public static final String ALLOW_OVER_APPLIED_PAYMENT = "ALLOW_OVER_APPLIED_PAYMENT"; public static final String ALogin_ShowOneRole = "ALogin_ShowOneRole"; + public static final String APPLICATION_DATABASE_VERSION = "APPLICATION_DATABASE_VERSION"; + public static final String APPLICATION_DATABASE_VERSION_SHOWN = "APPLICATION_DATABASE_VERSION_SHOWN"; + public static final String APPLICATION_HOST_SHOWN = "APPLICATION_HOST_SHOWN"; + public static final String APPLICATION_IMPLEMENTATION_VENDOR = "APPLICATION_IMPLEMENTATION_VENDOR"; + public static final String APPLICATION_IMPLEMENTATION_VENDOR_SHOWN = "APPLICATION_IMPLEMENTATION_VENDOR_SHOWN"; + public static final String APPLICATION_JVM_VERSION_SHOWN = "APPLICATION_JVM_VERSION_SHOWN"; + public static final String APPLICATION_MAIN_VERSION = "APPLICATION_MAIN_VERSION"; + public static final String APPLICATION_MAIN_VERSION_SHOWN = "APPLICATION_MAIN_VERSION_SHOWN"; + public static final String APPLICATION_OS_INFO_SHOWN = "APPLICATION_OS_INFO_SHOWN"; public static final String BACKGROUND_JOB_ALLOWED = "BACKGROUND_JOB_ALLOWED"; public static final String BACKGROUND_JOB_BY_DEFAULT = "BACKGROUND_JOB_BY_DEFAULT"; public static final String BACKGROUND_JOB_MAX_IN_SYSTEM = "BACKGROUND_JOB_MAX_IN_SYSTEM"; diff --git a/org.adempiere.ui.zk/theme/default/zul/login/version-info.zul b/org.adempiere.ui.zk/theme/default/zul/login/version-info.zul index 1e61bcbebb..8574ca0f25 100644 --- a/org.adempiere.ui.zk/theme/default/zul/login/version-info.zul +++ b/org.adempiere.ui.zk/theme/default/zul/login/version-info.zul @@ -11,6 +11,13 @@ Copyright (C) 2009 Idalica Corporation var vendor = Adempiere.getImplementationVendor(); var jvm = Adempiere.getJavaInfo(); var os = Adempiere.getOSInfo(); + var isVersionShown = Adempiere.isVersionShown(); + var isDBVersionShown = Adempiere.isDBVersionShown(); + var isVendorShown = Adempiere.isVendorShown(); + var isJVMShown = Adempiere.isJVMShown(); + var isOSShown = Adempiere.isOSShown(); + var isHostShown = Adempiere.isHostShown(); + var isInfoShown = isVersionShown || isDBVersionShown || isVendorShown || isJVMShown || isOSShown || isHostShown; -
+]]> +
- + - + - + - + - + - +
Version : ${mainVersion}
Database Version : ${dbVersion}
Vendor : ${vendor}
JVM : ${jvm}
OS : ${os}
Host : ${desktop.execution.serverName}
-]]> +