Search in sources :

Example 66 with DateTime

use of org.jaffa.datatypes.DateTime in project jaffa-framework by jaffa-projects.

the class FormDataWrapper method addOutputCommands.

private void addOutputCommands(Connection connection) throws SQLException {
    // 1=OUTPUT_COMMAND_ID, OUTPUT_TYPE, SEQUENCE_NO, OS_PATTERN, COMMAND_LINE
    // 6=CREATED_ON, CREATED_BY, LAST_CHANGED_ON, LAST_CHANGED_BY
    String sql = "insert into J_OUTPUT_COMMANDS values (?,?,?,?,?,  ?,?,?,?)";
    PreparedStatement pstmnt = connection.prepareStatement(sql);
    // Create first record
    pstmnt.setLong(1, 1000000);
    pstmnt.setString(2, "PDF");
    pstmnt.setLong(3, 1);
    pstmnt.setString(4, "Windows.*");
    // pstmnt.setString(5, "\"c:\\Program Files\\Adobe\\Acrobat 5.0\\Acrobat\\Acrobat.exe\" /t {0} {1} {2} {3}");
    pstmnt.setString(5, "\"C:\\Program Files\\Ghostgum\\gsview\\gsprint\" -printer \"{1}\" {2} {3} {0}");
    pstmnt.setTimestamp(6, DateTime.addMonth(new DateTime(), -2).timestamp());
    pstmnt.setString(7, "user2");
    pstmnt.setTimestamp(8, (new DateTime()).timestamp());
    pstmnt.setString(9, "user3");
    pstmnt.execute();
    pstmnt.clearParameters();
    // Create second record
    pstmnt.setLong(1, 1000001);
    pstmnt.setString(2, "PDF");
    pstmnt.setLong(3, 2);
    pstmnt.setString(4, ".*");
    pstmnt.setString(5, "/usr/gs/gsview \"{0}\" -p\"{1}\" {2} {3}");
    pstmnt.setTimestamp(6, DateTime.addMonth(new DateTime(), -2).timestamp());
    pstmnt.setString(7, "user2");
    pstmnt.setTimestamp(8, null);
    pstmnt.setString(9, null);
    pstmnt.execute();
    pstmnt.clearParameters();
    // Print on unix
    // pstmnt.setString(5, "lp -d\"{1}\" {2} {3} \"{0}\" ");
    pstmnt.close();
}
Also used : PreparedStatement(java.sql.PreparedStatement) DateTime(org.jaffa.datatypes.DateTime)

Example 67 with DateTime

use of org.jaffa.datatypes.DateTime in project jaffa-framework by jaffa-projects.

the class FormDataWrapper method addPrinterDefinitions.

private void addPrinterDefinitions(Connection connection) throws SQLException {
    // 1=PRINTER_ID, DESCRIPTION, SITE_CODE, LOCATION_CODE, REMOTE_PRINTER,
    // 6=REAL_PRINTER_NAME, PRINTER_OPTION1, PRINTER_OPTION2, OUTPUT_TYPE, CREATED_ON
    // 11=CREATED_BY, LAST_CHANGED_ON, LAST_CHANGED_BY
    String sql = "insert into J_PRINTER_DEFINITIONS values (?,?,?,?,?,  ?,?,?,?,?,  ?,?,?)";
    PreparedStatement pstmnt = connection.prepareStatement(sql);
    // Create first record
    pstmnt.setString(1, VAILD_PDF_PRINTER);
    pstmnt.setString(2, "Main Laser Printer");
    pstmnt.setString(3, "UTC");
    pstmnt.setString(4, "Copier Room");
    pstmnt.setBoolean(5, false);
    pstmnt.setString(6, REAL_PDF_PRINTER);
    pstmnt.setString(7, "-color");
    pstmnt.setString(8, null);
    pstmnt.setString(9, "PDF");
    pstmnt.setTimestamp(10, DateTime.addMonth(new DateTime(), -2).timestamp());
    pstmnt.setString(11, "user2");
    pstmnt.setTimestamp(12, (new DateTime()).timestamp());
    pstmnt.setString(13, "user3");
    pstmnt.execute();
    pstmnt.clearParameters();
    // Create second record
    pstmnt.setString(1, VAILD_LABEL_PRINTER);
    pstmnt.setString(2, "Intermec 3400D Label Printer");
    pstmnt.setString(3, "UTC");
    pstmnt.setString(4, "Main Hall");
    pstmnt.setBoolean(5, false);
    pstmnt.setString(6, "\\\\Hematite\\barcode1");
    pstmnt.setString(7, null);
    pstmnt.setString(8, null);
    pstmnt.setString(9, "Intermec 3400D");
    pstmnt.setTimestamp(10, DateTime.addMonth(new DateTime(), -2).timestamp());
    pstmnt.setString(11, "user2");
    pstmnt.setTimestamp(12, null);
    pstmnt.setString(13, null);
    pstmnt.execute();
    pstmnt.close();
}
Also used : PreparedStatement(java.sql.PreparedStatement) DateTime(org.jaffa.datatypes.DateTime)

