use of org.jaffa.modules.printing.domain.FormUsage in project jaffa-framework by jaffa-projects.
the class FormGroupMaintenanceTx method addRelatedDtosToRetrieveOut.
// .//GEN-END:_createPrevalidateOutDto_2_be
// .//GEN-BEGIN:_addRelatedDtosToRetrieveOut_1_be
/**
* Add related objects to FormGroupMaintenanceRetrieveOutDto
*/
private void addRelatedDtosToRetrieveOut(UOW uow, FormGroup formGroup, FormGroupMaintenanceRetrieveOutDto output) throws FrameworkException, ApplicationExceptions {
// .//GEN-BEGIN:_addRelatedDtosToRetrieveOut_FormUsage_1_be
if (formGroup.getFormName() != null) {
Criteria criteria = new Criteria();
criteria.setTable(FormUsageMeta.getName());
criteria.addCriteria(FormUsageMeta.FORM_NAME, formGroup.getFormName());
criteria.addOrderBy("EventName", Criteria.ORDER_BY_ASC);
// .//GEN-END:_addRelatedDtosToRetrieveOut_FormUsage_1_be
// Add custom code to set the criteria before the query//GEN-FIRST:_addRelatedDtosToRetrieveOut_FormUsage_1
// .//GEN-LAST:_addRelatedDtosToRetrieveOut_FormUsage_1
// .//GEN-BEGIN:_addRelatedDtosToRetrieveOut_FormUsage_2_be
Iterator itrMany = uow.query(criteria).iterator();
while (itrMany.hasNext()) {
FormUsage formUsage = (FormUsage) itrMany.next();
FormUsageDto dto = new FormUsageDto();
// .//GEN-END:_addRelatedDtosToRetrieveOut_FormUsage_2_be
// Add custom code before all the setters//GEN-FIRST:_addRelatedDtosToRetrieveOut_FormUsage_2
// .//GEN-LAST:_addRelatedDtosToRetrieveOut_FormUsage_2
// .//GEN-BEGIN:_addRelatedDtosToRetrieveOut_FormUsage_EventName_1_be
dto.setEventName(formUsage.getEventName());
// .//GEN-END:_addRelatedDtosToRetrieveOut_FormUsage_EventName_1_be
// .//GEN-BEGIN:_addRelatedDtosToRetrieveOut_FormUsage_FormAlternate_1_be
dto.setFormAlternate(formUsage.getFormAlternate());
// .//GEN-END:_addRelatedDtosToRetrieveOut_FormUsage_FormAlternate_1_be
// .//GEN-BEGIN:_addRelatedDtosToRetrieveOut_FormUsage_Copies_1_be
dto.setCopies(formUsage.getCopies());
// .//GEN-END:_addRelatedDtosToRetrieveOut_FormUsage_Copies_1_be
// .//GEN-BEGIN:_addRelatedDtosToRetrieveOut_FormUsage_Description_1_be
FormEvent chainFormEventEventNameEventName = null;
{
if (formUsage.getEventName() != null) {
Criteria criteriaFormEvent = new Criteria();
criteriaFormEvent.setTable(FormEventMeta.getName());
criteriaFormEvent.addCriteria(FormEventMeta.EVENT_NAME, formUsage.getEventName());
// .//GEN-END:_addRelatedDtosToRetrieveOut_FormUsage_Description_1_be
// Add custom code to modify the criteria//GEN-FIRST:_addRelatedDtosToRetrieveOut_FormUsage_Description_1
// .//GEN-LAST:_addRelatedDtosToRetrieveOut_FormUsage_Description_1
// .//GEN-BEGIN:_addRelatedDtosToRetrieveOut_FormUsage_Description_2_be
Iterator i = uow.query(criteriaFormEvent).iterator();
if (i.hasNext())
chainFormEventEventNameEventName = (FormEvent) i.next();
}
}
// .//GEN-BEGIN:_addRelatedDtosToRetrieveOut_FormUsage_Description_3_be
try {
dto.setDescription(chainFormEventEventNameEventName.getDescription());
} catch (NullPointerException e) {
// Do nothing
}
// .//GEN-END:_addRelatedDtosToRetrieveOut_FormUsage_Description_3_be
// Add custom code to pass values to the dto//GEN-FIRST:_addRelatedDtosToRetrieveOut_FormUsage_3
// .//GEN-LAST:_addRelatedDtosToRetrieveOut_FormUsage_3
// .//GEN-BEGIN:_addRelatedDtosToRetrieveOut_FormUsage_3_be
output.addFormUsage(dto);
}
// .//GEN-END:_addRelatedDtosToRetrieveOut_FormUsage_3_be
// .//GEN-BEGIN:_addRelatedDtosToRetrieveOut_FormUsage_6_be
}
// .//GEN-END:_addRelatedDtosToRetrieveOut_FormUsage_6_be
// .//GEN-BEGIN:_addRelatedDtosToRetrieveOut_2_be
}
use of org.jaffa.modules.printing.domain.FormUsage in project jaffa-framework by jaffa-projects.
the class FormGroupMaintenanceTx method createFormUsageEntry.
// .//GEN-END:_deleteRelatedObjects_2_be
// All the custom code goes here//GEN-FIRST:_custom
// Add the related FormUsage
private void createFormUsageEntry(UOW uow, FormGroupMaintenanceUpdateInDto input, boolean fromPrevalidate) throws FrameworkException, ApplicationExceptions {
ApplicationExceptions appExps = null;
try {
if (input.getFormName() != null) {
Criteria criteria = new Criteria();
criteria.setTable(FormUsageMeta.getName());
criteria.addCriteria(FormUsageMeta.FORM_NAME, input.getFormName());
Collection col = uow.query(criteria);
// Iterator itr = col.iterator();
for (int i = 0; i < input.getFormUsageCount(); i++) {
boolean found = false;
FormUsageDto inputFormUsageDto = input.getFormUsage(i);
for (Iterator itr = col.iterator(); itr.hasNext(); ) {
FormUsage formusage = (FormUsage) itr.next();
if (inputFormUsageDto.getEventName().equals(formusage.getEventName())) {
try {
formusage.updateFormAlternate(inputFormUsageDto.getFormAlternate());
} catch (ValidationException e) {
if (appExps == null)
appExps = new ApplicationExceptions();
appExps.add(e);
}
try {
formusage.updateCopies(inputFormUsageDto.getCopies());
} catch (ValidationException e) {
if (appExps == null)
appExps = new ApplicationExceptions();
appExps.add(e);
}
if (appExps != null && appExps.size() > 0)
throw appExps;
if (!fromPrevalidate) {
if (log.isDebugEnabled())
log.debug("Creating FormUsage: " + formusage);
uow.update(formusage);
found = true;
}
break;
} else {
continue;
}
}
if (!found) {
FormUsage formUsage = new FormUsage();
formUsage.setEventName(inputFormUsageDto.getEventName());
formUsage.setFormName(input.getFormName());
formUsage.setFormAlternate(inputFormUsageDto.getFormAlternate());
formUsage.setCopies(inputFormUsageDto.getCopies());
if (!fromPrevalidate) {
if (log.isDebugEnabled())
log.debug("Creating FormUsage: " + formUsage);
uow.add(formUsage);
}
}
}
for (Iterator itr = col.iterator(); itr.hasNext(); ) {
boolean found = false;
FormUsage formusage = (FormUsage) itr.next();
for (int i = 0; i < input.getFormUsageCount(); i++) {
FormUsageDto inputFormUsageDto = input.getFormUsage(i);
if (formusage.getEventName().equals(inputFormUsageDto.getEventName())) {
found = true;
break;
}
}
if (!found) {
if (!fromPrevalidate) {
if (log.isDebugEnabled())
log.debug("Creating FormUsage: " + formusage);
uow.delete(formusage);
}
}
}
}
} catch (ValidationException e) {
throw new ApplicationExceptions(e);
}
}
use of org.jaffa.modules.printing.domain.FormUsage in project jaffa-framework by jaffa-projects.
the class FormGroupViewerTx method addRelatedDtos.
// .//GEN-END:_buildDto_3_be
// .//GEN-BEGIN:_addRelatedDtos_1_be
private void addRelatedDtos(UOW uow, FormGroupViewerOutDto output, FormGroup formGroup) throws UOWException {
// .//GEN-BEGIN:_addRelatedDtos_FormUsage_1_be
if (formGroup.getFormName() != null) {
Criteria criteria = new Criteria();
criteria.setTable(FormUsageMeta.getName());
criteria.addCriteria(FormUsageMeta.FORM_NAME, formGroup.getFormName());
criteria.addOrderBy("FormName", Criteria.ORDER_BY_ASC);
// .//GEN-END:_addRelatedDtos_FormUsage_1_be
// Add custom code to set the criteria before the query //GEN-FIRST:_addRelatedDtos_FormUsage_1
// .//GEN-LAST:_addRelatedDtos_FormUsage_1
// .//GEN-BEGIN:_addRelatedDtos_FormUsage_2_be
Iterator itr = uow.query(criteria).iterator();
while (itr.hasNext()) {
FormUsage formUsage = (FormUsage) itr.next();
FormUsageDto dto = new FormUsageDto();
// .//GEN-END:_addRelatedDtos_FormUsage_2_be
// Add custom code before all the setters //GEN-FIRST:_addRelatedDtos_FormUsage_2
// .//GEN-LAST:_addRelatedDtos_FormUsage_2
// .//GEN-BEGIN:_addRelatedDtos_FormUsage_EventName_1_be
dto.setEventName(formUsage.getEventName());
// .//GEN-END:_addRelatedDtos_FormUsage_EventName_1_be
// .//GEN-BEGIN:_addRelatedDtos_FormUsage_FormAlternate_1_be
dto.setFormAlternate(formUsage.getFormAlternate());
// .//GEN-END:_addRelatedDtos_FormUsage_FormAlternate_1_be
// .//GEN-BEGIN:_addRelatedDtos_FormUsage_Copies_1_be
dto.setCopies(formUsage.getCopies());
// .//GEN-END:_addRelatedDtos_FormUsage_Copies_1_be
// .//GEN-BEGIN:_addRelatedDtos_FormUsage_Description_1_be
FormEvent chainFormEventEventNameEventName = null;
{
if (formUsage.getEventName() != null) {
Criteria criteriaFormEvent = new Criteria();
criteriaFormEvent.setTable(FormEventMeta.getName());
criteriaFormEvent.addCriteria(FormEventMeta.EVENT_NAME, formUsage.getEventName());
// .//GEN-END:_addRelatedDtos_FormUsage_Description_1_be
// Add custom code to modify the criteria //GEN-FIRST:_addRelatedDtos_FormUsage_Description_1
// .//GEN-LAST:_addRelatedDtos_FormUsage_Description_1
// .//GEN-BEGIN:_addRelatedDtos_FormUsage_Description_2_be
Iterator i = uow.query(criteriaFormEvent).iterator();
if (i.hasNext())
chainFormEventEventNameEventName = (FormEvent) i.next();
}
}
// .//GEN-BEGIN:_addRelatedDtos_FormUsage_Description_3_be
try {
dto.setDescription(chainFormEventEventNameEventName.getDescription());
} catch (NullPointerException e) {
// Do nothing
}
// .//GEN-END:_addRelatedDtos_FormUsage_Description_3_be
// Add custom code to pass values to the dto //GEN-FIRST:_addRelatedDtos_FormUsage_3
// .//GEN-LAST:_addRelatedDtos_FormUsage_3
// .//GEN-BEGIN:_addRelatedDtos_FormUsage_3_be
output.addFormUsage(dto);
}
}
// .//GEN-END:_addRelatedDtos_FormUsage_3_be
// .//GEN-BEGIN:_addRelatedDtos_2_be
}
use of org.jaffa.modules.printing.domain.FormUsage in project jaffa-framework by jaffa-projects.
the class FormSelectionMaintenanceTx method buildOutDto.
private FormSelectionMaintenanceOutDto buildOutDto(UOW uow, Collection results, FormSelectionMaintenanceInDto input) throws FrameworkException {
FormSelectionMaintenanceOutDto output = new FormSelectionMaintenanceOutDto();
// key=outputType, value=List of Printers
Map<String, List<String>> printersPerOutputType = null;
String variation = VariationContext.getVariation();
String outputType = null;
String[] keys = new String[6];
if (input.getKey1() != null) {
String[] keyArray = input.getKey1().getValues();
keys[0] = keyArray[0];
}
if (input.getKey2() != null) {
String[] keyArray = input.getKey2().getValues();
keys[1] = keyArray[0];
}
if (input.getKey3() != null) {
String[] keyArray = input.getKey3().getValues();
keys[2] = keyArray[0];
}
if (input.getKey4() != null) {
String[] keyArray = input.getKey4().getValues();
keys[3] = keyArray[0];
}
if (input.getKey5() != null) {
String[] keyArray = input.getKey5().getValues();
keys[4] = keyArray[0];
}
if (input.getKey6() != null) {
String[] keyArray = input.getKey6().getValues();
keys[5] = keyArray[0];
}
if (log.isDebugEnabled())
log.debug("Form Selection building OutDto using Event=" + input.getEvent() + ", key1=" + keys[0] + ", key2=" + keys[1] + ", key3=" + keys[2] + ", key4=" + keys[3] + ", key5=" + keys[4] + ", key6=" + keys[5] + ", variation=" + variation);
for (Iterator i = results.iterator(); i.hasNext(); ) {
FormUsage formUsage = (FormUsage) i.next();
FormDefinition formDefinition = FormProcessor.findFormDefinition(uow, formUsage.getFormName(), formUsage.getFormAlternate(), variation, outputType, keys);
if (formDefinition != null) {
FormSelectionMaintenanceOutRowDto row = new FormSelectionMaintenanceOutRowDto();
row.setFormName(formDefinition.getFormName());
row.setCopies(formUsage.getCopies());
if (input.getEvent() != null) {
String[] mEvent = input.getEvent().getValues();
row.setEvent(mEvent[0]);
}
if (keys[0] != null) {
row.setKey1(keys[0]);
}
if (keys[1] != null) {
row.setKey2(keys[1]);
}
if (keys[2] != null) {
row.setKey3(keys[2]);
}
if (keys[3] != null) {
row.setKey4(keys[3]);
}
if (keys[4] != null) {
row.setKey5(keys[4]);
}
if (keys[5] != null) {
row.setKey6(keys[5]);
}
if (input.getValue1() != null) {
String[] mValue1 = input.getValue1().getValues();
row.setValue1(mValue1[0]);
}
if (input.getValue2() != null) {
String[] mValue2 = input.getValue2().getValues();
row.setValue2(mValue2[0]);
}
if (input.getValue3() != null) {
String[] mValue3 = input.getValue3().getValues();
row.setValue3(mValue3[0]);
}
if (input.getValue4() != null) {
String[] mValue4 = input.getValue4().getValues();
row.setValue4(mValue4[0]);
}
if (input.getValue5() != null) {
String[] mValue5 = input.getValue5().getValues();
row.setValue5(mValue5[0]);
}
if (input.getValue6() != null) {
String[] mValue6 = input.getValue6().getValues();
row.setValue6(mValue6[0]);
}
// Use the form definition selected because it may have selected the "-RL" right-to-left alternate.
if (formUsage.getFormAlternate() != null) {
row.setFormAlternateName(formDefinition.getFormAlternate());
}
row.setVariation(formDefinition.getFormVariation());
row.setAdditionalDataComponent(formDefinition.getAdditionalDataComponent());
// Query on FormGroup to find FormType.
Criteria criteria = new Criteria();
criteria.setTable(FormGroupMeta.getName());
criteria.addCriteria(FormGroupMeta.FORM_NAME, formUsage.getFormName());
Collection col = uow.query(criteria);
Iterator itr = col.iterator();
if (itr.hasNext()) {
FormGroup formGroup = (FormGroup) itr.next();
row.setFormType(formGroup.getFormType());
}
// Default the printer if possible and only if it has not already been initialized
if (row.getPrinter() == null && input.getDefaultPrinters() != null) {
// Construct a Map of valid printers per outputType
if (printersPerOutputType == null)
printersPerOutputType = determinePrintersPerOutputType(uow, input.getDefaultPrinters());
// Get the first printer for an outputType
List<String> printers = printersPerOutputType.get(formDefinition.getOutputType());
if (printers != null && printers.size() >= 0)
row.setPrinter(printers.get(0));
}
if (row.getEmail() == null && (FormPrintFactory.ENGINE_TYPE_ITEXT.equals(row.getFormType()) || FormPrintFactory.ENGINE_TYPE_FOP.equals(row.getFormType())))
row.setEmail(getUserEmail());
output.addRows(row);
}
}
return output;
}
use of org.jaffa.modules.printing.domain.FormUsage in project jaffa-framework by jaffa-projects.
the class FormEventViewerTx method addRelatedDtos.
// .//GEN-END:_buildDto_3_be
// .//GEN-BEGIN:_addRelatedDtos_1_be
private void addRelatedDtos(UOW uow, FormEventViewerOutDto output, FormEvent formEvent) throws UOWException {
// .//GEN-BEGIN:_addRelatedDtos_FormUsage_1_be
if (formEvent.getEventName() != null) {
Criteria criteria = new Criteria();
criteria.setTable(FormUsageMeta.getName());
criteria.addCriteria(FormUsageMeta.EVENT_NAME, formEvent.getEventName());
criteria.addOrderBy("FormName", Criteria.ORDER_BY_ASC);
// .//GEN-END:_addRelatedDtos_FormUsage_1_be
// Add custom code to set the criteria before the query //GEN-FIRST:_addRelatedDtos_FormUsage_1
// .//GEN-LAST:_addRelatedDtos_FormUsage_1
// .//GEN-BEGIN:_addRelatedDtos_FormUsage_2_be
Iterator itr = uow.query(criteria).iterator();
while (itr.hasNext()) {
FormUsage formUsage = (FormUsage) itr.next();
FormUsageDto dto = new FormUsageDto();
// .//GEN-END:_addRelatedDtos_FormUsage_2_be
// Add custom code before all the setters //GEN-FIRST:_addRelatedDtos_FormUsage_2
// .//GEN-LAST:_addRelatedDtos_FormUsage_2
// .//GEN-BEGIN:_addRelatedDtos_FormUsage_FormName_1_be
dto.setFormName(formUsage.getFormName());
// .//GEN-END:_addRelatedDtos_FormUsage_FormName_1_be
// .//GEN-BEGIN:_addRelatedDtos_FormUsage_EventName_1_be
dto.setEventName(formUsage.getEventName());
// .//GEN-END:_addRelatedDtos_FormUsage_EventName_1_be
// .//GEN-BEGIN:_addRelatedDtos_FormUsage_FormAlternate_1_be
dto.setFormAlternate(formUsage.getFormAlternate());
// .//GEN-END:_addRelatedDtos_FormUsage_FormAlternate_1_be
// .//GEN-BEGIN:_addRelatedDtos_FormUsage_Copies_1_be
dto.setCopies(formUsage.getCopies());
// .//GEN-END:_addRelatedDtos_FormUsage_Copies_1_be
// .//GEN-BEGIN:_addRelatedDtos_FormUsage_CreatedOn_1_be
dto.setCreatedOn(formUsage.getCreatedOn());
// .//GEN-END:_addRelatedDtos_FormUsage_CreatedOn_1_be
// .//GEN-BEGIN:_addRelatedDtos_FormUsage_CreatedBy_1_be
dto.setCreatedBy(formUsage.getCreatedBy());
// .//GEN-END:_addRelatedDtos_FormUsage_CreatedBy_1_be
// .//GEN-BEGIN:_addRelatedDtos_FormUsage_LastChangedOn_1_be
dto.setLastChangedOn(formUsage.getLastChangedOn());
// .//GEN-END:_addRelatedDtos_FormUsage_LastChangedOn_1_be
// .//GEN-BEGIN:_addRelatedDtos_FormUsage_LastChangedBy_1_be
dto.setLastChangedBy(formUsage.getLastChangedBy());
// .//GEN-END:_addRelatedDtos_FormUsage_LastChangedBy_1_be
// Add custom code to pass values to the dto //GEN-FIRST:_addRelatedDtos_FormUsage_3
// .//GEN-LAST:_addRelatedDtos_FormUsage_3
// .//GEN-BEGIN:_addRelatedDtos_FormUsage_3_be
output.addFormUsage(dto);
}
}
// .//GEN-END:_addRelatedDtos_FormUsage_3_be
// .//GEN-BEGIN:_addRelatedDtos_2_be
}
Aggregations