Maximo Wire - The IBM Maximo Help & Discussion Forum
May 24, 2012, 12:23:28 am *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Welcome to Maximo Wire, the IBM Maximo help forum. Feel free to register and ask any Maximo related questions you like.
 
  Home Help Search Login Register  
*
Pages: [1]   Go Down
  Print  
Author Topic: Adding status change to custom application extending StatusHandler  (Read 680 times)
0 Members and 2 Guests are viewing this topic.
G Jeevan
Newbie
*

Karma: 2
Posts: 30



View Profile
« on: January 19, 2012, 12:45:22 pm »

Hi Friends Smiley

Once we create a custom application it may need change status functionality .So im gona share the steps i did to get it done.there may be other ways also but i found it good.........i am  new to maximo so plz correct me if i go wrong..................so lets rock....... Wink


Steps to add Status  Change to a custom application.

1.We need 2 new objects to add this capability to our custom application.
•   One persistent object to store status changes made.
•   One non-persistent to capture the values from status change dialog box.

(Note : Objects & Attributes Used...1.XSTATUSHISTORY[persistent]—Attributes:status,memo,id[my key field to maintain a relation with my main object],statdate,changeby.

2.XSTATUS[non-persistent]—Attributes:status,memo,statdate.[ur main object must have status and ststdate fields too and all the objects must be at the same level i.e site or system etc...and my main object is XREQUISITION......i will use this name later])

Create these two objects and apply config changes.

2.Create a new Synonym domain as status handler works on this type of domains only(may use exixting also).Synonym domain cant be created from front end so create it in data base.Search for table “SYNONYMDOMAIN” and enter the values which u want in the new domain like WAPPR\APPR etc.  Then in table “MAXDOMAIN” give the entry fo this new domain.Add this domain to main objects ‘status’ attribute.

3.We need to ceate 3 new relations all in main objects relationship tab(in database configuration).
•   Main Object      Child         Where Clause
•   Xrequisition      Xstatushistory      key=:key[ur key field]
•   Xrequisition      Xstatus         empty
•   Xrequisition      Synonymdomain   domainid=’<new domain name>’ and                  value=:status

4.Now we have to create class files for new objects
Xstatushistory needs 4 files (common files....... )
Xstatus need only 2 files [main class which extends ChangeStatus and a set class which extends ChangeStatusSet][place these class files in virtual folder for simpler identification of them being non-persistent]
CustomStatusHandler class which extends StatusHandler

5.Our main calss must extend StatefulMbo instead on Mbo and over ride 3 methods

•   getStatusHandler()
•   getStatusListName()
•   getStatusHistory()

getStatusHandler() must return the CustomStatusHandler class obj.[ return new ReqStatusHandler(this);]
getStatusListName() must return the domain used i.e new synonym domain. [return "PRSTATUS";]
getStatusHistory() must return the MboSet of Xstatushistory. [return getMboSet("REQTOSTATUS");]

6.Adding “Change Status” option in select action dropdown and creating dialog box.
Goto data base configuration and select the application
Goto select action--------sig options----new row
Option=status;desc=Change Status;visible=true--------------press ok
Goto select action----add\modify select action------new row
Element type=option;key value=status;desc=Change Statua;visible=true;tabs=all-----ok
Now export the applicatio xml and add code to create a dialog box
Note: dialog id must be same as key value created above.

Code for dialog box

<dialog beanclass="psdi.webclient.beans.common.ChangeStatusBean" id="status" label="Change Status" relationship="REQTOSTAT">
      <section border="true" datasrc="MAINRECORD" id="changestatus_grid1_1_1_grid3">
         <multiparttextbox dataattribute="xid" descdataattribute="xdescription" descinputmode="readonly" id="changestatus_grid1_1_1_grid3_1" inputmode="readonly" label="Requisition Id"/>
         <multiparttextbox dataattribute="status" descdataattribute="statusdesc.description" descinputmode="readonly" id="changestatus_grid1_1_1_grid3_5" label="Status"/>
      </section>
      <section id="changestatus_grid1_1_1_grid4">
         <combobox dataattribute="status" id="changestatus_grid1_1_1_grid4_1" label="Status"/>
         <textbox dataattribute="xstatdate" id="changestatus_grid1_1_1_grid4_2" label="Change Date" lookup="datelookup"/>
         <textbox dataattribute="xmemo" id="changestatus_grid1_1_1_grid4_3" label="Memo"/>
      </section>
      <buttongroup id="changestatus_2">
         <pushbutton default="true" id="changestatus_2_1" label="OK" mxevent="dialogok"/>
         <pushbutton id="changestatus_2_2" label="Cancel" mxevent="dialogcancel"/>
      </buttongroup>
   </dialog>
