details:   https://code.openbravo.com/erp/devel/pi/rev/8abccb7a41a6
changeset: 19088:8abccb7a41a6
user:      Carlos Aristu <carlos.aristu <at> openbravo.com>
date:      Fri Dec 21 08:52:44 2012 +0100
summary:   related to issue 22459: added getCountryFromOrgId method

diffstat:

 src/org/openbravo/erpCommon/utility/Utility.java |  32 +++++++++++++++---------
 1 files changed, 20 insertions(+), 12 deletions(-)

diffs (56 lines):

diff -r e0cdc20e50b8 -r 8abccb7a41a6 
src/org/openbravo/erpCommon/utility/Utility.java
--- a/src/org/openbravo/erpCommon/utility/Utility.java  Thu Dec 20 19:10:12 
2012 +0100
+++ b/src/org/openbravo/erpCommon/utility/Utility.java  Fri Dec 21 08:52:44 
2012 +0100
@@ -2506,6 +2506,24 @@
   }
 
   /**
+   * Gets the country of the organization.
+   * 
+   * @param orgid
+   *          ID of the organization.
+   * 
+   * @return the country of the organization.
+   * 
+   */
+  public static Country getCountryFromOrgId(String orgid) {
+    Organization organization = (Organization) 
OBDal.getInstance().get(Organization.ENTITY_NAME,
+        orgid);
+    List<OrganizationInformation> orgInfoList = 
organization.getOrganizationInformationList();
+    OrganizationInformation orginfo = orgInfoList.get(0);
+    Location location = orginfo.getLocationAddress();
+    return location.getCountry();
+  }
+
+  /**
    * Gets the date format for the organization country.
    * 
    * @param date
@@ -2519,12 +2537,7 @@
   public static String applyCountryDateFormat(Date date, String orgid) {
     try {
       OBContext.setAdminMode(true);
-      Organization organization = (Organization) 
OBDal.getInstance().get(Organization.ENTITY_NAME,
-          orgid);
-      List<OrganizationInformation> orgInfoList = 
organization.getOrganizationInformationList();
-      OrganizationInformation orginfo = orgInfoList.get(0);
-      Location location = orginfo.getLocationAddress();
-      Country country = location.getCountry();
+      Country country = getCountryFromOrgId(orgid);
       String dateFormat = (country.getDateformat() == null) ? "dd-MM-yyyy" : 
country
           .getDateformat();
       SimpleDateFormat df = new SimpleDateFormat(dateFormat);
@@ -2563,12 +2576,7 @@
       DecimalFormat defaultDecimalFormat) {
     try {
       OBContext.setAdminMode(true);
-      Organization organization = (Organization) 
OBDal.getInstance().get(Organization.ENTITY_NAME,
-          orgid);
-      List<OrganizationInformation> orgInfoList = 
organization.getOrganizationInformationList();
-      OrganizationInformation orginfo = orgInfoList.get(0);
-      Location location = orginfo.getLocationAddress();
-      Country country = location.getCountry();
+      Country country = getCountryFromOrgId(orgid);
       DecimalFormatSymbols symbols = new DecimalFormatSymbols();
       if (country.getDecimalseparator() != null)
         symbols.setDecimalSeparator(country.getDecimalseparator().equals("C") 
? ',' : '.');

------------------------------------------------------------------------------
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to