2010年12月12日星期日

Linux Tips

A.
When try to su to another user, the command always prompt incorrent password. The sudo works.

using the following commands:
 ls -l /bin/su

rpm -qf /bin/su
coreutils

rpm -qV coreutils
....
S file Size differs
M Mode differs (includes permissions and file type)
       5 MD5 sum differs
       D Device major/minor number mis-match
       L readLink(2) path mis-match
       U User ownership differs
       G Group ownership differs
       T mTime differs 

if the rpm -qV coreutils output something, means the coreutils has been updated.

have to install it.

don't know why it is updated/modified.

B.
close the putty session in the Windows client, and it's really sad that the server processing that is supposed to long running is killed too.
How to keep it running at the back end while I close the putty client session in the Windows desktop and leave the office.

Just run the back end server process using the following command:
nohup ****.sh &

Everything will be OK.


Install Oracle database in Linux (Oracle EL and CentOS 5, Red Hat 5)

This blog will record the steps to install Oracle database 11g in Linux. The Linux distribution I am using is Oracle EL 5.x and CentOS 5.x.

Once I tried to install Oracle 10g XE in Fedora 13, it's pretty simple and similar to the 11g enterprise/standard editions in the Oracle EL and CentOS, both are supposed to be incompatible with Redhat distribution.

So I think if you just want to install Oracle database on Linux, please try the enterprise distribution which are supposed to compatible with Redhat, Suse. And from the installation guide, it's really surprises me when I got the information that AsiaLinux was also supported by Oracle database.

I have to say that the installation guide in oracle.com is quite useful and by following this guide I can complete the installation process.

The hardware requirement is not a problem for me since I install the database in a server which has a memory of 8G, which also mean that I have to install the 64bit Linux.

The operation system neither is not a problem for me, oracle 11g support Linux 5 (Oracle EL 5, redhat 5 ...). In all the installations I have done, I got the conclusion that if you decide to use oracle's software and Linux as an operation system, maybe Oracle EL is your best choice, even better than RedHat or SUSE.  I believe that Oracle has done lots of test on their own Linux distribution. Although Oracle EL is just a little variant from RedHat right now, I believe that one day Oracle EL will develop independently with Redhat.

The lib requirements are the real requirement that I need to handle. They are still very simple, just with a simple command 'yum info' and 'yum install' I got all the required libraries installed. There is one thing needs to be mentioned, some libraries should be installed with both 32bit and 64bit version. 

Different Linux distributions differs in their pre-installed libraries. CentOS is with the minimum number of required libraries, especially when compared with Oracle Linux and Fedora.  The library's version is still very important. Since Oracle 11g is supposed to installed in an server, which definitely is equipped with older version libraries.  If you try to install Oracle 11g in Fedora 13, which has lots of latest libraries and some older libraries maybe have been deprecated, you may encounter this kind of problem.

Once I tried to install Oracle Forms builder in a Linux with Fedora 13 installed, after install various old version libraries, the Forms builder was still not be able to start up.  There is really  a contradiction in this scenario, which by the way is off topic. The contradiction is  that you have to install the latest distribution of Linux in desktop because of latest hardware support, otherwise your wireless card or anything else may not work properly; on the other hand, if you want to develop on this laptop, some enterprise software development tools may only support old version libraries. Sometimes, even a developer has to use Windows to replace Linux. That kind of scenarios suck.

Create the user and the groups needed. Someone may install everything as a root, which in my opinion is not a good practice. Others may intend to install the software in the /home directory. Maybe some very important/system level software should/can be installed in the /home directory, but I think install software in the /opt directory is very good.

Configure the kernel parameters for the Linux. 
This process is very important and maybe one of the most distinguished different between install software in Linux and Windows. In Windows, when you install a software, the OS is unchangeable, you just have to click 'Next' and 'Finish', but in Linux, there are lots of things to configure. This kernel parameters have lots of things to do with performance, without properly set of these parameters, the Oracle 11g can not be installed. During the run-time of the database, these parameters can be changed to tuning the performance of the database.

Configure Shell limits for the oracle user.  oracle is the installing user of the software, maybe it can be used as the user of all the oracle software.

Create required directory and environment variables like ORACLE_BASE, ORACLE_HOME.

# Oracle Settings
TMP=/tmp; export TMP
TMPDIR=$TMP; export TMPDIR

ORACLE_HOSTNAME=THE-HOST-NAME-OF-THE-SERVER; export ORACLE_HOSTNAME
ORACLE_UNQNAME=DB11G; export ORACLE_UNQNAME
ORACLE_BASE=/opt/app/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1; export ORACLE_HOME
ORACLE_SID=DB11G; export ORACLE_SID
ORACLE_TERM=xterm; export ORACLE_TERM
PATH=/usr/sbin:$PATH; export PATH
PATH=$ORACLE_HOME/bin:$PATH; export PATH

LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib; export LD_LIBRARY_PATH
CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib; export CLASSPATH

if [ $USER = "oracle" ]; then
if [ $SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
fi

Run the Installer. I run the Installer in the VNC Viewer. When I run the installer in the putty, the installer is not able to display even after I set the display property.

After the installation of the Database software and the setting of the environment variables, issue the following command:
  dbca
to create a database.

 

When install oracle 10g in the Redhat 5, the OS is not certified. After install all the required packages with the exact or higher version, changing the kernel parameters.

issue the following command to start the install process:

 

./runInstall –ignoreSysPrereqs

 

Often, the swap space size limitation is also annoying, for the redhat didn’t set the swap size properly when install the system. It’s very hard to extend the swap size, so you can just ignore the sys requirement check by using the –ignoreSysPrereqs parameter. 










2010年11月25日星期四

ADF bean scope and binding context scope

View Object’s criteria and bind variables

Technorati Tags: ,,

The tutorial is to demonstrate how to use View Object and it’s view criteria in a JSF backing bean.

Section 1. Apply a single view criteria with bind variable

Section 2. Apply multiple view criteria

Section 3. Add view Criteria at runtime

The source can be downloaded here:

2010年11月24日星期三

SelectOneChoice as a table’s filter input component

Technorati Tags: ,,,

When displaying data into tables and using the out-of-the-box filtering feature, an input box is used to input the filter data. But in some scenarios, you may want to use a SelectOneChoice for an attribute that has a list of value.  Sometimes, a LOV may be used if the list of value is of very large size, we will explore a LOV filter in the next section.

We will use the HR schema’s COUNTRIES and REGIONS tables for this demonstration.

The source code of this demonstration can be downloaded here: TableFilterDemo

Step 1. Create an Application with a Model project and a ViewController project.

Step 2. Create ADF BC components from tables: COUNTRIES, REGIONS. EO, VO and association, view link and AM are automatically created.  I would like to change all the attribute with a type of BigDecimal to the type of Number.

Now, the Model project is like below:

filter-model-project

Step 3. Let’s modify the CountryView to include the region name.

  3.1. Add the RegionEO into the CountryView object;

  3.2. Add RegionId and RegionName attributes of RegionEO into the CountryView’s attributes.

Step 4. Create a read only LOV for RegionID in the Regions table, named it RegionsList. The SQL is : SELECT region_id, region_name FROM regions

Step 5. Assign the RegionsList LOV to the CountryView as a View Accessor.

Step 6. Add a List of Value for the RegionId attribute in the CountryView VO.

Add LOV

Add_LOV2

In the UI hints tab:

Select the ‘Choice List’ and uncheck the ‘No Selection’ Item.

Save all the changes.

Step 7.  Now we can test the BC in the BC browser, from the BC browser, we can see that the region Id now is displayed as a Choice List.

LOV-test

Now we are going to create the web page.

The data control now is as below:

filter-datacontrol

Step 8. Create a page, name it Countries.jspx. Drag and drop the CountryView1 into the page, Create it as a read only table and select the ‘Filtering’  and ‘Row Selection’ checkbox. For the regionId column, set the rendered as ‘false’ (not necessary).

Please pay attention to the fact that the VarStatus attribute of the table is set to ‘vs’ automatically, which we will use.

Step 9. For the Region Name column, in the Column facets, select the filter facet and insert a SelectOneChoice into the filter facet, set the label of the SelectOneChoice to ‘’.

Note: since the SelectOneChoice component will return the index of the selected value, not the direct value, we have to configure the SelectOneChoice as below.

<af:selectOneChoice id="soc1"
                                 value="#{vs.filterCriteria.RegionId}">
               <af:forEach var="listrow">
                 <f:selectItem id="si1"/>
               </af:forEach>
             </af:selectOneChoice>

it’s important to change the value expression of the SelectOneChoice to :#{vs.filterCriteria.RegionId}. You would better use the expression builder to construct the expression. The vs object is under the ‘JSP Object’ folder.

select-value-setting

Then we have to assign list to the SelectOneChoice component and assign the itemValue and itemLabel to the the selectedItem.

Step 10. Adding  a bindings for the tree(or list).

  10.1. go the bindings of the page: add. The item to be created is a tree.

  tree-binding

   10.2 create the tree binding:

create tree binding

    10.3. Save and then go back to the source to configure the SelectOneChoice.

      the items attribute is configured to : items="#{bindings.RegionsList1.rangeSet}" , using the expression builder will help you correctly assign the expression.

      the SelecteItem’s itemValue=”#{listrow.RegionId}”itemLabel=”#{listrow.RegionName}”

     the final SelectOneChoice’s code is:

<af:selectOneChoice id="soc1"
                                  value="#{vs.filterCriteria.RegionId}"
                                  valuePassThru="true">
                <af:forEach var="listrow"
                            items="#{bindings.RegionsList1.rangeSet}">
                  <f:selectItem id="si1" itemLabel="#{listrow.RegionName}"
                                itemValue="#{listrow.RegionId}"/>
                </af:forEach>

</af:selectOneChoice>

Step 13. Let’s run the page.

Step 14. The SelectOneChoice works in some degree, but the ‘Enter’ has to be pressed to submit the filter request, even autoSubmit of the SelectOneChoice doesn’t work.

Step 15. Let’s add a client listener to solve this problem. Add a client listener to the SelectOneChoice with the following code:

<af:clientListener method="executeSelection"
                                  type="valueChange"/>

Step 16. add the executeSelection javascript code in the page.

<f:facet name="metaContainer">
      <af:resource type="javascript">
          function executeSelection(event){
            jsEl= document.getElementById(event.getSource().getClientId());
            if(document.createEvent){
              // FF
              var evt = document.createEvent("KeyboardEvent");
              evt.initKeyEvent(                                                                                     
                               "keydown",        //  in DOMString typeArg,                                                          
                                true,             //  in boolean canBubbleArg,                                                       
                                true,             //  in boolean cancelableArg,                                                      
                                null,             //  in nsIDOMAbstractView viewArg,  Specifies UIEvent.view. This value may be null.    
                                false,            //  in boolean ctrlKeyArg,                                                              
                                false,            //  in boolean altKeyArg,                                                       
                                false,            //  in boolean shiftKeyArg,                                                     
                                false,            //  in boolean metaKeyArg,                                                      
                                 13,               //  in unsigned long keyCodeArg,                                                     
                                 0);
              jsEl.dispatchEvent(evt);
            }else{
              // IE
              evt = document.createEventObject();
              evt.keyCode = 13;
              jsEl.fireEvent("onkeydown", evt);
            }
          }
      </af:resource>
      </f:facet>

Step 17. run the page again.

There is one problem when select the region from the list, although the table can be filtered, the list’s current value cannot be recovered. It’s of course a SelectOneChoince’s problem, have to fix it. 

2010年11月23日星期二

Update a delete flag instead of directly delete data from database

Technorati Tags: ,

In some scenario, it’s important and necessary to update a delete flag in the database table instead of directly delete the row data from the table.

First let’s see there is a QUESTIONS table with a DELETED column in the database. The DELETED column is a CHAR(1) with a default value of ‘N’.

Step 1. generate the Java code of the EO

Step 2. override the remove() method in the EO

@Override
public void remove() {
    this.setDeleted("Y");
    super.remove();
}

Step 3. override the doDML() method in the EO

@Override
protected void doDML(int operation, TransactionEvent transactionEvent) {
    if(operation == DML_DELETE){
      operation = DML_UPDATE;
    }
    super.doDML(operation, transactionEvent);
}

Step 4. change the query SQL of the VO, add the DELETE = ‘N’ condition.

Now, when delete an entity in the BC browser, the row data is still in the database, but with DELETED column’s value equals ‘Y’.

First, the remove() method is executed when try to remove a record. Then when commit the transaction, the doDML() method is executed for every row.

Create a LOV in ADF

 

Step 1. Define a read-only View Object

Step 2. Define a View Accessor in the source View Object

Step 3. configure the attribute in the source View Object’s List of Value and UI hints

 

The LOV is referenced in http://liuwuhua.blogspot.com/2010/11/selectonechoice-as-tables-filter-input.html and there is a step by step.

2010年11月22日星期一

Master-Detail Inserting in ADF BC

This tutorial illustrates how to manage composite association in a one-to-many mapping (with foreign key) and many-to-many mapping (with intersection table) in ADF BC, including how to configure the EO/Association and how to write custom code.

Assumption:  all the table’s primary keys are handled by native database sequence and trigger.

There are three tables in the database, PERSONS, PROJECTS, and PROJECT_PARTICIPATE, which is the intersection table. The database schema as below:

database-schema

Section A: One-to-Many scenario, take PERSONS and PROJECT_PARTICIPATION as an example

1. Generate EO, VO, Association, View Link for the table PERSONS and PROJECT_PARTICIPATION

2. Configure the ID attribute in the EOs, the Type as DBSequence, Updatable as ‘Never’, Refresh After as ‘Insert’, the default value as 0 (it’s really wired that the default value has to be configured, otherwise when you adding a new Person, the id attribute will not popup a minus value.

3. In the association’s behavior section, select ‘Composition Association’, also select ‘Optimize for database Cascade Delete’,’Implement Cascade Delete’,  ‘Cascade Update Key Attribute’

The ‘Cascade Update Key Attribute’ is very important, since otherwise the children’s foreign key value would not be updated.

4. Save the configure and run the application module in the BC browser to test the configure.

Section B: Many-to-Many scenario

take PERSONS, PROJECT_PARTICIPATION, PROJECTS as an example

1.  do the same thing to PROJECTS and the association. but when you configure the Composition Association for the other association, there is a warning, just keep it.

2. Save the configure and run the application module in the BC browser to test the configure, it doesn’t work in the second association.

Actually, we are make a mistake in the Composition Association. In a Composition Association, the composition owner and the composing EO have a highly tight relationship.  The composing EO should have only one owner, otherwise, an invalidOwner exception were threw. In our scenario, the ProjectParticipation EO should not have an owner.

We have to handle the second association’s adding and save manually. 

First Let’s do the Master-Detail adding in a non-composition association, that means, we have to handle the parent-children relationship manually.

There are two things we should make sure:

1. The parent object should be posted before the children objects. Since the ADF framework will post the pending changes in an chronological order, we have to overwrite the child entity’s postChange method.

2. After the post of the parent entity, we have to assign the parent entity’s id to the children’s foreign key. That means both the postChange and the refreshFKInNewContainees methods should be overwritten.

Here is the steps:

1. uncheck all the Composition Association in the two association’s behavior sections.

2. Configure the IDs of the EOs as before.

3. Generate the java source file for the three EOs. EOs are : ProjectImpl.java, PersonImpl.java, ProjectParticipateImpl.java

4.  override the postChange(TransactionEvent e) in the ProjectParticipateImpl.java

@Override
public void postChanges(TransactionEvent e) {
    if (this.getPostState() == STATUS_NEW ||
        this.getPostState() == STATUS_MODIFIED) {
        PersonImpl person = (PersonImpl)this.getPerson();
        if (person != null) {
            person.postChanges(e);
        }
        ProjectImpl project = (ProjectImpl)this.getProject();
        if (project != null) {
            project.postChanges(e);
        }
    }
    super.postChanges(e);
}

5. override the postChange() and refreshFKInNewContainees() in the ProjectImpl.java

private RowIterator newProjectParticipations; //as a cache for the two methods

@Override
public void postChanges(TransactionEvent transactionEvent) {
    if (this.getPostState() == STATUS_NEW) {
        this.newProjectParticipations = this.getProjectParticipate();
    }
    super.postChanges(transactionEvent);
}

@Override
protected void refreshFKInNewContainees() {
    if (this.newProjectParticipations != null) {
        Number projectId = this.getId().getSequenceNumber();
        while (this.newProjectParticipations.hasNext()) {
            ProjectParticipateImpl participate =
                (ProjectParticipateImpl)newProjectParticipations.next();
            participate.setProjectId(projectId);
        }
    }
    this.newProjectParticipations = null;
    //super.refreshFKInNewContainees();
}

6. override the postChange() and refreshFKInNewContainees() in the PersonImpl.java

private RowIterator newProjectParticipations;

@Override
public void postChanges(TransactionEvent e) {
    if (this.getPostState() == STATUS_NEW) {
        this.newProjectParticipations = this.getProjectParticipate();
    }
    super.postChanges(e);
}

@Override
protected void refreshFKInNewContainees() {
    if (this.newProjectParticipations != null) {
        Number personId = this.getId().getSequenceNumber();
        while (this.newProjectParticipations.hasNext()) {
            ProjectParticipateImpl participation =
                (ProjectParticipateImpl)this.newProjectParticipations.next();
            participation.setPersonId(personId);
        }
    }
    this.newProjectParticipations = null;
    //super.refreshFKInNewContainees();
}

 

 

7. Save all and test the Adding and saving operation in the BC Browser.

8. The source code and the sql script can be downloaded here. With the generated8 package as the many-to-many composition association and package generated7 as the one-to-many association.  Composition Association Demo

2010年11月19日星期五

Flex-field in Oracle EBS

Ledger in General Ledger

Chart of Accounts in General Ledger

Classification of Accounting Transactions

The core financial system provides the capability to classify accounting transactions by:

1. Fiscal Year;

2. Accounting quarter and month (period)

3. program (Project)

4. organization

5. activity

6. cost center

7. object class

8. budget function

9. other future defined attributes

The classification in EBS financial is by Chart of accounts.  In EBS financial, chart of accounts are implemented by Key flex fields. By the way, chart of accounts is one of the four elements of a ledger.

2010年11月18日星期四

Review of Beyond Code

Read the review of the book—Beyond Code, write some comments and plans based on this book’s review.

Beyond Code is a book about getting ahead for IT professionals. Its main purpose is to help IT professionals distinguish themselves from the growing crowd of IT consultants and project managers.

The author shows how to listen to others, how to build bridge, how to create bold strategies and how to build personal brand by his own personal experience.

There are two things that an IT professional should try to work out:

A. THE INNER GAME

Character and competence are important, but de-commoditization or standing apart from the field because of value-added skills is the answer.

Taking some risk and trying new things will open up new possibilities. If you do what you have always done, you know what you are getting, but you may never know what you missed until you truly try new things.

Another action necessary to stand apart from the crowd is to know your destination, to have written plans, and goals.  Most do not do so because they have other pressing needs, they want to be 100 percent sure about what their goals are, they fear being wrong, or they want to keeping their options open. Just because goals are written down, does not mean that they have to stay the same forever. As professionals grow and change, their goals should grow and change with them.

The professionals should command a premium and that the way to do this is by creating a powerful personal brand.

No two people are alike and their responses and reactions to business situations will be different, so don’t try to follow someone else’s footsteps to success.

Even while working on one project and meeting its deadlines, someone who stands out professionally is still reading and learning new skills that will help him or her on future projects. That is continuous learning.

Common valuable skills include: art of building long-term relationships; identifying personal strengths and highlighting them; learning to communicate well; learning to congruent in both words and actions; setting the right expectations for a project.

Scorecard: goes beyond having goals and plans. It involves tracking the execution of a plan in order to check progress. A seven step plan to do this: a) knowing what step of the plan you are on; b) knowing what the end goal is; c) being able to identify the gap between a) and b); d) defining an action plan to fill the gap; e) identifying key performance indicators; f) keeping a scorecard to measure both progress and feedback; g) modifying the plan based on the feedback.

