List of usage examples for java.util Collections singletonMap
public static <K, V> Map<K, V> singletonMap(K key, V value)
From source file:org.kemri.wellcome.controller.ReportDefinitionController.java
@RequestMapping(value = Views.UPLOAD, method = RequestMethod.POST) public @ResponseBody Map<String, ? extends Object> upload(@RequestParam("file") MultipartFile file, Model model) throws IOException { InputStream is = file.getInputStream(); try {//w ww . j av a2 s . c om service.unMarshallandSaveReportTemplates(is); } catch (Exception ex) { log.error(ex.getMessage()); ex.printStackTrace(); } finally { is.close(); } log.info("User:" + service.getUsername() + " uploaded the report template :" + file.getOriginalFilename() + " on " + Calendar.getInstance().getTime()); return Collections.singletonMap("u", "Saved"); }
From source file:io.swagger.test.integration.responses.ResponseWithExceptionTestIT.java
@Test public void verifyApiExceptionForYaml() throws IOException { try {//from w w w. jav a2 s . c om final Map<String, String> headerParams = Collections.singletonMap(HttpHeaders.ACCEPT, CustomMediaTypes.APPLICATION_YAML.toString()); client.invokeAPI("/throwApiException", "GET", new HashMap<String, String>(), null, headerParams, null, null, null, new String[0]); Assert.fail("Exception was expected!"); } catch (ApiException e) { final Response.Status expected = Response.Status.CONFLICT; Assert.assertEquals(e.getCode(), expected.getStatusCode()); final ApiError error = Json.mapper().readValue(e.getMessage(), ApiError.class); Assert.assertEquals(error.getCode(), expected.getStatusCode()); Assert.assertEquals(error.getMessage(), expected.getReasonPhrase()); } }
From source file:io.spring.initializr.actuate.autoconfigure.InitializrStatsAutoConfiguration.java
@Bean @ConditionalOnMissingBean(name = "statsRetryTemplate") public RetryTemplate statsRetryTemplate() { RetryTemplate retryTemplate = new RetryTemplate(); ExponentialBackOffPolicy backOffPolicy = new ExponentialBackOffPolicy(); backOffPolicy.setInitialInterval(3000L); backOffPolicy.setMultiplier(3);/*from w w w.java 2 s. c om*/ SimpleRetryPolicy retryPolicy = new SimpleRetryPolicy(this.statsProperties.getElastic().getMaxAttempts(), Collections.singletonMap(Exception.class, true)); retryTemplate.setBackOffPolicy(backOffPolicy); retryTemplate.setRetryPolicy(retryPolicy); return retryTemplate; }
From source file:org.suren.autotest.web.framework.selenium.action.SeleniumJqGridSequenceOperation.java
/** * @param absEle//from w w w .jav a2s . com */ private Button buildSearchButton(AbstractElement absEle) { Map<String, String> map = Collections.singletonMap(absEle.getDataStr(SEARCH_BUT_BY), absEle.getDataStr(SEARCH_BUT_INFO)); map.put("strategy", "priority"); LocatorUtil.setLocator(map, searchBut); return searchBut; }
From source file:hudson.plugins.mercurial.MercurialSCMHeadEvent.java
@NonNull @Override//from ww w . j a v a2 s . com public Map<SCMHead, SCMRevision> heads(@NonNull SCMSource source) { if (source instanceof MercurialSCMSource) { MercurialSCMSource hg = (MercurialSCMSource) source; String repository = hg.getSource(); if (repository != null) { if (MercurialStatus.looselyMatches(payload.getUrl(), repository)) { SCMHead head = new SCMHead(getPayload().getBranch()); SCMRevision revision = new MercurialSCMSource.MercurialRevision(head, getPayload().getChangesetId()); return Collections.singletonMap(head, revision); } } } return Collections.emptyMap(); }
From source file:org.yamj.core.database.service.ExecutionTaskStorageService.java
@Transactional(readOnly = true) public List<ExecutionTask> getTasksForExecution() { String query = "from ExecutionTask et where et.nextExecution <= :actualDate"; Map<String, Object> params = Collections.singletonMap("actualDate", (Object) new Date()); return this.commonDao.findByNamedParameters(query, params); }
From source file:com.quatico.base.aem.test.api.setup.Pages.java
@Override public Resource aPageWithParents(String path, Object... properties) throws Exception { Resource result = null;//from w ww . j av a2 s . c o m Page page = client.getPageManager().getPage(path); if (page != null) { return page.adaptTo(Resource.class); } PathIterator it = new PathIterator(path); it.first(); // root while (it.hasNext()) { String curPath = it.next(); if (Arrays.asList("/content", "/libs", "/apps").contains(curPath)) { continue; } result = client.getResourceResolver().getResource(curPath); if (result == null) { if (it.hasNext()) { result = client.getContentBuilder() .page(curPath, PageType.DEFAULT_TEMPLATE.getTemplate().getName(), new HashMap<>()) .adaptTo(Resource.class); } else { Properties pairs = new Properties(properties); String template = toStringValue(pairs.remove(TEMPLATE)); if (StringUtils.isEmpty(template)) { template = PageType.DEFAULT_TEMPLATE.getTemplate().getName(); } if (client.getResourceResolver().getResource(template) == null) { client.getContentBuilder().resource(template, Collections.singletonMap(PRIMARY_TYPE, ResourceType.TEMPLATE_TYPE)); } result = client.getContentBuilder().page(curPath, template, pairs.toMap()) .adaptTo(Resource.class); } } } if (result == null) { throw new RuntimeException(MessageFormat.format("Cannot create result at '{0}'", result)); } return result; }
From source file:com.cognifide.actions.msg.replication.ReplicationMessageProducer.java
private Resource createActionResource(ResourceResolver resolver, String actionType, String relPath) throws PersistenceException { final String path = createPath(relPath, config.getActionRoot(), config.getRandomPathPattern()); final Resource page = ResourceUtil.getOrCreateResource(resolver, path, Collections.singletonMap(JcrConstants.JCR_PRIMARYTYPE, (Object) "cq:Page"), null, false); final Map<String, Object> contentMap = new LinkedHashMap<String, Object>(); contentMap.put(JcrConstants.JCR_PRIMARYTYPE, "cq:PageContent"); contentMap.put("cq:distribute", false); final Resource content = resolver.create(page, JcrConstants.JCR_CONTENT, contentMap); resolver.commit();/*from w w w .j av a2 s. c o m*/ final ModifiableValueMap map = content.adaptTo(ModifiableValueMap.class); map.put(NameConstants.PN_PAGE_LAST_MOD, Calendar.getInstance()); map.put(NameConstants.PN_PAGE_LAST_MOD_BY, resolver.getUserID()); map.put("cq:distribute", true); return content; }
From source file:edu.washington.gs.skyline.model.quantification.GroupComparisonDataSet.java
public LinearFitResult calculateFoldChange(String label) { List<Replicate> replicates = removeIncompleteReplicates(label, this.replicates); if (replicates.size() == 0) { return null; }//from ww w .jav a2 s.c om List<Replicate> summarizedRows; if (replicates.stream().anyMatch(row -> null != row.getBioReplicate())) { Map<Pair<Boolean, Object>, List<Replicate>> groupedByBioReplicate = replicates.stream().collect( Collectors.groupingBy(replicate -> Pair.of(replicate.isControl(), replicate.bioReplicate))); summarizedRows = new ArrayList<>(); for (Map.Entry<Pair<Boolean, Object>, List<Replicate>> entry : groupedByBioReplicate.entrySet()) { Double log2Abundance = calculateMean(entry.getValue().stream() .map(replicateData -> replicateData.getLog2Abundance(label)).collect(Collectors.toList())); if (log2Abundance == null) { continue; } Replicate combinedReplicate = new Replicate(entry.getKey().getLeft(), entry.getKey().getValue()); ResultFileData resultFileData = combinedReplicate.ensureResultFileData(); resultFileData.setTransitionAreas(label, TransitionAreas.fromMap(Collections.singletonMap("", Math.pow(2.0, log2Abundance)))); if (getNormalizationMethod() instanceof NormalizationMethod.RatioToLabel) { TransitionAreas denominator = TransitionAreas.fromMap(Collections.singletonMap("", 1.0)); resultFileData.setTransitionAreas( ((NormalizationMethod.RatioToLabel) getNormalizationMethod()).getIsotopeLabelTypeName(), denominator); } summarizedRows.add(combinedReplicate); } } else { summarizedRows = replicates; } List<Double> abundances = summarizedRows.stream() .map(replicateData -> replicateData.getLog2Abundance(label)).collect(Collectors.toList()); List<Integer> features = Collections.nCopies(summarizedRows.size(), 0); List<Integer> runs = IntStream.range(0, summarizedRows.size()).boxed().collect(Collectors.toList()); List<Integer> subjects = IntStream.range(0, summarizedRows.size()).boxed().collect(Collectors.toList()); List<Boolean> subjectControls = summarizedRows.stream().map(Replicate::isControl) .collect(Collectors.toList()); FoldChangeDataSet foldChangeDataSet = new FoldChangeDataSet(abundances, features, runs, subjects, subjectControls); DesignMatrix designMatrix = DesignMatrix.getDesignMatrix(foldChangeDataSet, false); LinearFitResult linearFitResult = designMatrix.performLinearFit().get(0); return linearFitResult; }