Thursday, June 9, 2016

Solve Jenkins and Subversion time sync issue

You will notice below warning when your Jenkins server and Subversion server have different times (not in a time sync status)

WARNING: clock of the subversion server appears to be out of sync. This can result in inconsistent check out behavior.

There are two ways to sync Jenkins server with svn.
  1. Based on Jenkins time and svn time
  2. Based on Jenkins revision number and snv revision number

Before build projects Jenkins takes updates from svn. If times are not synced changes will not reflect properly. To solve this issue you can configure Jenkins to take updates based on head revision. Fix is simple.
You just have to add @HEAD to the end of your svn url.

for example:
If your previous svn url is 'http://your.svn.server/svnroot/your/code/location'
add @HEAD to the end of url.
New url is 'http://your.svn.server/svnroot/your/code/location@HEAD'

This will solve Jenkins and svn out of sync issues.


Cheers..!!

Saturday, June 6, 2015

Why URI Encoding...?


Most of you must heard about URI Encoding...

Why do we need to Encode URIs?

It is because otherwise servers cannot identify what we sent there.

When we are accessing/using urls we cannot add spaces there. While sending a GET request you may want to add spaces there. Then how do you send those data..?
When we are accessing/using urls we cannot add '/' there. '/' is reserved for use as a component separator. Then how do you send those data..?
Consider that you want to send a XML file attached there..

Here comes the URI encoding.

For example:
you want to encode this
http://www.mysite.com/?XML=<cs><o n="authcode" v="d82709ae"/><c n="FlightSearch"><q n="StartDate" v="18-May-2015"/><q n="EndDate" v="21-May-2015"/></c></cs>

into this
http://www.mysite.com/?XML=%3Ccs%3E%0A%3Co%20n=%22authcode%22%20v=%22d82709ae%22/%3E%0A%3Cc%20n=%22FlightSearch%22%3E%3Cq%20n=%22StartDate%22%20v=%2218-May-2015%22/%3E%0A%3Cq%20n=%22EndDate%22%20v=%2221-May-2015%22/%3E%3C/c%3E%0A%3C/cs%3E


You can try it here..


URL:






Cheers...!!

Sunday, March 29, 2015

Automatic data refresh Oracle ADF tables using ADF Poll

As you know we are using Oracle ADF tables to represent data at database tables, views, etc... When application loads tables load data from db and displays those. But if data is changed or new added or existing data get deleted..?? Then we need a mechanism to display the updated data.

We can use ADF Poll for this. Then we can use poll event to refresh table data after every time period.


