Search in sources :

Example 26 with DateTime

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

the class FormDataWrapper method addFormGroups.

private void addFormGroups(Connection connection) throws SQLException {
    String sql = "insert into J_FORM_GROUPS values (?,?,?,?,?,?,?)";
    PreparedStatement pstmnt = connection.prepareStatement(sql);
    // Create first record
    pstmnt.setString(1, FORM_NAME);
    pstmnt.setString(2, FORM_NAME + " Description");
    pstmnt.setString(3, FormPrintFactory.ENGINE_TYPE_ITEXT);
    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, FORM_NAME2);
    pstmnt.setString(2, FORM_NAME2 + " Description");
    pstmnt.setString(3, FormPrintFactory.ENGINE_TYPE_VELOCITY);
    pstmnt.setTimestamp(4, DateTime.addMonth(new DateTime(), -2).timestamp());
    pstmnt.setString(5, "user2");
    pstmnt.setTimestamp(6, null);
    pstmnt.setString(7, null);
    pstmnt.execute();
    pstmnt.clearParameters();
    // Create thrid record
    pstmnt.setString(1, FORM_NAME3);
    pstmnt.setString(2, FORM_NAME3 + " Description");
    pstmnt.setString(3, FormPrintFactory.ENGINE_TYPE_ITEXT);
    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();
    pstmnt.close();
}
Also used : PreparedStatement(java.sql.PreparedStatement) DateTime(org.jaffa.datatypes.DateTime)

Example 27 with DateTime

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

the class UserDataWrapper method addUsers.

private void addUsers(Connection connection) throws SQLException {
    // 1=USER_NAME*, FIRST_NAME*, LAST_NAME*, PASSWORD*, STATUS*,
    // 6=E_MAIL_ADDRESS, CREATED_DATETIME, CREATED_USER, LAST_UPDATE_DATETIME, LAST_UPDATE_USER,
    // 11=COMMENTS
    String sql = "insert into USERS values (?,?,?,?,?,  ?,?,?,?,?, ?)";
    PreparedStatement pstmnt = connection.prepareStatement(sql);
    // Create first record
    pstmnt.setString(1, USER1);
    pstmnt.setString(2, USER1);
    pstmnt.setString(3, USER1);
    pstmnt.setString(4, PASSWORD);
    pstmnt.setString(5, "A");
    pstmnt.setString(6, EMAIL);
    pstmnt.setTimestamp(7, DateTime.addMonth(new DateTime(), -2).timestamp());
    pstmnt.setString(8, "user2");
    pstmnt.setTimestamp(9, (new DateTime()).timestamp());
    pstmnt.setString(10, "user3");
    pstmnt.setString(11, "No Comment!");
    pstmnt.execute();
    addUserRoles(connection, USER1, USER1_ROLES);
    pstmnt.clearParameters();
    // Create second record
    pstmnt.setString(1, USER2);
    pstmnt.setString(2, USER2);
    pstmnt.setString(3, USER2);
    pstmnt.setString(4, PASSWORD);
    pstmnt.setString(5, "A");
    pstmnt.setString(6, EMAIL);
    pstmnt.setTimestamp(7, DateTime.addMonth(new DateTime(), -2).timestamp());
    pstmnt.setString(8, "user2");
    pstmnt.setTimestamp(9, null);
    pstmnt.setString(10, null);
    pstmnt.setString(11, "No Comment!");
    pstmnt.execute();
    addUserRoles(connection, USER2, USER2_ROLES);
    pstmnt.close();
}
Also used : PreparedStatement(java.sql.PreparedStatement) DateTime(org.jaffa.datatypes.DateTime)

Example 28 with DateTime

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

the class FormUsageMaintenanceTx method createDomain.

// .//GEN-END:_duplicateCheck_4_be
// .//GEN-BEGIN:_createDomain_1_be
/**
 * Create the domain object.
 */
private FormUsage createDomain(UOW uow, FormUsageMaintenanceCreateInDto input, boolean fromPrevalidate) throws FrameworkException, ApplicationExceptions {
    FormUsage domain = new FormUsage();
    ApplicationExceptions appExps = null;
    // .//GEN-BEGIN:_createDomain_2_be
    try {
        domain.updateFormAlternate(input.getFormAlternate());
    } catch (ValidationException e) {
        if (appExps == null)
            appExps = new ApplicationExceptions();
        appExps.add(e);
    }
    try {
        domain.updateCopies(input.getCopies());
    } 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.updateEventName(input.getEventName());
    } 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);
    }
    // .//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) DateTime(org.jaffa.datatypes.DateTime) FormUsage(org.jaffa.modules.printing.domain.FormUsage)

Example 29 with DateTime

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

the class PrinterOutputTypeMaintenanceTx method createDomain.

// .//GEN-END:_duplicateCheck_4_be
// .//GEN-BEGIN:_createDomain_1_be
/**
 * Create the domain object.
 */
private PrinterOutputType createDomain(UOW uow, PrinterOutputTypeMaintenanceCreateInDto input, boolean fromPrevalidate) throws FrameworkException, ApplicationExceptions {
    PrinterOutputType domain = new PrinterOutputType();
    ApplicationExceptions appExps = null;
    // .//GEN-BEGIN:_createDomain_2_be
    try {
        domain.updateOutputType(input.getOutputType());
    } 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.updateDirectPrinting(input.getDirectPrinting());
    } 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 : PrinterOutputType(org.jaffa.modules.printing.domain.PrinterOutputType) ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) ValidationException(org.jaffa.datatypes.ValidationException) DateTime(org.jaffa.datatypes.DateTime)

