ModelValidator

Help is preferred to those who publish their work as Open Source and not as private branches rejecting collaboration. Such projects are not maintainable and shall be deleted.
Forum rules
This forum is personally pruned to avoid redundant posts. Related topics are grouped together. IF YOU HAVE REGISTERED, you need to send email to red1(a)red1.org with your username in the subject title to get me to activate you.

ModelValidator

Postby edilsondneto » Sat Sep 24, 2011 5:40 am

Dears Brothers,

I'm super happy to have the support of all in solving the problems once again need your help to solve a simple problem.

Mdaf created the model to be used in a validator called ValidatorDaf. That presenter problem below, I am sending herewith the validadorDaf.
I'm going to finish this validator to implement, only implement the methods required.

Someone could tell me what I missed or forgotten?


The problem below was shown on screen log after I log the validation of models, after reboot.

===========> Login.validateLogin: Refused: nulljava.lang.ClassNotFoundException: org.adempierelbr.validator.ValidatorDaf global
[11]
-------------------------------
-----------> MIssue.set_ValueNoCheck: ReleaseNo - Value too long - truncated to length = 4 [11]
-----------> Msg.getMsg: NOT found: nulljava.lang.ClassNotFoundException: org.adempierelbr.validator.ValidatorDaf global
[11]


Class Validator:

Code: Select all
/******************************************************************************
* Product: ADempiereLCR - ADempiere Brazil LCR                      *
* This program is free software; you can redistribute it and/or modify it    *
* under the terms version 2 of the GNU General Public License as published   *
* by the Free Software Foundation. This program is distributed in the hope   *
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.           *
* See the GNU General Public License for more details.                       *
* You should have received a copy of the GNU General Public License along    *
* with this program; if not, write to the Free Software Foundation, Inc.,    *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.                     *
*****************************************************************************/
package org.adempierelbr.validator;


import org.compiere.model.MClient;
import org.compiere.model.ModelValidationEngine;
import org.compiere.model.ModelValidator;
import org.compiere.model.PO;
import org.compiere.util.CLogger;
import org.lcr.model.MDaf;


/**
*   Validatordaf .'.
*
*  If the document type has both Automatic Shipment and Invoice checked, it
*  will then validate the Shipment Document, verifying if the latter has the
*  Shipment Confirmation checked, if it does, and error is generated.
*
*   
*
*   @author Edilson Duarte Neto .'.
*   @version $Id: ValidatorDaf.java, 23/09/2011 08:44:00 Edilson Duarte Neto .'.
*
*/
public class ValidatorDaf implements ModelValidator
{


   /**
    *   Constructor.
    *   The class is instanciated when logging in and client is selected/known
    */
   public ValidatorDaf()
   {
      super ();
   }

   /**   Logger         */
   private static CLogger log = CLogger.getCLogger(ValidatorDaf.class);
   /** Client         */
   private int      m_AD_Client_ID = -1;

   /**
    *   Initialize Validation
    *   @param engine validation engine
    *   @param client client
    */
   public void initialize (ModelValidationEngine engine, MClient client)
   {
      //client = null for global validator
      if (client != null) {
         m_AD_Client_ID = client.getAD_Client_ID();
         log.info(client.toString());
      }
      else  {
         log.info("Initializing global validator: "+this.toString());
      }

      engine.addModelChange(MDaf.Table_Name, this); // Model Type
       engine.addDocValidate(MDaf.Table_Name, this); // Document Type

   
      
   }   //   initialize

   /**
    *   Get Client to be monitored
    *   @return AD_Client_ID client
    */
   public int getAD_Client_ID()
   {
      return m_AD_Client_ID;
   }   //   getAD_Client_ID

   /**
    *   User Login.
    *   Called when preferences are set
    *   @param AD_Org_ID org
    *   @param AD_Role_ID role
    *   @param AD_User_ID user
    *   @return error message or null
    */
   public String login (int AD_Org_ID, int AD_Role_ID, int AD_User_ID)
   {
      return null;
   }   //   login

    /**
     *   Model Change of a monitored Table.
     *   Called after PO.beforeSave/PO.beforeDelete
     *   when you called addModelChange for the table
     *   @param po persistent object
     *   @param type TYPE_
     *   @return error message or null
     *   @exception Exception if the recipient wishes the change to be not accept.
     */
   public String modelChange (PO po, int type) throws Exception
   {
      return null;
   } //modelChange



   /**
    *   Validate Document.
    *   Called as first step of DocAction.prepareIt
     *   when you called addDocValidate for the table.
     *   Note that totals, etc. may not be correct.
    *   @param po persistent object
    *   @param timing see TIMING_ constants
     *   @return error message or null
    */
   public String docValidate (PO po, int timing)
   {
      return null;
   }   //   docValidate

   /**
    *    Update Info Window Columns.
    *    - add new Columns
    *    - remove columns
    *    - change display sequence
    *   @param columns array of columns
    *   @param sqlFrom from clause, can be modified
    *   @param sqlOrder order by clause, can me modified
    *   @return true if you updated columns, sequence or sql From clause
    */

}




Photo Error in Start Adempiere, follow:
Attachments
modelvalidator.JPG
Error MOdel Validator
modelvalidator.JPG (30.32 KiB) Viewed 3104 times
edilsondneto
 
Posts: 16
Joined: Wed Aug 17, 2011 8:22 pm

Re: ModelValidator

Postby smartjsp » Tue Sep 27, 2011 12:13 am

Edilson.


It looks like a deployment issue in your java class, how are you deploying this component ? as an customization ...(customization.jar) or as an extension ...

Pedro Rozo
smartjsp
 
Posts: 44
Joined: Fri Mar 11, 2011 11:31 pm
Location: Bogota, Colombia

Re: ModelValidator

Postby edilsondneto » Wed Sep 28, 2011 8:28 pm

The problem was not the validator itself. He began the creation of tables in the data dictionary, I told only that the tables was a certain type of entidate, but the fields were of another kind. When user "Generate Model" and generated the I_XX X_XX incorrectly and based on that created the wrong model.

Finally, redid everything again including the class that Pedro Rozo cited the problem was solved. But thanks again everyone.
edilsondneto
 
Posts: 16
Joined: Wed Aug 17, 2011 8:22 pm


Return to HELP ME!!!

Who is online

Users browsing this forum: No registered users and 2 guests

cron