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:02 UTC
[streampipes] 11/11: [STREAMPIPES-642] remove old geocoder classes
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 4d8422248cb9724649e7d8d8b081f0d5eb0f5653
Author: micklich <mi...@apache.org>
AuthorDate: Wed Nov 30 12:44:11 2022 +0100
[STREAMPIPES-642] remove old geocoder classes
---
.../processor/geocoder/GoogleMapsGeocoding.java | 82 ----------------------
.../geocoder/GoogleMapsGeocodingController.java | 69 ------------------
.../geocoder/GoogleMapsGeocodingParameters.java | 36 ----------
3 files changed, 187 deletions(-)
diff --git a/streampipes-extensions/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/processor/geocoder/GoogleMapsGeocoding.java b/streampipes-extensions/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/processor/geocoder/GoogleMapsGeocoding.java
deleted file mode 100644
index 5ff4cabf1..000000000
--- a/streampipes-extensions/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/processor/geocoder/GoogleMapsGeocoding.java
+++ /dev/null
@@ -1,82 +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.geocoder;
-
-import com.google.maps.GeoApiContext;
-import com.google.maps.GeocodingApi;
-import com.google.maps.errors.ApiException;
-import com.google.maps.model.GeocodingResult;
-import org.apache.streampipes.commons.exceptions.SpRuntimeException;
-import org.apache.streampipes.model.runtime.Event;
-import org.apache.streampipes.processors.geo.jvm.config.ConfigKeys;
-import org.apache.streampipes.wrapper.context.EventProcessorRuntimeContext;
-import org.apache.streampipes.wrapper.routing.SpOutputCollector;
-import org.apache.streampipes.wrapper.runtime.EventProcessor;
-
-import java.io.IOException;
-
-public class GoogleMapsGeocoding implements EventProcessor<GoogleMapsGeocodingParameters> {
-
- private GeoApiContext context;
- private String placeField;
-
- @Override
- public void onInvocation(GoogleMapsGeocodingParameters parameters, SpOutputCollector spOutputCollector, EventProcessorRuntimeContext runtimeContext) throws SpRuntimeException {
- this.placeField = parameters.getPlaceField();
- String googleMapsApiKey = runtimeContext.getConfigStore().getConfig().getString(ConfigKeys.GOOGLE_API_KEY);
-
- if (googleMapsApiKey == null || googleMapsApiKey.equals("")) {
- throw new SpRuntimeException("Could not start Geocoder. Did you forget to add a Google Maps" +
- " API key?");
- }
-
- this.context = new GeoApiContext.Builder()
- .apiKey(googleMapsApiKey)
- .build();
- }
-
- @Override
- public void onEvent(Event event, SpOutputCollector collector) throws SpRuntimeException {
- String placename = event.getFieldBySelector(placeField).getAsPrimitive().getAsString();
-
- try {
- GeocodingResult[] results = GeocodingApi.geocode(context,
- placename).await();
-
- Double latitude = results[0].geometry.location.lat;
- Double longitude = results[0].geometry.location.lng;
-
- event.addField("latitude", latitude);
- event.addField("longitude", longitude);
-
- collector.collect(event);
-
- } catch (ApiException | InterruptedException | IOException e) {
- e.printStackTrace();
- throw new SpRuntimeException("Could not fetch geocoding result");
- }
-
-
-
- }
-
- @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/geocoder/GoogleMapsGeocodingController.java b/streampipes-extensions/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/processor/geocoder/GoogleMapsGeocodingController.java
deleted file mode 100644
index dd50c77d9..000000000
--- a/streampipes-extensions/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/processor/geocoder/GoogleMapsGeocodingController.java
+++ /dev/null
@@ -1,69 +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.geocoder;
-
-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.ProcessingElementBuilder;
-import org.apache.streampipes.sdk.builder.StreamRequirementsBuilder;
-import org.apache.streampipes.sdk.extractor.ProcessingElementParameterExtractor;
-import org.apache.streampipes.sdk.helpers.EpProperties;
-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.vocabulary.Geo;
-import org.apache.streampipes.wrapper.standalone.ConfiguredEventProcessor;
-import org.apache.streampipes.wrapper.standalone.declarer.StandaloneEventProcessingDeclarer;
-
-public class GoogleMapsGeocodingController extends StandaloneEventProcessingDeclarer<GoogleMapsGeocodingParameters> {
-
- private static final String PLACE_MAPPING = "place-mapping";
-
- @Override
- public DataProcessorDescription declareModel() {
- return ProcessingElementBuilder.create("org.apache.streampipes.processor.geo.jvm.geocoding")
- .category(DataProcessorType.GEO)
- .withAssets(Assets.DOCUMENTATION)
- .withLocales(Locales.EN)
- .requiredStream(StreamRequirementsBuilder
- .create()
- .requiredPropertyWithUnaryMapping(EpRequirements.stringReq(),
- Labels.withId(PLACE_MAPPING),
- PropertyScope.NONE)
- .build())
- .outputStrategy(OutputStrategies.append(
- EpProperties.doubleEp(Labels.empty(), "latitude", Geo.lat),
- EpProperties.stringEp(Labels.empty(), "longitude", Geo.lng)
- ))
- .build();
- }
-
- @Override
- public ConfiguredEventProcessor<GoogleMapsGeocodingParameters> onInvocation(DataProcessorInvocation graph,
- ProcessingElementParameterExtractor extractor) {
- String placeField = extractor.mappingPropertyValue(PLACE_MAPPING);
-
- GoogleMapsGeocodingParameters params = new GoogleMapsGeocodingParameters(graph, placeField);
-
- return new ConfiguredEventProcessor<>(params, GoogleMapsGeocoding::new);
- }
-}
diff --git a/streampipes-extensions/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/processor/geocoder/GoogleMapsGeocodingParameters.java b/streampipes-extensions/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/processor/geocoder/GoogleMapsGeocodingParameters.java
deleted file mode 100644
index 8ad424999..000000000
--- a/streampipes-extensions/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/processor/geocoder/GoogleMapsGeocodingParameters.java
+++ /dev/null
@@ -1,36 +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.geocoder;
-
-import org.apache.streampipes.model.graph.DataProcessorInvocation;
-import org.apache.streampipes.wrapper.params.binding.EventProcessorBindingParams;
-
-public class GoogleMapsGeocodingParameters extends EventProcessorBindingParams {
-
- private String placeField;
-
- public GoogleMapsGeocodingParameters(DataProcessorInvocation graph,
- String placeField) {
- super(graph);
- this.placeField = placeField;
- }
-
- public String getPlaceField() {
- return placeField;
- }
-}