Ejemplo n.º 1
0
  /** 解析布局管理器表达式. */
  public void interpret() {
    if (StringUtils.isEmpty(getLayoutStr())) return;

    String[] layoutSplit = StringUtils.split(getLayoutStr(), EXPRESSION_SPLIT);
    if (StringUtils.isEmpty(layoutSplit)) return;

    interpertColumns(layoutSplit[0]);
    for (String str : layoutSplit) {
      if (StringUtils.isEmpty(str) || MatcherUtil.isNumber(str)) continue;

      interpertFormCell(str);
    }
  }
Ejemplo n.º 2
0
  /**
   * 构造每个bop的布局样式 R2(C2(bop1, bop2)) 或 R2(bop3, C2(bop1, bop2))
   * <li>1. 遍历表达式, 解析子元素;
   * <li>2. 遇到左括号,将R2, C2 表达式压入表达式栈顶;
   * <li>3. 遇到逗号, 如果栈不为空, 将栈中的所有表达式代表的含义赋予bop, 将bop压入cellMap; 如果栈为空, 直接略过;
   * <li>4. 遇到右括号, 将栈中的所有表达式代表的含义赋予bop, 将bop压入cellMap, 从表达式栈顶弹出一项.
   *
   * @param str
   */
  private void interpertFormCell(String str) {
    // 表达式栈, 存储 R1, C1, R2, C2等合并单元格的表达式
    Stack<String> stack = new Stack<String>();

    // 表达式的元素
    String atom = "";
    // 遍历表达式, 解析子元素
    for (int i = 0, length = str.length(); i < length; i++) {
      char ch = str.charAt(i);
      // 遇到左括号,将R2, C2 表达式压入表达式栈顶
      if (LEFT_BRACKET == ch) {
        stack.push(atom);
        atom = "";
      }
      // 遇到逗号, 如果栈不为空, 将栈中的所有表达式代表的含义赋予bop, 将bop压入cellMap;
      // 如果栈为空, 直接略过;
      else if (FC_SPLIT == ch) {
        if (ContainerUtil.isNotNull(stack)) formatCell(atom, stack);
        atom = "";
      }
      // 遇到右括号, 将栈中的所有表达式代表的含义赋予bop, 将bop压入cellMap, 从表达式栈顶弹出一项
      else if (RIGHT_BRACKET == ch) {
        if (StringUtils.isNotEmpty(atom)) formatCell(atom, stack);
        stack.pop();
        atom = "";
      } else {
        atom += ch;
      }
    }
  }
Ejemplo n.º 3
0
  @SuppressWarnings("unchecked")
  private ProjectModuleBO convertElementToModule(Element element) {
    ProjectModuleBO module = new ProjectModuleBO();
    module.setId(Long.parseLong(element.getAttributeValue(ATTR_ID)));
    module.setModuleName(element.getAttributeValue(ATTR_NAME));
    module.setRemark(element.getAttributeValue(ATTR_REMARK));

    Element developerElement = element.getChild(NODE_DEV);
    module.setDevelopers(developerElement.getAttributeValue(ATTR_ID));
    Element packageElement = element.getChild(NODE_PACKAGE);

    List<Element> packageChildren = packageElement.getChildren();
    for (Element packElement : packageChildren) {
      String packName = packElement.getAttributeValue(ATTR_NAME);
      if (StringUtils.isEqual(packElement.getName(), NODE_SRC)) module.setSrcPackage(packName);
      else if (StringUtils.isEqual(packElement.getName(), NODE_JSP)) module.setJspPackage(packName);
      else if (StringUtils.isEqual(packElement.getName(), NODE_HBM)) module.setHbmPackage(packName);
      else if (StringUtils.isEqual(packElement.getName(), NODE_SPRING))
        module.setSpringPackage(packName);
      else if (StringUtils.isEqual(packElement.getName(), NODE_PAGEFLOW))
        module.setPageflowPackage(packName);
      else if (StringUtils.isEqual(packElement.getName(), NODE_VAR)) module.setVarPackage(packName);
      else if (StringUtils.isEqual(packElement.getName(), NODE_I18N))
        module.setI18nPackage(packName);
    }
    return module;
  }