Steps:



  1. Insert Poll inside “panelHeader” in which table is located
  2. Set poll interval from poll properties- This is the time gap for every refresh. for Ex: if you have set poll interval as 5 seconds table data will be refreshed after every 5 seconds.

    If you want you can take this value from template properties.
    Value you entered: #{manage_Template.dataRefreshRate}
    (This is used to get the refresh value by using the method in manage_Template)
  3. Set partial triggers from poll properties - Here you can specify the table which you want to get refreshed. for Ex: table1
  4. Set partial triggers from ADF table - Give the poll id for this field.
    Table --> Behavior --> Partial Triggers --> Set poll id here
  5. Set Poll Listener from poll properties - This is the most important mapping which links what is the action has to be taken out when poll event triggers

    Type a method e.g.: refreshSPIntentionTab ()
    Press enter
    (Method is created in .java file)
  6. Add the below code to the poll listener method using appropriate VOIterators


    There are three stages at this code.


    STAGE 1:

    If you want only to refresh the table you can use the current method. At this method you can’t maintain the current row position after table refresh.

    public void refreshSPIntentionTab (PollEvent pollEvent) {
            FacesContext fctx = FacesContext.getCurrentInstance();
            ValueBinding dcb = fctx.getApplication().createValueBinding("#{bindings}");
            DCBindingContainer bindings1 = (DCBindingContainer) dcb.getValue(fctx);
            if(bindings1!=null){
                DCIteratorBinding dciter = bindings1.findIteratorBinding("DeliveryIntentionsSPApprovVO1Iterator ");
                if(dciter!=null){
                    if(dciter.getCurrentRow()!=null){  
                        dciter.executeQuery();
                    }
                }
            }
        }


    STAGE 2:

    If you want to refresh the table and maintain the current row position after the table refresh.... We can apply this only for a single table; not for master-detail tables.

    public void refreshSPIntentionTab (PollEvent pollEvent) {
            FacesContext fctx = FacesContext.getCurrentInstance();
            ValueBinding dcb = fctx.getApplication().createValueBinding("#{bindings}");
            DCBindingContainer bindings1 = (DCBindingContainer)dcb.getValue(fctx);
            if (bindings1 != null) {
                DCIteratorBinding dciter = bindings1.findIteratorBinding("DeliveryIntentionsSPApprovVO1Iterator ");
                if (dciter != null) {
                    if (dciter.getCurrentRow() != null) {
                        Key current_row_key = dciter.getCurrentRow().getKey();
                        dciter.executeQuery();
                        if (current_row_key != null) {
                            try {
                                dciter.setCurrentRowWithKey(current_row_key.toStringFormat(true));
                            } catch (Exception ex) {
                                System.out.println("Exception in current_row_key");
                            }
                        }
                    }
                }
            }
        }


    STAGE 3:

    If you want to maintain the current row position of master-detail tables after the table refresh, use the following methods.

    // for the master table refresh
    public void refreshSPIntentionTab (PollEvent pollEvent) {
            FacesContext fctx = FacesContext.getCurrentInstance();
            ValueBinding dcb = fctx.getApplication().createValueBinding("#{bindings}");
            DCBindingContainer bindings1 = (DCBindingContainer)dcb.getValue(fctx);
            DCIteratorBinding it = bindings1.findIteratorBinding("DeliveryIntentionsSPApprovVO1Iterator");
            ViewObject vo = it.getViewObject();
            Row row = vo.getCurrentRow();
            Key key = row.getKey();
            int rangePosition = vo.getRangeIndexOf(row);
            int rangeStart = vo.getRangeStart();
            if(rangePosition==(-1)){
                rangePosition=rangePositionCommon;
                rangeStart=rangeStartCommon;
                }
            vo.executeQuery();
            vo.setRangeStart(rangeStart);
            Row[] rows = vo.findByKey(key, 1);
            if (rows != null && rows.length == 1) {            
                vo.scrollRangeTo(rows[0], rangePosition);
                vo.setCurrentRowAtRangeIndex(vo.getRangeIndexOf(rows[0]));
                rangePositionCommon=rangePosition;
                rangeStartCommon=rangeStart;
            }
        }

    // for the detail table refresh
    public void refreshSPIntentionTab (PollEvent pollEvent) {
            FacesContext fctx = FacesContext.getCurrentInstance();
            ValueBinding dcb = fctx.getApplication().createValueBinding("#{bindings}");
            DCBindingContainer bindings1 = (DCBindingContainer) dcb.getValue(fctx);
            if(bindings1!=null){
                DCIteratorBinding dciter = bindings1.findIteratorBinding("DeliveryIntentionsSPApprovVO1Iterator ");
                if(dciter!=null){
                    if(dciter.getCurrentRow()!=null){  
                        dciter.executeQuery();
                    }
                }
            }
        }

Now all the setup processes are completed. Please check your new functionality.


Cheers..!!

Saturday, February 14, 2015

Find Gender and Birthday by NIC Number


National Identity Card number is unique for each Sri Lankan.
At a glance it is just a sequence of numbers; but it contains some hidden details such as the persons gender and date of birth.
You can calculate those from below form. Enter your NIC no and click on "GO" button.
Note: There are two sections for Old format NIC and New format NIC.

Old NIC No  :
Gender   :
Birthday : 

New NIC No  :
Gender   :
Birthday : 


Cheers..!!

Saturday, September 21, 2013

How to set JXL Character Encoding

JXL (Java Excel API) is a open source Java API which allows Java developers to read Excel spreadsheets and to generate Excel spreadsheets dynamically. In addition, it contains a mechanism which allows java applications to read in a spreadsheet, modify some cells and write out the new spreadsheet.

You can learn how to use it by the following link.

