^1639973621167
@
sname
ThingRegistUtils
slabel
ThingRegistUtils
sdescriptors
xworker.lang.MetaDescriptor3
smany
true
seditCols
2
sinitialization
false
smodifier
public
sid
ThingRegistUtils
  @/@actions
  sname
  actions
  sdescriptors
  xworker.lang.MetaDescriptor3/@actions
  sid
  actions
    @/@actions/@getNotes
    sname
    getRegistThings
    sisSynchronized
    false
    sthrowException
    true
    suseOtherAction
    false
    svarScope
    Global
    sdisableGlobalContext
    false
    Scode
#$@text#$@
def pst = null;
def rs = null;
def things = [];

try{
    def target = thing instanceof org.xmeta.Thing ? thing : world.getThing(String.valueOf(thing));
    if(target == null){
        return things;
    }
    // 原本调用 metaThing.doAction("getAllDEPaths")，但该动作已不存在（doAction 对不存在的动作返回 null），
    // 于是下面 split 必然 NPE、整个方法被上层吞掉。改为直接用 API 收集：自身 + 所有描述者 + 所有继承。
    def paths = new java.util.LinkedHashSet();
    paths.add(target.getMetadata().getPath());
    def descriptors = target.getAllDescriptors();
    if(descriptors != null){
        for(def d : descriptors){
            if(d != null && d.getMetadata() != null){
                paths.add(d.getMetadata().getPath());
            }
        }
    }
    def extens = target.getAllExtends();
    if(extens != null){
        for(def e : extens){
            if(e != null && e.getMetadata() != null){
                paths.add(e.getMetadata().getPath());
            }
        }
    }

    // 用路径关联，不要用 id 关联：tblThings.id 是 INTEGER 自增，
    // 而 tblThingRegists 的 thingId / registThingId 存的是 TEXT shortPath，两者永不相交。
    def sql = "select distinct t.* from tblThings t where t.path in (select registThingPath from tblThingRegists where registType=? and thingPath in (";
    for(int i=0; i<paths.size(); i++){
        if(i != 0){
            sql = sql + ",";
        }
        sql = sql + "?";
    }
    sql = sql + "))";

    pst = con.prepareStatement(sql);
    def index = 2;
    pst.setString(1, registType);
    for(p in paths){
        pst.setString(index, p);
        index++;
    }
    rs = pst.executeQuery();
    while(rs.next()){
        def path = rs.getString("path");
        def th = world.getThing(path);
        if(th != null){
            things.add(th);
        }
    }

    return things;
}finally{
    if(rs != null){
        rs.close();
    }
    
    if(pst != null){
        pst.close();
    }
}
#$@text#$@
    sdescription
    <p>获取注册到指定事物的事物列表。</p>
    sdescriptors
    xworker.lang.actions.Actions/@GroovyAction
    sid
    getNotes
      @/@actions/@getNotes/@contexts
      sname
      contexts
      sdescriptors
      xworker.lang.actions.Inout/@contexts
      sid
      contexts
        @/@actions/@getNotes/@contexts/@db
        sname
        dataSource
        sconnectionName
        con
        stransaction
        false
        sdataSourcePath
        xworker.ide.db.datasource.XWorkerDataSource
        sdisable
        false
        sonError
        ignore
        spreventError
        false
        sinherit
        true
        sdescriptors
        xworker.lang.db.jdbc.DataSouceActionContext,xworker.lang.actions.Inout/@contexts/@context
        sid
        db
      @/@actions/@getNotes/@ins
      sisValidate
      false
      sname
      ins
      sdescriptors
      xworker.lang.actions.Inout/@ins
      sid
      ins
        @/@actions/@getNotes/@ins/@thing
        sname
        thing
        stypeCheck
        false
        soptional
        true
        scheck
        false
        scheckLevel
        exception
        sdescriptors
        xworker.lang.actions.Inout/@ins/@param
        sid
        thing
        @/@actions/@getNotes/@ins/@registType
        sname
        registType
        stypeCheck
        false
        soptional
        true
        scheck
        false
        scheckLevel
        exception
        sdescriptors
        xworker.lang.actions.Inout/@ins/@param
        sid
        registType