Looking at the big picture: Asking questions is the only way to determine what the entire puzzle looks like. What is the business need? what are the success criteria of the project? What is the expected outcome?

Reading the right material is another way to de-commoditize. Reading one book a week.

Adaptation is another one of the keys to distinguishing oneself. leave on project on a Friday and walk into a new one on Monday. Seeking information, developing a powerful network and being prepared for rapid changes in context are skills necessary for adaption.

Laughter :

Team members may focus primarily on themselves and their contributions, a leader will look beyond what is expected of him or herself and determine how to deliver more than is expected.

Keeping a relationship journal: merely a record of everything known about key business contacts.

Looking for simplicity and reducing clutter are two other necessary skills.  This is a precious commodity for everyone. Someone who can save someone else time and reduce the clutter in their life will automatically distinguish themselves.

It’s essential for consultants to care about every project as if it belonged solely to them.

Make sure that the problem being solved is the problem that needs to be solved.

Success = Love what you do + Do what is required.

Five reasons for loving your job and date and sign the exercise. Looking for evidence for loving your job, rather than looking for what is wrong with a job.

B. THE OUTER GAME

Leverage and discipline are two words that can change any life.  Think about the past year’s experience, specially: a) the number of clients interacted with; b) the number of projects worked on; c) the number of books read; d) the number of new acquaintances made; e) the number of active friends ; f) the number of seminars attended; g) the number of educational programs watched and h) the number of interactions with mentors

