Class Java2DBProcessorHelper


  • public class Java2DBProcessorHelper
    extends Object
    Author:
    pramodg
    • Constructor Detail

      • Java2DBProcessorHelper

        public Java2DBProcessorHelper​(String appName)
        Creates a new instance of Java2DBProcessorHelper to be used to execute SQL statements only.
        Parameters:
        appName - the name used for reporting purposes
      • Java2DBProcessorHelper

        public Java2DBProcessorHelper​(DeploymentContext ctx)
        Creates a new instance of Java2DBProcessorHelper. Do not parse all the data until it's requested in the #init() call.
        Parameters:
        ctx - the deployment context object.
    • Method Detail

      • init

        public void init()
        Initializes the rest of the settings
      • createOrDropTablesInDB

        public void createOrDropTablesInDB​(boolean create,
                                           String type)
        Iterate over all "create" or "drop" ddl files and execute them. Skip processing if the boolean argument is false.
      • getDDLFile

        public File getDDLFile​(String fileName,
                               boolean deploy)
        Read the ddl file from the disk location.
        Parameters:
        fileName - the string name of the file.
        deploy - true if this event results in creating tables.
        Returns:
        the jdbc ddl file.
      • executeDDLs

        public void executeDDLs​(File f,
                                Statement sql)
                         throws IOException
        Open a DDL file and execute each line as a SQL statement.
        Parameters:
        f - the File object to use.
        sql - the Statement to use for execution.
        Throws:
        IOException - if there is a problem with reading the file.
      • getDeployedLocation

        public String getDeployedLocation()
      • getAppRegisteredName

        public String getAppRegisteredName()
      • getCreateJdbcFileName

        public String getCreateJdbcFileName​(String bundleName)
        Returns createJdbcFileName
      • setCreateJdbcFileName

        public void setCreateJdbcFileName​(String createJdbcFileName,
                                          String bundleName)
        Sets createJdbcFileName
      • getDropJdbcFileName

        public String getDropJdbcFileName​(String bundleName)
        Returns dropJdbcFileName
      • setDropJdbcFileName

        public void setDropJdbcFileName​(String dropJdbcFileName,
                                        String bundleName)
        Sets dropJdbcFileName
      • getJndiName

        public String getJndiName​(String bundleName)
        Returns jndiName
      • setJndiName

        public void setJndiName​(String jndiName,
                                String bundleName)
        Sets jndiName
      • setProcessorType

        public void setProcessorType​(String processorType,
                                     String bundleName)
        Sets this processor type
      • getGeneratedLocation

        public String getGeneratedLocation​(String bundleName)
        Returns appGeneratedLocation or user defined value if the latter is specified
      • setGeneratedLocation

        public void setGeneratedLocation​(String generatedLocation,
                                         String bundleName)
        Sets the substitute for the internal location of the generated files
      • hasDeployCliOverrides

        public boolean hasDeployCliOverrides()
        Returns:
        true if cli overrides were set during deploy
      • hasUndeployCliOverrides

        public boolean hasUndeployCliOverrides()
        Returns:
        true if cli overrides were set during undeploy
      • getCreateTables

        public boolean getCreateTables​(boolean param)
        Create tables only on deploy, and only if the CLI options cliCreateTables or cliDropAndCreateTables are not set to false. If those options are not set (null) the value is taken from the boolean parameter provided by the caller.
        Returns:
        true if tables are to be created.
      • getDropTables

        public boolean getDropTables​(boolean param)
        Drop tables on undeploy and redeploy, if the corresponding CLI options cliDropAndCreateTables (for redeploy) or cliDropTables (for undeploy) are not set to false. If the corresponding option is not set the value is taken from the boolean parameter provided by the caller.
        Returns:
        true if the tables have to be dropped.
      • getCreateTables

        public boolean getCreateTables​(String bundleName)
        Calculate createTables value based on the parameter stored on deploy
      • setCreateTablesValue

        public void setCreateTablesValue​(boolean createTablesValue,
                                         String bundleName)
        Store user defined value for create tables for future reference.
      • getDropTables

        public boolean getDropTables​(String bundleName)
        Calculate dropTables value based on the parameter stored on deploy
      • setDropTablesValue

        public void setDropTablesValue​(boolean dropTablesValue,
                                       String bundleName)
        Store user defined value for drop tables for future reference.
      • getDDLNamePrefix

        public static String getDDLNamePrefix​(Object info)
        Returns name prefix for DDL files extracted from the info instance by the Sun-specific code.
        Parameters:
        info - the instance to use for the name generation.
        Returns:
        name prefix as String.
      • executeDDLStatement

        public boolean executeDDLStatement​(File fileName,
                                           String resourceName)
        Get the ddl files eventually executed against the database. This method deals with both create and drop ddl files.
        Parameters:
        fileName - the create or drop jdbc ddl file.
        resourceName - the jdbc resource name that would be used to get a connection to the database.
        Returns:
        true if the tables were successfully created/dropped from the database.
      • executeDDLStatement

        public boolean executeDDLStatement​(String fileNamePrefix,
                                           String resourceName)
        Get the DDL file and execute the statements.
        Parameters:
        fileNamePrefix - the common prefix for the DDL file name
        resourceName - the jdbc resource name that would be used to get a connection to the database.
        Returns:
        true if the statements were successfully in the database.
      • logI18NWarnMessage

        public void logI18NWarnMessage​(String errorCode,
                                       String regName,
                                       String fileName,
                                       Throwable ex)
        Provide a generic warning message to the user.
      • getI18NMessage

        public String getI18NMessage​(String errorCode)
        Get the localized message for the error code.
        Parameters:
        errorCode -
        Returns:
        i18ned message
      • warnUser

        public static void warnUser​(ActionReport report,
                                    String msg)
        Provide a warning message to the user. The message is appended to any already-existing warning message text.
        Parameters:
        msg - Message for user.