Wednesday, May 15, 2013

Save Point and Save Point Restore Activity Part1

Hi All ,

I did a sample POC which explained you what is use of save point restore activity in the task flow and also how to take snapshot of application and store into table base and later restore from back.

In developer guide following explanation is present about save point and save point restore activity.

Save Point :'A save point captures a snapshot of the Fusion web application at a specific instance.'

Save Point Restore Activity:'Save point restore enables the application to restore whatever was captured when the save point was originally created.'

Use Case:We have one page with two part where one part is used for link and second one is for dynamic region.Take a example that we have two link one is welcome link and another one is create employee link.
So if we toggle from one link to another link then data which we filled in employee form will automatically lost which we do not want.However we want to give privilege to user for restoring their lost data which still not into database.

Although there are two type of implementation approach for save point and they are

1-Implicit Save Point
2-Explicit Save Point

Here in this post i will explain explicit save point.

Ingredient for creating save point and restore save point :

1-One method for creating the save point.
2-Save Point Activity

Implementation of Explicit save point:

1-Creation of model Layer
2-Creation of View Layer
3-Configuration of data base to save save point to table
4-Creation of save point
5-Adding restore save point activity on task flow
6-Removing restore save point data from table

1-Creation of model Layer: I just created employee Entity object,View Object and added View Object into Application module.


  


2-Creation of View Layer :Create one bounded task flow which contains all save point related information and also view pages .




3-Configuration of data base to save save point to table: By default jdevelope does not configure target location for saving save point value into data base.Therefore we need to do configuration.
Step are following

1-Go to the Application resources section
2-Open adf-config.xml file
3-Click on controller section
4-Under save point add your data base connection it can be jndi name





5-After adding entry it will add following metadata code inside it file

<adf-controller-config xmlns="http://xmlns.oracle.com/adf/controller/config">
    <savepoint-datasource>
      java:comp/env/jdbc/Connection1DS
    </savepoint-datasource>
  </adf-controller-config>

Data base configuration has been finished.

4-Creation of save point : For creating save point you need to first identity where you want to take the snapshot of application.In my case i have one button which call save.And it will use for create the save point and take the snapshot.

You have call following method to take the snapshot of application however there are two way to call this method.

createSavePoint
java.lang.String createSavePoint()
Creates a save point with no custom attributes. The save point will be automatically removed when a top level bounded task flow on the stack completes execution. In order to ensure successful save point creation, all entries in the page flow scope must be serializable.

Returns:id of the save point that was created, or null if the save point was not successfully created.

1-You can call using expression language code
#{controllerContext.savePointManager.createSavePoint}

2-You can also call using java code and i have doing in my application using java code and code are

    public String saveTaskFlow() {
        ControllerContext controllerContext = ControllerContext.getInstance();
        String savePointId = null;
        if (controllerContext != null) {
            SavePointManager savePointManager =
                controllerContext.getSavePointManager();
            if (savePointManager != null) {
                //creating the save point
                savePointId = savePointManager.createSavePoint();
                //putting the save point id into session scope
                ADFContext.getCurrent().getSessionScope().put("savePointId",
                                                              savePointId);
            }
        }
        return null;
    }

5-Adding restore save point activity on task flow : You need to drag and drop save point restore activity into task flow to restoring the application. And you need to provide correct save point it. In my case it is available in session scope.Therefore i am passing it from session scope.


6-Removing restore save point data from table: In task flow there is one property call save point restore finalize which take method as value and it will called method after restoring snapshot.

Here you can get the hook point and you can write code which execute after restoring the save point.

    public void removeId() {
        String savePointId =
            (String)ADFContext.getCurrent().getSessionScope().get("savePointId");
        if (savePointId != null) {
            ControllerContext controllerContext =
                ControllerContext.getInstance();
            if (controllerContext != null) {
                SavePointManager savePointManager =
                    controllerContext.getSavePointManager();
                if (savePointManager != null) {
                    savePointManager.removeSavePoint(savePointId);
                    ADFContext.getCurrent().getSessionScope().remove("savePointId");
                }
            }
        }
    }


