@SkipValidation @Action( value = "outputArticle", results = { @Result(name = "success", type = "tiles", location = "/output-article.tiles"), @Result(name = "error", type = "redirectAction", location = "articleList") }) public String execute() throws Exception { if (articleString == null) { return ERROR; } articleName = articleService.get(Long.parseLong(articleString)).getName(); m.put("articleName", outputArticle.getArticle().getName()); m.put("articleBarCode", outputArticle.getArticle().getBarCode()); if (outputArticle.getArticle().getSize() != null) m.put("articleSize", outputArticle.getArticle().getSize().getId()); else m.put("articleSize", -1l); if (outputArticle.getArticle().getColour() != null) m.put("articleCode", outputArticle.getArticle().getColour().getCode()); else m.put("articleCode", ""); if (outputArticle.getArticle().getLocation() != null) m.put("articleLocation", outputArticle.getArticle().getLocation().getId()); else m.put("articleLocation", -1l); 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(); } } }
@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; }