Monday, June 9, 2014

Bean Class Sample In Maximo

Here is the sample code.

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package custom.webclient.system.beans;
import psdi.webclient.system.beans.*;
import java.rmi.RemoteException;
import psdi.util.MXException;
import java.text.ParseException;
import psdi.app.workorder.WORemote;
import psdi.mbo.MboSetRemote;
import psdi.server.MXServer;
import psdi.webclient.system.controller.Utility;
import psdi.webclient.system.controller.WebClientEvent;
import psdi.util.logging.FixedLoggerNames;
import psdi.util.logging.MXLogger;
import psdi.util.logging.MXLoggerFactory;
/**
*
* @author Emrah Sogutoglu
*/
public class TesisUcretBean extends DataBean {
MXLogger appLog = MXLoggerFactory.getLogger(FixedLoggerNames.LOGGERNAME_APP + ".TesisUcretSec");
private double getItemToolRate(String itemnum, WORemote wo)
 throws RemoteException, MXException {
MboSetRemote item = MXServer.getMXServer().getMboSet("ITEMORGINFO", wo.getUserInfo());
item.setWhere("ITEMNUM='" + itemnum + "'");
item.reset();
return item.getMbo(0).getDouble("TOOLRATE");
}
public int Q25_0_10() throws RemoteException, MXException, ParseException {
//Go to the related workorder
DataBean appBean = Utility.getDataSource(sessionContext, app.getAppHandler());
WORemote wo = (WORemote) appBean.getMbo();
System.out.println("WONUM: " + wo.getString("WONUM"));
//Building info is being fetched from workorder
MboSetRemote bina = wo.getMboSet("WO2BINA");
bina.setWhere("BINA_ID='" + wo.getString("BINAKODU") + "'");
bina.reset();
try {
 if (bina.count() > 0) {
     bina.getMbo(0).setValue("BR_ANA_KOLON_CAPI", "Q25(3/4'')");
     bina.getMbo(0).setValue("SEBEKE_BINA_MESAFE", "0-10M");
     bina.getMbo(0).setValue("TEK_SUBE_YOL_UCRETI", getItemToolRate("T01", wo));
     bina.save();
     appBean.save();
     appBean.fireStructureChangedEvent();
     Utility.sendEvent(new WebClientEvent("dialogclose", app.getCurrentPageId(), null, sessionContext));
     sessionContext.queueRefreshEvent();
 }
} catch (Exception e) {
 appLog.error("ERROR: " + e + "n" + e.getStackTrace());
}
return 1;
}
}

Ok guys, this code is attached to the related button. It is easy to do that. You just need to navigate to Application Designer. And then find your dialog. Push Edit dialogs button. Seek for your dialog in the list. Go to the related button properties. Then call the Q25_0_10() method in the event field of the properties window by writingQ25_0_10 in it as shown below.

I hope this helps you to create your own custom dialog and custom bean class.

No comments:

Post a Comment

JMS Messaging - High availability, scalability and Maximo Integration Framework using a single Service Integration Bus

T he first is configuring the JMS resources for scalability and the second is configuring the messaging engines for highly availability. For...