@Override
  public final CustOrder process(final Map<String, Object> pRqVs,
    final CustOrder pEntity, final IRequestData pRqDt) throws Exception {
    String act = pRqDt.getParameter("act");
    if (!("cnc".equals(act) || "pyd".equals(act) || "cls".equals(act))) {
      throw new ExceptionWithCode(ExceptionWithCode.FORBIDDEN,
        "Wrong action CO! " + act);
    }
    CustOrder oco = null;
    if (pEntity.getIsNew()) {
      throw new ExceptionWithCode(ExceptionWithCode.FORBIDDEN,
        "Attempt creating CO!");
    } else {
      oco = this.srvOrm.retrieveEntityById(pRqVs, CustOrder.class,
        pEntity.getItsId());
      if (oco.getInId() != null) {
        throw new Exception("NEY CU with INV");
      }
      oco.setDescr(pEntity.getDescr());
      boolean isNdUp = true;
      if ("cnc".equals(act)) {
        if (!(oco.getStat().equals(EOrdStat.BOOKED)
          || oco.getStat().equals(EOrdStat.PAYED)
            || oco.getStat().equals(EOrdStat.CLOSED))) {
          throw new ExceptionWithCode(ExceptionWithCode.FORBIDDEN,
            "Wrong action CO for status ! " + act + "/" + oco.getStat());
        }
        this.cncOrd.cancel(pRqVs, oco, EOrdStat.CANCELED);
        isNdUp = false;
      } else if ("pyd".equals(act)) {
        if (!oco.getStat().equals(EOrdStat.BOOKED)) {
          throw new ExceptionWithCode(ExceptionWithCode.FORBIDDEN,
            "Wrong action CO for status ! " + act + "/" + oco.getStat());
        }
        oco.setStat(EOrdStat.PAYED);
      } else if ("cls".equals(act)) {
        if (!(oco.getStat().equals(EOrdStat.BOOKED)
          || oco.getStat().equals(EOrdStat.PAYED))) {
          throw new ExceptionWithCode(ExceptionWithCode.FORBIDDEN,
            "Wrong action CO for status ! " + act + "/" + oco.getStat());
        }
        oco.setStat(EOrdStat.CLOSED);
      }
      if (isNdUp) {
        String[] fieldsNames =
          new String[] {"itsId", "itsVersion", "stat", "descr"};
        pRqVs.put("fieldsNames", fieldsNames);
        this.srvOrm.updateEntity(pRqVs, oco);
        pRqVs.remove("fieldsNames");
      }
    }
    return oco;
  }
@ Override public final CustOrder process ( final Map < String , Object > pRqVs , final CustOrder pEntity , final IRequestData pRqDt ) throws Exception { String act = pRqDt . getParameter ( "act" ) ; if ( ! ( "cnc" . equals ( act ) || "pyd" . equals ( act ) || "cls" . equals ( act ) ) ) { throw new ExceptionWithCode ( ExceptionWithCode . FORBIDDEN , "Wrong action CO! " + act ) ; } CustOrder oco = null ; if ( pEntity . getIsNew ( ) ) { throw new ExceptionWithCode ( ExceptionWithCode . FORBIDDEN , "Attempt creating CO!" ) ; } else { oco = this . srvOrm . retrieveEntityById ( pRqVs , CustOrder . class , pEntity . getItsId ( ) ) ; if ( oco . getInId ( ) != null ) { throw new Exception ( "NEY CU with INV" ) ; } oco . setDescr ( pEntity . getDescr ( ) ) ; boolean isNdUp = true ; if ( "cnc" . equals ( act ) ) { if ( ! ( oco . getStat ( ) . equals ( EOrdStat . BOOKED ) || oco . getStat ( ) . equals ( EOrdStat . PAYED ) || oco . getStat ( ) . equals ( EOrdStat . CLOSED ) ) ) { throw new ExceptionWithCode ( ExceptionWithCode . FORBIDDEN , "Wrong action CO for status ! " + act + "/" + oco . getStat ( ) ) ; } this . cncOrd . cancel ( pRqVs , oco , EOrdStat . CANCELED ) ; isNdUp = false ; } else if ( "pyd" . equals ( act ) ) { if ( ! oco . getStat ( ) . equals ( EOrdStat . BOOKED ) ) { throw new ExceptionWithCode ( ExceptionWithCode . FORBIDDEN , "Wrong action CO for status ! " + act + "/" + oco . getStat ( ) ) ; } oco . setStat ( EOrdStat . PAYED ) ; } else if ( "cls" . equals ( act ) ) { if ( ! ( oco . getStat ( ) . equals ( EOrdStat . BOOKED ) || oco . getStat ( ) . equals ( EOrdStat . PAYED ) ) ) { throw new ExceptionWithCode ( ExceptionWithCode . FORBIDDEN , "Wrong action CO for status ! " + act + "/" + oco . getStat ( ) ) ; } oco . setStat ( EOrdStat . CLOSED ) ; } if ( isNdUp ) { String [ ] fieldsNames = new String [ ] { "itsId" , "itsVersion" , "stat" , "descr" } ; pRqVs . put ( "fieldsNames" , fieldsNames ) ; this . srvOrm . updateEntity ( pRqVs , oco ) ; pRqVs . remove ( "fieldsNames" ) ; } } return oco ; }
<p>Process entity request.</p>
@param pRqVs additional param, e.g. return this line's
document in "nextEntity" for farther process
@param pRqDt Request Data
@param pEntity Entity to process
@return Entity processed for farther process or null
@throws Exception - an exception