Ejemplo n.º 4
0
  @Override
  public BusinessComponent query(BOProperty sourceBop) throws Exception {
    if (sourceBop instanceof DeliveryModeBOP) {
      if (StringUtils.isEqual(ConstantsValue.VALUE_1.getValue(), sourceBop.getValue().getValue()))
        getStatus().setHidden(false);
      else getStatus().setHidden(true);
    }
    setValue(getConsoleText());

    return super.query(sourceBop);
  }
Ejemplo n.º 5
0
  @SuppressWarnings("unchecked")
  @Override
  public DemoMobileBaseBO findSaveInfo(
      long shopId, long vistorId, Class<? extends DemoMobileBaseBO> calsz) throws Exception {
    QewebDetachedCriteria detachedCriteria =
        (QewebDetachedCriteria) QewebDetachedCriteria.forClass(calsz);
    detachedCriteria.add(Restrictions.eq("submitFlag", StringUtils.convertToInt(SubmitBOP.NO)));
    detachedCriteria.add(Restrictions.eq(IBaseDao.FIELD_DELETEFLAG, IBaseDao.UNDELETE_SIGNE));
    detachedCriteria.add(Restrictions.eq("shopBO.id", shopId));
    detachedCriteria.add(Restrictions.eq("visitor.id", vistorId));

    List<DemoMobileBaseBO> result = findByCriteria(detachedCriteria);

    return ContainerUtil.isNull(result) ? calsz.newInstance() : result.get(0);
  }
Ejemplo n.º 6
0
  /**
   * @param sourceBCList
   * @return
   */
  @Override
  public BusinessComponent query(BOProperty sourceBop) {
    Map<String, String> streetMap = new LinkedHashMap<String, String>();
    EnumRange.addPlease(streetMap);
    if (StringUtils.isEqual(sourceBop.getValue().getValue(), "9905")) {
      streetMap.put("1", "街道1");
      streetMap.put("2", "街道2");
      streetMap.put("3", "街道3");
      streetMap.put("4", "街道4");
    }

    EnumRange streetRange = new EnumRange();
    streetRange.setResult(streetMap);
    BCRange bcRange = new BCRange();
    bcRange.addRange(streetRange);
    setRange(bcRange);
    return this;
  }
Ejemplo n.º 7
0
  /**
   * 变量影响表单中的细粒度组件的值、状态
   *
   * @param fcList
   * @param simpleContainer
   */
  public static final void var2FC(
      Map<String, FinegrainedComponent> fcList, SimpleContainer simpleContainer) {
    Map<String, SimpleFC> simpleFCList = simpleContainer.getFcList();
    if (ContainerUtil.isNull(simpleFCList) || ContainerUtil.isNull(fcList)) return;

    for (Entry<String, SimpleFC> entry : simpleFCList.entrySet()) {
      if (!fcList.containsKey(entry.getKey())) continue;
      BOProperty bop = fcList.get(entry.getKey()).getBc();
      if (bop == null) continue;

      if (entry.getValue().isDisable() != null)
        bop.getStatus().setDisable(entry.getValue().isDisable());
      if (entry.getValue().isHidden() != null)
        bop.getStatus().setHidden(entry.getValue().isHidden());
      if (entry.getValue().isReadonly() != null)
        bop.getStatus().setReadonly(entry.getValue().isReadonly());
      if (StringUtils.isNotEmpty(entry.getValue().getValueStr()))
        bop.setValue(entry.getValue().getValueStr());
    }
  }