Here i am removing save point snapshot from table using savePointManager.removeSavePoint(savePointId) ethod which except savePointId. and also i am removing session id from the scope which mean user can not restore again.You change logic base on your business requirement.

Data base structure is following which will store snapshot value's.
Table Name is :ORADFCSAVPT
 





You can download sample at following link:

https://docs.google.com/file/d/0B8cP4jZuxLlXaHV0dmVLQWhzckE/edit?usp=sharing

Thanks
Prateek

Saturday, March 2, 2013

Guide for installing Glass Fish server ,integration with jdeveloper and security implementations

Hi,

After making oracle ADF essential open source with limited  features by oracle now it time is integrate ADF essential with glass fish server to understand how it's work.

Although there are a lot of blog post on same topic by oracle and team.But here i am going to collect all into one document,put some more information ,add some more feature and posting here.

In Oracle ADF essential following feature are not available

1-MDS support
2-Secutity
and also more...

Let me explain above point in details in Glass fish with adf application context.

Security for glass fish and ADF application:Security is very vital and important part of any web based application.Therefore before using oracle essential for any development you should need to think about your security approach.Although in glass fish server security is supported which is based on JAAS specification.
Oracle Security is also based on JAAS specification and ADF security is highly tightly coupled with weblogic server so if no weblogic server then no oracle adf security.
So if you are using Glass fish server for deploying your ADF application then you should need to learn in/out of JAAS security approach.

MDS :Regarding MDS we need to disable it JVM level in glass fish server.
I have created one document where i have explained all the things related to installing ,security and integration and also i captured all above points in document.

Apart from this we need to use correct version of jdeveloper which support glassfish deployment 
Above explanations is just high level information you should  read following document for more.

link is following

https://docs.google.com/file/d/0B8cP4jZuxLlXdXBTQTNCZ015R2c/edit?usp=sharing

Thanks,
Prateek

Sunday, February 17, 2013

Transfering File Using FTP Adapter

Hi ,

FTP adapter is use for transfer the file from one local/remote system to another local/remote system with use of the any FTP server.Obviously FTP adapter is based on the FTP protocol and also it is based on the Java EE Connector Architecture (JCA) 1.5 architecture .

Use Case :I have require where i need to transfer file from local/remote to remote/local location.File adapter will poll the file after each 10 second(Although you can change polling time base on your requirement). Here we do not need to read the contains of file.

Approach:The step are following

Step1:-We require to have FTP server on machine where server is running.Therefore i have installed FileZilla FTP server on my server machine.

You can download FileZilla FTP server at following server
link :http://filezilla-project.org/

Step2:-Need to create two user in FTP server which later we need to configure in FTP adapter JNDI.
Configure shared folder for both user.This all need to done in FTP server only not weblogic server.

Step3:Need to create two JNDI for local and remote location.This should be done in the under FTP adapter service which is present in the weblogic server.

Step4:Need to map FTP server user with weblogic user.This will done in weblogic server.Here Security mapping is require between FTP server username and weblogic  server user .

Step5:Use two  FTP  adapter in soa application for building a service which will automatically poll the file after each 10 seconds.

Implementations:

Step1:-We require to have FTP server on machine where server is running.Therefore i have installed FileZilla FTP server on my server machine.

  




Step2:-Need to create two user in FTP server which later we need to configure in FTP adapter JNDI.
Configure shared folder for both user.This all need to done in FTP server only not weblogic server.

a) For creating new use in FTP server.Go to edit-->user.following screen will open

b)click on the add button and give the user name.Here i am giving ftpweblogic as a username. and check the password check box and give the password here i am giving weblogic1


c)click on shared folders and add shared location and make it Set as home dir. and also check all the check box under file and directories section.

The above step need to do for next user as well.I have created user with user ftpweblogiclocal, password as weblogic1 and same folder as shared folder.


Step3:Need to create two JNDI for local and remote location.This should be done in the under FTP adapter service which is present in the weblogic server.

