Search in sources :

Example 41 with DateTime

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

the class AuditLogger method createAuditTransaction.

/**
 * Creates an AuditTransaction instance, if not already created, and adds it to the UOW.
 */
private void createAuditTransaction() throws ApplicationExceptions, FrameworkException {
    if (m_transactionId == null) {
        try {
            AuditTransaction at = new AuditTransaction();
            at.generateKey();
            at.setProcessName((String) MDC.get(AuditTransactionMeta.PROCESS_NAME));
            at.setSubProcessName((String) MDC.get(AuditTransactionMeta.SUB_PROCESS_NAME));
            at.setReason((String) MDC.get(AuditTransactionMeta.REASON));
            if (SecurityManager.getPrincipal() != null && SecurityManager.getPrincipal().getName() != null)
                at.setCreatedBy(SecurityManager.getPrincipal().getName());
            at.setCreatedOn(new DateTime());
            m_uow.addSpecial(at);
            m_transactionId = at.getTransactionId();
            if (log.isDebugEnabled())
                log.debug("Created AuditTransaction: " + at);
        } catch (ValidationException e) {
            if (log.isDebugEnabled())
                log.debug("Exception thrown during creation of AuditTransaction", e);
            throw new ApplicationExceptions(e);
        }
    }
}
Also used : ValidationException(org.jaffa.datatypes.ValidationException) ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) AuditTransaction(org.jaffa.components.audit.domain.AuditTransaction) DateTime(org.jaffa.datatypes.DateTime)

Example 42 with DateTime

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

the class UserSession method garbageCollectIdleComponents.

/**
 * This will perform garbage collection of idle components. Idle components are those components which have had no activity performed in the last 'timeOutMinutes' minutes.
 * @param timeOutMinutes The minutes used to determine idle components.
 */
public void garbageCollectIdleComponents(int timeOutMinutes) {
    List excludeComponents = null;
    String[] ec = StringHelper.parseString((String) ContextManagerFactory.instance().getProperty(RULE_GC_EXCLUDES), ",");
    if (ec == null || ec.length == 0)
        excludeComponents = new ArrayList();
    else
        excludeComponents = Arrays.asList(ec);
    // create an array of Component objects
    Component[] components = new Component[m_components.size()];
    Iterator itr = m_components.values().iterator();
    for (int i = 0; itr.hasNext(); i++) components[i] = (Component) itr.next();
    for (int i = 0; i < components.length; i++) {
        Component component = components[i];
        if (component.isActive() && !excludeComponents.contains(component.getComponentDefinition().getComponentName())) {
            // Collection of componentIds. This will avoid circular references
            Collection checkedComponentIdsList = new ArrayList();
            if (hasComponentTimedOut(component, DateTime.addMinute(new DateTime(), -timeOutMinutes), checkedComponentIdsList)) {
                if (log.isInfoEnabled())
                    log.info("Garbage collecting component " + component.getComponentDefinition().getComponentName() + " having id " + component.getComponentId());
                component.quit();
            }
        }
    }
}
Also used : Component(org.jaffa.presentation.portlet.component.Component) DateTime(org.jaffa.datatypes.DateTime)

Example 43 with DateTime

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

the class FinderComponent2 method performInquiry.

/**
 * Invokes the doInquiry() method and then removes the "rows" GridModel object from the cache.
 * @throws ApplicationExceptions This will be thrown in case any invalid data has been set.
 * @throws FrameworkException Indicates some system error.
 */
public void performInquiry() throws ApplicationExceptions, FrameworkException {
    m_finderOutDto = doInquiry();
    uncacheRowsModel();
    m_queryLastRunOn = new DateTime();
}
Also used : DateTime(org.jaffa.datatypes.DateTime)

Example 44 with DateTime

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

the class FinderTx method interpretDateTime.

private static AtomicCriteria interpretDateTime(String name, int operator, DateTime value) {
    AtomicCriteria atomic = new AtomicCriteria();
    // determine the start and end of the day
    DateTime dt1 = determineDateTimeLimit(value, true);
    DateTime dt2 = determineDateTimeLimit(value, false);
    if (dt1.equals(dt2)) {
        // an exact value has been passed !!!
        atomic.addCriteria(name, operator, value);
    } else {
        // now perform datatime interpretation based on the operator
        if (operator == Criteria.RELATIONAL_EQUALS) {
            atomic.addCriteria(name, Criteria.RELATIONAL_GREATER_THAN_EQUAL_TO, dt1);
            atomic.addCriteria(name, Criteria.RELATIONAL_SMALLER_THAN_EQUAL_TO, dt2);
        } else if (operator == Criteria.RELATIONAL_NOT_EQUALS) {
            atomic.addCriteria(name, Criteria.RELATIONAL_SMALLER_THAN, dt1);
            atomic.addOrCriteria(name, Criteria.RELATIONAL_GREATER_THAN, dt2);
        } else if (operator == Criteria.RELATIONAL_GREATER_THAN) {
            atomic.addCriteria(name, Criteria.RELATIONAL_GREATER_THAN, dt2);
        } else if (operator == Criteria.RELATIONAL_SMALLER_THAN) {
            atomic.addCriteria(name, Criteria.RELATIONAL_SMALLER_THAN, dt1);
        } else if (operator == Criteria.RELATIONAL_GREATER_THAN_EQUAL_TO) {
            atomic.addCriteria(name, Criteria.RELATIONAL_GREATER_THAN_EQUAL_TO, dt1);
        } else if (operator == Criteria.RELATIONAL_SMALLER_THAN_EQUAL_TO) {
            atomic.addCriteria(name, Criteria.RELATIONAL_SMALLER_THAN_EQUAL_TO, dt2);
        } else {
            // this should never happen
            atomic.addCriteria(name, operator, value);
        }
    }
    return atomic;
}
Also used : AtomicCriteria(org.jaffa.persistence.AtomicCriteria) DateTime(org.jaffa.datatypes.DateTime)

Example 45 with DateTime

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

the class FinderTx method determineDateTimeLimit.

private static DateTime determineDateTimeLimit(DateTime value, boolean lowerLimit) {
    DateTime dt = null;
    int maxHours = 23, maxMinutes = 59, maxSeconds = 59, maxMillis = 999;
    if (value.hourOfDay() == 0 && value.minute() == 0 && value.second() == 0) {
        if (lowerLimit)
            dt = DateTime.addMilli(value, -(value.milli()));
        else
            dt = new DateTime(value.year(), value.month(), value.day(), maxHours, maxMinutes, maxSeconds, maxMillis);
    } else if (value.minute() == 0 && value.second() == 0) {
        if (lowerLimit)
            dt = DateTime.addMilli(value, -(value.milli()));
        else
            dt = new DateTime(value.year(), value.month(), value.day(), value.hourOfDay(), maxMinutes, maxSeconds, maxMillis);
    } else if (value.second() == 0) {
        if (lowerLimit)
            dt = DateTime.addMilli(value, -(value.milli()));
        else
            dt = new DateTime(value.year(), value.month(), value.day(), value.hourOfDay(), value.minute(), maxSeconds, maxMillis);
    } else {
        dt = value;
    }
    return dt;
}
Also used : DateTime(org.jaffa.datatypes.DateTime)

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