Hulk Complex: anyone who feels they have to solve problems by themselves, who believe they cannot ask for help and are not comfortable asking for help, and who are only satisfied when solving problems by themselves, suffers from this complex. It’s more valuable to ask others for advice, because there is always something to be learned from someone else. This way a network of resources is created and the problem is solved. 

Rules to leveraging business relationships. The first is to give first. Help someone out before asking them for help. Points of leverage: people, books, blogs, magazines, events, hobbies, websites, videos and social networking.

Listening is important. Those who cannot check their ego at the door, who don’t know how to ask questions, who cannot handle silence, or who feel incomplete are usually not good at listening.

To improve listening skills, it’s necessary to listen to what people are saying and to offer insights about their conversations. It’s important to ask the right questions. Close-end questions are not the right questions. When working in a project situation, think about asking questions like:

1. What are some of the problems that you are trying to solve by implementing this solution?

2. Would you mind explaining how this project fits into the overall company?

3. What’s the roadmap for the next few years for this project?

4. questions those involve getting feedback about the project and personal performance. Ask, what am I doing well that i should continue doing? Or ask, what am I doing that i should start doing?

When listening, it’s crucial to listen without prejudice. Do not assign a label to the person giving you information. Assume he or she is a credible source. Resist the temptation to reach instant conclusions and keep an open mind.

