13 Utility to generate Validators
Once the taxonomy validation is enabled for a request DTO, it is mandatory to have a taxonomy validator for the same in the application.
A utility has been provided to generate the validators for such request DTOs. This section describes the steps to be followed to generate the validators using this utility.
- The machine should have JDK version 1.7 or above installed
 - The project having the custom request DTOs must be ready
 - Supporting jars as mentioned below
                        
- com.ofss.digx.appcore.dto.jar – (available in ‘obapi.app.framework.ear’)
 - com.ofss.fc.infra.jar – (available in ‘obapi.app.core.domain.ear’)
 - com.ofss.fc.appcore.dto.jar – (available in ‘obapi.app.core.domain.ear’)
 - Any other jars required for compilation of project containing custom request DTOs
 
 
This section explains step by step process to generate the validators using the utility.
Step 1: Copy the following artifacts from the <installer> to desired directory. This directory will be referred as <UTIL_DIR>.
- validator_gen.bat (for Windows) OR validator_gen.sh (for Linux)
 - lib folder – (contains pre-built jars required for utility)
 
Add the supporting jars as mentioned in the prerequisites (point no 3) in the lib folder.
< UTIL_DIR > and open
            command prompt / terminal.
                  Execute following command:
- For Linux
                        
./validator_gen.sh <BIN_DIR> <UTIL_DIR> <PROJECT_DIR> <PACKAGE_NAME> - For Windows
                        
/validator_gen.bat <BIN_DIR> <UTIL_DIR> <PROJECT_DIR> <PACKAGE_NAME>. 
Where,
<BIN_DIR>: Path where JDK bin is located (e.g.
                C:\Program Files\Java\jdk1.8.0_171\bin) (use “ if the path contains spaces)
                  
<PROJECT_DIR>: path where request DTO project is
                located
                  
<PACKAGE_NAME>: name of the package where the
                source of request DTOs is located
                  
Consider following example
If the customized request DTOs are located in ‘D:\workspaces\trunk\com.ofss.digx.cz.app.xface\src \com…’
Then, < PROJECT_DIR > = ‘D:\workspaces\trunk’ and
                    < PACKAGE_NAME > = ‘com.ofss.digx.cz.app.xface’
 As a result of utility, a jar
                containing the compiled classes of validator files will be created in
                    <UTIL_DIR>. Copy the jar file and paste in the EAR file
                where the jar of customized DTO classes is located. Deploy the EAR file in the
                application and restart the server.
                  
Note:
As the utility runs, it creates the source folder of the validator
                    classes in <PROJECT_DIR>. By default, this folder is
                    deleted once the utility execution is completed. This source folder can be
                    retained by following way. 
                     
Open ‘validator_gen.bat’ or ‘validator_gen.sh’ in notepad and set the value of variable ‘isValidatorSourceRequired’ to Y. Run the utility again. The source will available in <PROJECT_DIR>.