예제 #1
0
  public static ILfwRefModel getRefModel(RefNode refnode) {
    IRefModelFetcher fetcher = null;
    if (refnode instanceof NCRefNode)
      fetcher =
          (IRefModelFetcher)
              LfwClassUtil.newInstance(LfwRuntimeEnvironment.getServerConfig().get("REFMODEL_NC"));
    else fetcher = new DefaultRefModelFetcher();

    return fetcher.getRefModel(refnode, null);
  }
예제 #2
0
  /** 序列化多个dataset */
  public String[] serialize(Dataset[] dss) {
    if (dss != null && dss.length > 0) {
      String[] rss = new String[dss.length];
      for (int i = 0; i < dss.length; i++) {
        Dataset ds = dss[i];
        // 做数据校正,将“编码树”结构改造成为“PK树”,此改造在本页面会话中只进行一次
        if (ds.getExtendAttribute(Dataset.CODE_LEVEL_CLAZZ) != null) {
          ICodeRuleDsUtil dsUtil =
              (ICodeRuleDsUtil)
                  LfwClassUtil.newInstance(
                      (String) ds.getExtendAttributeValue(Dataset.CODE_LEVEL_CLAZZ));
          String codeRule = (String) ds.getExtendAttributeValue(Dataset.CODE_LEVEL_RULE);
          String codeField = (String) ds.getExtendAttributeValue(Dataset.CODE_LEVEL_CODEFIELD);
          String codePk = (String) ds.getExtendAttributeValue(Dataset.CODE_LEVEL_PK);
          String codePPk = (String) ds.getExtendAttributeValue(Dataset.CODE_LEVEL_PPK);
          int codeIndex = ds.getFieldSet().nameToIndex(codeField);
          int pkIndex = ds.getFieldSet().nameToIndex(codePk);
          int ppkIndex = ds.getFieldSet().nameToIndex(codePPk);
          dsUtil.buildCodeRuleDataset(ds, codeRule, codeIndex, pkIndex, ppkIndex);
        }

        // 处理字段关联
        processFieldRelation(ds);
        processFormular(ds);
        StringBuffer xmlSb = new StringBuffer(BUFFER_SIZE);
        xmlSb.append(
            "<dataset id=\""
                + ds.getId()
                + "\" focusIndex=\""
                + ds.getFocusIndex()
                + "\" currentkey=\""
                + (ds.getCurrentKey() == null ? EventContextConstant.NULL : ds.getCurrentKey())
                + "\" editable=\""
                + ds.isEnabled()
                + "\" randomRowIndex=\""
                + ds.getRandomRowIndex()
                + "\">\n");
        xmlSb.append("    <" + EventContextConstant.res_parameters + ">\n");
        ParameterSet resParamSet = ds.getResParameters();
        int count = resParamSet.size();
        for (int j = 0; j < count; j++) {
          Parameter param = resParamSet.getParameter(j);
          String name = param.getName();
          String value = param.getValue();
          xmlSb.append("      <" + EventContextConstant.parameter + " name=\"" + name + "\">");
          xmlSb
              .append(value == null ? "" : value)
              .append("</" + EventContextConstant.parameter + ">\n");
        }
        xmlSb.append("    </" + EventContextConstant.res_parameters + ">\n");
        xmlSb.append("    <rowsets>\n");
        RowSet[] rowsets = ds.getRowSets();
        for (int j = 0; j < rowsets.length; j++) {
          RowSet rowSet = rowsets[j];
          int pagecount = rowSet.getPaginationInfo().getPageCount();
          int pagesize = rowSet.getPaginationInfo().getPageSize();
          int recordscount = rowSet.getPaginationInfo().getRecordsCount();
          int pageindex = rowSet.getPaginationInfo().getPageIndex();
          xmlSb
              .append("    <rowset pagecount=\"")
              .append(pagecount)
              .append("\" pagesize=\"")
              .append(pagesize)
              .append("\" recordcount=\"")
              .append(recordscount)
              .append("\" pageindex=\"")
              .append(pageindex)
              .append("\" keyvalue=\"")
              .append(rowSet.getKeyvalue())
              .append("\"");
          if (rowSet.getOldKeyValue() != null) {
            xmlSb.append(" oldkeyvalue=\"").append(rowSet.getOldKeyValue()).append("\"");
          }
          xmlSb.append(">\n");

          RowData[] rds = rowSet.getRowDatas();
          for (int k = 0; k < rds.length; k++) {
            RowData rdata = rds[k];
            if (rdata.isRowDataChanged()) {
              xmlSb.append(
                  "    <"
                      + EventContextConstant.records
                      + " pageindex=\""
                      + rdata.getPageindex()
                      + "\" changed=\""
                      + rdata.isRowDataSelfChanged()
                      + "\">\n");
              Integer[] indices = rdata.getSelectIndices();
              if (indices != null && indices.length > 0) {
                xmlSb.append("<selected>");
                for (int l = 0; l < indices.length; l++) {
                  xmlSb.append(indices[l]);
                  if (l != indices.length - 1) {
                    xmlSb.append(",");
                  }
                }
                xmlSb.append("</selected>\n");
              }
              processRecord(xmlSb, rdata);
              xmlSb.append("</" + EventContextConstant.records + ">\n");
            }
          }
          xmlSb.append("    </rowset>\n");
        }
        xmlSb.append("    </rowsets>\n");
        xmlSb.append("</dataset>\n");
        rss[i] = xmlSb.toString();
      }
      return rss;
    }
    return null;
  }
예제 #3
0
 private String getRefTableName(Dataset refDs) {
   String superClazz = refDs.getVoMeta();
   SuperVO vo = (SuperVO) LfwClassUtil.newInstance(superClazz);
   return vo.getTableName();
 }