Official | HULFT IoT EdgeStreaming Plugin SDK Getting Started Third Edition: July 1, 2021

Implementation of SampleSinkOperationFactory

SampleSinkOperationFactory is a class holding the following information:

 

Superclass

BQLPluginSinkOperationFactory class

Description

A Factory class that returns an object holding the properties of Sink Operation and returns an operation object

 

Implementation of SampleSinkOperationFactory is as follows:

package com.appresso.ds.dp.modules.adapter.sample;

import com.appresso.ds.common.spi.constraint.NumberFillin;
import com.appresso.ds.common.spi.param.SimpleParameter;
import com.appresso.ds.common.xmlfw.xml.XmlHandler;
import com.appresso.ds.dp.share.adapter.bql.common.BQLPluginOutputOperationFactory;
import com.appresso.ds.dp.spi.OperationConfiguration;
import com.appresso.ds.dp.spi.OperationConfigurator;
import com.appresso.ds.dp.spi.OperationContext;
import org.xml.sax.SAXException;

import static com.appresso.ds.common.bql.BQLSimpleParameterType.INTEGER;

public class SampleSinkOperationFactory extends BQLPluginOutputOperationFactory {
 @Override 
 protected String getLabel() {
  return Messages.getString("Sample.Sink.Label");
 }

 @Override 
 protected String getPluginName() {
  return "sample_plugin";
 }

 @Override 
 public String getOperationName() {
  return "sample_sink";
 }

 @Override 
 protected String getTypeName() {
  return "sample_sink";
 }

 @Override 
 protected void setupOperationConfigurator(OperationConfigurator operationConfigurator) {
  operationConfigurator.addSimpleParameter(createDecimalParameter());
 }

 protected void setupInputSchema(XmlHandler handler, OperationConfiguration conf, OperationContext context)
   throws Exception {
  handler.startElement("", "payload", "payload", EMPTY_ATTRIBUTE);
  writeElement(handler, "formula");
  writeElement(handler, "value");
  handler.endElement("", "payload", "payload");
 }

 private void writeElement(XmlHandler handler, String name) throws SAXException {
  handler.startElement("", name, name, EMPTY_ATTRIBUTE);
  handler.endElement("", name, name);
 }

 private static SimpleParameter createDecimalParameter() {
  NumberFillin fillin = new NumberFillin();
  fillin.setMinValue(0);
  fillin.setMaxValue(10);
  fillin.setAllowMin(true);
  fillin.setAllowMax(true);
  fillin.setLabel(Messages.getString("Sample.Sink.Decimal.Label"));
  fillin.setRequired(true);
  return new SimpleParameter(INTEGER.toParameterKey("decimal"), fillin);
 }
}
            

 

 

 

Official | HULFT IoT EdgeStreaming Plugin SDK Getting Started Third Edition: July 1, 2021