List of usage examples for java.util TreeMap values
public Collection<V> values()
From source file:com.hichinaschool.flashcards.libanki.Decks.java
public void select(long did) { try {/* www . j a va 2 s. c o m*/ String name = mDecks.get(did).getString("name"); // current deck mCol.getConf().put("curDeck", Long.toString(did)); // and active decks (current + all children) TreeMap<String, Long> actv = children(did); actv.put(name, did); JSONArray ja = new JSONArray(); for (Long n : actv.values()) { ja.put(n); } mCol.getConf().put("activeDecks", ja); mChanged = true; } catch (JSONException e) { throw new RuntimeException(e); } }
From source file:org.waterforpeople.mapping.app.web.SurveyAssemblyServlet.java
private void assembleSurveyOnePass(Long surveyId) { /**************//from w ww. j a v a 2 s . co m * 1, Select survey based on surveyId 2. Retrieve all question groups fire off queue tasks */ log.warn("Starting assembly of " + surveyId); // Swap with proper UUID SurveyDAO surveyDao = new SurveyDAO(); Survey s = surveyDao.getById(surveyId); SurveyGroupDAO surveyGroupDao = new SurveyGroupDAO(); SurveyGroup sg = surveyGroupDao.getByKey(s.getSurveyGroupId()); Long transactionId = randomNumber.nextLong(); String lang = "en"; if (s != null && s.getDefaultLanguageCode() != null) { lang = s.getDefaultLanguageCode(); } final String versionAttribute = s.getVersion() == null ? "" : "version='" + s.getVersion() + "'"; String name = s.getName(); String surveyGroupId = ""; String surveyGroupName = ""; String registrationForm = ""; if (sg != null) { surveyGroupId = "surveyGroupId=\"" + sg.getKey().getId() + "\""; surveyGroupName = "surveyGroupName=\"" + StringEscapeUtils.escapeXml(sg.getCode()) + "\""; if (Boolean.TRUE.equals(sg.getMonitoringGroup())) { registrationForm = " registrationSurvey=\"" + sg.getNewLocaleSurveyId() + "\""; } } String surveyHeader = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><survey" + " name=\"" + StringEscapeUtils.escapeXml(name) + "\"" + " defaultLanguageCode=\"" + lang + "\" " + versionAttribute + registrationForm + " " + surveyGroupId + " " + surveyGroupName + ">"; String surveyFooter = "</survey>"; QuestionGroupDao qgDao = new QuestionGroupDao(); TreeMap<Integer, QuestionGroup> qgList = qgDao.listQuestionGroupsBySurvey(surveyId); if (qgList != null) { StringBuilder surveyXML = new StringBuilder(); surveyXML.append(surveyHeader); for (QuestionGroup item : qgList.values()) { log.warn("Assembling group " + item.getKey().getId() + " for survey " + surveyId); surveyXML.append(buildQuestionGroupXML(item)); } surveyXML.append(surveyFooter); log.warn("Uploading " + surveyId); UploadStatusContainer uc = uploadSurveyXML(surveyId, surveyXML.toString()); Message message = new Message(); message.setActionAbout("surveyAssembly"); message.setObjectId(surveyId); message.setObjectTitle(sg.getCode() + " / " + s.getName()); // String messageText = CONSTANTS.surveyPublishOkMessage() + " " // + url; if (uc.getUploadedFile() && uc.getUploadedZip()) { // increment the version so devices know to pick up the changes log.warn("Finishing assembly of " + surveyId); s.setStatus(Survey.Status.PUBLISHED); surveyDao.save(s); String messageText = "Published. Please check: " + uc.getUrl(); message.setShortMessage(messageText); message.setTransactionUUID(transactionId.toString()); MessageDao messageDao = new MessageDao(); messageDao.save(message); } else { // String messageText = // CONSTANTS.surveyPublishErrorMessage(); String messageText = "Failed to publish: " + surveyId + "\n" + uc.getMessage(); message.setTransactionUUID(transactionId.toString()); message.setShortMessage(messageText); MessageDao messageDao = new MessageDao(); messageDao.save(message); } log.warn("Completed onepass assembly method for " + surveyId); } }
From source file:org.rti.zcore.dar.report.OIDailyActivityReport.java
public void addPatientRecords(TreeMap<Date, OIPatient> patientRecords) { if (patients == null) { patients = new ArrayList<OIPatient>(); }//ww w . j a va 2 s .c o m patients.addAll(patientRecords.values()); }
From source file:jackpal.androidterm.TermPreferences.java
private void setAppPickerList() { PackageManager pm = this.getApplicationContext().getPackageManager(); final List<ApplicationInfo> installedAppList = pm.getInstalledApplications(0); final TreeMap<String, String> items = new TreeMap<>(); for (ApplicationInfo app : installedAppList) { Intent intent = pm.getLaunchIntentForPackage(app.packageName); if (intent != null) items.put(app.loadLabel(pm).toString(), app.packageName); }/*from w w w. ja v a 2 s.c om*/ List<String> list = new ArrayList<>(items.keySet()); final String labels[] = list.toArray(new String[list.size()]); list = new ArrayList<>(items.values()); final String packageNames[] = list.toArray(new String[list.size()]); String id = "external_app_package_name"; ListPreference packageName = (ListPreference) getPreferenceScreen().findPreference(id); packageName.setEntries(labels); packageName.setEntryValues(packageNames); }
From source file:com.mirth.connect.client.ui.alert.AlertChannelPane.java
public void setChannels(AlertChannels alertChannels, boolean includeConnectors) { if (PlatformUI.MIRTH_FRAME.channelPanel.getCachedChannelStatuses() != null) { TreeMap<String, Channel> channelMap = new TreeMap<String, Channel>(String.CASE_INSENSITIVE_ORDER); // Sort the channels by channel name for (ChannelStatus channelStatus : PlatformUI.MIRTH_FRAME.channelPanel.getCachedChannelStatuses() .values()) {//from w w w . j a v a 2s. co m Channel channel = channelStatus.getChannel(); channelMap.put(channel.getName(), channel); } ChannelTreeTableModel model = (ChannelTreeTableModel) channelTreeTable.getTreeTableModel(); model.addChannels(channelMap.values(), alertChannels, includeConnectors); } enableButton.setEnabled(false); disableButton.setEnabled(false); }
From source file:com.ichi2.libanki.Decks.java
/** * Select a new branch./* w ww .j a va 2 s. co m*/ */ public void select(long did) { try { String name = mDecks.get(did).getString("name"); // current deck mCol.getConf().put("curDeck", Long.toString(did)); // and active decks (current + all children) TreeMap<String, Long> actv = children(did); // Note: TreeMap is already sorted actv.put(name, did); JSONArray ja = new JSONArray(); for (Long n : actv.values()) { ja.put(n); } mCol.getConf().put("activeDecks", ja); mChanged = true; } catch (JSONException e) { throw new RuntimeException(e); } }
From source file:org.waterforpeople.mapping.app.web.SurveyAssemblyServlet.java
public String buildQuestionGroupXML(QuestionGroup item) { QuestionDao questionDao = new QuestionDao(); QuestionGroupDao questionGroupDao = new QuestionGroupDao(); QuestionGroup group = questionGroupDao.getByKey(item.getKey().getId()); TreeMap<Integer, Question> questionList = questionDao.listQuestionsByQuestionGroup(item.getKey().getId(), true);/*w w w .j a v a2 s . c om*/ StringBuilder sb = new StringBuilder("<questionGroup><heading>") .append(StringEscapeUtils.escapeXml(group.getCode())).append("</heading>"); if (questionList != null) { for (Question q : questionList.values()) { sb.append(marshallQuestion(q)); } } return sb.toString() + "</questionGroup>"; }
From source file:org.waterforpeople.mapping.app.web.SurveyAssemblyServlet.java
private void dispatchAssembleQuestionGroup(Long surveyId, String questionGroupIds, Long transactionId) { boolean isLast = true; String currentId = questionGroupIds; String remainingIds = null;/*from w w w .j av a 2 s . co m*/ if (questionGroupIds.contains(",")) { isLast = false; currentId = questionGroupIds.substring(0, questionGroupIds.indexOf(",")); remainingIds = questionGroupIds.substring(questionGroupIds.indexOf(",") + 1); } QuestionDao questionDao = new QuestionDao(); QuestionGroupDao questionGroupDao = new QuestionGroupDao(); QuestionGroup group = questionGroupDao.getByKey(Long.parseLong(currentId)); TreeMap<Integer, Question> questionList = questionDao .listQuestionsByQuestionGroup(Long.parseLong(currentId), true); StringBuilder sb = new StringBuilder("<questionGroup><heading>").append(group.getCode()) .append("</heading>"); if (questionList != null) { for (Question q : questionList.values()) { sb.append(marshallQuestion(q)); } } SurveyXMLFragment sxf = new SurveyXMLFragment(); sxf.setSurveyId(surveyId); sxf.setQuestionGroupId(Long.parseLong(currentId)); sxf.setFragmentOrder(group.getOrder()); sxf.setFragment(new Text(sb.append("</questionGroup>").toString())); sxf.setTransactionId(transactionId); sxf.setFragmentType(FRAGMENT_TYPE.QUESTION_GROUP); SurveyXMLFragmentDao sxmlfDao = new SurveyXMLFragmentDao(); sxmlfDao.save(sxf); if (isLast) { // Assemble the fragments sendQueueMessage(SurveyAssemblyRequest.ASSEMBLE_QUESTION_GROUP, surveyId, null, transactionId); } else { sendQueueMessage(SurveyAssemblyRequest.DISPATCH_ASSEMBLE_QUESTION_GROUP, surveyId, remainingIds, transactionId); } }
From source file:org.posterita.businesslogic.performanceanalysis.CustomPOSReportManager.java
public static TabularReport generateTabularReportGroupByDate(Properties ctx, String title, String subtitle, int account_id, Timestamp fromDate, Timestamp toDate, String salesGroup, String priceQtyFilter) throws OperationException { boolean isTaxDue = (account_id == Constants.TAX_DUE.intValue()); boolean isTaxCredit = (account_id == Constants.TAX_CREDIT.intValue()); NumberFormat formatter = new DecimalFormat("###,###,##0.00"); String sql = SalesAnalysisReportManager.getTabularDataSetSQL(ctx, account_id, fromDate, toDate, salesGroup); ArrayList<Object[]> tmpData = ReportManager.getReportData(ctx, sql, true); String currency = POSTerminalManager.getDefaultSalesCurrency(ctx).getCurSymbol(); ArrayList<Object[]> reportData = new ArrayList<Object[]>(); Object[] data = null;//from w w w . j av a 2s .c o m BigDecimal b = null; if (isTaxCredit || isTaxDue) { reportData.add(tmpData.remove(0)); Iterator<Object[]> iter = tmpData.iterator(); while (iter.hasNext()) { data = iter.next(); if (data.length == 1) { b = (BigDecimal) data[0]; data[0] = formatter.format(b.doubleValue()); } reportData.add(data); } } else { //---------------------------------------------------------------------------------------------------------------------------------------------------------- TreeMap<String, TabularReportRecordBean> map = new TreeMap<String, TabularReportRecordBean>(); String productName = null; BigDecimal price = null; BigDecimal qty = null; TabularReportRecordBean bean = null; ArrayList<Object[]> reportData2 = new ArrayList<Object[]>(); Object[] headers = tmpData.remove(0); //adding headers reportData2.add(new Object[] { headers[0], //headers[1], headers[2] + "(" + currency + ")", headers[3] }); double totalAmt = 0.0d; int totalQty = 0; for (Object[] record : tmpData) { productName = (String) record[0]; price = (BigDecimal) record[2]; qty = (BigDecimal) record[3]; totalAmt += price.doubleValue(); totalQty += qty.intValue(); bean = map.get(productName); if (bean == null) { bean = new TabularReportRecordBean(); bean.setProductName(productName); bean.setDate(""); bean.setPrice(price); bean.setQty(qty); } else { bean.setPrice(bean.getPrice().add(price)); bean.setQty(bean.getQty().add(qty)); } map.put(productName, bean); } //for Collection<TabularReportRecordBean> c = map.values(); for (TabularReportRecordBean tbean : c) { Object[] obj = new Object[] { tbean.getProductName(), tbean.getPrice(), tbean.getQty() }; reportData2.add(obj); } reportData.add(reportData2.remove(0)); Iterator<Object[]> iter = reportData2.iterator(); while (iter.hasNext()) { data = iter.next(); if (data.length > 2) { b = (BigDecimal) data[1]; data[1] = formatter.format(b.doubleValue()); } reportData.add(data); } reportData.add(new Object[] { "Total", "" + formatter.format(totalAmt), totalQty + "" }); } //style for table String tableStyle = "display"; //style for columns String[] styles = new String[] { "string", "currency", "numeric" }; if (isTaxCredit || isTaxDue) { styles = new String[] { "numeric" }; } //constructing the table TabularReport tReport = new TabularReport(reportData); //tReport.setSortable(true); tReport.setHeaderStyle(styles); tReport.setStyle(tableStyle); tReport.setTitle(title); tReport.setSubtitle(subtitle); tReport.createReport(); return tReport; }
From source file:com.terremark.impl.TerremarkClientImpl.java
/** * Internal method to retrieve the server supported API versions and time. If client specified a specific API * version, it is checked to see if the server supports it. {@link java.lang.IllegalArgumentException} is thrown if * the client API version is not supported by the server. If client did not specify a version, the latest version in * the server provided list is chosen for the client. The time difference between the server and the client is * computed and cached.//from w w w.j a va2 s.c o m * * @param clientVersion Client specified API version. Can be null. * @throws TerremarkException If error occurs while retrieving the server time and/or API versions. */ private void initialize(final Version clientVersion) throws TerremarkException { final SupportedVersions versions = getSupportedVersions(); final TreeMap<Date, String> versionDates = new TreeMap<Date, String>(); final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault()); for (final VersionInfo vi : versions.getVersionInfos()) { try { versionDates.put(sdf.parse(vi.getVersion()), vi.getVersion()); } catch (final ParseException ex) { throw new InternalServerException( "While validating the API version, got invalid version from server: " + vi.getVersion(), ex); } } String clientVersionStr = clientVersion == null ? null : clientVersion.toString(); if (clientVersionStr == null) { clientVersionStr = versionDates.lastEntry().getValue(); } else { if (!versionDates.values().contains(clientVersionStr)) { throw new IllegalArgumentException("Invalid API version: " + clientVersionStr); } } final Date serverDateTime = getTime().getCurrentServerTime().toGregorianCalendar().getTime(); versionAndDateProvider.setVersion(clientVersionStr); versionAndDateProvider.calculateClockSkew(serverDateTime); }