use of io.cdap.cdap.api.plugin.PluginPropertyField in project cdap by caskdata.
the class DefaultArtifactInspector method createPluginProperties.
/**
* Creates a collection of {@link PluginPropertyField} based on the given field.
*/
private Collection<PluginPropertyField> createPluginProperties(Field field, TypeToken<?> resolvingType, boolean inspectNested) throws UnsupportedTypeException {
TypeToken<?> fieldType = resolvingType.resolveType(field.getGenericType());
Class<?> rawType = fieldType.getRawType();
Name nameAnnotation = field.getAnnotation(Name.class);
Description descAnnotation = field.getAnnotation(Description.class);
String name = nameAnnotation == null ? field.getName() : nameAnnotation.value();
String description = descAnnotation == null ? "" : descAnnotation.value();
Macro macroAnnotation = field.getAnnotation(Macro.class);
boolean macroSupported = macroAnnotation != null;
if (rawType.isPrimitive()) {
return Collections.singleton(new PluginPropertyField(name, description, rawType.getName(), true, macroSupported));
}
rawType = Primitives.unwrap(rawType);
boolean required = true;
for (Annotation annotation : field.getAnnotations()) {
if (annotation.annotationType().getName().endsWith(".Nullable")) {
required = false;
break;
}
}
Map<String, PluginPropertyField> properties = new HashMap<>();
if (PluginConfig.class.isAssignableFrom(rawType)) {
if (!inspectNested) {
throw new IllegalArgumentException("Plugin config with name " + name + " is a subclass of PluginGroupConfig and can " + "only be defined within PluginConfig.");
}
// don't inspect if the field is already nested
inspectConfigField(fieldType, properties, false);
}
PluginPropertyField curField = new PluginPropertyField(name, description, rawType.getSimpleName().toLowerCase(), required, macroSupported, false, new HashSet<>(properties.keySet()));
properties.put(name, curField);
return properties.values();
}
use of io.cdap.cdap.api.plugin.PluginPropertyField in project cdap by caskdata.
the class MockSQLEngineWithCapabilities method getPluginClass.
private static PluginClass getPluginClass() {
Map<String, PluginPropertyField> properties = new HashMap<>();
properties.put("name", new PluginPropertyField("name", "", "string", true, false));
properties.put("outputDirName", new PluginPropertyField("outputDirName", "", "string", true, false));
properties.put("outputSchema", new PluginPropertyField("outputSchema", "", "string", true, false));
properties.put("expected", new PluginPropertyField("expected", "", "string", true, false));
return new PluginClass(BatchSQLEngine.PLUGIN_TYPE, NAME, "", MockSQLEngineWithCapabilities.class.getName(), "config", properties);
}
use of io.cdap.cdap.api.plugin.PluginPropertyField in project cdap by caskdata.
the class FieldLineageAction method getPluginClass.
private static PluginClass getPluginClass() {
Map<String, PluginPropertyField> properties = new HashMap<>();
properties.put("readDataset", new PluginPropertyField("readDataset", "", "string", true, false));
properties.put("writeDataset", new PluginPropertyField("writeDataset", "", "string", true, false));
properties.put("fieldOperations", new PluginPropertyField("fieldOperations", "", "string", true, false));
return PluginClass.builder().setName("FieldLineageAction").setType(Action.PLUGIN_TYPE).setDescription("").setClassName(FieldLineageAction.class.getName()).setProperties(properties).setConfigFieldName("config").build();
}
use of io.cdap.cdap.api.plugin.PluginPropertyField in project cdap by caskdata.
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();
}
use of io.cdap.cdap.api.plugin.PluginPropertyField in project cdap by caskdata.
the class TMSAlertPublisher method getPluginClass.
private static PluginClass getPluginClass() {
Map<String, PluginPropertyField> properties = new HashMap<>();
properties.put("topic", new PluginPropertyField("topic", "", "string", true, false));
properties.put("topicNamespace", new PluginPropertyField("topicNamespace", "", "string", true, false));
return PluginClass.builder().setName(NAME).setType(AlertPublisher.PLUGIN_TYPE).setDescription("").setClassName(TMSAlertPublisher.class.getName()).setProperties(properties).setConfigFieldName("conf").build();
}
Aggregations