use of org.jaffa.components.voucher.IVoucherGenerator in project jaffa-framework by jaffa-projects.
the class BusinessEventLog method validate.
// .//GEN-END:performPreDeleteReferentialIntegrity_1_be
// All the custom code goes here//GEN-FIRST:custom
/**
* {@inheritDoc}
*/
@Override
public void validate() throws ApplicationExceptions, FrameworkException {
// Generate the technical-key, if required
if (getLogId() == null) {
try {
IVoucherGenerator vg = VoucherGeneratorFactory.instance();
vg.setUow(getUOW());
vg.setDomainClassName(getClass().getName());
vg.setFieldName(BusinessEventLogMeta.LOG_ID);
vg.setLabelToken(BusinessEventLogMeta.META_LOG_ID.getLabelToken());
setLogId(vg.generate());
} catch (ValidationException e) {
throw new ApplicationExceptions(e);
}
}
super.validate();
}
use of org.jaffa.components.voucher.IVoucherGenerator in project jaffa-framework by jaffa-projects.
the class AuditTransaction method generateKey.
/**
* Generate the technical-key, if required.
*/
public void generateKey() throws ApplicationExceptions, FrameworkException {
if (getTransactionId() == null) {
try {
IVoucherGenerator vg = VoucherGeneratorFactory.instance();
vg.setUow(getUOW());
vg.setDomainClassName(getClass().getName());
vg.setFieldName(AuditTransactionMeta.TRANSACTION_ID);
vg.setLabelToken(AuditTransactionMeta.META_TRANSACTION_ID.getLabelToken());
setTransactionId(vg.generate());
} catch (ValidationException e) {
throw new ApplicationExceptions(e);
}
}
}
use of org.jaffa.components.voucher.IVoucherGenerator in project jaffa-framework by jaffa-projects.
the class AuditTransactionField method generateKey.
/**
* Generate the technical-key, if required.
*/
public void generateKey() throws ApplicationExceptions, FrameworkException {
if (getFieldId() == null) {
try {
IVoucherGenerator vg = VoucherGeneratorFactory.instance();
vg.setUow(getUOW());
vg.setDomainClassName(getClass().getName());
vg.setFieldName(AuditTransactionFieldMeta.FIELD_ID);
vg.setLabelToken(AuditTransactionFieldMeta.META_FIELD_ID.getLabelToken());
setFieldId(vg.generate());
} catch (ValidationException e) {
throw new ApplicationExceptions(e);
}
}
}
use of org.jaffa.components.voucher.IVoucherGenerator in project jaffa-framework by jaffa-projects.
the class QuartzSchedulerHelper method addTask.
/**
* Adds the Task to the Scheduler.
*
* @param task the Task.
* @throws FrameworkException in case any internal error occurs.
* @throws ApplicationExceptions Indicates application error(s).
*/
public void addTask(ScheduledTask task) throws FrameworkException, ApplicationExceptions {
// Ensure that the Scheduler is available
checkScheduler();
if (LOGGER.isDebugEnabled())
LOGGER.debug("Adding " + task);
// Validate the Task
prevalidate(task);
// Voucher the technical key
if (task.getScheduledTaskId() == null || task.getScheduledTaskId().length() == 0) {
IVoucherGenerator vg = VoucherGeneratorFactory.instance();
vg.setDomainClassName(ScheduledTask.class.getName());
vg.setFieldName(BusinessEventLogMeta.SCHEDULED_TASK_ID);
vg.setLabelToken(BusinessEventLogMeta.META_SCHEDULED_TASK_ID.getLabelToken());
task.setScheduledTaskId(vg.generate());
}
// Stamp CreatedBy and CreatedOn
if (task.getCreatedBy() == null && SecurityManager.getPrincipal() != null)
task.setCreatedBy(SecurityManager.getPrincipal().getName());
if (task.getCreatedOn() == null)
task.setCreatedOn(new DateTime());
// Create the Job and Trigger
final JobDetail job = taskToJob(task);
final Trigger trigger = TriggerHelper.taskToTrigger(task);
// Schedule the Task
try {
final Date ft = scheduler.scheduleJob(job, trigger);
if (LOGGER.isInfoEnabled())
LOGGER.info(task.getScheduledTaskId() + " has been scheduled to run at: " + ft + (trigger instanceof CronTrigger ? " and repeat based on expression: " + ((CronTrigger) trigger).getCronExpression() : ""));
} catch (SchedulerException e) {
LOGGER.error("Error adding task in scheduler " + task.getScheduledTaskId(), e);
// else
throw new JaffaSchedulerFrameworkException(JaffaSchedulerFrameworkException.ADD_TASK_ERROR, new Object[] { task.getScheduledTaskId() }, e);
}
}
use of org.jaffa.components.voucher.IVoucherGenerator in project jaffa-framework by jaffa-projects.
the class Transaction method generateKey.
/**
* Generate the technical-key, if required.
*/
public void generateKey() throws ApplicationExceptions, FrameworkException {
if (getId() == null) {
try {
IVoucherGenerator vg = VoucherGeneratorFactory.instance();
vg.setUow(getUOW());
vg.setDomainClassName(getClass().getName());
vg.setFieldName(TransactionMeta.ID);
vg.setLabelToken(TransactionMeta.META_ID.getLabelToken());
setId(vg.generate());
} catch (ValidationException e) {
throw new ApplicationExceptions(e);
}
}
}
Aggregations