Listening distinguishes one professional from another and is one characteristic of a leader. Leaders also distinguish themselves by their actions. Leaders are not leaders because of their position. Even if a leader is not in charge, they can still lead. It’s how the order is carried out that distinguishes a leader.

Filling in the blanks is another characteristic of a leader. Every organizations has gaps—duties or responsibilities that are not assigned to someone. Finding them and filling them is another thing that will distinguish one professional from another, as is being ready when the opportunity for leadership presents itself.

2010年11月17日星期三

Create Master-Detail page based on ADF technology

This tutorial shows how to use the ADF page fragment (region), partial page refresh to construct a master-detail based table-form page.  In comparison with the traditional JSF technology used in the previous session, we use contextual event framework (involves binding) to transfer messages between bounded task flows (regions) in the same page.

 

The source of this session is packaged together with the previous session, which can be downloaded at : Knowledge Share Demo 

The previous session can be viewed from here.

Projects and products involved

 

CCA & CRMOD : Contact Center Anywhere and CRM On Demand integration. One month from May 2010 to June 2010. Java, Web Service, Swing, SaaS.

EBS Financial Localization:  China National Audit Office Standard Version 2 for Public Sector. Almost four months from July 2010 to October 2010. EBS Financial R12 (GL, FA), PL/SQL, Forms.

TestOnline Demo Project: a project used to practice in ADF. One month from October 2010 to November 2010. (Two weeks of training and two weeks of practice). ADF, Java, JDeveloper, Oracle Database.

Next Generation Platform in Core banking: NPG. From November 2010 to …

2010年11月15日星期一

Composition Association in ADF BC

This post first illustrate how to model the one-to-many relationship in the ER model by ADF BC. After that, the many-to-many (the mapping was stored in a third table) relationship in the ER model’s implementation was demonstrated.

Association between entities has two different types of relation. The first one is references, which means the source entity refers the destination entity; without the source entity, the destination entity still exists.  The second one is the contains, which means the source entity contains the destination entity as a logical, nested part; without the source entity, the destination entity still exists.  The contains relation is a composite association.

JDeveloper will generate the composite association for an Association if the foreign key is set as ON DELETE CASCADE.  An entity object offers additional runtime behavior in the presence of composition. http://download.oracle.com/docs/cd/E15051_01/web.1111/b31974/bcentities.htm#sm0150

If there are more than one composition association for the same entity object, the other composition associations should be disabled, otherwise the program should provide additional composition management to the entity object.  The problem arises because when a composed entity is created, it performs an existence check on the value of the foreign key to ensure that it identifies an existing entity as its owning parent entity. If no foreign key is found, there will throw an InvalidOwnerException. 

