org.kuali.kfs.sys.context
Class SchemaBuilder

java.lang.Object
  extended by org.kuali.kfs.sys.context.SchemaBuilder

public class SchemaBuilder
extends Object

Called during the build process to output schema files with validation built from the data dictionary or set to defaults


Constructor Summary
SchemaBuilder()
           
 
Method Summary
protected static void buildDataDictionarySchemaValidationType(String ddAttributeName, Collection typesSchemaLines, Set<String> builtTypes)
          Constructs new AttributeSchemaValidationBuilder for the given attribute name to build the type XML lines which are added to the given collection
protected static void buildSchemaFile(File buildSchemFile, String outSchemaFilePathName, boolean useDataDictionaryValidation, Collection typesSchemaLines, String externalizableContentUrl, Set<String> builtTypes, boolean rebuildDDTypes)
          Process a single schema file (setting validation and externalizable token) and outputs to static directory.
protected static void buildSchemaFiles(Collection buildSchemaFiles, String staticDirectoryPath, String buildDirectoryPath, boolean useDataDictionaryValidation, String externalizableContentUrl, boolean rebuildDDTypes)
          Iterates through build schema files processing validation place-holders and outputting to static directory.
protected static Collection finalizeDataDictionaryTypesSchema()
          Builds footer XML lines for the data dictionary types include .
protected static Collection getBuildSchemaFiles(String buildDirectoryPath)
          Returns Collection of File objects for all .xsd files found in given directory (including sub-directories)
protected static String getRelativeFilePathName(File file, String parentPath)
          Determines what the relative path of the given file is relative to the given parent path.
protected static Collection initalizeDataDictionaryTypesSchema()
          Builds header XML lines for the data dictionary types include
protected static void logAndThrowException(String msg)
          Helper method for logging an error and throwing a new RuntimeException
static void main(String[] args)
           Performs schema build process.
protected static String processValidationPlaceholder(String validationPlaceholder, String buildLine, String fileName, int lineCount, boolean useDataDictionaryValidation, Collection typesSchemaLines, Set<String> builtTypes, boolean rebuildDDTypes)
          Performs logic to processes a validation place-holder for a line.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SchemaBuilder

public SchemaBuilder()
Method Detail

main

public static void main(String[] args)
 Performs schema build process. 
 
 Build directory path containing the schema files, static directory that schema files will be
 outputted to, and flag for whether to use data dictionary validation all must given as arguments. 
 
 Schema files in build directory should contain place-holders for which the validation will be substituted. The place-holder begin symbol is ${,
 and the end symbol is }. Then the place-holder should contain two parts, first the xsd type to use if data dictionary
 validation is not on. The second is the data dictionary entry (businessObjectEntry.attributeName) prefixed with 'dd:' that
 will be pulled for dd validation. The parts should be separated with a comma. Any type values without a place-holder will
 not be modified. 
 
 Program also fills in externalizable.static.content.url place-holder. Value to set should be passed as the fourth program argument
 

Parameters:
args -

getBuildSchemaFiles

protected static Collection getBuildSchemaFiles(String buildDirectoryPath)
Returns Collection of File objects for all .xsd files found in given directory (including sub-directories)

Parameters:
buildDirectoryPath - Directory to look for schema files
Returns:
Collection of File objects

buildSchemaFiles

protected static void buildSchemaFiles(Collection buildSchemaFiles,
                                       String staticDirectoryPath,
                                       String buildDirectoryPath,
                                       boolean useDataDictionaryValidation,
                                       String externalizableContentUrl,
                                       boolean rebuildDDTypes)
                                throws IOException
Iterates through build schema files processing validation place-holders and outputting to static directory. Include file for referenced schema types is also written out

Parameters:
buildSchemaFiles - collection of File objects for build schema files
staticDirectoryPath - path that processed schema files will be written to
buildDirectoryPath - path of build schema files
useDataDictionaryValidation - indicates whether data dictionary validation should be used, if false the general xsd datatype in the place-holder will be used
externalizableContentUrl - URL to set for externalizable.static.content.url token
Throws:
IOException - thrown for any read/write errors encountered

buildSchemaFile

