Fix test failures

corrective-policy
Pahansith 5 years ago
parent e486db868e
commit 684ff5df7f

@ -19,8 +19,11 @@
package org.wso2.carbon.device.mgt.core.operation.mgt; package org.wso2.carbon.device.mgt.core.operation.mgt;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
public class ProfileOperation extends ConfigOperation implements Serializable { public class ProfileOperation extends ConfigOperation implements Serializable {
private List<Integer> correctiveActionIds = new ArrayList<>();
public Type getType() { public Type getType() {
return Type.PROFILE; return Type.PROFILE;
@ -30,4 +33,11 @@ public class ProfileOperation extends ConfigOperation implements Serializable {
return Control.REPEAT; return Control.REPEAT;
} }
public List<Integer> getCorrectiveActionIds() {
return correctiveActionIds;
}
public void setCorrectiveActionIds(List<Integer> correctiveActionIds) {
this.correctiveActionIds = correctiveActionIds;
}
} }

@ -211,9 +211,13 @@ public class PolicyManagerImpl implements PolicyManager {
// Checks for the existing features // Checks for the existing features
for (ProfileFeature feature : updatedFeatureList) { for (ProfileFeature feature : updatedFeatureList) {
updatedCorrectiveActionsMap.put(feature.getId(), feature.getCorrectiveActions()); if (feature.getCorrectiveActions() != null) {
updatedCorrectiveActionsMap.put(feature.getId(), feature.getCorrectiveActions());
}
for (ProfileFeature fe : existingProfileFeaturesList) { for (ProfileFeature fe : existingProfileFeaturesList) {
existingCorrectiveActionsMap.put(fe.getId(), fe.getCorrectiveActions()); if (fe.getCorrectiveActions() != null) {
existingCorrectiveActionsMap.put(fe.getId(), fe.getCorrectiveActions());
}
if (feature.getFeatureCode().equalsIgnoreCase(fe.getFeatureCode())) { if (feature.getFeatureCode().equalsIgnoreCase(fe.getFeatureCode())) {
existingFeaturesList.add(feature); existingFeaturesList.add(feature);
temp.add(feature.getFeatureCode()); temp.add(feature.getFeatureCode());
@ -722,12 +726,16 @@ public class PolicyManagerImpl implements PolicyManager {
policy.setDevices(deviceList); policy.setDevices(deviceList);
try { try {
// PolicyManagementDAOFactory.openConnection();
Profile profile = profileManager.getProfile(policy.getProfileId()); Profile profile = profileManager.getProfile(policy.getProfileId());
policy.setProfile(profile); policy.setProfile(profile);
PolicyManagementDAOFactory.openConnection();
for (ProfileFeature profileFeature : policy.getProfile().getProfileFeaturesList()) { for (ProfileFeature profileFeature : policy.getProfile().getProfileFeaturesList()) {
profileFeature.setCorrectiveActions(policyDAO.getCorrectiveActionsOfPolicy(policyId, profileFeature.getId())); List<CorrectiveAction> correctiveActionsOfPolicy = policyDAO
.getCorrectiveActionsOfPolicy(policyId, profileFeature.getId());
if (correctiveActionsOfPolicy != null) {
profileFeature.setCorrectiveActions(correctiveActionsOfPolicy);
}
} }
} catch (ProfileManagementException e) { } catch (ProfileManagementException e) {
throw new PolicyManagementException("Error occurred while getting the profile related to policy ID (" + throw new PolicyManagementException("Error occurred while getting the profile related to policy ID (" +
@ -739,6 +747,10 @@ public class PolicyManagerImpl implements PolicyManager {
} catch (PolicyManagerDAOException e) { } catch (PolicyManagerDAOException e) {
throw new PolicyManagementException("Error occurred while getting the corrective " + throw new PolicyManagementException("Error occurred while getting the corrective " +
"actions related to policy ID (" + policyId + ")", e); "actions related to policy ID (" + policyId + ")", e);
} catch (SQLException e) {
e.printStackTrace();
} finally {
PolicyManagementDAOFactory.closeConnection();
} }

@ -66,6 +66,7 @@ public final class PolicyManagementConstants {
public static final String CORRECTIVE_POLICY_TYPE = "CORRECTIVE"; public static final String CORRECTIVE_POLICY_TYPE = "CORRECTIVE";
public static final String POLICY_CORRECTIVE_ACTION_TYPE = "POLICY"; public static final String POLICY_CORRECTIVE_ACTION_TYPE = "POLICY";
public static final String CORRECTIVE_POLICY_FEATURE_CODE = "CORRECTIVE_POLICY"; public static final String CORRECTIVE_POLICY_FEATURE_CODE = "CORRECTIVE_POLICY";
public static final String CORRECTIVE_POLICY_LIST = "CORRECTIVE_ACTIONS";
/** /**
Caller would reference the constants using PolicyManagementConstants.DEVICE_CONFIG_XML_NAME, Caller would reference the constants using PolicyManagementConstants.DEVICE_CONFIG_XML_NAME,

@ -195,33 +195,70 @@ public class PolicyManagerUtil {
} }
private static void setCorrectiveActions(List<ProfileFeature> features, private static void setCorrectiveActions(List<ProfileFeature> features,
PolicyOperation policyOperation, Policy policy) throws PolicyTransformException { PolicyOperation policyOperation, Policy policy)
List<ProfileFeature> effectiveFeatures = new ArrayList<>(features); throws PolicyTransformException {
ProfileOperation correctiveOperations = new ProfileOperation();
correctiveOperations.setCode(PolicyManagementConstants.CORRECTIVE_POLICY_LIST);
for (ProfileFeature effectiveFeature : features) { for (ProfileFeature effectiveFeature : features) {
if (effectiveFeature.getCorrectiveActions() != null) { if (effectiveFeature.getCorrectiveActions() != null) {
for (CorrectiveAction correctiveAction : effectiveFeature.getCorrectiveActions()) { for (CorrectiveAction correctiveAction : effectiveFeature.getCorrectiveActions()) {
if (PolicyManagementConstants.POLICY_CORRECTIVE_ACTION_TYPE if (PolicyManagementConstants.POLICY_CORRECTIVE_ACTION_TYPE
.equalsIgnoreCase(correctiveAction.getActionType())) { .equalsIgnoreCase(correctiveAction.getActionType())) {
PolicyAdministratorPoint pap = new PolicyAdministratorPointImpl(); PolicyAdministratorPoint pap = new PolicyAdministratorPointImpl();
try { try {
Policy correctivePolicy = pap.getPolicy(correctiveAction.getPolicyId()); Policy correctivePolicy = pap.getPolicy(correctiveAction.getPolicyId());
if (correctivePolicy == null || !PolicyManagementConstants.CORRECTIVE_POLICY_TYPE if (correctivePolicy == null || !PolicyManagementConstants
.equalsIgnoreCase(correctivePolicy.getPolicyType() )) { .CORRECTIVE_POLICY_TYPE.equalsIgnoreCase(correctivePolicy
String msg = "No corrective policy was found for the policy " + policy.getPolicyName() + .getPolicyType())) {
" and policy ID " + policy.getId(); String msg = "No corrective policy was found for the policy " +
policy.getPolicyName() + " and policy ID " + policy.getId();
log.error(msg); log.error(msg);
throw new PolicyTransformException(msg); throw new PolicyTransformException(msg);
} else { } else {
List<ProfileOperation> correctiveProfileOperations = createProfileOperations( createCorrectiveProfileOperations(correctivePolicy, correctiveOperations);
correctivePolicy.getProfile().getProfileFeaturesList()); policyOperation.getProfileOperations().add(correctiveOperations);
}
} catch (PolicyManagementException e) {
String msg = "Error occurred while retrieving corrective policy for policy " +
policy.getPolicyName() + " and policy ID " + policy.getId();
log.error(msg, e);
throw new PolicyTransformException(msg, e);
}
}
}
/*for (CorrectiveAction correctiveAction : effectiveFeature.getCorrectiveActions()) {
if (PolicyManagementConstants.POLICY_CORRECTIVE_ACTION_TYPE
.equalsIgnoreCase(correctiveAction.getActionType())) {
PolicyAdministratorPoint pap = new PolicyAdministratorPointImpl();
try {
Policy correctivePolicy = pap.getPolicy(correctiveAction.getPolicyId());
if (correctivePolicy == null || !PolicyManagementConstants
.CORRECTIVE_POLICY_TYPE.equalsIgnoreCase(correctivePolicy
.getPolicyType() )) {
String msg = "No corrective policy was found for the policy " +
policy.getPolicyName() + " and policy ID " + policy.getId();
log.error(msg);
throw new PolicyTransformException(msg);
} else {
*//*List<ProfileOperation> correctiveProfileOperations =
createProfileOperations();*//*
createCorrectiveProfileOperations(correctivePolicy.getProfile()
.getProfileFeaturesList());
ProfileFeature correctivePolicyFeature = new ProfileFeature(); ProfileFeature correctivePolicyFeature = new ProfileFeature();
correctivePolicyFeature.setProfileId(correctivePolicy.getProfileId()); correctivePolicyFeature.setProfileId(correctivePolicy.getProfileId());
correctivePolicyFeature.setContent(new Gson().toJson(correctiveProfileOperations)); correctivePolicyFeature.setContent(new Gson()
correctivePolicyFeature.setDeviceType(correctivePolicy.getProfile().getDeviceType()); .toJson(correctiveProfileOperations));
correctivePolicyFeature.setDeviceType(correctivePolicy
.getProfile().getDeviceType());
correctivePolicyFeature.setFeatureCode( correctivePolicyFeature.setFeatureCode(
PolicyManagementConstants.CORRECTIVE_POLICY_FEATURE_CODE); PolicyManagementConstants.CORRECTIVE_POLICY_FEATURE_CODE);
correctivePolicyFeature.setId(correctivePolicy.getId()); correctivePolicyFeature.setId(correctivePolicy.getId());
List<ProfileOperation> profileOperations = policyOperation.getProfileOperations();
effectiveFeatures.add(correctivePolicyFeature); effectiveFeatures.add(correctivePolicyFeature);
} }
} catch (PolicyManagementException e) { } catch (PolicyManagementException e) {
@ -230,15 +267,39 @@ public class PolicyManagerUtil {
log.error(msg, e); log.error(msg, e);
throw new PolicyTransformException(msg, e); throw new PolicyTransformException(msg, e);
} }
// Currently only supported POLICY corrective action type so the break is added. This should be // Currently only supported POLICY corrective action type so the break
// removed when we start supporting other corrective action types // is added. This should be removed when we start supporting other
// corrective action types
break; break;
} }
} }*/
} }
} }
} }
private static void createCorrectiveProfileOperations(Policy correctivePolicy,
ProfileOperation correctiveOperationList) {
ProfileOperation profileOperation = new ProfileOperation();
profileOperation.setId(correctivePolicy.getId());
profileOperation.setCode(PolicyManagementConstants.CORRECTIVE_POLICY_FEATURE_CODE);
profileOperation.setEnabled(true);
profileOperation.setStatus(org.wso2.carbon.device.mgt.common.operation.mgt.Operation.Status.PENDING);
profileOperation.setType(org.wso2.carbon.device.mgt.common.operation.mgt.Operation.Type.PROFILE);
String correctivePayload =(String) correctiveOperationList.getPayLoad();
if (correctivePayload == null) {
correctivePayload = "";
}
List<ProfileOperation> profileOperations = createProfileOperations(correctivePolicy
.getProfile().getProfileFeaturesList());
String payload = new Gson().toJson(profileOperations);
correctiveOperationList.setPayLoad(correctivePayload.concat(payload));
}
public static List<ProfileOperation> createProfileOperations(List<ProfileFeature> effectiveFeatures) { public static List<ProfileOperation> createProfileOperations(List<ProfileFeature> effectiveFeatures) {
List<ProfileOperation> profileOperations = new ArrayList<>(); List<ProfileOperation> profileOperations = new ArrayList<>();
@ -249,6 +310,9 @@ public class PolicyManagerUtil {
profileOperation.setStatus(org.wso2.carbon.device.mgt.common.operation.mgt.Operation.Status.PENDING); profileOperation.setStatus(org.wso2.carbon.device.mgt.common.operation.mgt.Operation.Status.PENDING);
profileOperation.setType(org.wso2.carbon.device.mgt.common.operation.mgt.Operation.Type.PROFILE); profileOperation.setType(org.wso2.carbon.device.mgt.common.operation.mgt.Operation.Type.PROFILE);
profileOperation.setPayLoad(feature.getContent()); profileOperation.setPayLoad(feature.getContent());
for (CorrectiveAction correctiveAction : feature.getCorrectiveActions()) {
profileOperation.getCorrectiveActionIds().add(correctiveAction.getPolicyId());
}
profileOperations.add(profileOperation); profileOperations.add(profileOperation);
} }
return profileOperations; return profileOperations;

@ -77,29 +77,6 @@ CREATE TABLE IF NOT EXISTS `WSO2CDM`.`DM_POLICY` (
ENGINE = InnoDB ENGINE = InnoDB
DEFAULT CHARACTER SET = latin1; DEFAULT CHARACTER SET = latin1;
-- -----------------------------------------------------
-- Table `WSO2CDM`.`DM_POLICY_CORRECTIVE_ACTION`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `WSO2CDM`.`DM_POLICY_CORRECTIVE_ACTION` (
`ID` INT(11) NOT NULL AUTO_INCREMENT,
`ACTION_TYPE` VARCHAR(45) NOT NULL,
`CORRECTIVE_POLICY_ID` INT(11) DEFAULT NULL,
`POLICY_ID` INT(11) NOT NULL,
`FEATURE_ID` INT(11) NOT NULL,
PRIMARY KEY (ID),
CONSTRAINT FK_DM_POLICY_DM_POLICY_CORRECTIVE_ACTION
FOREIGN KEY (POLICY_ID)
REFERENCES DM_POLICY (ID)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT FK_DM_POLICY_DM_POLICY_CORRECTIVE_ACTION
FOREIGN KEY (FEATURE_ID)
REFERENCES DM_PROFILE_FEATURES (ID)
ON DELETE NO ACTION
ON UPDATE NO ACTION
)ENGINE = InnoDB
DEFAULT CHARACTER SET = latin1;
-- ----------------------------------------------------- -- -----------------------------------------------------
-- Table `WSO2CDM`.`DM_DATE` -- Table `WSO2CDM`.`DM_DATE`
@ -227,6 +204,28 @@ CREATE TABLE IF NOT EXISTS `WSO2CDM`.`DM_PROFILE_FEATURES` (
ENGINE = InnoDB ENGINE = InnoDB
DEFAULT CHARACTER SET = latin1; DEFAULT CHARACTER SET = latin1;
-- -----------------------------------------------------
-- Table `WSO2CDM`.`DM_POLICY_CORRECTIVE_ACTION`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `WSO2CDM`.`DM_POLICY_CORRECTIVE_ACTION` (
`ID` INT(11) NOT NULL AUTO_INCREMENT,
`ACTION_TYPE` VARCHAR(45) NOT NULL,
`CORRECTIVE_POLICY_ID` INT(11) DEFAULT NULL,
`POLICY_ID` INT(11) NOT NULL,
`FEATURE_ID` INT(11) NOT NULL,
PRIMARY KEY (ID),
CONSTRAINT FK_DM_POLICY_DM_POLICY_CORRECTIVE_ACTION
FOREIGN KEY (POLICY_ID)
REFERENCES DM_POLICY (ID)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT FK_DM_POLICY_DM_POLICY_CORRECTIVE_ACTION_FEATURE
FOREIGN KEY (FEATURE_ID)
REFERENCES DM_PROFILE_FEATURES (ID)
ON DELETE NO ACTION
ON UPDATE NO ACTION
)ENGINE = InnoDB
DEFAULT CHARACTER SET = latin1;
-- ----------------------------------------------------- -- -----------------------------------------------------
-- Table `WSO2CDM`.`DM_ROLE_POLICY` -- Table `WSO2CDM`.`DM_ROLE_POLICY`

@ -194,25 +194,6 @@ CREATE TABLE IF NOT EXISTS DM_POLICY (
ON UPDATE NO ACTION ON UPDATE NO ACTION
); );
CREATE TABLE IF NOT EXISTS DM_POLICY_CORRECTIVE_ACTION (
ID INT(11) NOT NULL AUTO_INCREMENT,
ACTION_TYPE VARCHAR(45) NOT NULL,
CORRECTIVE_POLICY_ID INT(11) DEFAULT NULL,
POLICY_ID INT(11) NOT NULL,
FEATURE_ID INT(11) NOT NULL,
PRIMARY KEY (ID),
CONSTRAINT FK_DM_POLICY_DM_POLICY_CORRECTIVE_ACTION
FOREIGN KEY (POLICY_ID)
REFERENCES DM_POLICY (ID)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT FK_DM_POLICY_DM_POLICY_CORRECTIVE_ACTION
FOREIGN KEY (FEATURE_ID)
REFERENCES DM_PROFILE_FEATURES (ID)
ON DELETE NO ACTION
ON UPDATE NO ACTION
);
CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY ( CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY (
ID INT(11) NOT NULL AUTO_INCREMENT , ID INT(11) NOT NULL AUTO_INCREMENT ,
DEVICE_ID INT(11) NOT NULL , DEVICE_ID INT(11) NOT NULL ,
@ -259,6 +240,25 @@ CREATE TABLE IF NOT EXISTS DM_PROFILE_FEATURES (
ON UPDATE NO ACTION ON UPDATE NO ACTION
); );
CREATE TABLE IF NOT EXISTS DM_POLICY_CORRECTIVE_ACTION (
ID INT(11) NOT NULL AUTO_INCREMENT,
ACTION_TYPE VARCHAR(45) NOT NULL,
CORRECTIVE_POLICY_ID INT(11) DEFAULT NULL,
POLICY_ID INT(11) NOT NULL,
FEATURE_ID INT(11) NOT NULL,
PRIMARY KEY (ID),
CONSTRAINT FK_DM_POLICY_DM_POLICY_CORRECTIVE_ACTION
FOREIGN KEY (POLICY_ID)
REFERENCES DM_POLICY (ID)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT FK_DM_POLICY_DM_POLICY_CORRECTIVE_ACTION_FEATURE
FOREIGN KEY (FEATURE_ID)
REFERENCES DM_PROFILE_FEATURES (ID)
ON DELETE NO ACTION
ON UPDATE NO ACTION
);
CREATE TABLE IF NOT EXISTS DM_ROLE_POLICY ( CREATE TABLE IF NOT EXISTS DM_ROLE_POLICY (
ID INT(11) NOT NULL AUTO_INCREMENT , ID INT(11) NOT NULL AUTO_INCREMENT ,
ROLE_NAME VARCHAR(45) NOT NULL , ROLE_NAME VARCHAR(45) NOT NULL ,

@ -243,26 +243,6 @@ CREATE TABLE DM_POLICY (
ON DELETE NO ACTION ON UPDATE NO ACTION ON DELETE NO ACTION ON UPDATE NO ACTION
); );
IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[DM_POLICY_CORRECTIVE_ACTION]') AND TYPE IN (N'U'))
CREATE TABLE DM_POLICY_CORRECTIVE_ACTION (
ID INTEGER IDENTITY(1,1) NOT NULL,
ACTION_TYPE VARCHAR(45) NOT NULL,
CORRECTIVE_POLICY_ID INTEGER DEFAULT NULL,
POLICY_ID INTEGER NOT NULL,
FEATURE_ID INTEGER NOT NULL,
PRIMARY KEY (ID),
CONSTRAINT FK_DM_POLICY_DM_POLICY_CORRECTIVE_ACTION
FOREIGN KEY (POLICY_ID)
REFERENCES DM_POLICY (ID)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT FK_DM_POLICY_DM_POLICY_CORRECTIVE_ACTION
FOREIGN KEY (FEATURE_ID)
REFERENCES DM_PROFILE_FEATURES (ID)
ON DELETE NO ACTION
ON UPDATE NO ACTION
);
IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[DM_DEVICE_POLICY]') AND TYPE IN (N'U')) IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[DM_DEVICE_POLICY]') AND TYPE IN (N'U'))
CREATE TABLE DM_DEVICE_POLICY ( CREATE TABLE DM_DEVICE_POLICY (
ID INTEGER IDENTITY(1,1) NOT NULL, ID INTEGER IDENTITY(1,1) NOT NULL,
@ -300,6 +280,26 @@ CREATE TABLE DM_PROFILE_FEATURES (
ON DELETE NO ACTION ON UPDATE NO ACTION ON DELETE NO ACTION ON UPDATE NO ACTION
); );
IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[DM_POLICY_CORRECTIVE_ACTION]') AND TYPE IN (N'U'))
CREATE TABLE DM_POLICY_CORRECTIVE_ACTION (
ID INTEGER IDENTITY(1,1) NOT NULL,
ACTION_TYPE VARCHAR(45) NOT NULL,
CORRECTIVE_POLICY_ID INTEGER DEFAULT NULL,
POLICY_ID INTEGER NOT NULL,
FEATURE_ID INTEGER NOT NULL,
PRIMARY KEY (ID),
CONSTRAINT FK_DM_POLICY_DM_POLICY_CORRECTIVE_ACTION
FOREIGN KEY (POLICY_ID)
REFERENCES DM_POLICY (ID)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT FK_DM_POLICY_DM_POLICY_CORRECTIVE_ACTION_FEATURE
FOREIGN KEY (FEATURE_ID)
REFERENCES DM_PROFILE_FEATURES (ID)
ON DELETE NO ACTION
ON UPDATE NO ACTION
);
IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[DM_ROLE_POLICY]') AND TYPE IN (N'U')) IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[DM_ROLE_POLICY]') AND TYPE IN (N'U'))
CREATE TABLE DM_ROLE_POLICY ( CREATE TABLE DM_ROLE_POLICY (
ID INTEGER IDENTITY(1,1) NOT NULL, ID INTEGER IDENTITY(1,1) NOT NULL,

@ -228,25 +228,6 @@ CREATE TABLE IF NOT EXISTS DM_POLICY (
ON UPDATE NO ACTION ON UPDATE NO ACTION
)ENGINE = InnoDB; )ENGINE = InnoDB;
CREATE TABLE IF NOT EXISTS DM_POLICY_CORRECTIVE_ACTION (
ID INT(11) NOT NULL AUTO_INCREMENT,
ACTION_TYPE VARCHAR(45) NOT NULL,
CORRECTIVE_POLICY_ID INT(11) DEFAULT NULL,
POLICY_ID INT(11) NOT NULL,
FEATURE_ID INT(11) NOT NULL,
PRIMARY KEY (ID),
CONSTRAINT FK_DM_POLICY_DM_POLICY_CORRECTIVE_ACTION
FOREIGN KEY (POLICY_ID)
REFERENCES DM_POLICY (ID)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT FK_DM_POLICY_DM_POLICY_CORRECTIVE_ACTION
FOREIGN KEY (FEATURE_ID)
REFERENCES DM_PROFILE_FEATURES (ID)
ON DELETE NO ACTION
ON UPDATE NO ACTION
)ENGINE = InnoDB;
CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY ( CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY (
ID INT(11) NOT NULL AUTO_INCREMENT , ID INT(11) NOT NULL AUTO_INCREMENT ,
@ -296,6 +277,24 @@ CREATE TABLE IF NOT EXISTS DM_PROFILE_FEATURES (
ON UPDATE NO ACTION ON UPDATE NO ACTION
)ENGINE = InnoDB; )ENGINE = InnoDB;
CREATE TABLE IF NOT EXISTS DM_POLICY_CORRECTIVE_ACTION (
ID INT(11) NOT NULL AUTO_INCREMENT,
ACTION_TYPE VARCHAR(45) NOT NULL,
CORRECTIVE_POLICY_ID INT(11) DEFAULT NULL,
POLICY_ID INT(11) NOT NULL,
FEATURE_ID INT(11) NOT NULL,
PRIMARY KEY (ID),
CONSTRAINT FK_DM_POLICY_DM_POLICY_CORRECTIVE_ACTION
FOREIGN KEY (POLICY_ID)
REFERENCES DM_POLICY (ID)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT FK_DM_POLICY_DM_POLICY_CORRECTIVE_ACTION_FEATURE
FOREIGN KEY (FEATURE_ID)
REFERENCES DM_PROFILE_FEATURES (ID)
ON DELETE NO ACTION
ON UPDATE NO ACTION
)ENGINE = InnoDB;
CREATE TABLE IF NOT EXISTS DM_ROLE_POLICY ( CREATE TABLE IF NOT EXISTS DM_ROLE_POLICY (
ID INT(11) NOT NULL AUTO_INCREMENT , ID INT(11) NOT NULL AUTO_INCREMENT ,

@ -335,22 +335,6 @@ CREATE TABLE DM_POLICY (
) )
/ /
CREATE TABLE DM_POLICY_CORRECTIVE_ACTION (
ID NUMBER(10) NOT NULL,
ACTION_TYPE VARCHAR2(45) NOT NULL,
CORRECTIVE_POLICY_ID NUMBER(10) DEFAULT NULL,
POLICY_ID NUMBER(10) NOT NULL,
FEATURE_ID NUMBER(10) NOT NULL,
CONSTRAINT PK_DM_POLICY_CORRECTIVE_ACTION PRIMARY KEY (ID),
CONSTRAINT FK_DM_POLICY_DM_POLICY_CORRECTIVE_ACTION
FOREIGN KEY (POLICY_ID)
REFERENCES DM_POLICY (ID),
CONSTRAINT FK_DM_POLICY_DM_POLICY_CORRECTIVE_ACTION
FOREIGN KEY (FEATURE_ID)
REFERENCES DM_PROFILE_FEATURES (ID)
)
/
-- Generate ID using sequence and trigger -- Generate ID using sequence and trigger
CREATE SEQUENCE DM_POLICY_seq START WITH 1 INCREMENT BY 1 NOCACHE CREATE SEQUENCE DM_POLICY_seq START WITH 1 INCREMENT BY 1 NOCACHE
/ /
@ -422,6 +406,22 @@ CREATE TABLE DM_PROFILE_FEATURES (
) )
/ /
CREATE TABLE DM_POLICY_CORRECTIVE_ACTION (
ID NUMBER(10) NOT NULL,
ACTION_TYPE VARCHAR2(45) NOT NULL,
CORRECTIVE_POLICY_ID NUMBER(10) DEFAULT NULL,
POLICY_ID NUMBER(10) NOT NULL,
FEATURE_ID NUMBER(10) NOT NULL,
CONSTRAINT PK_DM_POLICY_CORRECTIVE_ACTION PRIMARY KEY (ID),
CONSTRAINT FK_DM_POLICY_DM_POLICY_CORRECTIVE_ACTION
FOREIGN KEY (POLICY_ID)
REFERENCES DM_POLICY (ID),
CONSTRAINT FK_DM_POLICY_DM_POLICY_CORRECTIVE_ACTION_FEATURE
FOREIGN KEY (FEATURE_ID)
REFERENCES DM_PROFILE_FEATURES (ID)
)
/
-- Generate ID using sequence and trigger -- Generate ID using sequence and trigger
CREATE SEQUENCE DM_PROFILE_FEATURES_seq START WITH 1 INCREMENT BY 1 NOCACHE CREATE SEQUENCE DM_PROFILE_FEATURES_seq START WITH 1 INCREMENT BY 1 NOCACHE
/ /

Loading…
Cancel
Save