List of usage examples for java.util Map clear
void clear();
From source file:com.glaf.chart.bean.ChartDataManager.java
protected void fetchData(Chart chart, TableModel rowMode, String querySQL, Map<String, Object> paramMap, String actorId) {/*from w w w . j a v a 2 s .com*/ if (StringUtils.isNotEmpty(querySQL)) { paramMap.put("curr_yyyymm", Integer.parseInt(SystemConfig.getCurrentYYYYMM())); paramMap.put("curr_yyyymmdd", Integer.parseInt(SystemConfig.getCurrentYYYYMMDD())); querySQL = QueryUtils.replaceSQLVars(querySQL); // querySQL = QueryUtils.replaceSQLParas(querySQL, paramMap); logger.debug("paramMap=" + paramMap); logger.debug("querySQL=" + querySQL); rowMode.setSql(querySQL); DatabaseConnectionConfig config = new DatabaseConnectionConfig(); Long databaseId = chart.getDatabaseId(); LoginContext loginContext = IdentityFactory.getLoginContext(actorId); Database currentDB = config.getDatabase(loginContext, databaseId); String systemName = Environment.getCurrentSystemName(); try { if (currentDB != null) { Environment.setCurrentSystemName(currentDB.getName()); } List<Map<String, Object>> rows = getTablePageService().getListData(querySQL, paramMap); if (rows != null && !rows.isEmpty()) { logger.debug(rows); int index = 0; Map<String, Object> dataMap = new java.util.HashMap<String, Object>(); for (Map<String, Object> rowMap : rows) { dataMap.clear(); Set<Entry<String, Object>> entrySet = rowMap.entrySet(); for (Entry<String, Object> entry : entrySet) { String key = entry.getKey(); Object value = entry.getValue(); dataMap.put(key, value); dataMap.put(key.toLowerCase(), value); } if ("pie".equals(chart.getChartType())) { index++; ColumnModel cell = new ColumnModel(); cell.setColumnName("col_" + index); cell.setSeries(MapUtils.getString(dataMap, "series")); cell.setDoubleValue(MapUtils.getDouble(dataMap, "doublevalue")); chart.addCellData(cell); } else { index++; ColumnModel cell = new ColumnModel(); cell.setColumnName("col_" + index); cell.setCategory(MapUtils.getString(dataMap, "category")); cell.setSeries(MapUtils.getString(dataMap, "series")); cell.setDoubleValue(MapUtils.getDouble(dataMap, "doublevalue")); chart.addCellData(cell); } } logger.debug("rows size:" + chart.getColumns().size()); } } catch (Exception ex) { ex.printStackTrace(); logger.error(ex); } finally { Environment.setCurrentSystemName(systemName); } } }
From source file:com.hp.mqm.atrf.alm.services.AlmWrapperService.java
private boolean clearMapIfSizeIsExceed(Map map, int maxSize) { if (map.size() > maxSize) { map.clear(); return true; }/*from www . j a v a 2 s. co m*/ return false; }
From source file:com.flexive.war.javascript.tree.StructureTreeWriter.java
/** * Render an assigned group, included assigned subgroups and properties. * * @param writer the tree node writer * @param nodeProperties an existing hashmap for storing additional JS properties (cleared on entry) * @param group the group to be rendered * @param isShowLabels true if labels should be shown, false if the Alias should be shown * @throws IOException if the tree could not be written *//*from ww w . j a v a 2 s .co m*/ private void writeGroupAssignment(TreeNodeWriter writer, Map<String, Object> nodeProperties, FxGroupAssignment group, boolean isShowLabels) throws IOException { nodeProperties.clear(); nodeProperties.put("alias", group.getAlias()); nodeProperties.put("assignmentId", String.valueOf(group.getId())); nodeProperties.put("nodeType", NODE_TYPE_GROUP); writer.startNode(new Node(String.valueOf(group.getId()), isShowLabels ? group.getDisplayName() : (String) nodeProperties.get("alias"), DOC_TYPE_GROUP, nodeProperties)); writer.startChildren(); List<FxAssignment> children = new ArrayList<FxAssignment>( group.getAssignedGroups().size() + group.getAssignedProperties().size()); children.addAll(group.getAssignedGroups()); children.addAll(group.getAssignedProperties()); Collections.sort(children, new FxSharedUtils.AssignmentPositionSorter()); for (FxAssignment child : children) { if (child instanceof FxGroupAssignment) writeGroupAssignment(writer, nodeProperties, (FxGroupAssignment) child, isShowLabels); else writePropertyAssignment(writer, nodeProperties, (FxPropertyAssignment) child, isShowLabels); } // add assigned properties writer.closeChildren(); writer.closeNode(); }
From source file:com.qualogy.qafe.core.datastore.ApplicationLocalStore.java
public void deleteAll(String uuid) { Map<String, Object> localStoreMap = store.get(uuid); debug("delelteAll: uuid=" + uuid + " - localStoreMap=" + localStoreMap); if (localStoreMap != null) { localStoreMap.clear(); // Make changes affected to the store when using distributed cache in Google AppEngine store(uuid, localStoreMap);// w w w . j ava2 s. co m } }
From source file:com.bstek.bdf2.core.orm.transaction.JdbcTransactionManager.java
private void clean() { Map<String, Session> sessionMap = ContextHolder.getHibernateSessionMap(); if (sessionMap == null) { return;// www . j a v a2 s .c om } for (Session session : sessionMap.values()) { if (session != null && session.isOpen()) { session.flush(); session.close(); session = null; } } sessionMap.clear(); }
From source file:de.hybris.platform.catalog.job.sort.impl.ComposedTypeSorter.java
/** * @param originalComposedTypeSet//www . j a v a2 s .c om * unsorted set of composed types from the catalog manager * @return a list of the same composed types, an element of this list depends on another element of the same list * with a lower index (or not) */ @Override public List<ComposedTypeModel> sort(final Collection<ComposedTypeModel> originalComposedTypeSet) { final List<ComposedTypeModel> returnlist = new ArrayList<ComposedTypeModel>(); final Set<ComposedTypeModel> origSet = new HashSet<ComposedTypeModel>(originalComposedTypeSet); //clone the set, we remove elements from it final Map<ComposedTypeModel, Integer> countMap = new HashMap<ComposedTypeModel, Integer>(); final Map<ComposedTypeModel, ComposedTypeNode> ct_ctn_map = new HashMap<ComposedTypeModel, ComposedTypeNode>(); while (true) { countMap.clear(); ct_ctn_map.clear(); for (final ComposedTypeModel ct : origSet) { ct_ctn_map.put(ct, new ComposedTypeNode(ct)); countMap.put(ct, Integer.valueOf(0)); } createNodes(origSet, ct_ctn_map, countMap); try { final List<ComposedTypeNode> sortedList = RequirementSolver.solve(ct_ctn_map.values()); for (final ComposedTypeNode ctn : sortedList) { returnlist.add(ctn.getComposedType()); } return returnlist; } catch (final RequirementSolverException e) { final ComposedTypeModel firstInList = getComposedTypewithHighestCount(countMap); returnlist.add(firstInList); origSet.remove(firstInList); } } }
From source file:com.facebook.stats.mx.TestStats.java
@Test(groups = "fast") public void testDynamicCounters() throws Exception { LongWrapper longValue = new LongWrapper(1); final String name = "testCounter"; Assert.assertTrue(stats.addDynamicCounter(name, longValue)); final Map<String, Long> exported = new HashMap<>(); stats.exportCounters(exported);/*from www . ja va 2s . c o m*/ Assert.assertEquals(exported.get(name), Long.valueOf(1)); // Test that the value gets exported longValue.setValue(123); exported.clear(); stats.exportCounters(exported); Assert.assertEquals(exported.get(name), Long.valueOf(123)); // Test that a duplicate set fails to override the previous value LongWrapper duplicateValue = new LongWrapper(24); Assert.assertFalse(stats.addDynamicCounter(name, duplicateValue)); exported.clear(); stats.exportCounters(exported); Assert.assertEquals(exported.get(name), Long.valueOf(123)); // Test unset Assert.assertTrue(stats.removeDynamicCounter(name)); exported.clear(); stats.exportCounters(exported); Assert.assertFalse(exported.containsKey(name)); // Test unset for non-existent key Assert.assertFalse(stats.removeDynamicCounter(name)); }
From source file:com.flexive.war.javascript.tree.StructureTreeWriter.java
/** * Render a type including its derived types, assigned groups and properties. * * @param writer the tree node writer * @param type the type to be rendered * @param isViewFlat if the tree is rendered flat or hierarchically * @param nodeProperties an existing hashmap for storing additional JS properties (cleared on entry) * @param isShowLabels true if labels should be shown, false if the Alias should be shown * @throws IOException if the tree could not be written *//*from w w w . j a v a 2 s . c o m*/ private void writeType(TreeNodeWriter writer, Map<String, Object> nodeProperties, FxType type, boolean isViewFlat, boolean isShowLabels) throws IOException { nodeProperties.clear(); nodeProperties.put("typeId", String.valueOf(type.getId())); final String docType = type.isRelation() ? DOC_TYPE_TYPE_RELATION : type.getIcon() != null && !type.getIcon().isEmpty() ? DOC_TYPE_TYPEID + type.getId() : DOC_TYPE_TYPE; nodeProperties.put("alias", type.getName().toUpperCase()); nodeProperties.put("nodeType", type.isRelation() ? NODE_TYPE_TYPE_RELATION : NODE_TYPE_TYPE); writer.startNode(new Node(String.valueOf(type.getId()), isShowLabels ? type.getDisplayName() : (String) nodeProperties.get("alias"), docType, nodeProperties)); writer.startChildren(); // write derived types //if the view is not flat, add derived types as child nodes if (!isViewFlat) { List<FxType> children = new ArrayList<FxType>(); // addAll() is used as type.getDerivedTypes returns an unmodifiable list children.addAll(type.getDerivedTypes()); // if show labels is true, order types by label if (isShowLabels) Collections.sort(children, new FxSharedUtils.SelectableObjectWithLabelSorter()); for (FxType child : children) { writeType(writer, nodeProperties, child, isViewFlat, isShowLabels); } } //sort group and property assignments List<FxAssignment> assignments = new ArrayList<FxAssignment>(); assignments.addAll(type.getAssignedGroups()); assignments.addAll(type.getAssignedProperties()); Collections.sort(assignments, new FxSharedUtils.AssignmentPositionSorter()); //write group and property assignments for (FxAssignment a : assignments) { if (a instanceof FxPropertyAssignment && !a.isSystemInternal()) writePropertyAssignment(writer, nodeProperties, (FxPropertyAssignment) a, isShowLabels); else if (a instanceof FxGroupAssignment) writeGroupAssignment(writer, nodeProperties, (FxGroupAssignment) a, isShowLabels); } writer.closeChildren(); writer.closeNode(); }
From source file:com.xyxy.platform.modules.core.web.ServletsTest.java
@Test public void encodeParameterStringWithPrefix() { Map<String, Object> params = Maps.newLinkedHashMap(); params.put("name", "foo"); params.put("age", "1"); String queryString = Servlets.encodeParameterStringWithPrefix(params, "search_"); assertThat(queryString).isEqualTo("search_name=foo&search_age=1"); // data type is not String params.clear(); params.put("name", "foo"); params.put("age", 1); queryString = Servlets.encodeParameterStringWithPrefix(params, "search_"); assertThat(queryString).isEqualTo("search_name=foo&search_age=1"); // prefix is blank or null queryString = Servlets.encodeParameterStringWithPrefix(params, null); assertThat(queryString).isEqualTo("name=foo&age=1"); queryString = Servlets.encodeParameterStringWithPrefix(params, ""); assertThat(queryString).isEqualTo("name=foo&age=1"); // map is empty or null queryString = Servlets.encodeParameterStringWithPrefix(null, "search_"); assertThat(queryString).isEmpty();// w w w . java 2 s. c om params.clear(); queryString = Servlets.encodeParameterStringWithPrefix(params, "search_"); assertThat(queryString).isEmpty(); }
From source file:com.google.gdt.eclipse.designer.hosted.tdz.HostedModeSupport.java
public void dispose() { m_browserShell.dispose();/*from w w w .jav a2s. c om*/ // dispose if initialized (may be not if Module loading failed) if (m_moduleSpaceHost != null) { m_moduleSpaceHost.getModuleSpace().dispose(); } // dispose for project; if the same project used in another editor // it would be added again by activating the project. m_gwtSharedClassLoader.dispose(m_moduleDescription); m_logSupport.dispose(); m_moduleSpaceHost = null; // clear static caches try { Class<?> clazz = m_gwtSharedClassLoader.loadClass("com.google.gwt.i18n.rebind.ClearStaticData"); Method method = clazz.getDeclaredMethod("clear"); method.setAccessible(true); method.invoke(null); } catch (Throwable e) { } try { Class<?> clazz = m_gwtSharedClassLoader .loadClass("com.google.gwt.uibinder.rebind.model.OwnerFieldClass"); Field mapField = clazz.getDeclaredField("FIELD_CLASSES"); mapField.setAccessible(true); Map<?, ?> map = (Map<?, ?>) mapField.get(null); map.clear(); } catch (Throwable e) { } }