List of usage examples for java.util LinkedHashMap get
public V get(Object key)
From source file:com.sat.spvgt.utils.tims.TIMS.java
/** * Buildupdatexml./*from w w w. j ava2s . co m*/ * * @param cred * the cred * @param result * the result * @return true, if successful */ public static boolean buildupdatexml(LinkedHashMap<String, String> cred, String result) { boolean status = true; String configID = cred.get("configID").toString(); String usrID = cred.get("userID").toString(); String tokenv = cred.get("token").toString(); // String sw = cred.get("sw").toString(); String platform = cred.get("platform").toString(); String brwtype = cred.get("brwtype").toString(); String brwversion = cred.get("brwversion").toString(); System.out.println("browser details:" + brwtype + brwversion); try { if (configID == null || configID == "") { status = false; System.out.println("configID shouldn't be null or blank."); } if (trID == null || trID == "") { status = false; System.out.println("Test Result ID shouldn't be null or blank"); } if (result == null || result == "") { status = false; System.out.println("Result shouldn't be null or blank"); } if (!(result.equals("passed") | result.equals("failed") | result.equals("blocked") | result.equals("dropped") | result.equals("passx") | result.equals("pending"))) { System.out.println("Invalid Status value"); return false; } xml = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n"; xml = xml + "<Tims xsi:schemaLocation=\"http://tims.cisco.com/namespace http://tims.cisco.com/xsd/Tims.xsd\"\n"; xml = xml + "xmlns=\"http://tims.cisco.com/namespace\"\n"; xml = xml + "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n"; xml = xml + "xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n"; xml = xml + "<Credential user=\"" + usrID + "\" token=\"" + tokenv + "\"/>\n"; xml = xml + "<ID>" + trID + "</ID>\n"; xml = xml + "<ListFieldValue editoperator=\"set\">\n"; xml = xml + "<FieldName>Status</FieldName>\n"; xml = xml + "<Value>" + result + "</Value>\n"; xml = xml + "</ListFieldValue>\n"; xml = xml + "<ListFieldValue editoperator=\"set\">\n"; xml = xml + "<FieldName>Tested by</FieldName>\n"; xml = xml + "<Value>" + usrID + "</Value>\n"; xml = xml + "</ListFieldValue>\n"; /* * xml=xml+"<ListFieldValue editoperator=\"set\">\n"; * xml=xml+"<FieldName>Software Version</FieldName>\n"; * xml=xml+"<Value>"+sw+"</Value>\n"; xml=xml+"</ListFieldValue>\n"; */ xml = xml + "<ListFieldValue editoperator=\"set\">\n"; xml = xml + "<FieldName>Platform</FieldName>\n"; xml = xml + "<Value>" + platform + "</Value>\n"; xml = xml + "</ListFieldValue>\n"; xml = xml + "<TextFieldValue editoperator=\"set\">\n"; xml = xml + "<FieldName>Browser Type</FieldName>\n"; xml = xml + "<Value>" + brwtype + "</Value>\n"; xml = xml + "</TextFieldValue>\n"; xml = xml + "<TextFieldValue editoperator=\"set\">\n"; xml = xml + "<FieldName>Browser Version</FieldName>\n"; xml = xml + "<Value>" + brwversion + "</Value>\n"; xml = xml + "</TextFieldValue>\n"; xml = xml + "</Tims>\n"; return status; } catch (Exception e) { e.printStackTrace(); status = false; return status; } }
From source file:com.sat.spvgt.utils.tims.TIMS.java
/** * Buildcreatexml.// w ww . j a va2 s. c o m * * @param cred * the cred * @param testCaseID * the test case id * @param result * the result * @param title * the title * @return true, if successful */ public static boolean buildcreatexml(LinkedHashMap<String, String> cred, String testCaseID, String result, String title) { boolean status = true; String userID = cred.get("userID").toString(); String automationToken = cred.get("token").toString(); // String projectID = cred.get("projectID").toString(); String configID = cred.get("configID").toString(); try { if (userID == null || userID == "") { status = false; System.out.println("userID shouldn't be null or blank."); } if (automationToken == null || automationToken == "") { status = false; System.out.println("Automation Token shouldn't be null or blank."); } if (testCaseID == null || testCaseID == "") { status = false; System.out.println("Test Case ID shouldn't be null or blank"); } if (configID == null || configID == "") { status = false; System.out.println("configID shouldn't be null or blank."); } xml = xml + "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n"; xml = xml + "<Tims xsi:schemaLocation=\"http://tims.cisco.com/namespace http://tims.cisco.com/xsd/Tims.xsd\"\n"; xml = xml + "xmlns=\"http://tims.cisco.com/namespace\"\n"; xml = xml + "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n"; xml = xml + "xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n"; xml = xml + "<Credential user=\"" + userID + "\" token=\"" + automationToken + "\"/>\n"; xml = xml + "<Result xlink:href=\"http://tims.cisco.com/xml/" + testCaseID + "/entity.svc\">\n"; xml = xml + "<Title><![CDATA[" + title + "]]></Title>\n"; xml = xml + "<ListFieldValue multi-value=\"false\">\n"; xml = xml + "<FieldName><![CDATA[Tested by]]>\n"; xml = xml + "</FieldName>\n"; xml = xml + "<Value><![CDATA[" + userID + "]]>\n"; xml = xml + "</Value>\n"; xml = xml + "<Value><![CDATA[shisuren]]>\n"; xml = xml + "</Value>\n"; xml = xml + "</ListFieldValue>\n"; xml = xml + "<Owner>\n"; xml = xml + "<UserID>\n" + userID + "\n</UserID>\n"; xml = xml + "<Email>\n" + userID + "@cisco.com" + "\n</Email>\n"; xml = xml + "</Owner>\n"; xml = xml + "<Status>" + result + "</Status>\n"; xml = xml + "<ConfigID xlink:href=\"http://tims.cisco.com/xml/" + configID + "/entity.svc\">" + configID + "</ConfigID>\n"; xml = xml + "<CaseID xlink:href=\"http://tims.cisco.com/xml/" + testCaseID + "/entity.svc\">" + testCaseID + "</CaseID>\n"; xml = xml + "</Result>\n"; xml = xml + "</Tims>"; return status; } catch (Exception e) { e.printStackTrace(); status = false; return status; } }
From source file:com.stratio.crossdata.sh.utils.ConsoleUtils.java
/** * In order to print the result, this method calculates the maximum width of every column. * * @param resultSet structure representing the result of a execution. * @return Map<String, Integer> where the key is the name of the column and Integer is the maximum * width./* www . ja v a 2 s . c om*/ */ private static Map<String, Integer> calculateColWidths(ResultSet resultSet) { LinkedHashMap<String, Integer> colWidths = new LinkedHashMap<>(); // Get column names or aliases width for (ColumnMetadata columnMetadata : resultSet.getColumnMetadata()) { colWidths.put(columnMetadata.getName().getColumnNameToShow(), columnMetadata.getName().getColumnNameToShow().length()); } // Find widest cell content of every column for (Row row : resultSet) { int pos = 0; for (String key : row.getCells().keySet()) { String cellContent = String.valueOf(row.getCell(key).getValue()); int currentWidth; if (colWidths.containsKey(key)) { currentWidth = colWidths.get(key); } else { Iterator<Map.Entry<String, Integer>> iter = colWidths.entrySet().iterator(); int limit = 0; while (limit < pos) { iter.next(); limit++; } currentWidth = iter.next().getKey().length(); } if (cellContent.length() > currentWidth) { colWidths.put(key, cellContent.length()); } pos++; } } return colWidths; }
From source file:com.geewhiz.pacify.utils.ArchiveUtils.java
private static LinkedHashMap<PArchive, List<PArchive>> getParentArchives(List<PFile> replacePFiles) { LinkedHashMap<PArchive, List<PArchive>> parentArchives = new LinkedHashMap<PArchive, List<PArchive>>(); // for performance get first all archives in an archive for (PFile pFile : replacePFiles) { if (!pFile.isArchiveFile()) { continue; }/* w w w. ja v a 2s . c o m*/ PArchive pArchive = pFile.getPArchive(); if (!pArchive.isArchiveFile()) { continue; } if (!parentArchives.containsKey(pArchive.getParentArchive())) { parentArchives.put(pArchive.getParentArchive(), new ArrayList<PArchive>()); } List<PArchive> pArchivesToReplace = parentArchives.get(pArchive.getParentArchive()); if (!pArchivesToReplace.contains(pArchive)) { pArchivesToReplace.add(pArchive); } } return parentArchives; }
From source file:com.miserablemind.api.consumer.tradeking.api.impl.response_entities.TKMarketStatusResponse.java
/** * This needs an explicit setter to unwrap the values from inside of "status" object * * @param statusResponse value from deserializer, in this case object "status" as a HashMap *///from ww w . j av a 2 s . c o m @JsonSetter("status") public void setAccounts(LinkedHashMap statusResponse) { this.currentStatus = (String) statusResponse.get("current"); this.nextStatus = (String) statusResponse.get("next"); this.changeAt = LocalTime.parse((String) statusResponse.get("change_at")); }
From source file:citation_prediction.CitationCore.java
/** * This function runs the Newton-Raphson function on an interval from .1 to 10 returning a list of * all the unique solutions.//from w w w . j a va2s .com * * @param data The citation data in days. * @param step The step you would like to use to step through the interval of .1 to 10. * @param m The average number of new references contained in each paper for a journal. * @return A list of list containing the WSB solutions. */ private static ArrayList<LinkedHashMap<String, Double>> newtonRaphson_ConvergenceTest(double[][] data, double start, double mu_guess, double sigma_guess, double step, double m, boolean wasAlreadyRun) { CitationCore cc = new CitationCore(); String[] matrix_headers = { "mu0", "sigma0", "lambda", "mu", "sigma", "iteration" }; ArrayList<ArrayList<Double>> matrix = new ArrayList<ArrayList<Double>>(100); ArrayList<LinkedHashMap<String, Double>> solutions = new ArrayList<LinkedHashMap<String, Double>>(100); ArrayList<Double> lambdas = new ArrayList<Double>(); for (double mu0 = start; mu0 < (mu_guess + 2); mu0 += step) { for (double sigma0 = start; sigma0 < (sigma_guess + 2); sigma0 += step) { LinkedHashMap<String, Double> answer = cc.newtonRaphson(data, mu0, sigma0, m); if (answer.get("lambda") != null) { ArrayList<Double> row = new ArrayList<Double>(); row.add(mu0); row.add(sigma0); row.add(answer.get("lambda")); row.add(answer.get("mu")); row.add(answer.get("sigma")); row.add(answer.get("iterations")); matrix.add(row); boolean isUnique = true; for (double l : lambdas) { if ((answer.get("lambda") < 0) || Math.abs(l - answer.get("lambda")) < 1e-2) { isUnique = false; break; } } if (isUnique) { LinkedHashMap<String, Double> s = new LinkedHashMap<String, Double>(); s.put("lambda", answer.get("lambda")); s.put("mu", answer.get("mu")); s.put("sigma", answer.get("sigma")); solutions.add(s); } lambdas.add(answer.get("lambda")); } } } printMatrix(matrix, matrix_headers); System.out.println("Unique Solutions:"); System.out.println(solutions.toString()); if (!wasAlreadyRun && solutions.isEmpty()) return newtonRaphson_ConvergenceTest(data, start, mu_guess, sigma_guess, .1, m, true); else return solutions; }
From source file:jp.or.openid.eiwg.scim.util.SCIMUtil.java
/** * ??????//from w w w . j a va 2 s.c om * * @param context * @param attributeName * @param isCore * @return ? */ public static LinkedHashMap<String, Object> getUserAttributeInfo(ServletContext context, String attributeName, boolean isCore) { LinkedHashMap<String, Object> result = null; Set<String> schemaIdSet = new HashSet<>(); // ? @SuppressWarnings("unchecked") ArrayList<LinkedHashMap<String, Object>> resourceTypes = (ArrayList<LinkedHashMap<String, Object>>) context .getAttribute("ResourceTypes"); Iterator<LinkedHashMap<String, Object>> resourceTypesIt = resourceTypes.iterator(); while (resourceTypesIt.hasNext()) { LinkedHashMap<String, Object> resourceTypeInfo = resourceTypesIt.next(); Object endpoint = SCIMUtil.getAttribute(resourceTypeInfo, "endpoint"); if (endpoint != null && endpoint.toString().equalsIgnoreCase("/Users")) { Object schema = SCIMUtil.getAttribute(resourceTypeInfo, "schema"); if (schema != null) { schemaIdSet.add(schema.toString()); } Object schemaExtensions = SCIMUtil.getAttribute(resourceTypeInfo, "schemaExtensions"); if (schemaExtensions != null && schemaExtensions instanceof ArrayList) { @SuppressWarnings("unchecked") ArrayList<LinkedHashMap<String, Object>> schemaExtensionList = (ArrayList<LinkedHashMap<String, Object>>) schemaExtensions; Iterator<LinkedHashMap<String, Object>> schemaExtensionListIt = schemaExtensionList.iterator(); while (schemaExtensionListIt.hasNext()) { LinkedHashMap<String, Object> schemaExtensionInfo = schemaExtensionListIt.next(); schema = SCIMUtil.getAttribute(schemaExtensionInfo, "schema"); if (schema != null) { schemaIdSet.add(schema.toString()); } } } break; } } // ? @SuppressWarnings("unchecked") ArrayList<LinkedHashMap<String, Object>> schemas = (ArrayList<LinkedHashMap<String, Object>>) context .getAttribute("Schemas"); Iterator<LinkedHashMap<String, Object>> schemasIt = schemas.iterator(); while (schemasIt.hasNext()) { LinkedHashMap<String, Object> schemaInfo = schemasIt.next(); // id? Object id = SCIMUtil.getAttribute(schemaInfo, "id"); if (id != null && id instanceof String) { // ?? boolean isUserSchema = false; if (!schemaIdSet.isEmpty()) { Iterator<String> schemaIdSetIt = schemaIdSet.iterator(); while (schemaIdSetIt.hasNext()) { if (id.toString().equalsIgnoreCase(schemaIdSetIt.next())) { isUserSchema = true; } } } if (isUserSchema) { Object attributes = schemaInfo.get("attributes"); if (attributes != null && attributes instanceof ArrayList) { @SuppressWarnings("unchecked") ArrayList<LinkedHashMap<String, Object>> attributeList = (ArrayList<LinkedHashMap<String, Object>>) attributes; Iterator<LinkedHashMap<String, Object>> attributeListIt = attributeList.iterator(); while (attributeListIt.hasNext()) { LinkedHashMap<String, Object> attributeInfo = attributeListIt.next(); Object name = attributeInfo.get("name"); // ?? if (attributeName.equalsIgnoreCase(name.toString())) { result = attributeInfo; break; } } } } } } if (result == null && isCore) { if (attributeName.equalsIgnoreCase("schemas")) { result = new LinkedHashMap<String, Object>(); result.put("name", "schemas"); result.put("type", "string"); result.put("multiValued", true); result.put("mutability", "readWrite"); } else if (attributeName.equalsIgnoreCase("id")) { result = new LinkedHashMap<String, Object>(); result.put("name", "id"); result.put("type", "string"); result.put("multiValued", false); result.put("mutability", "readOnly"); } else if (attributeName.equalsIgnoreCase("meta")) { result = new LinkedHashMap<String, Object>(); result.put("name", "meta"); result.put("type", "complex"); result.put("multiValued", false); result.put("mutability", "readOnly"); } } return result; }
From source file:javaslang.jackson.datatype.serialize.MultimapSerializer.java
@Override Object toJavaObj(Multimap<?, ?> value) throws IOException { final LinkedHashMap<Object, List<Object>> result = new LinkedHashMap<>(); value.forEach(e -> {/* ww w . j a va2 s .co m*/ List<Object> list = result.get(e._1); if (list == null) { list = new ArrayList<>(); result.put(e._1, list); } list.add(e._2); }); return result; }
From source file:com.miserablemind.api.consumer.tradeking.api.impl.response_entities.TKAllWatchListsResponse.java
@JsonSetter("watchlists") @SuppressWarnings("unchecked") public void setWatchLists(LinkedHashMap<String, Object> watchListsResponse) { ArrayList<String> resultList = new ArrayList<>(); Object list = watchListsResponse.get("watchlist"); ArrayList<LinkedHashMap<String, String>> itemList = new ArrayList<>(); if (list.getClass() == ArrayList.class) { //we know from condition this is right itemList = (ArrayList) list; } else {//from w w w. j a v a 2 s. co m itemList.add((LinkedHashMap) watchListsResponse.get("watchlist")); } resultList.addAll(itemList.stream().map(item -> item.get("id")).collect(Collectors.toList())); this.watchLists = new String[resultList.size()]; this.watchLists = resultList.toArray(this.watchLists); }
From source file:net.sf.maltcms.chromaui.project.spi.DBProjectFactory.java
private static void addSampleGroups(LinkedHashMap<String, Set<File>> sampleGroupToFile, LinkedHashMap<File, IChromatogramDescriptor> fileToDescriptor, IChromAUIProject icui) { for (String group : sampleGroupToFile.keySet()) { ISampleGroupDescriptor sampleGroupDescriptor = new SampleGroupDescriptor(); sampleGroupDescriptor.setName(group); sampleGroupDescriptor.setDisplayName(group); SampleGroupContainer tgc = new SampleGroupContainer(); tgc.setSampleGroup(sampleGroupDescriptor); ISampleGroupDescriptor sgd = new SampleGroupDescriptor(); sgd.setName(group);/* w w w .j av a 2 s.co m*/ sgd.setDisplayName(group); Set<File> files = sampleGroupToFile.get(group); for (File f : files) { IChromatogramDescriptor descr = fileToDescriptor.get(f); descr.setSampleGroup(sampleGroupDescriptor); tgc.addMembers(descr); } tgc.setName(group); tgc.setDisplayName(group); icui.addContainer(tgc); } }