Search in sources :

Example 1 with DateTime

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

the class PrinterDefinitionGraph method setLastChangedOn.

/**
 * @param lastChangedOn the lastChangedOn to set
 */
public void setLastChangedOn(DateTime lastChangedOn) {
    DateTime oldLastChangedOn = this.lastChangedOn;
    this.lastChangedOn = lastChangedOn;
    propertyChangeSupport.firePropertyChange("lastChangedOn", oldLastChangedOn, lastChangedOn);
}
Also used : DateTime(org.jaffa.datatypes.DateTime)

Example 2 with DateTime

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

the class PrinterDefinitionGraph method setCreatedOn.

/**
 * @param createdOn the createdOn to set
 */
public void setCreatedOn(DateTime createdOn) {
    DateTime oldCreatedOn = this.createdOn;
    this.createdOn = createdOn;
    propertyChangeSupport.firePropertyChange("createdOn", oldCreatedOn, createdOn);
}
Also used : DateTime(org.jaffa.datatypes.DateTime)

Example 3 with DateTime

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

the class FormDefinitionMaintenanceTx method updateDomain.

// .//GEN-END:_loadUpdate_3_be
// .//GEN-BEGIN:_updateDomain_1_be
/**
 * Update the domain object and add it to the UOW.
 */
private void updateDomain(UOW uow, FormDefinitionMaintenanceUpdateInDto input, FormDefinition domain, boolean fromPrevalidate) throws FrameworkException, ApplicationExceptions {
    ApplicationExceptions appExps = null;
    // .//GEN-END:_updateDomain_1_be
    // Add custom code//GEN-FIRST:_updateDomain_1
    // if FormTemplate and FieldLayout fields are null, set them to their current domain values, so
    // the generated code does not set them to null.
    String origFormTemplate = input.getFormTemplate();
    String origFieldLayout = input.getFieldLayout();
    if (input.getFormTemplate() == null)
        input.setFormTemplate(domain.getFormTemplate());
    if (input.getFieldLayout() == null)
        input.setFieldLayout(domain.getFieldLayout());
    // .//GEN-BEGIN:_updateDomain_2_be
    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.updateLastChangedOn(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.updateLastChangedBy(input.getHeaderDto().getUserId());
    } catch (ValidationException e) {
        if (appExps == null)
            appExps = new ApplicationExceptions();
        appExps.add(e);
    }
    // .//GEN-END:_updateDomain_2_be
    // Add custom code//GEN-FIRST:_updateDomain_2
    // Restore the original value in the input object incase any other logic relies on them
    input.setFormTemplate(origFormTemplate);
    input.setFieldLayout(origFieldLayout);
    // .//GEN-BEGIN:_updateDomain_3_be
    if (appExps != null && appExps.size() > 0)
        throw appExps;
}
Also used : ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) ValidationException(org.jaffa.datatypes.ValidationException) DateTime(org.jaffa.datatypes.DateTime)

Example 4 with DateTime

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

the class MessageViewerTx method buildDto.

/**
 * Obtains the Message based on the messageMode and creates the output.
 */
