use of org.jaffa.components.attachment.domain.Attachment in project jaffa-framework by jaffa-projects.
the class BusinessEventLogViewerTx method addRelatedDtos.
// .//GEN-END:_buildDto_3_be
// .//GEN-BEGIN:_addRelatedDtos_1_be
private void addRelatedDtos(UOW uow, BusinessEventLogViewerOutDto output, BusinessEventLog businessEventLog) throws UOWException {
// .//GEN-BEGIN:_addRelatedDtos_Attachment_1_be
if (businessEventLog.getLogId() != null) {
Criteria criteria = new Criteria();
criteria.setTable(AttachmentMeta.getName());
criteria.addCriteria(AttachmentMeta.SERIALIZED_KEY, businessEventLog.getLogId());
criteria.addOrderBy("AttachmentId", Criteria.ORDER_BY_ASC);
// Create a new Criteria, and pass the correct serializedKey
try {
criteria = new Criteria();
criteria.setTable(AttachmentMeta.getName());
criteria.addCriteria(AttachmentMeta.SERIALIZED_KEY, PersistentHelper.generateSerializedKey(businessEventLog));
criteria.addOrderBy(AttachmentMeta.ATTACHMENT_ID, Criteria.ORDER_BY_ASC);
} catch (Exception e) {
String str = "Error in generating the serialized key";
log.error(str, e);
throw new RuntimeException(str, e);
}
// .//GEN-LAST:_addRelatedDtos_Attachment_1
// .//GEN-BEGIN:_addRelatedDtos_Attachment_2_be
Iterator itr = uow.query(criteria).iterator();
while (itr.hasNext()) {
Attachment attachment = (Attachment) itr.next();
AttachmentDto dto = new AttachmentDto();
// .//GEN-END:_addRelatedDtos_Attachment_2_be
// Add custom code before all the setters//GEN-FIRST:_addRelatedDtos_Attachment_2
// .//GEN-LAST:_addRelatedDtos_Attachment_2
// .//GEN-BEGIN:_addRelatedDtos_Attachment_AttachmentId_1_be
dto.setAttachmentId(attachment.getAttachmentId());
// .//GEN-END:_addRelatedDtos_Attachment_AttachmentId_1_be
// .//GEN-BEGIN:_addRelatedDtos_Attachment_SerializedKey_1_be
dto.setSerializedKey(attachment.getSerializedKey());
// .//GEN-END:_addRelatedDtos_Attachment_SerializedKey_1_be
// .//GEN-BEGIN:_addRelatedDtos_Attachment_OriginalFileName_1_be
dto.setOriginalFileName(attachment.getOriginalFileName());
// .//GEN-END:_addRelatedDtos_Attachment_OriginalFileName_1_be
// .//GEN-BEGIN:_addRelatedDtos_Attachment_AttachmentType_1_be
dto.setAttachmentType(attachment.getAttachmentType());
// .//GEN-END:_addRelatedDtos_Attachment_AttachmentType_1_be
// .//GEN-BEGIN:_addRelatedDtos_Attachment_ContentType_1_be
dto.setContentType(attachment.getContentType());
// .//GEN-END:_addRelatedDtos_Attachment_ContentType_1_be
// .//GEN-BEGIN:_addRelatedDtos_Attachment_Description_1_be
dto.setDescription(attachment.getDescription());
// .//GEN-END:_addRelatedDtos_Attachment_Description_1_be
// .//GEN-BEGIN:_addRelatedDtos_Attachment_Remarks_1_be
dto.setRemarks(attachment.getRemarks());
// .//GEN-END:_addRelatedDtos_Attachment_Remarks_1_be
// .//GEN-BEGIN:_addRelatedDtos_Attachment_SupercededBy_1_be
dto.setSupercededBy(attachment.getSupercededBy());
// .//GEN-END:_addRelatedDtos_Attachment_SupercededBy_1_be
// .//GEN-BEGIN:_addRelatedDtos_Attachment_CreatedOn_1_be
dto.setCreatedOn(attachment.getCreatedOn());
// .//GEN-END:_addRelatedDtos_Attachment_CreatedOn_1_be
// .//GEN-BEGIN:_addRelatedDtos_Attachment_CreatedBy_1_be
dto.setCreatedBy(attachment.getCreatedBy());
// .//GEN-END:_addRelatedDtos_Attachment_CreatedBy_1_be
// .//GEN-BEGIN:_addRelatedDtos_Attachment_LastChangedOn_1_be
dto.setLastChangedOn(attachment.getLastChangedOn());
// .//GEN-END:_addRelatedDtos_Attachment_LastChangedOn_1_be
// .//GEN-BEGIN:_addRelatedDtos_Attachment_LastChangedBy_1_be
dto.setLastChangedBy(attachment.getLastChangedBy());
// .//GEN-END:_addRelatedDtos_Attachment_LastChangedBy_1_be
// .//GEN-BEGIN:_addRelatedDtos_Attachment_Data_1_be
dto.setData(attachment.getData());
// .//GEN-END:_addRelatedDtos_Attachment_Data_1_be
// Add custom code to pass values to the dto//GEN-FIRST:_addRelatedDtos_Attachment_3
// .//GEN-LAST:_addRelatedDtos_Attachment_3
// .//GEN-BEGIN:_addRelatedDtos_Attachment_3_be
output.addAttachment(dto);
}
}
// .//GEN-END:_addRelatedDtos_Attachment_3_be
// .//GEN-BEGIN:_addRelatedDtos_2_be
}
use of org.jaffa.components.attachment.domain.Attachment in project jaffa-framework by jaffa-projects.
the class AttachmentMaintenanceTx method createDomain.
// .//GEN-END:_duplicateCheck_4_be
// .//GEN-BEGIN:_createDomain_1_be
/**
* Create the domain object.
*/
private Attachment createDomain(UOW uow, AttachmentMaintenanceCreateInDto input, boolean fromPrevalidate) throws FrameworkException, ApplicationExceptions {
Attachment domain = new Attachment();
ApplicationExceptions appExps = null;
// .//GEN-BEGIN:_createDomain_2_be
try {
domain.updateAttachmentId(input.getAttachmentId());
} catch (ValidationException e) {
if (appExps == null)
appExps = new ApplicationExceptions();
appExps.add(e);
}
try {
domain.updateSerializedKey(input.getSerializedKey());
} catch (ValidationException e) {
if (appExps == null)
appExps = new ApplicationExceptions();
appExps.add(e);
}
try {
domain.updateOriginalFileName(input.getOriginalFileName());
} catch (ValidationException e) {
if (appExps == null)
appExps = new ApplicationExceptions();
appExps.add(e);
}
try {
domain.updateAttachmentType(input.getAttachmentType());
} catch (ValidationException e) {
if (appExps == null)
appExps = new ApplicationExceptions();
appExps.add(e);
}
try {
domain.updateContentType(input.getContentType());
} 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.updateSupercededBy(input.getSupercededBy());
} 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);
}
try {
domain.updateData(input.getData());
} 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.components.attachment.domain.Attachment in project jaffa-framework by jaffa-projects.
the class AttachmentMaintenanceTx 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 Attachment.
* @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 AttachmentMaintenancePrevalidateOutDto prevalidateCreate(AttachmentMaintenanceCreateInDto input) throws FrameworkException, ApplicationExceptions {
UOW uow = null;
try {
// Print Debug Information for the input
if (log.isDebugEnabled())
log.debug("Input: " + input);
// 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
Attachment domain = createDomain(uow, input, true);
domain = postCreate(uow, input, domain, true);
// Build the outbound dto
AttachmentMaintenancePrevalidateOutDto output = createPrevalidateOutDto(uow, domain, input);
// Print Debug Information for the output
if (log.isDebugEnabled())
log.debug("Output: " + output);
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.components.attachment.domain.Attachment in project jaffa-framework by jaffa-projects.
the class AttachmentHandler method endBeanAdd.
public void endBeanAdd(String path, Object source, Object target) throws ApplicationException, ApplicationExceptions, FrameworkException {
if (source instanceof AttachmentGraph && target instanceof Attachment) {
AttachmentGraph attachmentGraph = (AttachmentGraph) source;
Attachment attachment = (Attachment) target;
IAttachmentData attachmentDataImpl = AttachmentFactory.getAttachmentDataImpl();
if (attachmentDataImpl != null && attachment.getDocumentReferenceId() != null) {
if (attachmentDataImpl.read(attachment.getDocumentReferenceId()) == null) {
attachmentDataImpl.create(attachment.getDocumentReferenceId(), attachmentGraph.getData());
}
}
}
}
use of org.jaffa.components.attachment.domain.Attachment in project jaffa-framework by jaffa-projects.
the class AttachmentHandler method endBeanLoad.
/**
* Called after a bean has been loaded.
* @param path This is the source path of this graph, used when processing a more complex tree, where this is the path to get to this root object being processed.
* @param source the domain object that was just queried.
* @param target the graph object being molded.
* @param filter Filter object that it is used to control what fields are populated or the target objects.
* @param originalCriteria the original graph criteria.
* @throws ApplicationException if any Application error occurs.
* @throws ApplicationExceptions if multiple Application errors occur.
* @throws FrameworkException if an internal error occurs.
*/
@Override
public void endBeanLoad(String path, Object source, Object target, MappingFilter filter, GraphCriteria originalCriteria) throws ApplicationException, ApplicationExceptions, FrameworkException {
checkFunctionAccess((Attachment) source, false);
if (source instanceof Attachment && target instanceof AttachmentGraph) {
AttachmentGraph attachmentGraph = (AttachmentGraph) target;
Attachment attachment = (Attachment) source;
IAttachmentData attachmentDataImpl = AttachmentFactory.getAttachmentDataImpl();
if (attachmentDataImpl != null && attachment.getDocumentReferenceId() != null && (originalCriteria.getResultGraphRules() == null || originalCriteria.getResultGraphRules().length == 0 || !Arrays.asList(originalCriteria.getResultGraphRules()).contains("-data"))) {
byte[] data = attachmentDataImpl.read(attachment.getDocumentReferenceId());
if (data != null) {
attachmentGraph.setData(data);
}
}
}
}
Aggregations