List of usage examples for java.util SortedSet add
boolean add(E e);
From source file:com.taobao.tddl.common.StatMonitor.java
void visitMap2(SortedSet<Item> sortedSet, ConcurrentHashMap<String, StatCounter> map2, String key1, String key2, String key3) {/*from w w w. j a v a 2 s .c o m*/ if ("*".equals(key3)) { for (Map.Entry<String, StatCounter> entry : map2.entrySet()) { sortedSet.add(new Item(key1, key2, entry.getKey(), entry.getValue().count.get(), entry.getValue().value.get())); } } else { StatCounter statCounter = map2.get(key3); if (statCounter != null) { sortedSet.add(new Item(key1, key2, key3, statCounter.count.get(), statCounter.value.get())); } } }
From source file:org.stockwatcher.data.cassandra.StockDAOImpl.java
@Override public SortedSet<Trade> getTradesBySymbolAndDate(StatementOptions options, String symbol, Date tradeDate) { if (symbol == null || symbol.length() == 0) { throw new IllegalArgumentException("symbol is null or zero length"); }//from ww w.j a v a2 s . c o m if (tradeDate == null) { throw new IllegalArgumentException("tradeDate is null"); } SortedSet<Trade> trades = new TreeSet<Trade>(); try { BoundStatement bs = selectTradesBySymbolAndDate.bind(); bs.setString("stock_symbol", symbol); bs.setDate("trade_date", tradeDate); for (Row row : execute(bs, options)) { trades.add(createTrade(row)); } } catch (DriverException e) { throw new DAOException(e); } return trades; }
From source file:net.sourceforge.fenixedu.presentationTier.Action.publico.department.PublicDepartmentSiteDA.java
private void setupTeachersAreas(HttpServletRequest request, Department department) { SortedSet<Unit> areas = new TreeSet<Unit>(Unit.COMPARATOR_BY_NAME_AND_ID); SortedSet<Teacher> teachersNoArea = new TreeSet<Teacher>(Teacher.TEACHER_COMPARATOR_BY_CATEGORY_AND_NUMBER); Map<String, SortedSet<Teacher>> teachers = new Hashtable<String, SortedSet<Teacher>>(); for (Teacher teacher : department.getAllCurrentTeachers()) { Unit area = teacher.getCurrentSectionOrScientificArea(); if (area != null) { areas.add(area); addListTeacher(teachers, area.getExternalId().toString(), teacher); } else {/* w ww . j a v a2s.com*/ teachersNoArea.add(teacher); } } if (areas.isEmpty()) { request.setAttribute("ignoreAreas", true); } request.setAttribute("areas", areas); request.setAttribute("teachers", teachers); request.setAttribute("teachersNoArea", teachersNoArea); }
From source file:com.migratebird.DefaultDbUpdate.java
/** * @return the repeatable scripts that failed during the last database update *///from ww w.ja va 2 s. com protected SortedSet<ExecutedScript> getRepeatableScriptsThatFailedDuringLastUpdate() { SortedSet<ExecutedScript> failedExecutedScripts = new TreeSet<ExecutedScript>(); for (ExecutedScript script : executedScriptInfoSource.getExecutedScripts()) { if (!script.isSuccessful() && script.getScript().isRepeatable()) { failedExecutedScripts.add(script); } } return failedExecutedScripts; }
From source file:com.migratebird.DefaultDbUpdate.java
/** * @return the incremental scripts that failed during the last database update *///from w w w.j av a 2s .co m protected SortedSet<ExecutedScript> getIncrementalScriptsThatFailedDuringLastUpdate() { SortedSet<ExecutedScript> failedExecutedScripts = new TreeSet<ExecutedScript>(); for (ExecutedScript script : executedScriptInfoSource.getExecutedScripts()) { if (!script.isSuccessful() && script.getScript().isIncremental()) { failedExecutedScripts.add(script); } } return failedExecutedScripts; }
From source file:br.com.hslife.orcamento.service.RelatorioCustomizadoServiceTest.java
@Test public void testProcessarRelatorioCustomizado() throws ApplicationException { // Instancia as colunas SortedSet<RelatorioColuna> colunas = new TreeSet<>(); // Nome da conta RelatorioColuna coluna = new RelatorioColuna(); coluna.setNomeColuna("nomeConta"); coluna.setOrdem(1);/*from w w w . j a v a 2 s.com*/ coluna.setTextoExibicao("Conta"); coluna.setTipoDado(TipoDado.STRING); coluna.setFormatar(false); colunas.add(coluna); // tipo de lanamento coluna = new RelatorioColuna(); coluna.setNomeColuna("tipoLancamento"); coluna.setOrdem(2); coluna.setTextoExibicao("Tipo"); coluna.setTipoDado(TipoDado.STRING); coluna.setFormatar(false); colunas.add(coluna); // descrio do lanamento coluna = new RelatorioColuna(); coluna.setNomeColuna("descricao"); coluna.setOrdem(3); coluna.setTextoExibicao("Descrio"); coluna.setTipoDado(TipoDado.STRING); coluna.setFormatar(false); colunas.add(coluna); // Data de pagamento coluna = new RelatorioColuna(); coluna.setNomeColuna("dataPagamento"); coluna.setOrdem(4); coluna.setTextoExibicao("Pago em"); coluna.setTipoDado(TipoDado.STRING); coluna.setFormatar(false); colunas.add(coluna); // valor pago coluna = new RelatorioColuna(); coluna.setNomeColuna("valorPago"); coluna.setOrdem(5); coluna.setTextoExibicao("Valor"); coluna.setTipoDado(TipoDado.STRING); coluna.setFormatar(false); colunas.add(coluna); // Instancia os parmetros Set<RelatorioParametro> parametros = new LinkedHashSet<>(); RelatorioParametro parametro = new RelatorioParametro(); // Data inicial parametro.setNomeParametro("dataInicio"); parametro.setTextoExibicao("Data Inicial"); parametro.setTipoDado(TipoDado.DATE); parametros.add(parametro); // Data final parametro = new RelatorioParametro(); parametro.setNomeParametro("dataFim"); parametro.setTextoExibicao("Data Fim"); parametro.setTipoDado(TipoDado.DATE); parametros.add(parametro); relatorio = EntityInitializerFactory.createRelatorioCustomizado(usuario, "select c.descricao as nomeConta, l.tipoLancamento, l.descricao, l.dataPagamento, l.valorPago from lancamentoconta l inner join conta c on c.id = l.idConta where l.dataPagamento >= :dataInicio and l.dataPagamento <= :dataFim and c.idUsuario = " + usuario.getId(), colunas, parametros); relatorioCustomizadoService.cadastrar(relatorio); Moeda moeda = EntityInitializerFactory.createMoeda(usuario); moedaService.cadastrar(moeda); Conta conta = EntityInitializerFactory.createConta(usuario, moeda); contaService.cadastrar(conta); for (int i = 1; i <= 5; i++) { LancamentoConta lancamento = new LancamentoConta(); lancamento.setConta(conta); lancamento.setMoeda(moeda); lancamento.setDataPagamento(new Date()); lancamento.setDescricao("Lanamento de teste " + i); lancamento.setValorPago(i * 100); lancamentoContaService.cadastrar(lancamento); } // Seta os parmetros Map<String, Object> parameterValues = new HashMap<>(); parameterValues.put("dataInicio", new Date()); parameterValues.put("dataFim", new Date()); List<Map<String, Object>> resultado = relatorioCustomizadoService.processarRelatorioCustomizado(relatorio, parameterValues); //Itera as linhas for (Map<String, Object> linhas : resultado) { // Itera as colunas System.out.println("Nome da conta: " + linhas.get("nomeConta")); System.out.println("Tipo: " + linhas.get("tipoLancamento")); System.out.println("Descrio: " + linhas.get("descricao")); System.out.println("Pago em: " + linhas.get("dataPagamento")); System.out.println("Valor: " + linhas.get("valorPago")); System.out.println(); } }
From source file:com.hmsinc.epicenter.service.ClassificationService.java
@PostConstruct public void init() throws Exception { logger.info("Initializing classifiers.."); new TransactionTemplate(transactionManager).execute(new TransactionCallbackWithoutResult() { /*//from w w w . j a va2s . c o m * (non-Javadoc) * * @see org.springframework.transaction.support.TransactionCallbackWithoutResult#doInTransactionWithoutResult(org.springframework.transaction.TransactionStatus) */ @Override protected void doInTransactionWithoutResult(TransactionStatus status) { // Configure default classifiers final List<Classifier> allClassifiers = analysisRepository.getList(Classifier.class); try { final ClassifierMetadata cm = (ClassifierMetadata) jaxbContext.createUnmarshaller() .unmarshal(configuration.getInputStream()); for (Classifier classifier : cm.getClassifiers()) { try { final ClassificationEngine engine = ClassifierFactory .createClassifier(classifier.getResource()); if (engine != null) { Validate.isTrue(engine.getName().equals(classifier.getName()), "Classifier names must match! (configured: " + classifier.getName() + " actual: " + engine.getName()); boolean isInstalled = false; for (Classifier installed : allClassifiers) { if (installed.getName().equals(engine.getName()) && installed.getVersion().equals(engine.getVersion())) { isInstalled = true; classifier = installed; break; } } classifiers.put(engine.getName(), engine); if (!isInstalled) { // Copy the properties and create // Classification objects classifier.setVersion(engine.getVersion()); classifier.setDescription(engine.getDescription()); logger.info("Installing classifier: {}", classifier.getName()); final SortedSet<Classification> classifications = new TreeSet<Classification>(); for (String category : engine.getCategories()) { if (!category.equalsIgnoreCase("Other")) { classifications.add(new Classification(classifier, category)); } } classifier.setClassifications(classifications); analysisRepository.save(classifier); } } } catch (IOException e) { logger.warn(e.getMessage()); } } // Load the and initialize any unconfigured classifiers.. for (Classifier classifier : allClassifiers) { if (classifier.isEnabled() && !classifiers.containsKey(classifier.getName())) { try { final ClassificationEngine engine = ClassifierFactory .createClassifier(classifier.getResource()); if (engine != null) { classifiers.put(engine.getName(), engine); } } catch (IOException e) { logger.warn(e.getMessage()); } } } // Configure DataTypes final List<DataType> dataTypes = cm.getDataTypes(); // Hydrate the PatientClasses because the XML descriptor // will only reference the name // Also remove any targets with unconfigured classifiers. for (DataType dataType : dataTypes) { logger.debug("Data type: " + dataType.toString()); final List<ClassificationTarget> unconfigured = new ArrayList<ClassificationTarget>(); for (ClassificationTarget ct : dataType.getTargets()) { if (ct.getClassifier() == null || ct.getClassifier().getId() == null && !classifiers.containsKey(ct.getClassifier().getName())) { logger.debug("Skipping unconfigured classification target"); unconfigured.add(ct); } else { final PatientClass pc = attributeRepository .getPatientClassByName(ct.getPatientClass().getName()); Validate.notNull(pc, "Unknown patient class: " + ct.getPatientClass().toString()); ct.setPatientClass(pc); if (classifiers.containsKey(ct.getClassifier().getName())) { ct.setClassifier( analysisRepository.getClassifierByName(ct.getClassifier().getName())); } } } dataType.getTargets().removeAll(unconfigured); } upgradeTasks.validateAttributes(dataTypes, DataType.class, analysisRepository); } catch (JAXBException e) { throw new RuntimeException(e); } catch (IOException e) { throw new RuntimeException(e); } } }); }
From source file:org.stockwatcher.data.cassandra.StockDAOImpl.java
@Override public SortedSet<Industry> getIndustries(StatementOptions options) { SortedSet<Industry> industries = new TreeSet<Industry>(); try {/*from w w w .j a va2 s .c om*/ Statement statement = select().column("industry_id").column("industry_name").column("sector_id") .column("sector_name").from("Industry"); for (Row row : execute(statement, options)) { industries.add(createIndustry(row)); } } catch (DriverException e) { throw new DAOException(e); } if (industries.isEmpty()) { throw new DAOException("no industries found"); } return industries; }
From source file:net.pms.dlna.protocolinfo.PanasonicDmpProfiles.java
/** * Tries to parse {@code dmpProfilesString} and adds the resulting * {@link ProtocolInfo} instances to the {@link Set} of type * {@link PanasonicDmpProfileType} in {@code deviceProtocolInfo}. * * @param dmpProfilesString a space separated string of format profile * representations whose presence is to be ensured. * @return {@code true} if the {@link Set} of {@link ProtocolInfo} in * {@code deviceProtocolInfo} changed as a result of the call. * Returns {@code false} this already contains the specified * elements./*w w w. jav a 2 s. c o m*/ */ public boolean add(String dmpProfilesString) { if (StringUtils.isBlank(dmpProfilesString)) { return false; } dmpProfilesString = dmpProfilesString.replaceFirst("\\s*X-PANASONIC-DMP-Profile:\\s*", "").trim(); String[] elements = dmpProfilesString.trim().split("\\s+"); SortedSet<ProtocolInfo> protocolInfoSet = new TreeSet<>(); for (String element : elements) { try { ProtocolInfo protocolInfo = dmpProfileToProtocolInfo(element); if (protocolInfo != null) { protocolInfoSet.add(protocolInfo); } } catch (ParseException e) { LOGGER.warn("Unable to parse protocolInfo from \"{}\", this profile will not be registered: {}", element, e.getMessage()); LOGGER.trace("", e); } } boolean result = false; if (!protocolInfoSet.isEmpty()) { result = deviceProtocolInfo.addAll(PANASONIC_DMP, protocolInfoSet); } populated |= result; return result; }
From source file:gov.nih.nci.caintegrator.web.action.study.management.EditGenomicSourceAction.java
/** * @return all platform names//from ww w . jav a 2s. co m */ public List<String> getFilterPlatformNames() { SortedSet<String> platformNames = new TreeSet<String>(); for (PlatformConfiguration platformConfiguration : getArrayDataService().getPlatformConfigurations()) { if (Status.LOADED.equals(platformConfiguration.getStatus()) && platformConfiguration.getPlatform().getVendor() == getTempGenomicSource().getPlatformVendor() && platformConfiguration.getPlatformType().getDataType() == getTempGenomicSource() .getDataType()) { platformNames.add(platformConfiguration.getPlatform().getName()); } } return new ArrayList<String>(platformNames); }