Friday, June 30, 2017

Getting Ref of the View Object referenced by the current Iterator binding for One iterator page without knowing the name of the iterator

Getting Ref of the View Object referenced by the current Iterator binding for One iterator page without knowing the name of the iterator

In a previous blog (Playing around with ADFdatacontrol),  it was shown that you can get the ApplicationModule object without having to know the name of the Data Control. i mean Instead of this line of code
AppModuleImpl appmodule = (AppModuleImpl)ADFUtils.getApplicationModuleForDataControl("AppModuleDataControl");

you could write the following
        DCBindingContainer binding =   (DCBindingContainer)ADFUtils.getBindingContainer();
        DCDataControl cDataControl = binding.getDataControl();
        ApplicationModule AM =cDataControl.getApplicationModule();


Now, and in order to be more generic in code writing, here is a code that will get you the View Object to which the iterator binding of a page is bound to.
This code will work for simple pages that contain one iterator binding because if there are two iterator bindings within the same page definition, you will need to specify which one you
want

// this piece of code will get all iterator bindings for the page and will check that there is only ONE iterator binding, this implementation is much faster than iterator through the iterator and count it
    
   ArrayList arr = binding.getAllIterBindingList();
        if (arr instanceof Collection) {
            int size = (arr).size();
            System.out.println(size);
            if (size != 1) {
                System.out.println("not single iterator ok");
  //  practically, should through an exception  
              }
          
       else
 {
//  once you are sure there is only one iterator, then you fetch the first iteratorbinding in the list

                DCIteratorBinding ItrBind = (DCIteratorBinding)arr.get(0);

// here you get the viewobject that the iterator references without its name

                ViewObject voData = ItrBind.getViewObject();
 //  just playing around with some method of the view object to test               
                Long range = voData.getEstimatedRowCount();
                System.out.println("Range :" + range.toString());
                System.out.println("VO name " + voData.getDefFullName());
            }
        }
      else {
            System.out.println("not a collection ");
        }


You can now create a method that shall return the ViewObject 

    public ViewObject  getCurrentIteratorVO () {
        DCBindingContainer binding = (DCBindingContainer)ADFUtils.getBindingContainer();
        ArrayList arr = binding.getAllIterBindingList();
        if (arr instanceof Collection) {
            int size = (arr).size();
            System.out.println(size);
            if (size != 1) {
                System.out.println("not single iterator ");
            // practically, should through an exception
            }
            else {
               DCIteratorBinding ItrBind = (DCIteratorBinding)arr.get(0);
               ViewObject voData = ItrBind.getViewObject();
              return voData;
                 }
           } 
         else 
          {
            System.out.println("not a collection ");
         }
                return null;
    }

Call the method
    public String cb6_action() {
        // Add event code here...
        ViewObject vv = getCurrentIteratorVO();
        return null;
    }

The output is

1
Range :14


VO name model.EmpView

Tuesday, June 27, 2017

Playing around with ADF dataControl

While trying to figure out what one of our ex-colleagues at REALSOFT is programming a business rule engine admin screen for the Health Insurance Administration card issuance and administration software solution, i noticed the following piece of code

    AppModuleImpl appmodule =
        (AppModuleImpl)ADFUtils.getApplicationModuleForDataControl("AppModuleDataControl");

this piece of code is specific for the Oracle Application Development Framework that we use to build JEE web scalable , mission critical applications.

Being a principal in the company, i try to find ways not only to optimize the coding endeavor , but also to minimize costs. 

One way of doing that is obviously  by building reusable libraries, encapsulate the nitty-gritty issues and minimizing the things that the developer needs to understand about the framework in order to getting his applications up and running.

What i do not like about the above is that fact that the developer needs to know the Data Control  Name in order to access the ApplicationModule object 

 What i have in mind is to create a method that will get does not need the developer to know more that the method name in order to get the application module.  I fiddled around with helper classes found the following


public class Ammar {
    public Ammar() {
        super();
    }
    public void PlayWithDataControl(){
        DCBindingContainer binding =   (DCBindingContainer)ADFUtils.getBindingContainer();
        DCDataControl cDataControl = binding.getDataControl();
        ApplicationModule AM =cDataControl.getApplicationModule();
//        System.out.println(cDataControl.getName());  to make sure i am within the same data control
// another legitimate question is what if i have more that one page in the application, am i getting the application module pertaining to the page definition i am on?  well , the test below indicates that the answer is yes,, i created two pages, and called the following code from both, and each printed its own page definition name

System.out.println(    binding.getDef().getContainerName());
      
    }

So ,  i would just modify the above and add it to company Library

