DataFilterAppComponent

Required to implement a data-filter component. Data filters reads 0 or more rows of input and produces 0 or more rows of results.

Source: Github

Example:

package my.org.components;

import io.dexi.service.AppContext;
import io.dexi.service.components.AppComponent;
import io.dexi.service.components.DataFilterAppComponent;
import io.dexi.service.exceptions.UserErrorException;
import io.dexi.service.utils.ResultStream;
import io.dexi.service.utils.RowStream;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

@AppComponent("process-data-with-my-app")
public class MyAppDataFilterAppComponent implements DataFilterAppComponent<MyAppConfig, MyComponentConfig> {

    @Override
    public void filter(AppContext<MyAppConfig, MyComponentConfig> ctxt, RowStream inputs, ResultStream outputs) {
        try {
            while (inputs.hasNext()) {
                final Map<String, Object> row = inputs.next();

                //Process row
                Map<String, Object> result = new HashMap<>(row);

                outputs.append(result);
            }
        } catch (IOException e) {
            throw new UserErrorException("Failed to process inputs", e);
        }
    }

    @Override
    public Class<MyComponentConfig> getComponentConfigClass() {
        return MyComponentConfig.class;
    }
}
components:
- name: process-data-with-my-app
  type: data-filter
  title: Process data using my app
  specification:
    endpoint: # Will invoke MyAppDataFilterAppComponent::filter
      url: "${baseUrl}/dexi/data/filter/invoke"
      method: POST
    inputs:
    	id: 
      	type: number
        title: ID
      title:
      	type: string
        title: Title
    outputs:
    	id: 
      	type: number
        title: ID
      title:
      	type: string
        title: Title