private MessageViewerOutDto buildDto(MessageViewerInDto input) throws FrameworkException, ApplicationExceptions {
    try {
        Message message = findMessage(input);
        MessageViewerOutDto output = new MessageViewerOutDto();
        output.setJMSMessageID(input.getJMSMessageID());
        output.setError(message.getStringProperty(JmsBrowser.HEADER_ERROR_DETAILS));
        output.setPriority(new Long(message.getJMSPriority()));
        output.setHasPriorityAccess(JmsBrowser.hasChangePriorityAccess(message.getStringProperty(JmsBrowser.HEADER_ORIGINAL_QUEUE_NAME)));
        output.setJMSDestination(message.getJMSDestination());
        output.setJMSDeliveryMode(message.getJMSDeliveryMode());
        output.setJMSTimestamp(message.getJMSTimestamp() != 0 ? new DateTime(message.getJMSTimestamp()) : null);
        output.setJMSCorrelationID(message.getJMSCorrelationID());
        output.setJMSReplyTo(message.getJMSReplyTo());
        try {
            output.setJMSRedelivered(message.getJMSRedelivered());
        } catch (Exception e) {
        // JBossMessaging throws "java.lang.IllegalStateException: This should never be called directly". Do nothing
        }
        output.setJMSType(message.getJMSType());
        output.setJMSExpiration(message.getJMSExpiration());
        if (message instanceof TextMessage)
            output.setPayLoad(((TextMessage) message).getText());
        // Generate a Map of header elements, keyed by the name of each header element
        // Ignore Error Details as we are showing it in a separate section
        Map<String, HeaderElementDto> headerElements = new LinkedHashMap<String, HeaderElementDto>();
        for (Enumeration e = message.getPropertyNames(); e.hasMoreElements(); ) {
            String name = (String) e.nextElement();
            if (!JmsBrowser.HEADER_ERROR_DETAILS.equals(name)) {
                String value = Formatter.format(message.getObjectProperty(name));
                HeaderElementDto headerElement = headerElements.get(name);
                if (headerElement == null) {
                    headerElement = new HeaderElementDto();
                    headerElement.setName(name);
                    headerElements.put(name, headerElement);
                }
                headerElement.setValue(value);
            }
        }
        // Add labels to the header-elements based on the QueueInfo
        // It is possible that a display-param points to a property on the Message (eg. JMSMessageID, JMSPriority etc.)
        // Use bean intropsection to extract the value of that property
        QueueInfo queueInfo = ConfigurationService.getInstance().getQueueInfo(message.getStringProperty(JmsBrowser.HEADER_ORIGINAL_QUEUE_NAME));
        if (queueInfo != null && queueInfo.getDisplayParam() != null) {
            for (DisplayParam displayParam : queueInfo.getDisplayParam()) {
                HeaderElementDto headerElement = headerElements.get(displayParam.getName());
                if (headerElement == null) {
                    try {
                        headerElement = new HeaderElementDto();
                        headerElement.setName(displayParam.getName());
                        headerElement.setLabel(displayParam.getLabel());
                        headerElements.put(displayParam.getName(), headerElement);
                        if (displayParam.getName().equals("JMSTimestamp")) {
                            String value = message.getJMSTimestamp() != 0 ? Formatter.format(new DateTime(message.getJMSTimestamp())) : null;
                            headerElement.setValue(value);
                        } else {
                            String value = Formatter.format(BeanHelper.getField(message, displayParam.getName()));
                            headerElement.setValue(value);
                        }
                    } catch (Exception e) {
                    // do nothing
                    }
                } else {
                    headerElement.setLabel(displayParam.getLabel());
                }
            }
        }
        output.setHeaderElements(headerElements.values().toArray(new HeaderElementDto[headerElements.values().size()]));
        buildBusinessEventLogDto(input, output, message);
        return output;
    } catch (JMSException e) {
        throw new JaffaMessagingFrameworkException(JaffaMessagingFrameworkException.MESSAGE_INFO_MISSING, null, e);
    }
}
Also used : MessageViewerOutDto(org.jaffa.modules.messaging.components.messageviewer.dto.MessageViewerOutDto) QueueInfo(org.jaffa.modules.messaging.services.configdomain.QueueInfo) Enumeration(java.util.Enumeration) Message(javax.jms.Message) TextMessage(javax.jms.TextMessage) JaffaMessagingFrameworkException(org.jaffa.modules.messaging.services.JaffaMessagingFrameworkException) JMSException(javax.jms.JMSException) DateTime(org.jaffa.datatypes.DateTime) FrameworkException(org.jaffa.exceptions.FrameworkException) JaffaMessagingFrameworkException(org.jaffa.modules.messaging.services.JaffaMessagingFrameworkException) JMSException(javax.jms.JMSException) LinkedHashMap(java.util.LinkedHashMap) HeaderElementDto(org.jaffa.modules.messaging.components.messageviewer.dto.HeaderElementDto) DisplayParam(org.jaffa.modules.messaging.services.configdomain.DisplayParam) TextMessage(javax.jms.TextMessage)