protected static void buildSchemaFile(File buildSchemFile,
                                      String outSchemaFilePathName,
                                      boolean useDataDictionaryValidation,
                                      Collection typesSchemaLines,
                                      String externalizableContentUrl,
                                      Set<String> builtTypes,
                                      boolean rebuildDDTypes)
                               throws IOException
Process a single schema file (setting validation and externalizable token) and outputs to static directory. Any new data dictionary types encountered are added to the given Collection for later writing to the types include file

Parameters:
buildSchemFile - build schema file that should be processed
outSchemaFilePathName - full file path name for the outputted schema
useDataDictionaryValidation - indicates whether data dictionary validation should be used, if false the general xsd datatype in the place-holder will be used
typesSchemaLines - collection of type XML lines to add to for any new types
externalizableContentUrl - URL to set for externalizable.static.content.url token
builtTypes - - Set of attribute names for which a schema validation type has been built
Throws:
IOException - thrown for any read/write errors encountered

processValidationPlaceholder

protected static String processValidationPlaceholder(String validationPlaceholder,
                                                     String buildLine,
                                                     String fileName,
                                                     int lineCount,
                                                     boolean useDataDictionaryValidation,
                                                     Collection typesSchemaLines,
                                                     Set<String> builtTypes,
                                                     boolean rebuildDDTypes)
Performs logic to processes a validation place-holder for a line. First collects the configuration given in the place-holder (general xsd type and data dictionary attribute). If use data dictionary validation is set to false, then the place-holder will be set to the xsd type. If data dictionary validation is set to true, the general xsd type will be removed, and the corresponding the data dictionary will be consulted to build the dd type
 ex. type="${xsd:token,dd:Chart.chartOfAccountsCode}" with useDataDictionaryValidation=false becomes type="xsd:token"
    type="${xsd:token,dd:Chart.chartOfAccountsCode}" with useDataDictionaryValidation=true becomes type="dd:Chart.chartOfAccountsCode" and XML lines created for dd Types file
 

Parameters:
validationPlaceholder - the parsed place-holder contents
buildLine - the complete line being read
fileName - the name for the file being processed
lineCount - count for the line being read
useDataDictionaryValidation - indicates whether data dictionary validation should be used, if false the general xsd datatype in the place-holder will be used
typesSchemaLines - collection of type XML lines to add to for any new types
builtTypes - - Set of attribute names for which a schema validation type has been built
Returns:
String the out XML line (which validation filled in)

buildDataDictionarySchemaValidationType

protected static void buildDataDictionarySchemaValidationType(String ddAttributeName,
                                                              Collection typesSchemaLines,
                                                              Set<String> builtTypes)
Constructs new AttributeSchemaValidationBuilder for the given attribute name to build the type XML lines which are added to the given collection

Parameters:
ddAttributeName - attribute entry name (business object class and attribute name) with dd: namespace prefix
typesSchemaLines - collection of type XML lines to add to for any new types
builtTypes - - Set of attribute names for which a schema validation type has been built
See Also:
AttributeSchemaValidationBuilder

initalizeDataDictionaryTypesSchema

protected static Collection initalizeDataDictionaryTypesSchema()
Builds header XML lines for the data dictionary types include

Returns:
Collection containing the XML lines

finalizeDataDictionaryTypesSchema

protected static Collection finalizeDataDictionaryTypesSchema()
Builds footer XML lines for the data dictionary types include .

Returns:
Collection containing the XML lines

getRelativeFilePathName

protected static String getRelativeFilePathName(File file,
                                                String parentPath)
Determines what the relative path of the given file is relative to the given parent path. Since parentPath is configured string method checks for / or \\ path separators .
 eg. File path - /build/project/xsd/gl/collector.xsd, Parent Path - /build/project/xsd returns gl/collector.xsd
 

Parameters:
file - File for which we want to find the relative path
parentPath - Path to parent directory
Returns:
String the relative path of the file

logAndThrowException

protected static void logAndThrowException(String msg)
Helper method for logging an error and throwing a new RuntimeException

Parameters:
msg - message for logging and exception


Copyright © 2005-2012 The Kuali Foundation. All Rights Reserved.