At the default settings JXL is unable to read some special characters such like ®, ™, ©, etc.. which are used commonly.
This is the way how to overcome that issue.

Usually you can create the Workbook file as below.

Workbook workbook = Workbook.getWorkbook( new File(<path_to_excel_file>) );



At that case you can not read special characters like above mentioned. So this is the solution.

WorkbookSettings ws = new WorkbookSettings();
ws.setEncoding("CP1250");
Workbook workbook = Workbook.getWorkbook( new File(<path_to_excel_file>), ws );



Here CP1250 is a standard character encoding format. Like that you can specify what is the Character set you are going to use (ex: utf8, cp1250, etc...). So set the character set at the very beginning. Then you can read and write the characters which are defined under that character encoding system.

Cheers...!!

Tuesday, August 20, 2013

Convert XSD file to JAR by one command



What is XSD ....??

It is considered as the grammar of the XML... The XML Schema language is also referred to as XML Schema Definition (XSD). Simply XSD files are used to validate XML.


XSD files can be converted to a JAR file simply using the Apache XMLBeans

If you have already setup Apache XMLBeans then go to the folder which contains the xsd file and apply the below command which will convert xsd file to a jar file. (if not follow the Setup XMLBeans instructions)

>> scomp -out <jar_file_name.jar> <xsd_document_name.xsd>

example:
>> scomp -out getSupplierNames.jar getSupplierNames.xsd

Setup XMLBeans

First you have to setup Apache Ant and JDK 1.4 or later version.

JDK installation...
JDK can be downloaded from Java downloads. Install it and set the Environment Variables if they are not set correctly (Right click My Computer --> Properties --> Advanced --> Environment Variables --> System Variables)
    Variable: JAVA_HOME
    Value   : <folder where the JDK software is located>

If PATH variale exists append the value, else add the value.
    Variable: PATH
    Value   : %JAVA_HOME%\bin

Apache Ant installation...
Apache Ant can be downloaded from Ant Binary Distributions. Download the zip file and extract it.
Set below Environment Variables as described above.
    Variable: ANT_HOME
    Value   : <folder where you uncompressed Ant to>


If PATH variale exists append the value, else add the value.
    Variable: PATH
    Value   : %ANT_HOME%/bin

Apache XMLBeans installation...
 Apache XMLBeans can be downloaded from download mirrors. Download the zip file and extract it.
Set below Environment Variables as described earlier.
    Variable: XMLBEANS_HOME
    Value   : <folder where you uncompressed XMLBeans to>


If PATH variale exists append the value, else add the value.
    Variable: PATH
    Value   : %XMLBEANS_HOME%\bin

If CLASSPATH variale exists append the value, else add the value.
    Variable: CLASSPATH
    Value   : <path to xbean.jar>
              [usually this should be %XMLBEANS_HOME%\xbean.jar]

Now all the setup processes are completed and you can convert XSD files to JAR files using the scomp command as described at the top of the article....

CHEERS.......!!



Monday, August 20, 2012

How to Change Folder Background Win7


  1. First we have to unhide the protected operating system files.
    Goto any folder.
    Then Organize --> Folder and Search Options --> View (second tab)
    Select "Show hidden files, folders and drivers".
    then uncheck "Hide protected operating system files (Recommended)".
     
  2. Then a file called "desktop.ini" will visible (that file may not be there too). If the "desktop.ini" is not at there then you will have to create it by yourself (just create a file and rename it to "desktop.ini" ).
     
  3. Then enter the following code to the "desktop.ini" file.
    [AveFolder]
    IconArea_Image=E:\images\listening_music-1366x768.jpg


  1. At that code " E:\images\listening_music-1366x768.jpg" is the the path & the name of the image you are going to set as your folder background.
     
  2. After applying the image your folder names may not be clearly visible for you. So you can change the folder font color by adding the following code for the "desktop.ini" file (you can change the color by changing the TestR, TextG and TextB values. given values are the corresponding values for WHITE).
    TextR=255
    TextG=255
    TextB=255

  1. Furthermore you can enable the "shadow text" feature by adding the following code to "desktop.ini" file.
    ShadowedText=1
     
That is how it happens and now you are OK... :D :D
Good luck....!!