Export - Export template validation
Export template validation
Why is export template validation needed?
Everytime an export profile is to be exported the underlying export template has to be validated to prevent unexpected exceptions during export. The export process will be cancelled if the validation returns with an error result.
Who triggers an export template validation?
A validation is started every time an export template is loaded, saved, or if the validation is started by the user via GUI.
Furthermore, each export process is preceded by a validation of the export template.
How are the validation results presented?
All validation results - especially warnings and errors - are written to the export template's problem log. In the GUI, the problem log's content is displayed in the "Log" view of the "Export format templates" perspective.
If an export process is canceled due to validation errors, the export protocol will show those problems.
What validation steps are executed?
Check the variables
Information about not used variables
Error if a mandatory variable is not editable and has no value assigned
Error if the value of a variable doesn't match the data type of the variable
Check the data fields
Permission check
Error if data field validation rules are not completely configured
Information if a data field is not used in the template
Error if a data field is not completely configured
Check the data providers
Error if not all data providers could be initialized
Error if not all mandatory non-editable parameters got a value
Check the export post steps
Error if not all export post step parameters could be initialized
Error if not all mandatory non-editable parameters got a value
Error if a file specified as parameter value is not available
Check the file configuration
Warning if a file with a file name pattern is assigned to multiple export template modules because of possible overlapping file names
Error in case of invalid file name patterns
Check the export template modules
Error if the data provider of a module is unknown
Error if a module got no file assigned
Warning if a module is empty
Warning if a module contains an invalid character, that character is deleted
Error in case of unknown variables, functions, data fields, sub-modules
Check the template
Error if the spefified format mapping table is unknown
Check the mime configuration
Warning if the configuration of file attachement export is inconsistent
The file attachement export is well-configured if the "ExportMime" function is used in an export template module and the "Query file name with multimedia server" option is activated and the "File attachment export" export post step is assigned to the template.
Determine the initialization entity
The data provider parameter values are analyzed. If there's exactly one mandatory editable parameter that can get a list of entity proxies the initialization entity is set to the template.
The initialization entity is used to get all export templates for a preview or direct export that match a selection of objects, e.g. items or products
Do extended validations
All additional validations steps are executed, see below
How to add own export template validation steps
Implement a Template validation
This feature applies to the Heiler Product Manager in versions 7.0 and above
During some cases like adding a new post-processing step you want to add a further validation. For this you have to implement the ValidateExportTemplate interface and contribute it to the ValidateExportTemplate extension.
validateTemplate
The validateTemplate function returns the error code of the current validation.
@Override
public
int
validateTemplate( ExportTemplate template, ProblemLog problemLog, IProgressMonitor monitor )
throws
CoreException
{
try
{
monitor.beginTask(
""
,
1000
);
//$NON-NLS-1$
int
result = IStatus.OK;
if
( !monitor.isCanceled() )
{
monitor.subTask( Messages.getString(
"ValidateMyExportTemplate.taskname.checkMyTemplate"
) );
//$NON-NLS-1$
result = validateMyTemplateConfiguration( template, problemLog );
monitor.worked(
1000
);
}
return
result;
}
finally
{
monitor.done();
}
}
An implementation of line 12 could look like following
private
int
validateMyTemplateConfiguration( ExportTemplate template, ProblemLog problemLog )
{
int
result = IStatus.OK;
// check if my export post step is registered in this template
ExportPostStep exportPostStep = template.getExportPostStepManager()
.getExportPostStepByIdentifier( POSTSTEP_UNIQUE_IDENTIFIER );
if
( exportPostStep !=
null
&& exportPostStep.getName().contains(
"abc"
) )
//$NON-NLS-1$
{
result = IStatus.ERROR;
String message = Messages.getString(
"ValidateMyExportTemplate.error.wrongPostStepName"
);
//$NON-NLS-1$
ValidateUtils.writeLogEntry( problemLog, Categories.CONSISTENCY, IStatus.ERROR,
ExportErrorCodes.ERR_MY_TEMPLATE__WRONG_POST_STEP_NAME, message,
null
,
ExportConst.ENTITY__MY_EXPORT_TEMPLATE,
null
, template.getName() );
}
return
result;
}
Note: It's not recommended using database calls during this method.
Contribution
Make the validation available for the system: contribute it to the ValidateExportTemplate extension point.
<plug-in>
<extension
point=
"com.heiler.ppm.export.core.ValidateExportTemplate"
>
<ValidateExportTemplate
class
=
"com.heiler.ppm.export.core.example.validate.ValidateMyExportTemplate"
name=
"ValidateHsxExportTemplate"
>
</ValidateExportTemplate>
</extension>
</plug-in>