Utility Class in Web Mapper

You can use inbuilt mapper utility classes and global methods available in the Web Mapper to map the elements. To use methods,

  1. Access the Web Mapper.
  2. From the Parameters panel, do the following as per your requirement:
    1. For mapper utility classes, expand Methods > Global > MapperUtilityClass. The list of methods appears. The description of the methods is described later in this section.




    2. For global methods, expand  Methods > Global > GlobalMethodCall. The list of methods appears. The description of the methods is described later in this section.



  3. Select the appropriate method from the Parameters panel. The definition of the method appears on the selected tab.

Methods Available in the Web Mapper

Following are the methods available in the class MapperUtilityClass. Click on the method to know its summary an syntax.

 

 charAt ()

Summary:

Returns the character at the specified index. This method accepts following two parameters: data string and an integer index.

Syntax:

java:MapperUtilityClass.charAt('Adeptia', 3) 
 equalsIgnoreCase ()

Summary:

Compares one string to another string, ignoring case considerations, and returns true or false. Two strings are considered equal ignoring case if they are of the same length and corresponding characters in the two strings are the equal ignoring case.

Syntax:

java:MapperUtilityClass.equalsIgnoreCase('adeptia','ADEPTIA') 
 matches ()

Summary:

Checks if the given data string matches the given regular expression. This method accepts following two parameters: data string and regular expression.

Syntax:

java:MapperUtilityClass.matches('Welcome to Adeptia.com',"(.*)Adeptia(.*)")
 replaceAll ()

Summary:

Replaces all the occurrences of a particular string from the given data string. This method accepts following three parameters - data string, value to be replaced, and the replaced value.

Syntax:

java:MapperUtilityClass.replaceAll('beauty','y' ,'iful') 
 replaceFirst ()

Summary:

Replaces the first occurrence of a particular string from the given data string. This method accepts following three parameters - data string, value to be replaced, and the replaced value.

Syntax:

java:MapperUtilityClass.replaceFirst('adeptia','a' ,'A') 
 toLowerCase ()

Summary:

Converts the data string to lower case. This method accepts one string type parameter only.

Syntax:

java:MapperUtilityClass.toLowerCase('ADEPTIA') 
 toUpperCase ()

Summary:

Converts the data string to upper case. This method accepts one string type parameter only.

Syntax:

java:MapperUtilityClass.toUpperCase('adeptia') 
 getCurrentDate ()

Summary:

Gets the current date and time from the server and gives the output in the desired Java Time Zone. This method accepts following two parameters: Date/Time format in the data string and Time Zone in the data string.

Syntax:

java:MapperUtilityClass.getCurrentDate(‘yyyy-MM-dd HH:mm:ss’ , ‘time-zone’) 
 abortMapping ()

Summary:

Aborts the mapping. This method accepts one string type parameter only.

Syntax:

java:MapperUtilityClass.abortMapping("Error message") 
 stringToHex ()

Summary:

Converts the string to hexadecimal representation. This method accepts one string type parameter only.

Syntax:

java:MapperUtilityClass.stringToHex('Adeptia') 
 newLineBefore ()

Summary:

Inserts a new line just before the start of the data. This method accepts one string type parameter only.

Syntax:

java:MapperUtilityClass.newLineBefore('Adeptia') 
 newLineAfter ()

Summary:

Inserts a newline at the end of the data. This method accepts one string type parameter only.

Syntax:

java:MapperUtilityClass.newLineAfter('Adeptia') 
 newLineBeforeAndAfter ()

Summary:

Inserts a new line just before the start of the data and at the end of the data. This method accepts one string type parameter only.

Syntax:

java:MapperUtilityClass.newLineBeforeAndAfter('Adeptia') 
 getRandomNumber ()

Summary:

Generates a random number. This method accepts no input parameter.

Syntax:

java:MapperUtilityClass.getRandomNumber() 
 getNextorPreviousDate ()

Summary:

Adds or subtracts the number of days to the current date based on the value passed. If the value passed is a positive integer then it will add the passed number of days to the current date and vice versa. This method accepts one integer type parameter only.

Syntax:

java:MapperUtilityClass.getNextorPreviousDate(2) 
 getJulian7fromDate ()

Summary:

Converts the date to the Julian date format CCYYDDD. This method accepts following two parameters: date string and the format of the date passed.

Syntax:

java:MapperUtilityClass.getJulian7FromDate('dd-MM-yyyy','yyyyddd') 
 getJulian7IntoDate ()

