Hans,

This process is still incorrect. This is how it was designed:

1. Get all default global preferences (userLoginId = "_NA_", userPrefGroupTypeId = "GLOBAL_PREFERENCES") from the database. 2. Get all user-specified global preferences from the database, replace default global preferences with user-specified global preferences.

So, in the case of the visual theme ID:

1. Get the default global preferences visual theme ID from the database (should be set to "BIZZNESS_TIME"). 2. Replace the default visual theme ID with a user-specified visual theme ID, if found.

There is no need for a properties file setting. If the default visual theme ID is not found, then that is a seed-data loading error or a user error, and it should be fixed accordingly.

If a user wants to change the default visual theme, they do so by modifying the UserPreference entity in Webtools.

One thing we should try to avoid is referencing specific visual themes in code. The original design accommodated that.

-Adrian



[email protected] wrote:
Author: hansbak
Date: Wed Sep 30 05:16:17 2009
New Revision: 820178

URL: http://svn.apache.org/viewvc?rev=820178&view=rev
Log:
On request of adrian, put the VISUAL_THEME default record back in the database, 
however added the function that values in general properties can override this 
value. Combined the implementation with the definition of the 
defaultOrganizationPartyId

Modified:
    ofbiz/trunk/applications/commonext/widget/CommonScreens.xml
    ofbiz/trunk/applications/commonext/widget/HelpScreens.xml
    
ofbiz/trunk/applications/content/src/org/ofbiz/content/data/DataResourceWorker.java
    ofbiz/trunk/applications/content/widget/content/ContentScreens.xml
    ofbiz/trunk/framework/common/config/general.properties
    ofbiz/trunk/framework/common/data/CommonTypeData.xml
    ofbiz/trunk/framework/common/script/org/ofbiz/common/CommonServices.xml
    ofbiz/trunk/framework/common/servicedef/services.xml
    
ofbiz/trunk/framework/common/src/org/ofbiz/common/preferences/PreferenceServices.java
    ofbiz/trunk/framework/common/widget/CommonScreens.xml

Modified: ofbiz/trunk/applications/commonext/widget/CommonScreens.xml
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/commonext/widget/CommonScreens.xml?rev=820178&r1=820177&r2=820178&view=diff
==============================================================================
--- ofbiz/trunk/applications/commonext/widget/CommonScreens.xml (original)
+++ ofbiz/trunk/applications/commonext/widget/CommonScreens.xml Wed Sep 30 
05:16:17 2009
@@ -40,8 +40,7 @@
                 <section>
                     <condition><not><if-empty 
field="PartyAcctgPrefAndGroupList"/></not></condition><!-- produced by  
changeOrgPartyId.groovy-->
                     <actions>
-                        <property-to-field resource="general" 
property="defaultOrganizationPartyId" field="defaultOrganizationPartyIdProperties"/>
-                        <set field="defaultOrganizationPartyId" 
value="${bsh:&quot;DEFAULT&quot;.equals(userPreferences.get(&quot;ORGANIZATION_PARTY&quot;))?defaultOrganizationPartyIdProperties:userPreferences.get(&quot;ORGANIZATION_PARTY&quot;)}"
 global="true"/>
+                        <set field="defaultOrganizationPartyId" 
value="${userPreferences.ORGANIZATION_PARTY}" global="true"/>
                         <property-to-field resource="general" 
property="currency.uom.id.default" field="defaultCurrencyUomId"/>
                         <entity-one entity-name="PartyAcctgPrefAndGroup" 
value-field="orgParty">
                             <field-map field-name="partyId" 
from-field="defaultOrganizationPartyId"/>

Modified: ofbiz/trunk/applications/commonext/widget/HelpScreens.xml
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/commonext/widget/HelpScreens.xml?rev=820178&r1=820177&r2=820178&view=diff
==============================================================================
--- ofbiz/trunk/applications/commonext/widget/HelpScreens.xml (original)
+++ ofbiz/trunk/applications/commonext/widget/HelpScreens.xml Wed Sep 30 
05:16:17 2009
@@ -32,9 +32,7 @@
                 </service>
                 <set field="userPreferences" from-field="prefResult.userPrefMap" 
global="true"/>
<set field="lookupType" value="HELP"/> - <property-map resource="general" map-name="generalProperties" global="true"/>
-                <set field="defaultVisualThemeId" 
from-field="generalProperties.defaultVisualThemeId" default-value="BIZZNESS_TIME"/>
-                <set field="visualThemeId" from-field="userPreferences.VISUAL_THEME" 
default-value="${defaultVisualThemeId}" global="true"/>
+                <set field="visualThemeId" from-field="userPreferences.VISUAL_THEME" 
global="true"/>
                 <service service-name="getVisualThemeResources">
                     <field-map field-name="visualThemeId"/>
                     <field-map field-name="themeResources" 
