package com.webclient.beans.udkbfl;

import com.ibm.tivoli.maximo.asset.ilog.controls.ILogControl;
import psdi.mbo.MboRemote;
import psdi.mbo.MboSetRemote;
import psdi.util.MXApplicationException;
import psdi.util.MXException;
import psdi.webclient.system.beans.ResultsBean;
import psdi.webclient.system.controller.ControlInstance;
import psdi.webclient.system.controller.PageInstance;
import psdi.webclient.system.controller.WebClientEvent;

import java.rmi.RemoteException;
/**
 * ÖªÊ¶¿âÊ÷×´DataBean
 * edit 2023-10-12
 */
public class UdkbResultsBean extends ResultsBean
{
    public int selectrecord()
            throws MXException, RemoteException
    {
        int var1 = super.selectrecord();

        return var1;
    }

    private void markTopologyViewInitRequired() {
        PageInstance currentPage = this.clientSession.getCurrentApp().getCurrentPage();
        ControlInstance ctrl = currentPage.getControlInstance("asset_assettopoapplet");
        if ((ctrl != null) && ((ctrl instanceof ILogControl)))
            ((ILogControl)ctrl).setInitialLoadRequired(true);
    }

    public int addrow()
            throws MXException
    {
        int add = super.addrow();
        try {
            MboRemote mbo = getMbo();
            if (null != mbo) {
                int minid = (int)mbo.getThisMboSet().min("UDKBFLID");
                MboSetRemote udkbflSet = mbo.getMboSet("$UDKBFL", "UDKBFL", "UDKBFLID=" + minid + "");
                if ((null != udkbflSet) && (!udkbflSet.isEmpty())) {
                    MboRemote minMbo = udkbflSet.getMbo(0);
                    String flbh = minMbo.getString("FLBH");
                    mbo.setValue("PARENT", flbh, 2L);
                    minMbo.setValue("HASCHILDREN", true, 2L);
                } else {
                    mbo.setValue("HASCHILDREN", true, 2L);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        this.app.getAppBean().refreshTable();
        return add;
    }

    public synchronized void save() throws MXException {
        super.save();
        try
        {
            this.app.getAppBean().reloadTable();
            this.app.getAppBean().refreshTable();
            this.app.getDataBean("1532060720158").reloadTable();
            this.app.getDataBean("1664194624573").refreshTable();

            WebClientEvent webclientevent = this.clientSession.getCurrentEvent();
            this.clientSession.showMessageBox(webclientevent, new MXApplicationException("udinspart", "udinspart_save", new String[0]));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}