a)go to the weblogic admin server -->deployments -->Ftpadapter

b)click on FtpAdapter-->configuration -->Outbound  Connections Pools 



c)click the New button  and select the javax.resource.cci.ConnectionFactory and then next.Give the JNDI name here i am give eis/Ftp/FtpAdapterLocal and click finished .

Do the same step for creating second JNDI. BTW there is already one JNDI present which we can use for second user.
JNDI name is eis/Ftp/FtpAdapter


Step4:Need to map FTP server user with weblogic user.This will done in weblogic server.Here credential  mapping is require between FTP server username and weblogic  server user .

a)click on again FtpAdapter-->Security-->credential mapping  
b)click on new and select the JNDI which you want to map .Here we need to map both JNDI which we have created step 3.I have selected eis/Ftp/FtpAdapter and then next

c)Select the Configured User Name option and give your weblogic user name in inputext and click next 

d)In the next page give the FTP username and password.
fpweblogic/weblogic1


 The mapping has been created successfully.


Step5:Use two  FTP  adapter in soa application for building a service which will automatically poll the file after each 10 seconds.

a)It is time to open jdeveloper.Create a SOA applicatio with BPEL and select the Define Service Later as Template

  

b)drag and drop FtpAdapter in the Expose Service.Click next  and then in the next page give the FTP adapter name here i am giving InFile .


c)click next and next give the JNDI name eis/ftp/FtpAdapter and next
d)in operation page select operation type as Get File and check the Read File as attachment




e)In file Directories page give the Directory for Incoming file(Physical File ) value as \in

*we already configure the shared location in FTP server.It will search \in inside shared folder.
click next

f)And in the next File Filtering  page and give the *.xml value in the Include Files With Name Pattern .Here i am transferring XML file  so that is reason why i have give *.xml .



g)In next page .Set file polling  time and next and then finish it.
h)Again drag and drop one more file adapter in external references section.
i)Give the FTPAdatper name PutFile and then next,again next and then give the second JNDI name here then next.
j)In Operation page select the Operation Name as put and then next

k)In Page File configuration give the file  Naming Converation  value and Directory For Outgoing files


l)No need to provide schema since here i want to transfer file one location without reading contains of file so in this page need to check the check box because schema type is Opaque .

File Adapter are ready to use .

In next step  map the value of one file adapter into second file adapter through BEPL and deploy it soa server.

Put the any sample file into in folder where file extension should be .xml.So when polling will happens it will move the file from in to out folder and it will delete the moved file from in Folder.


You can download sample application at following location

link:https://docs.google.com/file/d/0B8cP4jZuxLlXaV9MN2JUX1BBVUE/edit?usp=sharing

Thanks
Prateek



Monday, January 28, 2013

Bar Grpah-3 (Series Set and Alert Set)

Hi

Agenda:In this post  i would like to explain how we can programmatically create series set and alert set in bar and horizontal bar graph.

Explanation about Series Set and Series tag :

Tag is :<dvt:series> and <dvt:seriesSet>

<dvt:series> is for giving or changing information for single bar at a time
<dvt:seriesSet> is for giving or changing information all bar which are present in the bar graph.
It has a lot of attribute which will apply in all bar graph.

Series set is use for changing color ,space and other property of the bar in bar graph.<dvt:series> tag is good only if you know how may bar are generated at run time.And also if you have 10-20 series then in this case also you have to put same number of tag into UI source code which is tedious.

 <dvt:seriesSet> has one attribute SeriesMap where we can pass the value series and it will generate different type of series at run time.

Code are following for creating series map. It map contains key as Integer and value as a object of the Series.Here i am just changing color of one series but you can also change other property.

Here i am changing color of the first series to green therefore i passed 0 as key in map.

    private Map<Integer,Series>  seriesMap;
    public void setSeriesMap(Map<Integer, Series> seriesMap) {
        this.seriesMap = seriesMap;
    }

    public Map<Integer, Series> getSeriesMap() {
        if(seriesMap==null){
            seriesMap=new HashMap<Integer,Series>();
            Series s1=new Series();
            s1.setColor(Color.GREEN);
            seriesMap.put(0, s1);
        }
        return seriesMap;
    }