Example 68 with DateTime

use of org.jaffa.datatypes.DateTime in project jaffa-framework by jaffa-projects.

the class FormDataWrapper method addOutputTypes.

private void addOutputTypes(Connection connection) throws SQLException {
    // 1=OUTPUT_TYPE, DESCRIPTION, DIRECT_PRINTING, CREATED_ON, CREATED_BY
    // 6=LAST_CHANGED_ON, LAST_CHANGED_BY
    String sql = "insert into J_OUTPUT_TYPES values (?,?,?,?,?,  ?,?)";
    PreparedStatement pstmnt = connection.prepareStatement(sql);
    // Create first record
    pstmnt.setString(1, "PDF");
    pstmnt.setString(2, "Portable Document Format");
    pstmnt.setBoolean(3, false);
    pstmnt.setTimestamp(4, DateTime.addMonth(new DateTime(), -2).timestamp());
    pstmnt.setString(5, "user2");
    pstmnt.setTimestamp(6, (new DateTime()).timestamp());
    pstmnt.setString(7, "user3");
    pstmnt.execute();
    pstmnt.clearParameters();
    // Create second record
    pstmnt.setString(1, "Intermec 3400D");
    pstmnt.setString(2, "Intermec 3400D Label Printer");
    pstmnt.setBoolean(3, true);
    pstmnt.setTimestamp(4, DateTime.addMonth(new DateTime(), -2).timestamp());
    pstmnt.setString(5, "user2");
    pstmnt.setTimestamp(6, null);
    pstmnt.setString(7, null);
    pstmnt.execute();
    pstmnt.close();
}
Also used : PreparedStatement(java.sql.PreparedStatement) DateTime(org.jaffa.datatypes.DateTime)

Example 69 with DateTime

use of org.jaffa.datatypes.DateTime 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;
}
Also used : ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) ValidationException(org.jaffa.datatypes.ValidationException) FormDefinition(org.jaffa.modules.printing.domain.FormDefinition) DateTime(org.jaffa.datatypes.DateTime)

Example 70 with DateTime

use of org.jaffa.datatypes.DateTime 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);
    }
}
Also used : IVoucherGenerator(org.jaffa.components.voucher.IVoucherGenerator) DateTime(org.jaffa.datatypes.DateTime) Date(java.util.Date)

Aggregations

DateTime (org.jaffa.datatypes.DateTime)74 Criteria (org.jaffa.persistence.Criteria)16 UOW (org.jaffa.persistence.UOW)11 AtomicCriteria (org.jaffa.persistence.AtomicCriteria)9 PreparedStatement (java.sql.PreparedStatement)8 ValidationException (org.jaffa.datatypes.ValidationException)8 ApplicationExceptions (org.jaffa.exceptions.ApplicationExceptions)8 Iterator (java.util.Iterator)7 Map (java.util.Map)5 Date (java.util.Date)4 FrameworkException (org.jaffa.exceptions.FrameworkException)4 LinkedHashMap (java.util.LinkedHashMap)3 JMSException (javax.jms.JMSException)3 MarshallException (org.directwebremoting.extend.MarshallException)3 CheckBoxModel (org.jaffa.presentation.portlet.widgets.model.CheckBoxModel)3 DateTimeModel (org.jaffa.presentation.portlet.widgets.model.DateTimeModel)3 DropDownModel (org.jaffa.presentation.portlet.widgets.model.DropDownModel)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 Enumeration (java.util.Enumeration)2 LinkedList (java.util.LinkedList)2