I think only with composition association can a master-detail binding be implemented.  Actually dis-select the composition association in both associations will make both the master-details run properly. 

In a master-detail mapping, if the composition association is not enabled, the master record and its detail records cannot be inserted at the same transaction, since when insert the detail records, the details records have no foreign key reference (the current value of the id of the master record is not assigned by the DBSequence).

This means the composite association should only be used in the one-to-many mapping scenario. A single entity object can not be in two different composite associations.

In a many-to-many mapping with the mapping stored in the intersection table, the many-to-many can be decomposed into two one-to-many mappings, although NEITHER the two mappings should be set as the composite association.None should be set as the composite association.

Please reference http://liuwuhua.blogspot.com/2010/11/master-detail-crud-in-adf-bc.html for an example.

New Vocabularies

Technorati Tags:

Veteran: 老手.

The veteran worker have two apprentices working with him.

The Veteran Day on November 11, 2010.  退伍军人日

Refrain: 克制

It’s difficult for us the refrain from laughing when we are seeing a comedy.

Poised: 镇定自若的

The BPMS market is poised to finally become a mainstream market.

Congruent: 适合的,一致的,和谐的

Learning to be congruent in both works and actions.

One-off: 一次性的;一次性事务

There is a chopsticks called chopsticks convenience. The chopsticks are simple, rough, use-disposable and one-off. 

Bespoke: 定制的. custom.

Bespoke requests from individual buyers can also increase the manufacture’s cost.

2010年11月14日星期日

View Object’s query criteria

section 1. using basic columns and operators

It’s easy to configure a query criteria and a bind variable in the View object to query like :

select * from candidate_answers where question_id = :VariableQuestionId

The bind variable can be settled with a default value, without a settled default value, the default value defaults to null.

section 2. using database functions to column like length(description) >5

It’s a little trick to configure a query criteria and a bind variable in the View Object to query like:

select * from candidate_answers where

length(description) >= :VariableDescriptionLength.

A. first configure an additional attribute in the VO, named DescriptionLength as a ‘Mapped to Column or SQL’.

B. everything then goes the same as the simple criteria in section 1.

C. check the View Object Where clause sub-window in the Create Criteria Window to make sure that the expected SQL is issued.

From this criteria, we can see that a View object is really a view query for the database, everything is from the entity object or the query. VO can be flexibly set to fulfill the requirement.

I don’t know if there is other way to fulfill the various expected SQL query in the VO by criteria.

section 3. Test the criteria in the business component browser.

use the Criteria icon in the BC Browser to set the bind variable.

Sequencing in TopLink Mapping and Sequencing in ADF BC

This post will explain using sequencing as primary key in TopLink Mapping and ADF BC’s mapping specifically.

Section A:

Sequencing in TopLink. There are two options to implement the sequencing in toplink.  The applied technology and attributes of the selected technology can be set at the mapping level by double-clicking the map in the structure.

sequence-config

  • using TABLE sequencing : the sequence value will be queried from a table, the table’s name can be the default ‘SEQUENCE’ when using the ‘Default Sequence Table’ option, or the user defined table when using the ‘Custom Sequence table ’ options. In this option, all the objects in the system share the same sequence table.
  • using oracle native sequencing. The sequence value will be queried from a sequence in the database. In this option, every object in the system can have its own coordinated sequence.  The Preallocation Size of the sequence should be the same as the ‘increase by’ parameter of the sequence in the database. Since there will be different sequences for objects and the increase-by parameter of the sequence is usually set to 1, it’s a good practice to set the Preallocation size to 1 instead of the default value-50.

I will illustrate the option 2 from here below.

Step 1. Create the Sequence in the database.

Step 2. Open the object’s mapping descriptor and select the Sequencing tab.

Step 3. Set the sequence’s name in the database. The table and its column that uses the sequence to generate its values.

sequence-config-2

Save the change, and now when insert a new object, the object will get the Id from the sequence.

Section B:

When using ADF BC, it’s very necessary to set the Id column (primary key)’s value of a table to be generated by a sequence in the database.

Step 1. Create the sequence;

Step 2. Create an trigger on the table to set the value of the ID attribute of the object by query next value from the sequence; [This is the very difference between sequencing in TopLink and Entity Object]

Step 3. In the Entity Object’s configuration file, set the attribute’s Type to DBSequence.

When choosing the type to DBSequence,  a ‘Sequence’ tag displays. Set the sequence name created in the Step 1 and set a Start number which should be greater than 0.  (It’s really wired that the ‘Sequence’ tab doesn’t show up sometimes)

Also, the Updatable property of the attribute should be set as ‘Never’. As below:

 sequencing-eo

Save all the changes.

When Inserting the record/object, an sequence value is set to the Id column.

NOTE:

The previously generated VO’s code will not change coordinated when the EO’s xml changes. So please change the ID to DBSequence before generating the VO code.

Using Task Flow as a Popup Dialog

Technorati Tags: ,,,

In this post, I will demonstrate how to use a task flow as a popup.

The scenario is as below picture:

task-flow-as-popup

First, the table will list all the records in the table.

With an Insert button, a cleared popup will display to ask the user input new record.  

With an Edit button, a filled-form popup will display to ask the user to edit the current record.

