示例#1
0
  public Map process(UIBlockContext parser) {
    Map ctx = new HashMap();
    this.init(parser, ctx);

    List result = new ArrayList();
    if (parser.getPageSize() == 1) {
      Object record = parser.getItemObj();
      if (record != null) {
        result.add(record);
      }
    }
    if (result.size() == 0) {
      result = parser.query(getExpr(parser));
      if (parser.getBlock().isFillBlank())
        for (int i = result.size(); i < parser.getPageSize(); i++) {
          result.add(null);
        }
    }

    UIBlockDataModel data = parser.getCatalog();
    if (parser.getCellCount() == 1) {
      for (Object obj : result) {
        if (obj == null) data.addItem(new UIBlockDataModel());
        else data.addItem(parser.makeDataModel(obj));
      }
    } else {
      List<List> listlist = parser.querySplit(result);
      for (List<IProduct> list : listlist) {
        UIBlockDataModel row = new UIBlockDataModel();
        data.addItem(row);
        for (IProduct obj : list) {
          UIBlockDataModel item = parser.makeDataModel(obj);
          if (obj != null) {
            StringBuffer title = new StringBuffer(item.getTitle());
            Double oldprice = obj.getOldPrice();
            Double price = obj.getNowPrice();
            Double balance = obj.getBalance();
            if (oldprice != null && !oldprice.equals(price))
              title.append(" 原价:" + Obj.format(oldprice, "#,##0.00"));
            if (price != null && oldprice != null && !oldprice.equals(price))
              title.append(" 现价:" + Obj.format(price, "#,##0.00"));
            if (balance != null && balance > 0)
              title.append(" 省:" + Obj.format(balance, "#,##0.00"));
            item.setTitle(title.toString());
          }
          row.addItem(item);
        }
      }
    }

    ctx.put("data", data);
    ctx.put("pager", parser.getPager());

    return ctx;
  }
示例#2
0
文件: Nodes.java 项目: kmetop/demsy
  private Node getNode(Serializable nodeID) {
    String key = Obj.toKey(nodeID);
    if (key.length() == 0) {
      return null;
    }

    Node node = nodeMap.get(key);

    if (node == null) {
      node = new Node(key);
      nodeMap.put(key, node);
    }

    return node;
  }
示例#3
0
文件: Nodes.java 项目: kmetop/demsy
 public boolean existNode(Serializable nodeID) {
   return nodeMap.get(Obj.toKey(nodeID)) != null;
 }