from-field="layoutSettings"/>
@@ -129,9 +127,7 @@
                 <property-map resource="CommonUiLabels" map-name="uiLabelMap" 
global="true"/>
                 <property-map resource="CommonExtUiLabels" map-name="uiLabelMap" 
global="true"/>
                 <set field="contentId" from-field="parameters.contentId" 
default-value="${contentId}"/>
-                <property-map resource="general" map-name="generalProperties" 
global="true"/>
-                <set field="defaultVisualThemeId" 
from-field="generalProperties.defaultVisualThemeId" default-value="BIZZNESS_TIME"/>
-                <set field="visualThemeId" from-field="userPreferences.VISUAL_THEME" 
default-value="${defaultVisualThemeId}" global="true"/>
+                <set field="visualThemeId" from-field="userPreferences.VISUAL_THEME" 
default-value="BIZZNESS_TIME" global="true"/>
                 <service service-name="getVisualThemeResources">
                     <field-map field-name="visualThemeId"/>
                     <field-map field-name="themeResources" 
from-field="layoutSettings"/>

Modified: 
ofbiz/trunk/applications/content/src/org/ofbiz/content/data/DataResourceWorker.java
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/data/DataResourceWorker.java?rev=820178&r1=820177&r2=820178&view=diff
==============================================================================
--- 
ofbiz/trunk/applications/content/src/org/ofbiz/content/data/DataResourceWorker.java
 (original)
+++ 
ofbiz/trunk/applications/content/src/org/ofbiz/content/data/DataResourceWorker.java
 Wed Sep 30 05:16:17 2009
