Examples of CodeScript


Examples of org.beangle.ems.dictionary.model.CodeScript

   */
  @SuppressWarnings("unchecked")
  public String gen(CodeFixture fixture) {
    // 在必要时查找相应的生成脚本
    String script = fixture.getScript();
    CodeScript codeScript = null;
    if (null == script) {
      codeScript = getCodeScript(EntityUtils.getEntityClassName(fixture.getEntity().getClass()));
      if (null == codeScript) { return null; }
      script = codeScript.getScript();
      try {
        String code = (String) PropertyUtils.getProperty(fixture.getEntity(), codeScript.getAttr());
        if (isValidCode(code)) { return code; }
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    int seqLength = -1;
    // 替换自动代码生成中的seq[x]
    if (StringUtils.contains(script, SEQ)) {
      seqLength = NumberUtils.toInt(StringUtils.substringBetween(script, SEQ + "[", "]"));

      script = StringUtils.replace(script,
          SEQ + "[" + StringUtils.substringBetween(script, SEQ + "[", "]") + "]", SEQ);
    }
    fixture.setScript(script);
    String code = super.gen(fixture);
    List<String> seqs = CollectUtils.newArrayList();
    if (-1 != seqLength) {
      try {
        OqlBuilder<?> builder = OqlBuilder.from(Class.forName(codeScript.getCodeClassName()),
            "entity");
        builder.select("select substr(entity." + codeScript.getAttr() + "," + (code.indexOf(SEQ) + 1)
            + "," + seqLength + ")");
        builder.where(" entity." + codeScript.getAttr() + " like :codeExample",
            StringUtils.replace(code, SEQ, "%"));
        builder.where("length(entity." + codeScript.getAttr() + ")="
            + (code.length() - SEQ.length() + seqLength));
        seqs = (List<String>) entityDao.search(builder);
        Collections.sort(seqs);
      } catch (Exception e) {
        throw new RuntimeException(e);
View Full Code Here

Examples of org.beangle.ems.dictionary.model.CodeScript

   * @param response
   * @return @
   */
  public String edit() {
    Long codeScriptId = getLong("codeScriptId");
    CodeScript codeScript = null;
    if (null == codeScriptId) {
      codeScript = (CodeScript) populate(CodeScript.class, "codeScript");
    } else {
      codeScript = (CodeScript) entityDao.get(CodeScript.class, codeScriptId);
    }
View Full Code Here

Examples of org.beangle.ems.dictionary.model.CodeScript

   * @param response
   * @return @
   */
  public String info() {
    Long codeScriptId = getLong("codeScriptId");
    CodeScript codeScript = (CodeScript) entityDao.get(CodeScript.class, codeScriptId);
    put("codeScript", codeScript);
    return forward();
  }
View Full Code Here

Examples of org.beangle.ems.dictionary.model.CodeScript

   * @param response
   * @return @
   */
  public String save() {
    Long codeScriptId = getLong("codeScript.id");
    CodeScript codeScript = null;
    if (null == codeScriptId) {
      codeScript = new CodeScript();
      codeScript.setCreatedAt(new Date(System.currentTimeMillis()));
    } else {
      codeScript = (CodeScript) entityDao.get(CodeScript.class, codeScriptId);
    }
    codeScript.setUpdatedAt(new Date(System.currentTimeMillis()));
    Model.populate(Params.sub("codeScript"), codeScript);
    entityDao.saveOrUpdate(codeScript);
    return redirect("search", "info.save.success");
  }
View Full Code Here

Examples of org.beangle.ems.dictionary.model.CodeScript

   */
  @SuppressWarnings("unchecked")
  public String gen(CodeFixture fixture) {
    // 在必要时查找相应的生成脚本
    String script = fixture.getScript();
    CodeScript codeScript = null;
    if (null == script) {
      codeScript = getCodeScript(EntityUtils.getEntityClassName(fixture.getEntity().getClass()));
      if (null == codeScript) { return null; }
      script = codeScript.getScript();
      try {
        String code = (String) PropertyUtils.getProperty(fixture.getEntity(), codeScript.getAttr());
        if (isValidCode(code)) { return code; }
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    int seqLength = -1;
    // 替换自动代码生成中的seq[x]
    if (StringUtils.contains(script, SEQ)) {
      seqLength = NumberUtils.toInt(StringUtils.substringBetween(script, SEQ + "[", "]"));

      script = StringUtils.replace(script,
          SEQ + "[" + StringUtils.substringBetween(script, SEQ + "[", "]") + "]", SEQ);
    }
    fixture.setScript(script);
    String code = super.gen(fixture);
    List<String> seqs = CollectUtils.newArrayList();
    if (-1 != seqLength) {
      try {
        OqlBuilder<?> builder = OqlBuilder.from(Class.forName(codeScript.getCodeClassName()),
            "entity");
        builder.select("select substr(entity." + codeScript.getAttr() + "," + (code.indexOf(SEQ) + 1)
            + "," + seqLength + ")");
        builder.where(" entity." + codeScript.getAttr() + " like :codeExample",
            StringUtils.replace(code, SEQ, "%"));
        builder.where("length(entity." + codeScript.getAttr() + ")="
            + (code.length() - SEQ.length() + seqLength));
        seqs = (List<String>) entityDao.search(builder);
        Collections.sort(seqs);
      } catch (Exception e) {
        throw new RuntimeException(e);
View Full Code Here

Examples of org.beangle.ems.dictionary.model.CodeScript

   * @param response
   * @return @
   */
  public String edit() {
    Long codeScriptId = getLong("codeScriptId");
    CodeScript codeScript = null;
    if (null == codeScriptId) {
      codeScript = (CodeScript) populate(CodeScript.class, "codeScript");
    } else {
      codeScript = (CodeScript) entityDao.get(CodeScript.class, codeScriptId);
    }
View Full Code Here

Examples of org.beangle.ems.dictionary.model.CodeScript

   * @param response
   * @return @
   */
  public String info() {
    Long codeScriptId = getLong("codeScriptId");
    CodeScript codeScript = (CodeScript) entityDao.get(CodeScript.class, codeScriptId);
    put("codeScript", codeScript);
    return forward();
  }
View Full Code Here

Examples of org.beangle.ems.dictionary.model.CodeScript

   * @param response
   * @return @
   */
  public String save() {
    Long codeScriptId = getLong("codeScript.id");
    CodeScript codeScript = null;
    if (null == codeScriptId) {
      codeScript = new CodeScript();
      codeScript.setCreatedAt(new Date(System.currentTimeMillis()));
    } else {
      codeScript = (CodeScript) entityDao.get(CodeScript.class, codeScriptId);
    }
    codeScript.setUpdatedAt(new Date(System.currentTimeMillis()));
    Model.populate(Params.sub("codeScript"), codeScript);
    entityDao.saveOrUpdate(codeScript);
    return redirect("search", "info.save.success");
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.