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