Tuesday, March 26, 2013

How to sum column in View Object using Groovy

Use Case : 
we have 2 tables PayOrders  and  PayOrderTrans 
 we need to :  sum Credit column in PaymentOrderTrans table

  • First create New Attribute called CreditTotal 
  • Go to Default Value section
  • Choose Expression
  • Enter the following expression
         object.getRowSet().sum('Credit')

  What about the Null value ?   
     to avoid null value, you must modify the expression to
          object.getRowSet().sum('Credit != null ? Credit : 0 ')


Saturday, March 23, 2013

The techniques for populate a sequence attribute in Oracle ADF


Technique No1:   
Allowing the database to handle the insertion operation
1- Add trigger to DB Table to fetch next sequence' number


2- Open Entity Object (ex:Department)
3- Change type of DepartmentId attribute to DBSequence


Technique No2
Fetching the next sequence number using Java/Groovy
first we need to add a java method to get thenext sequence' No
  • Open Department Entity Object
  • Go to Java ==>> Edit Java Option 
  • Check Generate Entity Object Class
  • Open DepartmentsImpl Java file 
  • Add the following lines to end of the file

To Get the next sequence number at the time of record creation (Java code):
  • Open DepartmentsImpl Java file
  • Go to Source Menu ==>> Override Methods
  • check create method
Add the following line after create  method 

To Get the next sequence number at the time of record creation (Groovy) : 
    • Open Departments Entity Object
    • Go to DepartmentId
    • Choose Expression in Default Value section
    • Enter adf.object.nextSequenceVal("DEPARTMENTS_SEQ")
       
      To Get the next sequence number at the time of Commit (Java Code) : 
      used to avoid gaps between sequence number 

      • Open DepartmentsImpl Entity Object
      • Go to Java tab 
      • Check Data Manipulation Methods 
      •  Add the following to doDML methods

      Question:if i am in need to apply EMPLOYEES SEQ to Employee Id,do i need to add nextSequenceVal method in the Employees EO again ?
      Answer : Yes, but can you think of a more general way to extend ADF Framework Classes where you can add your favorite utilities


      To add our custom ADF Framework Classes:
      • Right click on TestSeqModel 
      • java ==>>Class
      • Enter EntityImpl for Name 
      • Enter model.extension for Package
      • Enter oracle.jbo.server.EntityImpl for Extends
      • Add nextSequenceVal method
       
      • Double click on TestSeqModel 
      • Go to ADF Business Component ==>> Base Classes
      • In Entity Object Section  , browse for Row 
      • Enter entity word in the search menu
      • Choose model.extension
      • Press Ok and again OK 
      • Remove nextSequenceVal method from Departments EO 
      • The nextSequenceVal method is available now to all Entity Objects
      • Use nextSequenceVal in Employees EO
      Nick Haralabidis spoke about using a custom property to populate a sequence attribute in his book Oracle JDeveloper 11gR2 Cookbook 



      The best solution for me is the third one

      Friday, March 22, 2013

      Oracle Team Productivity Center & Jira (part 2 )

      i described how to deal with the tasks and the same concept can applied to Jira .
      Now i will add Task in JDeveloper  to reflect in Jira
      • Open Jira
      • Two tasks only here
        • Log in to OTPC
        • Right click on Jira Repository ==>> New Issue
          • Enter details to the task
          • Save the task 
          • Back to Jira , the new task here
          • Go to the Task in JDeveloper
          • Press Comment button
          • Write some thing like Done
          • Press Save 
          • Back to the task 
          • Press Close issue 
          • Back again to Jira
          • What do you see? 





          good luck

          Oracle Team Productivity Center & Task


          Oracle offer local task repository if you don't like to work with other programs like  Microsoft Project,Bugzilla or Jira  
          How we can deal with local Task Repository ? See below 
          • Install Task Connector if you didnt install it before
           
          Defining task repository and adding it to DevTeam
          • Connect to OPTC as administrator (otpcadmin/welcome1)
          • Go to Repositories tab
          • Click green button to add new repository
          •  Enter Task Repository for Name
          • Go to Teams tab ==>>Team Repository
          • Check Task Repository
          • Discount from OTPC
          • Connect as normal user (wael/wael)
          • Observe Task Repository under Work Items menu
           We will add a new task
          • Right click on Task Repository
          • Choose New Task
           

          Enter Adding logo to Login page to Task Name
          Enter Adding logo to Login page for Description

          • Click the search icon next to Assign to
          • Click the search button
          • Assign the task to Saleh  
          • Click save
          Searching for the tasks assigned to Saleh
          • Disconnect from OTPC
          • Connect as saleh/saleh
          • Right click on Task Repository ==>> Query By ID
          • Enter 1
          • The Result

          Another way to search for tasks
          • Right click on Task Repository ==>> New Query
          • Click on the search button
          • Choose Assigned to from the list in Search criteria area
          • Choose Saleh from the list
          • Click Save button
          • Enter My Tasks for Name
          • The Result 
          • At any time you can run My Tasks to know the tasks assigned to you




          good luck

          Sunday, March 17, 2013

          Oracle Team Productivity Center & SubVersion


          How we can connect subversion and OPTC ? that's what we'll talk about today

          first we need subversion server , i will use VisualSVN server (evaluation copy) for our demo to explain concept  , you can use what you like or choose free one ( VisualSVN is not free )

          After installation , run server 


          - Right click on Repositories 
          - Choose create New repository

           

          - Enter AdfRepository for name
           

          - Right click on AdfRepository  
          - Choose Project Structure 


          - Enter Finance for project name 




          because we use evaluation copy we will create user , with Enterprise Edition you can connect to active dirctory , or you can choose to use free subversion 
          see Comparison of Subversion clients

          - Go to Users ==>> right click and choose create user 
            say user name : waelSVN  , password : 123


            - Now open Jdeveloper , 
            - Connect to OPTC 
            - Login as optcadmin/welcome1


          - Go to Team Administration


          - Go to Repositories tab ==>> Versioning 
          - Click on green button 
          - Choose Subversion from connector list 
          - Enter AdfRepository for Name 


          - Go to Teams tab ==>> Team Repositories
          - Check AdfRepository

             
          - Back to Subversion Server 
          - Copy URL for Repository

              
          - Past value in server url 


          - Log out and log in again as wael/wael  
          - Double click on AdfRepository 
          - Enter user name and password for Subversion User (waelSVN/123)
          - Test connection  

            
          - Your screen should be like following picture 


          - Right click on AdfRepository  
          - Choose New Remote Directory


          - Enter Hr for name  

           

           - We can see change in JDeveloper 


          - And in Subversion server 



          more about subversion :
           



          good luck