From a16c82bebd7a6b8a289263a7a5ea1f8507bbae2c Mon Sep 17 00:00:00 2001 From: charithag Date: Fri, 7 May 2021 17:47:25 +0530 Subject: [PATCH] Allow dynamic control of operations --- .../dto/operation/mgt/CommandOperation.java | 8 ++++---- .../dto/operation/mgt/ConfigOperation.java | 18 +++++++----------- .../dto/operation/mgt/PolicyOperation.java | 14 +++++++------- .../dto/operation/mgt/ProfileOperation.java | 9 ++++----- .../core/operation/mgt/CommandOperation.java | 7 ++++--- .../core/operation/mgt/ConfigOperation.java | 19 +++++++++---------- .../core/operation/mgt/PolicyOperation.java | 9 +++++---- .../core/operation/mgt/ProfileOperation.java | 11 ++++++----- 8 files changed, 46 insertions(+), 49 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dto/operation/mgt/CommandOperation.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dto/operation/mgt/CommandOperation.java index bc132a9b209..c7eb730c4ee 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dto/operation/mgt/CommandOperation.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dto/operation/mgt/CommandOperation.java @@ -22,6 +22,10 @@ public class CommandOperation extends Operation { private boolean enabled; + public CommandOperation() { + setControl(Control.NO_REPEAT); + } + public boolean isEnabled() { return enabled; } @@ -34,8 +38,4 @@ public class CommandOperation extends Operation { return Type.COMMAND; } - public Control getControl(){ - return Control.NO_REPEAT; - } - } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dto/operation/mgt/ConfigOperation.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dto/operation/mgt/ConfigOperation.java index c2be65a3724..28116d5dc6d 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dto/operation/mgt/ConfigOperation.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dto/operation/mgt/ConfigOperation.java @@ -23,10 +23,11 @@ import java.util.List; public class ConfigOperation extends Operation { - private List properties; + private final List properties; public ConfigOperation() { - properties = new ArrayList(); + properties = new ArrayList<>(); + setControl(Control.REPEAT); } public List getConfigProperties() { @@ -37,6 +38,10 @@ public class ConfigOperation extends Operation { properties.add(new Property(name, value, type)); } + public Type getType() { + return Type.CONFIG; + } + public static class Property { private String name; private Object value; @@ -73,13 +78,4 @@ public class ConfigOperation extends Operation { } } - public Type getType() { - return Type.CONFIG; - } - - - public Control getControl(){ - return Control.REPEAT; - } - } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dto/operation/mgt/PolicyOperation.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dto/operation/mgt/PolicyOperation.java index dc6ae4dd785..bc93bcf0f8b 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dto/operation/mgt/PolicyOperation.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dto/operation/mgt/PolicyOperation.java @@ -19,7 +19,13 @@ package org.wso2.carbon.device.mgt.core.dto.operation.mgt; import java.util.List; -public class PolicyOperation extends Operation{ +public class PolicyOperation extends Operation { + + private List profileOperations; + + public PolicyOperation() { + setControl(Control.REPEAT); + } public List getProfileOperations() { return profileOperations; @@ -29,10 +35,4 @@ public class PolicyOperation extends Operation{ this.profileOperations = profileOperations; } - private List profileOperations; - - public Control getControl(){ - return Control.REPEAT; - } - } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dto/operation/mgt/ProfileOperation.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dto/operation/mgt/ProfileOperation.java index 107cf091d70..9e3db16f2ee 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dto/operation/mgt/ProfileOperation.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dto/operation/mgt/ProfileOperation.java @@ -22,13 +22,12 @@ import java.io.Serializable; public class ProfileOperation extends ConfigOperation implements Serializable { - public Type getType() { - return Type.PROFILE; + public ProfileOperation() { + super(); } - - public Control getControl(){ - return Control.REPEAT; + public Type getType() { + return Type.PROFILE; } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/CommandOperation.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/CommandOperation.java index 3a9ecefca33..618c05adf3a 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/CommandOperation.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/CommandOperation.java @@ -24,6 +24,10 @@ public class CommandOperation extends Operation { private boolean enabled; + public CommandOperation() { + setControl(Control.NO_REPEAT); + } + public boolean isEnabled() { return enabled; } @@ -35,8 +39,5 @@ public class CommandOperation extends Operation { public Type getType() { return Type.COMMAND; } - public Control getControl(){ - return Control.NO_REPEAT; - } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/ConfigOperation.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/ConfigOperation.java index 69d8aafc4a7..753b170a1b5 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/ConfigOperation.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/ConfigOperation.java @@ -21,8 +21,6 @@ package org.wso2.carbon.device.mgt.core.operation.mgt; import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; public class ConfigOperation extends Operation { @@ -38,6 +36,15 @@ public class ConfigOperation extends Operation { properties.add(new Property(name, value, type)); }*/ + public ConfigOperation() { + //properties = new ArrayList<>(); + setControl(Control.REPEAT); + } + + public Type getType() { + return Type.CONFIG; + } + public static class Property implements Serializable { private String name; private Object value; @@ -74,12 +81,4 @@ public class ConfigOperation extends Operation { } } - public Type getType() { - return Type.CONFIG; - } - - public Control getControl(){ - return Control.REPEAT; - } - } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/PolicyOperation.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/PolicyOperation.java index 6b36492a83a..47ca55f95e0 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/PolicyOperation.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/PolicyOperation.java @@ -18,6 +18,7 @@ package org.wso2.carbon.device.mgt.core.operation.mgt; import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; + import java.util.List; public class PolicyOperation extends Operation { @@ -25,6 +26,10 @@ public class PolicyOperation extends Operation { public static final String POLICY_OPERATION_CODE = "POLICY_BUNDLE"; private List profileOperations; + public PolicyOperation() { + setControl(Control.REPEAT); + } + public List getProfileOperations() { return profileOperations; } @@ -33,8 +38,4 @@ public class PolicyOperation extends Operation { this.profileOperations = profileOperations; } - public Control getControl(){ - return Control.REPEAT; - } - } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/ProfileOperation.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/ProfileOperation.java index 34235246668..ac1082317b6 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/ProfileOperation.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/ProfileOperation.java @@ -19,21 +19,21 @@ package org.wso2.carbon.device.mgt.core.operation.mgt; import java.io.Serializable; -import java.util.ArrayList; import java.util.List; public class ProfileOperation extends ConfigOperation implements Serializable { + private static final long serialVersionUID = -3322674908775087365L; private List correctiveActionIds; private List reactiveActionIds; - public Type getType() { - return Type.PROFILE; + public ProfileOperation() { + super(); } - public Control getControl(){ - return Control.REPEAT; + public Type getType() { + return Type.PROFILE; } public List getCorrectiveActionIds() { @@ -51,4 +51,5 @@ public class ProfileOperation extends ConfigOperation implements Serializable { public void setReactiveActionIds(List reactiveActionIds) { this.reactiveActionIds = reactiveActionIds; } + }