List of usage examples for org.apache.commons.lang.time FastDateFormat format
public String format(Calendar calendar)
Formats a Calendar
object.
From source file:net.joinedminds.tools.evet.TimeValueTable.java
private JSONObject getJsonObject() { FastDateFormat fdf = resolution == Db.CountResolution.Day ? DATE_FORMAT : DATETIME_FORMAT; JSONObject data = new JSONObject(); JSONArray categories = new JSONArray(); JSONArray values = new JSONArray(); SortedSet<Date> keys = new TreeSet<>(); keys.addAll(keySet());/*from w w w.j a va 2 s . com*/ for (Date key : keys) { categories.add(fdf.format(key)); values.add(get(key).get(0)); //TODO support multisets } data.put("categories", categories); data.put("data", values); return data; }
From source file:com.intuit.tank.job.ActJobNodeBean.java
public ActJobNodeBean(JobInstance job, boolean hasRights, FastDateFormat fmt) { super();// ww w . j av a2 s. c o m this.setHasRights(hasRights); this.setName(job.getName()); this.setJobId(String.valueOf(job.getId())); this.setId(String.valueOf(job.getId())); this.setReportMode(job.getReportingMode().toString()); this.setStatus(job.getStatus().toString()); this.setRegion(""); this.setActiveUsers(String.valueOf(job.getBaselineVirtualUsers())); this.setTotalUsers(String.valueOf(job.getTotalVirtualUsers())); this.jobDetails = job.getJobDetails(); if (job.getStartTime() != null) { this.setStartTime(fmt.format(job.getStartTime())); } else { this.setStartTime(""); } if (job.getEndTime() != null) { this.setEndTime(fmt.format(job.getEndTime())); } else { this.setEndTime(""); } }
From source file:com.intuit.tank.job.VMNodeBean.java
public VMNodeBean(CloudVmStatus vmStatus, boolean hasRights, FastDateFormat fmt) { super();//from ww w.j ava 2 s . c o m this.setHasRights(hasRights); this.setName("Agent"); this.setJobId(vmStatus.getJobId()); this.setId(vmStatus.getInstanceId()); this.setReportMode(""); this.setStatus(vmStatus.getJobStatus().toString()); this.setRegion(vmStatus.getVmRegion().toString()); this.setActiveUsers(String.valueOf(vmStatus.getCurrentUsers())); this.setNumFailures(vmStatus.getValidationFailures()); this.setUserDetails(vmStatus.getUserDetails()); this.setTotalUsers(String.valueOf(vmStatus.getTotalUsers())); setTps(vmStatus.getTotalTps()); if (vmStatus.getStartTime() != null) { this.setStartTime(fmt.format(vmStatus.getStartTime())); } else { this.setStartTime(""); } if (vmStatus.getEndTime() != null) { this.setEndTime(fmt.format(vmStatus.getEndTime())); } else { this.setEndTime(""); } }
From source file:com.tesora.dve.mysqlapi.repl.MyReplicationSlaveService.java
@Override public void restart() throws PEException { stop();//from w ww.jav a 2 s . c o m // initiate reconnection on new thread to allow existing i/o thread to resume channel closed processing reconnectThread = new Thread(new Runnable() { @Override public void run() { FastDateFormat formatter = FastDateFormat.getDateTimeInstance(FastDateFormat.MEDIUM, FastDateFormat.MEDIUM); long retries = 0; long start = System.currentTimeMillis(); long lastAttempt = start; logger.info("Replication slave lost connection on " + formatter.format(start) + ". Attempting to reconnect with the following parameters: " + MyReplicationSlaveConfig.REPL_SLAVE_MASTER_RETRY_CONNECT + "=" + myConfig.getMasterConnectRetry() + " seconds" + ", " + MyReplicationSlaveConfig.REPL_SLAVE_SLAVE_NET_TIMEOUT + "=" + myConfig.getSlaveNetTimeout() + " seconds" + ", " + MyReplicationSlaveConfig.REPL_SLAVE_MASTER_RETRY_COUNT + "=" + myConfig.getMasterRetryCount()); while (myClient == null || !myClient.isConnected()) { if (Thread.interrupted()) { logger.info("Replication slave reconnection was terminated by STOP service command."); reconnectThread = null; break; } if (((retries > 0) && (retries >= myConfig.getMasterRetryCount())) || ((lastAttempt - start) / 1000) > myConfig.getSlaveNetTimeout()) { logger.warn( "Replication slave was unable to reconnect and will stop replication. Total attempts=" + retries + ", Started=" + formatter.format(start) + ", Ended=" + formatter.format(lastAttempt)); reconnectThread = null; return; } try { Thread.sleep(myConfig.getMasterConnectRetry() * 1000); } catch (Exception e) { logger.info("Replication slave reconnection was terminated by STOP service command."); reconnectThread = null; return; } if (Thread.interrupted()) { reconnectThread = null; logger.info("Replication slave reconnection was terminated by STOP service command."); break; } retries++; lastAttempt = System.currentTimeMillis(); try { if (logger.isDebugEnabled()) { logger.debug("Replication slave reconnect attempt #" + retries + " at " + formatter.format(lastAttempt)); } start(false); } catch (Exception e) { // do nothing if (logger.isDebugEnabled()) { logger.debug("Replication slave reconnect attempt #" + retries + " failed.", e); } } } if (myClient.isConnected()) { // successfully reconnected logger.info("Replication slave successfully reconnected on attempt " + retries + " on " + formatter.format(lastAttempt)); } } }, "ReplicationReconnect"); reconnectThread.start(); }
From source file:com.tesora.dve.db.mysql.DBTypeBasedUtilsTest.java
@Test public void mysqlConvertToObjectTest() throws Exception { ColumnMetadata colMd = new ColumnMetadata(); FastDateFormat fdfDate = FastDateFormat.getInstance(MysqlNativeConstants.MYSQL_DATE_FORMAT); FastDateFormat fdfDateTime = FastDateFormat.getInstance(MysqlNativeConstants.MYSQL_DATETIME_FORMAT); FastDateFormat fdfTime = FastDateFormat.getInstance(MysqlNativeConstants.MYSQL_TIME_FORMAT); FastDateFormat fdfTimestamp = FastDateFormat.getInstance(MysqlNativeConstants.MYSQL_TIMESTAMP_FORMAT); for (Pair<MyFieldType, Object> expValue : expValuesMysql) { DataTypeValueFunc dtvf = DBTypeBasedUtils.getMysqlTypeFunc(expValue.getFirst()); assertNotNull("Couldn't find function for " + expValue.getFirst(), dtvf); if (expValue.getSecond() != null) { String value;// w w w.j a v a 2 s. com if (MyFieldType.FIELD_TYPE_DATE.equals(expValue.getFirst())) { value = fdfDate.format(expValue.getSecond()); } else if (MyFieldType.FIELD_TYPE_DATETIME.equals(expValue.getFirst())) { value = fdfDateTime.format(expValue.getSecond()); } else if (MyFieldType.FIELD_TYPE_TIME.equals(expValue.getFirst())) { value = fdfTime.format(expValue.getSecond()); } else if (MyFieldType.FIELD_TYPE_TIMESTAMP.equals(expValue.getFirst())) { value = fdfTimestamp.format(expValue.getSecond()); } else if (MyFieldType.FIELD_TYPE_BIT.equals(expValue.getFirst())) { value = new String((byte[]) expValue.getSecond(), CharsetUtil.ISO_8859_1); } else { value = expValue.getSecond().toString(); } Object valueObj = dtvf.convertStringToObject(value, colMd); assertEqualData(expValue.getSecond(), valueObj); } } }
From source file:com.smartitengineering.cms.spi.impl.type.ContentTypeObjectConverter.java
@Override public PersistentContentType rowsToObject(Result startRow, ExecutorService executorService) { try {/*from w ww .j a va 2 s.c o m*/ PersistableContentType contentType = SmartContentSPI.getInstance().getPersistableDomainFactory() .createPersistableContentType(); PersistentContentType persistentContentType = new PersistentContentType(); /* * Simple fields */ persistentContentType.setMutableContentType(contentType); persistentContentType.setVersion(0l); logger.info("::::::::::::::::::::: Converting rowId to ContentTypeId :::::::::::::::::::::"); contentType.setContentTypeID(getInfoProvider().getIdFromRowId(startRow.getRow())); if (logger.isInfoEnabled()) { logger.info(new StringBuilder("ContentTypeId ").append(contentType.getContentTypeID()).toString()); } Map<byte[], byte[]> simpleValues = startRow.getFamilyMap(FAMILY_SIMPLE); byte[] displayName = simpleValues.remove(CELL_DISPLAY_NAME); if (displayName != null) { logger.debug("Set display name of the content type!"); contentType.setDisplayName(Bytes.toString(displayName)); } byte[] primaryFieldName = simpleValues.remove(CELL_PRIMARY_FIELD_NAME); if (primaryFieldName != null) { final String toString = Bytes.toString(primaryFieldName); if (logger.isDebugEnabled()) { logger.debug("Set primary field name of the content type!" + toString); } contentType.setPrimaryFieldName(toString); } byte[] defTyoe = simpleValues.remove(CELL_DEF_TYPE); if (defTyoe != null) { final String toString = Bytes.toString(defTyoe); if (logger.isDebugEnabled()) { logger.debug("Set primary field name of the content type!" + toString); } contentType.setDefinitionType(ContentType.DefinitionType.valueOf(toString)); } contentType.setEntityTagValue(Bytes.toString(simpleValues.remove(CELL_ENTITY_TAG))); logger.debug("Setting creation and last modified date"); contentType.setCreationDate(Utils.toDate(simpleValues.remove(CELL_CREATION_DATE))); contentType.setLastModifiedDate(Utils.toDate(simpleValues.remove(CELL_LAST_MODIFIED_DATE))); final byte[] parentId = simpleValues.remove(CELL_PARENT_ID); if (parentId != null) { logger.debug("Setting parent id"); contentType.setParent(getInfoProvider().getIdFromRowId(parentId)); } if (!simpleValues.isEmpty()) { String displayNamesPrefix = new StringBuilder(CELL_PARAMETERIZED_DISPLAY_NAME_PREFIX).append(':') .toString(); final byte[] toBytes = Bytes.toBytes(CELL_PARAMETERIZED_DISPLAY_NAME_PREFIX); for (Entry<byte[], byte[]> entry : simpleValues.entrySet()) { if (logger.isDebugEnabled()) { logger.debug("Extra simple fields Key " + Bytes.toString(entry.getKey()) + " " + Bytes.startsWith(entry.getKey(), toBytes)); logger.debug("Extra simple fields Value " + Bytes.toString(entry.getValue())); } if (Bytes.startsWith(entry.getKey(), toBytes)) { String paramKey = Bytes.toString(entry.getKey()).substring(displayNamesPrefix.length()); String paramVal = Bytes.toString(entry.getValue()); contentType.getMutableParameterizedDisplayNames().put(paramKey, paramVal); } } } if (logger.isDebugEnabled()) { final FastDateFormat formatter = DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT; logger.debug(String.format("Creation date is %s and last modified date is %s", formatter.format(contentType.getCreationDate()), formatter.format(contentType.getLastModifiedDate()))); logger.debug(String.format("Id is %s and parent id is %s", contentType.getContentTypeID().toString(), ObjectUtils.toString(contentType.getParent()))); } /* * Content status */ logger.debug("Form statuses"); NavigableMap<byte[], byte[]> statusMap = startRow.getFamilyMap(FAMILY_STATUSES); int index = 0; for (byte[] statusName : statusMap.navigableKeySet()) { final String statusNameStr = Bytes.toString(statusName); if (logger.isDebugEnabled()) { logger.debug(new StringBuilder("Forming content status for ").append(statusNameStr).toString()); } //Value not required as both are the same for status MutableContentStatus contentStatus = SmartContentAPI.getInstance().getContentTypeLoader() .createMutableContentStatus(); contentStatus.setContentTypeID(contentType.getContentTypeID()); contentStatus.setId(++index); contentStatus.setName(statusNameStr); contentType.getMutableStatuses().add(contentStatus); } /* * Representations */ logger.debug("Form representations!"); NavigableMap<byte[], byte[]> representationMap = startRow.getFamilyMap(FAMILY_REPRESENTATIONS); Map<String, MutableRepresentationDef> reps = new HashMap<String, MutableRepresentationDef>(); for (byte[] keyBytes : representationMap.navigableKeySet()) { final String key = Bytes.toString(keyBytes); if (logger.isDebugEnabled()) { logger.debug(new StringBuilder("Work with key ").append(key).toString()); } final int indexOfFirstColon = key.indexOf(':'); final String repName = key.substring(0, indexOfFirstColon); final byte[] qualifier = Bytes.toBytes(key.substring(indexOfFirstColon + 1)); if (logger.isDebugEnabled()) { logger.debug(new StringBuilder("Representation name ").append(repName).toString()); logger.debug(new StringBuilder("Representation qualifier ").append(Bytes.toString(qualifier)) .toString()); } MutableRepresentationDef representationDef = reps.get(repName); if (representationDef == null) { logger.debug("Creating new representation def and putting to map"); representationDef = SmartContentAPI.getInstance().getContentTypeLoader() .createMutableRepresentationDef(); reps.put(repName, representationDef); representationDef.setName(repName); } final byte[] value = representationMap.get(keyBytes); fillResourceDef(qualifier, representationDef, value); } contentType.getMutableRepresentationDefs().addAll(reps.values()); /* * Content Co-Processors */ logger.debug("Form Content Co-Processors!"); NavigableMap<byte[], byte[]> ccpMap = startRow.getFamilyMap(FAMILY_CCP); Map<String, MutableContentCoProcessorDef> ccps = new HashMap<String, MutableContentCoProcessorDef>(); for (byte[] keyBytes : ccpMap.navigableKeySet()) { final String key = Bytes.toString(keyBytes); if (logger.isDebugEnabled()) { logger.debug(new StringBuilder("CCP Work with key ").append(key).toString()); } final int indexOfFirstColon = key.indexOf(':'); final String ccpName = key.substring(0, indexOfFirstColon); final byte[] qualifier = Bytes.toBytes(key.substring(indexOfFirstColon + 1)); if (logger.isDebugEnabled()) { logger.debug(new StringBuilder("CCP name ").append(ccpName).toString()); logger.debug(new StringBuilder("CCP qualifier ").append(Bytes.toString(qualifier)).toString()); } MutableContentCoProcessorDef ccpDef = ccps.get(ccpName); if (ccpDef == null) { logger.debug("Creating new content co processor def and putting to map"); ccpDef = SmartContentAPI.getInstance().getContentTypeLoader() .createMutableContentCoProcessorDef(); ccps.put(ccpName, ccpDef); ccpDef.setName(ccpName); } final byte[] value = ccpMap.get(keyBytes); if (Arrays.equals(qualifier, CELL_CCP_PHASE)) { ccpDef.setPhase(ContentType.ContentProcessingPhase.valueOf(Bytes.toString(value))); } else if (Arrays.equals(qualifier, CELL_CCP_PRIORITY)) { ccpDef.setPriority(Bytes.toInt(value)); } else { fillResourceDef(qualifier, ccpDef, value); } } List<MutableContentCoProcessorDef> ccpDefs = new ArrayList<MutableContentCoProcessorDef>(ccps.values()); Collections.sort(ccpDefs, new Comparator<ContentCoProcessorDef>() { public int compare(ContentCoProcessorDef o1, ContentCoProcessorDef o2) { return o1.getPriority() - o2.getPriority(); } }); for (MutableContentCoProcessorDef ccpDef : ccpDefs) { contentType.addContentCoProcessorDef(ccpDef); } /* * Fields */ NavigableMap<byte[], byte[]> fieldMap = startRow.getFamilyMap(FAMILY_FIELDS); //From a map of all cells form a map of cells by field name Map<String, Map<String, byte[]>> fieldsByName = new LinkedHashMap<String, Map<String, byte[]>>(); Utils.organizeByPrefix(fieldMap, fieldsByName, ':'); for (String fieldName : fieldsByName.keySet()) { final MutableFieldDef fieldDef = SmartContentAPI.getInstance().getContentTypeLoader() .createMutableFieldDef(); final Map<String, byte[]> fieldCells = fieldsByName.get(fieldName); populateFieldDef(fieldDef, fieldName, fieldCells); contentType.getMutableFieldDefs().add(fieldDef); } /* * Variants of content type */ Map<byte[], byte[]> variants = startRow.getFamilyMap(FAMILY_TYPE_REPRESENTATIONS); if (variants != null && !variants.isEmpty()) { final Map<MediaType, String> variantMap = new HashMap<MediaType, String>(variants.size()); for (byte[] mediaType : variants.keySet()) { variantMap.put(MediaType.fromString(Bytes.toString(mediaType)), Bytes.toString(variants.get(mediaType))); } contentType.setRepresentations(variantMap); contentType.setFromPersistentStorage(true); } return persistentContentType; } catch (Exception ex) { logger.warn("Error converting result to content type, throwing exception...", ex); throw new RuntimeException(ex); } }
From source file:inti.util.DateFormatterPerformanceTest.java
public void format(int count) throws Exception { Date date = new Date(); DateFormatter dateFormatter = new DateFormatter(); FastDateFormat fastDateFormat = FastDateFormat.getInstance("EEE, dd-MMM-yyyy hh:mm:ss 'GMT'"); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("EEE, dd-MMM-yyyy hh:mm:ss 'GMT'"); StringBuilder builder = new StringBuilder(); long start, end; Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT"), Locale.ENGLISH); for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { dateFormatter.formatDate(date.getTime(), Format.RFC1123, builder, cal); builder.delete(0, builder.length()); }/* w w w. j a v a 2 s .co m*/ Thread.sleep(10); } start = System.currentTimeMillis(); for (int i = 0; i < count; i++) { dateFormatter.formatDate(date.getTime(), Format.RFC1123, builder, cal); builder.delete(0, builder.length()); } end = System.currentTimeMillis(); System.out.format("format(DateFormatter-special) - count: %d, duration: %dms, ratio: %#.4f", count, end - start, count / ((end - start) / 1000.0)); System.out.println(); for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { dateFormatter.formatDate(date.getTime()); } Thread.sleep(10); } start = System.currentTimeMillis(); for (int i = 0; i < count; i++) { dateFormatter.formatDate(date.getTime()); } end = System.currentTimeMillis(); System.out.format("format(DateFormatter-simple) - count: %d, duration: %dms, ratio: %#.4f", count, end - start, count / ((end - start) / 1000.0)); System.out.println(); for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { fastDateFormat.format(date); } Thread.sleep(10); } start = System.currentTimeMillis(); for (int i = 0; i < count; i++) { fastDateFormat.format(date); } end = System.currentTimeMillis(); System.out.format("format(FastDateFormat) - count: %d, duration: %dms, ratio: %#.4f", count, end - start, count / ((end - start) / 1000.0)); System.out.println(); for (int i = 0; i < 100; i++) { for (int j = 0; j < 10; j++) { simpleDateFormat.format(date); } Thread.sleep(10); } start = System.currentTimeMillis(); for (int i = 0; i < count; i++) { simpleDateFormat.format(date); } end = System.currentTimeMillis(); System.out.format("format(SimpleDateFormat) - count: %d, duration: %dms, ratio: %#.4f", count, end - start, count / ((end - start) / 1000.0)); System.out.println(); }
From source file:com.benfante.minimark.blo.AssessmentXMLFOBuilder.java
private StringBuilder makeHeader(StringBuilder result, AssessmentFilling assessment, Locale locale) { FastDateFormat dateTimeFormat = FastDateFormat.getDateTimeInstance(FastDateFormat.SHORT, FastDateFormat.SHORT, locale); result.append("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>").append('\n'); result.append("<!DOCTYPE root [").append('\n'); result.append(" <!ELEMENT root (#PCDATA) >").append('\n'); result.append(/*w w w. j av a 2 s. c om*/ " <!ENTITY rchk '<fo:external-graphic src=\"url('images/interface/rchk.gif')\" content-height=\"9pt\" content-width=\"9pt\"/>' >") .append('\n'); result.append( " <!ENTITY ruchk '<fo:external-graphic src=\"url('images/interface/ruchk.gif')\" content-height=\"9pt\" content-width=\"9pt\"/>' >") .append('\n'); result.append( " <!ENTITY cchk '<fo:external-graphic src=\"url('images/interface/cchk.jpg')\" content-height=\"9pt\" content-width=\"9pt\"/>' >") .append('\n'); result.append( " <!ENTITY cuchk '<fo:external-graphic src=\"url('images/interface/cuchk.jpg')\" content-height=\"9pt\" content-width=\"9pt\"/>' >") .append('\n'); result.append(" <!ENTITY agrave 'à' >").append('\n'); result.append(" <!ENTITY egrave 'è' >").append('\n'); result.append(" <!ENTITY igrave 'ì' >").append('\n'); result.append(" <!ENTITY ograve 'ò' >").append('\n'); result.append(" <!ENTITY ugrave 'ù' >").append('\n'); result.append(" <!ENTITY aacute 'á' >").append('\n'); result.append(" <!ENTITY eacute 'é' >").append('\n'); result.append(" <!ENTITY iacute 'í' >").append('\n'); result.append(" <!ENTITY oacute 'ó' >").append('\n'); result.append(" <!ENTITY uacute 'ú' >").append('\n'); result.append("]>").append('\n'); result.append("<fo:root xmlns:fo=\"http://www.w3.org/1999/XSL/Format\">").append('\n'); result.append(" <fo:layout-master-set>").append('\n'); result.append( " <fo:simple-page-master master-name=\"normal\" page-height=\"210mm\" page-width=\"297mm\" margin-top=\"1cm\" margin-bottom=\"0.5cm\" margin-left=\"1.5cm\" margin-right=\"1.5cm\">") .append('\n'); result.append( " <fo:region-body margin-top=\"0cm\" margin-bottom=\"1.5cm\" column-count=\"2\" column-gap=\"0.25in\"/>") .append('\n'); result.append(" <fo:region-before extent=\"0cm\"/>").append('\n'); result.append(" <fo:region-after extent=\"1cm\"/>").append('\n'); result.append(" </fo:simple-page-master>").append('\n'); result.append( " <fo:simple-page-master master-name=\"blank\" page-height=\"210mm\" page-width=\"297mm\" margin-top=\"1cm\" margin-bottom=\"0.5cm\" margin-left=\"1.5cm\" margin-right=\"1.5cm\">") .append('\n'); result.append(" <fo:region-body/>").append('\n'); result.append(" <fo:region-before region-name=\"header-blank\" extent=\"297mm\"/>").append('\n'); result.append(" <fo:region-after extent=\"1cm\"/>").append('\n'); result.append(" </fo:simple-page-master>").append('\n'); result.append(" <fo:page-sequence-master master-name=\"all\">").append('\n'); result.append(" <fo:repeatable-page-master-alternatives>").append('\n'); result.append( " <fo:conditional-page-master-reference blank-or-not-blank=\"not-blank\" master-reference=\"normal\"/>") .append('\n'); result.append( " <fo:conditional-page-master-reference blank-or-not-blank=\"blank\" master-reference=\"blank\"/>") .append('\n'); result.append(" </fo:repeatable-page-master-alternatives>").append('\n'); result.append(" </fo:page-sequence-master>").append('\n'); result.append(" </fo:layout-master-set>").append('\n'); result.append( " <fo:page-sequence id=\"assprintseq\" master-reference=\"all\" font-family=\"sans-serif\" font-size=\"9pt\" line-height=\"11pt\" space-after.optimum=\"12pt\" force-page-count=\"end-on-even\">") .append('\n'); result.append(" <fo:static-content flow-name=\"header-blank\">"); result.append(" <fo:block space-before=\"100mm\" text-align-last=\"center\">").append( messageSource.getMessage("IntentionallyLeftBlank", null, "?IntentionallyLeftBlank?", locale)) .append("</fo:block>"); result.append(" </fo:static-content>"); result.append(" <fo:static-content flow-name=\"xsl-region-after\">").append('\n'); result.append(" <fo:block>").append('\n'); result.append(" <fo:table table-layout=\"fixed\" width=\"264mm\">").append('\n'); result.append(" <fo:table-column column-width=\"88mm\"/>").append('\n'); result.append(" <fo:table-column column-width=\"88mm\"/>").append('\n'); result.append(" <fo:table-column column-width=\"88mm\"/>").append('\n'); result.append(" <fo:table-body>").append('\n'); result.append(" <fo:table-row>").append('\n'); result.append(" <fo:table-cell text-align=\"start\">").append('\n'); result.append(" <fo:block>").append('\n'); result.append(" <![CDATA[").append(assessment.getIdentifier()).append(' ') .append(assessment.getFirstName()).append(' ').append(assessment.getLastName()).append("]]>") .append('\n'); result.append(" </fo:block>").append('\n'); result.append(" </fo:table-cell>").append('\n'); result.append(" <fo:table-cell text-align=\"center\">").append('\n'); result.append(" <fo:block>").append('\n'); result.append(" ") .append(assessment.getSubmittedDate() != null ? dateTimeFormat.format(assessment.getSubmittedDate()) : messageSource.getMessage("NotSubmitted", null, "?NotSubmitted?", locale)) .append('\n'); result.append(" </fo:block>").append('\n'); result.append(" </fo:table-cell>").append('\n'); result.append(" <fo:table-cell text-align=\"end\">").append('\n'); result.append(" <fo:block>").append('\n'); result.append(messageSource.getMessage("PageNOfM", new String[] { "<fo:page-number/>", "<fo:page-number-citation-last ref-id='assprintseq'/>" }, "?PageNOfM?", locale)).append('\n'); result.append(" </fo:block>").append('\n'); result.append(" </fo:table-cell>").append('\n'); result.append(" </fo:table-row>").append('\n'); result.append(" </fo:table-body>").append('\n'); result.append(" </fo:table>").append('\n'); result.append(" </fo:block>").append('\n'); result.append(" </fo:static-content>").append('\n'); result.append(" <fo:flow flow-name=\"xsl-region-body\">").append('\n'); result.append(" <fo:block font-size=\"11pt\" font-weight=\"bold\" text-align=\"center\">") .append('\n'); result.append(" <fo:block space-after=\"11pt\">").append(assessment.getAssessment().getTitle()) .append("</fo:block>").append('\n'); result.append(" <fo:block>") .append(messageSource.getMessage("Incumbent", null, "?Incumbent?", locale)).append(": ") .append(assessment.getAssessment().getCourse().getIncumbent()).append("</fo:block>").append('\n'); result.append(" <fo:block>").append(dateTimeFormat.format(assessment.getStartDate())) .append("</fo:block>").append('\n'); result.append(" </fo:block>").append('\n'); return result; }
From source file:org.ala.spatial.services.web.DashboardController.java
@RequestMapping(value = { DASHBOARD_HOME, DASHBOARD_INDEX }) public ModelAndView index(HttpServletRequest req) { if (!Utilities.isLoggedIn(req)) { //ModelAndView mv = new ModelAndView("dashboard/types"); //mv.addAttribute("error", "authentication"); //mv.addAttribute("message", "Please authenticate yourself with the ALA system"); //return mv; return new ModelAndView("message", "msg", "Please authenticate yourself with the ALA system"); }// w w w.j ava2 s . co m String useremail = Utilities.getUserEmail(req); List<Action> abe = actionDao.getActionsByEmail(useremail); FastDateFormat df = FastDateFormat.getInstance("yyyy-MM-dd hh:mm"); HashMap<String, String> types = new HashMap<String, String>(); for (Action a : abe) { if (a.getService() == null) { continue; } String val = ""; if (types.containsKey(a.getCategory1())) { val = types.get(a.getCategory1()) + "|"; } val += a.getService().getName() + "-" + a.getId() + "-" + df.format(a.getTime()).replaceAll("-", "_"); types.put(a.getCategory1(), val); } List<Session> sessions = actionDao.getActionsBySessionsByUser(useremail); for (int i = 0; i < sessions.size(); i++) { Session session = sessions.get(i); String[] mal = session.getTasks().split(","); for (String s : mal) { session.incrementCount(s); } } ModelAndView mv = new ModelAndView("dashboard/index"); mv.addObject("abe", abe); mv.addObject("types", types); mv.addObject("sessions", sessions); mv.addObject("useremail", useremail); mv.addObject("isAdmin", Utilities.isUserAdmin(req)); return mv; }
From source file:org.ala.spatial.services.web.DashboardController.java
@RequestMapping(value = { DASHBOARD_HOME + "/types/{type}", "app/types/{type}" }) public ModelAndView displayFullTypeList(@PathVariable String type, HttpServletRequest req) { if (type.equals("")) { return index(req); }/*ww w .j ava 2 s .c om*/ String useremail = null; if (Utilities.isAppAuth(req)) { try { useremail = URLDecoder.decode(req.getParameter("email"), "UTF-8"); } catch (UnsupportedEncodingException e) { logger.error("User: " + req.getParameter("email")); return new ModelAndView("message", "msg", "Please authenticate yourself with the ALA system"); } } else if (!Utilities.isLoggedIn(req)) { //ModelAndView mv = new ModelAndView("dashboard/types"); //mv.addAttribute("error", "authentication"); //mv.addAttribute("message", "Please authenticate yourself with the ALA system"); //return mv; return new ModelAndView("message", "msg", "Please authenticate yourself with the ALA system"); } else { useremail = Utilities.getUserEmail(req); } List<Action> abe = actionDao.getActionsByEmailAndCategory1(useremail, type); FastDateFormat df = FastDateFormat.getInstance("yyyy-MM-dd hh:mm"); HashMap<String, String> types = new HashMap<String, String>(); for (Action a : abe) { if (a.getService() == null) { continue; } if (a.getCategory1() != null && !a.getCategory1().equalsIgnoreCase(type)) { continue; } String val = ""; if (types.containsKey(a.getCategory1())) { val = types.get(a.getCategory1()) + "|"; } val += a.getService().getName() + "-" + a.getId() + "-" + df.format(a.getTime()).replaceAll("-", "_"); types.put(a.getCategory1(), val); } String key = type.substring(0, 1).toUpperCase() + type.substring(1).toLowerCase(); ModelAndView mv = new ModelAndView("dashboard/types"); mv.addObject("abe", abe); mv.addObject("types", types); mv.addObject("key", key); mv.addObject("useremail", useremail); mv.addObject("isAdmin", Utilities.isUserAdmin(req)); return mv; }