List of usage examples for java.util LinkedHashMap containsKey
boolean containsKey(Object key);
From source file:com.espertech.esper.regression.pattern.TestCronParameter.java
private void checkResults(String eventId) { log.debug(".checkResults Checking results for event " + eventId); String expressionText = patternStmt.getText(); LinkedHashMap<String, LinkedList<EventDescriptor>> allExpectedResults = testCase.getExpectedResults(); EventBean[] receivedResults = listener.getLastNewData(); // If nothing at all was expected for this event, make sure nothing was received if (!(allExpectedResults.containsKey(eventId))) { if ((receivedResults != null) && (receivedResults.length > 0)) { log.debug(".checkResults Incorrect result for expression : " + expressionText); log.debug(".checkResults Expected no results for event " + eventId + ", but received " + receivedResults.length + " events"); log.debug(".checkResults Received, have " + receivedResults.length + " entries"); printList(receivedResults);/*from ww w .ja v a 2 s . c o m*/ TestCase.assertFalse(true); } } LinkedList<EventDescriptor> expectedResults = allExpectedResults.get(eventId); // Compare the result lists, not caring about the order of the elements if (!(compareLists(receivedResults, expectedResults))) { log.debug(".checkResults Incorrect result for expression : " + expressionText); log.debug(".checkResults Expected size=" + expectedResults.size() + " received size=" + (receivedResults == null ? 0 : receivedResults.length)); log.debug(".checkResults Expected, have " + expectedResults.size() + " entries"); printList(expectedResults); log.debug(".checkResults Received, have " + (receivedResults == null ? 0 : receivedResults.length) + " entries"); printList(receivedResults); TestCase.assertFalse(true); } }
From source file:com.opengamma.analytics.financial.interestrate.capletstripping.CapletStrippingFunction.java
public CapletStrippingFunction(final List<CapFloor> caps, final YieldCurveBundle yieldCurves, final LinkedHashMap<String, double[]> knotPoints, final LinkedHashMap<String, Interpolator1D> interpolators, final LinkedHashMap<String, ParameterLimitsTransform> parameterTransforms, final LinkedHashMap<String, InterpolatedDoublesCurve> knownParameterTermSturctures) { Validate.notNull(caps, "caps null"); Validate.notNull(knotPoints, "null node points"); Validate.notNull(interpolators, "null interpolators"); Validate.isTrue(knotPoints.size() == interpolators.size(), "size mismatch between nodes and interpolators"); if (knownParameterTermSturctures == null) { Validate.isTrue(knotPoints.containsKey(ALPHA) && interpolators.containsKey(ALPHA), "alpha curve not found"); Validate.isTrue(knotPoints.containsKey(BETA) && interpolators.containsKey(BETA), "beta curve not found"); Validate.isTrue(knotPoints.containsKey(NU) && interpolators.containsKey(NU), "nu curve not found"); Validate.isTrue(knotPoints.containsKey(RHO) && interpolators.containsKey(RHO), "rho curve not found"); } else {/* ww w. j a va 2 s.c o m*/ Validate.isTrue((knotPoints.containsKey(ALPHA) && interpolators.containsKey(ALPHA)) ^ knownParameterTermSturctures.containsKey(ALPHA), "alpha curve not found"); Validate.isTrue((knotPoints.containsKey(BETA) && interpolators.containsKey(BETA)) ^ knownParameterTermSturctures.containsKey(BETA), "beta curve not found"); Validate.isTrue((knotPoints.containsKey(NU) && interpolators.containsKey(NU)) ^ knownParameterTermSturctures.containsKey(NU), "nu curve not found"); Validate.isTrue((knotPoints.containsKey(RHO) && interpolators.containsKey(RHO)) ^ knownParameterTermSturctures.containsKey(RHO), "rho curve not found"); } final LinkedHashMap<String, Interpolator1D> transInterpolators = new LinkedHashMap<String, Interpolator1D>(); final Set<String> names = interpolators.keySet(); for (final String name : names) { final Interpolator1D temp = new TransformedInterpolator1D(interpolators.get(name), parameterTransforms.get(name)); transInterpolators.put(name, temp); } _curveBuilder = new InterpolatedCurveBuildingFunction(knotPoints, transInterpolators); // _parameterTransforms = parameterTransforms; //TODO all the check for this _capPricers = new ArrayList<CapFloorPricer>(caps.size()); for (final CapFloor cap : caps) { _capPricers.add(new CapFloorPricer(cap, yieldCurves)); } _knownParameterTermStructures = knownParameterTermSturctures; }
From source file:com.intel.iotkitlib.LibUtils.IotKit.java
public String prepareUrl(String urlToAppend, LinkedHashMap urlSlugNameValues) { String urlPrepared = null;/*from www . ja va 2s .co m*/ if (urlToAppend != null) { if (Utilities.sharedPreferences == null) { Log.w(TAG, "cannot find shared preferences object,not able to create URL"); return null; } //Handling Slug param replacement in URL if (urlToAppend.contains("data_account_id")) { if (urlSlugNameValues != null && urlSlugNameValues.containsKey("account_id")) { urlToAppend = urlToAppend.replace("data_account_id", urlSlugNameValues.get("account_id").toString()); } else { urlToAppend = urlToAppend.replace("data_account_id", Utilities.sharedPreferences.getString("account_id", "")); } //updating device id url-value if (urlToAppend.contains("other_device_id")) { urlToAppend = urlToAppend.replace("other_device_id", urlSlugNameValues.get("other_device_id").toString()); } if (urlToAppend.contains("device_id")) { urlToAppend = urlToAppend.replace("device_id", Utilities.sharedPreferences.getString("deviceId", "")); } if (urlToAppend.contains("cmp_catalog_id")) { urlToAppend = urlToAppend.replace("cmp_catalog_id", urlSlugNameValues.get("cmp_catalog_id").toString()); } if (urlToAppend.contains("cid")) { String sensorId = null; if ((sensorId = Utilities.getSensorId(urlSlugNameValues.get("cname").toString())) != null) { urlToAppend = urlToAppend.replace("cid", sensorId); } else { Log.d(TAG, "No component found with this name-To Delete"); } /*if (Utilities.sharedPreferences.getString("cname", ""). contentEquals(urlSlugNameValues.get("cname").toString())) { urlToAppend = urlToAppend.replace("cid", Utilities.sharedPreferences.getString("cid", "")); } */ } if (urlToAppend.contains("email")) { urlToAppend = urlToAppend.replace("email", urlSlugNameValues.get("email").toString()); } if (urlToAppend.contains("rule_id")) { urlToAppend = urlToAppend.replace("rule_id", urlSlugNameValues.get("rule_id").toString()); } if (urlToAppend.contains("alert_id")) { urlToAppend = urlToAppend.replace("alert_id", urlSlugNameValues.get("alert_id").toString()); } if (urlToAppend.contains("invitee_user_id")) { urlToAppend = urlToAppend.replace("invitee_user_id", urlSlugNameValues.get("invitee_user_id").toString()); } } else if (urlToAppend.contains("device_id")) { urlToAppend = urlToAppend.replace("device_id", Utilities.sharedPreferences.getString("deviceId", "")); } else if (urlToAppend.contains("user_id")) { urlToAppend = urlToAppend.replace("user_id", urlSlugNameValues.get("user_id").toString()); } else if (urlToAppend.contains("email")) { urlToAppend = urlToAppend.replace("email", urlSlugNameValues.get("email").toString()); } else { Log.d(TAG, "URL with out slugs"); } } urlToAppend = urlToAppend.replaceAll("\\{", ""); urlToAppend = urlToAppend.replaceAll("\\}", ""); //appending the module url to base url urlPrepared = base_Url + urlToAppend; return urlPrepared; }
From source file:com.huateng.startup.init.MenuInfoUtil.java
/** * ???// w w w .j a v a2s .c om * @param degree */ @SuppressWarnings("unchecked") public static LinkedHashMap<String, Object> setOperatorMenuWithDegree(String degree, String contextPath, Document document) { String sql = "select * FROM TBL_ROLE_FUNC_MAP WHERE KEY_ID in ( " + degree + ")"; ICommQueryDAO commQueryDAO = (ICommQueryDAO) ContextUtil.getBean("CommQueryDAO"); List<Object[]> funcMapList = commQueryDAO.findBySQLQuery(sql); valueIdRole(funcMapList); List<Object> menuLvl1List = allMenuBean.getDataList(); LinkedHashMap<String, Object> menuIndexMap = new LinkedHashMap<String, Object>(); String panelStr = ""; //????? for (int i = 0, n = menuLvl1List.size(); i < n; i++) { Map<String, Object> menuLvl1Map = (Map<String, Object>) menuLvl1List.get(i); LinkedList<Object> menuLvl2List = (LinkedList<Object>) menuLvl1Map.get(Constants.MENU_CHILDREN); List<String> menuList = new ArrayList<String>(); for (int j = 0, m = menuLvl2List.size(); j < m; j++) { Map<String, Object> menuLvl2Map = (Map<String, Object>) menuLvl2List.get(j); LinkedList<Object> menuLvl3List = (LinkedList<Object>) menuLvl2Map.get(Constants.MENU_CHILDREN); for (int k = 0, l = menuLvl3List.size(); k < l; k++) { Map<String, Object> menuLvl3Map = (Map<String, Object>) menuLvl3List.get(k); for (int a = 0, b = funcMapList.size(); a < b; a++) { if (StringUtils.trim(funcMapList.get(a)[1].toString()) .equals(StringUtils.trim(menuLvl3Map.get(Constants.MENU_ID).toString()))) { if (!menuIndexMap.containsKey(menuLvl1Map.get(Constants.MENU_ID).toString())) { Map<String, Object> menuLvl1HashMap = new LinkedHashMap<String, Object>(); String menuId = menuLvl1Map.get(Constants.MENU_ID).toString(); menuLvl1HashMap.put(Constants.MENU_ID, menuLvl1Map.get(Constants.MENU_ID)); menuLvl1HashMap.put(Constants.MENU_TEXT, menuLvl1Map.get(Constants.MENU_TEXT)); menuLvl1HashMap.put(Constants.MENU_CLS, menuLvl1Map.get(Constants.MENU_CLS)); menuLvl1HashMap.put(Constants.MENU_HANDLER, Constants.MENU_LVL1_FUNC); menuLvl1HashMap.put(Constants.TOOL_BAR_TYPE, Constants.TOOL_BAR_BUTTON); menuLvl1HashMap.put(Constants.TOOLBAR_ICON, Constants.TOOLBAR_ICON_MENU); menuLvl1HashMap.put(Constants.IS_EXPAND, true); if ("1".equals(menuId) && panelStr.indexOf("baseTree") == -1) { panelStr = panelStr + "baseTree,"; } if ("2".equals(menuId) && panelStr.indexOf("mchtTree") == -1) { panelStr = panelStr + "mchtTree,"; } if ("3".equals(menuId) && panelStr.indexOf("termTree") == -1) { panelStr = panelStr + "termTree,"; } if ("5".equals(menuId) && panelStr.indexOf("queryTree") == -1) { panelStr = panelStr + "queryTree,"; } if ("9".equals(menuId) && panelStr.indexOf("onLinePayTree") == -1) { panelStr = panelStr + "onLinePayTree,"; } if ("10".equals(menuId) && panelStr.indexOf("taskTree") == -1) { panelStr = panelStr + "taskTree,"; } if ("8".equals(menuId) && panelStr.indexOf("clearTree") == -1) { panelStr = panelStr + "clearTree,"; } if ("4".equals(menuId) && panelStr.indexOf("riskTree") == -1) { panelStr = panelStr + "riskTree,"; } if ("11".equals(menuId) && panelStr.indexOf("provisionsTree") == -1) { panelStr = panelStr + "provisionsTree,"; } if ("12".equals(menuId) && panelStr.indexOf("errorTree") == -1) { panelStr = panelStr + "errorTree,"; } Map<String, Object> menuLvl2HashMap = new LinkedHashMap<String, Object>(); menuLvl2HashMap.put(Constants.MENU_ID, menuLvl2Map.get(Constants.MENU_ID)); menuLvl2HashMap.put(Constants.MENU_TEXT, menuLvl2Map.get(Constants.MENU_TEXT)); menuLvl2HashMap.put(Constants.MENU_PARENT_ID, menuLvl2Map.get(Constants.MENU_PARENT_ID)); menuLvl2HashMap.put(Constants.MENU_CLS, menuLvl2Map.get(Constants.MENU_CLS)); menuLvl2HashMap.put(Constants.TOOLBAR_ICON, Constants.TOOLBAR_ICON_MENUITEM); menuLvl2HashMap.put(Constants.IS_EXPAND, true); Map<String, Object> menuLvl3HashMap = new LinkedHashMap<String, Object>(); int index = menuList.lastIndexOf((String) menuLvl3Map.get(Constants.MENU_ID)); LinkedList<Object> menuLvl3Child = new LinkedList<Object>(); //System.out.println((String)menuLvl3Map.get(Constants.MENU_ID) + ">>>>>>>>>" + index + ">>>>>" + menuList.size()); if (-1 == index) { String tbar = MenuUtil.initMenu((String) menuLvl3Map.get(Constants.MENU_ID), (String) funcMapList.get(a)[5]); menuLvl3HashMap.put(Constants.MENU_ID, menuLvl3Map.get(Constants.MENU_ID)); menuLvl3HashMap.put(Constants.MENU_TEXT, menuLvl3Map.get(Constants.MENU_TEXT)); menuLvl3HashMap.put(Constants.MENU_PARENT_ID, menuLvl3Map.get(Constants.MENU_PARENT_ID)); menuLvl3HashMap.put(Constants.MENU_LEAF, true); menuLvl3HashMap.put(Constants.MENU_URL, menuLvl3Map.get(Constants.MENU_URL)); menuLvl3HashMap.put(Constants.ROLE_FLAG, tbar); menuLvl3HashMap.put(Constants.MENU_CLS, menuLvl3Map.get(Constants.MENU_CLS)); menuLvl3HashMap.put(Constants.MENU_HANDLER, Constants.MENU_LVL3_FUNC); menuLvl3HashMap.put(Constants.TOOLBAR_ICON, menuLvl3Map.get(Constants.TOOLBAR_ICON)); menuLvl3HashMap.put(Constants.IS_EXPAND, true); menuList.add((String) menuLvl3Map.get(Constants.MENU_ID)); menuLvl3Child.add(menuLvl3HashMap); } else { Map<String, Object> menu = (Map<String, Object>) menuLvl3Child.get(index); menu.put(Constants.ROLE_FLAG, (String) menu.get(Constants.ROLE_FLAG) + funcMapList.get(a)[5]); } menuLvl2HashMap.put(Constants.MENU_CHILDREN, menuLvl3Child); menuLvl2HashMap.put(Constants.TOOL_BAR_CHILDREN, menuLvl3Child); LinkedList<Object> menuLvl2Child = new LinkedList<Object>(); menuLvl2Child.add(menuLvl2HashMap); menuLvl1HashMap.put(Constants.MENU_CHILDREN, menuLvl2Child); menuLvl1HashMap.put(Constants.TOOL_BAR_CHILDREN, menuLvl2Child); menuIndexMap.put(menuLvl1Map.get(Constants.MENU_ID).toString(), menuLvl1HashMap); } else { Map<String, Object> menuLvl1HashMap = (Map<String, Object>) menuIndexMap .get(menuLvl1Map.get(Constants.MENU_ID).toString()); LinkedList<Object> menuLvl2Child = (LinkedList<Object>) menuLvl1HashMap .get(Constants.MENU_CHILDREN); boolean hasMenu = false; for (int c = 0, d = menuLvl2Child.size(); c < d; c++) { Map<String, Object> menuLvl2HashMap = (Map<String, Object>) menuLvl2Child .get(c); if (StringUtils.trim(menuLvl2HashMap.get(Constants.MENU_ID).toString()).equals( StringUtils.trim(menuLvl2Map.get(Constants.MENU_ID).toString()))) { LinkedList<Object> menuLvl3Child = (LinkedList<Object>) menuLvl2HashMap .get(Constants.MENU_CHILDREN); Map<String, Object> menuLvl3HashMap = new LinkedHashMap<String, Object>(); int index = menuList .lastIndexOf((String) menuLvl3Map.get(Constants.MENU_ID)); if (-1 == index) { String tbar = MenuUtil.initMenu( (String) menuLvl3Map.get(Constants.MENU_ID), (String) funcMapList.get(a)[5]); menuLvl3HashMap.put(Constants.MENU_ID, menuLvl3Map.get(Constants.MENU_ID)); menuLvl3HashMap.put(Constants.MENU_TEXT, menuLvl3Map.get(Constants.MENU_TEXT)); menuLvl3HashMap.put(Constants.MENU_PARENT_ID, menuLvl3Map.get(Constants.MENU_PARENT_ID)); menuLvl3HashMap.put(Constants.MENU_LEAF, true); menuLvl3HashMap.put(Constants.MENU_URL, menuLvl3Map.get(Constants.MENU_URL)); menuLvl3HashMap.put(Constants.ROLE_FLAG, tbar); menuLvl3HashMap.put(Constants.MENU_CLS, menuLvl3Map.get(Constants.MENU_CLS)); menuLvl3HashMap.put(Constants.MENU_HANDLER, Constants.MENU_LVL3_FUNC); menuLvl3HashMap.put(Constants.TOOLBAR_ICON, menuLvl3Map.get(Constants.TOOLBAR_ICON)); menuLvl3HashMap.put(Constants.IS_EXPAND, true); menuList.add((String) menuLvl3Map.get(Constants.MENU_ID)); menuLvl3Child.add(menuLvl3HashMap); } // else{ // Map<String, Object> menu = (Map<String, Object>)menuLvl3Child.get(index); // menu.put(Constants.ROLE_FLAG,(String)menu.get(Constants.ROLE_FLAG) + funcMapList.get(a)[5]); // } menuLvl2HashMap.put(Constants.MENU_CHILDREN, menuLvl3Child); menuLvl2HashMap.put(Constants.TOOL_BAR_CHILDREN, menuLvl3Child); menuLvl2HashMap.put(Constants.IS_EXPAND, true); menuLvl2Child.set(c, menuLvl2HashMap); hasMenu = true; break; } } if (!hasMenu) { String tbar = MenuUtil.initMenu((String) menuLvl3Map.get(Constants.MENU_ID), (String) funcMapList.get(a)[5]); Map<String, Object> menuLvl2HashMap = new HashMap<String, Object>(); menuLvl2HashMap.put(Constants.MENU_ID, menuLvl2Map.get(Constants.MENU_ID)); menuLvl2HashMap.put(Constants.MENU_TEXT, menuLvl2Map.get(Constants.MENU_TEXT)); menuLvl2HashMap.put(Constants.MENU_PARENT_ID, menuLvl2Map.get(Constants.MENU_PARENT_ID)); menuLvl2HashMap.put(Constants.MENU_CLS, menuLvl2Map.get(Constants.MENU_CLS)); menuLvl2HashMap.put(Constants.TOOLBAR_ICON, Constants.TOOLBAR_ICON_MENUITEM); menuLvl2HashMap.put(Constants.IS_EXPAND, true); LinkedList<Object> menuLvl3Child = new LinkedList<Object>(); Map<String, Object> menuLvl3HashMap = new LinkedHashMap<String, Object>(); menuLvl3HashMap.put(Constants.MENU_ID, menuLvl3Map.get(Constants.MENU_ID)); menuLvl3HashMap.put(Constants.MENU_TEXT, menuLvl3Map.get(Constants.MENU_TEXT)); menuLvl3HashMap.put(Constants.MENU_PARENT_ID, menuLvl3Map.get(Constants.MENU_PARENT_ID)); menuLvl3HashMap.put(Constants.MENU_LEAF, true); menuLvl3HashMap.put(Constants.MENU_URL, menuLvl3Map.get(Constants.MENU_URL)); menuLvl3HashMap.put(Constants.MENU_CLS, menuLvl3Map.get(Constants.MENU_CLS)); menuLvl3HashMap.put(Constants.ROLE_FLAG, tbar); menuLvl3HashMap.put(Constants.MENU_HANDLER, Constants.MENU_LVL3_FUNC); //menuLvl3HashMap.put(Constants.TOOLBAR_ICON, Constants.TOOLBAR_ICON_MENUITEM); menuLvl3HashMap.put(Constants.TOOLBAR_ICON, menuLvl3Map.get(Constants.TOOLBAR_ICON)); menuLvl3HashMap.put(Constants.IS_EXPAND, true); menuLvl3Child.add(menuLvl3HashMap); menuLvl2HashMap.put(Constants.MENU_CHILDREN, menuLvl3Child); menuLvl2HashMap.put(Constants.TOOL_BAR_CHILDREN, menuLvl3Child); menuLvl2Child.add(menuLvl2HashMap); } menuLvl1HashMap.put(Constants.MENU_CHILDREN, menuLvl2Child); menuLvl1HashMap.put(Constants.TOOL_BAR_CHILDREN, menuLvl2Child); menuLvl1HashMap.put(Constants.IS_EXPAND, true); menuIndexMap.put(menuLvl1Map.get(Constants.MENU_ID).toString(), menuLvl1HashMap); } } } } } } menuIndexMap.remove(Constants.TREE_MENU_PANEL); if (panelStr.length() != 0) { menuIndexMap.put(Constants.TREE_MENU_PANEL, panelStr.substring(0, panelStr.length() - 1)); } else { menuIndexMap.put(Constants.TREE_MENU_PANEL, ""); } return menuIndexMap; }
From source file:org.kutkaitis.timetable2.timetable.MonteCarlo.java
private LinkedHashMap<String, String> getTeachersTimeTable(String teacherName, LinkedHashMap<String, LinkedHashMap> dayTimeTable) { LinkedHashMap<String, String> teachersTimeTable; if (!dayTimeTable.containsKey(teacherName)) { teachersTimeTable = new LinkedHashMap<>(); dayTimeTable.put(teacherName, teachersTimeTable); } else {/*w w w.j av a2 s .c o m*/ teachersTimeTable = dayTimeTable.get(teacherName); } return teachersTimeTable; }
From source file:ubic.gemma.core.visualization.ExperimentalDesignVisualizationServiceImpl.java
/** * See bug 3775. For experiments which have more than one bioassay dimension, we typically have to "extend" the * layout to include more bioassays. Because the ordering is defined by the factor values associated with the * underlying biomaterials, this is going to be okay. *//* w w w .j a va2 s . co m*/ private LinkedHashMap<BioAssayValueObject, LinkedHashMap<ExperimentalFactor, Double>> extendLayout( DoubleVectorValueObject vec, Long eeId) { BioAssayDimensionValueObject bioAssayDimension = this.getBioAssayDimensionForVector(vec); ExpressionExperimentValueObject ee = vec.getExpressionExperiment(); ExpressionExperiment actualEe = this.getExperimentForVector(vec, ee); LinkedHashMap<BioAssayValueObject, LinkedHashMap<ExperimentalFactor, Double>> extension = this .getExperimentalDesignLayout(actualEe, expressionExperimentService.getBioAssayDimensions(actualEe)); for (BioAssayValueObject vbaVo : bioAssayDimension.getBioAssays()) { assert extension.containsKey(vbaVo); } for (BioAssayValueObject vbaVo : vec.getBioAssays()) { assert extension.containsKey(vbaVo); } cachedLayouts.get(eeId).putAll(extension); return cachedLayouts.get(eeId); }
From source file:org.zlwima.emurgency.staticclientapp.websockets.WebSocketHandshake.java
public byte[] getHandshake() { String path = url.getPath();/* w ww .j a v a 2 s . c o m*/ String host = url.getHost(); if (url.getPort() != -1) { host += ":" + url.getPort(); } LinkedHashMap<String, String> header = new LinkedHashMap<String, String>(); header.put("Host", host); header.put("Upgrade", "websocket"); header.put("Connection", "Upgrade"); header.put("Sec-WebSocket-Version", String.valueOf(WebSocket.getVersion())); header.put("Sec-WebSocket-Key", this.nonce); if (this.protocol != null) { header.put("Sec-WebSocket-Protocol", this.protocol); } if (this.extraHeaders != null) { for (String fieldName : this.extraHeaders.keySet()) { // Only checks for Field names with the exact same text, // but according to RFC 2616 (HTTP) field names are case-insensitive. if (!header.containsKey(fieldName)) { header.put(fieldName, this.extraHeaders.get(fieldName)); } } } String handshake = "GET " + path + " HTTP/1.1\r\n"; handshake += this.generateHeader(header); handshake += "\r\n"; byte[] handshakeBytes = new byte[handshake.getBytes().length]; System.arraycopy(handshake.getBytes(), 0, handshakeBytes, 0, handshake.getBytes().length); return handshakeBytes; }
From source file:com.epam.ta.reportportal.ws.converter.builders.UserResourceBuilder.java
private UserResourceBuilder addUser(User user, List<Project> projects) { if (user != null) { UserResource resource = getObject(); resource.setUserId(user.getLogin()); resource.setEmail(user.getEmail()); resource.setPhotoId(user.getPhotoId()); resource.setFullName(user.getFullName()); resource.setAccountType(user.getType().toString()); resource.setUserRole(user.getRole().toString()); resource.setLastlogin(user.getMetaInfo().getLastLogin()); resource.setIsLoaded(UserType.UPSA != user.getType()); if (projects.size() > 1) Collections.sort(projects, PROJECT_NAME_ALPHABET); LinkedHashMap<String, UserResource.AssignedProject> userProjects = new LinkedHashMap<>(projects.size()); for (Project project : projects) { UserResource.AssignedProject assignedProject = new UserResource.AssignedProject(); Project.UserConfig userConfig = project.getUsers().get(user.getId()); assignedProject.setProjectRole(userConfig.getProjectRole().name()); assignedProject.setProposedRole(userConfig.getProposedRole().name()); assignedProject.setEntryType(project.getConfiguration().getEntryType().name()); userProjects.put(project.getId(), assignedProject); }/*from w w w . j a va 2 s . co m*/ resource.setAssignedProjects(userProjects); if (userProjects.containsKey(user.getDefaultProject())) { resource.setDefaultProject(user.getDefaultProject()); } else { resource.setDefaultProject(personalProjectName(user.getId())); } } return this; }
From source file:org.fao.fenix.wds.web.rest.crowdprices.CrowdPricesDataRESTService.java
private LinkedHashMap<String, List<List<String>>> getCrowdPricesPoints(List<List<String>> table) { LinkedHashMap<String, List<List<String>>> markets = new LinkedHashMap<String, List<List<String>>>(); for (List<String> row : table) { String marketname = row.get(0); List<List<String>> rows = new ArrayList<List<String>>(); if (markets.containsKey(marketname)) { rows = markets.get(marketname); }/* w w w . ja v a 2s . co m*/ rows.add(row); markets.put(marketname, rows); } return markets; }
From source file:com.espertech.esper.pattern.EvalEveryDistinctStateExpireKeyNode.java
public final void evaluateTrue(MatchedEventMap matchEvent, EvalStateNode fromNode, boolean isQuitted) { // determine if this evaluation has been seen before from the same node Object matchEventKey = PatternExpressionUtil.getKeys(matchEvent, everyNode); boolean haveSeenThis = false; LinkedHashMap<Object, Long> keysFromNode = spawnedNodes.get(fromNode); if (keysFromNode != null) { // Clean out old keys Iterator<Map.Entry<Object, Long>> it = keysFromNode.entrySet().iterator(); long currentTime = everyNode.getContext().getPatternContext().getTimeProvider().getTime(); for (; it.hasNext();) { Map.Entry<Object, Long> entry = it.next(); if (currentTime - entry.getValue() >= everyNode.getFactoryNode().getMsecToExpire()) { it.remove();/*from www . ja v a2 s. co m*/ } else { break; } } if (keysFromNode.containsKey(matchEventKey)) { haveSeenThis = true; } else { keysFromNode.put(matchEventKey, currentTime); } } if (isQuitted) { spawnedNodes.remove(fromNode); } // See explanation in EvalFilterStateNode for the type check if (fromNode.isFilterStateNode()) { // We do not need to newState new listeners here, since the filter state node below this node did not quit } else { // Spawn all nodes below this EVERY node // During the start of a child we need to use the temporary evaluator to catch any event created during a start // Such events can be raised when the "not" operator is used. EvalEveryStateSpawnEvaluator spawnEvaluator = new EvalEveryStateSpawnEvaluator( everyNode.getContext().getPatternContext().getStatementName()); EvalStateNode spawned = everyNode.getChildNode().newState(spawnEvaluator, null, 0L); spawned.start(beginState); // If the whole spawned expression already turned true, quit it again if (spawnEvaluator.isEvaluatedTrue()) { spawned.quit(); } else { LinkedHashMap<Object, Long> keyset = new LinkedHashMap<Object, Long>(); if (keysFromNode != null) { keyset.putAll(keysFromNode); } spawnedNodes.put(spawned, keyset); spawned.setParentEvaluator(this); } } if (!haveSeenThis) { this.getParentEvaluator().evaluateTrue(matchEvent, this, false); } }