Package org.openbravo.erpCommon.utility
Class Utility
- java.lang.Object
-
- org.openbravo.erpCommon.utility.Utility
-
public class Utility extends Object
- Author:
- Fernando Iriazabal Utility class
-
-
Field Summary
Fields Modifier and Type Field Description static String
BUTLER_UTILS_URL
static String
COMMUNITY_BRANDING_URL
static String
STATIC_COMMUNITY_BRANDING_URL
-
Constructor Summary
Constructors Constructor Description Utility()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static String
addDaysToDate(String strDate, String strDays, DateFormat DateFormatter)
static String
addSystem(String list)
Adds the system element to the given list.static String
applyCountryDateFormat(Timestamp timeStamp, String orgid)
Gets the date format for the organization country.static String
applyCountryDateFormat(Date date, String orgid)
Gets the date format for the organization country.static String
arrayDobleEntrada(String strArrayName, FieldProvider[] data)
Constructs and returns a two dimensional array of the data passed.static String
arrayEntradaSimple(String strArrayName, FieldProvider[] data)
Constructs and returns a two dimensional array of the data passed.static String
arrayListToString(ArrayList<String> list, boolean addQuotes)
Deprecated.Use instead the more genericStringCollectionUtils.commaSeparated(Collection, boolean)
static String
calculateLaborDays(String strDate1, String strDate2, DateFormat DateFormatter)
static boolean
canUpdate(ConnectionProvider conn, VariablesSecureApp vars, String AD_Client_ID, String AD_Org_ID, String window)
Checks if the user can make modifications in the window.static Long[]
computeImageSize(byte[] bytea)
This method calculates the size of an imagestatic boolean
deleteDir(File f)
Deletes recursively a (non-empty) directorystatic boolean
deleteDir(File[] f)
Deletes recursively a (non-empty) array of directoriesstatic void
dumpFile(String fileLocation, OutputStream outputstream)
Write the output to a file.static String
fileToString(String strPath)
Generates a String representing the file in a pathstatic void
fillSQLParameters(ConnectionProvider conn, VariablesSecureApp vars, FieldProvider data, ComboTableData cmb, String window, String actual_value)
Fill the parameters of the sql with the session values or FieldProvider values.static String
focusFieldJS(String id)
Returns a JavaScript function to be used on selectors Depending on what element you want to focus, you pass the idstatic String
formatDate(Date date, String pattern)
static String
formatMessageBDToHtml(String message)
static boolean
generateFile(String strPath, String strFile, String data)
Saves the content into a fisical file.static boolean
generateFileEncoding(String strPath, String strFile, String data, String encoding)
static String
getButtonName(ConnectionProvider conn, VariablesSecureApp vars, String reference, String currentValue, String buttonId, HashMap<String,String> usedButtonShortCuts, HashMap<String,String> reservedButtonShortCuts)
static String
getButtonName(ConnectionProvider conn, VariablesSecureApp vars, String fieldId, String buttonId, HashMap<String,String> usedButtonShortCuts, HashMap<String,String> reservedButtonShortCuts)
static String
getCommunityBrandingUrl()
Computes the community branding url on the basis of system information.static String
getContext(ConnectionProvider conn, VariablesSecureApp vars, String context, String window)
Gets a value from the context.static String
getContext(ConnectionProvider conn, VariablesSecureApp vars, String context, String strWindow, int accessLevel)
Gets a value from the context.static Country
getCountryFromOrgId(String orgid)
Gets the country of the organization.static DecimalFormat
getCountryNumberFormat(String orgid, DecimalFormat defaultDecimalFormat)
Gets the number format for the organization country.static DateFormat
getDateFormatter(VariablesSecureApp vars)
static String
getDefault(ConnectionProvider conn, VariablesSecureApp vars, String columnname, String context, String window, String defaultValue)
Overloaded method for backwards compatibilitystatic String
getDefault(ConnectionProvider conn, VariablesSecureApp vars, String columnname, String context, String window, String defaultValue, FieldProvider sessionData)
Gets a default value.static String
getDocumentNo(Connection conn, ConnectionProvider con, VariablesSecureApp vars, String WindowNo, String TableName, String C_DocTypeTarget_ID, String C_DocType_ID, boolean onlyDocType, boolean updateNext)
static String
getDocumentNo(ConnectionProvider conn, String AD_Client_ID, String TableName, boolean updateNext)
Gets the document number from database.static String
getDocumentNo(ConnectionProvider conn, VariablesSecureApp vars, String WindowNo, String TableName, String C_DocTypeTarget_ID, String C_DocType_ID, boolean onlyDocType, boolean updateNext)
Gets the document number from the database.static String
getDocumentNoConnection(Connection conn, ConnectionProvider con, String AD_Client_ID, String TableName, boolean updateNext)
Gets the document number from database.static String
getFieldName(String fieldId, String language)
Returns a field name in the specified language.static DecimalFormat
getFormat(VariablesSecureApp vars, String typeName)
Returns a DecimalFormat for the given formatting type contained in the Format.xml filestatic byte[]
getImage(String id)
Provides the image as a byte array.static byte[]
getImageLogo(String logo, String org)
Provides the image logo as a byte array for the indicated parameters.static Image
getImageLogoObject(String logo, String org)
Provides the image logo as a byte array for the indicated parameters.static Image
getImageObject(String id)
Provides the image as an image object.static <T extends BaseOBObject>
StringgetInStrList(List<T> obObjectList)
Creates a comma separated string with the Id's of the OBObjects included in the List.static <T extends BaseOBObject>
StringgetInStrList(List<T> obObjectList, boolean addParentheses)
Creates a comma separated string with the Id's of the OBObjects included in the List.static String
getInStrSet(Set<String> set)
Creates a comma separated string with the Id's of the Set of Strings.static Vector<String>
getIntersectionVector(Vector<String> v1, Vector<String> v2)
Returns a Vector<String> with the elements that appear in both v1 and v2 Vectorsstatic String
getJSConfirmOnChanges(VariablesSecureApp vars, String windowId)
Build a JavaScript variable used for prompting a confirmation on changesstatic String
getListValueName(String listName, String value, String lang)
Returns the name for a value in a list reference in the selected language.static String
getPreference(VariablesSecureApp vars, String context, String window)
Gets the value of the given preference.static OBError
getProcessInstanceMessage(ConnectionProvider conn, VariablesSecureApp vars, PInstanceProcessData[] pinstanceData)
static String
getReferenceableOrg(VariablesSecureApp vars, String currentOrg)
Returns the list of referenceables organizations from the current one.static String
getReferenceableOrg(ConnectionProvider conn, VariablesSecureApp vars, String currentOrg, String window, int accessLevel)
Returns the list of referenceables organizations from the current one.static String[]
getReferenceValues(ConnectionProvider connectionProvider, String language, String referenceId)
Gets the reference list for a particular reference idstatic String
getSelectorOrgs(ConnectionProvider conn, VariablesSecureApp vars, String currentOrg)
Returns the organization list for selectors, two cases are possible: Organization is empty (null or ""): accessible list of organizations will be returned.String
getServletInfo()
static Vector<String>
getStringVector(String s)
Returns a Vector<String> composed by the comma separated elements in String sstatic String
getTabURL(String tabId, String type, boolean completeURL)
Returns the URL for a tabstatic String
getTabURL(ConnectionProvider conn, String tabId, String type)
Deprecated.static String
getTabURL(Tab tab, String type, boolean completeURL)
Returns the URL for a tabstatic String
getTransactionalDate(ConnectionProvider conn, VariablesSecureApp vars, String window)
Gets the transactional range defined.static net.sf.jasperreports.engine.JasperReport
getTranslatedJasperReport(ConnectionProvider conn, String reportName, String language, String baseDesignPath)
Deprecated.static String
getVectorToString(Vector<String> v)
Returns the elements in Vector v as an String separating with commas the elementsstatic String
getWindowID(ConnectionProvider conn, String strTabID)
Gets the window id for a tab.static boolean
hasAttachments(ConnectionProvider conn, String userClient, String userOrg, String tableId, String recordId)
Deprecated.static boolean
isBigDecimal(String str)
Determine if a String can be parsed into a BigDecimal.static boolean
isBiggerDate(String strDate1, String strDate2, DateFormat DateFormatter)
static boolean
isDateTime(String reference)
Deprecated.static boolean
isDecimalNumber(String reference)
Deprecated.static boolean
isElementInList(String strList, String strElement)
Checks if an element is in a list.static boolean
isExcludedFromAutoSave(String canonicalName)
Checks if a class is excluded from the autosave processstatic boolean
isHexStringChar(char c)
Returns true if the input argument character is A-F, a-f or 0-9.static boolean
isID(String reference)
Deprecated.static boolean
isInFieldProvider(FieldProvider[] data, String fieldName, String key)
Checks if the value exists in the given array of FieldProviders.static boolean
isIntegerNumber(String reference)
Deprecated.static boolean
isModalProcess(String processId)
Same asisModalProcess(Process)
passing as parameter the process id.static boolean
isModalProcess(Process process)
Returns whether theProcess
should be opened in modal or in poup mode.static boolean
isNewUI()
Checks whether the current context is using new UIstatic boolean
isNumericParameter(String reference)
Deprecated.static boolean
isTreeTab(ConnectionProvider conn, String stradTabId)
Checks if the tab is declared as a tree tab.static boolean
isUUIDString(String CharacterString)
Determines if a string of characters is an Openbravo UUID (Universal Unique Identifier), i.e., if it is a 32 length hexadecimal string.static boolean
isWeekendDay(String strDay, DateFormat DateFormatter)
static FieldProvider
locateMessage(ConnectionProvider conn, String strCode, String strLanguage)
static boolean
mergeOpenbravoProperties(String originalFile, String newFile)
When updating core it is necessary to update Openbravo properties maintaining already assigned properties.static String
messageBD(ConnectionProvider conn, String strCode, String strLanguage)
static String
messageBD(ConnectionProvider conn, String strCode, String strLanguage, boolean escape)
static String
parseContext(ConnectionProvider conn, VariablesSecureApp vars, String context, String window)
Parse the given string searching the @ elements to translate with the correct values.static String
parseContext(ConnectionProvider conn, VariablesSecureApp vars, String context, String window, Vector<String> params)
Parse the given string searching the @ elements to translate with the correct values.static String
parseTranslation(ConnectionProvider conn, VariablesSecureApp vars, String language, String text)
static String
parseTranslation(ConnectionProvider conn, VariablesSecureApp vars, Map<String,String> replaceMap, String language, String text)
static byte[]
resizeImageByte(byte[] bytea, int maxW, int maxH, boolean maintainAspectRatio, boolean canMakeLargerImage)
Resize an image giving the image input as byte[]static BufferedImage
showImage(String id)
Provides the image as a BufferedImage object.static BufferedImage
showImageLogo(String logo)
Provides the image logo as a BufferedImage object.static BufferedImage
showImageLogo(String logo, String org)
Provides the image logo as a BufferedImage object.static String
stringBaseCurrencyId(ConnectionProvider conn, String strClientId)
Returns the ID of the base currency of the given clientstatic String
stringISOSymbol(ConnectionProvider conn, String strCurrencyID)
Returns the ISO code plus the symbol of the given currency in the form (ISO-SYM), e.g., (USD-$)static String
stringList(String list)
Returns a string list comma separated as SQL strings.static ArrayList<String>
stringToArrayList(String list)
Transforms a comma separated String into an ArrayListstatic ArrayList<String>
stringToArrayList(String[] list)
Transforms a String[] into an ArrayListstatic void
throwErrorMessage(String message)
Throws an OBException with a message in the right language.static String
translate(ConnectionProvider conn, VariablesSecureApp vars, String token, String language)
static OBError
translateError(ConnectionProvider conn, VariablesSecureApp vars, String strLanguage, String message)
static String
wikifiedName(String strSource)
Generates a String representing the wikified name from source
-
-
-
Field Detail
-
COMMUNITY_BRANDING_URL
public static final String COMMUNITY_BRANDING_URL
- See Also:
- Constant Field Values
-
STATIC_COMMUNITY_BRANDING_URL
public static final String STATIC_COMMUNITY_BRANDING_URL
- See Also:
- Constant Field Values
-
BUTLER_UTILS_URL
public static final String BUTLER_UTILS_URL
- See Also:
- Constant Field Values
-
-
Method Detail
-
getCommunityBrandingUrl
public static String getCommunityBrandingUrl()
Computes the community branding url on the basis of system information. Note the returned url does not contain the protocol part, it starts with //... So the caller has to prepend it with the needed protocol part (i.e. http: or https:).
-
isExcludedFromAutoSave
public static boolean isExcludedFromAutoSave(String canonicalName)
Checks if a class is excluded from the autosave process- Parameters:
canonicalName
-- Returns:
- True is the class is excluded or false if not.
-
isNumericParameter
@Deprecated public static boolean isNumericParameter(String reference)
Deprecated.Checks if a getNumericParameters is needed based on a reference. Deprecated, use UIReference.- Parameters:
reference
-- Returns:
- true if the passed reference represents a numeric type, false otherwise.
-
isID
@Deprecated public static boolean isID(String reference)
Deprecated.Checks if the reference is an ID. Deprecated, use UIReference.- Parameters:
reference
- String with the reference- Returns:
- True if is a ID reference
-
isDecimalNumber
@Deprecated public static boolean isDecimalNumber(String reference)
Deprecated.Checks if the references is a decimal number type. Deprecated, use UIReference.- Parameters:
reference
- String with the reference.- Returns:
- True if is a decimal or false if not.
-
isIntegerNumber
@Deprecated public static boolean isIntegerNumber(String reference)
Deprecated.Checks if the references is an integer number type. Deprecated, use UIReference.- Parameters:
reference
- String with the reference.- Returns:
- True if is an integer or false if not.
-
isDateTime
@Deprecated public static boolean isDateTime(String reference)
Deprecated.Checks if the references is a datetime type. Deprecated, use UIReference.- Parameters:
reference
- String with the reference.- Returns:
- True if is a datetime or false if not.
-
formatDate
public static String formatDate(Date date, String pattern)
- See Also:
OBDateUtils.formatDate(Date, String)
-
messageBD
public static String messageBD(ConnectionProvider conn, String strCode, String strLanguage)
-
messageBD
public static String messageBD(ConnectionProvider conn, String strCode, String strLanguage, boolean escape)
-
throwErrorMessage
public static void throwErrorMessage(String message)
Throws an OBException with a message in the right language.- Parameters:
message
- the key of the message
-
getPreference
public static String getPreference(VariablesSecureApp vars, String context, String window)
Gets the value of the given preference.- Parameters:
vars
- Handler for the session info.context
- String with the preference.window
- String with the window id.- Returns:
- String with the value.
-
getTransactionalDate
public static String getTransactionalDate(ConnectionProvider conn, VariablesSecureApp vars, String window)
Gets the transactional range defined.- Parameters:
conn
- Handler for the database connection.vars
- Handler for the session info.window
- String with the window id.- Returns:
- String with the value.
-
getContext
public static String getContext(ConnectionProvider conn, VariablesSecureApp vars, String context, String window)
Gets a value from the context. For client 0 is always added (used for references), to check if it must be added or not use the getContext with accesslevel method.- Parameters:
conn
- Handler for the database connection.vars
- Handler for the session info.context
- String with the parameter to search.window
- String with the window id.- Returns:
- String with the value.
-
getContext
public static String getContext(ConnectionProvider conn, VariablesSecureApp vars, String context, String strWindow, int accessLevel)
Gets a value from the context. Access level values: 1 Organization 3 Client/Organization 4 System only 6 System/Client 7 All- Parameters:
conn
- Handler for the database connection.vars
- Handler for the session info.context
- String with the parameter to search.strWindow
- String with the window id.accessLevel
-- Returns:
- String with the value.
-
getReferenceableOrg
public static String getReferenceableOrg(VariablesSecureApp vars, String currentOrg)
Returns the list of referenceables organizations from the current one. This includes all its ancestors and descendants.- Parameters:
vars
-currentOrg
-- Returns:
- comma delimited Stirng of referenceable organizations.
-
getReferenceableOrg
public static String getReferenceableOrg(ConnectionProvider conn, VariablesSecureApp vars, String currentOrg, String window, int accessLevel)
Returns the list of referenceables organizations from the current one. This includes all its ancestors and descendants. This method takes into account accessLevel and user level: useful to calculate org list for child tabs- Parameters:
conn
-vars
-currentOrg
-window
-accessLevel
-- Returns:
- the list of referenceable organizations, comma delimited
-
getSelectorOrgs
public static String getSelectorOrgs(ConnectionProvider conn, VariablesSecureApp vars, String currentOrg)
Returns the organization list for selectors, two cases are possible:- Organization is empty (null or ""): accessible list of organizations will be returned. This case is used in calls from filters to selectors.
- Organization is not empty: referenceable from current organization list of organizations will be returned. This is the way it is called from wad windows.
- Parameters:
conn
- Handler for the database connectionvars
-currentOrg
-- Returns:
- the organization list for selectors
-
getDefault
public static String getDefault(ConnectionProvider conn, VariablesSecureApp vars, String columnname, String context, String window, String defaultValue, FieldProvider sessionData)
Gets a default value.- Parameters:
conn
- Handler for the database connection.vars
- Handler for the session info.columnname
- String with the column name.context
- String with the parameter.window
- String with the window id.defaultValue
- with the default value.sessionData
- FieldProvider with the data stored in session- Returns:
- String with the value.
-
getDefault
public static String getDefault(ConnectionProvider conn, VariablesSecureApp vars, String columnname, String context, String window, String defaultValue)
Overloaded method for backwards compatibility
-
getStringVector
public static Vector<String> getStringVector(String s)
Returns a Vector<String> composed by the comma separated elements in String s- Parameters:
s
-- Returns:
- the list of String obtained by converting the comma delimited String
-
getIntersectionVector
public static Vector<String> getIntersectionVector(Vector<String> v1, Vector<String> v2)
Returns a Vector<String> with the elements that appear in both v1 and v2 Vectors- Parameters:
v1
-v2
-- Returns:
- the combination of v1 and v2 without duplicates
-
getVectorToString
public static String getVectorToString(Vector<String> v)
Returns the elements in Vector v as an String separating with commas the elements- Parameters:
v
-- Returns:
- a comma delimited String
-
parseContext
public static String parseContext(ConnectionProvider conn, VariablesSecureApp vars, String context, String window)
Parse the given string searching the @ elements to translate with the correct values. Parameters are directly inserted in the returned String.- Parameters:
conn
- Handler for the database connection.vars
- Handler for the session info.context
- String to parse.window
- String with the window id.- Returns:
- String parsed.
-
parseContext
public static String parseContext(ConnectionProvider conn, VariablesSecureApp vars, String context, String window, Vector<String> params)
Parse the given string searching the @ elements to translate with the correct values. If params is not null it adds a ? symbol in the context and adds the actual value to the params Vector, other case the actual value is replaced in the context.
-
getDocumentNo
public static String getDocumentNo(ConnectionProvider conn, VariablesSecureApp vars, String WindowNo, String TableName, String C_DocTypeTarget_ID, String C_DocType_ID, boolean onlyDocType, boolean updateNext)
Gets the document number from the database.- Parameters:
conn
- Handler for the database connection.vars
- Handler for the session info.WindowNo
- Window id.TableName
- Table name.C_DocTypeTarget_ID
- Id of the doctype target.C_DocType_ID
- id of the doctype.onlyDocType
- Search only for doctype.updateNext
- Save the new sequence in database.- Returns:
- String with the new document number.
-
getDocumentNo
public static String getDocumentNo(Connection conn, ConnectionProvider con, VariablesSecureApp vars, String WindowNo, String TableName, String C_DocTypeTarget_ID, String C_DocType_ID, boolean onlyDocType, boolean updateNext)
-
getDocumentNo
public static String getDocumentNo(ConnectionProvider conn, String AD_Client_ID, String TableName, boolean updateNext)
Gets the document number from database.- Parameters:
conn
- Handler for the database connection.AD_Client_ID
- String with the client id.TableName
- Table name.updateNext
- Save the new sequence in database.- Returns:
- String with the new document number.
-
getDocumentNoConnection
public static String getDocumentNoConnection(Connection conn, ConnectionProvider con, String AD_Client_ID, String TableName, boolean updateNext)
Gets the document number from database.- Parameters:
conn
- Handler for the database connection.AD_Client_ID
- String with the client id.TableName
- Table name.updateNext
- Save the new sequence in database.- Returns:
- String with the new document number.
-
addSystem
public static String addSystem(String list)
Adds the system element to the given list.- Parameters:
list
- String with the list.- Returns:
- String with the modified list.
-
canUpdate
public static boolean canUpdate(ConnectionProvider conn, VariablesSecureApp vars, String AD_Client_ID, String AD_Org_ID, String window) throws javax.servlet.ServletException
Checks if the user can make modifications in the window.- Parameters:
conn
- Handler for the database connection.vars
- Handler for the session info.AD_Client_ID
- Id of the client.AD_Org_ID
- Id of the organization.window
- Window id.- Returns:
- True if has permission, false if not.
- Throws:
javax.servlet.ServletException
-
parseTranslation
public static String parseTranslation(ConnectionProvider conn, VariablesSecureApp vars, String language, String text)
-
parseTranslation
public static String parseTranslation(ConnectionProvider conn, VariablesSecureApp vars, Map<String,String> replaceMap, String language, String text)
-
translate
public static String translate(ConnectionProvider conn, VariablesSecureApp vars, String token, String language)
-
isInFieldProvider
public static boolean isInFieldProvider(FieldProvider[] data, String fieldName, String key)
Checks if the value exists in the given array of FieldProviders.- Parameters:
data
- Array of FieldProviders.fieldName
- Name of the field to search.key
- The value to search.- Returns:
- True if exists or false if not.
-
getWindowID
public static String getWindowID(ConnectionProvider conn, String strTabID) throws javax.servlet.ServletException
Gets the window id for a tab.- Parameters:
conn
- Handler for the database connection.strTabID
- Id of the tab.- Returns:
- String with the id of the window.
- Throws:
javax.servlet.ServletException
-
generateFile
public static boolean generateFile(String strPath, String strFile, String data)
Saves the content into a fisical file.- Parameters:
strPath
- path for the file.strFile
- name of the file.data
- content of the file.- Returns:
- true if everything is ok or false if not.
-
generateFileEncoding
public static boolean generateFileEncoding(String strPath, String strFile, String data, String encoding)
-
isTreeTab
public static boolean isTreeTab(ConnectionProvider conn, String stradTabId) throws javax.servlet.ServletException
Checks if the tab is declared as a tree tab.- Parameters:
conn
- Handler for the database connection.stradTabId
- Id of the tab.- Returns:
- True if is a tree tab or false if isn't.
- Throws:
javax.servlet.ServletException
-
fillSQLParameters
public static void fillSQLParameters(ConnectionProvider conn, VariablesSecureApp vars, FieldProvider data, ComboTableData cmb, String window, String actual_value) throws javax.servlet.ServletException
Fill the parameters of the sql with the session values or FieldProvider values. Used in the combo fields.- Parameters:
conn
- Handler for the database connection.vars
- Handler for the session info.data
- FieldProvider with the columns values.cmb
- ComboTableData object.window
- Window id.actual_value
- actual value for the combo.- Throws:
javax.servlet.ServletException
- See Also:
ComboTableData.fillParameters(FieldProvider, String, String)
-
getProcessInstanceMessage
public static OBError getProcessInstanceMessage(ConnectionProvider conn, VariablesSecureApp vars, PInstanceProcessData[] pinstanceData) throws javax.servlet.ServletException
- Throws:
javax.servlet.ServletException
- See Also:
OBMessageUtils.getProcessInstanceMessage(ProcessInstance)
-
translateError
public static OBError translateError(ConnectionProvider conn, VariablesSecureApp vars, String strLanguage, String message)
-
locateMessage
public static FieldProvider locateMessage(ConnectionProvider conn, String strCode, String strLanguage)
-
getServletInfo
public String getServletInfo()
-
isElementInList
public static boolean isElementInList(String strList, String strElement)
Checks if an element is in a list. List is an string like "(e1, e2, e3,...)" where en are elements. It is inteeded to be used for checking user client and organizations.- Parameters:
strList
- List to check instrElement
- Element to check in the list- Returns:
- true in case the element is in the list
-
focusFieldJS
public static String focusFieldJS(String id)
Returns a JavaScript function to be used on selectors Depending on what element you want to focus, you pass the id- Parameters:
id
- the html tag id to focus on- Returns:
- a String JavaScript function
-
dumpFile
public static void dumpFile(String fileLocation, OutputStream outputstream)
Write the output to a file. It creates a file in the file location writing the content of the outputstream.- Parameters:
fileLocation
- the file where you are going to writeoutputstream
- the data source
-
stringList
public static String stringList(String list)
Returns a string list comma separated as SQL strings.- Returns:
- comma delimited quoted string
-
getInStrList
public static <T extends BaseOBObject> String getInStrList(List<T> obObjectList)
Creates a comma separated string with the Id's of the OBObjects included in the List.- Type Parameters:
T
-- Parameters:
obObjectList
- List of OBObjects- Returns:
- Comma separated string of Id's
-
getInStrList
public static <T extends BaseOBObject> String getInStrList(List<T> obObjectList, boolean addParentheses)
Creates a comma separated string with the Id's of the OBObjects included in the List.- Type Parameters:
T
-- Parameters:
obObjectList
- List of OBObjectsaddParentheses
- String will be surrounded with parentheses- Returns:
- Comma separated string of Id's
-
isUUIDString
public static boolean isUUIDString(String CharacterString)
Determines if a string of characters is an Openbravo UUID (Universal Unique Identifier), i.e., if it is a 32 length hexadecimal string.- Parameters:
CharacterString
- A string of characters.- Returns:
- Returns true if this string of characters is an UUID.
-
isHexStringChar
public static final boolean isHexStringChar(char c)
Returns true if the input argument character is A-F, a-f or 0-9.- Parameters:
c
- A single character.- Returns:
- Returns true if this character is hexadecimal.
-
deleteDir
public static boolean deleteDir(File[] f)
Deletes recursively a (non-empty) array of directories- Parameters:
f
-- Returns:
- true in case the deletion has been successful
-
deleteDir
public static boolean deleteDir(File f)
Deletes recursively a (non-empty) directory- Parameters:
f
-- Returns:
- true in case the deletion has been successful
-
fileToString
public static String fileToString(String strPath) throws FileNotFoundException
Generates a String representing the file in a path- Parameters:
strPath
-- Returns:
- file to a String
- Throws:
FileNotFoundException
-
wikifiedName
public static String wikifiedName(String strSource) throws FileNotFoundException
Generates a String representing the wikified name from source- Parameters:
strSource
-- Returns:
- strTarget: wikified name
- Throws:
FileNotFoundException
-
getButtonName
public static String getButtonName(ConnectionProvider conn, VariablesSecureApp vars, String reference, String currentValue, String buttonId, HashMap<String,String> usedButtonShortCuts, HashMap<String,String> reservedButtonShortCuts)
-
getButtonName
public static String getButtonName(ConnectionProvider conn, VariablesSecureApp vars, String fieldId, String buttonId, HashMap<String,String> usedButtonShortCuts, HashMap<String,String> reservedButtonShortCuts)
-
stringBaseCurrencyId
public static String stringBaseCurrencyId(ConnectionProvider conn, String strClientId) throws javax.servlet.ServletException
Returns the ID of the base currency of the given client- Parameters:
strClientId
- ID of client.- Returns:
- Returns String strBaseCurrencyId with the ID of the base currency.
- Throws:
javax.servlet.ServletException
-
getJSConfirmOnChanges
public static String getJSConfirmOnChanges(VariablesSecureApp vars, String windowId)
Build a JavaScript variable used for prompting a confirmation on changes- Parameters:
vars
- Helper to access the user contextwindowId
- Identifier of the window- Returns:
- A string containing a JavaScript variable to be used by the checkForChanges function (utils.js)
-
arrayListToString
@Deprecated public static String arrayListToString(ArrayList<String> list, boolean addQuotes)
Deprecated.Use instead the more genericStringCollectionUtils.commaSeparated(Collection, boolean)
Transforms an ArrayList to a String comma separated.- Parameters:
list
-- Returns:
- a comma separated String containing the contents of the array.
-
stringToArrayList
public static ArrayList<String> stringToArrayList(String list)
Transforms a comma separated String into an ArrayList- Parameters:
list
-- Returns:
- the list representation of the comma delimited String
-
stringToArrayList
public static ArrayList<String> stringToArrayList(String[] list)
Transforms a String[] into an ArrayList- Parameters:
list
-- Returns:
- the list representation of the array
-
stringISOSymbol
public static String stringISOSymbol(ConnectionProvider conn, String strCurrencyID) throws javax.servlet.ServletException
Returns the ISO code plus the symbol of the given currency in the form (ISO-SYM), e.g., (USD-$)- Parameters:
strCurrencyID
- ID of the currency.- Returns:
- Returns String strISOSymbol with the ISO code plus the symbol of the currency.
- Throws:
javax.servlet.ServletException
-
hasAttachments
@Deprecated public static boolean hasAttachments(ConnectionProvider conn, String userClient, String userOrg, String tableId, String recordId) throws javax.servlet.ServletException
Deprecated.- Throws:
javax.servlet.ServletException
-
calculateLaborDays
public static String calculateLaborDays(String strDate1, String strDate2, DateFormat DateFormatter) throws ParseException
- Throws:
ParseException
- See Also:
OBDateUtils.calculateLaborDays(String, String, DateFormat)
-
addDaysToDate
public static String addDaysToDate(String strDate, String strDays, DateFormat DateFormatter) throws ParseException
- Throws:
ParseException
- See Also:
OBDateUtils.addDaysToDate(String, int, DateFormat)
-
getDateFormatter
public static DateFormat getDateFormatter(VariablesSecureApp vars)
-
isWeekendDay
public static boolean isWeekendDay(String strDay, DateFormat DateFormatter) throws ParseException
- Throws:
ParseException
- See Also:
OBDateUtils.isWeekendDay(String, DateFormat)
-
isBiggerDate
public static boolean isBiggerDate(String strDate1, String strDate2, DateFormat DateFormatter) throws ParseException
- Throws:
ParseException
- See Also:
OBDateUtils.isBiggerDate(String, String, DateFormat)
-
getTranslatedJasperReport
@Deprecated public static net.sf.jasperreports.engine.JasperReport getTranslatedJasperReport(ConnectionProvider conn, String reportName, String language, String baseDesignPath) throws net.sf.jasperreports.engine.JRException
Deprecated.- Throws:
net.sf.jasperreports.engine.JRException
-
getTabURL
public static String getTabURL(Tab tab, String type, boolean completeURL)
Returns the URL for a tab- Parameters:
tab
- The tab to obtain the url fortype
- "R" -> Relation, "E" -> Edition, "X" -> ExcelcompleteURL
- if true returns the complete ULR including server name and context, if not, it return URL relative to base context- Returns:
- the URL for a tab.
-
getTabURL
public static String getTabURL(String tabId, String type, boolean completeURL)
Returns the URL for a tab- Parameters:
tabId
- Id for the tab to obtain the url fortype
- "R" -> Relation, "E" -> Edition, "X" -> ExcelcompleteURL
- if true returns the complete ULR including server name and context, if not, it return URL relative to base context- Returns:
- the URL for a tab.
-
getTabURL
@Deprecated public static String getTabURL(ConnectionProvider conn, String tabId, String type)
Deprecated.
-
isBigDecimal
public static boolean isBigDecimal(String str)
Determine if a String can be parsed into a BigDecimal.- Parameters:
str
- a String- Returns:
- true if the string can be parsed
-
mergeOpenbravoProperties
public static boolean mergeOpenbravoProperties(String originalFile, String newFile) throws FileNotFoundException, IOException
When updating core it is necessary to update Openbravo properties maintaining already assigned properties. Thus properties in original file are preserved but the new ones in Openbravo.properties.template file are added with the default value.- Returns:
- false in case no changes where needed, true in case the merge includes some changes and the original file is modified
- Throws:
IOException
FileNotFoundException
-
getListValueName
public static String getListValueName(String listName, String value, String lang)
Returns the name for a value in a list reference in the selected language.- Parameters:
listName
- Name for the reference list to look invalue
- Value to look forlang
- Language, if null the default language will be returned- Returns:
- Name for the value, in case the value is not found in the list the return is not the name but the passed value
-
arrayDobleEntrada
public static String arrayDobleEntrada(String strArrayName, FieldProvider[] data)
Constructs and returns a two dimensional array of the data passed. Array definition is constructed according to Javascript syntax. Used to generate data storage of lists or trees within some manual windows/reports.- Parameters:
strArrayName
- String with the name of the array to be defined.data
- FieldProvider object with the data to be included in the array with the following three columns mandatory: padre | id | name.- Returns:
- String containing array definition according to Javascript syntax.
-
arrayEntradaSimple
public static String arrayEntradaSimple(String strArrayName, FieldProvider[] data)
Constructs and returns a two dimensional array of the data passed. Array definition is constructed according to Javascript syntax. Used to generate data storage of lists or trees within some manual windows/reports.- Parameters:
strArrayName
- String with the name of the array to be defined.data
- FieldProvider object with the data to be included in the array with the following two columns mandatory: id | name.- Returns:
- String containing array definition according to Javascript syntax.
-
getReferenceValues
public static String[] getReferenceValues(ConnectionProvider connectionProvider, String language, String referenceId) throws javax.servlet.ServletException
Gets the reference list for a particular reference id- Parameters:
connectionProvider
-language
-referenceId
-- Returns:
- refValues string array containing reference values
- Throws:
javax.servlet.ServletException
-
getFormat
public static DecimalFormat getFormat(VariablesSecureApp vars, String typeName)
Returns a DecimalFormat for the given formatting type contained in the Format.xml file
-
isNewUI
public static boolean isNewUI()
Checks whether the current context is using new UI- Returns:
- true in case new UI is being used false if not
-
getImage
public static byte[] getImage(String id)
Provides the image as a byte array. These images are stored in the table AD_IMAGE as a BLOB field.- Parameters:
id
- The id of the image to display- Returns:
- The image requested
-
getImageObject
public static Image getImageObject(String id)
Provides the image as an image object. These images are stored in the table AD_IMAGE as a BLOB field.- Parameters:
id
- The id of the image to display- Returns:
- The image requested
-
showImage
public static BufferedImage showImage(String id) throws IOException
Provides the image as a BufferedImage object. Commonly used for reports.- Parameters:
id
- The id of the image to display- Returns:
- The image requested
- Throws:
IOException
- See Also:
getImage(String)
-
getImageLogoObject
public static Image getImageLogoObject(String logo, String org)
Provides the image logo as a byte array for the indicated parameters.- Parameters:
logo
- The name of the logo to display This can be one of the following: companylogo, companylogosubmark, companylogodocs, companylogoreceipts, youritservicelogin or banner-production The following values are also supported but they are deprecated in favor of the values above: yourcompanylogin, yourcompanymenu, yourcompanybig, yourcompanydoc, yourcompanylegalorg
- The organization id used to get the logo.- Returns:
- The image requested
-
getImageLogo
public static byte[] getImageLogo(String logo, String org)
Provides the image logo as a byte array for the indicated parameters.- Parameters:
logo
- The name of the logo to display This can be one of the following: companylogo, companylogosubmark, companylogodocs, companylogoreceipts, youritservicelogin or banner-production The following values are also supported but they are deprecated in favor of the values above: yourcompanylogin, yourcompanymenu, yourcompanybig, yourcompanydoc, yourcompanylegalorg
- The organization id used to get the logo.- Returns:
- The image requested
-
computeImageSize
public static Long[] computeImageSize(byte[] bytea) throws IOException
This method calculates the size of an image- Parameters:
bytea
- The contents of the image- Returns:
- An Long array with two elements (width, height)
- Throws:
IOException
-
resizeImageByte
public static byte[] resizeImageByte(byte[] bytea, int maxW, int maxH, boolean maintainAspectRatio, boolean canMakeLargerImage) throws IOException
Resize an image giving the image input as byte[]- Parameters:
bytea
- The contents of the image as a byte arraymaxW
- Maximum width that the image will be resized.maxH
- Maximum height that the image will be resized.maintainAspectRatio
- If true, the image will be resized exactly to the maximum parameters. If false, the imagen will be resized closest to the maximum parameters keeping aspect ratiocanMakeLargerImage
- If true and the original image is smaller than maximum parameters, the resized image could be larger than the original one. If false, not.- Returns:
- The resized image
- Throws:
IOException
-
showImageLogo
public static BufferedImage showImageLogo(String logo) throws IOException
Provides the image logo as a BufferedImage object. Commonly used for reports.- Parameters:
logo
- The name of the logo to display- Returns:
- The image requested
- Throws:
IOException
- See Also:
getImageLogo(String,String)
-
showImageLogo
public static BufferedImage showImageLogo(String logo, String org) throws IOException
Provides the image logo as a BufferedImage object. Commonly used for reports.- Parameters:
logo
- The name of the logo to displayorg
- The organization id used to get the logo- Returns:
- The image requested
- Throws:
IOException
- See Also:
getImageLogo(String,String)
-
isModalProcess
public static boolean isModalProcess(Process process)
Returns whether theProcess
should be opened in modal or in poup mode.- Parameters:
process
- Process to check- Returns:
true
in case it should be opened in modal,false
if not.
-
isModalProcess
public static boolean isModalProcess(String processId)
Same asisModalProcess(Process)
passing as parameter the process id.- Parameters:
processId
- to check- Returns:
true
in case it should be opened in modal,false
if not.- See Also:
isModalProcess(Process)
-
getFieldName
public static String getFieldName(String fieldId, String language)
Returns a field name in the specified language. If there is not translation for that language, it returns the base name of the field.- Parameters:
fieldId
- ID of the field to look for.language
- Language to get the name in.- Returns:
- field name in the correct language.
-
getInStrSet
public static String getInStrSet(Set<String> set)
Creates a comma separated string with the Id's of the Set of Strings.- Parameters:
set
- Set of Strings- Returns:
- Comma separated string of Id's
-
getCountryFromOrgId
public static Country getCountryFromOrgId(String orgid)
Gets the country of the organization.- Parameters:
orgid
- ID of the organization.- Returns:
- the country of the organization or null if the organization address is not defined.
-
applyCountryDateFormat
public static String applyCountryDateFormat(Date date, String orgid)
Gets the date format for the organization country.- Parameters:
date
- Date to apply the format.orgid
- ID of the organization.- Returns:
- date with the country format string applied. In case is not defined, a default format is applied
-
applyCountryDateFormat
public static String applyCountryDateFormat(Timestamp timeStamp, String orgid)
Gets the date format for the organization country.- Parameters:
timeStamp
- TimeStamp to apply the format.orgid
- ID of the organization.- Returns:
- date with the country format string applied. In case is not defined, a default format is applied
-
getCountryNumberFormat
public static DecimalFormat getCountryNumberFormat(String orgid, DecimalFormat defaultDecimalFormat)
Gets the number format for the organization country.- Parameters:
orgid
- ID of the organization.defaultDecimalFormat
- Default decimal format. It will be returned in case the country of the organization is not defined.- Returns:
- DecimalFormat for the number representation defined for the country.
-
-