You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@streampipes.apache.org by mi...@apache.org on 2022/11/30 15:00:00 UTC

[streampipes] 09/11: [STREAMPIPES-642] remove old static distance controller

This is an automated email from the ASF dual-hosted git repository.

micklich pushed a commit to branch STREAMPIPES-642
in repository https://gitbox.apache.org/repos/asf/streampipes.git

commit b55c6aabe1bc066d7c2a1a6b6ffcb7c17f01edad
Author: micklich <mi...@apache.org>
AuthorDate: Tue Nov 29 21:55:39 2022 +0100

    [STREAMPIPES-642] remove old static distance controller
---
 .../StaticDistanceCalculator.java                  | 60 ---------------
 .../StaticDistanceCalculatorController.java        | 87 ----------------------
 .../StaticDistanceCalculatorParameters.java        | 65 ----------------
 3 files changed, 212 deletions(-)

diff --git a/streampipes-extensions/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/processor/staticdistancecalculator/StaticDistanceCalculator.java b/streampipes-extensions/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/processor/staticdistancecalculator/StaticDistanceCalculator.java
deleted file mode 100644
index 9fc79946e..000000000
--- a/streampipes-extensions/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/processor/staticdistancecalculator/StaticDistanceCalculator.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- *   Licensed to the Apache Software Foundation (ASF) under one or more
- *   contributor license agreements.  See the NOTICE file distributed with
- *   this work for additional information regarding copyright ownership.
- *   The ASF licenses this file to You under the Apache License, Version 2.0
- *   (the "License"); you may not use this file except in compliance with
- *   the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- *   Unless required by applicable law or agreed to in writing, software
- *   distributed under the License is distributed on an "AS IS" BASIS,
- *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *   See the License for the specific language governing permissions and
- *   limitations under the License.
- */
-package org.apache.streampipes.processors.geo.jvm.processor.staticdistancecalculator;
-
-import org.apache.streampipes.commons.exceptions.SpRuntimeException;
-import org.apache.streampipes.model.runtime.Event;
-import org.apache.streampipes.processors.geo.jvm.latlong.helper.HaversineDistanceUtil;
-import org.apache.streampipes.wrapper.context.EventProcessorRuntimeContext;
-import org.apache.streampipes.wrapper.routing.SpOutputCollector;
-import org.apache.streampipes.wrapper.runtime.EventProcessor;
-
-public class StaticDistanceCalculator implements EventProcessor<StaticDistanceCalculatorParameters> {
-
-  private String latitudeFieldName;
-  private String longitudeFieldName;
-
-  private Float selectedLocationLatitude;
-  private Float selectedLocationLongitude;
-
-  @Override
-  public void onInvocation(StaticDistanceCalculatorParameters parameters, SpOutputCollector spOutputCollector, EventProcessorRuntimeContext runtimeContext) throws SpRuntimeException {
-    this.latitudeFieldName = parameters.getLatitudeFieldName();
-    this.longitudeFieldName = parameters.getLongitudeFieldName();
-
-    this.selectedLocationLatitude = parameters.getSelectedLatitude();
-    this.selectedLocationLongitude = parameters.getSelectedLongitude();
-  }
-
-  @Override
-  public void onEvent(Event event, SpOutputCollector collector) throws SpRuntimeException {
-    Float latitude = event.getFieldBySelector(latitudeFieldName).getAsPrimitive().getAsFloat();
-    Float longitude = event.getFieldBySelector(longitudeFieldName).getAsPrimitive().getAsFloat();
-
-    Float distance = HaversineDistanceUtil.dist(latitude, longitude, selectedLocationLatitude,
-            selectedLocationLongitude);
-
-    event.addField("distance", distance);
-
-    collector.collect(event);
-  }
-
-  @Override
-  public void onDetach() throws SpRuntimeException {
-
-  }
-}
diff --git a/streampipes-extensions/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/processor/staticdistancecalculator/StaticDistanceCalculatorController.java b/streampipes-extensions/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/processor/staticdistancecalculator/StaticDistanceCalculatorController.java
deleted file mode 100644
index 1885e1112..000000000
--- a/streampipes-extensions/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/processor/staticdistancecalculator/StaticDistanceCalculatorController.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- *   Licensed to the Apache Software Foundation (ASF) under one or more
- *   contributor license agreements.  See the NOTICE file distributed with
- *   this work for additional information regarding copyright ownership.
- *   The ASF licenses this file to You under the Apache License, Version 2.0
- *   (the "License"); you may not use this file except in compliance with
- *   the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- *   Unless required by applicable law or agreed to in writing, software
- *   distributed under the License is distributed on an "AS IS" BASIS,
- *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *   See the License for the specific language governing permissions and
- *   limitations under the License.
- */
-package org.apache.streampipes.processors.geo.jvm.processor.staticdistancecalculator;
-
-import org.apache.streampipes.model.DataProcessorType;
-import org.apache.streampipes.model.graph.DataProcessorDescription;
-import org.apache.streampipes.model.graph.DataProcessorInvocation;
-import org.apache.streampipes.model.schema.PropertyScope;
-import org.apache.streampipes.sdk.builder.PrimitivePropertyBuilder;
-import org.apache.streampipes.sdk.builder.ProcessingElementBuilder;
-import org.apache.streampipes.sdk.builder.StreamRequirementsBuilder;
-import org.apache.streampipes.sdk.extractor.ProcessingElementParameterExtractor;
-import org.apache.streampipes.sdk.helpers.EpRequirements;
-import org.apache.streampipes.sdk.helpers.Labels;
-import org.apache.streampipes.sdk.helpers.Locales;
-import org.apache.streampipes.sdk.helpers.OutputStrategies;
-import org.apache.streampipes.sdk.utils.Assets;
-import org.apache.streampipes.sdk.utils.Datatypes;
-import org.apache.streampipes.vocabulary.Geo;
-import org.apache.streampipes.vocabulary.SO;
-import org.apache.streampipes.wrapper.standalone.ConfiguredEventProcessor;
-import org.apache.streampipes.wrapper.standalone.declarer.StandaloneEventProcessingDeclarer;
-
-import java.net.URI;
-
-public class StaticDistanceCalculatorController extends StandaloneEventProcessingDeclarer<StaticDistanceCalculatorParameters> {
-
-  private static final String LATITUDE_KEY = "latitude-key";
-  private static final String LONGITUDE_KEY = "longitude-key" ;
-  private static final String SELECTED_LATITUDE_KEY = "selected-latitude-key";
-  private static final String SELECTED_LONGITUDE_KEY = "selected-longitude-key";
-
-  @Override
-  public DataProcessorDescription declareModel() {
-    return ProcessingElementBuilder.create("org.apache.streampipes.processors.geo.jvm.processor" +
-            ".staticdistancecalculator")
-            .category(DataProcessorType.GEO)
-            .withAssets(Assets.DOCUMENTATION)
-            .withLocales(Locales.EN)
-            .requiredStream(StreamRequirementsBuilder
-                    .create()
-                    .requiredPropertyWithUnaryMapping(EpRequirements.domainPropertyReq(Geo.lat)
-                            , Labels.withId(LATITUDE_KEY), PropertyScope.MEASUREMENT_PROPERTY)
-                    .requiredPropertyWithUnaryMapping(EpRequirements.domainPropertyReq(Geo.lng)
-                            , Labels.withId(LONGITUDE_KEY), PropertyScope.MEASUREMENT_PROPERTY)
-                    .build())
-            .requiredFloatParameter(Labels.withId(SELECTED_LATITUDE_KEY))
-            .requiredFloatParameter(Labels.withId(SELECTED_LONGITUDE_KEY))
-            .outputStrategy(
-                    OutputStrategies.append(PrimitivePropertyBuilder
-                            .create(Datatypes.Float,"distance")
-                            .domainProperty(SO.Number)
-                            .measurementUnit(URI.create("http://qudt.org/vocab/unit#Kilometer"))
-                            .build())
-            )
-            .build();
-
-  }
-
-  @Override
-  public ConfiguredEventProcessor<StaticDistanceCalculatorParameters> onInvocation(DataProcessorInvocation graph,
-                                                  ProcessingElementParameterExtractor extractor) {
-    String latitudeFieldName = extractor.mappingPropertyValue(LATITUDE_KEY);
-    String longitudeFieldName = extractor.mappingPropertyValue(LONGITUDE_KEY);
-    Float selectedLatitude = extractor.singleValueParameter(SELECTED_LATITUDE_KEY, Float.class);
-    Float selectedLongitude = extractor.singleValueParameter(SELECTED_LONGITUDE_KEY, Float.class);
-
-    StaticDistanceCalculatorParameters staticParam = new StaticDistanceCalculatorParameters(graph,
-            latitudeFieldName, longitudeFieldName, selectedLatitude, selectedLongitude);
-
-    return new ConfiguredEventProcessor<>(staticParam, StaticDistanceCalculator::new);
-  }
-}
diff --git a/streampipes-extensions/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/processor/staticdistancecalculator/StaticDistanceCalculatorParameters.java b/streampipes-extensions/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/processor/staticdistancecalculator/StaticDistanceCalculatorParameters.java
deleted file mode 100644
index 0d7e34773..000000000
--- a/streampipes-extensions/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/processor/staticdistancecalculator/StaticDistanceCalculatorParameters.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- *   Licensed to the Apache Software Foundation (ASF) under one or more
- *   contributor license agreements.  See the NOTICE file distributed with
- *   this work for additional information regarding copyright ownership.
- *   The ASF licenses this file to You under the Apache License, Version 2.0
- *   (the "License"); you may not use this file except in compliance with
- *   the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- *   Unless required by applicable law or agreed to in writing, software
- *   distributed under the License is distributed on an "AS IS" BASIS,
- *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *   See the License for the specific language governing permissions and
- *   limitations under the License.
- */
-package org.apache.streampipes.processors.geo.jvm.processor.staticdistancecalculator;
-
-import org.apache.streampipes.model.graph.DataProcessorInvocation;
-import org.apache.streampipes.wrapper.params.binding.EventProcessorBindingParams;
-
-public class StaticDistanceCalculatorParameters extends EventProcessorBindingParams {
-
-  private String latitudeFieldName;
-  private String longitudeFieldName;
-
-  private Float selectedLatitude;
-  private Float selectedLongitude;
-
-  public StaticDistanceCalculatorParameters(DataProcessorInvocation graph,
-                                            String latitudeFieldName,
-                                            String longitudeFieldName,
-                                            Float selectedLatitude,
-                                            Float selectedLongitude) {
-    super(graph);
-    this.latitudeFieldName = latitudeFieldName;
-    this.longitudeFieldName = longitudeFieldName;
-    this.selectedLatitude = selectedLatitude;
-    this.selectedLongitude = selectedLongitude;
-  }
-
-  public String getLatitudeFieldName() {
-    return latitudeFieldName;
-  }
-
-  public String getLongitudeFieldName() {
-    return longitudeFieldName;
-  }
-
-  public Float getSelectedLatitude() {
-    return selectedLatitude;
-  }
-
-  public void setSelectedLatitude(Float selectedLatitude) {
-    this.selectedLatitude = selectedLatitude;
-  }
-
-  public Float getSelectedLongitude() {
-    return selectedLongitude;
-  }
-
-  public void setSelectedLongitude(Float selectedLongitude) {
-    this.selectedLongitude = selectedLongitude;
-  }
-}