org.neo4j.driver.internal.messaging.request.MessageWithMetadata Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of neo4j-java-driver Show documentation
Show all versions of neo4j-java-driver Show documentation
Access to the Neo4j graph database through Java
/*
* Copyright (c) "Neo4j"
* Neo4j Sweden AB [https://neo4j.com]
*
* Licensed 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.neo4j.driver.internal.messaging.request;
import static org.neo4j.driver.Values.value;
import java.util.Map;
import org.neo4j.driver.Value;
import org.neo4j.driver.internal.GqlNotificationConfig;
import org.neo4j.driver.internal.InternalNotificationSeverity;
import org.neo4j.driver.internal.messaging.Message;
abstract class MessageWithMetadata implements Message {
static final String NOTIFICATIONS_MINIMUM_SEVERITY = "notifications_minimum_severity";
static final String NOTIFICATIONS_DISABLED_CATEGORIES = "notifications_disabled_categories";
static final String NOTIFICATIONS_DISABLED_CLASSIFICATIONS = "notifications_disabled_classifications";
private final Map metadata;
public MessageWithMetadata(Map metadata) {
this.metadata = metadata;
}
public Map metadata() {
return metadata;
}
static void appendNotificationConfig(
Map result, GqlNotificationConfig config, boolean legacyNotifications) {
if (config != null) {
var severity = (InternalNotificationSeverity) config.minimumSeverity();
if (severity != null) {
result.put(NOTIFICATIONS_MINIMUM_SEVERITY, value(severity.type().toString()));
}
var disabledClassifications = config.disabledClassifications();
if (disabledClassifications != null) {
var list =
disabledClassifications.stream().map(Object::toString).toList();
result.put(
legacyNotifications
? NOTIFICATIONS_DISABLED_CATEGORIES
: NOTIFICATIONS_DISABLED_CLASSIFICATIONS,
value(list));
}
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy