Fix code review discussions

corrective-policy
Pahansith 4 years ago
parent a24879f551
commit d08f20d90e

@ -594,7 +594,6 @@ $(document).ready(function () {
} }
}); });
//todo
$('input[type=radio][name=policy-type-radio-btn]').change(function() { $('input[type=radio][name=policy-type-radio-btn]').change(function() {
if ($(this).val() === "CORRECTIVE") { if ($(this).val() === "CORRECTIVE") {
$("#select-general-policy-type").addClass("hidden"); $("#select-general-policy-type").addClass("hidden");

@ -44,8 +44,6 @@ function onRequest(context) {
var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"]; var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"];
page["isCloud"] = devicemgtProps.isCloud; page["isCloud"] = devicemgtProps.isCloud;
/*page["correctivePolicies"] = JSON.stringify(policyModule.getAllPoliciesByType("CORRECTIVE")["content"]);*/
return page; return page;
} }

@ -306,16 +306,12 @@ public class PolicyDAOImpl implements PolicyDAO {
public List<CorrectiveAction> getCorrectiveActionsOfPolicy(int policyId) throws PolicyManagerDAOException { public List<CorrectiveAction> getCorrectiveActionsOfPolicy(int policyId) throws PolicyManagerDAOException {
try { try {
Connection conn = this.getConnection(); Connection conn = this.getConnection();
String query = "SELECT * " + String query = "SELECT ACTION_TYPE, CORRECTIVE_POLICY_ID, FEATURE_ID, POLICY_ID " +
"FROM DM_POLICY_CORRECTIVE_ACTION " + "FROM DM_POLICY_CORRECTIVE_ACTION " +
"WHERE POLICY_ID = ?"; "WHERE POLICY_ID = ?";
try (PreparedStatement selectStmt = conn.prepareStatement(query)) { try (PreparedStatement selectStmt = conn.prepareStatement(query)) {
List<CorrectiveAction> correctiveActions = new ArrayList<>();
selectStmt.setInt(1, policyId); selectStmt.setInt(1, policyId);
try (ResultSet rs = selectStmt.executeQuery()) { return extractCorrectivePolicies(selectStmt);
extractCorrectivePolicies(selectStmt, correctiveActions);
}
return correctiveActions;
} }
} catch (SQLException e) { } catch (SQLException e) {
String msg = "Error occurred while retrieving corrective actions of policy ID " + policyId; String msg = "Error occurred while retrieving corrective actions of policy ID " + policyId;
@ -328,12 +324,11 @@ public class PolicyDAOImpl implements PolicyDAO {
public List<CorrectiveAction> getAllCorrectiveActions() throws PolicyManagerDAOException { public List<CorrectiveAction> getAllCorrectiveActions() throws PolicyManagerDAOException {
try { try {
Connection conn = this.getConnection(); Connection conn = this.getConnection();
String query = "SELECT * " + String query = "SELECT ACTION_TYPE, CORRECTIVE_POLICY_ID, FEATURE_ID, POLICY_ID " +
"FROM DM_POLICY_CORRECTIVE_ACTION "; "FROM DM_POLICY_CORRECTIVE_ACTION ";
try (PreparedStatement stmt = conn.prepareStatement(query)) { try (PreparedStatement stmt = conn.prepareStatement(query)) {
List<CorrectiveAction> correctiveActions = new ArrayList<>(); List<CorrectiveAction> correctiveActions = new ArrayList<>();
extractCorrectivePolicies(stmt, correctiveActions); return extractCorrectivePolicies(stmt);
return correctiveActions;
} }
} catch (SQLException e) { } catch (SQLException e) {
String msg = "Error occurred while retrieving all corrective actions"; String msg = "Error occurred while retrieving all corrective actions";
@ -342,8 +337,14 @@ public class PolicyDAOImpl implements PolicyDAO {
} }
} }
private void extractCorrectivePolicies(PreparedStatement stmt, List<CorrectiveAction> /**
correctiveActions) throws SQLException { * Extract corrective policies from DB query result
* @param stmt DB Query statement
* @return List of corrective actions queries
* @throws SQLException when a DB related issue occurs
*/
private List<CorrectiveAction> extractCorrectivePolicies(PreparedStatement stmt) throws SQLException {
List<CorrectiveAction> correctiveActions = new ArrayList<>();
try (ResultSet rs = stmt.executeQuery()) { try (ResultSet rs = stmt.executeQuery()) {
CorrectiveAction correctiveAction; CorrectiveAction correctiveAction;
while (rs.next()) { while (rs.next()) {
@ -355,6 +356,7 @@ public class PolicyDAOImpl implements PolicyDAO {
correctiveActions.add(correctiveAction); correctiveActions.add(correctiveAction);
} }
} }
return correctiveActions;
} }
@Override @Override
@ -362,14 +364,12 @@ public class PolicyDAOImpl implements PolicyDAO {
int policyId, int featureId) int policyId, int featureId)
throws PolicyManagerDAOException { throws PolicyManagerDAOException {
try { try {
boolean isFeatureIdContains = false;
Connection conn = this.getConnection(); Connection conn = this.getConnection();
String query = "UPDATE DM_POLICY_CORRECTIVE_ACTION " + String query = "UPDATE DM_POLICY_CORRECTIVE_ACTION " +
"SET CORRECTIVE_POLICY_ID = ? " + "SET CORRECTIVE_POLICY_ID = ? " +
"WHERE ACTION_TYPE = ? " + "WHERE ACTION_TYPE = ? " +
"AND POLICY_ID = ? "; "AND POLICY_ID = ? ";
if (featureId != -1) { if (featureId != -1) {
isFeatureIdContains = true;
query = query.concat("AND FEATURE_ID = ?"); query = query.concat("AND FEATURE_ID = ?");
} }
try (PreparedStatement updateStmt = conn.prepareStatement(query)) { try (PreparedStatement updateStmt = conn.prepareStatement(query)) {
@ -377,7 +377,7 @@ public class PolicyDAOImpl implements PolicyDAO {
updateStmt.setInt(1, correctiveAction.getPolicyId()); updateStmt.setInt(1, correctiveAction.getPolicyId());
updateStmt.setString(2, correctiveAction.getActionType()); updateStmt.setString(2, correctiveAction.getActionType());
updateStmt.setInt(3, policyId); updateStmt.setInt(3, policyId);
if (isFeatureIdContains) { if (featureId != -1) {
updateStmt.setInt(4, featureId); updateStmt.setInt(4, featureId);
} }
updateStmt.addBatch(); updateStmt.addBatch();
@ -400,16 +400,14 @@ public class PolicyDAOImpl implements PolicyDAO {
String query = "DELETE FROM DM_POLICY_CORRECTIVE_ACTION " + String query = "DELETE FROM DM_POLICY_CORRECTIVE_ACTION " +
"WHERE ACTION_TYPE = ? " + "WHERE ACTION_TYPE = ? " +
"AND POLICY_ID = ? "; "AND POLICY_ID = ? ";
boolean isFeatueIdContains = false;
if (featureId != -1) { if (featureId != -1) {
isFeatueIdContains = true;
query = query.concat("AND FEATURE_ID = ?"); query = query.concat("AND FEATURE_ID = ?");
} }
try (PreparedStatement deleteStmt = conn.prepareStatement(query)) { try (PreparedStatement deleteStmt = conn.prepareStatement(query)) {
for (CorrectiveAction correctiveAction : correctiveActions) { for (CorrectiveAction correctiveAction : correctiveActions) {
deleteStmt.setString(1, correctiveAction.getActionType()); deleteStmt.setString(1, correctiveAction.getActionType());
deleteStmt.setInt(2, policyId); deleteStmt.setInt(2, policyId);
if (isFeatueIdContains) { if (featureId != -1) {
deleteStmt.setInt(3, featureId); deleteStmt.setInt(3, featureId);
} }
deleteStmt.addBatch(); deleteStmt.addBatch();

@ -170,14 +170,6 @@ public class PolicyManagerImpl implements PolicyManager {
policyDAO.addPolicyCriteriaProperties(policy.getPolicyCriterias()); policyDAO.addPolicyCriteriaProperties(policy.getPolicyCriterias());
} }
/*if (policy.getCorrectiveActions() != null && !policy.getCorrectiveActions().isEmpty()) {
if (log.isDebugEnabled()) {
log.debug("Adding corrective actions for policy " + policy.getPolicyName() +
" having policy id " + policy.getId());
}
policyDAO.addCorrectiveActionsOfPolicy(policy.getCorrectiveActions(), policy.getId());
}*/
if (policy.isActive()) { if (policy.isActive()) {
policyDAO.activatePolicy(policy.getId()); policyDAO.activatePolicy(policy.getId());
} }
@ -358,6 +350,13 @@ public class PolicyManagerImpl implements PolicyManager {
return policy; return policy;
} }
/**
* Using for update old type of corrective policies which has single corrective policy
* per single general policy
* @param policy updating new corrective policy
* @param previousPolicy previous corrective policy
* @throws PolicyManagerDAOException for errors occur while updating corrective actions
*/
private void updateSingleCorrectiveActionList(Policy policy, Policy previousPolicy) private void updateSingleCorrectiveActionList(Policy policy, Policy previousPolicy)
throws PolicyManagerDAOException { throws PolicyManagerDAOException {
List<CorrectiveAction> updatedCorrectiveActions = policy.getCorrectiveActions(); List<CorrectiveAction> updatedCorrectiveActions = policy.getCorrectiveActions();
@ -400,42 +399,30 @@ public class PolicyManagerImpl implements PolicyManager {
} }
if (!correctiveActionsToUpdate.isEmpty()) { if (!correctiveActionsToUpdate.isEmpty()) {
try { policyDAO.updateCorrectiveActionsOfPolicy(correctiveActionsToUpdate,
policyDAO.updateCorrectiveActionsOfPolicy(correctiveActionsToUpdate, previousPolicy.getId(), -1);
previousPolicy.getId(), -1);
} catch (PolicyManagerDAOException e) {
String msg = "Error occurred while updating corrective policies of the policy" +
" "+ previousPolicy.getId();
log.error(msg, e);
throw new PolicyManagerDAOException(msg, e);
}
} }
if (!correctiveActionsToAdd.isEmpty()) { if (!correctiveActionsToAdd.isEmpty()) {
try { policyDAO.addCorrectiveActionsOfPolicy(correctiveActionsToAdd,
policyDAO.addCorrectiveActionsOfPolicy(correctiveActionsToAdd, previousPolicy.getId(), -1);
previousPolicy.getId(), -1);
} catch (PolicyManagerDAOException e) {
String msg = "Error occurred while adding new corrective policies to the " +
"policy the policy " + previousPolicy.getId();
log.error(msg, e);
throw new PolicyManagerDAOException(msg, e);
}
} }
if (!correctiveActionsToDelete.isEmpty()) { if (!correctiveActionsToDelete.isEmpty()) {
try { policyDAO.deleteCorrectiveActionsOfPolicy(correctiveActionsToDelete,
policyDAO.deleteCorrectiveActionsOfPolicy(correctiveActionsToDelete, previousPolicy.getId(), -1);
previousPolicy.getId(), -1);
} catch (PolicyManagerDAOException e) {
String msg = "Error occurred while deleting corrective actions from the " +
"policy " + previousPolicy.getId();
log.error(msg, e);
throw new PolicyManagerDAOException(msg, e);
}
} }
} }
/**
* Using for update new type of corrective policies which has multiple corrective policies
* per single general policy
* @param updatedCorrectiveActionsMap updated corrective actions <FeatureId, CorrectiveActionList>
* @param existingCorrectiveActionsMap existing corrective actions <FeatureId, CorrectiveActionList>
* @param policy updating policy
* @param previousPolicy for errors occur while updating corrective actions
* @throws PolicyManagerDAOException
*/
private void updateMultipleCorrectiveActions( private void updateMultipleCorrectiveActions(
Map<Integer, List<CorrectiveAction>> updatedCorrectiveActionsMap, Map<Integer, List<CorrectiveAction>> updatedCorrectiveActionsMap,
Map<Integer, List<CorrectiveAction>> existingCorrectiveActionsMap, Map<Integer, List<CorrectiveAction>> existingCorrectiveActionsMap,
@ -496,7 +483,6 @@ public class PolicyManagerImpl implements PolicyManager {
} }
} }
for (Integer featureId : existingCorrectiveActionsMap.keySet()) { for (Integer featureId : existingCorrectiveActionsMap.keySet()) {
List<CorrectiveAction> existingCorrectiveActions = existingCorrectiveActionsMap List<CorrectiveAction> existingCorrectiveActions = existingCorrectiveActionsMap
.get(featureId); .get(featureId);
@ -521,51 +507,29 @@ public class PolicyManagerImpl implements PolicyManager {
} }
if (!correctiveActionsToUpdate.isEmpty()) { if (!correctiveActionsToUpdate.isEmpty()) {
try { for (Integer featureId : correctiveActionsToUpdate.keySet()) {
for (Integer featureId : correctiveActionsToUpdate.keySet()) { List<CorrectiveAction> correctiveActions = correctiveActionsToUpdate
List<CorrectiveAction> correctiveActions = correctiveActionsToUpdate .get(featureId);
.get(featureId); policyDAO.updateCorrectiveActionsOfPolicy(correctiveActions,
policyDAO.updateCorrectiveActionsOfPolicy(correctiveActions, previousPolicy.getId(), featureId);
previousPolicy.getId(), featureId);
}
} catch (PolicyManagerDAOException e) {
String msg = "Error occurred while updating corrective policies of the policy" +
" "+ previousPolicy.getId();
log.error(msg, e);
throw new PolicyManagerDAOException(msg, e);
} }
} }
if (!correctiveActionsToAdd.isEmpty()) { if (!correctiveActionsToAdd.isEmpty()) {
try { for (Integer featureId : correctiveActionsToAdd.keySet()) {
for (Integer featureId : correctiveActionsToAdd.keySet()) { List<CorrectiveAction> correctiveActions = correctiveActionsToAdd
List<CorrectiveAction> correctiveActions = correctiveActionsToAdd .get(featureId);
.get(featureId); policyDAO.addCorrectiveActionsOfPolicy(correctiveActions,
policyDAO.addCorrectiveActionsOfPolicy(correctiveActions, previousPolicy.getId(), featureId);
previousPolicy.getId(), featureId);
}
} catch (PolicyManagerDAOException e) {
String msg = "Error occurred while adding new corrective policies to the " +
"policy the policy " + previousPolicy.getId();
log.error(msg, e);
throw new PolicyManagerDAOException(msg, e);
} }
} }
if (!correctiveActionsToDelete.isEmpty()) { if (!correctiveActionsToDelete.isEmpty()) {
try { for (Integer featureId : correctiveActionsToDelete.keySet()) {
for (Integer featureId : correctiveActionsToDelete.keySet()) { List<CorrectiveAction> correctiveActions = correctiveActionsToDelete
List<CorrectiveAction> correctiveActions = correctiveActionsToDelete .get(featureId);
.get(featureId); policyDAO.deleteCorrectiveActionsOfPolicy(correctiveActions,
policyDAO.deleteCorrectiveActionsOfPolicy(correctiveActions, previousPolicy.getId(), featureId);
previousPolicy.getId(), featureId);
}
} catch (PolicyManagerDAOException e) {
String msg = "Error occurred while deleting corrective actions from the " +
"policy " + previousPolicy.getId();
log.error(msg, e);
throw new PolicyManagerDAOException(msg, e);
} }
} }
} }
@ -908,6 +872,12 @@ public class PolicyManagerImpl implements PolicyManager {
try { try {
Profile profile = profileManager.getProfile(policy.getProfileId()); Profile profile = profileManager.getProfile(policy.getProfileId());
policy.setProfile(profile); policy.setProfile(profile);
} catch (ProfileManagementException e) {
throw new PolicyManagementException("Error occurred while getting the profile related to policy ID (" +
policyId + ")", e);
}
try {
PolicyManagementDAOFactory.openConnection(); PolicyManagementDAOFactory.openConnection();
List<CorrectiveAction> correctiveActionsOfPolicy = policyDAO List<CorrectiveAction> correctiveActionsOfPolicy = policyDAO
.getCorrectiveActionsOfPolicy(policyId); .getCorrectiveActionsOfPolicy(policyId);
@ -922,13 +892,6 @@ public class PolicyManagerImpl implements PolicyManager {
policy.setCorrectiveActions(getSingleCorrectiveAction policy.setCorrectiveActions(getSingleCorrectiveAction
(correctiveActionsOfPolicy, policyId)); (correctiveActionsOfPolicy, policyId));
} }
} catch (ProfileManagementException e) {
throw new PolicyManagementException("Error occurred while getting the profile related to policy ID (" +
policyId + ")", e);
// } catch (SQLException e) {
// throw new PolicyManagementException("Error occurred while opening a connection to the data source", e);
// } finally {
// PolicyManagementDAOFactory.closeConnection();
} catch (PolicyManagerDAOException e) { } catch (PolicyManagerDAOException e) {
String msg = "Error occurred while getting the corrective actions related to policy " + String msg = "Error occurred while getting the corrective actions related to policy " +
"ID (" + policyId + ")"; "ID (" + policyId + ")";
@ -941,8 +904,6 @@ public class PolicyManagerImpl implements PolicyManager {
} finally { } finally {
PolicyManagementDAOFactory.closeConnection(); PolicyManagementDAOFactory.closeConnection();
} }
return policy; return policy;
} }
@ -1525,8 +1486,15 @@ public class PolicyManagerImpl implements PolicyManager {
return policyList; return policyList;
} }
/**
* Build the list of policies which are included new and old types of corrective actions
* @param policyList queried policy list
* @param profileList queried profile list
* @throws PolicyManagerDAOException when failed to read policies from DB
* @throws GroupManagementException when failed to read policy groups from DB
*/
private void buildPolicyList(List<Policy> policyList, List<Profile> profileList) private void buildPolicyList(List<Policy> policyList, List<Profile> profileList)
throws PolicyManagerDAOException, GroupManagementException, PolicyManagementException { throws PolicyManagerDAOException, GroupManagementException {
List<CorrectiveAction> allCorrectiveActions = policyDAO.getAllCorrectiveActions(); List<CorrectiveAction> allCorrectiveActions = policyDAO.getAllCorrectiveActions();
for (Policy policy : policyList) { for (Policy policy : policyList) {
String policyPayloadVersion = policy.getPolicyPayloadVersion(); String policyPayloadVersion = policy.getPolicyPayloadVersion();
@ -1594,6 +1562,10 @@ public class PolicyManagerImpl implements PolicyManager {
} }
} }
/**
* Clear corrective action metadata values to avoid sending in payload
* @param correctiveAction list of corrective actions
*/
private void clearMetaDataValues(CorrectiveAction correctiveAction) { private void clearMetaDataValues(CorrectiveAction correctiveAction) {
correctiveAction.setAssociatedGeneralPolicyId(null); //avoiding send in payload correctiveAction.setAssociatedGeneralPolicyId(null); //avoiding send in payload
correctiveAction.setFeatureId(null); //avoiding send in payload correctiveAction.setFeatureId(null); //avoiding send in payload

@ -150,7 +150,7 @@ public class PolicyManagerUtil {
PolicyManagementConstants.GENERAL_POLICY_TYPE.equals(policy.getPolicyType())) { PolicyManagementConstants.GENERAL_POLICY_TYPE.equals(policy.getPolicyType())) {
String policyPayloadVersion = policy.getPolicyPayloadVersion(); String policyPayloadVersion = policy.getPolicyPayloadVersion();
float payloadVersion = 0f; float payloadVersion = 0f;
if (policyPayloadVersion != null && !StringUtils.isEmpty(policyPayloadVersion)) { if (!StringUtils.isEmpty(policyPayloadVersion)) {
payloadVersion = Float.parseFloat(policyPayloadVersion); payloadVersion = Float.parseFloat(policyPayloadVersion);
} }
if (payloadVersion >= 2.0f) { if (payloadVersion >= 2.0f) {
@ -229,8 +229,9 @@ public class PolicyManagerUtil {
correctiveProfileOperation.setCode(PolicyManagementConstants.POLICY_ACTIONS); correctiveProfileOperation.setCode(PolicyManagementConstants.POLICY_ACTIONS);
Set<Integer> correctivePolicyIdSet = new HashSet<>(); Set<Integer> correctivePolicyIdSet = new HashSet<>();
try { try {
List<CorrectiveAction> correctiveActions;
for (ProfileFeature feature : features) { for (ProfileFeature feature : features) {
List<CorrectiveAction> correctiveActions = feature.getCorrectiveActions(); correctiveActions = feature.getCorrectiveActions();
for (CorrectiveAction correctiveAction : correctiveActions) { for (CorrectiveAction correctiveAction : correctiveActions) {
if (PolicyManagementConstants.POLICY_CORRECTIVE_ACTION_TYPE if (PolicyManagementConstants.POLICY_CORRECTIVE_ACTION_TYPE
.equals(correctiveAction.getActionType())) { .equals(correctiveAction.getActionType())) {
@ -242,13 +243,12 @@ public class PolicyManagerUtil {
PolicyAdministratorPoint pap = new PolicyAdministratorPointImpl(); PolicyAdministratorPoint pap = new PolicyAdministratorPointImpl();
List<Policy> allCorrectivePolicies = pap List<Policy> allCorrectivePolicies = pap
.getPolicies(PolicyManagementConstants.CORRECTIVE_POLICY_TYPE); .getPolicies(PolicyManagementConstants.CORRECTIVE_POLICY_TYPE);
idLoop:
for (Integer policyId : correctivePolicyIdSet) { for (Integer policyId : correctivePolicyIdSet) {
for (Policy correctivePolicy : allCorrectivePolicies) { for (Policy correctivePolicy : allCorrectivePolicies) {
if (policyId == correctivePolicy.getId()) { if (policyId == correctivePolicy.getId()) {
createCorrectiveProfileOperations(correctivePolicy, correctiveProfileOperation); createCorrectiveProfileOperations(correctivePolicy, correctiveProfileOperation);
policyOperation.getProfileOperations().add(correctiveProfileOperation); policyOperation.getProfileOperations().add(correctiveProfileOperation);
continue idLoop; break;
} }
} }
} }
@ -287,7 +287,11 @@ public class PolicyManagerUtil {
correctiveOperationList.setPayLoad(payLoad); correctiveOperationList.setPayLoad(payLoad);
} }
/**
* Create list of profile operations
* @param effectiveFeatures effective features of the policy
* @return List of ProfileOperation
*/
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<>();
for (ProfileFeature feature : effectiveFeatures) { for (ProfileFeature feature : effectiveFeatures) {

@ -206,20 +206,16 @@ CREATE TABLE IF NOT EXISTS DM_POLICY_CORRECTIVE_ACTION (
ACTION_TYPE VARCHAR(45) NOT NULL, ACTION_TYPE VARCHAR(45) NOT NULL,
CORRECTIVE_POLICY_ID INT(11) DEFAULT NULL, CORRECTIVE_POLICY_ID INT(11) DEFAULT NULL,
POLICY_ID INT(11) NOT NULL, POLICY_ID INT(11) NOT NULL,
FEATURE_ID INT(11) NOT NULL, FEATURE_ID INT(11) DEFAULT NULL,
PRIMARY KEY (ID), PRIMARY KEY (ID),
CONSTRAINT FK_DM_POLICY_DM_POLICY_CORRECTIVE_ACTION CONSTRAINT FK_DM_POLICY_DM_POLICY_CORRECTIVE_ACTION
FOREIGN KEY (POLICY_ID) FOREIGN KEY (POLICY_ID)
REFERENCES DM_POLICY (ID) REFERENCES DM_POLICY (ID)
ON DELETE NO ACTION 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 ON UPDATE NO ACTION
); );
DROP TABLE IF EXISTS DM_DEVICE_POLICY; DROP TABLE IF EXISTS DM_DEVICE_POLICY;
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 ,

@ -243,19 +243,15 @@ CREATE TABLE IF NOT EXISTS DM_POLICY_CORRECTIVE_ACTION (
ACTION_TYPE VARCHAR(45) NOT NULL, ACTION_TYPE VARCHAR(45) NOT NULL,
CORRECTIVE_POLICY_ID INTEGER DEFAULT NULL, CORRECTIVE_POLICY_ID INTEGER DEFAULT NULL,
POLICY_ID INTEGER NOT NULL, POLICY_ID INTEGER NOT NULL,
FEATURE_ID INTEGER NOT NULL, FEATURE_ID INTEGER DEFAULT NULL,
CONSTRAINT FK_DM_POLICY_DM_POLICY_CORRECTIVE_ACTION CONSTRAINT FK_DM_POLICY_DM_POLICY_CORRECTIVE_ACTION
FOREIGN KEY (POLICY_ID) FOREIGN KEY (POLICY_ID)
REFERENCES DM_POLICY (ID) REFERENCES DM_POLICY (ID)
ON DELETE NO ACTION 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 ON UPDATE NO ACTION
); );
CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY ( CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY (
ID INTEGER NOT NULL DEFAULT NEXTVAL ('DM_DEVICE_POLICY_seq') , ID INTEGER NOT NULL DEFAULT NEXTVAL ('DM_DEVICE_POLICY_seq') ,
DEVICE_ID INTEGER NOT NULL , DEVICE_ID INTEGER NOT NULL ,

Loading…
Cancel
Save