List of usage examples for java.util Map remove
V remove(Object key);
From source file:com.wavemaker.runtime.server.ServerUtils.java
/** * Get the method parameter from the parameters map; as a side effect, remove that entry. * // ww w .java2s . c o m * @param params The map - this is side-effected, and the method entry is removed. * @return The method to invoke. */ public static String getMethod(Map<String, Object[]> params) { String method = null; if (params.containsKey(ServerConstants.METHOD)) { Object methodO = params.get(ServerConstants.METHOD); if (methodO instanceof String[]) { if (1 == ((String[]) methodO).length) { method = ((String[]) methodO)[0]; } } } if (method == null) { throw new WMRuntimeException(MessageResource.SERVER_NOMETHODORID, params); } params.remove(ServerConstants.METHOD); return method; }
From source file:com.hp.octane.integrations.uft.UftTestDispatchUtils.java
/** * Go over discovered and octane data tables * 1.if DT doesn't exist on octane - this is new DT * 2. all DTs that are found in Octane but not discovered - delete those DTs from server */// www . jav a2 s .c o m private static boolean matchDiscoveryDataTablesResultsWithOctaneForFullSync(EntitiesService entitiesService, UftTestDiscoveryResult discoveryResult) { boolean hasDiff = false; Map<String, Entity> octaneDataTablesMap = getDataTablesFromServer(entitiesService, Long.parseLong(discoveryResult.getWorkspaceId()), Long.parseLong(discoveryResult.getScmRepositoryId()), null); for (ScmResourceFile dataTable : discoveryResult.getAllScmResourceFiles()) { Entity octaneDataTable = octaneDataTablesMap.remove(dataTable.getRelativePath()); if (octaneDataTable != null) {//found in Octnat - skip dataTable.setOctaneStatus(OctaneStatus.NONE); hasDiff = true; } } //go over DT that exist in Octane but not discovered for (Entity octaneDataTable : octaneDataTablesMap.values()) { hasDiff = true; ScmResourceFile dt = new ScmResourceFile(); dt.setId(octaneDataTable.getId()); dt.setName(octaneDataTable.getName()); dt.setRelativePath(octaneDataTable.getStringValue(EntityConstants.ScmResourceFile.RELATIVE_PATH_FIELD)); dt.setOctaneStatus(OctaneStatus.DELETED); discoveryResult.getAllScmResourceFiles().add(dt); } return hasDiff; }
From source file:br.com.autonomiccs.cloudTraces.main.CloudTracesSimulator.java
/** * For every time that is sent by parameter, we return the list of {@link VirtualMachine} from the map of virtual machines by time. * It removes the entry mapped that is returned. *//*from www .j a v a2 s . co m*/ private static List<VirtualMachine> getVirtualMachinesWithTaskExecutionAtTime( Map<Integer, List<VirtualMachine>> mapVirtualMachinesTaskExecutionByTime, List<Integer> times) { List<VirtualMachine> virtualMachines = new ArrayList<>(); for (Integer time : times) { List<VirtualMachine> virtualMachine = mapVirtualMachinesTaskExecutionByTime.remove(time); virtualMachines.addAll(virtualMachine); } return virtualMachines; }
From source file:com.liferay.knowledgebase.admin.util.KBStructureContentUtil.java
public static String updateKBStructureFields(String localizedLanguageId, List<KBStructureField> kbStructureFields, String content) throws PortalException, SystemException { Document document = null;//from ww w. j a va2 s .c o m try { document = SAXReaderUtil.read(content); } catch (DocumentException de) { throw new PortalException(de); } Element rootElement = document.getRootElement(); Element oldKBStructureContentElement = (Element) rootElement .selectSingleNode("kb-structure-content[@language-id='" + localizedLanguageId + "']"); if (oldKBStructureContentElement != null) { oldKBStructureContentElement.detach(); } Element newKBStructureContentElement = rootElement.addElement("kb-structure-content"); newKBStructureContentElement.addAttribute("language-id", localizedLanguageId); for (KBStructureField kbStructureField : kbStructureFields) { String kbStructureFieldId = kbStructureField.getKbStructureFieldId(); String kbStructureFieldName = StringEscapeUtils.escapeXml(kbStructureField.getName()); String kbStructureFieldLabel = StringEscapeUtils.escapeXml(kbStructureField.getLabel()); String kbStructureFieldType = StringEscapeUtils.escapeXml(kbStructureField.getType()); if (Validator.isNull(kbStructureFieldId)) { kbStructureFieldId = String.valueOf(CounterLocalServiceUtil.increment()); } Element kbStructureFieldElement = newKBStructureContentElement.addElement("kb-structure-field"); kbStructureFieldElement.addAttribute("kb-structure-field-id", kbStructureFieldId); kbStructureFieldElement.addAttribute("name", kbStructureFieldName); kbStructureFieldElement.addAttribute("label", kbStructureFieldLabel); kbStructureFieldElement.addAttribute("type", kbStructureFieldType); List<KBStructureOption> kbStructureOptions = kbStructureField.getKbStructureOptions(); for (KBStructureOption kbStructureOption : kbStructureOptions) { String kbStructureOptionId = kbStructureOption.getKbStructureOptionId(); String kbStructureOptionLabel = StringEscapeUtils.escapeXml(kbStructureOption.getLabel()); String kbStructureOptionValue = StringEscapeUtils.escapeXml(kbStructureOption.getValue()); if (Validator.isNull(kbStructureOptionId)) { kbStructureOptionId = String.valueOf(CounterLocalServiceUtil.increment()); } Element kbStructureOptionElement = kbStructureFieldElement.addElement("kb-structure-option"); kbStructureOptionElement.addAttribute("kb-structure-option-id", kbStructureOptionId); kbStructureOptionElement.addAttribute("label", kbStructureOptionLabel); kbStructureOptionElement.addAttribute("value", kbStructureOptionValue); } } Map<String, Element> elements = new TreeMap<String, Element>(); for (Element element : rootElement.elements()) { String languageId = element.attributeValue("language-id"); elements.put(languageId, (Element) element.detach()); } String defaultLanguageId = rootElement.attributeValue("default-language-id"); Element defaultKBStructureContentElement = elements.remove(defaultLanguageId); rootElement.add(defaultKBStructureContentElement); if (!localizedLanguageId.equals(defaultLanguageId)) { for (Map.Entry<String, Element> entry : elements.entrySet()) { rootElement.add(entry.getValue()); } } else { updateLocalizations(rootElement, defaultKBStructureContentElement, elements); } try { return document.formattedString(); } catch (IOException ioe) { return document.asXML(); } }
From source file:jp.terasoluna.fw.util.ConvertUtil.java
/** * ?????????//from w ww.j av a 2s .c o m * <p> * ?????{@link #CLASS_FIELDNAME}???? * ??????????? * ????????????????1? * ?????????? * </p> * <ul> * <li><code>null</code>?? - ??????????</li> * <li><code>Object[]</code>?? - ??????</li> * <li><code>Collection</code>?? - ?????</li> * <li>???? - ?1????????</li> * </ul> * @param obj * @return ???? * @throws IllegalArgumentException ????????? */ @SuppressWarnings("unchecked") public static List<Map<String, Object>> toListOfMap(Object obj) throws IllegalArgumentException { Object[] array = ConvertUtil.toArray(obj); List<Map<String, Object>> result = new ArrayList<Map<String, Object>>(); for (Object object : array) { Map<String, Object> map = null; if (object instanceof Map) { map = (Map<String, Object>) object; } else { try { map = PropertyUtils.describe(object); } catch (IllegalAccessException e) { throw new IllegalArgumentException(e); } catch (InvocationTargetException e) { throw new IllegalArgumentException(e); } catch (NoSuchMethodException e) { throw new IllegalArgumentException(e); } } map.remove(CLASS_FIELDNAME); result.add(map); } return result; }
From source file:com.clican.pluto.common.control.Control.java
public static Control decodeProperty(String description) { Map<String, String> properties = new HashMap<String, String>(); for (String s : description.split(";")) { String[] entry = s.split("="); if (entry.length == 1) { properties.put(entry[0], null); } else {/*from w w w . j ava 2 s. c o m*/ properties.put(entry[0], entry[1]); } } Control control = null; if (properties.get("class") != null) { try { control = (Control) Class.forName(properties.get("class")).newInstance(); } catch (Exception e) { throw new PlutoException(e); } } else { throw new PlutoException("Cannot get class property from dymanic property's control annotation."); } properties.remove("class"); for (String key : properties.keySet()) { String value = properties.get(key); if (org.apache.commons.lang.StringUtils.isEmpty(value)) { continue; } try { org.apache.commons.beanutils.BeanUtils.setProperty(control, key, value); } catch (Exception e) { List<String> listValue = StringUtils.getListFromSymbolSplitString(value, ","); try { org.apache.commons.beanutils.BeanUtils.setProperty(control, key, listValue); } catch (Exception ex) { throw new PlutoException(ex); } } } return control; }
From source file:com.tilab.ca.sse.core.util.SSEUtils.java
public static Map sortIntegersMap(Map passedMap) { LOG.debug("[sortHashMapIntegers] - BEGIN"); List mapKeys = new ArrayList(passedMap.keySet()); List mapValues = new ArrayList(passedMap.values()); Collections.sort(mapValues);/*www .ja v a2s .c o m*/ Collections.reverse(mapValues); Collections.sort(mapKeys); Map sortedMap = new LinkedHashMap(); Iterator valueIt = mapValues.iterator(); while (valueIt.hasNext()) { Object val = valueIt.next(); Iterator keyIt = mapKeys.iterator(); while (keyIt.hasNext()) { Object key = keyIt.next(); String comp1 = passedMap.get(key).toString(); String comp2 = val.toString(); if (comp1.equals(comp2)) { passedMap.remove(key); mapKeys.remove(key); sortedMap.put((Integer) key, (Integer) val); break; } } } LOG.debug("[sortHashMapIntegers] - END"); return sortedMap; }
From source file:io.fabric8.maven.core.util.KubernetesResourceUtil.java
public static Map<String, String> removeVersionSelector(Map<String, String> selector) { Map<String, String> answer = new HashMap<>(selector); answer.remove("version"); return answer; }
From source file:io.github.retz.scheduler.Launcher.java
private static void maybeRequeueRunningJobs(String master, String frameworkId, List<Job> running) { LOG.info("{} jobs found in DB 'STARTING' or 'STARTED' state. Requeuing...", running.size()); int offset = 0; int limit = 128; Map<String, Job> runningMap = running.stream().collect(Collectors.toMap(job -> job.taskId(), job -> job)); List<Job> recoveredJobs = new LinkedList<>(); while (true) { try {/*from ww w. ja v a2 s. com*/ List<Map<String, Object>> tasks = MesosHTTPFetcher.fetchTasks(master, frameworkId, offset, limit); if (tasks.isEmpty()) { break; } for (Map<String, Object> task : tasks) { String state = (String) task.get("state"); // Get TaskId String taskId = (String) task.get("id"); if (runningMap.containsKey(taskId)) { Job job = runningMap.remove(taskId); recoveredJobs.add(JobQueue.updateJobStatus(job, state)); } else { LOG.warn("Unknown job!"); } } offset = offset + tasks.size(); } catch (MalformedURLException e) { LOG.error(e.toString()); throw new RuntimeException(e.toString()); } } Database.getInstance().updateJobs(recoveredJobs); LOG.info("{} jobs rescheduled, {} jobs didn't need change.", recoveredJobs.size(), runningMap.size()); }
From source file:bluej.collect.DataCollectorImpl.java
public static void removeClass(Package pkg, final File sourceFile) { final ProjectDetails projDetails = new ProjectDetails(pkg.getProject()); MultipartEntity mpe = new MultipartEntity(); mpe.addPart("source_histories[][source_history_type]", CollectUtility.toBody("file_delete")); mpe.addPart("source_histories[][name]", CollectUtility.toBodyLocal(projDetails, sourceFile)); submitEvent(pkg.getProject(), pkg, EventName.DELETE, new PlainEvent(mpe) { @Override// www . jav a 2 s . c om public MultipartEntity makeData(int sequenceNum, Map<FileKey, List<String>> fileVersions) { // We should remove the old source from the fileVersions hash: fileVersions.remove(new FileKey(projDetails, CollectUtility.toPath(projDetails, sourceFile))); return super.makeData(sequenceNum, fileVersions); } }); }