Ejemplo n.º 8
0
  @SuppressWarnings("unchecked")
  @Override
  public void update(ProjectModuleBO module) {
    Element rootElement = getRootElement();
    if (rootElement == null) return;

    List<Element> elements = getElmentsByXpath(getXPath_ModuleId(module.getId()), rootElement);
    if (ContainerUtil.isNull(elements)) return;

    // 修改moduleElement节点
    Element moduleElement = elements.get(0);
    moduleElement.setAttribute(ATTR_NAME, module.getModuleName());
    moduleElement.setAttribute(ATTR_REMARK, module.getRemark());

    // 修改developers节点
    Element developElement = moduleElement.getChild(NODE_DEV);
    developElement.setAttribute(ATTR_ID, module.getDevelopers());

    // 修改package节点
    Element packageElement = moduleElement.getChild(NODE_PACKAGE);
    List<Element> childElements = packageElement.getChildren();
    for (Element packElement : childElements) {
      if (StringUtils.isEqual(NODE_SRC, packElement.getName()))
        packElement.setAttribute(ATTR_NAME, module.getSrcPackage());
      else if (StringUtils.isEqual(NODE_JSP, packElement.getName()))
        packElement.setAttribute(ATTR_NAME, module.getJspPackage());
      else if (StringUtils.isEqual(NODE_HBM, packElement.getName()))
        packElement.setAttribute(ATTR_NAME, module.getHbmPackage());
      else if (StringUtils.isEqual(NODE_SPRING, packElement.getName()))
        packElement.setAttribute(ATTR_NAME, module.getSpringPackage());
      else if (StringUtils.isEqual(NODE_PAGEFLOW, packElement.getName()))
        packElement.setAttribute(ATTR_NAME, module.getPageflowPackage());
      else if (StringUtils.isEqual(NODE_VAR, packElement.getName()))
        packElement.setAttribute(ATTR_NAME, module.getVarPackage());
      else if (StringUtils.isEqual(NODE_I18N, packElement.getName()))
        packElement.setAttribute(ATTR_NAME, module.getI18nPackage());
    }

    saveXML(rootElement);
  }
Ejemplo n.º 9
0
  @Override
  public List<ProjectModuleBO> findModules(BOTemplate bot) {
    Element rootElement = getRootElement();
    if (rootElement == null) return null;

    List<Element> moduleElements = getElmentsByXpath(getXPath_ModuleAll(), rootElement);
    if (ContainerUtil.isNull(moduleElements)) return null;

    List<ProjectModuleBO> modules = new LinkedList<ProjectModuleBO>();
    for (Element element : moduleElements) {
      ProjectModuleBO module = convertElementToModule(element);

      if (bot == null || ContainerUtil.isNull(bot.getBotMap())) {
        modules.add(module);
        continue;
      }

      // 判断查询结果是否符合查询条件
      boolean inQuery = true;
      // 模块名称
      if (StringUtils.isNotEmpty((String) bot.getBotMap().get("moduleName"))) {
        if (!StringUtils.hasSubString(
            module.getModuleName(), bot.getBotMap().get("moduleName").toString())) {
          inQuery = false;
        }
      }
      // 开发人员
      if (inQuery && StringUtils.isNotEmpty((String) bot.getBotMap().get("developers"))) {
        if (!StringUtils.hasSubString(
            module.getDevelopers(), bot.getBotMap().get("developers").toString())) {
          inQuery = false;
        }
      }
      // 模块ID
      if (inQuery && StringUtils.isNotEmpty((String) bot.getBotMap().get("id"))) {
        if (!StringUtils.isEqual(module.getId() + "", bot.getBotMap().get("id").toString())) {
          inQuery = false;
        }
      }
      if (inQuery) modules.add(module);
    }

    return modules;
  }
Ejemplo n.º 10
0
 /**
  * 解析默认列数
  *
  * @param str 布局管理器划分的总列数
  */
 private void interpertColumns(String str) {
   Integer columns = StringUtils.convertToInteger(str);
   if (columns != null && columns > 0) setColumns(columns);
 }
Ejemplo n.º 11
0
 /**
  * @param layoutStr 布局管理器表达式
  * @param defColumns 默认列数
  */
 public Interpreter(String layoutStr, int defColumns) {
   this.layoutStr = StringUtils.removeAllSpace(layoutStr);
   this.columns = defColumns;
 }