Bean class used is in commons folder so no need to create it.For Relationship use the relation ship created for xstaus table.”Statusdesc” is relationship name to synonymdomain.
To the status attribute in xstatus object add a field class to populate the dropdown in dialog box.Look for FldChangeStatus class in[C:\ibm\SMP\maximo\applications\maximo\businessobjects\classes\psdi\common\commtmplt\virtual]

cont......

Logged
G Jeevan
Newbie
*

Karma: 2
Posts: 30



View Profile
« Reply #1 on: January 19, 2012, 12:46:52 pm »

cont.......



7.Now  code sniplets

1.set statdate to current date in non-persistent main class’s add method
public void add()
     throws MXException, RemoteException
 {
   super.add();
     Date currentDT = MXServer.getMXServer().getDate();
     setValue("statdate", currentDT, 11L);       
     
 }
Now in set class of non-persistent object write similar code
protected MboSetRemote getMboIntoSet(MboRemote mbo)
        throws MXException, RemoteException
    {
        MboSetRemote changeSet = getMboServer().getMboSet("XREQUISITION", getUserInfo());
        SqlFormat sqf = new SqlFormat(mbo, "xid = :xid and siteid = :siteid");
        changeWOSet.setWhere(sqf.format());
        return changeSet;
    }

    protected void changeMboStatus(MboRemote req, MboRemote param)
        throws MXException, RemoteException
    {       
       ((RequisitionRemote)req).changeStatus(param.getString("status"), param.getDate("statdate"), param.getString("memo"));
    }
Our Remote must contain changeStatus method so create it in Remote.
Methods to be used in CustomStatusHandler class
public void canChangeStatus(String currentStatus, String desiredStatus, long accessModifier)
           throws MXException, RemoteException
       {

          Current status and desired status are available here so any conditions needed to be checked before the status can be changed can be done here.Exceptions can be thrown.       
          
          
       }
public void changeStatus(String currentStatus, String desiredStatus, Date date, String memo)
        throws MXException, RemoteException
    {
In this method we can apply status changes to main object attributes.
Parent.SetValue(“status”,desiredStatus.2L)
}
After this method is done the controll goes to Main Class which also has a changeStatus() method
public void changeStatus(String status, Date date, String memo,
         long accessModifier) throws MXException, RemoteException {
Now set values to xstatushistory
SqlFormat sqf = new SqlFormat("1=2");

         MboSetRemote statusHistorySet = getMboSet("&statushistory",
               "xstatushistory", sqf.format());
         System.out.println("mbo set is" + statusHistorySet.getName());
         MboRemote historyStatusRemote = statusHistorySet.add();
         if (historyStatusRemote != null) {

            historyStatusRemote.setValue("xid", getString("xid"), 2L);
            historyStatusRemote.setValue("xchangeby",
                  getString("xchangedby"), 2L);
            historyStatusRemote.setValue("statdate",
                  getString("xchangedate"), 2L);
            historyStatusRemote.setValue("status", status, 2L);
            historyStatusRemote.setValue("memo", memo, 2L);
}

This should give u status change functionality ........................

StatusHandler methods call flow
Its starts when u select the Change Status option in Select Actions
For  easier understanding i am using the names of class files in  my application along with the object names.
Object : Xrequisition         ----main class Requisition.java (req or requisition)
               -----ReqStatusHandler.java
   Xstatushistory         ----- ReqStatus.java
   Xstatus   [non-persistent]   ----ReqChangeStatus.java and  ReqChangeStatusSet.java 

1.   in ReqChangeStatusSet getMboIntoSet()
2.   in req constructor()
3.   in req init()
4.   in ReqChangeStatusSet changeMboStatus()
5.   in requisition changeStatus ()
6.   in requisition getStatusListName()
7.   in requisition getStatusHandler()
8.   in ReqStatusHandler constructor()
9.   in ReqStatusHandler canChangeStatus()
10.   in requisition changeStatus ()


For more ref plz check PR application class files.
Hope it helps u


Thanks & Regards Cheesy


Logged
kvnaresh
Newbie
*

Karma: 0
Posts: 11


View Profile
« Reply #2 on: January 29, 2012, 11:17:29 pm »

    WOW !!!!!!!!  That's an interesting stuff ..... good one jeevan.
Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  

Recent

TinyPortal v1.0 beta 4 © Bloc
Powered by MySQL Powered by PHP Powered by SMF 1.1.15 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!