@SafeVarargs public static List<Option> from(Tuple2<String, String>... options) { return Arrays.stream(options).map(o -> new Option(o.a, o.b)).collect(Collectors.toList()); } }
public Option(Option o) { super(o); this.name = o.getName(); this.selected = o.isSelected(); this.internalName = o.getInternalName(); }
public BoundPipelineElementBuilder withPredefinedSelection(String internalStaticPropertyId, List<String> selectedOptions) { this.streamPipesEntity.getStaticProperties().stream().filter(sp -> sp instanceof SelectionStaticProperty).forEach(sp -> { if (sp.getInternalName().equals(internalStaticPropertyId)) { sp.setPredefined(true); ((SelectionStaticProperty) sp).getOptions().forEach(o -> { if (selectedOptions.stream().anyMatch(so -> so.equals(o.getName()))) { o.setSelected(true); } }); } }); return this; }
private void activateSensors(List<Option> config) { // this.selectedSensors = Arrays.asList(SensorNames.ALL_SENSOR_KEYS); this.selectedSensors = new ArrayList<>(); for (Option option : config) { if (option.isSelected()) { this.selectedSensors.add(option.getInternalName()); } } }
public <V> V selectedSingleValueInternalName(String internalName, Class<V> targetClass) { return typeParser.parse(getStaticPropertyByName(internalName, OneOfStaticProperty.class) .getOptions() .stream() .filter(Option::isSelected) .findFirst() .get() .getInternalName(), targetClass); }
private Option findSelected(List<Option> options) { return options .stream() .filter(o -> o.isSelected()) .findFirst() .get(); }
private <V, T extends SelectionStaticProperty> V selectedSingleValue(String internalName, Class<V> targetClass, Class<T> oneOfStaticProperty) { return typeParser.parse(getStaticPropertyByName(internalName, oneOfStaticProperty) .getOptions() .stream() .filter(Option::isSelected) .findFirst() .get() .getName(), targetClass); }
private void activateSensors(List<Option> config) { // this.selectedSensors = Arrays.asList(SensorNames.ALL_SENSOR_KEYS); this.selectedSensors = new ArrayList<>(); for (Option option : config) { if (option.isSelected()) { this.selectedSensors.add(option.getInternalName()); } } }
private EventProperty modifyEventProperty(EventProperty eventProperty, StaticProperty staticProperty, TransformOperationType transformOperationType) { if (staticProperty instanceof SelectionStaticProperty) { return modifyEventProperty(eventProperty, transformOperationType, findSelected(((SelectionStaticProperty) staticProperty).getOptions()).getInternalName()); } else if (staticProperty instanceof FreeTextStaticProperty) { return modifyEventProperty(eventProperty, transformOperationType, ((FreeTextStaticProperty) staticProperty) .getValue ()); } return eventProperty; }
private Option findSelected(List<Option> options) { return options .stream() .filter(o -> o.isSelected()) .findFirst() .get(); }
public List<Option> options(List<Option> options) { return options.stream().map(o -> new Option(o)).collect(Collectors.toList()); }
private EventProperty modifyEventProperty(EventProperty eventProperty, StaticProperty staticProperty, TransformOperationType transformOperationType) { if (staticProperty instanceof SelectionStaticProperty) { return modifyEventProperty(eventProperty, transformOperationType, findSelected(((SelectionStaticProperty) staticProperty).getOptions()).getInternalName()); } else if (staticProperty instanceof FreeTextStaticProperty) { return modifyEventProperty(eventProperty, transformOperationType, ((FreeTextStaticProperty) staticProperty) .getValue ()); } return eventProperty; }
private List<Option> handleResponse(Response httpResp) throws JsonSyntaxException, IOException { String resp = httpResp.returnContent().asString(); RuntimeOptionsResponse response = GsonSerializer .getGsonWithIds() .fromJson(resp, RuntimeOptionsResponse.class); return response .getOptions() .stream() .map(o -> new Option(o.getLabel(), o.getAdditionalPayload())) .collect(Collectors.toList()); }
private List<Option> handleResponse(Response httpResp) throws JsonSyntaxException, IOException { String resp = httpResp.returnContent().asString(); RuntimeOptionsResponse response = GsonSerializer .getGsonWithIds() .fromJson(resp, RuntimeOptionsResponse.class); return response .getOptions() .stream() .map(o -> new Option(o.getLabel(), o.getAdditionalPayload())) .collect(Collectors.toList()); }
@Override public SpecificAdapterStreamDescription declareModel() { return SpecificDataStreamAdapterBuilder.create(ID, "OpenSenseMap", "Environment Sensors") .iconUrl("openSenseMap.png") .requiredMultiValueSelection(Labels.from("sensors", "Sensors", "Select the " + "sensors that are included in the data stream"), Stream .of(SensorNames.ALL_SENSOR_LABELS) .map(s -> new Option(s, SensorNames.getKeyFromLabel(s))) .collect(Collectors.toList())) .build(); }
@Override public SpecificAdapterStreamDescription declareModel() { SpecificAdapterStreamDescription description = SpecificDataStreamAdapterBuilder.create(ID, "OpenSenseMap", "Environment Sensors") .iconUrl("openSenseMap.png") .requiredMultiValueSelection(Labels.from("sensors", "Sensors", "Select the " + "sensors that are included in the data stream"), Stream .of(SensorNames.ALL_SENSOR_LABELS) .map(s -> new Option(s, SensorNames.getKeyFromLabel(s))) .collect(Collectors.toList())) .build(); description.setAppId(ID); return description; }
@Override public FormatDescription declareModel() { FormatDescription fd = new FormatDescription(ID, "Csv", "This is the description" + "for csv format"); FreeTextStaticProperty delimiterProperty = new FreeTextStaticProperty("delimiter", "Delimiter", "The delimiter for json. Mostly either , or ;"); AnyStaticProperty offset = new AnyStaticProperty("header", "Header", "Does the CSV file include a header or not"); offset.setOptions(Arrays.asList(new Option("Header","Header"))); // FreeTextStaticProperty offset = new FreeTextStaticProperty("header", // "Includes Header", "Description"); fd.addConfig(delimiterProperty); fd.addConfig(offset); return fd; }
@Override public FormatDescription declareModel() { FormatDescription fd = new FormatDescription(ID, "Csv", "This is the description" + "for csv format"); FreeTextStaticProperty delimiterProperty = new FreeTextStaticProperty("delimiter", "Delimiter", "The delimiter for json. Mostly either , or ;"); fd.setAppId(ID); AnyStaticProperty offset = new AnyStaticProperty("header", "Header", "Does the CSV file include a header or not"); offset.setOptions(Arrays.asList(new Option("Header","Header"))); // // FreeTextStaticProperty offset = new FreeTextStaticProperty("header", // "Includes Header", "Description"); fd.addConfig(delimiterProperty); fd.addConfig(offset); return fd; }
for (int i = 0; i < data.length(); i++) { JSONObject object = data.getJSONObject(i); options.add(new Option(object.getString(value)));
for (int i = 0; i < data.length(); i++) { JSONObject object = data.getJSONObject(i); options.add(new Option(object.getString(value)));