List of usage examples for java.util LinkedHashMap put
V put(K key, V value);
From source file:com.intel.iotkitlib.RuleManagement.java
/** * Update the status of the rule. Cannot be used for changing the status of draft rule. * Status value should be one of the following: ["Active", "Archived", "On-hold"] * * @param ruleId the identifier for the rule to have the status updated. * @param status value should be one of the following: ["Active", "Archived", "On-hold"] * @return For async model, return CloudResponse which wraps true if the request of REST * call is valid; otherwise false. The actual result from * the REST call is return asynchronously as part {@link RequestStatusHandler#readResponse}. * For synch model, return CloudResponse which wraps HTTP return code and response. * @throws JSONException//from ww w.java 2s.c om */ public CloudResponse updateStatusOfRule(String ruleId, String status) throws JSONException { if (ruleId == null) { Log.d(TAG, ERR_INVALID_ID); return new CloudResponse(false, ERR_INVALID_ID); } if (status == null) { Log.d(TAG, ERR_INVALID_STATUS); return new CloudResponse(false, ERR_INVALID_STATUS); } String body; if ((body = createBodyForUpdateOfRuleStatus(status)) == null) { return new CloudResponse(false, ERR_INVALID_BODY); } //initiating put for rule status update HttpPutTask createInvitation = new HttpPutTask(); createInvitation.setHeaders(basicHeaderList); createInvitation.setRequestBody(body); LinkedHashMap<String, String> linkedHashMap = new LinkedHashMap<String, String>(); linkedHashMap.put("rule_id", ruleId); String url = objIotKit.prepareUrl(objIotKit.updateStatusOfRule, linkedHashMap); return super.invokeHttpExecuteOnURL(url, createInvitation); }
From source file:com.opengamma.analytics.financial.provider.sensitivity.multicurve.SimpleParameterSensitivity.java
/** * Create a copy of the sensitivity and add a given sensitivity to it. * @param other The sensitivity to add.//from w ww . j a v a 2s .c o m * @return The total sensitivity. */ public SimpleParameterSensitivity plus(final SimpleParameterSensitivity other) { ArgumentChecker.notNull(other, "Sensitivity to add"); final MatrixAlgebra algebra = MatrixAlgebraFactory.COMMONS_ALGEBRA; final LinkedHashMap<String, DoubleMatrix1D> result = new LinkedHashMap<>(); result.putAll(_sensitivity); for (final Map.Entry<String, DoubleMatrix1D> entry : other.getSensitivities().entrySet()) { final String name = entry.getKey(); if (result.containsKey(name)) { result.put(name, (DoubleMatrix1D) algebra.add(result.get(name), entry.getValue())); } else { result.put(name, entry.getValue()); } } return new SimpleParameterSensitivity(result); }
From source file:com.kerio.dashboard.LicenseTileUpdater.java
private boolean sendRequests() { JSONObject emptyArguments = new JSONObject(); LinkedHashMap<String, JSONObject> requests = new LinkedHashMap<String, JSONObject>(); LinkedHashMap<String, JSONObject> response; JSONObject productInfo = this.client.exec("ProductInfo.get", emptyArguments); requests.put("ProductRegistration.getFullStatus", emptyArguments); requests.put("ProductInfo.getUsedDevicesCount", emptyArguments); requests.put("Antivirus.get", emptyArguments); if (newVersion(productInfo)) { requests.put("ContentFilter.getUrlFilterConfig", emptyArguments); } else {/* w w w . j av a 2s .c o m*/ requests.put("HttpPolicy.getUrlFilterConfig", emptyArguments); } requests.put("Antivirus.getUpdateStatus", new JSONObject()); requests.put("IntrusionPrevention.get", new JSONObject()); requests.put("IntrusionPrevention.getUpdateStatus", new JSONObject()); requests.put("ProductInfo.get", new JSONObject()); response = this.client.execBatch(requests); infoResult = response.get("ProductRegistration.getFullStatus"); devices = response.get("ProductInfo.getUsedDevicesCount"); av = response.get("Antivirus.get"); if (newVersion(productInfo)) { webFilter = response.get("ContentFilter.getUrlFilterConfig"); } else { webFilter = response.get("HttpPolicy.getUrlFilterConfig"); } if ((devices == null) || infoResult == null || av == null || webFilter == null) { this.notify("Unable to update"); return false; } else { return true; } }
From source file:com.opengamma.analytics.financial.provider.sensitivity.inflation.ParameterSensitivityInflationUnderlyingMatrixCalculator.java
/** * Computes the sensitivity with respect to the parameters from the point sensitivities to the continuously compounded rate. * @param sensitivity The point sensitivity. * @param inflation The inflation provider. Not null. * @param curvesSet The set of curves for which the sensitivity will be computed. Not null. * @return The sensitivity (as a ParameterSensitivity). ??The order of the sensitivity is by curve as provided by the curvesSet?? *///from w w w. j a v a 2s . c o m @Override public DoubleMatrix1D pointToParameterSensitivity(final InflationSensitivity sensitivity, final InflationProviderInterface inflation, final Set<String> curvesSet) { // TODO: The first part depends only of the multicurves and curvesSet, not the sensitivity. Should it be refactored and done only once? final Set<String> curveNamesSet = inflation.getAllNames(); // curvesSet; // final int nbCurve = curveNamesSet.size(); final String[] curveNamesArray = new String[nbCurve]; int loopname = 0; final LinkedHashMap<String, Integer> curveNum = new LinkedHashMap<>(); for (final String name : curveNamesSet) { // loop over all curves (by name) curveNamesArray[loopname] = name; curveNum.put(name, loopname++); } final int[] nbNewParameters = new int[nbCurve]; // Implementation note: nbNewParameters - number of new parameters in the curve, parameters not from an underlying curve which is another curve of the bundle. final int[][] indexOther = new int[nbCurve][]; // Implementation note: indexOther - the index of the underlying curves, if any. loopname = 0; for (final String name : curveNamesSet) { // loop over all curves (by name) nbNewParameters[loopname] = inflation.getNumberOfParameters(name); loopname++; } loopname = 0; for (final String name : curveNamesSet) { // loop over all curves (by name) final List<String> underlyingCurveNames = inflation.getUnderlyingCurvesNames(name); final IntArrayList indexOtherList = new IntArrayList(); for (final String u : underlyingCurveNames) { final Integer i = curveNum.get(u); if (i != null) { indexOtherList.add(i); nbNewParameters[loopname] -= nbNewParameters[i]; // Only one level: a curve used as an underlying can not have an underlying itself. } } indexOther[loopname] = indexOtherList.toIntArray(); loopname++; } final int nbSensiCurve = curvesSet.size(); // for (final String name : curveNamesSet) { // loop over all curves (by name) // if (curvesSet.contains(name)) { // nbSensiCurve++; // } // } final int[] nbNewParamSensiCurve = new int[nbSensiCurve]; // Implementation note: nbNewParamSensiCurve final int[][] indexOtherSensiCurve = new int[nbSensiCurve][]; // Implementation note: indexOtherSensiCurve - final int[] startCleanParameter = new int[nbSensiCurve]; // Implementation note: startCleanParameter - for each curve for which the sensitivity should be computed, the index in the total sensitivity vector at which that curve start. final int[][] startDirtyParameter = new int[nbSensiCurve][]; // Implementation note: startDirtyParameter - for each curve for which the sensitivity should be computed, the indexes of the underlying curves. int nbSensitivityCurve = 0; int nbCleanParameters = 0; int currentDirtyStart = 0; for (final String name : curvesSet) { // loop over all curves (by name) // if (curvesSet.contains(name)) { final int num = curveNum.get(name); final IntArrayList startDirtyParameterList = new IntArrayList(); final List<String> underlyingCurveNames = inflation.getUnderlyingCurvesNames(name); for (final String u : underlyingCurveNames) { final Integer i = curveNum.get(u); if (i != null) { startDirtyParameterList.add(currentDirtyStart); currentDirtyStart += nbNewParameters[i]; } } startDirtyParameterList.add(currentDirtyStart); currentDirtyStart += nbNewParameters[num]; startDirtyParameter[nbSensitivityCurve] = startDirtyParameterList.toIntArray(); nbNewParamSensiCurve[nbSensitivityCurve] = nbNewParameters[num]; indexOtherSensiCurve[nbSensitivityCurve] = indexOther[num]; startCleanParameter[nbSensitivityCurve] = nbCleanParameters; nbCleanParameters += nbNewParamSensiCurve[nbSensitivityCurve]; nbSensitivityCurve++; // } } // Implementation note: Compute the "dirty" sensitivity, i.e. the sensitivity where the underlying curves are not taken into account. double[] sensiDirty = new double[0]; final Map<String, List<DoublesPair>> sensitivityPriceIndex = sensitivity.getPriceCurveSensitivities(); for (final String name : curvesSet) { // loop over all curves (by name) // if (curvesSet.contains(name)) { final int nbParam = inflation.getNumberOfParameters(name); final double[] s1Name = new double[nbParam]; final double[] sDsc1Name = inflation.parameterInflationSensitivity(name, sensitivityPriceIndex.get(name)); // if ((sDsc1Name != null) && (sFwd1Name == null)) { // s1Name = sDsc1Name; // } // if ((sDsc1Name == null) && (sFwd1Name != null)) { // s1Name = sFwd1Name; // } // if ((sDsc1Name != null) && (sFwd1Name != null)) { for (int loopp = 0; loopp < nbParam; loopp++) { s1Name[loopp] = sDsc1Name[loopp]; } // } sensiDirty = ArrayUtils.addAll(sensiDirty, s1Name); // } } // Implementation note: "clean" the sensitivity, i.e. add the underlying curve parts. final double[] sensiClean = new double[nbCleanParameters]; for (int loopcurve = 0; loopcurve < nbSensiCurve; loopcurve++) { for (int loopo = 0; loopo < indexOtherSensiCurve[loopcurve].length; loopo++) { if (curvesSet.contains(curveNamesArray[indexOtherSensiCurve[loopcurve][loopo]])) { for (int loops = 0; loops < nbNewParamSensiCurve[indexOtherSensiCurve[loopcurve][loopo]]; loops++) { sensiClean[startCleanParameter[indexOtherSensiCurve[loopcurve][loopo]] + loops] += sensiDirty[startDirtyParameter[loopcurve][loopo] + loops]; } } } for (int loops = 0; loops < nbNewParamSensiCurve[loopcurve]; loops++) { sensiClean[startCleanParameter[loopcurve] + loops] += sensiDirty[startDirtyParameter[loopcurve][indexOtherSensiCurve[loopcurve].length] + loops]; } } return new DoubleMatrix1D(sensiClean); }
From source file:com.opengamma.analytics.financial.provider.sensitivity.multicurve.ParameterSensitivityMulticurveUnderlyingMatrixCalculator.java
/** * Computes the sensitivity with respect to the parameters from the point sensitivities to the continuously compounded rate. * @param sensitivity The point sensitivity. * @param multicurves The multi-curve provider. Not null. * @param curvesSet The set of curves for which the sensitivity will be computed. Not null. * @return The sensitivity (as a ParameterSensitivity). ??The order of the sensitivity is by curve as provided by the curvesSet?? *///from w ww. ja v a 2s . co m @Override public DoubleMatrix1D pointToParameterSensitivity(final MulticurveSensitivity sensitivity, final MulticurveProviderInterface multicurves, final Set<String> curvesSet) { // TODO: The first part depends only of the multicurves and curvesSet, not the sensitivity. Should it be refactored and done only once? final Set<String> curveNamesSet = multicurves.getAllNames(); // curvesSet; // final int nbCurve = curveNamesSet.size(); final String[] curveNamesArray = new String[nbCurve]; int loopname = 0; final LinkedHashMap<String, Integer> curveNum = new LinkedHashMap<>(); for (final String name : curveNamesSet) { // loop over all curves (by name) curveNamesArray[loopname] = name; curveNum.put(name, loopname++); } final int[] nbNewParameters = new int[nbCurve]; // Implementation note: nbNewParameters - number of new parameters in the curve, parameters not from an underlying curve which is another curve of the bundle. final int[][] indexOther = new int[nbCurve][]; // Implementation note: indexOther - the index of the underlying curves, if any. loopname = 0; for (final String name : curveNamesSet) { // loop over all curves (by name) nbNewParameters[loopname] = multicurves.getNumberOfParameters(name); loopname++; } loopname = 0; for (final String name : curveNamesSet) { // loop over all curves (by name) final List<String> underlyingCurveNames = multicurves.getUnderlyingCurvesNames(name); final IntArrayList indexOtherList = new IntArrayList(); for (final String u : underlyingCurveNames) { final Integer i = curveNum.get(u); if (i != null) { indexOtherList.add(i); nbNewParameters[loopname] -= nbNewParameters[i]; // Only one level: a curve used as an underlying can not have an underlying itself. } } indexOther[loopname] = indexOtherList.toIntArray(); loopname++; } final int nbSensiCurve = curvesSet.size(); // for (final String name : curveNamesSet) { // loop over all curves (by name) // if (curvesSet.contains(name)) { // nbSensiCurve++; // } // } final int[] nbNewParamSensiCurve = new int[nbSensiCurve]; // Implementation note: nbNewParamSensiCurve final int[][] indexOtherSensiCurve = new int[nbSensiCurve][]; // Implementation note: indexOtherSensiCurve - final int[] startCleanParameter = new int[nbSensiCurve]; // Implementation note: startCleanParameter - for each curve for which the sensitivity should be computed, the index in the total sensitivity vector at which that curve start. final int[][] startDirtyParameter = new int[nbSensiCurve][]; // Implementation note: startDirtyParameter - for each curve for which the sensitivity should be computed, the indexes of the underlying curves. int nbSensitivityCurve = 0; int nbCleanParameters = 0; int currentDirtyStart = 0; for (final String name : curvesSet) { // loop over all curves (by name) // if (curvesSet.contains(name)) { final int num = curveNum.get(name); final IntArrayList startDirtyParameterList = new IntArrayList(); final List<String> underlyingCurveNames = multicurves.getUnderlyingCurvesNames(name); for (final String u : underlyingCurveNames) { final Integer i = curveNum.get(u); if (i != null) { startDirtyParameterList.add(currentDirtyStart); currentDirtyStart += nbNewParameters[i]; } } startDirtyParameterList.add(currentDirtyStart); currentDirtyStart += nbNewParameters[num]; startDirtyParameter[nbSensitivityCurve] = startDirtyParameterList.toIntArray(); nbNewParamSensiCurve[nbSensitivityCurve] = nbNewParameters[num]; indexOtherSensiCurve[nbSensitivityCurve] = indexOther[num]; startCleanParameter[nbSensitivityCurve] = nbCleanParameters; nbCleanParameters += nbNewParamSensiCurve[nbSensitivityCurve]; nbSensitivityCurve++; // } } // Implementation note: Compute the "dirty" sensitivity, i.e. the sensitivity where the underlying curves are not taken into account. double[] sensiDirty = new double[0]; final Map<String, List<DoublesPair>> sensitivityDsc = sensitivity.getYieldDiscountingSensitivities(); final Map<String, List<ForwardSensitivity>> sensitivityFwd = sensitivity.getForwardSensitivities(); for (final String name : curvesSet) { // loop over all curves (by name) // if (curvesSet.contains(name)) { final int nbParam = multicurves.getNumberOfParameters(name); final double[] s1Name = new double[nbParam]; final double[] sDsc1Name = multicurves.parameterSensitivity(name, sensitivityDsc.get(name)); final double[] sFwd1Name = multicurves.parameterForwardSensitivity(name, sensitivityFwd.get(name)); // if ((sDsc1Name != null) && (sFwd1Name == null)) { // s1Name = sDsc1Name; // } // if ((sDsc1Name == null) && (sFwd1Name != null)) { // s1Name = sFwd1Name; // } // if ((sDsc1Name != null) && (sFwd1Name != null)) { for (int loopp = 0; loopp < nbParam; loopp++) { s1Name[loopp] = sDsc1Name[loopp] + sFwd1Name[loopp]; } // } sensiDirty = ArrayUtils.addAll(sensiDirty, s1Name); // } } // Implementation note: "clean" the sensitivity, i.e. add the underlying curve parts. final double[] sensiClean = new double[nbCleanParameters]; for (int loopcurve = 0; loopcurve < nbSensiCurve; loopcurve++) { for (int loopo = 0; loopo < indexOtherSensiCurve[loopcurve].length; loopo++) { if (curvesSet.contains(curveNamesArray[indexOtherSensiCurve[loopcurve][loopo]])) { for (int loops = 0; loops < nbNewParamSensiCurve[indexOtherSensiCurve[loopcurve][loopo]]; loops++) { sensiClean[startCleanParameter[indexOtherSensiCurve[loopcurve][loopo]] + loops] += sensiDirty[startDirtyParameter[loopcurve][loopo] + loops]; } } } for (int loops = 0; loops < nbNewParamSensiCurve[loopcurve]; loops++) { sensiClean[startCleanParameter[loopcurve] + loops] += sensiDirty[startDirtyParameter[loopcurve][indexOtherSensiCurve[loopcurve].length] + loops]; } } return new DoubleMatrix1D(sensiClean); }
From source file:it.drwolf.ridire.session.LocalResourcesManager.java
public Map<String, Integer> getAllFunctionalMetadataMapPlusNull() { LinkedHashMap<String, Integer> ret1 = new LinkedHashMap<String, Integer>(); ret1.put("", -1); ret1.putAll(this.getAllFunctionalMetadataMap()); return ret1;/*from www . j av a2 s. co m*/ }
From source file:it.drwolf.ridire.session.LocalResourcesManager.java
public Map<String, Integer> getAllSemanticMetadataMapPlusNull() { LinkedHashMap<String, Integer> ret1 = new LinkedHashMap<String, Integer>(); ret1.put("", -1); ret1.putAll(this.getAllSemanticMetadataMap()); return ret1;/*from w w w. j a v a 2s . co m*/ }
From source file:de.helmholtz_muenchen.ibis.ngs.star.StarNodeModel.java
@Override protected LinkedHashMap<String, String> getGUIParameters(final BufferedDataTable[] inData) { LinkedHashMap<String, String> pars = new LinkedHashMap<String, String>(); pars.put("--runMode", m_runMode.getStringValue()); //input files String inputParameter = (isAlignRunMode() ? "--readFilesIn" : "--genomeFastaFiles"); ArrayList<String> inputArgument = new ArrayList<String>(); boolean is_zipped = false; if (isAlignRunMode()) { String path2readFile1 = inData[0].iterator().next().getCell(0).toString(); is_zipped = path2readFile1.endsWith(".gz"); inputArgument.add(path2readFile1); if (readType.equals("paired-end")) { String path2readFile2 = inData[0].iterator().next().getCell(1).toString(); if (!path2readFile1.equals(path2readFile2) && path2readFile2.length() > 0 && path2readFile2.endsWith(".gz") == is_zipped) { inputArgument.add(path2readFile2); }/*from w ww. j a va 2 s .co m*/ } if (is_zipped) { pars.put("--readFilesCommand", "zcat"); } pars.put("--genomeDir", genome_folder); if (m_two_pass.getBooleanValue()) { pars.put("--twopassMode", "Basic"); } } else { for (DataRow dr : inData[0]) { inputArgument.add(dr.getCell(0).toString()); } } pars.put(inputParameter, StringUtils.join(inputArgument, " ")); //output parameters String infile = inData[0].iterator().next().getCell(0).toString(); if (CompatibilityChecker.inputFileNotOk(out_folder, false)) { out_folder = new File(infile).getParent(); if (!isAlignRunMode()) { out_folder += File.separator + "STAR_genome"; } } if (!out_folder.endsWith(File.separator)) { out_folder += File.separator; } File outDir = new File(out_folder); if (!outDir.isDirectory()) { outDir.mkdirs(); } OUTFILE = out_folder; if (isAlignRunMode()) { String outfile = IO.replaceFileExtension(infile, "."); outfile = IO.getFileName(outfile); out_folder += outfile; OUTFILE = out_folder + "Aligned.out.sam"; } if (!isAlignRunMode()) { pars.put("--genomeDir", out_folder); } //required for log files pars.put("--outFileNamePrefix", out_folder); //add further parameters pars.put("--runThreadN", m_threads.getIntValue() + ""); if (!CompatibilityChecker.inputFileNotOk(gtf_file, true) && gtf_file.endsWith(".gtf")) { pars.put("--sjdbGTFfile", gtf_file); pars.put("--sjdbOverhang", m_overhang.getIntValue() + ""); } if (m_opt_parameter.isActive()) { pars.put(m_opt_parameter.getStringValue(), ""); } return pars; }
From source file:ch.entwine.weblounge.common.impl.util.doc.EndpointDocumentation.java
/** * Returns the map containing all of the elements that are referenced in the * underlying template used to render the documentation. * //from w w w . j a va2 s . co m * @return the properties map */ public Map<String, Object> toMap() { LinkedHashMap<String, Object> m = new LinkedHashMap<String, Object>(); m.put("metadata", this.metadata); m.put("notes", this.notes); ArrayList<EndpointCollection> collections = new ArrayList<EndpointCollection>(); for (EndpointCollection collection : endpointCollections) { // Only pass through the collections with things in them if (collection.getEndpoints().isEmpty()) continue; // Iterate over the endpoints for (Endpoint endpoint : collection.getEndpoints()) { // Balidate the endpoint if (!endpoint.getPathParameters().isEmpty()) { for (Parameter param : endpoint.getPathParameters()) { if (!endpoint.getPath().contains("{" + param.getName() + "}")) { throw new IllegalArgumentException("Path (" + endpoint.getPath() + ") does not match path parameter (" + param.getName() + ") for endpoint (" + endpoint.getName() + "), the path must contain all path param names"); } } } // Validate the endpoint path Pattern pattern = Pattern.compile("\\{(.+?)\\}"); Matcher matcher = pattern.matcher(endpoint.getPath()); int count = 0; while (matcher.find()) { if (!FORMAT_KEY.equals(matcher.group())) { count++; } } if (count != endpoint.getPathParameters().size()) { throw new IllegalArgumentException( "Path (" + endpoint.getPath() + ") does not match path parameters (" + endpoint.getPathParameters() + ") for endpoint (" + endpoint.getName() + "), the path must contain the same number of path params (" + count + ") as the pathParams list (" + endpoint.getPathParameters().size() + ")"); } // Handle the forms if (endpoint.getForm() != null) { TestForm form = endpoint.getForm(); if (form.isAutoGenerated() || form.isEmpty()) { form = new TestForm(endpoint); endpoint.setTestForm(form); } } // Handle the endpoint auto format paths if (endpoint.isAutoPathFormat()) { if (!endpoint.getOutputFormats().isEmpty()) { endpoint.setDefaultOutputFormat("." + FORMAT_KEY); StringBuilder sb = new StringBuilder(); sb.append(".{"); for (Format format : endpoint.getOutputFormats()) { if (sb.length() > 3) { sb.append("|"); } sb.append(format.getName()); } sb.append("}"); endpoint.setPathFormatHtml(sb.toString()); } } else { endpoint.setDefaultOutputFormat(""); endpoint.setPathFormatHtml(""); } } collections.add(collection); } m.put("endpointCollections", collections); return m; }
From source file:com.kerio.dashboard.SystemStatusUpdater.java
public void sendRequests() { LinkedHashMap<String, JSONObject> requests = new LinkedHashMap<String, JSONObject>(); requests.put("ProductInfo.getUptime", new JSONObject()); requests.put("UpdateChecker.getStatus", new JSONObject()); requests.put("Antivirus.get", new JSONObject()); requests.put("Antivirus.getUpdateStatus", new JSONObject()); requests.put("IntrusionPrevention.get", new JSONObject()); requests.put("IntrusionPrevention.getUpdateStatus", new JSONObject()); requests.put("ProductInfo.get", new JSONObject()); JSONObject productInfo = this.client.exec("ProductInfo.get", new JSONObject()); this.isNewVersion = newVersion(productInfo); if (this.isNewVersion) { requests.put("ContentFilter.getUrlFilterConfig", new JSONObject()); } else {//from w w w .j av a 2s.c om requests.put("HttpPolicy.getUrlFilterConfig", new JSONObject()); } JSONObject interfaceParams; try { interfaceParams = new JSONObject("{\"sortByGroup\":true,\"query\":{" + "\"conditions\":[{\"fieldName\":\"type\",\"comparator\":\"Eq\",\"value\":\"VpnServer\"}]," + "\"combining\":\"Or\",\"orderBy\":[{\"columnName\":\"name\",\"direction\":\"Asc\"}]" + "}}"); } catch (JSONException e) { interfaceParams = new JSONObject(); } requests.put("Interfaces.get", interfaceParams); this.response = this.client.execBatch(requests); }