List of usage examples for java.text DateFormat FULL
int FULL
To view the source code for java.text DateFormat FULL.
Click Source Link
From source file:org.sakaiproject.assignment2.logic.impl.AssignmentLogicImpl.java
/** * will handle the business logic and updates required to determine if an event * needs to be added, updated, or deleted from the Schedule (Calendar) tool. * Compares the existing assignment (if not null) to the new assignment to * carry out any actions that are required for the relationship with the * Schedule tool. Events are updated upon a change in the due date, title, or * group restrictions for the assignment. Events are deleted if the assignment * is deleted, changed to draft status, or the due date is removed. will also * add event when appropriate. Does not re-check permissions, so * make sure you are authorized to update assignments if you call this method. * @param originalAssignment - null if "updatedAssignment" is newly created * @param updatedAssignment//ww w . j a va 2 s.co m */ private void handleDueDateEvent(Assignment2 originalAssignment, Assignment2 updatedAssignment) { if (updatedAssignment == null) { throw new IllegalArgumentException("Null updatedAssignment passed to saveDueDateEvent"); } if (updatedAssignment.getId() == null) { throw new IllegalArgumentException( "The updatedAssignment passed to " + "saveDueDateEvent must have an id"); } String contextId = updatedAssignment.getContextId(); // make the due date locale-aware // use a date which is related to the current users locale DateFormat df = externalLogic.getDateFormat(null, DateFormat.FULL, bundleLogic.getLocale(), true); // create url to point back to this assignment to be included in the description // ASNN-477 // String assignUrl = externalLogic.getAssignmentViewUrl(REDIRECT_ASSIGNMENT_VIEW_ID) + "/" + updatedAssignment.getId(); String eventTitle = ""; String eventDescription = ""; if (updatedAssignment.getDueDate() != null) { String toolTitle = externalLogic.getToolTitle(); eventTitle = bundleLogic.getFormattedMessage("assignment2.schedule_event_title", new Object[] { toolTitle, updatedAssignment.getTitle() }); eventDescription = bundleLogic.getFormattedMessage("assignment2.schedule_event_description", new Object[] { updatedAssignment.getTitle(), df.format(updatedAssignment.getDueDate()), toolTitle }); } if (originalAssignment == null) { // this was a new assignment // check to see if there will be an event added for the due date if (updatedAssignment.getAddedToSchedule() && !updatedAssignment.isDraft() && updatedAssignment.getDueDate() != null) { // add an event for the due date for this assignment String eventId = calendarLogic.addDueDateToSchedule( updatedAssignment.getListOfAssociatedGroupReferences(), contextId, eventTitle, eventDescription, updatedAssignment.getDueDate(), updatedAssignment.getId()); updatedAssignment.setEventId(eventId); dao.update(updatedAssignment); } } else if (updatedAssignment.isDraft()) { if (updatedAssignment.getEventId() != null) { calendarLogic.deleteDueDateEvent(updatedAssignment.getEventId(), contextId); updatedAssignment.setEventId(null); dao.update(updatedAssignment); } } else if (originalAssignment.getEventId() == null && updatedAssignment.getAddedToSchedule()) { // this is a new event String eventIdId = calendarLogic.addDueDateToSchedule( updatedAssignment.getListOfAssociatedGroupReferences(), contextId, eventTitle, eventDescription, updatedAssignment.getDueDate(), updatedAssignment.getId()); updatedAssignment.setEventId(eventIdId); dao.update(updatedAssignment); } else if (originalAssignment.getEventId() != null && !updatedAssignment.getAddedToSchedule()) { // we must remove the original event calendarLogic.deleteDueDateEvent(originalAssignment.getEventId(), contextId); updatedAssignment.setEventId(null); dao.update(updatedAssignment); } else if (updatedAssignment.getAddedToSchedule()) { // if title, due date, or group restrictions were updated, we need to update the event Date oldDueDate = originalAssignment.getDueDate(); Date newDueDate = updatedAssignment.getDueDate(); if (oldDueDate != null && newDueDate == null) { // we need to remove this event because no longer has a due date calendarLogic.deleteDueDateEvent(originalAssignment.getEventId(), contextId); updatedAssignment.setEventId(null); dao.update(updatedAssignment); } else if (!originalAssignment.getTitle().equals(updatedAssignment.getTitle()) || (oldDueDate.after(newDueDate) || oldDueDate.before(newDueDate)) || !originalAssignment.getListOfAssociatedGroupReferences() .equals(updatedAssignment.getListOfAssociatedGroupReferences())) { // otherwise, we update only if there is a change in the assignment title, due date, // or group restrictions calendarLogic.updateDueDateEvent(updatedAssignment.getEventId(), updatedAssignment.getListOfAssociatedGroupReferences(), contextId, eventTitle, eventDescription, updatedAssignment.getDueDate(), updatedAssignment.getId()); // don't need to re-save assignment b/c id already exists } } }
From source file:org.hoteia.qalingo.core.service.EmailService.java
/** * @throws Exception //from w w w . ja v a 2 s . c o m */ public Email buildAndSaveNewOrderB2CConfirmationMail(final RequestData requestData, final Customer customer, final String velocityPath, final OrderConfirmationEmailBean orderConfirmationEmailBean) throws Exception { Email email = null; try { final String contextNameValue = requestData.getContextNameValue(); final Localization localization = requestData.getMarketAreaLocalization(); final Locale locale = localization.getLocale(); // SANITY CHECK checkEmailAddresses(orderConfirmationEmailBean); Map<String, Object> model = new HashMap<String, Object>(); DateFormat dateFormatter = DateFormat.getDateInstance(DateFormat.FULL, locale); java.sql.Timestamp currentDate = new java.sql.Timestamp((new java.util.Date()).getTime()); model.put(CURRENT_DATE, dateFormatter.format(currentDate)); model.put(CUSTOMER, customer); model.put("orderConfirmationEmailBean", orderConfirmationEmailBean); model.put(WORDING, coreMessageSource.loadWording(Email.WORDING_SCOPE_EMAIL, locale)); String fromAddress = handleFromAddress(orderConfirmationEmailBean.getFromAddress(), contextNameValue); String fromName = handleFromName(orderConfirmationEmailBean.getFromName(), locale); String toEmail = customer.getEmail(); MimeMessagePreparatorImpl mimeMessagePreparator = getMimeMessagePreparator(requestData, Email.EMAIl_TYPE_ORDER_CONFIRMATION, model); mimeMessagePreparator.setTo(toEmail); mimeMessagePreparator.setFrom(fromAddress); mimeMessagePreparator.setFromName(fromName); mimeMessagePreparator.setReplyTo(fromAddress); Object[] parameters = { customer.getLastname(), customer.getFirstname() }; mimeMessagePreparator.setSubject(coreMessageSource .getMessage("email.customer_new_order.confirmation_email_subject", parameters, locale)); mimeMessagePreparator.setHtmlContent(VelocityEngineUtils.mergeTemplateIntoString(getVelocityEngine(), velocityPath + "order-confirmation-html-content.vm", model)); mimeMessagePreparator.setPlainTextContent(VelocityEngineUtils.mergeTemplateIntoString( getVelocityEngine(), velocityPath + "order-confirmation-text-content.vm", model)); email = new Email(); email.setType(Email.EMAIl_TYPE_ORDER_CONFIRMATION); email.setStatus(Email.EMAIl_STATUS_PENDING); saveOrUpdateEmail(email, mimeMessagePreparator); } catch (MailException e) { logger.error("Error, can't save the message :", e); throw e; } catch (VelocityException e) { logger.error("Error, can't build the message :", e); throw e; } catch (IOException e) { logger.error("Error, can't serializable the message :", e); throw e; } return email; }
From source file:it.fub.jardin.server.DbUtils.java
/** * @param fieldName/*from w w w.ja v a2 s . co m*/ * @param result * @return ritorna la Foreign Key per il campo il cui nome passato come * parametro, se esiste. Se non esiste, ritorna una stringa vuota. * @throws SQLException */ // private List<BaseModelData> getForeignKeyInfoForAResultset(String // resultsetName) // throws SQLException { // return dbProperties.getForeignKeys(resultsetName); // } public User getUser(final Credentials credentials) throws VisibleException { String username = credentials.getUsername(); String password = credentials.getPassword(); ResultSet result; Connection connection; try { connection = this.dbConnectionHandler.getConn(); } catch (HiddenException e) { JardinLogger.error(username, "Errore SQL: impossibile connettersi al db"); throw new VisibleException(e.getLocalizedMessage()); } String query = "SELECT u.id, u.name, u.surname, u.email, u.office, " + "u.telephone, u.status AS userstatus, u.lastlogintime, " + "u.logincount, g.id AS groupid, g.name AS groupname " + "FROM " + T_USER + " u JOIN " + T_GROUP + " g ON g.id = u.id_group " + "WHERE username = ? and password = PASSWORD(?) and u.status='1'"; PreparedStatement ps; try { ps = connection.prepareStatement(query); ps.setString(1, username); ps.setString(2, password); } catch (SQLException e) { throw new VisibleException("Errore nella query " + "per la verifica di username e password"); } try { JardinLogger.info(username, "LOGIN: tentativo di login utente " + credentials.getUsername()); result = ps.executeQuery(); } catch (SQLException e) { e.printStackTrace(); JardinLogger.error(username, "Errore SQL: Errore durante l'interrogazione su database"); throw new VisibleException("Errore durante l'interrogazione su database"); } int rows = 0; try { while (result.next()) { rows++; if (rows > 1) { throw new VisibleException( "Errore nel database degli utenti: " + "due account con username e password uguali"); } /* Creazione dell'utente con i dati del database */ int uid = result.getInt("id"); int gid = result.getInt("groupid"); String name = result.getString("name"); String surname = result.getString("surname"); String group = result.getString("groupname"); String email = result.getString("email"); String office = result.getString("office"); String telephone = result.getString("telephone"); int status = result.getInt("userstatus"); int login = result.getInt("logincount"); JardinLogger.info(username, "login successfull!"); // String lastlogintime = result.getString("lastlogintime"); DateFormat df = DateFormat.getDateInstance(DateFormat.FULL, Locale.getDefault()); String last = df.format(new Date()); /* Carica le preferenze dell'utente */ List<ResultsetImproved> resultsets = this.getUserResultsetImproved(uid, gid); List<Message> messages = new ArrayList<Message>(); this.updateLoginCount(uid, ++login); User user = new User(uid, gid, new Credentials(username, password), name, surname, group, email, office, telephone, status, login, last, resultsets, messages); this.user = user; return user; } } catch (Exception e) { // Log.warn("Errore SQL", e); throw new VisibleException("Errore di accesso " + "al risultato dell'interrogazione su database"); } finally { try { this.dbConnectionHandler.closeConn(connection); } catch (HiddenException e) { // TODO Auto-generated catch block e.printStackTrace(); } } throw new VisibleException("Errore di accesso: username o password errati"); }
From source file:org.hoteia.qalingo.core.service.EmailService.java
/** * @throws Exception /*w w w. j a va 2 s .co m*/ */ public Email buildAndSaveNewOrderB2BConfirmationMail(final RequestData requestData, final User user, final String velocityPath, final OrderConfirmationEmailBean orderConfirmationEmailBean) throws Exception { Email email = null; try { final String contextNameValue = requestData.getContextNameValue(); final Localization localization = requestData.getMarketAreaLocalization(); final Locale locale = localization.getLocale(); // SANITY CHECK checkEmailAddresses(orderConfirmationEmailBean); Map<String, Object> model = new HashMap<String, Object>(); DateFormat dateFormatter = DateFormat.getDateInstance(DateFormat.FULL, locale); java.sql.Timestamp currentDate = new java.sql.Timestamp((new java.util.Date()).getTime()); model.put(CURRENT_DATE, dateFormatter.format(currentDate)); model.put(USER, user); model.put("orderConfirmationEmailBean", orderConfirmationEmailBean); model.put(WORDING, coreMessageSource.loadWording(Email.WORDING_SCOPE_EMAIL, locale)); String fromAddress = handleFromAddress(orderConfirmationEmailBean.getFromAddress(), contextNameValue); String fromName = handleFromName(orderConfirmationEmailBean.getFromName(), locale); String toEmail = user.getEmail(); MimeMessagePreparatorImpl mimeMessagePreparator = getMimeMessagePreparator(requestData, Email.EMAIl_TYPE_ORDER_CONFIRMATION, model); mimeMessagePreparator.setTo(toEmail); mimeMessagePreparator.setFrom(fromAddress); mimeMessagePreparator.setFromName(fromName); mimeMessagePreparator.setReplyTo(fromAddress); Object[] parameters = { user.getLastname(), user.getFirstname() }; mimeMessagePreparator.setSubject(coreMessageSource .getMessage("email.store_new_order.confirmation_email_subject", parameters, locale)); mimeMessagePreparator.setHtmlContent(VelocityEngineUtils.mergeTemplateIntoString(getVelocityEngine(), velocityPath + "order-confirmation-html-content.vm", model)); mimeMessagePreparator.setPlainTextContent(VelocityEngineUtils.mergeTemplateIntoString( getVelocityEngine(), velocityPath + "order-confirmation-text-content.vm", model)); email = new Email(); email.setType(Email.EMAIl_TYPE_ORDER_CONFIRMATION); email.setStatus(Email.EMAIl_STATUS_PENDING); saveOrUpdateEmail(email, mimeMessagePreparator); } catch (MailException e) { logger.error("Error, can't save the message :", e); throw e; } catch (VelocityException e) { logger.error("Error, can't build the message :", e); throw e; } catch (IOException e) { logger.error("Error, can't serializable the message :", e); throw e; } return email; }
From source file:org.hoteia.qalingo.core.service.EmailService.java
/** * @throws Exception // w ww .j a v a 2 s .c om */ public Email buildAndSaveOrderShippedConfirmationMail(final RequestData requestData, final Customer customer, final String velocityPath, final OrderSentConfirmationEmailBean orderSentConfirmationEmailBean) throws Exception { Email email = null; try { final String contextNameValue = requestData.getContextNameValue(); final Localization localization = requestData.getMarketAreaLocalization(); final Locale locale = localization.getLocale(); // SANITY CHECK checkEmailAddresses(orderSentConfirmationEmailBean); Map<String, Object> model = new HashMap<String, Object>(); DateFormat dateFormatter = DateFormat.getDateInstance(DateFormat.FULL, locale); java.sql.Timestamp currentDate = new java.sql.Timestamp((new java.util.Date()).getTime()); model.put(CURRENT_DATE, dateFormatter.format(currentDate)); model.put(CUSTOMER, customer); model.put("orderSentConfirmationEmailBean", orderSentConfirmationEmailBean); model.put(WORDING, coreMessageSource.loadWording(Email.WORDING_SCOPE_EMAIL, locale)); String fromAddress = handleFromAddress(orderSentConfirmationEmailBean.getFromAddress(), contextNameValue); String fromName = handleFromName(orderSentConfirmationEmailBean.getFromName(), locale); String toEmail = customer.getEmail(); MimeMessagePreparatorImpl mimeMessagePreparator = getMimeMessagePreparator(requestData, Email.EMAIl_TYPE_ORDER_SHIPPED, model); mimeMessagePreparator.setTo(toEmail); mimeMessagePreparator.setFrom(fromAddress); mimeMessagePreparator.setFromName(fromName); mimeMessagePreparator.setReplyTo(fromAddress); Object[] parameters = { customer.getLastname(), customer.getFirstname() }; mimeMessagePreparator.setSubject( coreMessageSource.getMessage("email.order_shipped.shipped_email_subject", parameters, locale)); mimeMessagePreparator.setHtmlContent(VelocityEngineUtils.mergeTemplateIntoString(getVelocityEngine(), velocityPath + "order-shipped-html-content.vm", model)); mimeMessagePreparator.setPlainTextContent(VelocityEngineUtils.mergeTemplateIntoString( getVelocityEngine(), velocityPath + "order-shipped-text-content.vm", model)); email = new Email(); email.setType(Email.EMAIl_TYPE_ORDER_SHIPPED); email.setStatus(Email.EMAIl_STATUS_PENDING); saveOrUpdateEmail(email, mimeMessagePreparator); } catch (MailException e) { logger.error("Error, can't save the message :", e); throw e; } catch (VelocityException e) { logger.error("Error, can't build the message :", e); throw e; } catch (IOException e) { logger.error("Error, can't serializable the message :", e); throw e; } return email; }
From source file:org.hoteia.qalingo.core.service.EmailService.java
/** * @throws Exception /*from ww w . j av a2 s . c om*/ */ public Email buildAndSaveAbandonedShoppingCartMail(final RequestData requestData, final Customer customer, final String velocityPath, final AbandonedShoppingCartEmailBean abandonedShoppingCartEmailBean) throws Exception { Email email = null; try { final String contextNameValue = requestData.getContextNameValue(); final Localization localization = requestData.getMarketAreaLocalization(); final Locale locale = localization.getLocale(); // SANITY CHECK checkEmailAddresses(abandonedShoppingCartEmailBean); Map<String, Object> model = new HashMap<String, Object>(); DateFormat dateFormatter = DateFormat.getDateInstance(DateFormat.FULL, locale); java.sql.Timestamp currentDate = new java.sql.Timestamp((new java.util.Date()).getTime()); model.put(CURRENT_DATE, dateFormatter.format(currentDate)); model.put(CUSTOMER, customer); model.put("abandonedShoppingCartEmailBean", abandonedShoppingCartEmailBean); model.put(WORDING, coreMessageSource.loadWording(Email.WORDING_SCOPE_EMAIL, locale)); String fromAddress = handleFromAddress(abandonedShoppingCartEmailBean.getFromAddress(), contextNameValue); String fromName = handleFromName(abandonedShoppingCartEmailBean.getFromName(), locale); String toEmail = customer.getEmail(); MimeMessagePreparatorImpl mimeMessagePreparator = getMimeMessagePreparator(requestData, Email.EMAIl_TYPE_ABANDONED_SHOPPING_CART, model); mimeMessagePreparator.setTo(toEmail); mimeMessagePreparator.setFrom(fromAddress); mimeMessagePreparator.setFromName(fromName); mimeMessagePreparator.setReplyTo(fromAddress); Object[] parameters = { customer.getLastname(), customer.getFirstname() }; mimeMessagePreparator.setSubject(coreMessageSource .getMessage("email.abandoned_shopping_cart.email_subject", parameters, locale)); mimeMessagePreparator.setHtmlContent(VelocityEngineUtils.mergeTemplateIntoString(getVelocityEngine(), velocityPath + "abandoned-shopping-cart-html-content.vm", model)); mimeMessagePreparator.setPlainTextContent(VelocityEngineUtils.mergeTemplateIntoString( getVelocityEngine(), velocityPath + "abandoned-shopping-cart-text-content.vm", model)); email = new Email(); email.setType(Email.EMAIl_TYPE_ABANDONED_SHOPPING_CART); email.setStatus(Email.EMAIl_STATUS_PENDING); saveOrUpdateEmail(email, mimeMessagePreparator); } catch (MailException e) { logger.error("Error, can't save the message :", e); throw e; } catch (VelocityException e) { logger.error("Error, can't build the message :", e); throw e; } catch (IOException e) { logger.error("Error, can't serializable the message :", e); throw e; } return email; }
From source file:org.exoplatform.outlook.OutlookServiceImpl.java
/** * Generate message summary text./* w ww .ja va 2 s.co m*/ * * @param message {@link String} * @return {@link String} */ protected String messageSummary(OutlookMessage message) { String fromEmail = message.getFrom().getEmail(); String fromName = message.getFrom().getDisplayName(); Date time = message.getCreated().getTime(); Locale locale = Locale.ENGLISH; ResourceBundle res = resourceBundleService.getResourceBundle("locale.outlook.Outlook", locale); DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.FULL, locale); DateFormat timeFormat = DateFormat.getTimeInstance(DateFormat.SHORT, locale); StringBuilder fromLine = new StringBuilder(); fromLine.append(fromName); fromLine.append('<'); fromLine.append(fromEmail); fromLine.append('>'); StringBuilder summary = new StringBuilder(); summary.append(res.getString("Outlook.activity.from")); summary.append(": <a href='mailto:"); summary.append(fromEmail); summary.append("' target='_top'>"); summary.append(ContentReader.simpleEscapeHtml(fromLine.toString())); summary.append("</a> "); summary.append(res.getString("Outlook.activity.on")); summary.append(' '); summary.append(dateFormat.format(time)); summary.append(' '); summary.append(res.getString("Outlook.activity.at")); summary.append(' '); summary.append(timeFormat.format(time)); return summary.toString(); }
From source file:net.sf.fspdfs.chartthemes.simple.SimpleChartTheme.java
protected void setAxisTickLabels(Axis axis, JRFont tickLabelFont, Paint tickLabelColor, String tickLabelMask, AxisSettings axisSettings) {//from w w w. jav a 2s.co m boolean axisTickLabelsVisible = axisSettings.getTickLabelsVisible() == null || axisSettings.getTickLabelsVisible().booleanValue();//FIXMETHEME axis visibility should be dealt with above; axis.setTickLabelsVisible(axisTickLabelsVisible); if (axisTickLabelsVisible) { JRBaseFont font = new JRBaseFont(); JRFontUtil.copyNonNullOwnProperties(axisSettings.getTickLabelFont(), font); JRFontUtil.copyNonNullOwnProperties(tickLabelFont, font); font = new JRBaseFont(getChart(), font); axis.setTickLabelFont(JRFontUtil.getAwtFont(font, getLocale())); RectangleInsets tickLabelInsets = axisSettings.getTickLabelInsets(); if (tickLabelInsets != null) { axis.setTickLabelInsets(tickLabelInsets); } Paint tickLabelPaint = tickLabelColor != null ? tickLabelColor : axisSettings.getTickLabelPaint() != null ? axisSettings.getTickLabelPaint().getPaint() : null; if (tickLabelPaint != null) { axis.setTickLabelPaint(tickLabelPaint); } TimeZone timeZone = getChartContext().getTimeZone(); if (axis instanceof DateAxis && timeZone != null) { // used when no mask is set ((DateAxis) axis).setTimeZone(timeZone); } if (tickLabelMask != null) { if (axis instanceof NumberAxis) { NumberFormat fmt = NumberFormat.getInstance(); if (fmt instanceof DecimalFormat) ((DecimalFormat) fmt).applyPattern(tickLabelMask); ((NumberAxis) axis).setNumberFormatOverride(fmt); } else if (axis instanceof DateAxis) { DateFormat fmt; if (tickLabelMask.equals("SHORT") || tickLabelMask.equals("DateFormat.SHORT")) fmt = DateFormat.getDateInstance(DateFormat.SHORT); else if (tickLabelMask.equals("MEDIUM") || tickLabelMask.equals("DateFormat.MEDIUM")) fmt = DateFormat.getDateInstance(DateFormat.MEDIUM); else if (tickLabelMask.equals("LONG") || tickLabelMask.equals("DateFormat.LONG")) fmt = DateFormat.getDateInstance(DateFormat.LONG); else if (tickLabelMask.equals("FULL") || tickLabelMask.equals("DateFormat.FULL")) fmt = DateFormat.getDateInstance(DateFormat.FULL); else fmt = new SimpleDateFormat(tickLabelMask); // FIXME fmt cannot be null if (fmt != null) { if (timeZone != null) { fmt.setTimeZone(timeZone); } ((DateAxis) axis).setDateFormatOverride(fmt); } else ((DateAxis) axis).setDateFormatOverride( DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT)); } // ignore mask for other axis types. } } }
From source file:net.sf.fspdfs.chartthemes.spring.GenericChartTheme.java
protected void setAxisTickLabels(Axis axis, JRFont tickLabelFont, Paint tickLabelColor, String tickLabelMask, Integer baseFontSize) {//from w ww . j a va 2 s . c o m Boolean defaultAxisTickLabelsVisible = (Boolean) getDefaultValue(defaultAxisPropertiesMap, ChartThemesConstants.AXIS_TICK_LABELS_VISIBLE); if (defaultAxisTickLabelsVisible != null && defaultAxisTickLabelsVisible.booleanValue()) { Font themeTickLabelFont = getFont( (JRFont) getDefaultValue(defaultAxisPropertiesMap, ChartThemesConstants.AXIS_TICK_LABEL_FONT), tickLabelFont, baseFontSize); axis.setTickLabelFont(themeTickLabelFont); RectangleInsets defaultTickLabelInsets = (RectangleInsets) getDefaultValue(defaultAxisPropertiesMap, ChartThemesConstants.AXIS_TICK_LABEL_INSETS); if (defaultTickLabelInsets != null) { axis.setTickLabelInsets(defaultTickLabelInsets); } Paint tickLabelPaint = tickLabelColor != null ? tickLabelColor : (Paint) getDefaultValue(defaultAxisPropertiesMap, ChartThemesConstants.AXIS_TICK_LABEL_PAINT); if (tickLabelPaint != null) { axis.setTickLabelPaint(tickLabelPaint); } TimeZone timeZone = getChartContext().getTimeZone(); if (axis instanceof DateAxis && timeZone != null) { // used when no mask is set ((DateAxis) axis).setTimeZone(timeZone); } if (tickLabelMask != null) { if (axis instanceof NumberAxis) { NumberFormat fmt = NumberFormat.getInstance(); if (fmt instanceof DecimalFormat) ((DecimalFormat) fmt).applyPattern(tickLabelMask); ((NumberAxis) axis).setNumberFormatOverride(fmt); } else if (axis instanceof DateAxis) { DateFormat fmt; if (tickLabelMask.equals("SHORT") || tickLabelMask.equals("DateFormat.SHORT")) fmt = DateFormat.getDateInstance(DateFormat.SHORT); else if (tickLabelMask.equals("MEDIUM") || tickLabelMask.equals("DateFormat.MEDIUM")) fmt = DateFormat.getDateInstance(DateFormat.MEDIUM); else if (tickLabelMask.equals("LONG") || tickLabelMask.equals("DateFormat.LONG")) fmt = DateFormat.getDateInstance(DateFormat.LONG); else if (tickLabelMask.equals("FULL") || tickLabelMask.equals("DateFormat.FULL")) fmt = DateFormat.getDateInstance(DateFormat.FULL); else fmt = new SimpleDateFormat(tickLabelMask); // FIXME fmt cannot be null if (fmt != null) { if (timeZone != null) { fmt.setTimeZone(timeZone); } ((DateAxis) axis).setDateFormatOverride(fmt); } else ((DateAxis) axis).setDateFormatOverride( DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT)); } // ignore mask for other axis types. } } }
From source file:it.fub.jardin.server.DbUtils.java
public User getSimpleUser(Credentials credentials) throws VisibleException { String username = credentials.getUsername(); String password = credentials.getPassword(); ResultSet result;/*from w w w . j a v a 2s . c om*/ Connection connection; try { connection = this.dbConnectionHandler.getConn(); } catch (HiddenException e) { throw new VisibleException(e.getLocalizedMessage()); } String query = "SELECT u.id, u.name, u.surname, u.email, u.office, " + "u.telephone, u.status AS userstatus, u.lastlogintime, " + "u.logincount, g.id AS groupid, g.name AS groupname " + "FROM " + T_USER + " u JOIN " + T_GROUP + " g ON g.id = u.id_group " + "WHERE username = ? and password = PASSWORD(?) AND u.status = '1'"; // JardinLogger.debug("query getuser:" // + "SELECT u.id, u.name, u.surname, u.email, u.office, " // + "u.telephone, u.status AS userstatus, u.lastlogintime, " // + "u.logincount, g.id AS groupid, g.name AS groupname " + "FROM " // + T_USER + " u JOIN " + T_GROUP + " g ON g.id = u.id_group " // + "WHERE username = " + username + " and password = PASSWORD(" // + password + ") AND status = '1'"); PreparedStatement ps; try { ps = connection.prepareStatement(query); ps.setString(1, username); ps.setString(2, password); } catch (SQLException e) { throw new VisibleException("Errore nella query " + "per la verifica di username e password"); } try { result = ps.executeQuery(); } catch (SQLException e) { // Log.debug("User validation query: " + ps.toString()); e.printStackTrace(); throw new VisibleException("Errore durante l'interrogazione su database"); } int rows = 0; try { while (result.next()) { rows++; if (rows > 1) { throw new VisibleException( "Errore nel database degli utenti: " + "due account con username e password uguali"); } // JardinLogger.info("LOGIN: login utente " + credentials.getUsername() // + " RIUSCITO!"); /* Creazione dell'utente con i dati del database */ int uid = result.getInt("id"); int gid = result.getInt("groupid"); String name = result.getString("name"); String surname = result.getString("surname"); String group = result.getString("groupname"); String email = result.getString("email"); String office = result.getString("office"); String telephone = result.getString("telephone"); int status = result.getInt("userstatus"); int login = result.getInt("logincount"); DateFormat df = DateFormat.getDateInstance(DateFormat.FULL, Locale.getDefault()); String last = df.format(new Date()); /* Carica le preferenze dell'utente */ List<Message> messages = new ArrayList<Message>(); User user = new User(uid, gid, new Credentials(username, password), name, surname, group, email, office, telephone, status, login, last); this.user = user; if (login > 0) { login++; this.updateLoginCount(uid, login); // System.out.println("conto login: " + login); } return user; } } catch (Exception e) { // Log.warn("Errore SQL", e); throw new VisibleException("Errore di accesso " + "al risultato dell'interrogazione su database"); } finally { try { this.dbConnectionHandler.closeConn(connection); } catch (HiddenException e) { // TODO Auto-generated catch block e.printStackTrace(); } } // JardinLogger.info("Errore LOGIN: tentativo di login utente " // + credentials.getUsername() + " FALLITO!"); throw new VisibleException("Errore di accesso: username o password errati"); }