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);
}
}
}
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();
}
}
}
}
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();
}
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;
}
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;
}
Aggregations