use of org.jaffa.modules.printing.domain.FormDefinition in project jaffa-framework by jaffa-projects.
the class FormGroup method performPreDeleteReferentialIntegrity.
// .//GEN-END:performForeignKeyValidations_1_be
// .//GEN-BEGIN:performPreDeleteReferentialIntegrity_1_be
/**
* This method is triggered by the UOW, before adding this object to the Delete-Store.
* This will raise an exception if any associated/aggregated objects exist.
* This will cascade delete all composite objects.
* @throws PreDeleteFailedException if any error occurs during the process.
*/
public void performPreDeleteReferentialIntegrity() throws PreDeleteFailedException {
FormUsage[] formUsageArray = null;
try {
formUsageArray = getFormUsageArray();
} catch (FrameworkException e) {
throw new PreDeleteFailedException(null, e);
}
if (formUsageArray != null && formUsageArray.length > 0) {
// Stop the deletion !!
throw new PreDeleteFailedException(null, new RelatedDomainObjectFoundException(FormUsageMeta.getLabelToken()));
}
FormDefinition[] formDefinitionArray = null;
try {
formDefinitionArray = getFormDefinitionArray();
} catch (FrameworkException e) {
throw new PreDeleteFailedException(null, e);
}
if (formDefinitionArray != null && formDefinitionArray.length > 0) {
try {
// Perform cascade deletes
for (int i = 0; i < formDefinitionArray.length; i++) getUOW().delete(formDefinitionArray[i]);
} catch (Exception e) {
throw new PreDeleteFailedException(null, e);
}
}
}
use of org.jaffa.modules.printing.domain.FormDefinition in project jaffa-framework by jaffa-projects.
the class FormTemplate method findFormDefinitionObject.
/**
* Finds the related FormDefinition object.
* If checkExistenceOnly is false, then the related object will be fetched and assigned to the corresponding member variable of this class.
* If checkExistenceOnly is true, then a mere existence check is performed for the related object, as oppposed to fetching all the values for that object.
*/
private void findFormDefinitionObject(boolean checkExistenceOnly) throws ValidationException, FrameworkException {
UOW uow = getUOW();
boolean localUow = false;
try {
if (m_formDefinitionObject == null && getFormId() != null) {
Criteria criteria = new Criteria();
criteria.setTable(FormDefinitionMeta.getName());
criteria.addCriteria(FormDefinitionMeta.FORM_ID, getFormId());
if (checkExistenceOnly)
criteria.addFunction(Criteria.FUNCTION_COUNT, null, Criteria.ID_FUNCTION_COUNT);
Number count = null;
if (uow == null || !uow.isActive()) {
uow = new UOW();
localUow = true;
}
Iterator itr = uow.query(criteria).iterator();
if (itr.hasNext()) {
if (checkExistenceOnly)
count = (Number) ((Map) itr.next()).get(Criteria.ID_FUNCTION_COUNT);
else
m_formDefinitionObject = (FormDefinition) itr.next();
}
if (m_formDefinitionObject == null && (count == null || count.intValue() <= 0))
throw new InvalidForeignKeyException(FormTemplateMeta.META_FORM_ID.getLabelToken(), new Object[] { FormDefinitionMeta.getLabelToken(), FormDefinitionMeta.META_FORM_ID.getLabelToken() });
}
} finally {
if (localUow && uow != null)
uow.rollback();
}
}
use of org.jaffa.modules.printing.domain.FormDefinition in project jaffa-framework by jaffa-projects.
the class FormDefinitionMaintenanceTx method createDomain.
// .//GEN-END:_duplicateCheck_4_be
// .//GEN-BEGIN:_createDomain_1_be
/**
* Create the domain object.
*/
private FormDefinition createDomain(UOW uow, FormDefinitionMaintenanceCreateInDto input, boolean fromPrevalidate) throws FrameworkException, ApplicationExceptions {
FormDefinition domain = new FormDefinition();
ApplicationExceptions appExps = null;
// .//GEN-BEGIN:_createDomain_2_be
try {
domain.updateFormId(input.getFormId());
} catch (ValidationException e) {
if (appExps == null)
appExps = new ApplicationExceptions();
appExps.add(e);
}
try {
domain.updateFormName(input.getFormName());
} catch (ValidationException e) {
if (appExps == null)
appExps = new ApplicationExceptions();
appExps.add(e);
}
try {
domain.updateFormAlternate(input.getFormAlternate());
} catch (ValidationException e) {
if (appExps == null)
appExps = new ApplicationExceptions();
appExps.add(e);
}
try {
domain.updateFormVariation(input.getFormVariation());
} catch (ValidationException e) {
if (appExps == null)
appExps = new ApplicationExceptions();
appExps.add(e);
}
try {
domain.updateOutputType(input.getOutputType());
} catch (ValidationException e) {
if (appExps == null)
appExps = new ApplicationExceptions();
appExps.add(e);
}
try {
domain.updateFormTemplate(input.getFormTemplate());
} catch (ValidationException e) {
if (appExps == null)
appExps = new ApplicationExceptions();
appExps.add(e);
}
try {
domain.updateFieldLayout(input.getFieldLayout());
} catch (ValidationException e) {
if (appExps == null)
appExps = new ApplicationExceptions();
appExps.add(e);
}
try {
domain.updateDescription(input.getDescription());
} catch (ValidationException e) {
if (appExps == null)
appExps = new ApplicationExceptions();
appExps.add(e);
}
try {
domain.updateRemarks(input.getRemarks());
} catch (ValidationException e) {
if (appExps == null)
appExps = new ApplicationExceptions();
appExps.add(e);
}
try {
domain.updateDomFactory(input.getDomFactory());
} catch (ValidationException e) {
if (appExps == null)
appExps = new ApplicationExceptions();
appExps.add(e);
}
try {
domain.updateDomClass(input.getDomClass());
} catch (ValidationException e) {
if (appExps == null)
appExps = new ApplicationExceptions();
appExps.add(e);
}
try {
domain.updateDomKey1(input.getDomKey1());
} catch (ValidationException e) {
if (appExps == null)
appExps = new ApplicationExceptions();
appExps.add(e);
}
try {
domain.updateDomKey2(input.getDomKey2());
} catch (ValidationException e) {
if (appExps == null)
appExps = new ApplicationExceptions();
appExps.add(e);
}
try {
domain.updateDomKey3(input.getDomKey3());
} catch (ValidationException e) {
if (appExps == null)
appExps = new ApplicationExceptions();
appExps.add(e);
}
try {
domain.updateDomKey4(input.getDomKey4());
} catch (ValidationException e) {
if (appExps == null)
appExps = new ApplicationExceptions();
appExps.add(e);
}
try {
domain.updateDomKey5(input.getDomKey5());
} catch (ValidationException e) {
if (appExps == null)
appExps = new ApplicationExceptions();
appExps.add(e);
}
try {
domain.updateDomKey6(input.getDomKey6());
} catch (ValidationException e) {
if (appExps == null)
appExps = new ApplicationExceptions();
appExps.add(e);
}
try {
domain.updateAdditionalDataComponent(input.getAdditionalDataComponent());
} catch (ValidationException e) {
if (appExps == null)
appExps = new ApplicationExceptions();
appExps.add(e);
}
try {
domain.updateFollowOnFormName(input.getFollowOnFormName());
} catch (ValidationException e) {
if (appExps == null)
appExps = new ApplicationExceptions();
appExps.add(e);
}
try {
domain.updateFollowOnFormAlternate(input.getFollowOnFormAlternate());
} catch (ValidationException e) {
if (appExps == null)
appExps = new ApplicationExceptions();
appExps.add(e);
}
try {
if (!fromPrevalidate)
domain.updateCreatedOn(new DateTime());
} catch (ValidationException e) {
if (appExps == null)
appExps = new ApplicationExceptions();
appExps.add(e);
}
try {
if (!fromPrevalidate && input.getHeaderDto() != null && input.getHeaderDto().getUserId() != null)
domain.updateCreatedBy(input.getHeaderDto().getUserId());
} catch (ValidationException e) {
if (appExps == null)
appExps = new ApplicationExceptions();
appExps.add(e);
}
// .//GEN-BEGIN:_createDomain_3_be
if (appExps != null && appExps.size() > 0)
throw appExps;
return domain;
}
use of org.jaffa.modules.printing.domain.FormDefinition in project jaffa-framework by jaffa-projects.
the class FormDefinitionMaintenanceTx method create.
// .//GEN-END:_prevalidateCreate_1_be
// .//GEN-BEGIN:_create_1_be
/**
* Persists a new 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 FormDefinitionMaintenanceRetrieveOutDto create(FormDefinitionMaintenanceCreateInDto 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);
// Do not allow a Duplicate record
duplicateCheck(uow, input);
// Validate the foreign objects
validateForeignObjects(uow, input);
// Create the domain object
FormDefinition domain = createDomain(uow, input, false);
uow.add(domain);
domain = postCreate(uow, input, domain, false);
FormTemplate formTemplate = createOrLoadFormTemplate(uow, input, domain, false);
if (formTemplate != null && formTemplate.isModified()) {
if (formTemplate.isDatabaseOccurence())
uow.update(formTemplate);
else
uow.add(formTemplate);
}
// Commit the changes
uow.commit();
// Print Debug Information for the output
if (log.isDebugEnabled())
log.debug("Successfully created the domain object. Now retrieving the object details.");
if (input.getFormId() == null) {
if (log.isDebugEnabled())
log.debug("The Key is not set completely. Probably using AutoGenerated keys. Cannot re-retrieve the object details. Returning NULL instead");
return null;
}
// Build the outbound dto by performing a retrieve
FormDefinitionMaintenanceRetrieveInDto retrieveInDto = new FormDefinitionMaintenanceRetrieveInDto();
retrieveInDto.setHeaderDto(input.getHeaderDto());
retrieveInDto.setFormId(input.getFormId());
FormDefinitionMaintenanceRetrieveOutDto output = retrieve(retrieveInDto);
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.FormDefinition in project jaffa-framework by jaffa-projects.
the class FormDefinitionMaintenanceTx method prevalidateCreate.
// .//GEN-END:_destroy_2_be
// .//GEN-BEGIN:_prevalidateCreate_1_be
/**
* This method is used to perform prevalidations before creating a new 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 prevalidateCreate(FormDefinitionMaintenanceCreateInDto 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);
// Do not allow a Duplicate record
duplicateCheck(uow, input);
// Validate the foreign objects
validateForeignObjects(uow, input);
// Create the domain object
FormDefinition domain = createDomain(uow, input, true);
domain = postCreate(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();
}
}
Aggregations