@ -59,6 +59,7 @@ import java.util.HashMap;
import java.util.LinkedList ;
import java.util.LinkedList ;
import java.util.List ;
import java.util.List ;
import java.util.Map ;
import java.util.Map ;
import java.util.Properties ;
import java.util.stream.Collectors ;
import java.util.stream.Collectors ;
import java.util.stream.IntStream ;
import java.util.stream.IntStream ;
@ -75,15 +76,16 @@ public class GenericOperationDAOImpl implements OperationDAO {
try {
try {
Connection connection = OperationManagementDAOFactory . getConnection ( ) ;
Connection connection = OperationManagementDAOFactory . getConnection ( ) ;
String sql = "INSERT INTO DM_OPERATION(TYPE, CREATED_TIMESTAMP, RECEIVED_TIMESTAMP, OPERATION_CODE, " +
String sql = "INSERT INTO DM_OPERATION(TYPE, CREATED_TIMESTAMP, RECEIVED_TIMESTAMP, OPERATION_CODE, " +
"INITIATED_BY, OPERATION_DETAILS, TENANT_ID) VALUES (?, ?, ?, ?, ?, ?, ?)";
"INITIATED_BY, OPERATION_DETAILS, OPERATION_PROPERTIES, TENANT_ID) VALUES (?, ?, ?, ?, ?, ?, ?, ?)";
stmt = connection . prepareStatement ( sql , new String [ ] { "id" } ) ;
stmt = connection . prepareStatement ( sql , new String [ ] { "id" } ) ;
stmt . setString ( 1 , operation . getType ( ) . toString ( ) ) ;
stmt . setString ( 1 , operation . getType ( ) . toString ( ) ) ;
stmt . setLong ( 2 , DeviceManagementDAOUtil . getCurrentUTCTime ( ) ) ;
stmt . setLong ( 2 , DeviceManagementDAOUtil . getCurrentUTCTime ( ) ) ;
stmt . setLong ( 3 , 0 ) ;
stmt . setLong ( 3 , 0 ) ;
stmt . setString ( 4 , operation . getCode ( ) ) ;
stmt . setString ( 4 , operation . getCode ( ) ) ;
stmt . setString ( 5 , operation . getInitiatedBy ( ) ) ;
stmt . setString ( 5 , operation . getInitiatedBy ( ) ) ;
stmt . setObject ( 6 , operation ) ;
stmt . setObject ( 6 , operation . getPayLoad ( ) ) ;
stmt . setInt ( 7 , PrivilegedCarbonContext . getThreadLocalCarbonContext ( ) . getTenantId ( ) ) ;
stmt . setObject ( 7 , operation . getProperties ( ) ) ;
stmt . setInt ( 8 , PrivilegedCarbonContext . getThreadLocalCarbonContext ( ) . getTenantId ( ) ) ;
stmt . executeUpdate ( ) ;
stmt . executeUpdate ( ) ;
rs = stmt . getGeneratedKeys ( ) ;
rs = stmt . getGeneratedKeys ( ) ;
@ -164,7 +166,7 @@ public class GenericOperationDAOImpl implements OperationDAO {
}
}
@Override
@Override
public Map < Integer , Integer > getExisting OperationIDs( Integer [ ] enrolmentIds , String operationCode )
public Map < Integer , Integer > getExisting NotExecuted OperationIDs( Integer [ ] enrolmentIds , String operationCode )
throws OperationManagementDAOException {
throws OperationManagementDAOException {
PreparedStatement stmt = null ;
PreparedStatement stmt = null ;
ResultSet rs = null ;
ResultSet rs = null ;
@ -576,7 +578,7 @@ public class GenericOperationDAOImpl implements OperationDAO {
+ "dor.ID AS OP_RES_ID, de.DEVICE_ID, d.DEVICE_IDENTIFICATION, d.DEVICE_TYPE_ID, "
+ "dor.ID AS OP_RES_ID, de.DEVICE_ID, d.DEVICE_IDENTIFICATION, d.DEVICE_TYPE_ID, "
+ "dt.NAME AS DEVICE_TYPE_NAME, eom.STATUS, eom.CREATED_TIMESTAMP, "
+ "dt.NAME AS DEVICE_TYPE_NAME, eom.STATUS, eom.CREATED_TIMESTAMP, "
+ "eom.UPDATED_TIMESTAMP, op.OPERATION_CODE, op.TYPE AS OPERATION_TYPE, "
+ "eom.UPDATED_TIMESTAMP, op.OPERATION_CODE, op.TYPE AS OPERATION_TYPE, "
+ "dor.OPERATION_RESPONSE, op.INITIATED_BY, dor.RECEIVED_TIMESTAMP, dor.IS_LARGE_RESPONSE FROM "
+ "dor.OPERATION_RESPONSE, op.INITIATED_BY, dor.RECEIVED_TIMESTAMP, dor.IS_LARGE_RESPONSE FROM "
+ "DM_ENROLMENT_OP_MAPPING eom INNER JOIN DM_OPERATION op "
+ "DM_ENROLMENT_OP_MAPPING eom INNER JOIN DM_OPERATION op "
+ "ON op.ID=eom.OPERATION_ID INNER JOIN DM_ENROLMENT de "
+ "ON op.ID=eom.OPERATION_ID INNER JOIN DM_ENROLMENT de "
+ "ON de.ID=eom.ENROLMENT_ID INNER JOIN DM_DEVICE d ON d.ID=de.DEVICE_ID "
+ "ON de.ID=eom.ENROLMENT_ID INNER JOIN DM_DEVICE d ON d.ID=de.DEVICE_ID "
@ -1189,24 +1191,14 @@ public class GenericOperationDAOImpl implements OperationDAO {
Operation operation = null ;
Operation operation = null ;
try {
try {
Connection conn = OperationManagementDAOFactory . getConnection ( ) ;
Connection conn = OperationManagementDAOFactory . getConnection ( ) ;
String sql = "SELECT ID, TYPE, CREATED_TIMESTAMP, RECEIVED_TIMESTAMP, OPERATION_CODE, INITIATED_BY FROM " +
String sql = "SELECT ID, TYPE, CREATED_TIMESTAMP, RECEIVED_TIMESTAMP, OPERATION_CODE, INITIATED_BY , " +
" DM_OPERATION WHERE id = ?";
" OPERATION_DETAILS, OPERATION_PROPERTIES FROM DM_OPERATION WHERE id = ?";
stmt = conn . prepareStatement ( sql ) ;
stmt = conn . prepareStatement ( sql ) ;
stmt . setInt ( 1 , id ) ;
stmt . setInt ( 1 , id ) ;
rs = stmt . executeQuery ( ) ;
rs = stmt . executeQuery ( ) ;
if ( rs . next ( ) ) {
if ( rs . next ( ) ) {
operation = new Operation ( ) ;
operation = OperationDAOUtil . getOperation ( rs ) ;
operation . setId ( rs . getInt ( "ID" ) ) ;
operation . setType ( Operation . Type . valueOf ( rs . getString ( "TYPE" ) ) ) ;
operation . setCreatedTimeStamp ( new Timestamp ( rs . getLong ( "CREATED_TIMESTAMP" ) * 1000L ) . toString ( ) ) ;
if ( rs . getLong ( "RECEIVED_TIMESTAMP" ) = = 0 ) {
operation . setReceivedTimeStamp ( "" ) ;
} else {
operation . setReceivedTimeStamp ( new Timestamp ( rs . getLong ( "RECEIVED_TIMESTAMP" ) * 1000L ) . toString ( ) ) ;
}
operation . setCode ( rs . getString ( "OPERATION_CODE" ) ) ;
operation . setInitiatedBy ( rs . getString ( "INITIATED_BY" ) ) ;
}
}
} catch ( SQLException e ) {
} catch ( SQLException e ) {
@ -1219,16 +1211,19 @@ public class GenericOperationDAOImpl implements OperationDAO {
}
}
@Override
@Override
public Operation getOperationByDeviceAndId ( int enrolmentId , int operationId ) throws OperationManagementDAOException {
public Operation getOperationByDeviceAndId ( int enrolmentId , int operationId )
throws OperationManagementDAOException {
PreparedStatement stmt = null ;
PreparedStatement stmt = null ;
ResultSet rs = null ;
ResultSet rs = null ;
Operation operation = null ;
Operation operation = null ;
try {
try {
Connection conn = OperationManagementDAOFactory . getConnection ( ) ;
Connection conn = OperationManagementDAOFactory . getConnection ( ) ;
String sql = "SELECT o.ID, o.TYPE, o.CREATED_TIMESTAMP, o.RECEIVED_TIMESTAMP, om.STATUS, " +
String sql = "SELECT o.ID, o.TYPE, o.CREATED_TIMESTAMP, o.RECEIVED_TIMESTAMP, om.STATUS, " +
"o.OPERATION_CODE, o.INITIATED_BY, om.ID AS OM_MAPPING_ID, " +
"o.OPERATION_CODE, o.INITIATED_BY, o.OPERATION_DETAILS, o.OPERATION_PROPERTIES, " +
"om.UPDATED_TIMESTAMP FROM (SELECT ID, TYPE, CREATED_TIMESTAMP, RECEIVED_TIMESTAMP," +
"om.ID AS OM_MAPPING_ID, om.UPDATED_TIMESTAMP, om.STATUS FROM " +
"OPERATION_CODE, INITIATED_BY FROM DM_OPERATION WHERE id = ?) o INNER JOIN (SELECT * FROM " +
"(SELECT ID, TYPE, CREATED_TIMESTAMP, RECEIVED_TIMESTAMP," +
"OPERATION_CODE, INITIATED_BY, OPERATION_DETAILS, OPERATION_PROPERTIES FROM DM_OPERATION " +
"WHERE id = ?) o INNER JOIN (SELECT * FROM " +
"DM_ENROLMENT_OP_MAPPING dm where dm.OPERATION_ID = ? AND dm.ENROLMENT_ID = ?) om " +
"DM_ENROLMENT_OP_MAPPING dm where dm.OPERATION_ID = ? AND dm.ENROLMENT_ID = ?) om " +
"ON o.ID = om.OPERATION_ID " ;
"ON o.ID = om.OPERATION_ID " ;
stmt = conn . prepareStatement ( sql ) ;
stmt = conn . prepareStatement ( sql ) ;
@ -1238,20 +1233,14 @@ public class GenericOperationDAOImpl implements OperationDAO {
rs = stmt . executeQuery ( ) ;
rs = stmt . executeQuery ( ) ;
if ( rs . next ( ) ) {
if ( rs . next ( ) ) {
operation = new Operation ( ) ;
operation = OperationDAOUtil . getOperation ( rs ) ;
operation . setId ( rs . getInt ( "ID" ) ) ;
operation . setType ( Operation . Type . valueOf ( rs . getString ( "TYPE" ) ) ) ;
operation . setCreatedTimeStamp ( new Timestamp ( rs . getLong ( "CREATED_TIMESTAMP" ) * 1000L ) . toString ( ) ) ;
operation . setStatus ( Operation . Status . valueOf ( rs . getString ( "STATUS" ) ) ) ;
if ( rs . getLong ( "UPDATED_TIMESTAMP" ) = = 0 ) {
if ( rs . getLong ( "UPDATED_TIMESTAMP" ) = = 0 ) {
operation . setReceivedTimeStamp ( "" ) ;
operation . setReceivedTimeStamp ( "" ) ;
} else {
} else {
operation . setReceivedTimeStamp (
operation . setReceivedTimeStamp (
new Timestamp ( ( rs . getLong ( "UPDATED_TIMESTAMP" ) * 1000 ) ) . toString ( ) ) ;
new Timestamp ( ( rs . getLong ( "UPDATED_TIMESTAMP" ) * 1000 ) ) . toString ( ) ) ;
}
}
operation . setCode ( rs . getString ( "OPERATION_CODE" ) ) ;
operation . setStatus ( Operation . Status . valueOf ( rs . getString ( "STATUS" ) ) ) ;
operation . setInitiatedBy ( rs . getString ( "INITIATED_BY" ) ) ;
OperationDAOUtil . setActivityId ( operation , rs . getInt ( "ID" ) ) ;
}
}
} catch ( SQLException e ) {
} catch ( SQLException e ) {
throw new OperationManagementDAOException ( "SQL error occurred while retrieving the operation " +
throw new OperationManagementDAOException ( "SQL error occurred while retrieving the operation " +
@ -1272,7 +1261,8 @@ public class GenericOperationDAOImpl implements OperationDAO {
try {
try {
Connection conn = OperationManagementDAOFactory . getConnection ( ) ;
Connection conn = OperationManagementDAOFactory . getConnection ( ) ;
String sql = "SELECT o.ID, TYPE, o.CREATED_TIMESTAMP, o.RECEIVED_TIMESTAMP, o.OPERATION_CODE, " +
String sql = "SELECT o.ID, TYPE, o.CREATED_TIMESTAMP, o.RECEIVED_TIMESTAMP, o.OPERATION_CODE, " +
"o.INITIATED_BY, om.ID AS OM_MAPPING_ID, om.UPDATED_TIMESTAMP FROM DM_OPERATION o " +
"o.INITIATED_BY, o.OPERATION_DETAILS, o.OPERATION_PROPERTIES, om.ID AS OM_MAPPING_ID, " +
"om.UPDATED_TIMESTAMP FROM DM_OPERATION o " +
"INNER JOIN (SELECT * FROM DM_ENROLMENT_OP_MAPPING dm " +
"INNER JOIN (SELECT * FROM DM_ENROLMENT_OP_MAPPING dm " +
"WHERE dm.ENROLMENT_ID = ? AND dm.STATUS = ?) om ON o.ID = om.OPERATION_ID ORDER BY o.CREATED_TIMESTAMP DESC" ;
"WHERE dm.ENROLMENT_ID = ? AND dm.STATUS = ?) om ON o.ID = om.OPERATION_ID ORDER BY o.CREATED_TIMESTAMP DESC" ;
stmt = conn . prepareStatement ( sql ) ;
stmt = conn . prepareStatement ( sql ) ;
@ -1281,20 +1271,14 @@ public class GenericOperationDAOImpl implements OperationDAO {
rs = stmt . executeQuery ( ) ;
rs = stmt . executeQuery ( ) ;
while ( rs . next ( ) ) {
while ( rs . next ( ) ) {
operation = new Operation ( ) ;
operation = OperationDAOUtil . getOperation ( rs ) ;
operation . setId ( rs . getInt ( "ID" ) ) ;
operation . setStatus ( status ) ;
operation . setType ( Operation . Type . valueOf ( rs . getString ( "TYPE" ) ) ) ;
operation . setCreatedTimeStamp ( new Timestamp ( rs . getLong ( "CREATED_TIMESTAMP" ) * 1000L ) . toString ( ) ) ;
if ( rs . getLong ( "UPDATED_TIMESTAMP" ) = = 0 ) {
if ( rs . getLong ( "UPDATED_TIMESTAMP" ) = = 0 ) {
operation . setReceivedTimeStamp ( "" ) ;
operation . setReceivedTimeStamp ( "" ) ;
} else {
} else {
operation . setReceivedTimeStamp (
operation . setReceivedTimeStamp (
new Timestamp ( ( rs . getLong ( "UPDATED_TIMESTAMP" ) * 1000 ) ) . toString ( ) ) ;
new Timestamp ( ( rs . getLong ( "UPDATED_TIMESTAMP" ) * 1000 ) ) . toString ( ) ) ;
}
}
operation . setCode ( rs . getString ( "OPERATION_CODE" ) ) ;
operation . setInitiatedBy ( rs . getString ( "INITIATED_BY" ) ) ;
operation . setStatus ( status ) ;
OperationDAOUtil . setActivityId ( operation , rs . getInt ( "ID" ) ) ;
operations . add ( operation ) ;
operations . add ( operation ) ;
}
}
} catch ( SQLException e ) {
} catch ( SQLException e ) {
@ -1317,7 +1301,8 @@ public class GenericOperationDAOImpl implements OperationDAO {
try {
try {
Connection conn = OperationManagementDAOFactory . getConnection ( ) ;
Connection conn = OperationManagementDAOFactory . getConnection ( ) ;
String sql = "SELECT o.ID, TYPE, o.CREATED_TIMESTAMP, o.RECEIVED_TIMESTAMP, o.OPERATION_CODE, " +
String sql = "SELECT o.ID, TYPE, o.CREATED_TIMESTAMP, o.RECEIVED_TIMESTAMP, o.OPERATION_CODE, " +
"o.INITIATED_BY, om.ID AS OM_MAPPING_ID, om.UPDATED_TIMESTAMP FROM DM_OPERATION o " +
"o.INITIATED_BY, o.OPERATION_DETAILS, o.OPERATION_PROPERTIES, om.ID AS OM_MAPPING_ID, " +
"om.UPDATED_TIMESTAMP FROM DM_OPERATION o " +
"INNER JOIN (SELECT * FROM DM_ENROLMENT_OP_MAPPING dm " +
"INNER JOIN (SELECT * FROM DM_ENROLMENT_OP_MAPPING dm " +
"WHERE dm.ENROLMENT_ID = ? AND dm.STATUS = ?) om ON o.ID = om.OPERATION_ID ORDER BY " +
"WHERE dm.ENROLMENT_ID = ? AND dm.STATUS = ?) om ON o.ID = om.OPERATION_ID ORDER BY " +
"o.CREATED_TIMESTAMP DESC LIMIT ?,?" ;
"o.CREATED_TIMESTAMP DESC LIMIT ?,?" ;
@ -1329,20 +1314,15 @@ public class GenericOperationDAOImpl implements OperationDAO {
rs = stmt . executeQuery ( ) ;
rs = stmt . executeQuery ( ) ;
while ( rs . next ( ) ) {
while ( rs . next ( ) ) {
operation = new Operation ( ) ;
operation = OperationDAOUtil . getOperation ( rs ) ;
operation . setId ( rs . getInt ( "ID" ) ) ;
operation . setStatus ( status ) ;
operation . setType ( Operation . Type . valueOf ( rs . getString ( "TYPE" ) ) ) ;
operation . setCreatedTimeStamp ( new Timestamp ( rs . getLong ( "CREATED_TIMESTAMP" ) * 1000L ) . toString ( ) ) ;
if ( rs . getLong ( "UPDATED_TIMESTAMP" ) = = 0 ) {
if ( rs . getLong ( "UPDATED_TIMESTAMP" ) = = 0 ) {
operation . setReceivedTimeStamp ( "" ) ;
operation . setReceivedTimeStamp ( "" ) ;
} else {
} else {
operation . setReceivedTimeStamp (
operation . setReceivedTimeStamp (
new Timestamp ( ( rs . getLong ( "UPDATED_TIMESTAMP" ) * 1000 ) ) . toString ( ) ) ;
new Timestamp ( ( rs . getLong ( "UPDATED_TIMESTAMP" ) * 1000 ) ) . toString ( ) ) ;
}
}
operation . setCode ( rs . getString ( "OPERATION_CODE" ) ) ;
operation . setInitiatedBy ( rs . getString ( "INITIATED_BY" ) ) ;
operation . setStatus ( status ) ;
operation . setStatus ( status ) ;
OperationDAOUtil . setActivityId ( operation , rs . getInt ( "OM_MAPPING_ID" ) ) ;
operations . add ( operation ) ;
operations . add ( operation ) ;
}
}
} catch ( SQLException e ) {
} catch ( SQLException e ) {
@ -1364,7 +1344,8 @@ public class GenericOperationDAOImpl implements OperationDAO {
try {
try {
Connection conn = OperationManagementDAOFactory . getConnection ( ) ;
Connection conn = OperationManagementDAOFactory . getConnection ( ) ;
String sql = "SELECT o.ID, o.TYPE, o.CREATED_TIMESTAMP, o.RECEIVED_TIMESTAMP, " +
String sql = "SELECT o.ID, o.TYPE, o.CREATED_TIMESTAMP, o.RECEIVED_TIMESTAMP, " +
"o.OPERATION_CODE, o.INITIATED_BY, om.STATUS, om.ID AS OM_MAPPING_ID, om.UPDATED_TIMESTAMP " +
"o.OPERATION_CODE, o.INITIATED_BY, o.OPERATION_DETAILS, o.OPERATION_PROPERTIES, om.STATUS, " +
"om.ID AS OM_MAPPING_ID, om.UPDATED_TIMESTAMP " +
"FROM DM_OPERATION o INNER JOIN (SELECT * FROM DM_ENROLMENT_OP_MAPPING dm " +
"FROM DM_OPERATION o INNER JOIN (SELECT * FROM DM_ENROLMENT_OP_MAPPING dm " +
"WHERE dm.ENROLMENT_ID = ?) om ON o.ID = om.OPERATION_ID " +
"WHERE dm.ENROLMENT_ID = ?) om ON o.ID = om.OPERATION_ID " +
"ORDER BY o.CREATED_TIMESTAMP DESC, o.ID DESC" ;
"ORDER BY o.CREATED_TIMESTAMP DESC, o.ID DESC" ;
@ -1373,18 +1354,13 @@ public class GenericOperationDAOImpl implements OperationDAO {
rs = stmt . executeQuery ( ) ;
rs = stmt . executeQuery ( ) ;
while ( rs . next ( ) ) {
while ( rs . next ( ) ) {
operation = new Operation ( ) ;
operation = OperationDAOUtil . getOperation ( rs ) ;
operation . setId ( rs . getInt ( "ID" ) ) ;
operation . setType ( Operation . Type . valueOf ( rs . getString ( "TYPE" ) ) ) ;
operation . setCreatedTimeStamp ( new Timestamp ( rs . getLong ( "CREATED_TIMESTAMP" ) * 1000L ) . toString ( ) ) ;
if ( rs . getLong ( "UPDATED_TIMESTAMP" ) = = 0 ) {
if ( rs . getLong ( "UPDATED_TIMESTAMP" ) = = 0 ) {
operation . setReceivedTimeStamp ( "" ) ;
operation . setReceivedTimeStamp ( "" ) ;
} else {
} else {
operation . setReceivedTimeStamp (
operation . setReceivedTimeStamp (
new Timestamp ( ( rs . getLong ( "UPDATED_TIMESTAMP" ) * 1000 ) ) . toString ( ) ) ;
new Timestamp ( ( rs . getLong ( "UPDATED_TIMESTAMP" ) * 1000 ) ) . toString ( ) ) ;
}
}
operation . setCode ( rs . getString ( "OPERATION_CODE" ) ) ;
operation . setInitiatedBy ( rs . getString ( "INITIATED_BY" ) ) ;
operation . setStatus ( Operation . Status . valueOf ( rs . getString ( "STATUS" ) ) ) ;
operation . setStatus ( Operation . Status . valueOf ( rs . getString ( "STATUS" ) ) ) ;
operations . add ( operation ) ;
operations . add ( operation ) ;
}
}
@ -1428,6 +1404,7 @@ public class GenericOperationDAOImpl implements OperationDAO {
"o.OPERATION_CODE, " +
"o.OPERATION_CODE, " +
"o.INITIATED_BY, " +
"o.INITIATED_BY, " +
"o.OPERATION_DETAILS, " +
"o.OPERATION_DETAILS, " +
"o.OPERATION_PROPERTIES, " +
"om.STATUS, " +
"om.STATUS, " +
"om.ID AS OM_MAPPING_ID, " +
"om.ID AS OM_MAPPING_ID, " +
"om.UPDATED_TIMESTAMP " +
"om.UPDATED_TIMESTAMP " +
@ -1514,36 +1491,14 @@ public class GenericOperationDAOImpl implements OperationDAO {
stmt . setInt ( paramIndex , request . getRowCount ( ) ) ;
stmt . setInt ( paramIndex , request . getRowCount ( ) ) ;
try ( ResultSet rs = stmt . executeQuery ( ) ) {
try ( ResultSet rs = stmt . executeQuery ( ) ) {
while ( rs . next ( ) ) {
while ( rs . next ( ) ) {
operation = new Operation ( ) ;
operation = OperationDAOUtil . getOperation ( rs ) ;
operation . setId ( rs . getInt ( "ID" ) ) ;
operation . setType ( Operation . Type . valueOf ( rs . getString ( "TYPE" ) ) ) ;
operation . setCreatedTimeStamp ( new Timestamp ( rs . getLong ( "CREATED_TIMESTAMP" ) * 1000L ) . toString ( ) ) ;
if ( rs . getLong ( "UPDATED_TIMESTAMP" ) = = 0 ) {
if ( rs . getLong ( "UPDATED_TIMESTAMP" ) = = 0 ) {
operation . setReceivedTimeStamp ( "" ) ;
operation . setReceivedTimeStamp ( "" ) ;
} else {
} else {
operation . setReceivedTimeStamp (
operation . setReceivedTimeStamp (
new Timestamp ( ( rs . getLong ( "UPDATED_TIMESTAMP" ) * 1000 ) ) . toString ( ) ) ;
new Timestamp ( ( rs . getLong ( "UPDATED_TIMESTAMP" ) * 1000 ) ) . toString ( ) ) ;
}
}
operation . setCode ( rs . getString ( "OPERATION_CODE" ) ) ;
operation . setInitiatedBy ( rs . getString ( "INITIATED_BY" ) ) ;
if ( MDMAppConstants . AndroidConstants . UNMANAGED_APP_UNINSTALL . equals ( operation . getCode ( ) ) ) {
byte [ ] operationDetails = rs . getBytes ( "OPERATION_DETAILS" ) ;
try ( ByteArrayInputStream bais = new ByteArrayInputStream ( operationDetails ) ;
ObjectInputStream ois = new ObjectInputStream ( bais ) ) {
profileOperation = ( ProfileOperation ) ois . readObject ( ) ;
operation . setPayLoad ( profileOperation . getPayLoad ( ) ) ;
} catch ( IOException e ) {
String msg = "IO Error occurred while retrieving app data of operation " ;
log . error ( msg , e ) ;
throw new OperationManagementDAOException ( msg , e ) ;
} catch ( ClassNotFoundException e ) {
String msg = "Class not found error occurred while retrieving app data of operation " ;
log . error ( msg , e ) ;
throw new OperationManagementDAOException ( msg , e ) ;
}
}
operation . setStatus ( Operation . Status . valueOf ( rs . getString ( "STATUS" ) ) ) ;
operation . setStatus ( Operation . Status . valueOf ( rs . getString ( "STATUS" ) ) ) ;
OperationDAOUtil . setActivityId ( operation , rs . getInt ( "ID" ) ) ;
operations . add ( operation ) ;
operations . add ( operation ) ;
}
}
}
}
@ -1562,7 +1517,6 @@ public class GenericOperationDAOImpl implements OperationDAO {
List < Operation > operations = new ArrayList < > ( ) ;
List < Operation > operations = new ArrayList < > ( ) ;
String createdTo = null ;
String createdTo = null ;
String createdFrom = null ;
String createdFrom = null ;
ProfileOperation profileOperation = null ;
DateFormat simple = new SimpleDateFormat ( "yyyy-MM-dd HH:mm:ss.SSS" ) ;
DateFormat simple = new SimpleDateFormat ( "yyyy-MM-dd HH:mm:ss.SSS" ) ;
boolean isCreatedDayProvided = false ;
boolean isCreatedDayProvided = false ;
boolean isUpdatedDayProvided = false ; //updated day = received day
boolean isUpdatedDayProvided = false ; //updated day = received day
@ -1586,6 +1540,7 @@ public class GenericOperationDAOImpl implements OperationDAO {
"o.OPERATION_CODE, " +
"o.OPERATION_CODE, " +
"o.INITIATED_BY, " +
"o.INITIATED_BY, " +
"o.OPERATION_DETAILS, " +
"o.OPERATION_DETAILS, " +
"o.OPERATION_PROPERTIES, " +
"om.STATUS, " +
"om.STATUS, " +
"om.ID AS OM_MAPPING_ID, " +
"om.ID AS OM_MAPPING_ID, " +
"om.UPDATED_TIMESTAMP " +
"om.UPDATED_TIMESTAMP " +
@ -1672,36 +1627,14 @@ public class GenericOperationDAOImpl implements OperationDAO {
stmt . setInt ( paramIndex , request . getRowCount ( ) ) ;
stmt . setInt ( paramIndex , request . getRowCount ( ) ) ;
try ( ResultSet rs = stmt . executeQuery ( ) ) {
try ( ResultSet rs = stmt . executeQuery ( ) ) {
while ( rs . next ( ) ) {
while ( rs . next ( ) ) {
operation = new Operation ( ) ;
operation = OperationDAOUtil . getOperation ( rs ) ;
operation . setId ( rs . getInt ( "ID" ) ) ;
operation . setType ( Operation . Type . valueOf ( rs . getString ( "TYPE" ) ) ) ;
operation . setCreatedTimeStamp ( new Timestamp ( rs . getLong ( "CREATED_TIMESTAMP" ) * 1000L ) . toString ( ) ) ;
if ( rs . getLong ( "UPDATED_TIMESTAMP" ) = = 0 ) {
if ( rs . getLong ( "UPDATED_TIMESTAMP" ) = = 0 ) {
operation . setReceivedTimeStamp ( "" ) ;
operation . setReceivedTimeStamp ( "" ) ;
} else {
} else {
operation . setReceivedTimeStamp (
operation . setReceivedTimeStamp (
new Timestamp ( ( rs . getLong ( "UPDATED_TIMESTAMP" ) * 1000 ) ) . toString ( ) ) ;
new Timestamp ( ( rs . getLong ( "UPDATED_TIMESTAMP" ) * 1000 ) ) . toString ( ) ) ;
}
}
operation . setCode ( rs . getString ( "OPERATION_CODE" ) ) ;
operation . setInitiatedBy ( rs . getString ( "INITIATED_BY" ) ) ;
if ( MDMAppConstants . AndroidConstants . UNMANAGED_APP_UNINSTALL . equals ( operation . getCode ( ) ) ) {
byte [ ] operationDetails = rs . getBytes ( "OPERATION_DETAILS" ) ;
try ( ByteArrayInputStream bais = new ByteArrayInputStream ( operationDetails ) ;
ObjectInputStream ois = new ObjectInputStream ( bais ) ) {
profileOperation = ( ProfileOperation ) ois . readObject ( ) ;
operation . setPayLoad ( profileOperation . getPayLoad ( ) ) ;
} catch ( IOException e ) {
String msg = "IO Error occurred while retrieving app data of operation " ;
log . error ( msg , e ) ;
throw new OperationManagementDAOException ( msg , e ) ;
} catch ( ClassNotFoundException e ) {
String msg = "Class not found error occurred while retrieving app data of operation " ;
log . error ( msg , e ) ;
throw new OperationManagementDAOException ( msg , e ) ;
}
}
operation . setStatus ( Operation . Status . valueOf ( rs . getString ( "STATUS" ) ) ) ;
operation . setStatus ( Operation . Status . valueOf ( rs . getString ( "STATUS" ) ) ) ;
OperationDAOUtil . setActivityId ( operation , rs . getInt ( "ID" ) ) ;
operations . add ( operation ) ;
operations . add ( operation ) ;
}
}
}
}
@ -1932,7 +1865,8 @@ public class GenericOperationDAOImpl implements OperationDAO {
try {
try {
Connection connection = OperationManagementDAOFactory . getConnection ( ) ;
Connection connection = OperationManagementDAOFactory . getConnection ( ) ;
stmt = connection . prepareStatement ( "SELECT o.ID, o.TYPE, o.CREATED_TIMESTAMP, o.RECEIVED_TIMESTAMP, " +
stmt = connection . prepareStatement ( "SELECT o.ID, o.TYPE, o.CREATED_TIMESTAMP, o.RECEIVED_TIMESTAMP, " +
"o.OPERATION_CODE, o.INITIATED_BY, om.ID AS OM_MAPPING_ID, om.UPDATED_TIMESTAMP FROM DM_OPERATION o " +
"o.OPERATION_CODE, o.INITIATED_BY, o.OPERATION_DETAILS, o.OPERATION_PROPERTIES, " +
"om.ID AS OM_MAPPING_ID, om.UPDATED_TIMESTAMP FROM DM_OPERATION o " +
"INNER JOIN (SELECT * FROM DM_ENROLMENT_OP_MAPPING dm " +
"INNER JOIN (SELECT * FROM DM_ENROLMENT_OP_MAPPING dm " +
"WHERE dm.ENROLMENT_ID = ? AND dm.STATUS = ?) om ON o.ID = om.OPERATION_ID " +
"WHERE dm.ENROLMENT_ID = ? AND dm.STATUS = ?) om ON o.ID = om.OPERATION_ID " +
"ORDER BY om.UPDATED_TIMESTAMP ASC, om.ID ASC LIMIT 1" ) ;
"ORDER BY om.UPDATED_TIMESTAMP ASC, om.ID ASC LIMIT 1" ) ;
@ -1942,21 +1876,14 @@ public class GenericOperationDAOImpl implements OperationDAO {
Operation operation = null ;
Operation operation = null ;
if ( rs . next ( ) ) {
if ( rs . next ( ) ) {
operation = new Operation ( ) ;
operation = OperationDAOUtil . getOperation ( rs ) ;
operation . setType ( OperationDAOUtil . getType ( rs . getString ( "TYPE" ) ) ) ;
operation . setId ( rs . getInt ( "ID" ) ) ;
operation . setCreatedTimeStamp ( new Timestamp ( rs . getLong ( "CREATED_TIMESTAMP" ) * 1000L ) . toString ( ) ) ;
if ( rs . getLong ( "UPDATED_TIMESTAMP" ) = = 0 ) {
if ( rs . getLong ( "UPDATED_TIMESTAMP" ) = = 0 ) {
operation . setReceivedTimeStamp ( "" ) ;
operation . setReceivedTimeStamp ( "" ) ;
} else {
} else {
operation . setReceivedTimeStamp (
operation . setReceivedTimeStamp (
new Timestamp ( ( rs . getLong ( "UPDATED_TIMESTAMP" ) * 1000 ) ) . toString ( ) ) ;
new Timestamp ( ( rs . getLong ( "UPDATED_TIMESTAMP" ) * 1000 ) ) . toString ( ) ) ;
}
}
operation . setCode ( rs . getString ( "OPERATION_CODE" ) ) ;
operation . setInitiatedBy ( rs . getString ( "INITIATED_BY" ) ) ;
operation . setStatus ( Operation . Status . PENDING ) ;
operation . setStatus ( Operation . Status . PENDING ) ;
OperationDAOUtil . setActivityId ( operation , rs . getInt ( "ID" ) ) ;
}
}
return operation ;
return operation ;
} catch ( SQLException e ) {
} catch ( SQLException e ) {
@ -1975,8 +1902,9 @@ public class GenericOperationDAOImpl implements OperationDAO {
List < Operation > operations = new ArrayList < > ( ) ;
List < Operation > operations = new ArrayList < > ( ) ;
try {
try {
Connection conn = OperationManagementDAOFactory . getConnection ( ) ;
Connection conn = OperationManagementDAOFactory . getConnection ( ) ;
String sql = "SELECT o.ID, TYPE, o.CREATED_TIMESTAMP, o.RECEIVED_TIMESTAMP, OPERATION_CODE, o.INITIATED_BY," +
String sql = "SELECT o.ID, TYPE, o.CREATED_TIMESTAMP, o.RECEIVED_TIMESTAMP, OPERATION_CODE, " +
" om.ID AS OM_MAPPING_ID, om.UPDATED_TIMESTAMP FROM " +
"o.INITIATED_BY, o.OPERATION_DETAILS, o.OPERATION_PROPERTIES, " +
"om.ID AS OM_MAPPING_ID, om.UPDATED_TIMESTAMP FROM " +
"(SELECT o.ID, TYPE, CREATED_TIMESTAMP, RECEIVED_TIMESTAMP, OPERATION_CODE, INITIATED_BY " +
"(SELECT o.ID, TYPE, CREATED_TIMESTAMP, RECEIVED_TIMESTAMP, OPERATION_CODE, INITIATED_BY " +
"FROM DM_OPERATION o WHERE o.TYPE = ?) o INNER JOIN (SELECT * FROM DM_ENROLMENT_OP_MAPPING dm " +
"FROM DM_OPERATION o WHERE o.TYPE = ?) o INNER JOIN (SELECT * FROM DM_ENROLMENT_OP_MAPPING dm " +
"WHERE dm.ENROLMENT_ID = ? AND dm.STATUS = ?) om ON o.ID = om.OPERATION_ID ORDER BY o.CREATED_TIMESTAMP ASC" ;
"WHERE dm.ENROLMENT_ID = ? AND dm.STATUS = ?) om ON o.ID = om.OPERATION_ID ORDER BY o.CREATED_TIMESTAMP ASC" ;
@ -1988,19 +1916,14 @@ public class GenericOperationDAOImpl implements OperationDAO {
rs = stmt . executeQuery ( ) ;
rs = stmt . executeQuery ( ) ;
while ( rs . next ( ) ) {
while ( rs . next ( ) ) {
operation = new Operation ( ) ;
operation = OperationDAOUtil . getOperation ( rs ) ;
operation . setId ( rs . getInt ( "ID" ) ) ;
operation . setStatus ( status ) ;
operation . setType ( Operation . Type . valueOf ( rs . getString ( "TYPE" ) ) ) ;
operation . setCreatedTimeStamp ( new Timestamp ( rs . getLong ( "CREATED_TIMESTAMP" ) * 1000L ) . toString ( ) ) ;
if ( rs . getLong ( "UPDATED_TIMESTAMP" ) = = 0 ) {
if ( rs . getLong ( "UPDATED_TIMESTAMP" ) = = 0 ) {
operation . setReceivedTimeStamp ( "" ) ;
operation . setReceivedTimeStamp ( "" ) ;
} else {
} else {
operation . setReceivedTimeStamp (
operation . setReceivedTimeStamp (
new Timestamp ( ( rs . getLong ( "UPDATED_TIMESTAMP" ) * 1000 ) ) . toString ( ) ) ;
new Timestamp ( ( rs . getLong ( "UPDATED_TIMESTAMP" ) * 1000 ) ) . toString ( ) ) ;
}
}
operation . setCode ( rs . getString ( "OPERATION_CODE" ) ) ;
operation . setInitiatedBy ( rs . getString ( "INITIATED_BY" ) ) ;
OperationDAOUtil . setActivityId ( operation , rs . getInt ( "ID" ) ) ;
operations . add ( operation ) ;
operations . add ( operation ) ;
}
}
} catch ( SQLException e ) {
} catch ( SQLException e ) {
@ -2013,7 +1936,8 @@ public class GenericOperationDAOImpl implements OperationDAO {
}
}
@Override
@Override
public Map < Integer , List < OperationMapping > > getOperationMappingsByStatus ( Operation . Status opStatus , Operation . PushNotificationStatus pushNotificationStatus ,
public Map < Integer , List < OperationMapping > > getOperationMappingsByStatus ( Operation . Status opStatus ,
Operation . PushNotificationStatus pushNotificationStatus ,
int limit ) throws OperationManagementDAOException {
int limit ) throws OperationManagementDAOException {
PreparedStatement stmt = null ;
PreparedStatement stmt = null ;
ResultSet rs = null ;
ResultSet rs = null ;
@ -2059,7 +1983,8 @@ public class GenericOperationDAOImpl implements OperationDAO {
@Override
@Override
public Map < Integer , List < OperationMapping > > getAllocatedOperationMappingsByStatus ( Operation . Status opStatus ,
public Map < Integer , List < OperationMapping > > getAllocatedOperationMappingsByStatus ( Operation . Status opStatus ,
Operation . PushNotificationStatus pushNotificationStatus , int limit , int activeServerCount , int serverIndex )
Operation . PushNotificationStatus pushNotificationStatus ,
int limit , int activeServerCount , int serverIndex )
throws OperationManagementDAOException {
throws OperationManagementDAOException {
PreparedStatement stmt = null ;
PreparedStatement stmt = null ;
ResultSet rs = null ;
ResultSet rs = null ;
@ -2272,7 +2197,7 @@ public class GenericOperationDAOImpl implements OperationDAO {
if ( activityPaginationRequest . getDeviceType ( ) ! = null | |
if ( activityPaginationRequest . getDeviceType ( ) ! = null | |
( activityPaginationRequest . getDeviceIds ( ) ! = null & & ! activityPaginationRequest . getDeviceIds ( ) . isEmpty ( ) ) | |
( activityPaginationRequest . getDeviceIds ( ) ! = null & & ! activityPaginationRequest . getDeviceIds ( ) . isEmpty ( ) ) | |
activityPaginationRequest . getSince ( ) ! = 0 | |
activityPaginationRequest . getSince ( ) ! = 0 | |
activityPaginationRequest . getStatus ( ) ! = null ) {
activityPaginationRequest . getStatus es ( ) ! = null ) {
sql . append ( "(SELECT DISTINCT OPERATION_ID FROM DM_ENROLMENT_OP_MAPPING eom WHERE TENANT_ID = ? " ) ;
sql . append ( "(SELECT DISTINCT OPERATION_ID FROM DM_ENROLMENT_OP_MAPPING eom WHERE TENANT_ID = ? " ) ;
@ -2305,8 +2230,12 @@ public class GenericOperationDAOImpl implements OperationDAO {
if ( activityPaginationRequest . getType ( ) ! = null ) {
if ( activityPaginationRequest . getType ( ) ! = null ) {
sql . append ( "AND TYPE = ? " ) ;
sql . append ( "AND TYPE = ? " ) ;
}
}
if ( activityPaginationRequest . getStatus ( ) ! = null ) {
if ( activityPaginationRequest . getStatuses ( ) ! = null & & ! activityPaginationRequest . getStatuses ( ) . isEmpty ( ) ) {
sql . append ( "AND STATUS = ? " ) ;
sql . append ( "AND STATUS IN (" ) ;
for ( int i = 0 ; i < activityPaginationRequest . getStatuses ( ) . size ( ) - 1 ; i + + ) {
sql . append ( "?, " ) ;
}
sql . append ( "?) " ) ;
}
}
sql . append ( "ORDER BY OPERATION_ID ASC limit ? , ? ) eom_ordered " +
sql . append ( "ORDER BY OPERATION_ID ASC limit ? , ? ) eom_ordered " +
@ -2360,8 +2289,12 @@ public class GenericOperationDAOImpl implements OperationDAO {
if ( activityPaginationRequest . getType ( ) ! = null ) {
if ( activityPaginationRequest . getType ( ) ! = null ) {
sql . append ( "AND eom.TYPE = ? " ) ;
sql . append ( "AND eom.TYPE = ? " ) ;
}
}
if ( activityPaginationRequest . getStatus ( ) ! = null ) {
if ( activityPaginationRequest . getStatuses ( ) ! = null & & ! activityPaginationRequest . getStatuses ( ) . isEmpty ( ) ) {
sql . append ( "AND eom.STATUS = ? " ) ;
sql . append ( "AND eom.STATUS IN (" ) ;
for ( int i = 0 ; i < activityPaginationRequest . getStatuses ( ) . size ( ) - 1 ; i + + ) {
sql . append ( "?, " ) ;
}
sql . append ( "?) " ) ;
}
}
sql . append ( "ORDER BY eom.OPERATION_ID, eom.UPDATED_TIMESTAMP" ) ;
sql . append ( "ORDER BY eom.OPERATION_ID, eom.UPDATED_TIMESTAMP" ) ;
@ -2372,7 +2305,7 @@ public class GenericOperationDAOImpl implements OperationDAO {
if ( activityPaginationRequest . getDeviceType ( ) ! = null | |
if ( activityPaginationRequest . getDeviceType ( ) ! = null | |
( activityPaginationRequest . getDeviceIds ( ) ! = null & & ! activityPaginationRequest . getDeviceIds ( ) . isEmpty ( ) ) | |
( activityPaginationRequest . getDeviceIds ( ) ! = null & & ! activityPaginationRequest . getDeviceIds ( ) . isEmpty ( ) ) | |
activityPaginationRequest . getSince ( ) ! = 0 | |
activityPaginationRequest . getSince ( ) ! = 0 | |
activityPaginationRequest . getStatus ( ) ! = null ) {
activityPaginationRequest . getStatus es ( ) ! = null ) {
if ( activityPaginationRequest . getDeviceType ( ) ! = null ) {
if ( activityPaginationRequest . getDeviceType ( ) ! = null ) {
stmt . setString ( index + + , activityPaginationRequest . getDeviceType ( ) ) ;
stmt . setString ( index + + , activityPaginationRequest . getDeviceType ( ) ) ;
@ -2401,8 +2334,10 @@ public class GenericOperationDAOImpl implements OperationDAO {
if ( activityPaginationRequest . getType ( ) ! = null ) {
if ( activityPaginationRequest . getType ( ) ! = null ) {
stmt . setString ( index + + , activityPaginationRequest . getType ( ) . name ( ) ) ;
stmt . setString ( index + + , activityPaginationRequest . getType ( ) . name ( ) ) ;
}
}
if ( activityPaginationRequest . getStatus ( ) ! = null ) {
if ( activityPaginationRequest . getStatuses ( ) ! = null & & ! activityPaginationRequest . getStatuses ( ) . isEmpty ( ) ) {
stmt . setString ( index + + , activityPaginationRequest . getStatus ( ) . name ( ) ) ;
for ( io . entgra . device . mgt . core . device . mgt . common . operation . mgt . Operation . Status status : activityPaginationRequest . getStatuses ( ) ) {
stmt . setString ( index + + , status . name ( ) ) ;
}
}
}
stmt . setInt ( index + + , activityPaginationRequest . getOffset ( ) ) ;
stmt . setInt ( index + + , activityPaginationRequest . getOffset ( ) ) ;
@ -2463,8 +2398,10 @@ public class GenericOperationDAOImpl implements OperationDAO {
if ( activityPaginationRequest . getType ( ) ! = null ) {
if ( activityPaginationRequest . getType ( ) ! = null ) {
stmt . setString ( index + + , activityPaginationRequest . getType ( ) . name ( ) ) ;
stmt . setString ( index + + , activityPaginationRequest . getType ( ) . name ( ) ) ;
}
}
if ( activityPaginationRequest . getStatus ( ) ! = null ) {
if ( activityPaginationRequest . getStatuses ( ) ! = null & & ! activityPaginationRequest . getStatuses ( ) . isEmpty ( ) ) {
stmt . setString ( index , activityPaginationRequest . getStatus ( ) . name ( ) ) ;
for ( io . entgra . device . mgt . core . device . mgt . common . operation . mgt . Operation . Status status : activityPaginationRequest . getStatuses ( ) ) {
stmt . setString ( index + + , status . name ( ) ) ;
}
}
}
try ( ResultSet rs = stmt . executeQuery ( ) ) {
try ( ResultSet rs = stmt . executeQuery ( ) ) {
@ -2496,7 +2433,7 @@ public class GenericOperationDAOImpl implements OperationDAO {
if ( activityPaginationRequest . getDeviceType ( ) ! = null | |
if ( activityPaginationRequest . getDeviceType ( ) ! = null | |
( activityPaginationRequest . getDeviceIds ( ) ! = null & & ! activityPaginationRequest . getDeviceIds ( ) . isEmpty ( ) ) | |
( activityPaginationRequest . getDeviceIds ( ) ! = null & & ! activityPaginationRequest . getDeviceIds ( ) . isEmpty ( ) ) | |
activityPaginationRequest . getSince ( ) ! = 0 | |
activityPaginationRequest . getSince ( ) ! = 0 | |
activityPaginationRequest . getStatus ( ) ! = null ) {
activityPaginationRequest . getStatus es ( ) ! = null ) {
sql . append ( "SELECT count(DISTINCT OPERATION_ID) AS ACTIVITY_COUNT " +
sql . append ( "SELECT count(DISTINCT OPERATION_ID) AS ACTIVITY_COUNT " +
"FROM DM_ENROLMENT_OP_MAPPING WHERE TENANT_ID = ? " ) ;
"FROM DM_ENROLMENT_OP_MAPPING WHERE TENANT_ID = ? " ) ;
@ -2526,8 +2463,12 @@ public class GenericOperationDAOImpl implements OperationDAO {
if ( activityPaginationRequest . getType ( ) ! = null ) {
if ( activityPaginationRequest . getType ( ) ! = null ) {
sql . append ( "AND TYPE = ? " ) ;
sql . append ( "AND TYPE = ? " ) ;
}
}
if ( activityPaginationRequest . getStatus ( ) ! = null ) {
if ( activityPaginationRequest . getStatuses ( ) ! = null & & ! activityPaginationRequest . getStatuses ( ) . isEmpty ( ) ) {
sql . append ( "AND STATUS = ? " ) ;
sql . append ( "AND STATUS IN (" ) ;
for ( int i = 0 ; i < activityPaginationRequest . getStatuses ( ) . size ( ) - 1 ; i + + ) {
sql . append ( "?, " ) ;
}
sql . append ( "?) " ) ;
}
}
} else {
} else {
@ -2555,7 +2496,7 @@ public class GenericOperationDAOImpl implements OperationDAO {
if ( activityPaginationRequest . getDeviceType ( ) ! = null | |
if ( activityPaginationRequest . getDeviceType ( ) ! = null | |
( activityPaginationRequest . getDeviceIds ( ) ! = null & & ! activityPaginationRequest . getDeviceIds ( ) . isEmpty ( ) ) | |
( activityPaginationRequest . getDeviceIds ( ) ! = null & & ! activityPaginationRequest . getDeviceIds ( ) . isEmpty ( ) ) | |
activityPaginationRequest . getSince ( ) ! = 0 | |
activityPaginationRequest . getSince ( ) ! = 0 | |
activityPaginationRequest . getStatus ( ) ! = null ) {
activityPaginationRequest . getStatus es ( ) ! = null ) {
if ( activityPaginationRequest . getDeviceType ( ) ! = null ) {
if ( activityPaginationRequest . getDeviceType ( ) ! = null ) {
stmt . setString ( index + + , activityPaginationRequest . getDeviceType ( ) ) ;
stmt . setString ( index + + , activityPaginationRequest . getDeviceType ( ) ) ;
}
}
@ -2579,8 +2520,10 @@ public class GenericOperationDAOImpl implements OperationDAO {
if ( activityPaginationRequest . getType ( ) ! = null ) {
if ( activityPaginationRequest . getType ( ) ! = null ) {
stmt . setString ( index + + , activityPaginationRequest . getType ( ) . name ( ) ) ;
stmt . setString ( index + + , activityPaginationRequest . getType ( ) . name ( ) ) ;
}
}
if ( activityPaginationRequest . getStatus ( ) ! = null ) {
if ( activityPaginationRequest . getStatuses ( ) ! = null & & ! activityPaginationRequest . getStatuses ( ) . isEmpty ( ) ) {
stmt . setString ( index + + , activityPaginationRequest . getStatus ( ) . name ( ) ) ;
for ( io . entgra . device . mgt . core . device . mgt . common . operation . mgt . Operation . Status status : activityPaginationRequest . getStatuses ( ) ) {
stmt . setString ( index + + , status . name ( ) ) ;
}
}
}
} else {
} else {
if ( activityPaginationRequest . getOperationCode ( ) ! = null ) {
if ( activityPaginationRequest . getOperationCode ( ) ! = null ) {
@ -2662,8 +2605,12 @@ public class GenericOperationDAOImpl implements OperationDAO {
if ( activityPaginationRequest . getType ( ) ! = null ) {
if ( activityPaginationRequest . getType ( ) ! = null ) {
sql . append ( "AND TYPE = ? " ) ;
sql . append ( "AND TYPE = ? " ) ;
}
}
if ( activityPaginationRequest . getStatus ( ) ! = null ) {
if ( activityPaginationRequest . getStatuses ( ) ! = null & & ! activityPaginationRequest . getStatuses ( ) . isEmpty ( ) ) {
sql . append ( "AND STATUS = ? " ) ;
sql . append ( "AND STATUS IN (" ) ;
for ( int i = 0 ; i < activityPaginationRequest . getStatuses ( ) . size ( ) - 1 ; i + + ) {
sql . append ( "?, " ) ;
}
sql . append ( "?) " ) ;
}
}
sql . append ( "ORDER BY ID ASC limit ? , ? ) eom " +
sql . append ( "ORDER BY ID ASC limit ? , ? ) eom " +
@ -2700,8 +2647,10 @@ public class GenericOperationDAOImpl implements OperationDAO {
if ( activityPaginationRequest . getType ( ) ! = null ) {
if ( activityPaginationRequest . getType ( ) ! = null ) {
stmt . setString ( index + + , activityPaginationRequest . getType ( ) . name ( ) ) ;
stmt . setString ( index + + , activityPaginationRequest . getType ( ) . name ( ) ) ;
}
}
if ( activityPaginationRequest . getStatus ( ) ! = null ) {
if ( activityPaginationRequest . getStatuses ( ) ! = null & & ! activityPaginationRequest . getStatuses ( ) . isEmpty ( ) ) {
stmt . setString ( index + + , activityPaginationRequest . getStatus ( ) . name ( ) ) ;
for ( io . entgra . device . mgt . core . device . mgt . common . operation . mgt . Operation . Status status : activityPaginationRequest . getStatuses ( ) ) {
stmt . setString ( index + + , status . name ( ) ) ;
}
}
}
stmt . setInt ( index + + , activityPaginationRequest . getOffset ( ) ) ;
stmt . setInt ( index + + , activityPaginationRequest . getOffset ( ) ) ;
@ -2744,7 +2693,6 @@ public class GenericOperationDAOImpl implements OperationDAO {
int tenantId = PrivilegedCarbonContext . getThreadLocalCarbonContext ( ) . getTenantId ( ) ;
int tenantId = PrivilegedCarbonContext . getThreadLocalCarbonContext ( ) . getTenantId ( ) ;
StringBuilder sql = new StringBuilder ( ) ;
StringBuilder sql = new StringBuilder ( ) ;
sql . append ( "SELECT count(DISTINCT ID) AS ACTIVITY_COUNT " +
sql . append ( "SELECT count(DISTINCT ID) AS ACTIVITY_COUNT " +
"FROM DM_ENROLMENT_OP_MAPPING WHERE TENANT_ID = ? " ) ;
"FROM DM_ENROLMENT_OP_MAPPING WHERE TENANT_ID = ? " ) ;
@ -2773,8 +2721,12 @@ public class GenericOperationDAOImpl implements OperationDAO {
if ( activityPaginationRequest . getType ( ) ! = null ) {
if ( activityPaginationRequest . getType ( ) ! = null ) {
sql . append ( "AND TYPE = ? " ) ;
sql . append ( "AND TYPE = ? " ) ;
}
}
if ( activityPaginationRequest . getStatus ( ) ! = null ) {
if ( activityPaginationRequest . getStatuses ( ) ! = null & & ! activityPaginationRequest . getStatuses ( ) . isEmpty ( ) ) {
sql . append ( "AND STATUS = ? " ) ;
sql . append ( "AND STATUS IN (" ) ;
for ( int i = 0 ; i < activityPaginationRequest . getStatuses ( ) . size ( ) - 1 ; i + + ) {
sql . append ( "?, " ) ;
}
sql . append ( "?) " ) ;
}
}
if ( activityPaginationRequest . getStartTimestamp ( ) > 0 & & activityPaginationRequest . getEndTimestamp ( ) > 0 ) {
if ( activityPaginationRequest . getStartTimestamp ( ) > 0 & & activityPaginationRequest . getEndTimestamp ( ) > 0 ) {
@ -2808,8 +2760,10 @@ public class GenericOperationDAOImpl implements OperationDAO {
if ( activityPaginationRequest . getType ( ) ! = null ) {
if ( activityPaginationRequest . getType ( ) ! = null ) {
stmt . setString ( index + + , activityPaginationRequest . getType ( ) . name ( ) ) ;
stmt . setString ( index + + , activityPaginationRequest . getType ( ) . name ( ) ) ;
}
}
if ( activityPaginationRequest . getStatus ( ) ! = null ) {
if ( activityPaginationRequest . getStatuses ( ) ! = null & & ! activityPaginationRequest . getStatuses ( ) . isEmpty ( ) ) {
stmt . setString ( index + + , activityPaginationRequest . getStatus ( ) . name ( ) ) ;
for ( io . entgra . device . mgt . core . device . mgt . common . operation . mgt . Operation . Status status : activityPaginationRequest . getStatuses ( ) ) {
stmt . setString ( index + + , status . name ( ) ) ;
}
}
}
if ( isTimeDurationFilteringProvided ) {
if ( isTimeDurationFilteringProvided ) {