Search in sources :

Example 86 with PluginPropertyField

use of io.cdap.cdap.api.plugin.PluginPropertyField in project cdap by caskdata.

the class StringValueFilterCompute method getPluginClass.

private static PluginClass getPluginClass() {
    Map<String, PluginPropertyField> properties = new HashMap<>();
    properties.put("field", new PluginPropertyField("field", "", "string", true, true));
    properties.put("value", new PluginPropertyField("value", "", "string", true, true));
    return PluginClass.builder().setName("StringValueFilterCompute").setType(SparkCompute.PLUGIN_TYPE).setDescription("").setClassName(StringValueFilterCompute.class.getName()).setProperties(properties).setConfigFieldName("conf").build();
}
Also used : HashMap(java.util.HashMap) PluginPropertyField(io.cdap.cdap.api.plugin.PluginPropertyField)

Example 87 with PluginPropertyField

use of io.cdap.cdap.api.plugin.PluginPropertyField in project cdap by cdapio.

the class PluginInstantiator method getFieldsWithMacro.

private Set<String> getFieldsWithMacro(Plugin plugin) {
    // TODO: cleanup after endpoint to get plugin details is merged (#6089)
    Set<String> macroFields = new HashSet<>();
    Map<String, PluginPropertyField> pluginPropertyFieldMap = plugin.getPluginClass().getProperties();
    TrackingMacroEvaluator trackingMacroEvaluator = new TrackingMacroEvaluator();
    for (Map.Entry<String, PluginPropertyField> pluginEntry : pluginPropertyFieldMap.entrySet()) {
        PluginPropertyField pluginField = pluginEntry.getValue();
        if (pluginEntry.getValue() != null && pluginField.isMacroSupported()) {
            String macroValue = plugin.getProperties().getProperties().get(pluginEntry.getKey());
            if (macroValue != null) {
                MacroParser macroParser = new MacroParser(trackingMacroEvaluator, MacroParserOptions.builder().setEscaping(pluginField.isMacroEscapingEnabled()).build());
                macroParser.parse(macroValue);
                if (trackingMacroEvaluator.hasMacro()) {
                    if (!pluginField.getChildren().isEmpty()) {
                        macroFields.addAll(pluginField.getChildren());
                    }
                    macroFields.add(pluginEntry.getKey());
                    trackingMacroEvaluator.reset();
                }
            }
        }
    }
    return macroFields;
}
Also used : PluginPropertyField(io.cdap.cdap.api.plugin.PluginPropertyField) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) HashMap(java.util.HashMap) HashSet(java.util.HashSet)

Example 88 with PluginPropertyField

use of io.cdap.cdap.api.plugin.PluginPropertyField in project cdap by cdapio.

the class MockRuntimeDatasetSource method getPluginClass.

private static PluginClass getPluginClass() {
    Map<String, PluginPropertyField> properties = new HashMap<>();
    properties.put("tableName", new PluginPropertyField("tableName", "", "string", true, false));
    properties.put("runtimeDatasetName", new PluginPropertyField("runtimeDatasetName", "", "string", true, true));
    return PluginClass.builder().setName("MockRuntime").setType(BatchSource.PLUGIN_TYPE).setDescription("").setClassName(MockRuntimeDatasetSource.class.getName()).setProperties(properties).setConfigFieldName("config").build();
}
Also used : HashMap(java.util.HashMap) PluginPropertyField(io.cdap.cdap.api.plugin.PluginPropertyField)

Example 89 with PluginPropertyField

use of io.cdap.cdap.api.plugin.PluginPropertyField in project cdap by cdapio.

the class MockSQLEngine method getPluginClass.

private static PluginClass getPluginClass() {
    Map<String, PluginPropertyField> properties = new HashMap<>();
    properties.put("name", new PluginPropertyField("name", "", "string", true, false));
    properties.put("inputDirName", new PluginPropertyField("inputDirName", "", "string", true, false));
    properties.put("outputDirName", new PluginPropertyField("outputDirName", "", "string", true, false));
    properties.put("outputSchema", new PluginPropertyField("outputSchema", "", "string", true, false));
    return new PluginClass(BatchSQLEngine.PLUGIN_TYPE, NAME, "", MockSQLEngine.class.getName(), "config", properties);
}
Also used : HashMap(java.util.HashMap) PluginClass(io.cdap.cdap.api.plugin.PluginClass) PluginPropertyField(io.cdap.cdap.api.plugin.PluginPropertyField)

Example 90 with PluginPropertyField

use of io.cdap.cdap.api.plugin.PluginPropertyField in project cdap by cdapio.

the class FileMoveAction method getPluginClass.

private static PluginClass getPluginClass() {
    Map<String, PluginPropertyField> properties = new HashMap<>();
    properties.put("sourceFileset", new PluginPropertyField("sourceFileset", "", "string", true, false));
    properties.put("destinationFileset", new PluginPropertyField("destinationFileset", "", "string", true, false));
    properties.put("filterRegex", new PluginPropertyField("filterRegex", "", "string", false, false));
    return PluginClass.builder().setName(NAME).setType(Action.PLUGIN_TYPE).setDescription("").setClassName(FileMoveAction.class.getName()).setProperties(properties).setConfigFieldName("conf").build();
}
Also used : HashMap(java.util.HashMap) PluginPropertyField(io.cdap.cdap.api.plugin.PluginPropertyField)

Aggregations

PluginPropertyField (io.cdap.cdap.api.plugin.PluginPropertyField)115 HashMap (java.util.HashMap)93 PluginClass (io.cdap.cdap.api.plugin.PluginClass)29 Test (org.junit.Test)16 ArtifactRange (io.cdap.cdap.api.artifact.ArtifactRange)12 ArtifactVersion (io.cdap.cdap.api.artifact.ArtifactVersion)12 Id (io.cdap.cdap.common.id.Id)12 File (java.io.File)10 ArtifactClasses (io.cdap.cdap.api.artifact.ArtifactClasses)8 ArtifactId (io.cdap.cdap.proto.id.ArtifactId)8 NamespaceId (io.cdap.cdap.proto.id.NamespaceId)8 Location (org.apache.twill.filesystem.Location)8 ImmutableMap (com.google.common.collect.ImmutableMap)6 ImmutableSet (com.google.common.collect.ImmutableSet)6 ApplicationClass (io.cdap.cdap.api.artifact.ApplicationClass)6 ArtifactId (io.cdap.cdap.api.artifact.ArtifactId)6 Requirements (io.cdap.cdap.api.plugin.Requirements)6 ArtifactNotFoundException (io.cdap.cdap.common.ArtifactNotFoundException)6 ArrayList (java.util.ArrayList)6 Map (java.util.Map)6