use of org.jaffa.persistence.UOW in project jaffa-framework by jaffa-projects.
the class FormDefinitionMaintenanceTx method prevalidateUpdate.
// .//GEN-END:_retrieve_1_be
// .//GEN-BEGIN:_prevalidateUpdate_1_be
/**
* This method is used to perform prevalidations before updating an existing instance of FormDefinition.
* @param input The new values for the domain object.
* @throws ApplicationExceptions This will be thrown if the input contains invalid data.
* @throws FrameworkException Indicates some system error.
* @return The object details.
*/
public FormDefinitionMaintenancePrevalidateOutDto prevalidateUpdate(FormDefinitionMaintenanceUpdateInDto 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
FormDefinition domain = load(uow, input);
// Ensure the domain object has not been modified
domainObjectChangedTest(input.getPerformDirtyReadCheck(), domain, input.getLastChangedOn());
// Validate the foreign objects
validateForeignObjects(uow, input);
// Update the domain object
updateDomain(uow, input, domain, true);
FormTemplate formTemplate = createOrLoadFormTemplate(uow, input, domain, true);
// Build the outbound dto
FormDefinitionMaintenancePrevalidateOutDto output = createPrevalidateOutDto(uow, domain, input);
// 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.persistence.UOW in project jaffa-framework by jaffa-projects.
the class FormDefinitionViewerTx method loadFormTemplate.
public byte[] loadFormTemplate(FormDefinitionViewerInDto input) throws FrameworkException, ApplicationExceptions {
UOW uow = new UOW();
try {
Criteria criteria = new Criteria();
criteria.setTable(FormTemplateMeta.getName());
criteria.addCriteria(FormTemplateMeta.FORM_ID, input.getFormId());
Iterator itr = uow.query(criteria).iterator();
if (itr.hasNext()) {
FormTemplate formTemplate = (FormTemplate) itr.next();
formTemplateContents = formTemplate.getTemplateData();
}
} finally {
if (uow != null)
uow.rollback();
}
return formTemplateContents;
}
use of org.jaffa.persistence.UOW in project jaffa-framework by jaffa-projects.
the class BusinessEventLogViewerTx method read.
// .//GEN-END:_destroy_2_be
// .//GEN-BEGIN:_read_1_be
/**
* Returns the details for BusinessEventLog.
* @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 BusinessEventLogViewerOutDto read(BusinessEventLogViewerInDto 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();
// Build the Criteria Object
Criteria criteria = buildCriteria(input, uow);
// .//GEN-END:_read_1_be
// Add custom code before the query//GEN-FIRST:_read_1
// .//GEN-LAST:_read_1
// .//GEN-BEGIN:_read_2_be
// Execute The Query
Collection results = uow.query(criteria);
// .//GEN-END:_read_2_be
// Add custom code after the query//GEN-FIRST:_read_2
// .//GEN-LAST:_read_2
// .//GEN-BEGIN:_read_3_be
// Convert the domain objects into the outbound dto
BusinessEventLogViewerOutDto output = buildDto(uow, results);
// Print Debug Information for the output
if (log.isDebugEnabled()) {
log.debug("Output: " + (output != null ? output.toString() : null));
}
return output;
} finally {
if (uow != null)
uow.rollback();
}
}
use of org.jaffa.persistence.UOW in project jaffa-framework by jaffa-projects.
the class RulesEngine method doValidationsForDomainField.
/**
* Invokes the doFieldValidaions for the field.
*/
private static void doValidationsForDomainField(String domainClassName, String fieldName, Object fieldValue, UOW uow, boolean doOnlyMandatory) throws ValidationException, FrameworkException {
String variation = VariationContext.getVariation();
// determine the ClassMetaData
ClassMetaData classMetaData = getClassMetaData(domainClassName, variation);
// determine the core ClassMetaData, if required
ClassMetaData coreClassMetaData = VariationContext.DEFAULT_VARIATION.equals(variation) ? null : getClassMetaData(domainClassName, VariationContext.DEFAULT_VARIATION);
boolean localUow = false;
try {
String labelToken = null;
// perform validations for the field
if (classMetaData != null) {
FieldMetaData fieldMetaData = classMetaData.getField(fieldName);
if (fieldMetaData != null) {
// create a UOW, if not passed in
if (uow == null) {
uow = new UOW();
localUow = true;
}
FieldMetaData coreFieldMetaData = coreClassMetaData != null ? coreClassMetaData.getField(fieldName) : null;
labelToken = getLabelToken(domainClassName, fieldMetaData.getName());
doFieldValidaions(fieldValue, uow, doOnlyMandatory, labelToken, fieldMetaData, coreFieldMetaData);
}
}
// perform validations for the field in the core file, if not defined in the variant file
if (coreClassMetaData != null) {
if (classMetaData == null || classMetaData.getField(fieldName) == null) {
FieldMetaData fieldMetaData = coreClassMetaData.getField(fieldName);
if (fieldMetaData != null) {
// create a UOW, if not passed in
if (uow == null) {
uow = new UOW();
localUow = true;
}
if (labelToken == null)
labelToken = getLabelToken(domainClassName, fieldMetaData.getName());
doFieldValidaions(fieldValue, uow, doOnlyMandatory, labelToken, fieldMetaData, null);
}
}
}
} finally {
if (localUow && uow != null)
uow.rollback();
}
}
use of org.jaffa.persistence.UOW in project jaffa-framework by jaffa-projects.
the class RulesEngine method doValidationsForDomainObject.
/**
* Invokes the doFieldValidaions for each field of the ClassMetaData object for the domainObject.
*/
private static void doValidationsForDomainObject(Object domainObject, UOW uow, boolean doOnlyMandatory) throws ValidationException, FrameworkException {
String variation = VariationContext.getVariation();
boolean localUow = false;
try {
// create a UOW, if not passed in
if (uow == null) {
uow = new UOW();
localUow = true;
}
// Determine the domain class. A persistent object could very well be a proxy. Hence invoke the appropriate method
String domainClassName = domainObject instanceof IPersistent ? uow.getActualPersistentClass(domainObject).getName() : domainObject.getClass().getName();
// determine the ClassMetaData
ClassMetaData classMetaData = getClassMetaData(domainClassName, variation);
// determine the core ClassMetaData, if required
ClassMetaData coreClassMetaData = VariationContext.DEFAULT_VARIATION.equals(variation) ? null : getClassMetaData(domainClassName, VariationContext.DEFAULT_VARIATION);
// perform validations for all the fields
if (classMetaData != null) {
FieldMetaData[] fields = classMetaData.getFields();
for (int i = 0; i < fields.length; i++) {
FieldMetaData fieldMetaData = fields[i];
FieldMetaData coreFieldMetaData = coreClassMetaData != null ? coreClassMetaData.getField(fieldMetaData.getName()) : null;
String labelToken = getLabelToken(domainClassName, fieldMetaData.getName());
Object fieldValue = getFieldValue(domainObject, fieldMetaData.getName());
doFieldValidaions(fieldValue, uow, doOnlyMandatory, labelToken, fieldMetaData, coreFieldMetaData);
}
}
// perform validations for the fields in the core file, which are not defined in the variant file
if (coreClassMetaData != null) {
FieldMetaData[] fields = coreClassMetaData.getFields();
for (int i = 0; i < fields.length; i++) {
FieldMetaData fieldMetaData = fields[i];
if (classMetaData == null || classMetaData.getField(fieldMetaData.getName()) == null) {
// create a UOW, if not passed in
if (uow == null) {
uow = new UOW();
localUow = true;
}
String labelToken = getLabelToken(domainClassName, fieldMetaData.getName());
Object fieldValue = getFieldValue(domainObject, fieldMetaData.getName());
doFieldValidaions(fieldValue, uow, doOnlyMandatory, labelToken, fieldMetaData, null);
}
}
}
} finally {
if (localUow && uow != null)
uow.rollback();
}
}
Aggregations