Monday, June 4, 2018

Not to update in query mode then override isAttributeUpdateable at VORowImpl class

ex:2

    public void setNewRowState(byte b) {
        //super.setNewRowState(b);
        if (b != Row.STATUS_INITIALIZED || getNewRowState() != Row.STATUS_NEW) {
         super.setNewRowState(b);
         }
    }
   
    protected boolean hasEntities() {
        return getEntity(0) != null;
      }
      /*
       * By convention, we'll say that the state of this VO row
       * is the state of its first entity object.
       *
       * Only makes sense to call this if VO row has entities
       */
      protected byte getViewRowStatus() {
        return getEntity(0).getPostState();
      }

    public boolean isAttributeUpdateable(int i) {
        Boolean update = super.isAttributeUpdateable(i);
       // System.out.println(" hasentiies "+hasEntities());
           
        if (hasEntities()) {
            byte status = getViewRowStatus();
            //System.out.println("status "+ status);
            //System.out.println(Entity.STATUS_NEW +" Entity.STATUS_MODIFIED "+Entity.STATUS_MODIFIED+" "+Entity.STATUS_UNMODIFIED);
            switch (status) {
             case Entity.STATUS_UNMODIFIED:
             case Entity.STATUS_MODIFIED:
                {
                    //System.out.println("inside status modified");
                    if (this.getTransApproved() != null || this.getTransApproved().equals("Y")) {
                        if (i == this.findAttrAndGetIndex("ValidToDt")) {
                            // System.out.println(i+" this.findAttrAndGetIndex(\"ValidToDt\") "+this.findAttrAndGetIndex("ValidToDt"));
                            return update;
                        }
                        return false;

                    }else break;
                }
             // 
                // return super.isAttributeUpdateable(i);
            }
        }
        return update;
    }

==================
ex:1
    public boolean isAttributeUpdateable(int i) {
        Boolean update = super.isAttributeUpdateable(i);
       // System.out.println(" hasentiies "+hasEntities());
         
        if (hasEntities()) {
            byte status = getViewRowStatus();
            //System.out.println("status "+ status);
            //System.out.println(Entity.STATUS_NEW +" Entity.STATUS_MODIFIED "+Entity.STATUS_MODIFIED+" "+Entity.STATUS_UNMODIFIED);
            switch (status) {
             case Entity.STATUS_UNMODIFIED:
             case Entity.STATUS_MODIFIED:
                {
                    //System.out.println("inside status modified");
                    if (this.getTransApproved() != null || this.getTransApproved().equals("Y")) {
                        if (i == this.findAttrAndGetIndex("ValidToDt")) {
                            // System.out.println(i+" this.findAttrAndGetIndex(\"ValidToDt\") "+this.findAttrAndGetIndex("ValidToDt"));
                            return update;
                        }
                        return false;

                    }else break;
                }
             // 
                // return super.isAttributeUpdateable(i);
            }
        }
        return update;
    }
==============



ex:2
public boolean isAttributeUpdateable(int i) {
        Boolean update = super.isAttributeUpdateable(i);
        if (this.getTransApproved()!=null || this.getTransApproved().equals("Y")){
            if ( i==this.findAttrAndGetIndex("ValidToDt")){
               // System.out.println(i+" this.findAttrAndGetIndex(\"ValidToDt\") "+this.findAttrAndGetIndex("ValidToDt"));
                        return update;
            }
            return false;
         
        }
       return update;
       // return super.isAttributeUpdateable(i);
    }

No comments:

Post a Comment