예제 #1
0
  private void doCache(SuperVO vo, Dataset ds, Row row) {
    ViewContext widgetCtx = getLifeCycleContext().getViewContext();
    // 此子表的dsId
    String dsId = getSlaveDataset(widgetCtx);
    DatasetRelation[] rels = widgetCtx.getView().getViewModels().getDsrelations().getDsRelations();
    if (rels == null) return;
    String foreignKey = null;
    for (int i = 0; i < rels.length; i++) {
      DatasetRelation dsRel = rels[i];
      if (dsRel.getDetailDataset().equals(dsId)) {
        foreignKey = dsRel.getDetailForeignKey();
        break;
      }
    }
    if (foreignKey == null) return;
    String foreignValue = (String) vo.getAttributeValue(foreignKey);
    List<SuperVO> list = (List<SuperVO>) LfwCacheManager.getSessionCache().get(foreignValue);
    if (list == null) {
      list = new ArrayList<SuperVO>();
    }
    list.add(vo);
    LfwCacheManager.getSessionCache().put(foreignValue, list);

    // 删除的子表的行信息
    String delRowForeignKey = foreignValue + "_" + dsId;
    List<Row> listDelRow = (List<Row>) LfwCacheManager.getSessionCache().get(delRowForeignKey);
    if (listDelRow == null) {
      listDelRow = new ArrayList<Row>();
    }
    listDelRow.add(row);
    LfwCacheManager.getSessionCache().put(delRowForeignKey, listDelRow);
  }
예제 #2
0
  public void execute() {
    ViewContext widgetctx = getLifeCycleContext().getViewContext();

    String dsId = getSlaveDataset(widgetctx);
    Dataset ds = widgetctx.getView().getViewModels().getDataset(dsId);
    Row selRow = ds.getSelectedRow();
    // 未选择行,给出提示
    if (selRow == null) throw new LfwRuntimeException("请选择要删除的行!");
    // 持久化
    Dataset2SuperVOSerializer ser = new Dataset2SuperVOSerializer();
    SuperVO vo = ser.serialize(ds, selRow)[0];
    if (vo.getPrimaryKey() == null) delete = true;
    if (delete) doDeleteVO(vo);
    else doCache(vo, ds, selRow);
    if (selRow != null) {
      int rowIndex = ds.getRowIndex(selRow);
      ds.removeRow(rowIndex);
      if (rowIndex > ds.getCurrentRowCount() - 1) rowIndex = ds.getCurrentRowCount() - 1;
      ds.setRowSelectIndex(rowIndex);
    }
    doAfterDelLine();
  }