@Override public void onPropertyModified(PropertyDescriptor descriptor, String oldValue, String newValue) { if (descriptor.isDynamic()) { if (!StringUtils.equals(oldValue, newValue)) { if (oldValue != null) { cachedJsonPathMap.remove(oldValue); } } } }
private Map<String, String> getFieldsNameMapping(ProcessContext context) { /** * list alternative regex */ Map<String, String> fieldsNameMappings = new HashMap<>(); // loop over dynamic properties to add alternative regex for (final Map.Entry<PropertyDescriptor, String> entry : context.getProperties().entrySet()) { if (!entry.getKey().isDynamic()) { continue; } final String fieldName = entry.getKey().getName(); final String mapping = entry.getValue(); fieldsNameMappings.put(fieldName, mapping); } return fieldsNameMappings; } }
private Map<String, String[]> getFieldsNameMapping(ProcessContext context) { /** * list alternative regex */ Map<String, String[]> fieldsNameMappings = new HashMap<>(); // loop over dynamic properties to add alternative regex for (final Map.Entry<PropertyDescriptor, String> entry : context.getProperties().entrySet()) { if (!entry.getKey().isDynamic()) { continue; } final String fieldName = entry.getKey().getName(); final String[] mapping = entry.getValue().split(","); fieldsNameMappings.put(fieldName, mapping); } return fieldsNameMappings; }
private Map<String, regexRule> getFieldsNameMapping(ProcessContext context) { /** * list alternative regex */ Map<String, regexRule> fieldsNameMappings = new HashMap<>(); // loop over dynamic properties to add alternative regex for (final Map.Entry<PropertyDescriptor, String> entry : context.getProperties().entrySet()) { if (!entry.getKey().isDynamic()) { continue; } final String fieldName = entry.getKey().getName(); final String[] splitedElements = entry.getValue().split(":", 2); if (splitedElements.length == 2) { String fieldToProduce = splitedElements[0]; String regexp = splitedElements[1]; fieldsNameMappings.put(fieldName, new regexRule(fieldToProduce, regexp)); } else { // Ignore the mapping rule logger.warn("The mapping rule for {} has the invalid value: {}", entry.getKey().getName(), entry.getValue()); } } return fieldsNameMappings; }
if (!entry.getKey().isDynamic()) { continue;
private Map<String, regexRule> getFieldsNameMapping(ProcessContext context) { /** * list alternative regex */ Map<String, regexRule> fieldsNameMappings = new HashMap<>(); // loop over dynamic properties to add alternative regex for (final Map.Entry<PropertyDescriptor, String> entry : context.getProperties().entrySet()) { if (!entry.getKey().isDynamic()) { continue; } final String fieldName = entry.getKey().getName(); final String[] splitedElements = entry.getValue().split(":", 2); if (splitedElements.length == 2) { String[] fieldsToProduce = splitedElements[0].split(","); String regexp = splitedElements[1]; fieldsNameMappings.put(fieldName, new regexRule(fieldsToProduce, regexp)); } else { // Ignore the mapping rule logger.warn("The mapping rule for {} has the invalid value: {}", entry.getKey().getName(), entry.getValue()); } } return fieldsNameMappings; }
@Override protected void setupDynamicProperties(ProcessContext context) { for (final Map.Entry<PropertyDescriptor, String> entry : context.getProperties().entrySet()) { if (!entry.getKey().isDynamic()) { continue; } String key = entry.getKey().getName(); String value = entry.getValue() .replaceAll("cache\\((\\S*\\))", "cache.get(\"test\", new com.hurence.logisland.record.StandardRecord().setId($1)") .replaceAll("\\.value", ".getField(com.hurence.logisland.record.FieldDictionary.RECORD_VALUE).asDouble()"); StringBuilder sb = new StringBuilder(); sb.append("var match=false;\n") .append("try {\n") .append("if( ") .append(value) .append(" ) { match=true; }\n") .append("} catch(error) {}"); dynamicTagValuesMap.put(entry.getKey().getName(), sb.toString()); // System.out.println(sb.toString()); // logger.debug(sb.toString()); } defaultCollection = context.getPropertyValue(DATASTORE_CACHE_COLLECTION).asString(); recordTTL = context.getPropertyValue(RECORD_TTL).asInteger(); }
if (!entry.getKey().isDynamic()) { continue;
private List<AlternativeMappingPattern> getAlternativePatterns(ProcessContext context, String valueRegexString) { /** * list alternative regex */ List<AlternativeMappingPattern> alternativeMappingRegex = new ArrayList<>(); // loop over dynamic properties to add alternative regex for (final Map.Entry<PropertyDescriptor, String> entry : context.getProperties().entrySet()) { if (!entry.getKey().isDynamic()) { continue; } if(!entry.getKey().getName().toLowerCase().contains("alt.value.fields")){ continue; } final String patternPropertyKey = entry.getKey().getName().toLowerCase().replace("fields", "regex"); if(context.getPropertyValue(patternPropertyKey) != null){ final String alternativeRegexString = context.getPropertyValue(patternPropertyKey).asString(); final String mapping = entry.getValue(); final Pattern pattern = Pattern.compile(alternativeRegexString); alternativeMappingRegex.add(new AlternativeMappingPattern(mapping, pattern)); } } return alternativeMappingRegex; }
if (!entry.getKey().isDynamic()) { continue;
@Override protected Collection<ValidationResult> customValidate(final ValidationContext context) { final List<ValidationResult> results = new ArrayList<>(super.customValidate(context)); int jsonPathCount = 0; for (final PropertyDescriptor desc : context.getProperties().keySet()) { if (desc.isDynamic()) { jsonPathCount++; } } if (jsonPathCount != 1) { results.add(new ValidationResult.Builder().subject("JsonPaths").valid(false) .explanation("Exactly one JsonPath must be set if using d").build()); } return results; }
generator.writeBooleanField("isDynamic", property.isDynamic()); generator.writeBooleanField("isSensitive", property.isSensitive()); generator.writeBooleanField("isExpressionLanguageSupported", property.isExpressionLanguageSupported());
if (!entry.getKey().isDynamic()) { continue;
if (!entry.getKey().isDynamic()) { continue;
if (!entry.getKey().isDynamic()) { continue;
private PropertyDescriptor getPropertyDescriptor(final PropertyDescriptor specDescriptor) { PropertyDescriptor descriptor = null; //check if property supported final List<PropertyDescriptor> supportedDescriptors = getSupportedPropertyDescriptors(); if (supportedDescriptors != null) { for (final PropertyDescriptor desc : supportedDescriptors) { //find actual descriptor if (specDescriptor.equals(desc)) { return desc; } } } descriptor = getSupportedDynamicPropertyDescriptor(specDescriptor.getName()); if (descriptor != null && !descriptor.isDynamic()) { descriptor = new PropertyDescriptor.Builder().fromPropertyDescriptor(descriptor).dynamic(true).build(); } if (descriptor == null) { descriptor = new PropertyDescriptor.Builder().fromPropertyDescriptor(specDescriptor).addValidator(Validator.INVALID).dynamic(true).build(); } return descriptor; }