List of usage examples for org.apache.commons.collections4 MapUtils isNotEmpty
public static boolean isNotEmpty(final Map<?, ?> map)
From source file:com.mirth.connect.server.channel.DelegateErrorTaskHandler.java
public boolean isErrored() { return MapUtils.isNotEmpty(errorMap); }
From source file:com.jkoolcloud.tnt4j.streams.filters.TRSizeFilter.java
private static TraceRecord cloneTraceRecord(TraceRecord trToCopyFrom, Long wholeTraceTime, Float percentageOffset) { TraceRecord trReturn = trToCopyFrom.copy(); trReturn.setChildren(new ArrayList<TraceRecord>()); if (trToCopyFrom.getChildren() == null) { return trReturn; }// w w w. ja va 2s. c om for (TraceRecord children : trToCopyFrom.getChildren()) { Long methodTime = children.getTime(); Float percentageMethod = (float) ((double) methodTime / (double) wholeTraceTime); if (percentageMethod >= percentageOffset || MapUtils.isNotEmpty(children.getAttrs()) || children.getMarker() != null) { trReturn.addChild(cloneTraceRecord(children, wholeTraceTime, percentageOffset)); } } return trReturn; }
From source file:com.jkoolcloud.tnt4j.streams.utils.SyslogUtils.java
/** * Extract Syslog name/value pairs if available in within the message. * * @param message//from w w w .ja v a2s.co m * Syslog event message * @param dataMap * log entry fields map to update * @return map of parsed out event attributes (name=value pairs) */ public static Map<String, Object> extractVariables(String message, Map<String, Object> dataMap) { if (message == null) { return null; } Map<String, Object> vars = parseVariables(message); if (MapUtils.isNotEmpty(vars)) { extractSpecialKeys(vars, dataMap); // PropertySnapshot snap = new PropertySnapshot(FIELD_SYSLOG_VARS, // (String) dataMap.get(ResourceName.name()), (OpLevel) dataMap.get(Severity.name())); // snap.addAll(vars); dataMap.put(SyslogStreamConstants.FIELD_SYSLOG_VARS, vars); } return vars; }
From source file:io.cloudslang.lang.runtime.bindings.OutputsBinding.java
public Map<String, Serializable> bindOutputs(Map<String, Serializable> inputs, Map<String, Serializable> actionReturnValues, List<Output> possibleOutputs) { Map<String, Serializable> outputs = new LinkedHashMap<>(); if (possibleOutputs != null) { for (Output output : possibleOutputs) { String outputKey = output.getName(); String outputExpr = output.getExpression(); if (outputExpr != null) { //construct script context Map<String, Serializable> scriptContext = new HashMap<>(); //put action outputs scriptContext.putAll(actionReturnValues); //declare the new output if (!actionReturnValues.containsKey(outputKey)) { scriptContext.put(outputKey, null); }// ww w . j a v a 2s . c o m //put operation inputs as a map if (MapUtils.isNotEmpty(inputs)) { scriptContext.put(ScoreLangConstants.BIND_OUTPUT_FROM_INPUTS_KEY, (Serializable) inputs); } Serializable scriptResult; try { scriptResult = scriptEvaluator.evalExpr(outputExpr, scriptContext); } catch (Throwable t) { throw new RuntimeException( "Error binding output: '" + output.getName() + "',\n\tError is: " + t.getMessage(), t); } //evaluate expression try { outputs.put(outputKey, scriptResult); } catch (ClassCastException ex) { throw new RuntimeException( "The output expression " + outputExpr + " does not return serializable value", ex); } } else { throw new RuntimeException("Output: " + outputKey + " has no expression"); } } } return outputs; }
From source file:com.jkoolcloud.tnt4j.streams.configure.sax.StreamsConfigSAXParser.java
/** * Reads the configuration and invokes the (SAX-based) parser to parse the configuration file contents. * * @param config//ww w . j ava 2s .co m * input stream to get configuration data from * @param validate * flag indicating whether to validate configuration XML against XSD schema * @return streams configuration data * @throws ParserConfigurationException * if there is an inconsistency in the configuration * @throws SAXException * if there was an error parsing the configuration * @throws IOException * if there is an error reading the configuration data */ public static StreamsConfigData parse(InputStream config, boolean validate) throws ParserConfigurationException, SAXException, IOException { if (validate) { config = config.markSupported() ? config : new ByteArrayInputStream(IOUtils.toByteArray(config)); Map<OpLevel, List<SAXParseException>> validationErrors = validate(config); if (MapUtils.isNotEmpty(validationErrors)) { for (Map.Entry<OpLevel, List<SAXParseException>> vee : validationErrors.entrySet()) { for (SAXParseException ve : vee.getValue()) { LOGGER.log(OpLevel.WARNING, StreamsResources.getString(StreamsResources.RESOURCE_BUNDLE_NAME, "StreamsConfigSAXParser.xml.validation.error"), ve.getLineNumber(), ve.getColumnNumber(), vee.getKey(), ve.getLocalizedMessage()); } } } } Properties p = Utils.loadPropertiesResource("sax.properties"); // NON-NLS SAXParserFactory parserFactory = SAXParserFactory.newInstance(); SAXParser parser = parserFactory.newSAXParser(); ConfigParserHandler hndlr = null; try { String handlerClassName = p.getProperty(HANDLER_PROP_KEY, ConfigParserHandler.class.getName()); if (StringUtils.isNotEmpty(handlerClassName)) { hndlr = (ConfigParserHandler) Utils.createInstance(handlerClassName); } } catch (Exception exc) { } if (hndlr == null) { hndlr = new ConfigParserHandler(); } parser.parse(config, hndlr); return hndlr.getStreamsConfigData(); }
From source file:io.github.swagger2markup.internal.document.SecurityDocument.java
/** * Builds the security MarkupDocument.// w w w.ja v a2s. c om * * @return the security MarkupDocument */ @Override public MarkupDocBuilder apply(MarkupDocBuilder markupDocBuilder, SecurityDocument.Parameters params) { Map<String, SecuritySchemeDefinition> definitions = params.securitySchemeDefinitions; if (MapUtils.isNotEmpty(definitions)) { applySecurityDocumentExtension(new Context(Position.DOCUMENT_BEFORE, markupDocBuilder)); buildSecurityTitle(markupDocBuilder, labels.getLabel(SECURITY)); applySecurityDocumentExtension(new Context(Position.DOCUMENT_BEGIN, markupDocBuilder)); buildSecuritySchemeDefinitionsSection(markupDocBuilder, definitions); applySecurityDocumentExtension(new Context(Position.DOCUMENT_END, markupDocBuilder)); applySecurityDocumentExtension(new Context(Position.DOCUMENT_AFTER, markupDocBuilder)); } return markupDocBuilder; }
From source file:io.cloudslang.lang.tools.build.tester.TriggerTestCaseEventListener.java
public static Map<String, Serializable> extractOutputs(LanguageEventData data) { Map<String, Serializable> outputsMap = new HashMap<>(); boolean thereAreOutputsForRootPath = data.containsKey(LanguageEventData.OUTPUTS) && data.containsKey(LanguageEventData.PATH) && data.getPath().equals(EXEC_START_PATH); if (thereAreOutputsForRootPath) { Map<String, Serializable> outputs = data.getOutputs(); if (MapUtils.isNotEmpty(outputs)) { outputsMap.putAll(outputs);//w ww . j a va 2s. co m } } return outputsMap; }
From source file:io.cloudslang.lang.compiler.validator.ExecutableValidatorImpl.java
@Override public void validateImportsSection(ParsedSlang parsedSlang) { Map<String, String> imports = parsedSlang.getImports(); ParsedSlang.Type executableType = parsedSlang.getType(); switch (executableType) { case FLOW:// w ww . j av a 2s. c o m break; case OPERATION: case DECISION: case SYSTEM_PROPERTY_FILE: if (MapUtils.isNotEmpty(imports)) { throw new RuntimeException("Type[" + executableType.name() + "] cannot have imports section"); } break; default: throw new RuntimeException("Not yet implemented"); } if (MapUtils.isNotEmpty(imports)) { Set<Map.Entry<String, String>> entrySet = imports.entrySet(); for (Map.Entry<String, String> entry : entrySet) { String alias = entry.getKey(); String namespace = entry.getValue(); validateNamespaceRules(namespace); validateSimpleNameRules(alias); } } }
From source file:com.haulmont.cuba.gui.xml.layout.loaders.AbstractTextFieldLoader.java
protected void loadCaseConversion(TextInputField.CaseConversionSupported component, Element element) { final String caseConversion = element.attributeValue("caseConversion"); if (StringUtils.isNotEmpty(caseConversion)) { component.setCaseConversion(TextInputField.CaseConversion.valueOf(caseConversion)); return;/*from www . j ava 2 s . c om*/ } if (resultComponent.getMetaPropertyPath() != null) { Map<String, Object> annotations = resultComponent.getMetaPropertyPath().getMetaProperty() .getAnnotations(); //noinspection unchecked Map<String, Object> conversion = (Map<String, Object>) annotations.get(CaseConversion.class.getName()); if (MapUtils.isNotEmpty(conversion)) { ConversionType conversionType = (ConversionType) conversion.get("type"); TextInputField.CaseConversion tfCaseConversion = TextInputField.CaseConversion .valueOf(conversionType.name()); component.setCaseConversion(tfCaseConversion); } } }
From source file:com.haulmont.cuba.gui.components.data.DataAwareComponentsTools.java
/** * todo JavaDoc/*from w ww . ja v a 2 s . c o m*/ * * @param component * @param valueSource */ public void setupCaseConversion(TextInputField.CaseConversionSupported component, EntityValueSource valueSource) { MetaProperty metaProperty = valueSource.getMetaPropertyPath().getMetaProperty(); Map<String, Object> annotations = metaProperty.getAnnotations(); String caseConversionAnnotation = CaseConversion.class.getName(); //noinspection unchecked Map<String, Object> caseConversion = (Map<String, Object>) annotations.get(caseConversionAnnotation); if (MapUtils.isNotEmpty(caseConversion)) { ConversionType conversionType = (ConversionType) caseConversion.get("type"); TextInputField.CaseConversion conversion = TextInputField.CaseConversion.valueOf(conversionType.name()); component.setCaseConversion(conversion); } }