Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

custom services samples #1

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

custom services samples #1

wants to merge 4 commits into from

Conversation

marco-porru
Copy link
Owner

No description provided.

@@ -0,0 +1,233 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Copyright (c) 2019 SAP SE or an affiliate company. All rights reserved.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The date is invalid (2019).
By the way, should we add the copyright to all files?


public class ConfigurationHandler {
private static final Logger LOGGER = LoggerFactory.getLogger(ConfigurationHandler.class); // logger
private static final String BASE_PATH = "./../edgeservices/"; // base path for custom configuration, same of other

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"same of other" is unclear to me what you mean.

private static final Logger LOGGER = LoggerFactory.getLogger(ConfigurationHandler.class); // logger
private static final String BASE_PATH = "./../edgeservices/"; // base path for custom configuration, same of other
// services
private static final String UNIFORM_PATH_SEPARATOR = "/"; // linux/windows valid file separator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not using the already generic File.separator constant?
https://docs.oracle.com/javase/7/docs/api/java/io/File.html#separator

defaultConfiguration = loadDefaultConfiguration();
}
// existing file paths
String jsonFile = BASE_PATH + serviceName + "/" + serviceName + ".json";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use File.separator, or reuse the constant you have defined at the top of the file.

}
// existing file paths
String jsonFile = BASE_PATH + serviceName + "/" + serviceName + ".json";
String fingerprintFile = BASE_PATH + serviceName + "/" + serviceName + "_fingerprint.txt";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use File.separator, or reuse the constant you have defined at the top of the file.

Comment on lines 11 to 16
Float variance;
Float pressureScale;
Boolean ingestionEnabled;
Boolean filterMeasurements;
Boolean filterCalculation;
List<MessageFilter> filteredObjects;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better use private access

Comment on lines 7 to 8
String externalConfigurationTopic;
String configurationFile;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better use private access

Comment on lines 4 to 6
String capabilityAlternateId;
String sensorAlternateId;
String sensorTypeAlternateId;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better use private access

Comment on lines +32 to +34
TypeReference<HashMap<String, Object>> typeRef = new TypeReference<HashMap<String, Object>>() {
};
Map<String, Object> originalMassageMap = mapper.readValue(mqttMessage.toString(), typeRef);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better:

Map<String, Object > originalMassageMap = mapper.readValue(
    mqttMessage.toString(), TypeFactory.mapType(HashMap.class, String.class, Object.class));

}

public static void sendMessage(String topic, String content) {
MqttMessage message = null;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

= null is redundant here, you can remove it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants