15 changed files with 108 additions and 72 deletions
@ -0,0 +1,33 @@ |
|||
/** |
|||
* Copyright © 2016-2024 The Thingsboard Authors |
|||
* |
|||
* 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.thingsboard.server.common.data; |
|||
|
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
|
|||
public interface HasDebugMode { |
|||
|
|||
boolean isDebugFailures(); |
|||
|
|||
void setDebugFailures(boolean debugFailures); |
|||
|
|||
boolean isDebugAll(); |
|||
|
|||
void setDebugAll(boolean debugAll); |
|||
|
|||
long getDebugAllUntil(); |
|||
|
|||
void setDebugAllUntil(long debugAllUntil); |
|||
} |
|||
@ -1,45 +0,0 @@ |
|||
/** |
|||
* Copyright © 2016-2024 The Thingsboard Authors |
|||
* |
|||
* 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.thingsboard.server.common.data.rule; |
|||
|
|||
import org.thingsboard.server.common.data.msg.TbNodeConnectionType; |
|||
|
|||
import java.util.Set; |
|||
|
|||
public final class RuleNodeDebugUtil { |
|||
private RuleNodeDebugUtil() {} |
|||
|
|||
public static boolean isDebugAllAvailable(RuleNode ruleNode) { |
|||
return ruleNode.getDebugAllUntil() > System.currentTimeMillis(); |
|||
} |
|||
|
|||
public static boolean isDebugAvailable(RuleNode ruleNode, String nodeConnection) { |
|||
return isDebugAllAvailable(ruleNode) || ruleNode.isDebugFailures() && TbNodeConnectionType.FAILURE.equals(nodeConnection); |
|||
} |
|||
|
|||
public static boolean isDebugFailuresAvailable(RuleNode ruleNode, Set<String> nodeConnections) { |
|||
return isDebugFailuresAvailable(ruleNode) && nodeConnections.contains(TbNodeConnectionType.FAILURE); |
|||
} |
|||
|
|||
public static boolean isDebugFailuresAvailable(RuleNode ruleNode, String nodeConnection) { |
|||
return isDebugFailuresAvailable(ruleNode) && TbNodeConnectionType.FAILURE.equals(nodeConnection); |
|||
} |
|||
|
|||
public static boolean isDebugFailuresAvailable(RuleNode ruleNode) { |
|||
return ruleNode.isDebugFailures() || isDebugAllAvailable(ruleNode); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,43 @@ |
|||
/** |
|||
* Copyright © 2016-2024 The Thingsboard Authors |
|||
* |
|||
* 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.thingsboard.common.util; |
|||
|
|||
import org.thingsboard.server.common.data.HasDebugMode; |
|||
import org.thingsboard.server.common.data.msg.TbNodeConnectionType; |
|||
|
|||
import java.util.Set; |
|||
|
|||
public final class DebugModeUtil { |
|||
private DebugModeUtil() { |
|||
} |
|||
|
|||
public static boolean isDebugAllAvailable(HasDebugMode debugMode) { |
|||
return debugMode.getDebugAllUntil() > System.currentTimeMillis(); |
|||
} |
|||
|
|||
public static boolean isDebugAvailable(HasDebugMode debugMode, String nodeConnection) { |
|||
return isDebugAllAvailable(debugMode) || debugMode.isDebugFailures() && TbNodeConnectionType.FAILURE.equals(nodeConnection); |
|||
} |
|||
|
|||
public static boolean isDebugFailuresAvailable(HasDebugMode debugMode, Set<String> nodeConnections) { |
|||
return isDebugFailuresAvailable(debugMode) && nodeConnections.contains(TbNodeConnectionType.FAILURE); |
|||
} |
|||
|
|||
private static boolean isDebugFailuresAvailable(HasDebugMode debugMode) { |
|||
return debugMode.isDebugFailures() || isDebugAllAvailable(debugMode); |
|||
} |
|||
|
|||
} |
|||
Loading…
Reference in new issue