Sunday, April 24, 2011

Removing hard coded set-attribute in EOImpl

I was faced with the below issue and posted it on several forums :-

Some EO's in my application have hard-coded setAttribute in order to get around an ADF issue where we have these transient attributes for EO assocations, but they don't show up on newly created rows.


For example:

protected void create(AttributeList attributeList) {
super.create(attributeList);
this.setAttribute("TransientAttribute1","SOME_LITERAL_VALUE1");
this.setAttribute("TransientAttribute2","SOME_LITERAL_VALUE2");
this.setAttribute("TransientAttribute3","SOME_LITERAL_VALUE3");
}

Our requirement is to get away with this method and instead achieve the above using either groovy expression or derived from sql expression. Using this, the values of the Transient attributes show up as null currently. We need to have the literal values show up on creating a new row.

Finally, what worked for me was :-

I had the setAttribute in the EOImpl file removed.
Instead I had the literal values set in the 'Literal' window and the 'Derived from SQL expression' window.
The test cases for most entities passed fine.
I added tests in entity unit tests to test the default values for common association attributes in case of new row creation as well as fetch row from DB. They worked perfectly fine in both cases

Monday, April 11, 2011

Recursively copying files along with directory structure in linux

Although this is something relatively simple, sometimes doesnt work correctly especially if you're trying it after a long time. You could be faced with errors like :

cp: cannot create symbolic link , etc.

If you wanna copy say, multiple files along with directory structure from
/ab/cd/ef/gh/ij/kl/mn/op/qr/st/uv/*

to

/aba/cdc/efe/ghg/iji/klk/mnm/opo/qrq/sts/uvu/*

then typically

cp -R /ab/cd/ef/gh/ij/kl/mn/op/qr/st/uv/ /aba/cdc/efe/ghg/iji/klk/mnm/opo/qrq/sts/uvu/

should work good for you.

The entire list of files along with the directory structure, gets copied at the destination location. It is important here to give the complete paths for source as well as destination instead of trying to use relative paths!