use of org.jaffa.modules.printing.domain.FormTemplate in project jaffa-framework by jaffa-projects.
the class FormTemplateMaintenanceTx method retrieve.
// .//GEN-END:_create_1_be
// .//GEN-BEGIN:_retrieve_1_be
/**
* Returns the details for FormTemplate.
* @param input The criteria based on which an object will be retrieved.
* @throws ApplicationExceptions This will be thrown if the criteria contains invalid data.
* @throws FrameworkException Indicates some system error.
* @return The object details. A null indicates, the object was not found.
*/
public FormTemplateMaintenanceRetrieveOutDto retrieve(FormTemplateMaintenanceRetrieveInDto input) throws FrameworkException, ApplicationExceptions {
UOW uow = null;
try {
// Print Debug Information for the input
if (log.isDebugEnabled())
log.debug("Input: " + (input != null ? input.toString() : null));
// create the UOW
uow = new UOW();
// Preprocess the input
preprocess(uow, input);
// Retrieve the object
FormTemplate domain = load(uow, input);
// Convert the domain objects into the outbound dto
FormTemplateMaintenanceRetrieveOutDto output = buildRetrieveOutDto(uow, input, domain);
// Print Debug Information for the output
if (log.isDebugEnabled())
log.debug("Output: " + (output != null ? output.toString() : null));
return output;
} catch (FrameworkException e) {
// If it is, then re-throw as ApplicationsExceptions, else throw the FrameworkException.
if (e.getCause() != null && e.getCause() instanceof ApplicationExceptions) {
throw (ApplicationExceptions) e.getCause();
} else if (e.getCause() != null && e.getCause() instanceof ApplicationException) {
ApplicationExceptions appExps = new ApplicationExceptions();
appExps.add((ApplicationException) e.getCause());
throw appExps;
} else
throw e;
} finally {
if (uow != null)
uow.rollback();
}
}
use of org.jaffa.modules.printing.domain.FormTemplate in project jaffa-framework by jaffa-projects.
the class FormTemplateViewerTx method buildDto.
// .//GEN-END:_buildCriteria_3_be
// .//GEN-BEGIN:_buildDto_1_be
private FormTemplateViewerOutDto buildDto(UOW uow, Collection results) throws UOWException {
FormTemplateViewerOutDto output = null;
Iterator itr = results.iterator();
if (itr.hasNext()) {
// just return the details for the 1st record retrieved.
FormTemplate formTemplate = (FormTemplate) itr.next();
output = new FormTemplateViewerOutDto();
// .//GEN-END:_buildDto_1_be
// Add custom code before all the setters //GEN-FIRST:_buildDto_1
// .//GEN-LAST:_buildDto_1
// .//GEN-BEGIN:_buildDto_FormId_1_be
output.setFormId(formTemplate.getFormId());
// .//GEN-END:_buildDto_FormId_1_be
// .//GEN-BEGIN:_buildDto_TemplateData_1_be
output.setTemplateData(formTemplate.getTemplateData());
// .//GEN-END:_buildDto_TemplateData_1_be
// .//GEN-BEGIN:_buildDto_LayoutData_1_be
output.setLayoutData(formTemplate.getLayoutData());
// .//GEN-END:_buildDto_LayoutData_1_be
// .//GEN-BEGIN:_buildDto_2_be
// Add related objects, if required
addRelatedDtos(uow, output, formTemplate);
// .//GEN-END:_buildDto_2_be
// Add custom code to pass values to the dto //GEN-FIRST:_buildDto_2
// .//GEN-LAST:_buildDto_2
// .//GEN-BEGIN:_buildDto_3_be
}
return output;
}
use of org.jaffa.modules.printing.domain.FormTemplate in project jaffa-framework by jaffa-projects.
the class FormDefinition method newFormTemplateObject.
/**
* Creates a new FormTemplate object and initializes the related fields.
* @throws ValidationException if an invalid value is passed.
* @throws FrameworkException Indicates some system error
* @return the related FormTemplate object with the initialized related fields.
*/
public FormTemplate newFormTemplateObject() throws ValidationException, FrameworkException {
FormTemplate formTemplate = new FormTemplate();
formTemplate.setFormId(getFormId());
// .//GEN-BEGIN:formTemplateObject_2_be
return formTemplate;
}
use of org.jaffa.modules.printing.domain.FormTemplate in project jaffa-framework by jaffa-projects.
the class FormDefinitionMaintenanceTx method addRelatedDtosToRetrieveOut.
// .//GEN-END:_createPrevalidateOutDto_2_be
// .//GEN-BEGIN:_addRelatedDtosToRetrieveOut_1_be
/**
* Add related objects to FormDefinitionMaintenanceRetrieveOutDto
*/
private void addRelatedDtosToRetrieveOut(UOW uow, FormDefinition formDefinition, FormDefinitionMaintenanceRetrieveOutDto output) throws FrameworkException, ApplicationExceptions {
// .//GEN-BEGIN:_addRelatedDtosToRetrieveOut_FormTemplate_1_be
if (formDefinition.getFormId() != null) {
Criteria criteria = new Criteria();
criteria.setTable(FormTemplateMeta.getName());
criteria.addCriteria(FormTemplateMeta.FORM_ID, formDefinition.getFormId());
// .//GEN-END:_addRelatedDtosToRetrieveOut_FormTemplate_1_be
// Add custom code to set the criteria before the query//GEN-FIRST:_addRelatedDtosToRetrieveOut_FormTemplate_1
// .//GEN-LAST:_addRelatedDtosToRetrieveOut_FormTemplate_1
// .//GEN-BEGIN:_addRelatedDtosToRetrieveOut_FormTemplate_4_be
Iterator itrOne = uow.query(criteria).iterator();
if (itrOne.hasNext()) {
FormTemplate formTemplate = (FormTemplate) itrOne.next();
// .//GEN-END:_addRelatedDtosToRetrieveOut_FormTemplate_4_be
// Add custom code to pass values to the dto//GEN-FIRST:_addRelatedDtosToRetrieveOut_FormTemplate_5
// .//GEN-LAST:_addRelatedDtosToRetrieveOut_FormTemplate_5
// .//GEN-BEGIN:_addRelatedDtosToRetrieveOut_FormTemplate_5_be
}
// .//GEN-END:_addRelatedDtosToRetrieveOut_FormTemplate_5_be
// .//GEN-BEGIN:_addRelatedDtosToRetrieveOut_FormTemplate_6_be
}
// .//GEN-END:_addRelatedDtosToRetrieveOut_FormTemplate_6_be
// .//GEN-BEGIN:_addRelatedDtosToRetrieveOut_2_be
}
use of org.jaffa.modules.printing.domain.FormTemplate in project jaffa-framework by jaffa-projects.
the class FormDefinitionMaintenanceTx method deleteRelatedObjects.
// .//GEN-END:_addRelatedDtosToRetrieveOut_2_be
// .//GEN-BEGIN:_deleteRelatedObjects_1_be
/**
* Delete the related domain objects if the 'Cascading' constraint is specified. Throw an exception in case 'Restricted' constraint is specified.
*/
private void deleteRelatedObjects(UOW uow, FormDefinitionMaintenanceDeleteInDto input, FormDefinition formDefinition) throws FrameworkException, ApplicationExceptions {
ApplicationExceptions appExps = null;
// .//GEN-BEGIN:_deleteRelatedObjects_FormTemplate_1_be
if (formDefinition.getFormId() != null) {
Criteria criteria = new Criteria();
criteria.setTable(FormTemplateMeta.getName());
criteria.addCriteria(FormTemplateMeta.FORM_ID, formDefinition.getFormId());
criteria.setLocking(Criteria.LOCKING_PARANOID);
// .//GEN-END:_deleteRelatedObjects_FormTemplate_1_be
// Add custom code to set the criteria before the query//GEN-FIRST:_deleteRelatedObjects_FormTemplate_1
// .//GEN-LAST:_deleteRelatedObjects_FormTemplate_1
// .//GEN-BEGIN:_deleteRelatedObjects_FormTemplate_4_be
Iterator itr = uow.query(criteria).iterator();
while (itr.hasNext()) {
FormTemplate formTemplate = (FormTemplate) itr.next();
if (log.isDebugEnabled())
log.debug("Deleting the related object " + formTemplate);
uow.delete(formTemplate);
}
// .//GEN-END:_deleteRelatedObjects_FormTemplate_4_be
// .//GEN-BEGIN:_deleteRelatedObjects_FormTemplate_6_be
}
// .//GEN-END:_deleteRelatedObjects_FormTemplate_6_be
// Add custom code//GEN-FIRST:_deleteRelatedObjects_1
// Stop the delete if this is the only record for the given formName/formAlternate combination, and if any FormUsage exists
Criteria criteria = new Criteria();
criteria.setTable(FormDefinitionMeta.getName());
criteria.addCriteria(FormDefinitionMeta.FORM_ID, Criteria.RELATIONAL_NOT_EQUALS, formDefinition.getFormId());
if (formDefinition.getFormName() != null)
criteria.addCriteria(FormDefinitionMeta.FORM_NAME, formDefinition.getFormName());
else
criteria.addCriteria(FormDefinitionMeta.FORM_NAME, Criteria.RELATIONAL_IS_NULL);
if (formDefinition.getFormAlternate() != null)
criteria.addCriteria(FormDefinitionMeta.FORM_ALTERNATE, formDefinition.getFormAlternate());
else
criteria.addCriteria(FormDefinitionMeta.FORM_ALTERNATE, Criteria.RELATIONAL_IS_NULL);
Iterator itr = uow.query(criteria).iterator();
if (!itr.hasNext()) {
// No other FormDefinition exists for the given formName/formAlternate combination
// Raise an error if any FormUsage exists for that formName/formAlternate combination.
criteria = new Criteria();
criteria.setTable(FormUsageMeta.getName());
if (formDefinition.getFormName() != null)
criteria.addCriteria(FormUsageMeta.FORM_NAME, formDefinition.getFormName());
else
criteria.addCriteria(FormUsageMeta.FORM_NAME, Criteria.RELATIONAL_IS_NULL);
if (formDefinition.getFormAlternate() != null)
criteria.addCriteria(FormUsageMeta.FORM_ALTERNATE, formDefinition.getFormAlternate());
else
criteria.addCriteria(FormUsageMeta.FORM_ALTERNATE, Criteria.RELATIONAL_IS_NULL);
itr = uow.query(criteria).iterator();
if (itr.hasNext())
throw new ApplicationExceptions(new ApplicationException("exception.Jaffa.Printing.FormDefinitionMaintenance.ReferrentialEUsage") {
});
}
// .//GEN-BEGIN:_deleteRelatedObjects_2_be
if (appExps != null)
throw appExps;
}
Aggregations