Example 5 with DateTime

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

the class QueueViewerTx method addRelatedDtos.

private void addRelatedDtos(QueueViewerInDto input, QueueViewerOutDto output) throws FrameworkException, ApplicationExceptions {
    Message[] messages = null;
    if (input.getMessageMode() == null || input.getMessageMode() == MessageModeEnum.PENDING)
        messages = JmsBrowser.getPendingMessages(input.getQueueName(), input.getFilter());
    else
        log.warn("Messages cannot be retrieved since unsupported messageMode '" + input.getMessageMode() + "' has been passed");
    try {
        // Determine the header elements for the queue
        QueueInfo queueInfo = ConfigurationService.getInstance().getQueueInfo(input.getQueueName());
        if (queueInfo != null && queueInfo.getDisplayParam() != null) {
            List<HeaderElementDto> headerElementDtos = new LinkedList<HeaderElementDto>();
            for (DisplayParam displayParam : queueInfo.getDisplayParam()) {
                HeaderElementDto headerElementDto = new HeaderElementDto();
                headerElementDto.setName(displayParam.getName());
                headerElementDto.setLabel(displayParam.getLabel());
                headerElementDtos.add(headerElementDto);
            }
            output.setHeaderElements(headerElementDtos.toArray(new HeaderElementDto[headerElementDtos.size()]));
        }
        if (messages != null && messages.length > 0) {
            List<MessageDto> messageDtos = new LinkedList<MessageDto>();
            String[] manageableMessages = null;
            for (Message message : messages) {
                MessageDto messageDto = new MessageDto();
                messageDto.setMessageId(message.getJMSMessageID());
                if (input.getMessageMode() == MessageModeEnum.IN_PROCESS) {
                    messageDto.setManageable(Arrays.binarySearch(manageableMessages, message.getJMSMessageID()) >= 0 ? Boolean.TRUE : Boolean.FALSE);
                } else
                    messageDto.setManageable(Boolean.FALSE);
                // Evaluate the header elements for the message
                if (queueInfo != null && queueInfo.getDisplayParam() != null) {
                    List<HeaderElementDto> headerElementDtos = new LinkedList<HeaderElementDto>();
                    for (DisplayParam displayParam : queueInfo.getDisplayParam()) {
                        HeaderElementDto headerElementDto = new HeaderElementDto();
                        headerElementDto.setName(displayParam.getName());
                        headerElementDto.setLabel(displayParam.getLabel());
                        Object value = message.getObjectProperty(displayParam.getName());
                        if (value == null) {
                            // Use bean intropsection to extract the value of the property
                            try {
                                if (displayParam.getName().equals("JMSTimestamp")) {
                                    value = message.getJMSTimestamp() != 0 ? new DateTime(message.getJMSTimestamp()) : null;
                                } else {
                                    value = BeanHelper.getField(message, displayParam.getName());
                                }
                            } catch (Exception e) {
                            // do nothing
                            }
                        }
                        if (value != null)
                            headerElementDto.setValue(Formatter.format(value));
                        headerElementDtos.add(headerElementDto);
                    }
                    messageDto.setHeaderElements(headerElementDtos.toArray(new HeaderElementDto[headerElementDtos.size()]));
                }
                messageDtos.add(messageDto);
            }
            output.setMessages(messageDtos.toArray(new MessageDto[messageDtos.size()]));
        }
    } catch (JMSException e) {
        throw new JaffaMessagingFrameworkException(JaffaMessagingFrameworkException.MESSAGE_INFO_MISSING, null, e);
    }
}
Also used : Message(javax.jms.Message) JMSException(javax.jms.JMSException) LinkedList(java.util.LinkedList) DateTime(org.jaffa.datatypes.DateTime) FrameworkException(org.jaffa.exceptions.FrameworkException) JMSException(javax.jms.JMSException)

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