Author: hansbak
Date: Wed Feb 1 08:24:36 2012 New Revision: 1238998 URL: http://svn.apache.org/viewvc?rev=1238998&view=rev Log: some missing files in -r1238993 Added: ofbiz/trunk/framework/common/data/CommonSystemPropertyData.xml (with props) ofbiz/trunk/framework/entity/script/ ofbiz/trunk/framework/entity/script/org/ ofbiz/trunk/framework/entity/script/org/ofbiz/ ofbiz/trunk/framework/entity/script/org/ofbiz/entity/ ofbiz/trunk/framework/entity/script/org/ofbiz/entity/test/ ofbiz/trunk/framework/entity/script/org/ofbiz/entity/test/EntityUtilPropertiesTests.xml (with props) ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntityUtilProperties.java (with props) Added: ofbiz/trunk/framework/common/data/CommonSystemPropertyData.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/data/CommonSystemPropertyData.xml?rev=1238998&view=auto ============================================================================== --- ofbiz/trunk/framework/common/data/CommonSystemPropertyData.xml (added) +++ ofbiz/trunk/framework/common/data/CommonSystemPropertyData.xml Wed Feb 1 08:24:36 2012 @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +--> +<entity-engine-xml> + <SystemProperty systemPropertyId="currency.uom.id.default" systemPropertyValue="THB" description="the default currency to use for prices, etc"/> + <SystemProperty systemPropertyId="defaultFromEmailAddress" systemPropertyValue="[hidden email]" description="general default 'fromEmailAddress' can be overridden in: EmailTemplateSetting"/> +</entity-engine-xml> Propchange: ofbiz/trunk/framework/common/data/CommonSystemPropertyData.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/trunk/framework/common/data/CommonSystemPropertyData.xml ------------------------------------------------------------------------------ svn:keywords = Date Rev Author URL Id Propchange: ofbiz/trunk/framework/common/data/CommonSystemPropertyData.xml ------------------------------------------------------------------------------ svn:mime-type = text/xml Added: ofbiz/trunk/framework/entity/script/org/ofbiz/entity/test/EntityUtilPropertiesTests.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/script/org/ofbiz/entity/test/EntityUtilPropertiesTests.xml?rev=1238998&view=auto ============================================================================== --- ofbiz/trunk/framework/entity/script/org/ofbiz/entity/test/EntityUtilPropertiesTests.xml (added) +++ ofbiz/trunk/framework/entity/script/org/ofbiz/entity/test/EntityUtilPropertiesTests.xml Wed Feb 1 08:24:36 2012 @@ -0,0 +1,45 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +--> + +<simple-methods xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/simple-methods.xsd"> + + <simple-method method-name="testGetGeneralProperties" short-description="test getting general properties" login-required="false"> + <call-class-method ret-field="currencyUomIdDefault" method-name="getPropertyValue" class-name="org.ofbiz.entity.util.EntityUtilProperties"> + <string value="general"/> + <string value="currency.uom.id.default"/> + <field field="delegator" type="org.ofbiz.entity.Delegator"/> + </call-class-method> + <assert><if-compare field="currencyUomIdDefault" operator="equals" value="THB"></if-compare></assert> + + <call-class-method ret-field="defaultFromEmailAddress" method-name="getPropertyValue" class-name="org.ofbiz.entity.util.EntityUtilProperties"> + <string value="general"/> + <string value="defaultFromEmailAddress"/> + <field field="delegator" type="org.ofbiz.entity.Delegator"/> + </call-class-method> + <assert><if-compare field="defaultFromEmailAddress" operator="equals" value="[hidden email]"></if-compare></assert> + + <property-to-field resource="general" property="currency.uom.id.default" field="currencyUomIdDefault"/> + <assert><if-compare field="currencyUomIdDefault" operator="equals" value="THB"></if-compare></assert> + + <property-to-field resource="general" property="defaultFromEmailAddress" field="defaultFromEmailAddress"/> + <assert><if-compare field="defaultFromEmailAddress" operator="equals" value="[hidden email]"></if-compare></assert> + </simple-method> +</simple-methods> Propchange: ofbiz/trunk/framework/entity/script/org/ofbiz/entity/test/EntityUtilPropertiesTests.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/trunk/framework/entity/script/org/ofbiz/entity/test/EntityUtilPropertiesTests.xml ------------------------------------------------------------------------------ svn:keywords = Date Rev Author URL Id Propchange: ofbiz/trunk/framework/entity/script/org/ofbiz/entity/test/EntityUtilPropertiesTests.xml ------------------------------------------------------------------------------ svn:mime-type = text/xml Added: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntityUtilProperties.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntityUtilProperties.java?rev=1238998&view=auto ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntityUtilProperties.java (added) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntityUtilProperties.java Wed Feb 1 08:24:36 2012 @@ -0,0 +1,242 @@ +/******************************************************************************* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + *******************************************************************************/ +package org.ofbiz.entity.util; + +import java.io.IOException; +import java.io.InputStream; +import java.io.Serializable; +import java.math.BigDecimal; +import java.math.BigInteger; +import java.net.URL; +import java.util.InvalidPropertiesFormatException; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Properties; +import java.util.ResourceBundle; +import java.util.Set; + +import org.ofbiz.base.util.Debug; +import org.ofbiz.base.util.UtilMisc; +import org.ofbiz.base.util.UtilProperties; +import org.ofbiz.base.util.UtilValidate; +import org.ofbiz.base.util.collections.ResourceBundleMapWrapper; +import org.ofbiz.entity.Delegator; +import org.ofbiz.entity.GenericValue; + +@SuppressWarnings("serial") +public class EntityUtilProperties implements Serializable { + + public final static String module = EntityUtilProperties.class.getName(); + + protected static String getSystemPropertyValue(String name, Delegator delegator) { + if (name == null || name.length() <= 0) return ""; + + // find system property + try { + List<GenericValue> systemProperties = delegator.findByAnd("SystemProperty", UtilMisc.toMap("systemPropertyId", name)); + if (UtilValidate.isNotEmpty(systemProperties)) { + GenericValue systemProperty = EntityUtil.getFirst(systemProperties); + String systemPropertyValue = systemProperty.getString("systemPropertyValue"); + return systemPropertyValue; + } + } catch (Exception e) { + Debug.logWarning("Could not get a sytem property for " + name + " : " + e.getMessage(), module); + } + return null; + } + + public static boolean propertyValueEquals(String resource, String name, String compareString) { + return UtilProperties.propertyValueEquals(resource, name, compareString); + } + + public static boolean propertyValueEqualsIgnoreCase(String resource, String name, String compareString) { + return UtilProperties.propertyValueEqualsIgnoreCase(resource, name, compareString); + } + + public static String getPropertyValue(String resource, String name, String defaultValue) { + return UtilProperties.getPropertyValue(resource, name, defaultValue); + } + + public static double getPropertyNumber(String resource, String name, double defaultValue) { + return UtilProperties.getPropertyNumber(resource, name, defaultValue); + } + + public static double getPropertyNumber(String resource, String name) { + return UtilProperties.getPropertyNumber(resource, name); + } + + public static Boolean getPropertyAsBoolean(String resource, String name, boolean defaultValue) { + return UtilProperties.getPropertyAsBoolean(resource, name, defaultValue); + } + + public static Integer getPropertyAsInteger(String resource, String name, int defaultNumber) { + return UtilProperties.getPropertyAsInteger(resource, name, defaultNumber); + } + + public static Long getPropertyAsLong(String resource, String name, long defaultNumber) { + return UtilProperties.getPropertyAsLong(resource, name, defaultNumber); + } + + public static Float getPropertyAsFloat(String resource, String name, float defaultNumber) { + return UtilProperties.getPropertyAsFloat(resource, name, defaultNumber); + } + + public static Double getPropertyAsDouble(String resource, String name, double defaultNumber) { + return UtilProperties.getPropertyAsDouble(resource, name, defaultNumber); + } + + public static BigInteger getPropertyAsBigInteger(String resource, String name, BigInteger defaultNumber) { + return UtilProperties.getPropertyAsBigInteger(resource, name, defaultNumber); + } + + public static BigDecimal getPropertyAsBigDecimal(String resource, String name, BigDecimal defaultNumber) { + return UtilProperties.getPropertyAsBigDecimal(resource, name, defaultNumber); + } + + public static String getPropertyValue(String resource, String name, Delegator delegator) { + String value = getSystemPropertyValue(name, delegator); + if (UtilValidate.isEmpty(value)) { + value = UtilProperties.getPropertyValue(resource, name); + } + return value; + } + + public static Properties getProperties(String resource) { + return UtilProperties.getProperties(resource); + } + + public static Properties getProperties(URL url) { + return UtilProperties.getProperties(url); + } + + public static boolean propertyValueEquals(URL url, String name, String compareString) { + return UtilProperties.propertyValueEquals(url, name, compareString); + } + + public static boolean propertyValueEqualsIgnoreCase(URL url, String name, String compareString) { + return UtilProperties.propertyValueEqualsIgnoreCase(url, name, compareString); + } + + public static String getPropertyValue(URL url, String name, String defaultValue) { + return UtilProperties.getPropertyValue(url, name, defaultValue); + } + + public static double getPropertyNumber(URL url, String name, double defaultValue) { + return UtilProperties.getPropertyNumber(url, name, defaultValue); + } + + public static double getPropertyNumber(URL url, String name) { + return UtilProperties.getPropertyNumber(url, name); + } + + public static String getPropertyValue(URL url, String name) { + return UtilProperties.getPropertyValue(url, name); + } + + public static String getSplitPropertyValue(URL url, String name) { + return UtilProperties.getSplitPropertyValue(url, name); + } + + public static void setPropertyValue(String resource, String name, String value) { + UtilProperties.setPropertyValue(resource, name, value); + } + + public static void setPropertyValueInMemory(String resource, String name, String value) { + UtilProperties.setPropertyValueInMemory(resource, name, value); + } + + public static String getMessage(String resource, String name, Locale locale, Delegator delegator) { + String value = getSystemPropertyValue(name, delegator); + if (UtilValidate.isEmpty(value)) { + value = UtilProperties.getMessage(resource, name, locale); + } + return value; + } + + public static String getMessage(String resource, String name, Object[] arguments, Locale locale) { + return UtilProperties.getMessage(resource, name, arguments, locale); + } + + public static <E> String getMessage(String resource, String name, List<E> arguments, Locale locale) { + return UtilProperties.getMessage(resource, name, arguments, locale); + } + + public static String getMessageList(String resource, String name, Locale locale, Object... arguments) { + return UtilProperties.getMessageList(resource, name, locale, arguments); + } + + public static String getMessage(String resource, String name, Map<String, ? extends Object> context, Locale locale) { + return UtilProperties.getMessage(resource, name, context, locale); + } + + public static String getMessageMap(String resource, String name, Locale locale, Object... context) { + return UtilProperties.getMessageMap(resource, name, locale, context); + } + + public static ResourceBundle getResourceBundle(String resource, Locale locale) { + return UtilProperties.getResourceBundle(resource, locale); + } + + public static ResourceBundleMapWrapper getResourceBundleMap(String resource, Locale locale) { + return UtilProperties.getResourceBundleMap(resource, locale); + } + + public static ResourceBundleMapWrapper getResourceBundleMap(String resource, Locale locale, Map<String, Object> context) { + return UtilProperties.getResourceBundleMap(resource, locale, context); + } + + public static Properties getProperties(String resource, Locale locale) { + return UtilProperties.getProperties(resource, locale); + } + + @Deprecated + public static Locale getFallbackLocale() { + return UtilProperties.getFallbackLocale(); + } + + public static List<Locale> localeToCandidateList(Locale locale) { + return UtilProperties.localeToCandidateList(locale); + } + + public static Set<Locale> getDefaultCandidateLocales() { + return UtilProperties.getDefaultCandidateLocales(); + } + + @Deprecated + public static List<Locale> getCandidateLocales(Locale locale) { + return UtilProperties.getCandidateLocales(locale); + } + + public static String createResourceName(String resource, Locale locale, boolean removeExtension) { + return UtilProperties.createResourceName(resource, locale, removeExtension); + } + + public static boolean isPropertiesResourceNotFound(String resource, Locale locale, boolean removeExtension) { + return UtilProperties.isPropertiesResourceNotFound(resource, locale, removeExtension); + } + + public static URL resolvePropertiesUrl(String resource, Locale locale) { + return UtilProperties.resolvePropertiesUrl(resource, locale); + } + + public static Properties xmlToProperties(InputStream in, Locale locale, Properties properties) throws IOException, InvalidPropertiesFormatException { + return UtilProperties.xmlToProperties(in, locale, properties); + } +} Propchange: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntityUtilProperties.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntityUtilProperties.java ------------------------------------------------------------------------------ svn:keywords = Date Rev Author URL Id Propchange: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntityUtilProperties.java ------------------------------------------------------------------------------ svn:mime-type = text/plain |
Free forum by Nabble | Edit this page |