With a Delete button, the current record will be deleted from the table.

With a Save button (not included in the picture above), all the changes will be committed to the database.

With an Undo button (not included in the picture above), all the changes will be rollback.

We are using the Suppliers table in the Order Demo schema.

First, create an ADF application. Name it PopupDemo and using the Model and ViewController as the name of the model project and the view project specifically.

Step 1. in the Model project, create EO, VO and AM from the table Suppliers;

   1.1. Set the WHO columns for the EO: SupplierEO.

   1.2. Set the supplierId column the type as DBSequence, with updateable = ‘Never’ and Refresh after attribute = ‘Insert’

    1.3. Set the labels and tip text.

Step 2. layout and create the page. Index.jspx as the following picture:

 index-layout

Step 3. Create the edit page—edit.jspx, with the layout as the following picture:

  edit-layout

Step 4. Create the unbounded task flow for navigation and the bounded task flow for edit;

   4.1. The edit bounded task flow as below: task-flow-edit

edit-flow

The SupplierEditView’s page is the edit.jspx.

   4.2. The unbounded task flow as below:

unbounded-task-flow 

The CreateInsert is a method call with the following configuration:

method-call

Step 5. binds the buttons and construct the backing bean.

5.1. in the Edit.jsfx page, set the ‘Save’ button’s action to ‘return’ (the same as the navigation case in the bounded task flow).

5.2  in the unbounded task flow, select the called ‘bounded task flow’, and set the attribute of ‘run as dialog’ and ‘display type’ as below:

runasdialog-config

5.3. Create a backing bean for the Index.jspx page. Name it backingBean_Index. The class is BackingBean_IndexPage.

5.3 in the Index.jspx page.

5.3.1 set the ‘Insert’ button’s properties as below:

insert_1

action: insert ; useWindow: true; WindowEmbedStyle: inlineDocument; WindowModalityStyle: modeless; returnListener:

#{backingBean_Index.onEditReturnListener}

5.3.2 For the Edit button, only the action changes to ‘edit’.

5.3.3 For the Commit button, set the following properties:

commit-binding

the partialSubmit = true and the ActionListener = #{bindings.Commit.execute}

5.3.4 For the Undo button, change the ActionListener to ‘#{bindings.Rollback.execute}’

5.3.5 For the Delete button, change the ActionListener to ‘#{bindings.Delete.execute}’

5.3.6 binding the table to the table_Suppliers property in the backing bean. set the row select as single.  set the partial trigger to button_undo and button_commit

Step 6. Coding the backing beans’ listeners.

add the partial trigger code in the backing bean’s onEditReturnListener method

public void onEditReturnListener(ReturnEvent returnEvent) {
    AdfFacesContext context = AdfFacesContext.getCurrentInstance();
    context.addPartialTarget(this.table_Suppliers);
}

Step 6. run the page and test the application.

Source Code Download

.

Reference the bindings with JSF managed bean in ADF

This post will demonstrate how to use the bindings variable in the backing bean of  the JSF page.

Also, the specific contents of the bindings variable and the page definition file’s details are explored.

Step 1. Add the bindings variable in the backing bean, if there is no backing bean for the page, just create one.

import oracle.adf.model.binding.DCBindingContainer;

import oracle.binding.OperationBinding;

public class BackingBean {

private DCBindingContainer bindings;

public void setBindings(DCBindingContainer bindings) {
    this.bindings = bindings;
}

public DCBindingContainer getBindings() {
    return bindings;
}

}

Step 2. Register the backing bean and also register the bindings field as the backing bean’s managed property.

 

<managed-bean>
    <managed-bean-name></managed-bean-name>
    <managed-bean-class >….</managed-bean-class>
    <managed-bean-scope>…</managed-bean-scope>
    <managed-property >     

<property-name>bindings</property-name>
<property-class>oracle.adf.model.binding.DCBindingContainer</property-class>
      <value>#{bindings}</value>
    </managed-property>
  </managed-bean>

Please pay attention to the managed property’s value and type.

Step 3. Now you can use the bindings in the backing bean.  For example:

OperationBinding operation = this.bindings.getOperationBinding("Commit");

operation.execute();

Please pay attention to the fact that the operation maybe is null, which is because there is no ‘Commit’ operation binding in the page. The operation binding should be configured at the page definition file.  We will explore the page definition in another session.

DCBindingContainer provides access to all contained bindings.

The following codes are just results of reasoning, not a tested one.

BindingContext may provides all the bindings configure in the data controls.

Through the Data control, the data provider , which maybe an application module can be accessed.

So the steps to access the application module in the JSF’s backing bean is as below:

FacesContext context = FacesContext.getCurrentInstance();
ELContext elContext = context.getELContext();
ValueExpression expression =
    context.getApplication().getExpressionFactory().createValueExpression(elContext,
                                                                          "#{data}",
                                                                          BindingContext.class);
BindingContext bc = (BindingContext)expression.getValue(elContext);
DCDataControl dcControl = bc.findDataControl("QuestionAMDataControl");
ApplicationModule am = (ApplicationModule)dcControl.getDataProvider();

Or we can access the BindingContext through DCBindingContext.

BindingContext bindingContext = bindings.getBindingContext();

