Fixing the oracl and postgres sql datasources and removing the start and end from the search context

4.x.x
geethkokila 9 years ago
parent aa63b5f592
commit 888971ae39

@ -24,8 +24,8 @@ import java.util.List;
public class SearchContext {
private List<Condition> conditions;
private int start;
private int end;
// private int start;
// private int end;
public List<Condition> getConditions() {
return conditions;
@ -35,20 +35,20 @@ public class SearchContext {
this.conditions = conditions;
}
public int getStart() {
return start;
}
public void setStart(int start) {
this.start = start;
}
public int getEnd() {
return end;
}
public void setEnd(int end) {
this.end = end;
}
// public int getStart() {
// return start;
// }
//
// public void setStart(int start) {
// this.start = start;
// }
//
// public int getEnd() {
// return end;
// }
//
// public void setEnd(int end) {
// this.end = end;
// }
}

@ -237,6 +237,13 @@
<scope>test</scope>
</dependency>
<!--<dependency>-->
<!--<groupId>com.google.code.gson</groupId>-->
<!--<artifactId>gson</artifactId>-->
<!--<version>1.7.1</version>-->
<!--</dependency>-->
</dependencies>
</project>

@ -48,15 +48,37 @@ public class SearchDevice extends BaseDeviceManagementTest {
SearchContext context = new SearchContext();
List<Condition> conditions = new ArrayList<>();
Condition cond = new Condition();
Condition cond = new Condition();
cond.setKey("BATTERY_VOLTAGE");
cond.setOperator("=");
cond.setValue("40");
cond.setState(Condition.State.AND);
conditions.add(cond);
Condition cond2 = new Condition();
cond2.setKey("CPU_USAGE");
cond2.setOperator(">");
cond2.setValue("40");
cond2.setState(Condition.State.OR);
conditions.add(cond2);
Condition cond3 = new Condition();
cond3.setKey("LOCATION");
cond3.setOperator("=");
cond3.setValue("Colombo");
cond3.setState(Condition.State.AND);
conditions.add(cond3);
context.setConditions(conditions);
// Gson gson = new Gson();
//
// String aaa = gson.toJson(context);
//
// log.info(aaa);
SearchManagerService service = new SearchManagerServiceImpl();
List<DeviceWrapper> deviceWrappers = service.search(context);

@ -51,7 +51,7 @@
<RecurrentTimes>5</RecurrentTimes>
</Operation>
<Operation>
<Name>LOCATION</Name>
<Name>DEVICE_LOCATION</Name>
<RecurrentTimes>1</RecurrentTimes>
</Operation>
</Operations>

@ -655,3 +655,132 @@ WHEN (NEW.NOTIFICATION_ID IS NULL)
/
-- NOTIFICATION TABLE END --
-- Device Info and Search Table --
BEGIN
EXECUTE IMMEDIATE 'DROP TABLE DM_DEVICE_INFO';
EXCEPTION
WHEN OTHERS THEN NULL;
END;
/
CREATE TABLE DM_DEVICE_INFO (
ID NUMBER(10) NOT NULL,
DEVICE_ID NUMBER(10) NULL,
KEY_FIELD VARCHAR2(45) NULL,
VALUE_FIELD VARCHAR2(100) NULL,
PRIMARY KEY (ID)
,
CONSTRAINT DM_DEVICE_INFO_DEVICE
FOREIGN KEY (DEVICE_ID)
REFERENCES DM_DEVICE (ID)
)
;
-- Generate ID using sequence and trigger
CREATE SEQUENCE DM_DEVICE_INFO_seq START WITH 1 INCREMENT BY 1;
CREATE OR REPLACE TRIGGER DM_DEVICE_INFO_seq_tr
BEFORE INSERT ON DM_DEVICE_INFO FOR EACH ROW
WHEN (NEW.ID IS NULL)
BEGIN
SELECT DM_DEVICE_INFO_seq.NEXTVAL INTO :NEW.ID FROM DUAL;
END;
/
CREATE INDEX DM_DEVICE_INFO_DEVICE_idx ON DM_DEVICE_INFO (DEVICE_ID ASC);
BEGIN
EXECUTE IMMEDIATE 'DROP TABLE DM_DEVICE_LOCATION';
EXCEPTION
WHEN OTHERS THEN NULL;
END;
/
CREATE TABLE DM_DEVICE_LOCATION (
ID NUMBER(10) NOT NULL,
DEVICE_ID NUMBER(10) NULL,
LATITUDE BINARY_DOUBLE NULL,
LONGITUDE BINARY_DOUBLE NULL,
STREET1 VARCHAR2(45) NULL,
STREET2 VARCHAR2(45) NULL,
CITY VARCHAR2(45) NULL,
ZIP VARCHAR2(10) NULL,
STATE VARCHAR2(45) NULL,
COUNTRY VARCHAR2(45) NULL,
PRIMARY KEY (ID)
,
CONSTRAINT DM_DEVICE_LOCATION_DEVICE
FOREIGN KEY (DEVICE_ID)
REFERENCES DM_DEVICE (ID)
)
;
-- Generate ID using sequence and trigger
CREATE SEQUENCE DM_DEVICE_LOCATION_seq START WITH 1 INCREMENT BY 1;
CREATE OR REPLACE TRIGGER DM_DEVICE_LOCATION_seq_tr
BEFORE INSERT ON DM_DEVICE_LOCATION FOR EACH ROW
WHEN (NEW.ID IS NULL)
BEGIN
SELECT DM_DEVICE_LOCATION_seq.NEXTVAL INTO :NEW.ID FROM DUAL;
END;
/
CREATE INDEX DM_DEVICE_LOCATION_DEVICE_idx ON DM_DEVICE_LOCATION (DEVICE_ID ASC);
BEGIN
EXECUTE IMMEDIATE 'DROP TABLE DM_DEVICE_DETAIL';
EXCEPTION
WHEN OTHERS THEN NULL;
END;
/
CREATE TABLE DM_DEVICE_DETAIL (
ID NUMBER(10) NOT NULL,
DEVICE_ID NUMBER(10) NOT NULL,
IMEI VARCHAR2(100) NULL,
IMSI VARCHAR2(100) NULL,
DEVICE_MODEL VARCHAR2(45) NULL,
VENDOR VARCHAR2(45) NULL,
OS_VERSION VARCHAR2(45) NULL,
BATTERY_LEVEL NUMBER(4) NULL,
INTERNAL_TOTAL_MEMORY NUMBER(5) NULL,
INTERNAL_AVAILABLE_MEMORY NUMBER(5) NULL,
EXTERNAL_TOTAL_MEMORY NUMBER(5) NULL,
EXTERNAL_AVAILABLE_MEMORY NUMBER(5) NULL,
OPERATOR VARCHAR2(45) NULL,
CONNECTION_TYPE VARCHAR2(10) NULL,
MOBILE_SIGNAL_STRENGTH NUMBER(5) NULL,
SSID VARCHAR2(45) NULL,
CPU_USAGE NUMBER(5) NULL,
TOTAL_RAM_MEMORY NUMBER(5) NULL,
AVAILABLE_RAM_MEMORY NUMBER(5) NULL,
PLUGGED_IN NUMBER(10) NULL,
PRIMARY KEY (ID)
,
CONSTRAINT FK_DM_DEVICE_DETAILS_DEVICE
FOREIGN KEY (DEVICE_ID)
REFERENCES DM_DEVICE (ID)
)
;
-- Generate ID using sequence and trigger
CREATE SEQUENCE DM_DEVICE_DETAIL_seq START WITH 1 INCREMENT BY 1;
CREATE OR REPLACE TRIGGER DM_DEVICE_DETAIL_seq_tr
BEFORE INSERT ON DM_DEVICE_DETAIL FOR EACH ROW
WHEN (NEW.ID IS NULL)
BEGIN
SELECT DM_DEVICE_DETAIL_seq.NEXTVAL INTO :NEW.ID FROM DUAL;
END;
/
CREATE INDEX FK_DM_DEVICE_DETAILS_DEVICE_idx ON DM_DEVICE_DETAIL (DEVICE_ID ASC);

@ -346,3 +346,75 @@ CREATE TABLE IF NOT EXISTS DM_NOTIFICATION (
-- NOTIFICATION TABLE END --
-- Device Info and Search Table --
CREATE TABLE IF NOT EXISTS DM_DEVICE_INFO (
ID INTEGER DEFAULT NEXTVAL ('DM_DEVICE_INFO_seq') NOT NULL,
DEVICE_ID INT NULL,
KEY_FIELD VARCHAR(45) NULL,
VALUE_FIELD VARCHAR(100) NULL,
PRIMARY KEY (ID) ,
CONSTRAINT DM_DEVICE_INFO_DEVICE
FOREIGN KEY (DEVICE_ID)
REFERENCES DM_DEVICE (ID)
ON DELETE NO ACTION
ON UPDATE NO ACTION
);
CREATE INDEX DM_DEVICE_INFO_DEVICE_idx ON DM_DEVICE_INFO (DEVICE_ID ASC);
CREATE TABLE IF NOT EXISTS DM_DEVICE_LOCATION (
ID INTEGER DEFAULT NEXTVAL ('DM_DEVICE_LOCATION_seq') NOT NULL,
DEVICE_ID INT NULL,
LATITUDE DOUBLE PRECISION NULL,
LONGITUDE DOUBLE PRECISION NULL,
STREET1 VARCHAR(45) NULL,
STREET2 VARCHAR(45) NULL,
CITY VARCHAR(45) NULL,
ZIP VARCHAR(10) NULL,
STATE VARCHAR(45) NULL,
COUNTRY VARCHAR(45) NULL,
PRIMARY KEY (ID) ,
CONSTRAINT DM_DEVICE_LOCATION_DEVICE
FOREIGN KEY (DEVICE_ID)
REFERENCES DM_DEVICE (ID)
ON DELETE NO ACTION
ON UPDATE NO ACTION
);
CREATE INDEX DM_DEVICE_LOCATION_DEVICE_idx ON DM_DEVICE_LOCATION (DEVICE_ID ASC);
CREATE TABLE IF NOT EXISTS DM_DEVICE_DETAIL (
ID INT NOT NULL DEFAULT NEXTVAL ('DM_DEVICE_DETAIL_seq'),
DEVICE_ID INT NOT NULL,
IMEI VARCHAR(100) NULL,
IMSI VARCHAR(100) NULL,
DEVICE_MODEL VARCHAR(45) NULL,
VENDOR VARCHAR(45) NULL,
OS_VERSION VARCHAR(45) NULL,
BATTERY_LEVEL DECIMAL(4) NULL,
INTERNAL_TOTAL_MEMORY DECIMAL(5) NULL,
INTERNAL_AVAILABLE_MEMORY DECIMAL(5) NULL,
EXTERNAL_TOTAL_MEMORY DECIMAL(5) NULL,
EXTERNAL_AVAILABLE_MEMORY DECIMAL(5) NULL,
OPERATOR VARCHAR(45) NULL,
CONNECTION_TYPE VARCHAR(10) NULL,
MOBILE_SIGNAL_STRENGTH DECIMAL(5) NULL,
SSID VARCHAR(45) NULL,
CPU_USAGE DECIMAL(5) NULL,
TOTAL_RAM_MEMORY DECIMAL(5) NULL,
AVAILABLE_RAM_MEMORY DECIMAL(5) NULL,
PLUGGED_IN INT NULL,
PRIMARY KEY (ID) ,
CONSTRAINT FK_DM_DEVICE_DETAILS_DEVICE
FOREIGN KEY (DEVICE_ID)
REFERENCES DM_DEVICE (ID)
ON DELETE NO ACTION
ON UPDATE NO ACTION
);
CREATE INDEX FK_DM_DEVICE_DETAILS_DEVICE_idx ON DM_DEVICE_DETAIL (DEVICE_ID ASC);

Loading…
Cancel
Save