List of usage examples for java.util LinkedHashMap put
V put(K key, V value);
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"); }/* w ww. j av a 2 s . c om*/ // 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:com.espertech.esper.event.bean.PropertyHelper.java
/** * Removed duplicate properties using the property name to find unique properties. * @param properties is a list of property descriptors *//*from ww w .j ava2s. c om*/ protected static void removeDuplicateProperties(List<InternalEventPropDescriptor> properties) { LinkedHashMap<String, InternalEventPropDescriptor> set = new LinkedHashMap<String, InternalEventPropDescriptor>(); List<InternalEventPropDescriptor> toRemove = new LinkedList<InternalEventPropDescriptor>(); // add duplicates to separate list for (InternalEventPropDescriptor desc : properties) { if (set.containsKey(desc.getPropertyName())) { toRemove.add(desc); continue; } set.put(desc.getPropertyName(), desc); } // remove duplicates for (InternalEventPropDescriptor desc : toRemove) { properties.remove(desc); } }
From source file:com.alibaba.wasp.meta.TestFMetaStore.java
public static LinkedHashMap<String, Field> clone(LinkedHashMap<String, Field> fields) { if (fields == null) { return null; }/*from ww w . ja v a2 s .c om*/ LinkedHashMap<String, Field> clone = new LinkedHashMap<String, Field>(); for (Field field : fields.values()) { Field cloneField = clone(field); clone.put(cloneField.getName(), cloneField); } return clone; }
From source file:com.linkedin.pinot.controller.helix.core.UAutoRebalancer.java
public static LinkedHashMap<String, Integer> stateCount(StateModelDefinition stateModelDef, int liveNodesNb, int totalReplicas) { LinkedHashMap<String, Integer> stateCountMap = new LinkedHashMap<String, Integer>(); List<String> statesPriorityList = stateModelDef.getStatesPriorityList(); int replicas = totalReplicas; for (String state : statesPriorityList) { String num = stateModelDef.getNumInstancesPerState(state); if ("N".equals(num)) { stateCountMap.put(state, liveNodesNb); } else if ("R".equals(num)) { // wait until we get the counts for all other states continue; } else {/*from w ww.j a v a 2s.co m*/ int stateCount = -1; try { stateCount = Integer.parseInt(num); } catch (Exception e) { // LOG.error("Invalid count for state: " + state + ", count: " + num + // ", use -1 instead"); } if (stateCount > 0) { stateCountMap.put(state, stateCount); replicas -= stateCount; } } } // get state count for R for (String state : statesPriorityList) { String num = stateModelDef.getNumInstancesPerState(state); if ("R".equals(num)) { stateCountMap.put(state, replicas); // should have at most one state using R break; } } return stateCountMap; }
From source file:Main.java
/** * This method will find all the parameters under this <code>paramsElement</code> and return them as * Map<String, String>. For example, * <pre>//from w ww.j av a2s . c o m * <result ... > * <param name="param1">value1</param> * <param name="param2">value2</param> * <param name="param3">value3</param> * </result> * </pre> * will returns a Map<String, String> with the following key, value pairs :- * <ul> * <li>param1 - value1</li> * <li>param2 - value2</li> * <li>param3 - value3</li> * </ul> * * @param paramsElement * @return */ public static Map<String, String> getParams(Element paramsElement) { LinkedHashMap<String, String> params = new LinkedHashMap<String, String>(); if (paramsElement == null) { return params; } NodeList childNodes = paramsElement.getChildNodes(); for (int i = 0; i < childNodes.getLength(); i++) { Node childNode = childNodes.item(i); if ((childNode.getNodeType() == Node.ELEMENT_NODE) && "param".equals(childNode.getNodeName())) { Element paramElement = (Element) childNode; String paramName = paramElement.getAttribute("name"); String val = getContent(paramElement); if (val.length() > 0) { params.put(paramName, val); } } } return params; }
From source file:com.cburch.logisim.gui.main.SelectionAttributes.java
private static LinkedHashMap<Attribute<Object>, Object> computeAttributes(Collection<Component> newSel) { LinkedHashMap<Attribute<Object>, Object> attrMap; attrMap = new LinkedHashMap<Attribute<Object>, Object>(); Iterator<Component> sit = newSel.iterator(); if (sit.hasNext()) { AttributeSet first = sit.next().getAttributeSet(); for (Attribute<?> attr : first.getAttributes()) { @SuppressWarnings("unchecked") Attribute<Object> attrObj = (Attribute<Object>) attr; attrMap.put(attrObj, first.getValue(attr)); }//from w w w .j a v a 2 s . co m while (sit.hasNext()) { AttributeSet next = sit.next().getAttributeSet(); Iterator<Attribute<Object>> ait = attrMap.keySet().iterator(); while (ait.hasNext()) { Attribute<Object> attr = ait.next(); if (next.containsAttribute(attr)) { Object v = attrMap.get(attr); if (v != null && !v.equals(next.getValue(attr))) { attrMap.put(attr, null); } } else { ait.remove(); } } } } return attrMap; }
From source file:com.primovision.lutransport.core.util.TollCompanyTagUploadUtil.java
private static void mapForEZPassNY(LinkedList<String> expectedColumnList) { LinkedHashMap<String, String> actualColumnMap = new LinkedHashMap<String, String>(); int expectedColumnStartIndex = 2; actualColumnMap.put(expectedColumnList.get(expectedColumnStartIndex++), StringUtils.EMPTY); actualColumnMap.put(expectedColumnList.get(expectedColumnStartIndex++), "TAG NUMBER/"); actualColumnMap.put(expectedColumnList.get(expectedColumnStartIndex++), "TAG NUMBER/"); actualColumnMap.put(expectedColumnList.get(expectedColumnStartIndex++), "Driver Name"); actualColumnMap.put(expectedColumnList.get(expectedColumnStartIndex++), "TRANS"); actualColumnMap.put(expectedColumnList.get(expectedColumnStartIndex++), "TIME"); actualColumnMap.put(expectedColumnList.get(expectedColumnStartIndex++), "AGENCY"); actualColumnMap.put(expectedColumnList.get(expectedColumnStartIndex++), "AMOUNT"); actualColumnMap.put(expectedColumnList.get(expectedColumnStartIndex++), "Invoice Date"); //actualColumnMap.put(expectedColumnList.get(expectedColumnStartIndex++), "Unit #"); tollCompanyToTollTagMapping.put(TOLL_COMPANY_EZ_PASS_NY, actualColumnMap); }
From source file:com.primovision.lutransport.core.util.TollCompanyTagUploadUtil.java
private static void mapForEZPassPA(LinkedList<String> expectedColumnList) { LinkedHashMap<String, String> actualColumnMap = new LinkedHashMap<String, String>(); int expectedColumnStartIndex = 2; actualColumnMap.put(expectedColumnList.get(expectedColumnStartIndex++), StringUtils.EMPTY); actualColumnMap.put(expectedColumnList.get(expectedColumnStartIndex++), "TAG/LICENSE"); actualColumnMap.put(expectedColumnList.get(expectedColumnStartIndex++), "TAG/LICENSE"); actualColumnMap.put(expectedColumnList.get(expectedColumnStartIndex++), "Driver Name"); actualColumnMap.put(expectedColumnList.get(expectedColumnStartIndex++), "EXIT DATE"); actualColumnMap.put(expectedColumnList.get(expectedColumnStartIndex++), "EXIT DATE"); actualColumnMap.put(expectedColumnList.get(expectedColumnStartIndex++), "EXIT PLAZA"); actualColumnMap.put(expectedColumnList.get(expectedColumnStartIndex++), "AMOUNT"); actualColumnMap.put(expectedColumnList.get(expectedColumnStartIndex++), "Invoice Date"); //actualColumnMap.put(expectedColumnList.get(expectedColumnStartIndex++), "Unit #"); tollCompanyToTollTagMapping.put(TOLL_COMPANY_EZ_PASS_PA, actualColumnMap); }
From source file:com.primovision.lutransport.core.util.TollCompanyTagUploadUtil.java
private static void mapForIPass(LinkedList<String> expectedColumnList) { LinkedHashMap<String, String> actualColumnMap = new LinkedHashMap<String, String>(); int expectedColumnStartIndex = 2; actualColumnMap.put(expectedColumnList.get(expectedColumnStartIndex++), StringUtils.EMPTY); actualColumnMap.put(expectedColumnList.get(expectedColumnStartIndex++), "Transponder ID"); actualColumnMap.put(expectedColumnList.get(expectedColumnStartIndex++), "Transponder ID"); actualColumnMap.put(expectedColumnList.get(expectedColumnStartIndex++), "Driver Name"); actualColumnMap.put(expectedColumnList.get(expectedColumnStartIndex++), "Transaction date"); actualColumnMap.put(expectedColumnList.get(expectedColumnStartIndex++), "Transaction date"); actualColumnMap.put(expectedColumnList.get(expectedColumnStartIndex++), "Toll agency"); actualColumnMap.put(expectedColumnList.get(expectedColumnStartIndex++), "Transaction amount"); actualColumnMap.put(expectedColumnList.get(expectedColumnStartIndex++), "Invoice Date"); //actualColumnMap.put(expectedColumnList.get(expectedColumnStartIndex++), "Unit #"); tollCompanyToTollTagMapping.put(TOLL_COMPANY_IPASS, actualColumnMap); }
From source file:com.primovision.lutransport.core.util.TollCompanyTagUploadUtil.java
private static void mapForSunPass(LinkedList<String> expectedColumnList) { LinkedHashMap<String, String> actualColumnMap = new LinkedHashMap<String, String>(); int expectedColumnStartIndex = 2; actualColumnMap.put(expectedColumnList.get(expectedColumnStartIndex++), StringUtils.EMPTY); actualColumnMap.put(expectedColumnList.get(expectedColumnStartIndex++), "TOLL TAG # / PLATE #"); actualColumnMap.put(expectedColumnList.get(expectedColumnStartIndex++), "TOLL TAG # / PLATE #"); actualColumnMap.put(expectedColumnList.get(expectedColumnStartIndex++), "Driver Name"); actualColumnMap.put(expectedColumnList.get(expectedColumnStartIndex++), "TRANSACTION DATE"); actualColumnMap.put(expectedColumnList.get(expectedColumnStartIndex++), "TRANSACTION TIME"); actualColumnMap.put(expectedColumnList.get(expectedColumnStartIndex++), StringUtils.EMPTY); actualColumnMap.put(expectedColumnList.get(expectedColumnStartIndex++), "AMOUNT"); actualColumnMap.put(expectedColumnList.get(expectedColumnStartIndex++), "Invoice Date"); //actualColumnMap.put(expectedColumnList.get(expectedColumnStartIndex++), "Unit #"); tollCompanyToTollTagMapping.put(TOLL_COMPANY_SUN_PASS, actualColumnMap); }