package com.webclient.beans.udkbfl;
import psdi.util.MXException;
import psdi.webclient.beans.common.TreeControlBean;
import psdi.webclient.system.beans.DataBean;

import java.rmi.RemoteException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
/**
 * 知识分类树状DataBean
 * edit 2023-10-12
 */
public class UdkbflListTreeBean extends TreeControlBean {


    protected void initialize() throws MXException, RemoteException {
        super.initialize();
    }

    public int selectrecord() throws MXException, RemoteException {
        super.selectrecord();
        return 1;
    }

    // 过滤特殊字符
    public static String StringFilter(String str) throws PatternSyntaxException {
        // 只允许字母和数字 // String regEx ="[^a-zA-Z0-9]";
        // 清除掉所有特殊字符
        String regEx = "[`~!@#$%^&*()+=|{}':;',\\[\\].<>/?~！@#￥%……&*（）——+|{}【】‘；：”“’。，、？]";
        Pattern p = Pattern.compile(regEx);
        Matcher m = p.matcher(str);
        return m.replaceAll("").trim();
    }

    public Object[][] getTop(String[] dataattributes, int maxchildren) throws MXException, RemoteException {

        return super.getTop(dataattributes,maxchildren);
    }

    public Object[][] getChildren(String objectname, String uniqueid, String[] dataattributes, int maxchildren) throws MXException, RemoteException {
        return super.getChildren(objectname,uniqueid,dataattributes,maxchildren);
    }


    public int selectnode() throws MXException, RemoteException {
        String selectedUniqueId = getuniqueidvalue();
        if ((selectedUniqueId != null) && (!("".equals(selectedUniqueId)))) {
            String sql="PARENT in(SELECT FLBH FROM UDKBFL WHERE UDKBFLID="+selectedUniqueId+") OR UDKBFLID="+selectedUniqueId.replace(",", "")+" ";
            DataBean resultBean = this.app.getDataBean("1664194624573");
            resultBean.setAppWhere(sql);
            resultBean.reset();
        }
        return 1;
    }

    public int execute() throws MXException, RemoteException {
        return 1;
    }


}