@@ -697,7 +697,7 @@
                 if (sourceFileLocation != null && sourceFileLocation.exists()) 
{
                     UtilMisc.copyFile(sourceFileLocation,targetFileLocation);
                 } else {
-                    String defaultVisualThemeId = 
UtilProperties.getPropertyValue("general", "defaultVisualThemeId");
+                    String defaultVisualThemeId = 
UtilProperties.getPropertyValue("general", "VISUAL_THEME");
                     if (defaultVisualThemeId != null) {
                         GenericValue themeValue = delegator.findByPrimaryKeyCache("VisualThemeResource", 
UtilMisc.toMap("visualThemeId", 
defaultVisualThemeId,"resourceTypeEnumId","VT_DOCBOOKSTYLESHEET","sequenceId","01"));
                         sourceFileLocation = new 
File(System.getProperty("ofbiz.home")+"/themes"+themeValue.get("resourceValue"));

Modified: ofbiz/trunk/applications/content/widget/content/ContentScreens.xml
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/widget/content/ContentScreens.xml?rev=820178&r1=820177&r2=820178&view=diff
==============================================================================
--- ofbiz/trunk/applications/content/widget/content/ContentScreens.xml 
(original)
+++ ofbiz/trunk/applications/content/widget/content/ContentScreens.xml Wed Sep 
30 05:16:17 2009
@@ -165,9 +165,7 @@
                 <property-map resource="CommonUiLabels" map-name="uiLabelMap" 
global="true"/>
                 <property-map resource="CommonExtUiLabels" map-name="uiLabelMap" 
global="true"/>
                 <set field="contentId" from-field="parameters.contentId" 
default-value="${contentId}"/>
-                <property-map resource="general" map-name="generalProperties" 
global="true"/>
-                <set field="defaultVisualThemeId" 
from-field="generalProperties.defaultVisualThemeId" default-value="BIZZNESS_TIME"/>
-                <set field="visualThemeId" from-field="userPreferences.VISUAL_THEME" 
default-value="${defaultVisualThemeId}" global="true"/>
+                <set field="visualThemeId" from-field="userPreferences.VISUAL_THEME" 
default-value="BIZZNESS_TIME" global="true"/>
                 <service service-name="getVisualThemeResources">
                     <field-map field-name="visualThemeId"/>
                     <field-map field-name="themeResources" 
from-field="layoutSettings"/>

Modified: ofbiz/trunk/framework/common/config/general.properties
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/config/general.properties?rev=820178&r1=820177&r2=820178&view=diff
==============================================================================
--- ofbiz/trunk/framework/common/config/general.properties (original)
+++ ofbiz/trunk/framework/common/config/general.properties Wed Sep 30 05:16:17 
2009
@@ -23,11 +23,11 @@
 # -- the default currency to use for prices, etc
 currency.uom.id.default=USD
+# These values override the _NA_ DEFAULT values in user preferences for the GLOBAL_PREFERENCES userPrefGroupTypeId
 # -- the default organizationPartyId for used in dropdowns and reports
-defaultOrganizationPartyId=Company
-
-# ID of the VisualTheme to use if there VISUAL_THEME UserPreference record for 
the current user
-defaultVisualThemeId=BIZZNESS_TIME
+ORGANIZATION_PARTY=Company
+# ID of the VisualTheme to use if there VISUAL_THEME UserPreference record for the current user supported values: FLAT_GREY and BIZZNESS_TIME and BLUELIGHT +VISUAL_THEME=BIZZNESS_TIME # -- the default decimal format for currency
 currency.decimal.format=##0.00

Modified: ofbiz/trunk/framework/common/data/CommonTypeData.xml
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/data/CommonTypeData.xml?rev=820178&r1=820177&r2=820178&view=diff
==============================================================================
--- ofbiz/trunk/framework/common/data/CommonTypeData.xml (original)
+++ ofbiz/trunk/framework/common/data/CommonTypeData.xml Wed Sep 30 05:16:17 
2009
@@ -102,7 +102,7 @@
<!-- User preferences seed data -->
     <UserPrefGroupType userPrefGroupTypeId="GLOBAL_PREFERENCES" description="Global 
preferences"/>
-    <!-- UserPreference userLoginId="_NA_" userPrefTypeId="VISUAL_THEME" 
userPrefGroupTypeId="GLOBAL_PREFERENCES" userPrefValue="BIZZNESS_TIME" specified in general properties! 
-->
+    <UserPreference userLoginId="_NA_" userPrefTypeId="VISUAL_THEME" 
userPrefGroupTypeId="GLOBAL_PREFERENCES" userPrefValue="DEFAULT"/><!-- will be overruled by the setting 
in general.properties (if present) -->
<!-- Visual Themes seed data -->
     <EnumerationType description="Visual Theme Resource Type (stylesheet, javascript file, etc)" 
enumTypeId="VT_RES_TYPE" hasTable="N"/>

Modified: 
ofbiz/trunk/framework/common/script/org/ofbiz/common/CommonServices.xml
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/script/org/ofbiz/common/CommonServices.xml?rev=820178&r1=820177&r2=820178&view=diff
==============================================================================
--- ofbiz/trunk/framework/common/script/org/ofbiz/common/CommonServices.xml 
(original)
+++ ofbiz/trunk/framework/common/script/org/ofbiz/common/CommonServices.xml Wed 
Sep 30 05:16:17 2009
@@ -197,10 +197,6 @@
<simple-method method-name="getVisualThemeResources" short-description="Get visual theme resources" login-required="false">
         <set field="visualThemeId" from-field="parameters.visualThemeId"/>
-        <if-empty field="visualThemeId">
-            <add-error><fail-property property="CommonVisualThemeIdNotFound" 
resource="CommonUiLabels"/></add-error>
-            <check-errors/>
-        </if-empty>
         <set field="themeResources" from-field="parameters.themeResources"/>
         <entity-condition list="resourceList" entity-name="VisualThemeResource" 
use-cache="true">
             <condition-expr field-name="visualThemeId" 
from-field="visualThemeId"/>

Modified: ofbiz/trunk/framework/common/servicedef/services.xml
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/servicedef/services.xml?rev=820178&r1=820177&r2=820178&view=diff
==============================================================================
--- ofbiz/trunk/framework/common/servicedef/services.xml (original)
+++ ofbiz/trunk/framework/common/servicedef/services.xml Wed Sep 30 05:16:17 
2009
@@ -410,7 +410,11 @@
<service name="getUserPreference" engine="java"
             location="org.ofbiz.common.preferences.PreferenceServices" 
invoke="getUserPreference">
-        <description>Gets a single user preference.</description>
+        <description>
+            Gets a single user preference.
+ If not found for the specific userLogin, find it for the _NA_ userlogin. + If the value is DEFAULT, find the value in general.properties file.
+        </description>
         <attribute name="userPrefTypeId" type="String" mode="IN" 
optional="false"/>
         <attribute name="userPrefLoginId" type="String" mode="IN" 
optional="true"/>
         <attribute name="userPrefGroupTypeId" type="String" mode="IN" 
optional="true"/>
@@ -466,7 +470,7 @@
             Map of Lists, where the resourceTypeEnumId is the key and the value
             is a List of resourceValue Strings for that resourceTypeEnumId.
         </description>
-        <attribute name="visualThemeId" type="String" mode="IN" 
optional="false"/>
+        <attribute name="visualThemeId" type="String" mode="IN" optional="true" 
default-value="BIZZNESS_TIME"/>
         <attribute name="themeResources" type="Map" mode="IN" optional="true"/>
         <attribute name="themeResources" type="Map" mode="OUT" 
optional="false"/>
     </service>

Modified: 
ofbiz/trunk/framework/common/src/org/ofbiz/common/preferences/PreferenceServices.java
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/src/org/ofbiz/common/preferences/PreferenceServices.java?rev=820178&r1=820177&r2=820178&view=diff
==============================================================================
--- 
ofbiz/trunk/framework/common/src/org/ofbiz/common/preferences/PreferenceServices.java
 (original)
+++ 
ofbiz/trunk/framework/common/src/org/ofbiz/common/preferences/PreferenceServices.java
 Wed Sep 30 05:16:17 2009
@@ -139,7 +139,18 @@
             Debug.logWarning(e.getMessage(), module);
             return ServiceUtil.returnError(UtilProperties.getMessage(resource, 
"getPreference.readFailure", new Object[] { e.getMessage() }, locale));
         }
-
+        // for the 'DEFAULT' values find the related values in general 
properties and if found use those.
+        Iterator it = userPrefMap.entrySet().iterator();
+        Map generalProperties = UtilProperties.getProperties("general");
+        while (it.hasNext()) {
+            Map.Entry pairs = (Map.Entry) it.next();
+            if (pairs.getValue().equals("DEFAULT")) {
+                if 
(UtilValidate.isNotEmpty(generalProperties.get(pairs.getKey()))) {
+                    userPrefMap.put((String) pairs.getKey(), 
generalProperties.get(pairs.getKey()));
+                }
+            }
+        }
+ Map<String, Object> result = ServiceUtil.returnSuccess();
         result.put("userPrefMap", userPrefMap);
         return result;

Modified: ofbiz/trunk/framework/common/widget/CommonScreens.xml
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/widget/CommonScreens.xml?rev=820178&r1=820177&r2=820178&view=diff
==============================================================================
--- ofbiz/trunk/framework/common/widget/CommonScreens.xml (original)
+++ ofbiz/trunk/framework/common/widget/CommonScreens.xml Wed Sep 30 05:16:17 
2009
@@ -121,9 +121,7 @@
                 <set field="layoutSettings.javaScripts[]" 
value="/images/calendar_date_select.js" global="true"/>
                 <set field="layoutSettings.javaScripts[]" 
value="/images/GooglemapMarkers.js" global="true"/>
                 <set field="layoutSettings.commonHeaderImageLinkUrl" 
from-field="layoutSettings.commonHeaderImageLinkUrl" default-value="main" global="true"/>
-                <property-map resource="general" map-name="generalProperties" 
global="true"/>
-                <set field="defaultVisualThemeId" 
from-field="generalProperties.defaultVisualThemeId" default-value="BIZZNESS_TIME"/>
-                <set field="visualThemeId" from-field="userPreferences.VISUAL_THEME" 
default-value="${defaultVisualThemeId}" global="true"/>
+                <set field="visualThemeId" from-field="userPreferences.VISUAL_THEME" 
default-value="BIZZNESS_TIME" global="true"/>
                 <service service-name="getVisualThemeResources">
                     <field-map field-name="visualThemeId"/>
                     <field-map field-name="themeResources" 
from-field="layoutSettings"/>
@@ -241,8 +239,7 @@
                 <set field="userPreferences" from-field="prefResult.userPrefMap" 
global="true"/>
<property-map resource="general" map-name="generalProperties" global="true"/>
-                <set field="defaultVisualThemeId" 
from-field="generalProperties.defaultVisualThemeId" default-value="BIZZNESS_TIME"/>
-                <set field="visualThemeId" from-field="userPreferences.VISUAL_THEME" 
default-value="${defaultVisualThemeId}" global="true"/>
+                <set field="visualThemeId" from-field="userPreferences.VISUAL_THEME" 
default-value="BIZZNESS_TIME" global="true"/>
                 <service service-name="getVisualThemeResources">
                     <field-map field-name="visualThemeId"/>
                     <field-map field-name="themeResources" 
from-field="layoutSettings"/>



Reply via email to