@Action( value = "doOutputArticle", results = { @Result(name = "error", type = "tiles", location = "/licence.tiles"), @Result(name = "success", type = "redirectAction", location = "articleListSession"), @Result(name = "input", type = "tiles", location = "/output-article.tiles") }) public String save() throws Exception { if (outputArticle != null && outputArticle.hashCode() != outputArticleHash) { boolean hasError = false; if (fromString.equals("")) { addFieldError("fromString", Messages.getString("fromSB")); hasError = true; } if (customerString.equals("")) { addFieldError("outputCustomer", Messages.getString("customer")); hasError = true; } if (hasError) return INPUT; outputArticle.setOutDate(new Date()); if (!articleString.equals("")) outArticle = articleService.get(Long.parseLong(articleString.trim())); if (!fromString.equals("")) outputArticle.setFrom(employeeService.get(Long.parseLong(fromString.trim()))); outputArticle.setCustomer(customerService.get(Long.parseLong(customerString))); outputArticle.setNumber( outputArticleService.getOutputArticleNumber(OutputArticleActivity.finish)); if (outArticle.getCount() < outputArticle.getOutCount()) { addFieldError("outCount", Messages.getString("notEnoughArticleResourse")); return INPUT; } outArticle.setCount(outArticle.getCount() - outputArticle.getOutCount()); outputArticle.setStatus(OutputArticleActivity.finish); outputArticle.setArticle(outArticle); articleService.saveOrUpdate(outArticle); outputArticleService.saveOrUpdate(outputArticle); return SUCCESS; } return INPUT; }
@SkipValidation @Action( value = "outList", results = { @Result(name = "success", type = "tiles", location = "/output-article-list.tiles") }) public String list() throws Exception { this.outputArticleList = outputArticleService.getOutputArticleFinish(); return SUCCESS; }
public void prepare() throws Exception { if (outputArticle != null && outputArticle.getId() != null) { articleString = outputArticle.getId().toString().trim(); this.outputArticle = outputArticleService.get(outputArticle.getId()); if (outArticle != null) { this.outputArticleHash = outputArticle.hashCode(); } else { outputArticle = new OutputArticle(articleService.get(Long.parseLong(articleString))); this.outputArticleHash = outputArticle.hashCode(); } } }