Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package org.jleaf.erp.fin.web.controller.pointernalsoigstagging;
- import java.io.Serializable;
- import java.util.Arrays;
- import javax.annotation.PostConstruct;
- import javax.faces.event.AjaxBehaviorEvent;
- import org.jleaf.baseweb.controller.LoginController;
- import org.jleaf.core.GeneralConstants;
- import org.jleaf.erp.fin.api.FinanceApiForIndocom;
- import org.jleaf.erp.fin.web.controller.model.PoInternalSoIgsTaggingLazyModel;
- import org.jleaf.util.DateUtil;
- import org.jleaf.web.helper.MessageHelper;
- import org.jleaf.web.jsf.FacesUtils;
- import org.jleaf.web.jsf.template.AbstractBrowseController;
- import org.jleaf.web.jsf.template.BasicController;
- import org.jleaf.web.jsf.util.JSONObjectUtil;
- import org.jleaf.web.model.ComboItem;
- import org.jleaf.web.model.Rules;
- import org.jleaf.web.util.Validator;
- import org.json.simple.JSONObject;
- import org.primefaces.context.RequestContext;
- import org.slf4j.Logger;
- import org.slf4j.LoggerFactory;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.context.ApplicationContext;
- import org.springframework.context.annotation.Scope;
- import org.springframework.stereotype.Controller;
- /**
- *
- * @author Adrian
- * Feb 23, 2017
- */
- @SuppressWarnings("serial")
- @Controller
- @Scope("view")
- public class PoInternalSoIgsTaggingController extends AbstractBrowseController implements FinanceApiForIndocom, Serializable {
- private static final Logger log = LoggerFactory.getLogger(PoInternalSoIgsTaggingController.class);
- private PoInternalSoIgsTaggingLazyModel model;
- @Autowired
- ApplicationContext applicationContext;
- @SuppressWarnings("unchecked")
- @PostConstruct
- private void init() {
- }
- @SuppressWarnings({ "unchecked", "deprecation" })
- public void doSearch() {
- JSONObject inputJson = new JSONObject();
- inputJson.put("poInternalNo", this.filterBean.getData().get("poInternalNo"));
- inputJson.put("poNo", this.filterBean.getData().get("poNo"));
- inputJson.put("soNo", this.filterBean.getData().get("soNo"));
- log.debug("input Json: " + inputJson);
- try {
- JSONObject output = serviceContext.executeService(
- COUNT_PO_INTERNAL_SO_IGS_TAGGING_LIST_ADVANCE, inputJson);
- log.debug("output_service:" + output);
- JSONObject result = JSONObjectUtil.getResult(output);
- log.debug("output_result:" + result);
- String status = JSONObjectUtil.getResultStatus(output);
- if (status != null && status.equals(GeneralConstants.OK)) {
- log.debug("output_OK:");
- Long rowCount = Long.valueOf(result.get("count").toString());
- model = new PoInternalSoIgsTaggingLazyModel(serviceContext, inputJson);
- model.setRowCount(rowCount.intValue());
- model.setPageSize(25);
- FacesUtils.addInfoMessage("Data Has Been Loaded");
- } else if (status != null && status.equals(GeneralConstants.FAIL)) {
- MessageHelper.displayError(result);
- }
- } catch (Exception ex) {
- ex.printStackTrace();
- FacesUtils.addErrorMessage(ex.getMessage());
- }
- }
- @SuppressWarnings("unchecked")
- public void initAdd() {
- log.debug(">>>>>> INIT ADD");
- }
- @SuppressWarnings("unchecked")
- public void initEdit(JSONObject poInternalSoIgsTagging) {
- setSelected((JSONObject) poInternalSoIgsTagging.clone());
- ComboItem poInternalOuCombo = new ComboItem("id", getSelected().get("poInternalOuId"));
- ComboItem soOuCombo = new ComboItem("id", getSelected().get("soOuId"));
- ComboItem poInternalCombo = new ComboItem("id", getSelected().get("poInternalId"));
- poInternalCombo.put("docNo", getSelected().get("poInternalNo"));
- ComboItem soCombo = new ComboItem("id", getSelected().get("soId"));
- soCombo.put("docNo", getSelected().get("soNo"));
- getSelected().put("poInternalOu", poInternalOuCombo);
- getSelected().put("soOu", soOuCombo);
- getSelected().put("poInternal", poInternalCombo);
- getSelected().put("so", soCombo);
- }
- @SuppressWarnings("unchecked")
- public void initRemove(JSONObject poInternalSoIgsTagging) {
- setSelected((JSONObject) poInternalSoIgsTagging.clone());
- }
- @SuppressWarnings("unchecked")
- public void addItem(){
- log.debug(">>>>>>>>> ADD ITEM");
- /*if (null == getSelected().get("poInternalOu")) {
- MessageHelper.displayError("org.jleaf.erp.fin.web.pleaseSelectPoInternalOU");
- return;
- }
- if (null == getSelected().get("soOu")) {
- MessageHelper.displayError("org.jleaf.erp.fin.web.pleaseSelectSoOU");
- return;
- }*/
- if (null == getSelected().get("poInternal")) {
- MessageHelper.displayError("org.jleaf.erp.fin.web.pleaseSelectPoInternal");
- return;
- }
- if (null == getSelected().get("so")) {
- MessageHelper.displayError("org.jleaf.erp.fin.web.pleaseSelectSo");
- return;
- }
- /*JSONObject poInternalOu = (JSONObject) getSelected().get("poInternalOu");
- Long poInternalOuId = Long.valueOf(poInternalOu.get("id").toString());
- JSONObject soOu = (JSONObject) getSelected().get("soOu");
- Long soOuId = Long.valueOf(soOu.get("id").toString());*/
- JSONObject poInternal = (JSONObject) getSelected().get("poInternal");
- Long poInternalOuId = Long.valueOf(poInternal.get("ouId").toString());
- Long poInternalId = Long.valueOf(poInternal.get("id").toString());
- JSONObject so = (JSONObject) getSelected().get("so");
- Long soOuId = Long.valueOf(so.get("ouId").toString());
- Long soId = Long.valueOf(so.get("id").toString());
- /*if (GeneralConstants.NULL_REF_VALUE_LONG.equals(poInternalId)) {
- MessageHelper.displayError("org.jleaf.erp.fin.web.pleaseSelectPoInternal");
- return;
- }
- if (GeneralConstants.NULL_REF_VALUE_LONG.equals(soId)) {
- MessageHelper.displayError("org.jleaf.erp.fin.web.pleaseSelectSo");
- return;
- }*/
- JSONObject input = new JSONObject();
- input.put("poInternalOuId", poInternalOuId);
- input.put("poInternalId", poInternalId);
- input.put("soOuId", soOuId);
- input.put("soId", soId);
- log.debug(">>>>>>>>> INPUT DTO FOR ADD ITEM = "+input);
- try {
- JSONObject output = serviceContext.executeService(
- ADD_PO_INTERNAL_SO_IGS_TAGGING, input);
- JSONObject result = JSONObjectUtil.getResult(output);
- String status = JSONObjectUtil.getResultStatus(output);
- log.debug("statusnya" + result);
- if (status != null && status.equals(GeneralConstants.OK)) {
- MessageHelper.displayEditSuccess();
- RequestContext.getCurrentInstance().addCallbackParam("success", true);
- } else if (status != null && status.equals(GeneralConstants.FAIL)) {
- MessageHelper.displayError(result);
- RequestContext.getCurrentInstance().addCallbackParam("success", false);
- }
- } catch (Exception ex) {
- ex.printStackTrace();
- FacesUtils.addErrorMessage(ex.getMessage());
- }
- }
- @SuppressWarnings("unchecked")
- public void editItem(){
- if (null == getSelected().get("poInternalOu")) {
- MessageHelper.displayError("org.jleaf.erp.fin.web.pleaseSelectPoInternalOU");
- return;
- }
- if (null == getSelected().get("soOu")) {
- MessageHelper.displayError("org.jleaf.erp.fin.web.pleaseSelectSoOU");
- return;
- }
- if (null == getSelected().get("poInternal")) {
- MessageHelper.displayError("org.jleaf.erp.fin.web.pleaseSelectPoInternal");
- return;
- }
- if (null == getSelected().get("so")) {
- MessageHelper.displayError("org.jleaf.erp.fin.web.pleaseSelectSo");
- return;
- }
- JSONObject poInternalOu = (JSONObject) getSelected().get("poInternalOu");
- Long poInternalOuId = Long.valueOf(poInternalOu.get("id").toString());
- JSONObject soOu = (JSONObject) getSelected().get("soOu");
- Long soOuId = Long.valueOf(soOu.get("id").toString());
- JSONObject poInternal = (JSONObject) getSelected().get("poInternal");
- Long poInternalId = Long.valueOf(poInternal.get("id").toString());
- JSONObject so = (JSONObject) getSelected().get("so");
- Long soId = Long.valueOf(so.get("id").toString());
- if (GeneralConstants.NULL_REF_VALUE_LONG.equals(poInternalId)) {
- MessageHelper.displayError("org.jleaf.erp.fin.web.pleaseSelectPoInternal");
- return;
- }
- if (GeneralConstants.NULL_REF_VALUE_LONG.equals(soId)) {
- MessageHelper.displayError("org.jleaf.erp.fin.web.pleaseSelectSo");
- return;
- }
- JSONObject input = new JSONObject();
- input.put("id", getSelected().get("id"));
- input.put("version", getSelected().get("version"));
- input.put("poInternalOuId", poInternalOuId);
- input.put("poInternalId", poInternalId);
- input.put("soOuId", soOuId);
- input.put("soId", soId);
- try {
- JSONObject output = serviceContext.executeService(
- EDIT_PO_INTERNAL_SO_IGS_TAGGING, input);
- JSONObject result = JSONObjectUtil.getResult(output);
- String status = JSONObjectUtil.getResultStatus(output);
- log.debug("statusnya" + result);
- if (status != null && status.equals(GeneralConstants.OK)) {
- MessageHelper.displayEditSuccess();
- RequestContext.getCurrentInstance().addCallbackParam("success", true);
- } else if (status != null && status.equals(GeneralConstants.FAIL)) {
- MessageHelper.displayError(result);
- RequestContext.getCurrentInstance().addCallbackParam("success", false);
- }
- } catch (Exception ex) {
- ex.printStackTrace();
- FacesUtils.addErrorMessage(ex.getMessage());
- }
- }
- @SuppressWarnings("unchecked")
- public void removeItem(){
- JSONObject input = new JSONObject();
- input.put("id", getSelected().get("id"));
- input.put("version", getSelected().get("version"));
- try {
- JSONObject output = serviceContext.executeService(
- REMOVE_PO_INTERNAL_SO_IGS_TAGGING, input);
- JSONObject result = JSONObjectUtil.getResult(output);
- String status = JSONObjectUtil.getResultStatus(output);
- log.debug("statusnya" + result);
- if (status != null && status.equals(GeneralConstants.OK)) {
- MessageHelper.displayEditSuccess();
- RequestContext.getCurrentInstance().addCallbackParam("success", true);
- } else if (status != null && status.equals(GeneralConstants.FAIL)) {
- MessageHelper.displayError(result);
- RequestContext.getCurrentInstance().addCallbackParam("success", false);
- }
- } catch (Exception ex) {
- ex.printStackTrace();
- FacesUtils.addErrorMessage(ex.getMessage());
- }
- }
- @SuppressWarnings("unchecked")
- public void onFilterChanged(AjaxBehaviorEvent event) {
- log.debug(">>>>>>>>>>>> FILTER CHANGED ");
- /*JSONObject poInternalOu = (JSONObject) getSelected().get("poInternalOu");
- Long poInternalOuId = Long.valueOf(poInternalOu.get("id").toString());
- JSONObject soOu = (JSONObject) getSelected().get("soOu");
- Long soOuId = Long.valueOf(soOu.get("id").toString());
- log.debug(">>>>>>>>>>>>>> poInternalOuId = " +poInternalOuId);
- log.debug(">>>>>>>>>>>>>> soOuId = " +soOuId);*/
- }
- @Override
- public String searchTaskName() {
- // TODO Auto-generated method stub
- return null;
- }
- @Override
- public JSONObject getJsonForSearch() {
- // TODO Auto-generated method stub
- return null;
- }
- @Override
- public void afterSearch(JSONObject result, boolean isOk) {
- // TODO Auto-generated method stub
- }
- public PoInternalSoIgsTaggingLazyModel getModel() {
- return model;
- }
- public void setModel(PoInternalSoIgsTaggingLazyModel model) {
- this.model = model;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement