List of usage examples for java.util LinkedHashMap get
public V get(Object key)
From source file:org.envirocar.wps.util.EnviroCarFeatureParser.java
/** * utility method for gathering properties of EnviroCar track features * // w w w . j av a 2 s . c om * @param features * ArrayList containing parsed JSON features * @return * set of strings representing the phenomena (e.g. speed, MAF, etc.) */ private Set<String> gatherPropertiesForFeatureTypeBuilder(ArrayList<?> features) { Set<String> distinctPhenomenonNames = new HashSet<String>(); for (Object object : features) { if (object instanceof LinkedHashMap<?, ?>) { LinkedHashMap<?, ?> featureMap = (LinkedHashMap<?, ?>) object; Object propertiesObject = featureMap.get("properties"); if (propertiesObject instanceof LinkedHashMap<?, ?>) { LinkedHashMap<?, ?> propertiesMap = (LinkedHashMap<?, ?>) propertiesObject; Object phenomenonsObject = propertiesMap.get("phenomenons"); if (phenomenonsObject instanceof LinkedHashMap<?, ?>) { LinkedHashMap<?, ?> phenomenonsMap = (LinkedHashMap<?, ?>) phenomenonsObject; for (Object phenomenonKey : phenomenonsMap.keySet()) { Object phenomenonValue = phenomenonsMap.get(phenomenonKey); if (phenomenonValue instanceof LinkedHashMap<?, ?>) { LinkedHashMap<?, ?> phenomenonValueMap = (LinkedHashMap<?, ?>) phenomenonValue; String unit = phenomenonValueMap.get("unit").toString(); distinctPhenomenonNames.add(phenomenonKey.toString() + " (" + unit + ")"); } } } } } } return distinctPhenomenonNames; }
From source file:com.redhat.topicindex.security.FedoraAccountSystem.java
@SuppressWarnings("unchecked") private boolean authenticate() throws LoginException { if (password == null || username == null) throw new LoginException("No Username/Password found"); if (password.equals("") || username.equals("")) throw new LoginException("No Username/Password found"); HttpClient client = new HttpClient(); PostMethod method = new PostMethod(FEDORA_JSON_URL); try {/*from w w w.j a v a 2 s. c o m*/ // Generate the data to send List<NameValuePair> formparams = new ArrayList<NameValuePair>(); formparams.add(new NameValuePair("username", username)); formparams.add(new NameValuePair("user_name", username)); formparams.add(new NameValuePair("password", String.valueOf(password))); formparams.add(new NameValuePair("login", "Login")); method.addParameters(formparams.toArray(new NameValuePair[formparams.size()])); // Send the data and get the response client.executeMethod(method); // Handle the response BufferedReader br = new BufferedReader( new InputStreamReader(new ByteArrayInputStream(method.getResponseBody()))); JSONParser parser = new JSONParser(); ContainerFactory containerFactory = new ContainerFactory() { public List creatArrayContainer() { return new LinkedList(); } public Map createObjectContainer() { return new LinkedHashMap(); } }; // Parse the response to check authentication success and valid groups String line; while ((line = br.readLine()) != null) { Map json = (Map) parser.parse(line, containerFactory); if (json.containsKey("success") && json.containsKey("person")) { if (json.get("person") instanceof LinkedHashMap) { LinkedHashMap person = (LinkedHashMap) json.get("person"); if (person.get("status").equals("active")) { if (person.containsKey("approved_memberships")) { if (person.get("approved_memberships") instanceof LinkedList) { if (!checkCLAAgreement(((LinkedList) person.get("approved_memberships")))) { throw new LoginException("FAS authentication failed for " + username + ". Contributor License Agreement not yet signed"); } } else if (person.get("approved_memberships") instanceof LinkedHashMap) { if (!checkCLAAgreement(((LinkedHashMap) person.get("approved_memberships")))) { throw new LoginException("FAS authentication failed for " + username + ". Contributor License Agreement not yet signed"); } } } else { throw new LoginException("FAS authentication failed for " + username + ". Contributor License Agreement not yet signed"); } } else { throw new LoginException( "FAS authentication failed for " + username + ". Account is not active"); } } } else { throw new LoginException("Error: FAS authentication failed for " + username); } } } catch (LoginException e) { throw e; } catch (Exception e) { log.error(e.getMessage()); e.printStackTrace(); } finally { method.releaseConnection(); } return true; }
From source file:com.fortify.bugtracker.tgt.jira.processor.JiraTargetProcessorSubmitIssues.java
@Override protected TargetIssueLocator submitIssue(Context context, LinkedHashMap<String, Object> issueFields) { JiraRestConnection conn = JiraConnectionFactory.getConnection(context); issueFields.put("project.key", ICLIOptionsJira.CLI_JIRA_PROJECT_KEY.getValue(context)); issueFields.put("issuetype.name", getIssueType()); issueFields.put("summary", StringUtils.abbreviate((String) issueFields.get("summary"), 254)); return conn.submitIssue(issueFields); }
From source file:com.opengamma.analytics.math.curve.InterpolatedCurveBuildingFunction.java
public InterpolatedCurveBuildingFunction(final LinkedHashMap<String, double[]> knotPoints, LinkedHashMap<String, Interpolator1D> interpolators) { Validate.notNull(knotPoints, "null knot points"); Validate.notNull(interpolators, "null interpolators"); int count = 0; Set<String> names = knotPoints.keySet(); for (String name : names) { int size = knotPoints.get(name).length; Validate.isTrue(size > 0, "no knot points for " + name); count += size;//w w w . j av a 2 s .c o m } _knotPoints = knotPoints; _interpolators = interpolators; _nNodes = count; }
From source file:com.espertech.esper.epl.join.plan.NStreamOuterQueryPlanBuilder.java
private static void addNotYetNavigated(int streamNo, int numStreams, LinkedHashMap<Integer, int[]> substreamsPerStream, NStreamQueryPlanBuilder.BestChainResult bestChain) { // sum up all substreams (the query plan for each stream: nested iteration or cardinal) Set<Integer> streams = new HashSet<Integer>(); streams.add(streamNo);/*from ww w .j av a2 s . c o m*/ recursiveAdd(streamNo, streamNo, substreamsPerStream, streams, false); // we are done, all have navigated if (streams.size() == numStreams) { return; } int previous = streamNo; for (int stream : bestChain.getChain()) { if (streams.contains(stream)) { previous = stream; continue; } // add node as a nested join to the previous stream int[] substreams = substreamsPerStream.get(previous); if (substreams == null) { substreams = new int[0]; } int[] added = CollectionUtil.addValue(substreams, stream); substreamsPerStream.put(previous, added); if (!substreamsPerStream.containsKey(stream)) { substreamsPerStream.put(stream, new int[0]); } previous = stream; } }
From source file:com.qspin.qtaste.ui.tools.FileNode.java
/** * Loads the children, caching the results in the children ivar. *///ww w. j av a 2 s . com public Object[] getChildren() { if (children != null) { return children; } if (this.isTestcaseDir()) { try { ArrayList<TestDataNode> arrayDataNode = new ArrayList<>(); // load test case data File tcDataFile = this.getPythonTestScript().getTestcaseData(); if (tcDataFile == null) { return new Object[] {}; } CSVFile csvDataFile = new CSVFile(tcDataFile); List<LinkedHashMap<String, String>> data = csvDataFile.getCSVDataSet(); Iterator<LinkedHashMap<String, String>> it = data.iterator(); int rowIndex = 1; while (it.hasNext()) { LinkedHashMap<String, String> dataRow = it.next(); if (dataRow.containsKey("COMMENT")) { String comment = dataRow.get("COMMENT"); arrayDataNode.add(new TestDataNode(tcDataFile, comment, rowIndex)); } rowIndex++; } children = arrayDataNode.toArray(); return children; } catch (IOException ex) { // unable to read data file } } else { ArrayList<FileNode> arrayFileNode = new ArrayList<>(); if (f.isDirectory()) { File[] childFiles = FileUtilities.listSortedFiles(f); for (File childFile : childFiles) { FileNode fn = new FileNode(childFile, childFile.getName(), m_TestSuiteDir); boolean nodeToAdd = fn.isTestcaseDir(); if (!fn.isTestcaseDir()) { // go recursilvely to its child and check if it must be added nodeToAdd = checkIfDirectoryContainsTestScriptFile(childFile); } if (nodeToAdd && !childFile.isHidden()) { arrayFileNode.add(fn); } } } children = arrayFileNode.toArray(); } if (children == null) { return new Object[] {}; } else { return children; } }
From source file:net.big_oh.resourcestats.dao.RequestorDAOIntegrationTest.java
/** * Test method for/* ww w. j a va2 s.co m*/ * {@link net.big_oh.resourcestats.dao.RequestorDAO#getMostFrequentRequestors(int)} * . */ @Test public void testGetMostFrequentRequestorsInt() { try { sf.getCurrentSession().beginTransaction(); LinkedHashMap<Requestor, Number> requestors = dao.getMostFrequentRequestors(5); assertNotNull(requestors); for (Object key : requestors.keySet()) { assertTrue(key instanceof Requestor); Object value = requestors.get(key); assertTrue(value instanceof Number); } // TODO DSW Provide improved assertions sf.getCurrentSession().getTransaction().commit(); } catch (Throwable t) { HibernateUtil.rollback(t, sf, log); throw new RuntimeException(t); } }
From source file:net.big_oh.resourcestats.dao.RequestorDAOIntegrationTest.java
/** * Test method for//from www . j a va2 s . c o m * {@link net.big_oh.resourcestats.dao.RequestorDAO#getMostFrequentRequestors(int, int)} * . */ @Test public void testGetMostFrequentRequestorsIntInt() { try { sf.getCurrentSession().beginTransaction(); LinkedHashMap<Requestor, Number> requestors = dao.getMostFrequentRequestors(5, 7); assertNotNull(requestors); for (Object key : requestors.keySet()) { assertTrue(key instanceof Requestor); Object value = requestors.get(key); assertTrue(value instanceof Number); } // TODO DSW Provide improved assertions sf.getCurrentSession().getTransaction().commit(); } catch (Throwable t) { HibernateUtil.rollback(t, sf, log); throw new RuntimeException(t); } }
From source file:com.concursive.connect.web.modules.setup.utils.SetupUtils.java
public static void insertDefaultSiteConfig(Connection db, String fileLibraryPath, Project project, String purpose, ApplicationPrefs prefs) throws Exception { LOG.debug("insertDefaultSiteConfig"); // Validate the pre-reqs if (!StringUtils.hasText(project.getTitle()) || !StringUtils.hasText(project.getShortDescription()) || !StringUtils.hasText(project.getKeywords())) { throw new Exception("Title, description, keywords are required"); }/*from ww w .j a v a 2 s.c o m*/ // Load the categories ProjectCategoryList categoryList = new ProjectCategoryList(); categoryList.setTopLevelOnly(true); categoryList.buildList(db); // Determine the default's category int categoryId = categoryList.getIdFromValue("Groups"); // Determine the tabs boolean isPrivate = false; ProjectCategoryList validCategoryList = new ProjectCategoryList(); if ("social".equals(purpose)) { validCategoryList.add(categoryList.getFromValue("Groups")); validCategoryList.add(categoryList.getFromValue("People")); validCategoryList.add(categoryList.getFromValue("Events")); validCategoryList.add(categoryList.getFromValue("Ideas")); validCategoryList.add(categoryList.getFromValue("Sponsors")); } else if ("directory".equals(purpose)) { validCategoryList.add(categoryList.getFromValue("Businesses")); validCategoryList.add(categoryList.getFromValue("Organizations")); validCategoryList.add(categoryList.getFromValue("Groups")); validCategoryList.add(categoryList.getFromValue("People")); validCategoryList.add(categoryList.getFromValue("Places")); validCategoryList.add(categoryList.getFromValue("Events")); validCategoryList.add(categoryList.getFromValue("Ideas")); } else if ("community".equals(purpose)) { validCategoryList.add(categoryList.getFromValue("Groups")); validCategoryList.add(categoryList.getFromValue("People")); validCategoryList.add(categoryList.getFromValue("Ideas")); } else if ("intranet".equals(purpose)) { isPrivate = true; prefs.add(ApplicationPrefs.INFORMATION_IS_SENSITIVE, "true"); prefs.add(ApplicationPrefs.USERS_CAN_REGISTER, "false"); prefs.add(ApplicationPrefs.USERS_CAN_INVITE, "false"); prefs.add(ApplicationPrefs.USERS_CAN_START_PROJECTS, "true"); validCategoryList.add(categoryList.getFromValue("Groups")); validCategoryList.add(categoryList.getFromValue("People")); validCategoryList.add(categoryList.getFromValue("Events")); validCategoryList.add(categoryList.getFromValue("Ideas")); validCategoryList.add(categoryList.getFromValue("Projects")); } else if ("projects".equals(purpose)) { isPrivate = true; prefs.add(ApplicationPrefs.INFORMATION_IS_SENSITIVE, "true"); prefs.add(ApplicationPrefs.USERS_CAN_REGISTER, "false"); prefs.add(ApplicationPrefs.USERS_CAN_INVITE, "false"); validCategoryList.add(categoryList.getFromValue("Groups")); validCategoryList.add(categoryList.getFromValue("People")); validCategoryList.add(categoryList.getFromValue("Projects")); } else if ("web".equals(purpose)) { validCategoryList.add(categoryList.getFromValue("Products")); validCategoryList.add(categoryList.getFromValue("Services")); validCategoryList.add(categoryList.getFromValue("Partners")); validCategoryList.add(categoryList.getFromValue("Groups")); validCategoryList.add(categoryList.getFromValue("People")); validCategoryList.add(categoryList.getFromValue("Events")); validCategoryList.add(categoryList.getFromValue("Ideas")); validCategoryList.add(categoryList.getFromValue("Projects")); } // Update the related tabs, or leave all enabled if (validCategoryList.size() > 0) { for (ProjectCategory category : categoryList) { category.setEnabled(validCategoryList.get(category) != null); category.setSensitive(isPrivate); category.update(db); } } // Determine the profile visibility project.setUpdateAllowGuests(true); project.setAllowGuests(isPrivate ? false : true); project.setUpdateAllowParticipants(true); project.setAllowParticipants(true); project.setUpdateMembershipRequired(true); project.setMembershipRequired(false); project.setApproved(true); // Determine the tabs project.setShowProfile(true); project.getFeatures().setLabelProfile("Overview"); project.setShowNews(true); project.getFeatures().setLabelNews("Blog"); project.setShowReviews(true); project.setShowWiki(true); project.setShowCalendar(true); project.setShowDiscussion(true); project.setShowDocuments(true); project.setShowClassifieds(true); project.setShowBadges(true); project.setShowLists(true); project.setShowIssues(true); project.setShowTeam(true); project.getFeatures().setLabelTickets("Issues"); project.getFeatures().setLabelTeam("Participants"); project.setShowMessages(true); // Determine the record details project.setUniqueId("main-profile"); project.setGroupId(1); project.setCategoryId(categoryId); project.setOwner(1); project.setEnteredBy(1); project.setModifiedBy(1); project.insert(db); project.updateFeatures(db); project.setSystemDefault(true); project.updateSystemDefault(db); // Build a list of roles LookupList roleList = CacheUtils.getLookupList("lookup_project_role"); // Build a list of the default permissions PermissionList permissionList = new PermissionList(); permissionList.setProjectId(project.getId()); permissionList.buildList(db); // Modify the permissions for the default profile LinkedHashMap<String, Integer> permissionMap = new LinkedHashMap<String, Integer>(); permissionMap.put("project-tickets-view", TeamMember.MEMBER); permissionMap.put("project-tickets-other", TeamMember.CHAMPION); permissionMap.put("project-tickets-add", TeamMember.MEMBER); permissionMap.put("project-tickets-edit", TeamMember.CHAMPION); permissionMap.put("project-tickets-assign", TeamMember.CHAMPION); permissionMap.put("project-tickets-close", TeamMember.CHAMPION); permissionMap.put("project-tickets-delete", TeamMember.MANAGER); for (String name : permissionMap.keySet()) { Permission permission = permissionList.get(name); permission.setUserLevel(roleList.getIdFromLevel(permissionMap.get(name))); LOG.debug("Updating a permission: " + name); permission.update(db); } // Get the admin role int adminRowLevel = roleList.getIdFromValue("Manager"); // Add the admins as a member UserList userList = new UserList(); userList.setAdmin(Constants.TRUE); userList.buildList(db); for (User thisUser : userList) { TeamMember thisMember = new TeamMember(); thisMember.setProjectId(project.getId()); thisMember.setUserId(thisUser.getId()); thisMember.setUserLevel(adminRowLevel); thisMember.setEnteredBy(1); thisMember.setModifiedBy(1); thisMember.insert(db); } }
From source file:org.cloudfoundry.community.servicebroker.vrealize.VraClient.java
Map<String, Object> getLinks(JsonElement resources) { Map<String, Object> map = new HashMap<String, Object>(); ReadContext ctx = JsonPath.parse(resources.toString()); JSONArray o = ctx.read("$.content[*].links[*]"); Iterator it = o.iterator();//from w w w . jav a 2 s . c o m while (it.hasNext()) { LinkedHashMap ja = (LinkedHashMap) it.next(); Object key = ja.get("rel"); Object val = ja.get("href"); if (key != null && val != null) { map.put(key.toString(), val); } } return map; }