Summary:

Converts the Julian date CCYYDDD to the date format. This method accepts following two parameters: Julian date string and the format of the date.

Syntax:

java:MapperUtilityClass.putJulian7IntoDate('2008354','yyyyMMdd') 
 dateAdd ()

Summary:

Increases the date and time stamp by the values specified in the parameters passed. This method accepts following nine parameters: date-time in the string format, date-time in the string format in which you have entered the previous parameter value, date-time in string format in which you want the output, an integer value by which you want to increase the year, an integer value by which you want to increase the month, an integer value by which you want to increase the day, an integer value by which you want to increase the hours, an integer value by which you want to increase the minutes, and an integer value by which you want to increase the seconds.

Syntax:

java:MapperUtilityClass.dateAdd(‘2013-11-27 HH:mm:ss’, ‘yyyy-MM-dd HH:mm:ss’, ‘MM-dd-yyyy HH:mm:ss’, yyyy, MM, dd, hh, mm, ss) 
 executeDbUpdateQuery ()

Summary:

Performs an update operation in the database. This method accepts following two parameters: dBConnectionInfoID and database query.

Syntax:

java:MapperUtilityClass.executeDbUpdateQuery( $dbInfo,'select * from Table') 
 executeDbInsertQuery ()

Summary:

Performs an insert operation on the database. This method accepts following two parameters: dBConnectionInfoID and database query.

Syntax:

java:MapperUtilityClass.executeDbInsertQuery($dbInfo,'select * from Table') 
 executeDbDeleteQuery ()

Summary:

Performs the delete operation on the database. This method accepts following two parameters: dBConnectionInfoID and database query.

Syntax:

java:MapperUtilityClass.executeDbDeleteQuery($dbInfo,'select * from Table') 
 encodefileAsBase64 ()

Summary:

Encodes the data as Base64. This method accepts one string type parameter only.

Syntax:

java:MapperUtilityClass.encodeFileAsBase64('C:\SourceFile.txt') 
 invokeREST ()

Summary:

Calls RESTful web service. This method accepts following eight parameters. All the parameters should be of String format. Parameter details are as follows:

  1. URL of the REST web service.
  2. Operation (GET, PUT, POST, or DELETE) to be performed.
  3. Data to be sent with POST request. This field is optional. For GET request and other web services that don't require any input, leave this field blank (' ').
  4. Request media type, for example, text/html, application/xml.
  5. Response media type, for example, text/html, application/xml.
  6. HTTP header to be sent with the request. Multiple header parameters should be separated by a comma, for example, name=san, id=3.
  7. Username to perform authentication of your web service. Leave this parameter blank (' ') if the web service doesn't require any authentication.
  8. Password to perform authentication of your web service. Leave this parameter blank (' ') if the web service doesn't require any authentication.

Syntax:

java:MapperUtilityClass.invokeREST('http://www.thomas-bayer.com/sqlrest/PRODUCT/12','GET/POST/PUT/DELETE','data to be sent (optional for get)' ,'application/xml','application/xml','Accept-Charset=utf-8,Cache-Control=no-cache,Content-Type: application/xml','username','password') 

 

Following are the global methods available in the class GlobalMehthodCall. Click on the method to know its summary an syntax.

 

 getAge ()

Summary:

Returns the present age. This method accepts one string type parameter only in the <parameter-name> format.

Syntax:

java:GlobalMethodCall.getAge(‘dd-MM-yyyy HH:mm:ss’) 
 getDaysLeft ()

Summary:

Returns a value (-1 or 0) depending on the value that you pass in it. This method accepts one string type parameter only in the <parameter-name> format.

It returns 0 if the value passed is greater than the current time and returns -1 if the value passed is less than the current time.

You have to pass the value in yyyy-MM-dd HH:mm:ss format.

Syntax:

java:GlobalMethodCall.getDaysLeft(‘yyyy-MM-dd’) 
 getAccountType ()

Summary:

Returns the account type of the parameter passed to it. This method accepts one string type parameter only in the <parameter-name> format. It returns following three values: AlphabetNumeric, NumericNumeric, and ErrorData.

If you pass an alphabet followed by some numeral then it returns AlphabetNumeric. If you pass numeral followed by another numeral then it returns NumericNumeric. If you pass any other values or do not add a delimiter (-) between the two values then it returns ErrorData.

Syntax:

java:GlobalMethodCall.getAccountType('alphabet-number-alphabet')
java:GlobalMethodCall.getAccountType('number-number-alphabet')