    public ApplicationModule getRSMyAppMod(){
        DCBindingContainer binding =  (DCBindingContainer)ADFUtils.getBindingContainer();
        return binding.getDataControl().getApplicationModule();
    }

you can then call it from your view controller ,, something like this, i am using strongly typed implementation here

    public String cb6_action() {
        // Add event code here...
        AppModuleImpl appMod = (AppModuleImpl)getRSMyAppMod();
        ViewObject vo = appMod.getEmpView1();
        ViewObjectImpl empView1 = appMod.getEmpView1();
}

Another corollary of the Binding container which i liked is the fact that i can fetch all the binding attributes

        List attrBindings = binding.getAttributeBindings();
        Iterator itr = attrBindings.iterator();
        while (itr.hasNext()){
            AttributeBinding attrBinding = (AttributeBinding)itr.next();
            String val = attrBinding.getInputValue().toString();
            System.out.println(val);

Yes another corollary is that one can find the  value of an attribute from the binding container directly by using the method    attrBinding.getName();


also i found in the ADFUtils helper method the following which return the value of any bound attribute..  This is very nice, and will make the life of people coming from forms background easier.
Just call the method ScreenValue instead of the getBoundAttribute, and it will be all fun


    public static Object getBoundAttributeValue(String attributeName) {
        return findControlBinding(attributeName).getInputValue();

Ammar  Sajdi  Third day of Eid at office enjoying the heat wave 35C

Sunday, June 25, 2017

Say Hi to Julia

By Ammar Sajdi

Well, Do not get too excited, Julia is a programming language. It saw the light on Valentine’s Day, 2012.
While it can be an effective general-purpose programming language, the real strength of Julia is the fact that provides for high-performance, parallel, and distributed computing.  


Well parallel and distributed caught my attention, I never wrote a program that can unleash the power of parallel computing. I looked at the language, and it is really easy to do parallel computing. This makes it suitable for applications that involve intense numerical analysis

if you want to know what people think of Julia refer to 

https://www.quora.com/What-is-your-take-on-Julia-language

someone said

There was never a doubt in my mind that Julia is good, probably the best language for the future, will succeed/already has for the scientific audience (as clearly better than all alternatives, for performance work where you also want to be "dynamic"). It's estimated to have exponential growth of users, doubling every 9 months now, estimated at 100,000 users, with I forget how many downloads per day. Look it up (it's in a video on YouTube, from one of the key Julia people).

I'm sure the rest of (non-HPC) programmers will eventually clue up, and use it as the general language that it is.

https://www.quora.com/Is-Julia-programming-language-growing-fast

finally, I met a young relative of mine who is studying Engineering at Stanford, and part of the industrial engineering curriculum is to take a course in Julia programming.

EDIT Sept 18, 2024:  So far it seems that Julia's programming language is not picking up as I thought. People still prefer to use Python. Julia could still be needed in certain situations like distributed and parallel processing.

https://www.reddit.com/r/Julia/comments/18s0ubz/is_julia_programming_language_destined_to_fade/

rgds

Ammar  Sajdi -  REALSOFT

ليش اسمه عيد

Ammar Sajdi   ,  2017

well I wrote about it before

3id in Arabic comes from E3adah (return, repetition). Saying Happy Eid implicitly means that one wishes the happy return of this occasion


Do I wish the return of events that occurred this year, well in the regional front, it has been bad and getting worse

civil war in Syria (not anymore a civil war, but a war fought by many countries on Syrian soil).

The Saudi war against Yemen,, Cholera breakout in Yemen, Gulf-Qatar Crises, Political unrest in Libya, Palestinian Hunger strike in Israeli prisons, and the list goes on.


Almotanabi summed it up by saying


عيد الي حال عدت يا عيد                                       بما مضى ام بامر فيك تجديد                         



ولا ماني شايف تجديد    شايف بما مضى بس اسوأ حالا


ولكن وعلى كل حال   كل عام ونتم بخير

Ammar

Fundamentals of Software Testing

Originally posted on jan , 23 2009, Published again on Sept,18,2024 extracted completely from    http://testingsoftware.blogspot.com/2005/1...