LotStepHistoryCommentAction.java
package com.mycim.webapp.actions.lot.lotstephistorycomment;
import com.fa.sesa.exception.Assert;
import com.fa.sesa.exception.Errors;
import com.fa.sesa.threadlocal.LocalContext;
import com.mycim.framework.utils.lang.StringUtils;
import com.mycim.webapp.WebUtils;
import com.mycim.webapp.actions.WipSetupAction;
import com.mycim.webapp.forms.LotStepHistoryCommentForm;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.math.NumberUtils;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class LotStepHistoryCommentAction extends WipSetupAction {
// --------------------------------------------------------- Public Methods
@Override
public ActionForward init(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws ServletException {
LotStepHistoryCommentForm theform = (LotStepHistoryCommentForm) form;
theform.setLotStepCommentType("");
theform.setComment("");
String lotRrn = request.getParameter("lotRrn");
String stepSequence = request.getParameter("stepSequence");
int pageNo = WebUtils.getParameterInt("pageNo", request);
int pageSize = WebUtils.getParameterInt("pageSize", request);
String from = request.getParameter("from");
if (from != null) {
theform.setFrom(from);
}
Map condition = new HashMap();
condition.put("lotRrn", lotRrn);
condition.put("stepSequence", stepSequence);
List comments = (List) lotQueryService
.qryLotStepHistoryComment(NumberUtils.toLong(lotRrn), NumberUtils.toLong(stepSequence), pageNo,
pageSize);
theform.setLotRrn(lotRrn);
theform.setStepSequence(stepSequence);
theform.setReason(StringUtils.EMPTY);
// theform.setComments(comments);
request.setAttribute("comments", comments);
if (comments != null && comments.size() > 0) {
request.setAttribute("totalCount", MapUtils.getIntValue((Map) comments.get(0), "totalCount"));
} else {
request.setAttribute("totalCount", -1);
}
request.setAttribute("pageNo", pageNo);
return (mapping.findForward("view"));
}
public ActionForward create(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws ServletException {
LotStepHistoryCommentForm theform = (LotStepHistoryCommentForm) form;
theform.setLotStepCommentType("");
theform.setComment("");
String lotRrn = request.getParameter("lotRrn");
String stepSequence = request.getParameter("stepSequence");
int pageNo = WebUtils.getParameterInt("pageNo", request);
int pageSize = WebUtils.getParameterInt("pageSize", request);
String from = request.getParameter("from");
if (from != null) {
theform.setFrom(from);
}
Map condition = new HashMap();
condition.put("lotRrn", lotRrn);
condition.put("stepSequence", stepSequence);
String inputReason = theform.getReason();
Assert.isFalse(StringUtils.isBlank(inputReason), Errors.create().content("Comment cannot be null.").build());
String comment = theform.getReason();
String commentType = request.getParameter("lotStepCommentType");
lotService.addLotStepHistoryComment(lotRrn, stepSequence, comment, commentType, LocalContext.getUserId(),
LocalContext.getFacilityRrn());
List comments = (List) lotQueryService
.qryLotStepHistoryComment(NumberUtils.toLong(lotRrn), NumberUtils.toLong(stepSequence), pageNo,
pageSize);
theform.setLotRrn(lotRrn);
theform.setStepSequence(stepSequence);
theform.setReason(StringUtils.EMPTY);
request.setAttribute("comments", comments);
if (comments != null && comments.size() > 0) {
request.setAttribute("totalCount", MapUtils.getIntValue((Map) comments.get(0), "totalCount"));
} else {
request.setAttribute("totalCount", -1);
}
request.setAttribute("pageNo", pageNo);
return (mapping.findForward("view"));
}
}
/*
* Modification Log Log No : Name : Modified Date: Description :
*/