List of usage examples for java.util Collections EMPTY_MAP
Map EMPTY_MAP
To view the source code for java.util Collections EMPTY_MAP.
Click Source Link
From source file:io.fabric8.forge.camel.commands.project.helper.CamelCommandsHelper.java
private static List<InputOptionByGroup> doCreateUIInputsForCamel(String camelComponentName, String uri, int maxOptionsPerPage, boolean consumerOnly, boolean producerOnly, CamelCatalog camelCatalog, InputComponentFactory componentFactory, ConverterFactory converterFactory, UIContext ui, boolean endpoint) throws Exception { List<InputOptionByGroup> answer = new ArrayList<>(); if (camelComponentName == null && uri != null) { camelComponentName = endpointComponentName(uri); }//from ww w . j av a2 s.c o m String json = camelCatalog.componentJSonSchema(camelComponentName); if (json == null) { throw new IllegalArgumentException( "Could not find catalog entry for component name: " + camelComponentName); } // is the component consumer or producer only, if so we do not need any kind of filter boolean componentConsumerOnly = CamelCatalogHelper.isComponentConsumerOnly(camelCatalog, camelComponentName); boolean componentProducerOnly = CamelCatalogHelper.isComponentProducerOnly(camelCatalog, camelComponentName); if (componentConsumerOnly || componentProducerOnly) { // reset the filters as the component can only be one of them anyway, so we should show all options consumerOnly = false; producerOnly = false; } List<Map<String, String>> data; if (endpoint) { data = JSonSchemaHelper.parseJsonSchema("properties", json, true); } else { data = JSonSchemaHelper.parseJsonSchema("componentProperties", json, true); } Map<String, String> currentValues = uri != null ? camelCatalog.endpointProperties(uri) : Collections.EMPTY_MAP; if (data != null) { // whether to prompt for all fields or not in the interactive mode boolean promptInInteractiveMode = false; if (ui instanceof ShellContext) { // we want to prompt if the command was executed without any arguments boolean params = ((ShellContext) ui).getCommandLine().hasParameters(); promptInInteractiveMode = !params; } List<InputComponent> inputs = new ArrayList<>(); InputOptionByGroup current = new InputOptionByGroup(); current.setGroup(null); current.setInputs(inputs); Set<String> namesAdded = new HashSet<>(); for (Map<String, String> propertyMap : data) { String name = propertyMap.get("name"); String kind = propertyMap.get("kind"); String group = propertyMap.get("group"); String label = propertyMap.get("label"); String type = propertyMap.get("type"); String javaType = propertyMap.get("javaType"); String deprecated = propertyMap.get("deprecated"); String required = propertyMap.get("required"); String currentValue = currentValues.get(name); String defaultValue = propertyMap.get("defaultValue"); String description = propertyMap.get("description"); String enums = propertyMap.get("enum"); String prefix = propertyMap.get("prefix"); String multiValue = propertyMap.get("multiValue"); if (current.getGroup() == null) { current.setGroup(group); } // its a new group if (group != null && !group.equals(current.getGroup())) { if (!current.getInputs().isEmpty()) { // this group is now done so add to answer answer.add(current); } // get ready for a new group inputs = new ArrayList<>(); current = new InputOptionByGroup(); current.setGroup(group); current.setInputs(inputs); } // filter out options in case we should only include consumers or producers only if (consumerOnly && label != null) { if (!label.contains("consumer")) { continue; } } if (producerOnly && label != null) { if (!label.contains("producer")) { continue; } } if (!Strings.isNullOrEmpty(name)) { Class<Object> inputClazz = CamelCommandsHelper.loadValidInputTypes(javaType, type); if (inputClazz != null) { if (namesAdded.add(name)) { // if its an enum and its optional then make sure there is a default value // if no default value exists then add none as the 1st choice default value // otherwise the GUI makes us force to select an option which is not what we want if (enums != null && (required == null || "false".equals(required))) { if (defaultValue == null || defaultValue.isEmpty()) { defaultValue = "none"; if (!enums.startsWith("none,")) { enums = "none," + enums; } } } boolean multi = "true".equals(multiValue); InputComponent input = createUIInput(ui.getProvider(), componentFactory, converterFactory, name, inputClazz, required, currentValue, defaultValue, enums, description, promptInInteractiveMode, multi, prefix); if (input != null) { inputs.add(input); // if we hit max options then create a new group if (inputs.size() == maxOptionsPerPage) { // this group is now done so add to answer if (!current.getInputs().isEmpty()) { answer.add(current); } // get ready for a new group inputs = new ArrayList<>(); current = new InputOptionByGroup(); current.setGroup(group); current.setInputs(inputs); } } } } } } // add last group if there was some new inputs if (!inputs.isEmpty()) { answer.add(current); } } // use common as faullback group name for (InputOptionByGroup group : answer) { if (group.getGroup() == null) { group.setGroup("common"); } } return answer; }
From source file:org.codehaus.groovy.grails.web.servlet.mvc.SimpleGrailsControllerHelper.java
private void initChainModel(GroovyObject controller) { FlashScope fs = this.grailsAttributes.getFlashScope( (HttpServletRequest) controller.getProperty(ControllerDynamicMethods.REQUEST_PROPERTY)); if (fs.containsKey(PROPERTY_CHAIN_MODEL)) { this.chainModel = (Map) fs.get(PROPERTY_CHAIN_MODEL); if (this.chainModel == null) this.chainModel = Collections.EMPTY_MAP; }/*from w w w. j a v a 2 s . c om*/ }
From source file:org.apache.ode.bpel.engine.BpelRuntimeContextImpl.java
/** * Evaluate a property alias query expression against a variable, returning * the normalized {@link String} representation of the property value. * * @param variable/*from w ww . j a va 2s. c om*/ * variable to read * @param property * property to read * @return value of property for variable, in String form * @throws org.apache.ode.bpel.common.FaultException * in case of selection or other fault */ public String readProperty(VariableInstance variable, OProcess.OProperty property) throws FaultException { Node varData = readVariable(variable.scopeInstance, variable.declaration.name, false); OProcess.OPropertyAlias alias = property.getAlias(variable.declaration.type); String val = _bpelProcess.extractProperty((Element) varData, Collections.EMPTY_MAP, alias, variable.declaration.getDescription()); if (BpelProcess.__log.isTraceEnabled()) { BpelProcess.__log .trace("readPropertyAlias(variable=" + variable + ", alias=" + alias + ") = " + val.toString()); } return val; }
From source file:diva.rest.model.DivaRoot.java
public void saveModel(org.eclipse.emf.common.util.URI uri) { Resource res = new XMIResourceImpl(uri); res.getContents().add(root);/*from w w w. java 2s .c o m*/ try { res.save(Collections.EMPTY_MAP); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:com.streamsets.datacollector.creation.PipelineBeanCreator.java
@SuppressWarnings("unchecked") private PipelineConfigBean createPipelineConfigs(PipelineConfiguration pipelineConf, List<Issue> errors, Map<String, Object> runtimeParameters) { PipelineConfigBean pipelineConfigBean = new PipelineConfigBean(); StageConfiguration stageConf = getPipelineConfAsStageConf(pipelineConf); if (ConfigInjector.get().createConfigBeans(pipelineConfigBean, "", new ConfigInjector.StageInjectorContext( PIPELINE_DEFINITION, stageConf, runtimeParameters, errors))) { // To support parameters in Pipeline Configuration inject "parameters" (constants) field first Config parametersConfigConf = stageConf.getConfig(PARAMETERS); ConfigDefinition parametersConfigDef = PIPELINE_DEFINITION.getConfigDefinitionsMap().get(PARAMETERS); if (parametersConfigConf != null) { try { ConfigInjector.get().injectConfigValue(pipelineConfigBean, PipelineConfigBean.class.getField(PARAMETERS), parametersConfigConf.getValue(), parametersConfigDef, new ConfigInjector.StageInjectorContext(PIPELINE_DEFINITION, stageConf, Collections.EMPTY_MAP, errors)); } catch (NoSuchFieldException ex) { IssueCreator issueCreator = IssueCreator.getStage(stageConf.getStageName()); errors.add(issueCreator.create(CreationError.CREATION_000, "pipeline", parametersConfigDef.getLabel(), ex.toString())); pipelineConfigBean.constants = Collections.EMPTY_MAP; }/*from ww w . j a v a 2 s . c o m*/ } Map<String, Object> resolvedConstants = pipelineConfigBean.constants; if (pipelineConfigBean.constants == null) { pipelineConfigBean.constants = Collections.emptyMap(); resolvedConstants = Collections.emptyMap(); } else { // Merge constant and runtime Constants if (runtimeParameters != null) { for (String key : runtimeParameters.keySet()) { if (resolvedConstants.containsKey(key)) { resolvedConstants.put(key, runtimeParameters.get(key)); } } } } ConfigInjector.get().injectConfigs(pipelineConfigBean, "", new ConfigInjector.StageInjectorContext( PIPELINE_DEFINITION, stageConf, pipelineConfigBean.constants, errors)); if (runtimeParameters != null) { pipelineConfigBean.constants = resolvedConstants; } } return pipelineConfigBean; }
From source file:com.redhat.rhn.domain.server.ServerFactory.java
/** * Returns a global multi org spanning list of * servers that are config enabled.//from w w w . ja v a 2 s.c o m * Basically used by taskomatic. * @return a list of config enabled systems */ public static List<Server> listConfigEnabledSystems() { return singleton.listObjectsByNamedQuery("Server.listConfigEnabledSystems", Collections.EMPTY_MAP); }
From source file:com.redhat.rhn.domain.server.ServerFactory.java
/** * Returns a global multi org spanning list of * servers that are config-diff enabled. * Basically used by taskomatic.//from www . ja v a 2s . c o m * @return a list of config-diff enabled systems */ public static List<Server> listConfigDiffEnabledSystems() { return singleton.listObjectsByNamedQuery("Server.listConfigDiffEnabledSystems", Collections.EMPTY_MAP); }
From source file:com.adobe.acs.commons.mcp.impl.processes.renovator.Renovator.java
protected void buildStructures(ActionManager manager) { manager.deferredWithResolver(rr -> { moves.forEach(node -> {/*w ww. ja va 2 s . c om*/ manager.deferredWithResolver(rr2 -> { node.visit(childNode -> { manager.deferredWithResolver(rr3 -> { Actions.setCurrentItem("Building structure for " + childNode.getSourcePath()); childNode.move(replicatorQueue, rr3); }); }, null, MovingNode::isCopiedBeforeMove); }); }); additionalTargetFolders.forEach(path -> { manager.deferredWithResolver(rr2 -> { Actions.setCurrentItem("Building structure for " + path); performNecessaryReplicationOnAncestors(rr2, path); ResourceUtil.getOrCreateResource(rr2, path, Collections.EMPTY_MAP, "sling:Folder", false); if (detailedReport) { note(path, Report.misc, "Created additional destination folder"); } }); }); }); }
From source file:com.ideabase.repository.webservice.controller.RESTfulControllerImpl.java
private void handleTagcloudAction(final RESTfulAction pAction, final HttpServletRequest pRequest, final HttpServletResponse pResponse) throws ParseException, IOException { // find max article parameter final String maxTagsString = pRequest.getParameter(PARAM_MAX_TAGS); final int maxTags; if (maxTagsString != null) { maxTags = Integer.parseInt(maxTagsString); } else {// ww w.j a va 2s . c om maxTags = DEFAULT_TAGCLOUD_MAX; } // perform search with the given query and max articles final PaginatedList<Hit> hits = performSearch(pAction, pRequest, pResponse); // find select parameter final String paramSelect = pRequest.getParameter(PARAM_SELECT); if (paramSelect == null || paramSelect.length() == 0) { throw new RuntimeException("no such parameter called 'select', example " + "usages - /service/find_*/q.xml?q=query&select=item_id, price"); } final String[] fields = paramSelect.split(SEPARATOR_COMMA); final GenericItem tagCloudHolder = new GenericItem(); if (hits != null && !hits.isEmpty()) { final List<Integer> itemIds = new ArrayList<Integer>(); // iterate each article for (final Hit hit : hits) { final GenericItem item = mRepositoryService.getItem(hit.getId(), GenericItem.class); if (item != null) { // lookup term store to find all term count itemIds.add(item.getId()); } } if (!itemIds.isEmpty()) { tagCloudHolder.setFields(mTermUsageService.getTags(itemIds, Arrays.asList(fields), maxTags)); } else { tagCloudHolder.setFields(Collections.EMPTY_MAP); } } final ResponseElement responseElement = new ResponseElement(ELEMENT_ITEM, tagCloudHolder); generateResponse(true, pAction, pRequest, pResponse, responseElement, STATUS_OK_200); }
From source file:com.silverwrist.venice.std.TrackbackManager.java
/** * Extracts all <META HTTP-EQUIV=...> tags from the given page content and returns them * as a {@link java.util.Map Map}.// ww w. j av a 2 s. c o m * * @param content The content of the page to scan. * @return A non-modifiable <code>Map</code> containing all the <META HTTP-EQUIV=...> tags from the page. * The keys are the HTTP-EQUIV names, converted to upper-case. The values are the CONTENT values. */ private static final Map extractHttpEquivTags(String content) { Map rc = new HashMap(); RE m = new RE(s_meta_tag, RE.MATCH_CASEINDEPENDENT); int pos = 0; while (m.match(content, pos)) { // get the meta tag itself String s = m.getParen(0); RE m2 = new RE(s_http_equiv_attr, RE.MATCH_CASEINDEPENDENT); if (m2.match(s)) { // extract the HTTP-EQUIV name String name = extractAttribute(s.substring(m2.getParenEnd(0))).toUpperCase(); m2 = new RE(s_content_attr, RE.MATCH_CASEINDEPENDENT); if (m2.match(s)) { // extract the CONTENT value String val = extractAttribute(s.substring(m2.getParenEnd(0))); // put the value into the return Map String exist = (String) (rc.get(name)); if (exist == null) rc.put(name, val); else rc.put(name, exist + ", " + val); } // end if // else ignore this one } // end if // else ignore this one // reset position for next time pos = m.getParenEnd(0); } // end while if (rc.isEmpty()) return Collections.EMPTY_MAP; else return Collections.unmodifiableMap(rc); }