List of usage examples for java.util Map clear
void clear();
From source file:hoot.services.controllers.osm.OSMTestUtils.java
static Set<Long> createTestRelations(long changesetId, Set<Long> nodeIds, Set<Long> wayIds) throws Exception { Long[] nodeIdsArr = nodeIds.toArray(new Long[nodeIds.size()]); Long[] wayIdsArr = wayIds.toArray(new Long[wayIds.size()]); List<RelationMember> members = new ArrayList<>(); members.add(new RelationMember(nodeIdsArr[0], ElementType.Node, "role1")); members.add(new RelationMember(wayIdsArr[1], ElementType.Way, "role3")); members.add(new RelationMember(wayIdsArr[0], ElementType.Way, "role2")); members.add(new RelationMember(nodeIdsArr[2], ElementType.Node)); Map<String, String> tags = new HashMap<>(); tags.put("key 1", "val 1"); long firstRelationId = insertNewRelation(changesetId, getMapId(), members, tags); Set<Long> relationIds = new LinkedHashSet<>(); relationIds.add(firstRelationId);/*w w w.j a v a2 s .c om*/ tags.clear(); members.clear(); tags.put("key 2", "val 2"); tags.put("key 3", "val 3"); members.add(new RelationMember(nodeIdsArr[4], ElementType.Node, "role1")); members.add(new RelationMember(firstRelationId, ElementType.Relation, "role1")); relationIds.add(insertNewRelation(changesetId, getMapId(), members, tags)); tags.clear(); members.clear(); tags.put("key 4", "val 4"); members.add(new RelationMember(wayIdsArr[1], ElementType.Way)); relationIds.add(insertNewRelation(changesetId, getMapId(), members, tags)); tags.clear(); members.clear(); members.add(new RelationMember(nodeIdsArr[2], ElementType.Node, "role1")); relationIds.add(insertNewRelation(changesetId, getMapId(), members, null)); members.clear(); return relationIds; }
From source file:com.esd.ps.LoginController.java
/** * ??//from ww w . ja va 2s . c om * * @param username * @return */ public Map<String, Object> checkLoginName(String username) { Map<String, Object> map = new HashMap<String, Object>(); if (!StringUtils.isEmpty(username)) { user user = userService.getAllUsersByUserName(username); if (user == null) { map.clear(); map.put(Constants.MESSAGE, MSG_USER_NOT_EXIST); map.put(Constants.REPLAY, Constants.ZERO); return map; } if (user.getUserStatus() == false) { map.clear(); map.put(Constants.MESSAGE, MSG_USER_STOP); map.put(Constants.REPLAY, Constants.ZERO); return map; } map.clear(); map.put(Constants.REPLAY, Constants.ONE); } return map; }
From source file:com.tonbeller.jpivot.mondrian.script.ScriptableMondrianDrillThroughTableModel.java
/** * execute sql query/*from w ww . j a va 2 s.c om*/ * @throws Exception */ private void executeQuery() { Connection con = null; try { InputStream catExtIs = ScriptableMondrianDrillThroughTableModel.class.getClassLoader() .getResourceAsStream("/" + catalogExtension); if (catExtIs != null) { Digester catExtDigester = new Digester(); catExtDigester.push(this); catExtDigester.addSetProperties("extension"); catExtDigester.addObjectCreate("extension/script", "com.tonbeller.jpivot.mondrian.script.ScriptColumn"); catExtDigester.addSetProperties("extension/script"); catExtDigester.addSetNext("extension/script", "addScript"); catExtDigester.parse(catExtIs); URL scriptsBaseURL = Thread.currentThread().getContextClassLoader().getResource(scriptRootUrl); scriptEngine = new GroovyScriptEngine(new URL[] { scriptsBaseURL }); } con = getConnection(); Statement s = con.createStatement(); s.setMaxRows(maxResults); ResultSet rs = s.executeQuery(sql); ResultSetMetaData md = rs.getMetaData(); int numCols = md.getColumnCount(); List columnTitlesList = new ArrayList(); // set column headings for (int i = 0; i < numCols; i++) { // columns are 1 based columnTitlesList.add(i, md.getColumnName(i + 1)); } // loop on script columns for (ListIterator sIt = scripts.listIterator(); sIt.hasNext();) { final ScriptColumn sc = (ScriptColumn) sIt.next(); columnTitlesList.add(sc.getPosition() - 1, sc.getTitle()); } columnTitles = (String[]) columnTitlesList.toArray(new String[0]); // loop through rows List tempRows = new ArrayList(); Map scriptInput = new HashMap(); Binding binding = new Binding(); while (rs.next()) { List rowList = new ArrayList(); scriptInput.clear(); // loop on columns, 1 based for (int i = 0; i < numCols; i++) { rowList.add(i, rs.getObject(i + 1)); scriptInput.put(columnTitles[i], rs.getObject(i + 1)); } binding.setVariable("input", scriptInput); // loop on script columns for (ListIterator sIt = scripts.listIterator(); sIt.hasNext();) { final ScriptColumn sc = (ScriptColumn) sIt.next(); scriptEngine.run(sc.getFile(), binding); final Object output = binding.getVariable("output"); if (output instanceof Map) { Map outMap = (Map) output; rowList.add(sc.getPosition() - 1, new DefaultCell((String) outMap.get("URL"), (String) outMap.get("Value"))); } else if (output instanceof String) { rowList.add(sc.getPosition() - 1, (String) output); } else { throw new Exception("Unknown groovy script return type (not a Map nor String)."); } } tempRows.add(new DefaultTableRow(rowList.toArray())); } rs.close(); rows = (TableRow[]) tempRows.toArray(new TableRow[0]); } catch (Exception e) { e.printStackTrace(); logger.error("?", e); // problem occured, set table model to zero size rows = new TableRow[1]; columnTitles = new String[1]; columnTitles[0] = "An error occured"; Object[] row = new Object[1]; row[0] = e.toString(); rows[0] = new DefaultTableRow(row); ready = false; return; } finally { try { con.close(); } catch (Exception e1) { // ignore } } ready = true; }
From source file:co.cask.cdap.internal.app.services.http.handlers.PreferencesHttpHandlerTest.java
@Test public void testInstance() throws Exception { Map<String, String> propMap = Maps.newHashMap(); Assert.assertEquals(propMap, getProperty(getURI(), false, 200)); Assert.assertEquals(propMap, getProperty(getURI(), true, 200)); propMap.put("k1", "3@#3"); propMap.put("@#$#ljfds", "231@#$"); setProperty(getURI(), propMap, 200); Assert.assertEquals(propMap, getProperty(getURI(), false, 200)); Assert.assertEquals(propMap, getProperty(getURI(), true, 200)); propMap.clear(); deleteProperty(getURI(), 200);//w w w . j a va 2s . co m Assert.assertEquals(propMap, getProperty(getURI(), false, 200)); Assert.assertEquals(propMap, getProperty(getURI(), true, 200)); }
From source file:hoot.services.command.CommandRunner.java
public CommandResult exec(String[] pCmd, Map<String, String> pEnv, boolean useSysEnv, File dir, Writer pOut, Writer pErr) throws IOException, InterruptedException { int out = 0;/* w w w .j a v a 2s. co m*/ String pCmdString = ArrayUtils.toString(pCmd); ProcessBuilder builder = new ProcessBuilder(); builder.command(pCmd); Map<String, String> env = builder.environment(); if (!useSysEnv) env.clear(); for (String name : pEnv.keySet()) { env.put(name, pEnv.get(name)); } builder.directory(dir); logExec(pCmdString, env); StopWatch clock = new StopWatch(); clock.start(); try { process = builder.start(); out = handleProcess(process, pCmdString, pOut, pErr, _outputList, sig_interrupt); } finally { this.cleanUpProcess(); clock.stop(); if (_log.isInfoEnabled()) _log.info("'" + pCmdString + "' completed in " + clock.getTime() + " ms"); } if (sig_interrupt.getValue() == true) { out = -9999; } CommandResult result = new CommandResult(pCmdString, out, pOut.toString(), pErr.toString()); return result; }
From source file:hoot.services.command.CommandRunner.java
public CommandResult exec(String[] pCmd, Map<String, String> pEnv, boolean useSysEnv, Writer pOut, Writer pErr) throws IOException, InterruptedException { int out = 0;/*w w w .j a v a2 s .c o m*/ String pCmdString = ArrayUtils.toString(pCmd); ProcessBuilder builder = new ProcessBuilder(); builder.command(pCmd); Map<String, String> env = builder.environment(); if (!useSysEnv) env.clear(); for (String name : pEnv.keySet()) { env.put(name, pEnv.get(name)); } logExec(pCmdString, env); StopWatch clock = new StopWatch(); clock.start(); try { process = builder.start(); out = handleProcess(process, pCmdString, pOut, pErr, _outputList, sig_interrupt); } finally { this.cleanUpProcess(); clock.stop(); if (_log.isInfoEnabled()) _log.info("'" + pCmdString + "' completed in " + clock.getTime() + " ms"); } if (sig_interrupt.getValue() == true) { out = -9999; } CommandResult result = new CommandResult(pCmdString, out, pOut.toString(), pErr.toString()); return result; }
From source file:com.netsteadfast.greenstep.bsc.action.DegreeFeedbackProjectManagementAction.java
private void loadProjectData() throws ServiceException, Exception { this.transformFields2ValueObject(this.degreeFeedbackProject, new String[] { "oid" }); DefaultResult<DegreeFeedbackProjectVO> result = this.degreeFeedbackProjectService .findObjectByOid(degreeFeedbackProject); if (result.getValue() == null) { throw new ServiceException(result.getSystemMessage().getValue()); }/*www. j a va 2s . c om*/ this.degreeFeedbackProject = result.getValue(); Map<String, Object> paramMap = new HashMap<String, Object>(); paramMap.put("projectOid", this.degreeFeedbackProject.getOid()); Map<String, String> orderByMap = new HashMap<String, String>(); orderByMap.put("name", "asc"); this.degreeFeedbackItems = this.degreeFeedbackItemService.findListByParams(paramMap, null, orderByMap); orderByMap.clear(); orderByMap.put("value", "asc"); this.degreeFeedbackLevels = this.degreeFeedbackLevelService.findListByParams(paramMap, null, orderByMap); List<String> appendOwnerEmplOids = this.employeeService .findForAppendEmployeeOidsByDegreeFeedbackProjectOwner(this.degreeFeedbackProject.getOid()); List<String> appendRaterEmplOids = this.employeeService .findForAppendEmployeeOidsByDegreeFeedbackProjectRater(this.degreeFeedbackProject.getOid()); List<String> appendOwnerNames = this.employeeService.findForAppendNames(appendOwnerEmplOids); List<String> appendRaterNames = this.employeeService.findForAppendNames(appendRaterEmplOids); this.getFields().put("ownerOids", this.fillAppendContent(appendOwnerEmplOids)); this.getFields().put("raterOids", this.fillAppendContent(appendRaterEmplOids)); this.getFields().put("ownerNames", this.fillAppendContent(appendOwnerNames)); this.getFields().put("raterNames", this.fillAppendContent(appendRaterNames)); }
From source file:com.netsteadfast.greenstep.service.logic.impl.ApplicationSystemLogicServiceImpl.java
/** * TB_SYS //from w w w . jav a 2 s .c o m * * @param sys * @return * @throws ServiceException * @throws Exception */ @ServiceMethodAuthority(type = { ServiceMethodType.DELETE }) @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { RuntimeException.class, IOException.class, Exception.class }) @Override public DefaultResult<Boolean> delete(SysVO sys) throws ServiceException, Exception { if (sys == null || StringUtils.isBlank(sys.getOid())) { throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK)); } DefaultResult<SysVO> sysResult = this.sysService.findObjectByOid(sys); if (sysResult.getValue() == null) { throw new ServiceException(sysResult.getSystemMessage().getValue()); } sys = sysResult.getValue(); Map<String, Object> params = new HashMap<String, Object>(); params.put("progSystem", sys.getSysId()); if (this.sysProgService.countByParams(params) > 0) { throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.DATA_CANNOT_DELETE)); } params.clear(); params.put("system", sys.getSysId()); if (this.sysMsgNoticeConfigService.countByParams(params) > 0) { throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.DATA_CANNOT_DELETE)); } if (this.sysWsConfigService.countByParams(params) > 0) { throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.DATA_CANNOT_DELETE)); } if (this.sysBeanHelpService.countByParams(params) > 0) { throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.DATA_CANNOT_DELETE)); } if (this.sysCtxBeanService.countByParams(params) > 0) { throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.DATA_CANNOT_DELETE)); } if (this.sysTwitterService.countByParams(params) > 0) { throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.DATA_CANNOT_DELETE)); } if (this.sysExprJobService.countByParams(params) > 0) { throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.DATA_CANNOT_DELETE)); } // ?? tb_sys_multi_name params.clear(); params.put("sysId", sys.getSysId()); List<TbSysMultiName> sysMultiNames = this.sysMultiNameService.findListByParams(params); for (int i = 0; sysMultiNames != null && i < sysMultiNames.size(); i++) { this.sysMultiNameService.delete(sysMultiNames.get(i)); } return this.sysService.deleteObject(sys); }
From source file:ddf.catalog.impl.operations.OperationsStorageSupport.java
public void commitAndCleanup(StorageRequest storageRequest, Map<String, Map<String, Path>> tmpContentPaths) { if (storageRequest != null) { try {//ww w. j a v a 2 s . c om sourceOperations.getStorage().commit(storageRequest); } catch (StorageException e) { LOGGER.info("Unable to commit content changes for id: {}", storageRequest.getId(), e); rollbackStorage(storageRequest); } } tmpContentPaths.values().stream().flatMap(id -> id.values().stream()) .forEach(path -> FileUtils.deleteQuietly(path.toFile())); tmpContentPaths.clear(); }
From source file:com.alibaba.otter.common.push.datasource.media.MediaPushDataSourceHandler.java
@Override public boolean destory(Long pipelineId) { Map<DbMediaSource, DataSource> sources = dataSources.remove(pipelineId); if (sources != null) { for (DataSource dataSource : sources.values()) { try { MediaPushDataSource mediaPushDataSource = (MediaPushDataSource) dataSource; mediaPushDataSource.destory(); } catch (SQLException e) { log.error("ERROR ## close the datasource has an error", e); }//from w ww .j a va2 s .c o m } sources.clear(); } return true; }