Explanation about Alerts Set and Alert tag :

Tag :<dvt:alert> and <dvt:alertSet>

This tag are use to show waring and error in bar chart.<dvt:alert> is for showing single bar warning  and error where else <dvt:alertSet> contians information of bars at a same time.

So here i am putting warning image in first bar which has Example_Bar_1 as column value.

    public void setAlertSet(Map<Integer, Alert> alertMap) {
        this.alertMap = alertMap;
    }

    public Map<Integer, Alert> getAlertSet() {
        String text = "Example_Bar_1";
        alertMap = new HashMap();
        Alert al1 = new Alert();
        al1.setXValue(text);
        al1.setYValue(80.00);
        al1.setImageSource("/images/warningIcon.png");
        alertMap.put(0, al1);
        return alertMap;
    }






i have put image under images folder.

Download sample application at following location

link :https://docs.google.com/file/d/0B8cP4jZuxLlXZGpHLXZhLTdYVjg/edit?usp=sharing

Thanks
Prateek




Thursday, January 24, 2013

Bar Graph -2

Hi

In my last post i have given example for creating model of bar graph by passing value in tabular data.In this post i will create the model of graph by using LocalXMLDataSource and GraphDataModel.Then pass the value in the value property of bar graph.

Explanation is following

1-First defined variable  in backing bean

private GraphDataModel graphDataModel;

2-Created setter and getter of above variable

    public void setGraphDataModel(GraphDataModel graphDataModel) {
        this.graphDataModel = graphDataModel;
    }

    public GraphDataModel getGraphDataModel() {
               return graphDataModel;
    }

3-Whole code of backing bean is following.In getter method i have created object of LocalXMLDataSource then set into GraphDataMode object .

package com.example.oracle.backingbean;

import oracle.adf.view.faces.bi.model.GraphDataModel;

import oracle.dss.dataView.LocalXMLDataSource;

public class BarGraphBackingBean {
    public BarGraphBackingBean() {
        super();
    }

    private GraphDataModel graphDataModel;

    public void setGraphDataModel(GraphDataModel graphDataModel) {
        this.graphDataModel = graphDataModel;
    }

    public GraphDataModel getGraphDataModel() {
        if (graphDataModel == null) {
            graphDataModel = new GraphDataModel();
            LocalXMLDataSource ds = new LocalXMLDataSource(columnsValue(), seriesValue(), dataPoint());
            graphDataModel.setDataSource(ds);
        }
        return graphDataModel;
    }

    public String[] seriesValue() {
        String[] seriesLabels = { "Series_1", "Series_2", "Series_3"};
        return seriesLabels;
    }

    public String[] columnsValue() {
        String[] columnLabels = { "Column_1","Column_2" };
        return columnLabels;
    }

    public Object[][] dataPoint() {
        Object[][] dataPoint = new Object[2][3];
        dataPoint[0][0] = new Double(10);
        dataPoint[0][1] = new Double(20);
        dataPoint[0][2] = new Double(30);
        dataPoint[1][0] = new Double(40);
        dataPoint[1][1] = new Double(50);
        dataPoint[1][2] = new Double(60);
        return dataPoint;
    }
}

*Two column
*Three Series
*And each column has three data point value.

Step 4:Page code is following

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<f:view xmlns:f="http://java.sun.com/jsf/core" xmlns:af="http://xmlns.oracle.com/adf/faces/rich"
        xmlns:dvt="http://xmlns.oracle.com/dss/adf/faces">
    <af:document title="barGraphPage.jsf" id="d1">
        <af:form id="f1">
            <dvt:barGraph id="graph1" subType="BAR_VERT_CLUST" value="#{barGraphBackingBean.graphDataModel}">
                <dvt:background>
                    <dvt:specialEffects/>
                </dvt:background>
                <dvt:graphPlotArea/>
                <dvt:seriesSet>
                    <dvt:series/>
                </dvt:seriesSet>
                <dvt:o1Axis/>
                <dvt:y1Axis/>
                <dvt:legendArea automaticPlacement="AP_NEVER"/>
            </dvt:barGraph>
        </af:form>
    </af:document>
