Adding the policy related new tables

revert-70aa11f8
geethkokila 10 years ago
parent f25dc65b54
commit 1d180c1a1e

@ -23,7 +23,6 @@ import org.wso2.carbon.policy.mgt.common.ProfileFeature;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects;
public class ProfileFeatureCreator { public class ProfileFeatureCreator {
@ -35,15 +34,15 @@ public class ProfileFeatureCreator {
ProfileFeature profileFeature = new ProfileFeature(); ProfileFeature profileFeature = new ProfileFeature();
if (i % 2 == 0) { if (i % 2 == 0) {
profileFeature.setContent( getJSON()); profileFeature.setContent(getJSON());
} else { } else {
profileFeature.setContent(getJSON2()); profileFeature.setContent(getJSON2());
} }
profileFeature.setDeviceTypeId(1); profileFeature.setDeviceTypeId(1);
profileFeature.setFeatureCode(feature.getCode()); profileFeature.setFeatureCode(feature.getCode());
// profileFeature.setContent("rrrrrrrrrrrrrrrrrrrrrrrrrrrrr"); // profileFeature.setContent("mm");
// profileFeature.setProfileId(1); // profileFeature.setProfileId(1);
// profileFeature.setFeature(feature); // profileFeature.setFeature(feature);
profileFeatureList.add(profileFeature); profileFeatureList.add(profileFeature);

@ -69,6 +69,9 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_OPERATION_MAPPING (
--- POLICY RELATED TABLES ---- --- POLICY RELATED TABLES ----
CREATE TABLE IF NOT EXISTS DM_PROFILE ( CREATE TABLE IF NOT EXISTS DM_PROFILE (
ID INT NOT NULL AUTO_INCREMENT , ID INT NOT NULL AUTO_INCREMENT ,
PROFILE_NAME VARCHAR(45) NOT NULL , PROFILE_NAME VARCHAR(45) NOT NULL ,
@ -77,114 +80,184 @@ CREATE TABLE IF NOT EXISTS DM_PROFILE (
CREATED_TIME DATETIME NOT NULL , CREATED_TIME DATETIME NOT NULL ,
UPDATED_TIME DATETIME NOT NULL , UPDATED_TIME DATETIME NOT NULL ,
PRIMARY KEY (ID) , PRIMARY KEY (ID) ,
CONSTRAINT DM_PROFILE_DEVICE_TYPE FOREIGN KEY (DEVICE_TYPE_ID ) REFERENCES DM_DEVICE_TYPE (ID ) CONSTRAINT DM_PROFILE_DEVICE_TYPE
FOREIGN KEY (DEVICE_TYPE_ID )
REFERENCES DM_DEVICE_TYPE (ID )
ON DELETE NO ACTION ON DELETE NO ACTION
ON UPDATE NO ACTION ON UPDATE NO ACTION
); );
CREATE TABLE IF NOT EXISTS DM_POLICY ( CREATE TABLE IF NOT EXISTS DM_POLICY (
ID INT(11) NOT NULL AUTO_INCREMENT , ID INT(11) NOT NULL AUTO_INCREMENT ,
NAME VARCHAR(45) NULL DEFAULT NULL , NAME VARCHAR(45) NULL DEFAULT NULL ,
TENANT_ID INT(11) NOT NULL , TENANT_ID INT(11) NOT NULL ,
PROFILE_ID INT(11) NOT NULL , PROFILE_ID INT(11) NOT NULL ,
COMPLIANCE VARCHAR(100) NULL,
PRIORITY INT NOT NULL , PRIORITY INT NOT NULL ,
PRIMARY KEY (ID) , PRIMARY KEY (ID) ,
CONSTRAINT FK_DM_PROFILE_DM_POLICY FOREIGN KEY (PROFILE_ID ) REFERENCES DM_PROFILE (ID ) CONSTRAINT FK_DM_PROFILE_DM_POLICY
FOREIGN KEY (PROFILE_ID )
REFERENCES DM_PROFILE (ID )
ON DELETE NO ACTION 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 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 ,
POLICY_ID INT(11) NOT NULL , POLICY_ID INT(11) NOT NULL ,
PRIMARY KEY (ID) , PRIMARY KEY (ID) ,
CONSTRAINT FK_POLICY_DEVICE_POLICY FOREIGN KEY (POLICY_ID ) REFERENCES DM_POLICY (ID ) CONSTRAINT FK_POLICY_DEVICE_POLICY
FOREIGN KEY (POLICY_ID )
REFERENCES DM_POLICY (ID )
ON DELETE NO ACTION ON DELETE NO ACTION
ON UPDATE NO ACTION, ON UPDATE NO ACTION,
CONSTRAINT FK_DEVICE_DEVICE_POLICY FOREIGN KEY (DEVICE_ID ) REFERENCES DM_DEVICE (ID ) CONSTRAINT FK_DEVICE_DEVICE_POLICY
FOREIGN KEY (DEVICE_ID )
REFERENCES DM_DEVICE (ID )
ON DELETE NO ACTION ON DELETE NO ACTION
ON UPDATE NO ACTION ON UPDATE NO ACTION
); );
CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE_POLICY ( CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE_POLICY (
ID INT(11) NOT NULL , ID INT(11) NOT NULL ,
DEVICE_TYPE_ID INT(11) NOT NULL , DEVICE_TYPE_ID INT(11) NOT NULL ,
POLICY_ID INT(11) NOT NULL , POLICY_ID INT(11) NOT NULL ,
PRIMARY KEY (ID) , PRIMARY KEY (ID) ,
CONSTRAINT FK_DEVICE_TYPE_POLICY FOREIGN KEY (POLICY_ID ) REFERENCES DM_POLICY (ID ) CONSTRAINT FK_DEVICE_TYPE_POLICY
FOREIGN KEY (POLICY_ID )
REFERENCES DM_POLICY (ID )
ON DELETE NO ACTION ON DELETE NO ACTION
ON UPDATE NO ACTION, ON UPDATE NO ACTION,
CONSTRAINT FK_DEVICE_TYPE_POLICY_DEVICE_TYPE FOREIGN KEY (DEVICE_TYPE_ID ) REFERENCES DM_DEVICE_TYPE (ID ) CONSTRAINT FK_DEVICE_TYPE_POLICY_DEVICE_TYPE
FOREIGN KEY (DEVICE_TYPE_ID )
REFERENCES DM_DEVICE_TYPE (ID )
ON DELETE NO ACTION ON DELETE NO ACTION
ON UPDATE NO ACTION ON UPDATE NO ACTION
); );
CREATE TABLE IF NOT EXISTS DM_PROFILE_FEATURES ( CREATE TABLE IF NOT EXISTS DM_PROFILE_FEATURES (
ID INT(11) NOT NULL AUTO_INCREMENT, ID INT(11) NOT NULL AUTO_INCREMENT,
PROFILE_ID INT(11) NOT NULL, PROFILE_ID INT(11) NOT NULL,
FEATURE_CODE VARCHAR(10) NOT NULL, FEATURE_CODE VARCHAR(30) NOT NULL,
DEVICE_TYPE_ID INT NOT NULL, DEVICE_TYPE_ID INT NOT NULL,
CONTENT BLOB NULL DEFAULT NULL, CONTENT BLOB NULL DEFAULT NULL,
PRIMARY KEY (ID), PRIMARY KEY (ID),
CONSTRAINT FK_DM_PROFILE_DM_POLICY_FEATURES FOREIGN KEY (PROFILE_ID) REFERENCES DM_PROFILE (ID) CONSTRAINT FK_DM_PROFILE_DM_POLICY_FEATURES
FOREIGN KEY (PROFILE_ID)
REFERENCES DM_PROFILE (ID)
ON DELETE NO ACTION ON DELETE NO ACTION
ON UPDATE 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 ,
POLICY_ID INT(11) NOT NULL , POLICY_ID INT(11) NOT NULL ,
PRIMARY KEY (ID) , PRIMARY KEY (ID) ,
CONSTRAINT FK_ROLE_POLICY_POLICY FOREIGN KEY (POLICY_ID ) REFERENCES DM_POLICY (ID ) CONSTRAINT FK_ROLE_POLICY_POLICY
FOREIGN KEY (POLICY_ID )
REFERENCES DM_POLICY (ID )
ON DELETE NO ACTION ON DELETE NO ACTION
ON UPDATE NO ACTION ON UPDATE NO ACTION
); );
CREATE TABLE IF NOT EXISTS DM_LOCATION (
LATITUDE VARCHAR(45) NOT NULL ,
LONGITUDE VARCHAR(45) NOT NULL , CREATE TABLE IF NOT EXISTS DM_USER_POLICY (
POLICY_ID INT(11) NOT NULL , ID INT NOT NULL AUTO_INCREMENT ,
CONSTRAINT FK_DM_POLICY_DM_LOCATION FOREIGN KEY (POLICY_ID ) REFERENCES DM_POLICY (ID ) POLICY_ID INT NOT NULL ,
USERNAME VARCHAR(45) NOT NULL ,
PRIMARY KEY (ID) ,
CONSTRAINT DM_POLICY_USER_POLICY
FOREIGN KEY (POLICY_ID )
REFERENCES DM_POLICY (ID )
ON DELETE NO ACTION ON DELETE NO ACTION
ON UPDATE NO ACTION ON UPDATE NO ACTION
); );
CREATE TABLE IF NOT EXISTS DM_TIME ( CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY_APPLIED (
STARTING_TIME DATETIME NOT NULL , ID INT NOT NULL AUTO_INCREMENT ,
ENDING_TIME DATETIME NOT NULL , DEVICE_ID INT NOT NULL ,
POLICY_ID INT(11) NOT NULL , POLICY_ID INT NOT NULL ,
CONSTRAINT FK_DM_POLICY_DM_TIME FOREIGN KEY (POLICY_ID ) REFERENCES DM_POLICY (ID ) POLICY_CONTENT BLOB NULL ,
APPLIED TINYINT(1) NULL ,
CREATED_TIME TIMESTAMP NULL ,
UPDATED_TIME TIMESTAMP NULL ,
APPLIED_TIME TIMESTAMP NULL ,
PRIMARY KEY (ID) ,
CONSTRAINT FK_DM_POLICY_DEVCIE_APPLIED
FOREIGN KEY (DEVICE_ID )
REFERENCES DM_DEVICE (ID )
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT FK_DM_POLICY_DEVICE_APPLIED_POLICY
FOREIGN KEY (POLICY_ID )
REFERENCES DM_POLICY (ID )
ON DELETE NO ACTION ON DELETE NO ACTION
ON UPDATE NO ACTION ON UPDATE NO ACTION
); );
CREATE TABLE IF NOT EXISTS DM_DATE (
START_DATE DATE NOT NULL , CREATE TABLE IF NOT EXISTS DM_CRITERIA (
END_DATE DATE NOT NULL , ID INT NOT NULL AUTO_INCREMENT,
POLICY_ID INT NOT NULL , TENANT_ID INT NOT NULL,
CONSTRAINT DM_DATE_POLICY FOREIGN KEY (POLICY_ID ) REFERENCES DM_POLICY (ID ) NAME VARCHAR(50) NULL,
PRIMARY KEY (ID)
);
CREATE TABLE IF NOT EXISTS DM_POLICY_CRITERIA (
ID INT NOT NULL AUTO_INCREMENT,
CRITERIA_ID INT NOT NULL,
POLICY_ID INT NOT NULL,
PRIMARY KEY (ID),
CONSTRAINT FK_CRITERIA_POLICY_CRITERIA
FOREIGN KEY (CRITERIA_ID)
REFERENCES DM_CRITERIA (ID)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT FK_POLICY_POLICY_CRITERIA
FOREIGN KEY (POLICY_ID)
REFERENCES DM_POLICY (ID)
ON DELETE NO ACTION ON DELETE NO ACTION
ON UPDATE NO ACTION ON UPDATE NO ACTION
); );
CREATE TABLE IF NOT EXISTS DM_USER_POLICY (
ID INT NOT NULL AUTO_INCREMENT , CREATE TABLE IF NOT EXISTS DM_POLICY_CRITERIA_PROPERTIES (
POLICY_ID INT NOT NULL , ID INT NOT NULL AUTO_INCREMENT,
USERNAME VARCHAR(45) NOT NULL , POLICY_CRITERION_ID INT NOT NULL,
PRIMARY KEY (ID) , PROP_KEY VARCHAR(45) NULL,
CONSTRAINT DM_POLICY_USER_POLICY FOREIGN KEY (POLICY_ID ) REFERENCES DM_POLICY (ID ) PROP_VALUE VARCHAR(100) NULL,
ON DELETE NO ACTION CONTENT BLOB NULL COMMENT 'This is used to ',
PRIMARY KEY (ID),
CONSTRAINT FK_POLICY_CRITERIA_PROPERTIES
FOREIGN KEY (POLICY_CRITERION_ID)
REFERENCES DM_POLICY_CRITERIA (ID)
ON DELETE CASCADE
ON UPDATE NO ACTION ON UPDATE NO ACTION
); );

Loading…
Cancel
Save