Search in sources :

Example 26 with StrSubstitutor

use of org.apache.commons.lang3.text.StrSubstitutor in project solr-cmd-utils by tblsoft.

the class AbstractFilter method getProperty.

public String getProperty(String name, String defaultValue) {
    if (filter.getProperty() == null) {
        return defaultValue;
    }
    String value = (String) filter.getProperty().get(name);
    if (value != null) {
        StrSubstitutor strSubstitutor = new StrSubstitutor(variables);
        value = strSubstitutor.replace(value);
        return value;
    }
    return defaultValue;
}
Also used : StrSubstitutor(org.apache.commons.lang3.text.StrSubstitutor)

Example 27 with StrSubstitutor

use of org.apache.commons.lang3.text.StrSubstitutor in project solr-cmd-utils by tblsoft.

the class AbstractReader method getProperty.

public String getProperty(String name, String defaultValue) {
    String value = (String) reader.getProperty().get(name);
    if (value != null) {
        StrSubstitutor strSubstitutor = new StrSubstitutor(variables);
        value = strSubstitutor.replace(value);
        return value;
    }
    return defaultValue;
}
Also used : StrSubstitutor(org.apache.commons.lang3.text.StrSubstitutor)

Example 28 with StrSubstitutor

use of org.apache.commons.lang3.text.StrSubstitutor in project solr-cmd-utils by tblsoft.

the class FieldJoiner method document.

@Override
public void document(Document document) {
    Map<String, String> documentMap = new HashMap<String, String>();
    for (Field field : document.getFields()) {
        documentMap.put(field.getName(), field.getValue());
    }
    StrSubstitutor sub = new StrSubstitutor(documentMap);
    String value = sub.replace(output);
    document.addField(outputField, value);
    super.document(document);
}
Also used : Field(de.tblsoft.solr.pipeline.bean.Field) StrSubstitutor(org.apache.commons.lang3.text.StrSubstitutor) HashMap(java.util.HashMap)

Example 29 with StrSubstitutor

use of org.apache.commons.lang3.text.StrSubstitutor in project solr-cmd-utils by tblsoft.

the class MappingFilter method document.

@Override
public void document(Document document) {
    Document mappedDocument;
    if (!appendFields) {
        mappedDocument = new Document();
    } else {
        mappedDocument = new Document();
        mappedDocument.getFields().addAll(document.getFields());
    }
    for (Field f : document.getFields()) {
        List<String> mappedNameList = mapping.get(f.getName());
        if (mappedNameList == null) {
            continue;
        }
        for (String mappedName : mappedNameList) {
            List<String> mappedFunctions = mappingFunctions.get(mappedName);
            if (!Strings.isNullOrEmpty(mappedName)) {
                List<String> newValues = new ArrayList<String>();
                for (String value : f.getValues()) {
                    String newValue = value;
                    for (String function : mappedFunctions) {
                        newValue = simpleMapping.executeFunction(function, newValue);
                    }
                    newValues.add(newValue);
                }
                mappedDocument.addField(mappedName, newValues);
                Field mappedField = mappedDocument.getField(mappedName);
                for (String function : mappedFunctions) {
                    simpleMapping.executeFieldFunction(function, mappedField);
                }
            }
        }
    }
    for (Map.Entry<String, String> entry : joins.entrySet()) {
        Map<String, String> documentMap = new HashMap<String, String>();
        for (Field field : document.getFields()) {
            documentMap.put(field.getName(), field.getValue());
        }
        StrSubstitutor sub = new StrSubstitutor(documentMap);
        String value = sub.replace(entry.getValue());
        mappedDocument.addField(entry.getKey(), value);
    }
    if (mappedDocument.getFields().size() != 0) {
        addMissingFields(mappedDocument);
        sortFieldsByName(mappedDocument);
        super.document(mappedDocument);
    }
}
Also used : Field(de.tblsoft.solr.pipeline.bean.Field) StrSubstitutor(org.apache.commons.lang3.text.StrSubstitutor) Document(de.tblsoft.solr.pipeline.bean.Document)

Example 30 with StrSubstitutor

use of org.apache.commons.lang3.text.StrSubstitutor in project fabric8 by fabric8io.

the class Support method createStrSubstitutor.

public static StrSubstitutor createStrSubstitutor(String prefix, String suffix, StrLookup<String> lookup) {
    StrSubstitutor substitutor = new StrSubstitutor();
    substitutor.setEnableSubstitutionInVariables(true);
    substitutor.setVariablePrefix(prefix);
    substitutor.setVariableSuffix(suffix);
    substitutor.setVariableResolver(lookup);
    return substitutor;
}
Also used : StrSubstitutor(org.apache.commons.lang3.text.StrSubstitutor)

Aggregations

StrSubstitutor (org.apache.commons.lang3.text.StrSubstitutor)32 HashMap (java.util.HashMap)16 File (java.io.File)5 Map (java.util.Map)5 IOException (java.io.IOException)4 StrLookup (org.apache.commons.lang3.text.StrLookup)3 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)2 UnrecognizedPropertyException (com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException)2 MetricConfigDTO (com.linkedin.thirdeye.datalayer.dto.MetricConfigDTO)2 Field (de.tblsoft.solr.pipeline.bean.Field)2 FileWriter (java.io.FileWriter)2 SQLException (java.sql.SQLException)2 List (java.util.List)2 Properties (java.util.Properties)2 StringUtils (org.apache.commons.lang3.StringUtils)2 Test (org.junit.Test)2 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)2 DomainVO (com.cloud.domain.DomainVO)1 AccountVO (com.cloud.user.AccountVO)1 UserVO (com.cloud.user.UserVO)1