</f:view>


Here i have created two column and each column has contains 3 series.
Running page screen is following



Code is present at following location

https://docs.google.com/file/d/0B8cP4jZuxLlXRXljdHNXRDlJVTg/edit?usp=sharing

Thanks,
Prateek

Tuesday, January 22, 2013

Programmatically creation of Bar Graph In ADF

Hi ,

In this post i would to explain the some basic approach for creating and changing the property of the bar graph.

"A bar chart or bar graph is a chart with rectangular bars with lengths proportional to the values that they represent. The bars can be plotted vertically or horizontally. A vertical bar chart is sometimes called a column bar chart." from wikipedia .

There are different type of approach for creating the bar graph in oracle adf application.First one you can drag and drop VO from data controls as bar graph.While dragging and dropping the VO will ask some property i.e. Series value which you need to give and it will create the graph and add property into the page def file.

Although there are also other ways where you can pass value in following attribute of the bar graph to create bar graph manually.

1-value(manual and as well as drag /drop)
2-tabular data (for manual approach)


I am going to explain how we can create the model value for bar graph which we can pass in the tabular data attribute of bar graph .

Model for Tabular Data :

1-Define attribute /variable with following signature type
 It should be list and it will contains Object array.
 private List<Object[]> listObject;

2-create the setter and getter of the same attribute

public List<Object[]> getListObject() {
             return listObject;
    }
   public void setListObject(List<Object[]> listObject) {
        this.listObject = listObject;
    }
}

3-In the getter method we need to put series value which will render bar in the bar graph or graph chart.

    public List<Object[]> getListObject() {
        if (listObject == null) {
            listObject = new ArrayList<Object[]>();
            Object[] obj1 = { "Example_Bar_1", "Series_1", 73.0 };
            Object[] obj2 = { "Example_Bar_2", "Series_1", 100.0 };
            Object[] obj3 = { "Example_Bar_3", "Series_1", 30.0 };
            Object[] obj4 = { "Example_Bar_4", "Series_1", 40.0 };
            listObject.add(obj1);
            listObject.add(obj2);
            listObject.add(obj3);
            listObject.add(obj4);
        }
        return listObject;
    }

Here i have created four bar and all are belong to same series.

"Example_Bar_1", "Series_1", 73.0 :-
 i)it is x axis value
ii)it is series name (here only one series is present and that is Series_1)
iii)it is data point value or y axis value which always be double.

Because they all belong to same series therefore they have same color for their bar.Although you can give different value in this case bar graph color will changed.

With same series value


With different value



4-Binding this variable to the UI Bar Graph component of the UI

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<f:view xmlns:f="http://java.sun.com/jsf/core" xmlns:af="http://xmlns.oracle.com/adf/faces/rich"
        xmlns:dvt="http://xmlns.oracle.com/dss/adf/faces">
    <af:document title="barPage.jsf" id="d1">
        <af:form id="f1">
            <dvt:barGraph id="graph1" subType="BAR_VERT_CLUST" tabularData="#{barBackingBean.listObject}" shortDesc="example">
                <dvt:background>
                    <dvt:specialEffects/>
                </dvt:background>
                <dvt:graphPlotArea/>
                <dvt:seriesSet>
                    <dvt:series/>
                </dvt:seriesSet>
                <dvt:o1Axis/>
                <dvt:y1Axis/>
                <dvt:legendArea automaticPlacement="AP_NEVER"/>
            </dvt:barGraph>
        </af:form>
    </af:document>
</f:view>

In next post i will create the bar graph using GraphDataModel object.


Link :http://docs.oracle.com/cd/E12839_01/apirefs.1111/e12418/tagdoc/dvt_barGraph.html

Download sample Application :

https://docs.google.com/file/d/0B8cP4jZuxLlXVzZpRHdVU2hvSnc/edit?usp=sharing