Example 30 with DateTime

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

the class JmsQueueAdmin method createMessageGraph.

/**
 * Molds the input JMS Message into a MessageGraph.
 */
private static MessageGraph createMessageGraph(Message message, String queueName, PropertyFilter pf) throws JMSException, IntrospectionException {
    MessageGraph graph = new MessageGraph();
    graph.setQueueMetaData(createQueueMetaData(queueName, pf));
    if (pf.isFieldIncluded("type"))
        graph.setType(queueName);
    if (pf.isFieldIncluded("messageId"))
        graph.setMessageId(message.getJMSMessageID());
    if (pf.isFieldIncluded("priority"))
        graph.setPriority(new Long(message.getJMSPriority()));
    if (pf.isFieldIncluded("createdOn"))
        graph.setCreatedOn(message.getJMSTimestamp() != 0 ? new DateTime(message.getJMSTimestamp()) : null);
    if (pf.isFieldIncluded("createdBy"))
        graph.setCreatedBy(message.getStringProperty(JmsBrowser.HEADER_USER_ID));
    if (pf.isFieldIncluded("errorMessage"))
        graph.setErrorMessage(message.getStringProperty(JmsBrowser.HEADER_ERROR_DETAILS));
    if (pf.isFieldIncluded("payload") && message instanceof TextMessage)
        graph.setPayload(((TextMessage) message).getText());
    if (pf.isFieldIncluded("hasAdminAccess"))
        graph.setHasAdminAccess(JmsBrowser.hasAdminMessageAccess(queueName));
    if (pf.isFieldIncluded("applicationFields") || pf.isFieldIncluded("technicalFields")) {
        // Generate a Map of header elements, keyed by the name of each header element
        // Names beginning with JMS and jaffa_ will be treated as techincal, while the rest will be assumed to be application-specific
        Map<String, MessageField> applicationFields = new LinkedHashMap<String, MessageField>();
        Map<String, MessageField> technicalFields = new TreeMap<String, MessageField>();
        for (Enumeration e = message.getPropertyNames(); e.hasMoreElements(); ) {
            String name = (String) e.nextElement();
            String value = Formatter.format(message.getObjectProperty(name));
            MessageField messageField = new MessageField();
            messageField.setName(name);
            messageField.setValue(value);
            if (name.startsWith("JMS") || name.startsWith("jaffa_"))
                technicalFields.put(name, messageField);
            else
                applicationFields.put(name, messageField);
        }
        // Treat all the JMS* properties of the Message as technical
        if (pf.isFieldIncluded("technicalFields")) {
            BeanInfo beanInfo = Introspector.getBeanInfo(Message.class);
            if (beanInfo != null) {
                PropertyDescriptor[] pds = beanInfo.getPropertyDescriptors();
                if (pds != null) {
                    for (PropertyDescriptor pd : pds) {
                        if (pd.getReadMethod() != null && !pd.getPropertyType().isArray()) {
                            String name = pd.getName();
                            try {
                                Object value = pd.getReadMethod().invoke(message);
                                MessageField messageField = new MessageField();
                                messageField.setName(name);
                                messageField.setValue(Formatter.format(value));
                                technicalFields.put(name, messageField);
                            } catch (Exception e) {
                                if (log.isDebugEnabled())
                                    log.debug("Exception thrown while reading Message property: " + name, e);
                            }
                        }
                    }
                }
            }
            if (!technicalFields.isEmpty())
                graph.setTechnicalFields(technicalFields.values().toArray(new MessageField[technicalFields.size()]));
        }
        // Add labels to the application-fields from the configuration-file
        if (pf.isFieldIncluded("applicationFields")) {
            QueueInfo queueInfo = ConfigurationService.getInstance().getQueueInfo(queueName);
            if (queueInfo != null && queueInfo.getDisplayParam() != null) {
                for (DisplayParam displayParam : queueInfo.getDisplayParam()) {
                    if (displayParam.getLabel() != null && applicationFields.containsKey(displayParam.getName()))
                        applicationFields.get(displayParam.getName()).setLabel(MessageHelper.replaceTokens(displayParam.getLabel()));
                }
            }
            if (!applicationFields.isEmpty())
                graph.setApplicationFields(applicationFields.values().toArray(new MessageField[applicationFields.size()]));
        }
    }
    return graph;
}
Also used : QueueInfo(org.jaffa.modules.messaging.services.configdomain.QueueInfo) Enumeration(java.util.Enumeration) PropertyDescriptor(java.beans.PropertyDescriptor) BeanInfo(java.beans.BeanInfo) TreeMap(java.util.TreeMap) DateTime(org.jaffa.datatypes.DateTime) MessageField(org.jaffa.qm.apis.data.MessageField) JMSException(javax.jms.JMSException) IntrospectionException(java.beans.IntrospectionException) LinkedHashMap(java.util.LinkedHashMap) MessageGraph(org.jaffa.qm.apis.data.MessageGraph) DisplayParam(org.jaffa.modules.messaging.services.configdomain.DisplayParam) TextMessage(javax.jms.TextMessage)

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