Also the DCDataControl can also be found by the DCBindingContainer:

DCDataControl dbControl = bindings.findDataControl("QuestionAMDataControl");

Create a Detail-Master based Form-Table page in traditional JSF technology

In this tutorial, a simple page will be created using JSF technology involving backing bean, ADF faces, partial trigger.

In the next tutorial, the same scenario will be implemented by complex ADF faces technology involving JSF fragment/region, bounded task flow, contextual event framework and partial trigger.

The scenario is illustrated as the below picture.

simple-scenario

At first, the table will list all the names in the system by two columns.  The user can add new names into the system by input first name and last name in the above form and click the Confirm button.  After the Confirm button, the new name is added into the system, then the table will refresh itself to display all the names including the new added one.

Here goes the tutorial:

Step 1. Create an application named KnowledgeShareApp to host the model and the view.  The model project’s name is Model and the view project’s name is ViewController-weblog. The Model project’s package prefix is:

oracle.share.model

Step 2. In order to simply the demonstration, we just imitate the database operations with a Database class. Download the source Database.java.

Also the logic is very simple, the database record can be represented by the java class: SimpleName.java.

Step 3. Layout out the page.

3.1 Drag and drop a Panel Stretch Layout Component from the component palette to the page.  Set the start and end facets’ width to 0, then set the top and bottom facets’ height to 0.

3.2 Drag and drop a Panel Group Layout Component from the palette to the center facet of the stretch layout. Set the group layout component’s layout attribute ‘scroll’.

3.3 Drag and drop a Panel Form Layout into the group layout component in step

    • 3.3.1. Then insert a Separator after the Form Layout. Finally, insert a table component after the Separator component.
    • 3.3.2. Drag and drop a Button component after the second Input Text component.

3.4 Drag and drop two Input Text components into the Form Layout component in the above step. 

3.5 The table is composed of two columns. The OutputText component’s value in first column’s value is set as the following EL:

<af:outputText value="#{row.firstName}" id="ot1"/>

The ‘row’ is specified in the table’s ‘var’ attribute.

The second column’s value is set as the following EL:

<af:outputText value="#{row.lastName}" id="ot2"/>

3.6 Save all the changes, the layout of the page is finished.

Step 4. Create the backing bean. Download the backing bean’s java source.

The backing bean’s skeleton code is as below:

public class BackingBean_SimpleDemo {
    private RichInputText inputText_FirstName;
    private RichInputText inputText_LastName;   
    private RichTable table_FullNames;
    private List<SimpleName> simpleNames = DataBase.findAllSimpleNames();
    public String addFullName() {
        DataBase.registerEntity(new SimpleName(this.inputText_FirstName.getValue().toString(),
                                               this.inputText_LastName.getValue().toString()));
        this.table_FullNames.setValue(DataBase.findAllSimpleNames());
        return "confirm";
    }   
}

The inputText_FirstName and inputText_LastName binds to the two input text in the page specifically. 

The table_FullNames binds to the table in the page. The simple Names list binds to the table’s value attribute.  This is a value binding, which would not cause the partial refreshment of the table on the page.

The addFullName binds to the action attribute of the Confirm button.  At the end of the method, the table_FullNames refreshes its value which will make the view handler partial refresh the table component on the JSF page. This is because the table now is a component binding, refreshment of the RichTable component in the backing bean would automatically partial refresh the table on the page.

Step 5. register the backing bean in the adfc-config.xml file.

Now you can test your project by run the page. 

In the next session, I will implement the same scenario in an ADF way by using page fragment and contextual event framework, which makes the page fragments be reused among the application.

All the source code of the this session and the next can be downloaded at this url below:

Knowledge Share Demo Code

EBS Financial Notes

Try to explain the Financial application’s main purpose, most valuable concepts as well as the origination of these concepts.

The content here is only based on three-months experience in EBS financials. Most of them are common concepts involved in all the modules. A little knowledge in General Ledger and Fixed Assets are covered.

The minimum requirements of a financial management system is to collect accurate, timely, complete, reliable and consistent financial information. Based on those financial information and with the help of the system, the organization should have the ability to :

1. provide for adequate management reporting

2. support organization level policy decisions; (multi-level organization with complex hierarchy)

3. support budgets;

4. facilitate the preparation and execution of agency budgets;

5.  provide complete audit trail.

For an integrated financial management system, the following characteristics are the minimum :

A. standard data classification (definition and formats) established and used for recording financial events;

B. common processes used for processing similar kinds of transactions;

C. Internal controls over data entry, transaction processing and reporting applied consistently

D. A design that eliminates unnecessary duplication of transaction entry.

The core financial system mainly consists of the following sub-systems:

AA. system management: contains the following processes: Accounting classification management (actually in GL) , transaction control.

A. General Ledger management. GL is the central function of the core financial system. The general ledger is the highest level of summarization and maintains account balances. All transactions to record financial events must post, either individually or in summary to the general ledger, regardless of the origin of the transaction.

Including processes: General Ledger Account Definition; Accruals, Closing and Consolidation; General Ledger Analysis and Reconsolidation. 

B. Payment management

C. Receivable Management

D. Fixed Assets Management

E. Budget Management

F. Cost Management

Hello World!

Hello World blog entry.