sexta-feira, 30 de maio de 2014

Use Stringbuffer

2.12 Use Stringbuffer Instead of String Concatenation

The String class is the most commonly used class in Java. Especially in Web applications, it is used extensively to generate and format HTML content.
String is designed to be immutable; in order to modify a String, you have to create a new String object. Therefore, string concatenation can result in creating many intermediate String objects before the final String can be constructed. StringBuffer is the mutable companion class of String; it allows you to modify the String. Therefore, StringBuffer is generally more efficient than String when concatenation is needed.
This section also features the following practices:

2.12.1 Use StringBuffer Instead of String Concatenation If You Repeatedly Append to a String In Multiple Statements

Using the "+=" operation on a String repeatedly is expensive.
For example:
String s = new
String();
     [do some work ...]
s += s1;
     [do some more work...]
s += s2;

Replace the above string concatenation with a StringBuffer:
StringBuffer strbuf = new StringBuffer();
     [do some work ...]
strbuf.append(s1);
     [so some more work ...]
strbuf.append(s2);
String s = strbuf.toString();

2.12.2 Use Either String or StringBuffer If the Concatenation Is Within One Statement

String and StringBuffer perform the same in some cases; so you do not need to use StringBuffer directly.
    String s = "a" + "b" + "c";
to
    String s = "abc";
 
Optimization is done automatically by the compiler.
  • The Java2 compiler will automatically collapse the above.
  • The Java2 compiler will also automatically convert the following:
             String s = s1 + s2;
        to
             String s = (new StringBuffer()).append(s1).append(s2).toString();
    
    
    
    
    In these cases, there is no need to use StringBuffer directly.

2.12.3 Use StringBuffer Instead of String Concatenation If You Know the Size of the String

The default character buffer for StringBuffer is 16. When the buffer is full, a new one has to be re-allocated (usually at twice the size of the original one). The old buffer will be released after the content is copied to the new one. This constant reallocation can be avoided if the StringBuffer is created with a buffer size that is big enough to hold the String.
The following will be more efficient than using a String concatenation.
    String s = (new StringBuffer(1024)).
append(s1).append(s2). toString();

will be faster than
    String s = s1 + s2;

The-Dining-Philosophers-Problem

http://adit.io/posts/2013-05-11-The-Dining-Philosophers-Problem-With-Ron-Swanson.html


terça-feira, 27 de maio de 2014

Cascade

Form
select USR_LOGIN as lkv_encoded from USR where UPPER(USR_LOGIN)!=(UPPER(NVL('$Form
data.UD_HQ_SMBOB_PRIMARY_OWNER_CII$','0'))) and (USR_UDF_RESOURCE_TYPE = 'INT' or USR_UDF_RESOURCE_TYPE = 'CON')


<PrePopulationAdapter name="Prepop" classname="ca.qc.hydro.gia.adapters.PrePopulatePrimaryOwner"/>
</AttributeReference>
<AttributeReference available-in-bulk="true" length="100" widget="lookup-query" type="String" required="true" attr-ref="Secondary OwnerCII" name="CII du responsable suppléant">
<lookupQuery lookup-query="select USR_LOGIN as CII_du_responsable_suppléant from USR where UPPER(USR_LOGIN)!=(UPPER('$Form data.Primary OwnerCII''')) and (UPPER(USR_EMP_TYPE)='EMPLOYEE' or UPPER(USR_EMP_TYPE)='CONSULTANT')" display-field="CII_du_responsable_suppléant" save-field="CII_du_responsable_suppléant"/>
</AttributeReference>
</request-data-set>

segunda-feira, 10 de março de 2014

SAP connector


Transforma EMP type do idoc.


----

Employee Type

import java.util.HashMap;
import oracle.iam.connectors.common.transform.Transformation;

import common.utils.CustLogger;
import common.utils.Constants11g;

public class EmployeeTypeTransform implements Transformation {
 
    private CustLogger logger = new CustLogger("OIMCP.SAPH");
    private String sClassName = getClass().getName();
         
    public Object transform(HashMap hmUserDetails, HashMap hmEntitlementDetails,String sField) {

     String sMethodName = "transform";
     logger.setMethodStartLog(sClassName, sMethodName);
     String sEmpType = Constants11g.EMP_TYPE_FULL_TIME;
   
     if(null != hmUserDetails) {
  
        //Declare and initialize user details from recon
        String sResourceType = (String)hmUserDetails.get("Resource Type");
          
        logger.info(sClassName, sMethodName, "Resource Type: " + sResourceType);
             
        //Verifies user Resource Type and sets Employee Type
            if (sResourceType.equalsIgnoreCase(Constants11g.RES_TYPE_INT) ) {
                sEmpType = Constants11g.EMP_TYPE_EMPLOYEE;
            } else if(sResourceType.equals(Constants11g.RES_TYPE_CON)) {
                sEmpType = Constants11g.EMP_TYPE_CONSULTANT;
            } else if(sResourceType.equals(Constants11g.RES_TYPE_PAR)) {
                sEmpType = Constants11g.EMP_TYPE_PARTNER;
            }
        
        logger.info(sClassName, sMethodName, "Setting Employee Type to : " + sEmpType);
     }
   
    return sEmpType;
  
 }

Configurei 2 Lookups para ativar a transformacao:
- Lookup.SAP.HRMS.ReconTransformation

Employee Type package.classEmployeeTypeTransform
 
- Lookup.SAP.HRMS.Configuration

Use Transformation For Recon: Yes
 
Sao