diff --git a/src/policy/src/main/java/eu/teraflow/policy/model/BooleanOperator.java b/src/policy/src/main/java/eu/teraflow/policy/model/BooleanOperator.java index 4de1743d0178d5f61737a2830b49370068156c8f..7231c02e5895ba08379abe39454259b79e1cc90a 100644 --- a/src/policy/src/main/java/eu/teraflow/policy/model/BooleanOperator.java +++ b/src/policy/src/main/java/eu/teraflow/policy/model/BooleanOperator.java @@ -1,3 +1,19 @@ +/* +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* 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 eu.teraflow.policy.model; public enum BooleanOperator { diff --git a/src/policy/src/main/java/eu/teraflow/policy/model/NumericalOperator.java b/src/policy/src/main/java/eu/teraflow/policy/model/NumericalOperator.java index ccd424a02ba771edc215ee92e7bfc0125a5b5c27..48029e550acf53f7b23816e3b2c409701ce03f30 100644 --- a/src/policy/src/main/java/eu/teraflow/policy/model/NumericalOperator.java +++ b/src/policy/src/main/java/eu/teraflow/policy/model/NumericalOperator.java @@ -1,3 +1,19 @@ +/* +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* 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 eu.teraflow.policy.model; public enum NumericalOperator { diff --git a/src/policy/src/main/java/eu/teraflow/policy/model/PolicyRuleActionEnum.java b/src/policy/src/main/java/eu/teraflow/policy/model/PolicyRuleActionEnum.java index 317daa02939bfe21c267b758999bae9d20f294af..7d9354a05ff42b556caefdcf635234d706da8352 100644 --- a/src/policy/src/main/java/eu/teraflow/policy/model/PolicyRuleActionEnum.java +++ b/src/policy/src/main/java/eu/teraflow/policy/model/PolicyRuleActionEnum.java @@ -1,3 +1,19 @@ +/* +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* 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 eu.teraflow.policy.model; public enum PolicyRuleActionEnum { diff --git a/src/policy/src/main/java/eu/teraflow/policy/model/PolicyRuleBasic.java b/src/policy/src/main/java/eu/teraflow/policy/model/PolicyRuleBasic.java new file mode 100644 index 0000000000000000000000000000000000000000..898b3a48c5e2215ca53330f7fa6cd9dc637b9abf --- /dev/null +++ b/src/policy/src/main/java/eu/teraflow/policy/model/PolicyRuleBasic.java @@ -0,0 +1,82 @@ +/* +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* 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 eu.teraflow.policy.model; + +import eu.teraflow.policy.common.Util; +import java.util.List; + +public class PolicyRuleBasic { + + private final String policyRuleId; + private final PolicyRuleState policyRuleState; + private final int priority; + private final List<PolicyRuleCondition> policyRuleConditions; + private final BooleanOperator booleanOperator; + private final List<PolicyRuleAction> policyRuleActions; + + public PolicyRuleBasic( + String policyRuleId, + PolicyRuleState policyRuleState, + int priority, + List<PolicyRuleCondition> policyRuleConditions, + BooleanOperator booleanOperator, + List<PolicyRuleAction> policyRuleActions) { + this.policyRuleId = policyRuleId; + this.policyRuleState = policyRuleState; + this.priority = priority; + this.policyRuleConditions = policyRuleConditions; + this.booleanOperator = booleanOperator; + this.policyRuleActions = policyRuleActions; + } + + public String getPolicyRuleId() { + return policyRuleId; + } + + public PolicyRuleState getPolicyRuleState() { + return policyRuleState; + } + + public int getPriority() { + return priority; + } + + public List<PolicyRuleCondition> getPolicyRuleConditions() { + return policyRuleConditions; + } + + public BooleanOperator getBooleanOperator() { + return booleanOperator; + } + + public List<PolicyRuleAction> getPolicyRuleActions() { + return policyRuleActions; + } + + @Override + public String toString() { + return String.format( + "%s:{policyRuleId:\"%s\", %s, priority:%d, [%s], booleanOperator:\"%s\", [%s]}", + getClass().getSimpleName(), + policyRuleId, + policyRuleState, + priority, + Util.toString(policyRuleConditions), + booleanOperator.toString(), + Util.toString(policyRuleActions)); + } +} diff --git a/src/policy/src/main/java/eu/teraflow/policy/model/PolicyRuleDevice.java b/src/policy/src/main/java/eu/teraflow/policy/model/PolicyRuleDevice.java new file mode 100644 index 0000000000000000000000000000000000000000..46151ea5c50f5b2f1b6542098594813e5cbc2a50 --- /dev/null +++ b/src/policy/src/main/java/eu/teraflow/policy/model/PolicyRuleDevice.java @@ -0,0 +1,45 @@ +/* +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* 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 eu.teraflow.policy.model; + +import eu.teraflow.policy.common.Util; +import java.util.List; + +public class PolicyRuleDevice { + + private final PolicyRuleBasic policyRuleBasic; + private final List<String> deviceIds; + + public PolicyRuleDevice(PolicyRuleBasic policyRuleBasic, List<String> deviceIds) { + this.policyRuleBasic = policyRuleBasic; + this.deviceIds = deviceIds; + } + + public PolicyRuleBasic getPolicyRuleBasic() { + return policyRuleBasic; + } + + public List<String> getDeviceIds() { + return deviceIds; + } + + @Override + public String toString() { + return String.format( + "%s:{%s, [%s]}", getClass().getSimpleName(), policyRuleBasic, Util.toString(deviceIds)); + } +} diff --git a/src/policy/src/main/java/eu/teraflow/policy/model/PolicyRuleService.java b/src/policy/src/main/java/eu/teraflow/policy/model/PolicyRuleService.java new file mode 100644 index 0000000000000000000000000000000000000000..ac0710d8590153ef8df1e9dbeb6465eac88c3fa1 --- /dev/null +++ b/src/policy/src/main/java/eu/teraflow/policy/model/PolicyRuleService.java @@ -0,0 +1,54 @@ +/* +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* 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 eu.teraflow.policy.model; + +import eu.teraflow.policy.common.Util; +import eu.teraflow.policy.context.model.ServiceId; +import java.util.List; + +public class PolicyRuleService { + + private final PolicyRuleBasic policyRuleBasic; + private final ServiceId serviceId; + private final List<String> deviceIds; + + public PolicyRuleService( + PolicyRuleBasic policyRuleBasic, ServiceId serviceId, List<String> deviceIds) { + this.policyRuleBasic = policyRuleBasic; + this.serviceId = serviceId; + this.deviceIds = deviceIds; + } + + public PolicyRuleBasic getPolicyRuleBasic() { + return policyRuleBasic; + } + + public ServiceId getServiceId() { + return serviceId; + } + + public List<String> getDeviceIds() { + return deviceIds; + } + + @Override + public String toString() { + return String.format( + "%s:{%s, %s, [%s]}", + getClass().getSimpleName(), policyRuleBasic, serviceId, Util.toString(deviceIds)); + } +}