Merge pull request #46 from dilee/master

Refactored Enrollment DAO class
revert-70aa11f8
Geeth 9 years ago
commit a91e3056c7

@ -71,6 +71,7 @@ public class EnrollmentDAOImpl implements EnrollmentDAO {
PreparedStatement stmt = null;
ResultSet rs = null;
int status = -1;
int rows;
try {
conn = this.getConnection();
String sql = "UPDATE DM_ENROLMENT SET OWNERSHIP = ?, STATUS = ?, " +
@ -85,12 +86,12 @@ public class EnrollmentDAOImpl implements EnrollmentDAO {
stmt.setString(6, enrolmentInfo.getOwner());
stmt.setInt(7, tenantId);
stmt.setInt(8, enrolmentInfo.getId());
stmt.executeUpdate();
rows = stmt.executeUpdate();
rs = stmt.getGeneratedKeys();
if (rs.next()) {
if (rows > 0) {
status = 1;
}
return status;
} catch (SQLException e) {
throw new DeviceManagementDAOException("Error occurred while updating enrolment configuration", e);

@ -59,7 +59,7 @@ public class CommandOperationDAOImpl extends OperationDAOImpl {
try {
Connection connection = OperationManagementDAOFactory.getConnection();
stmt = connection.prepareStatement(
"UPDATE DM_COMMAND_OPERATION O SET O.ENABLED = ? WHERE O.OPERATION_ID = ?");
"UPDATE DM_COMMAND_OPERATION SET ENABLED = ? WHERE OPERATION_ID = ?");
stmt.setBoolean(1, operation.isEnabled());
stmt.setInt(2, operation.getId());
stmt.executeUpdate();

@ -82,8 +82,8 @@ public class ConfigOperationDAOImpl extends OperationDAOImpl {
try {
super.updateOperation(operation);
Connection connection = OperationManagementDAOFactory.getConnection();
stmt = connection.prepareStatement("UPDATE DM_CONFIG_OPERATION O SET O.OPERATION_CONFIG = ? " +
"WHERE O.OPERATION_ID = ?");
stmt = connection.prepareStatement("UPDATE DM_CONFIG_OPERATION SET OPERATION_CONFIG = ? " +
"WHERE OPERATION_ID = ?");
bao = new ByteArrayOutputStream();
oos = new ObjectOutputStream(bao);
oos.writeObject(operation);

@ -70,8 +70,8 @@ public class OperationDAOImpl implements OperationDAO {
PreparedStatement stmt = null;
try {
Connection connection = OperationManagementDAOFactory.getConnection();
stmt = connection.prepareStatement("UPDATE DM_OPERATION O SET O.RECEIVED_TIMESTAMP=? " +
"WHERE O.ID=?");
stmt = connection.prepareStatement("UPDATE DM_OPERATION SET RECEIVED_TIMESTAMP=? " +
"WHERE ID=?");
stmt.setTimestamp(1, new Timestamp(new Date().getTime()));
stmt.setInt(2, operation.getId());
stmt.executeUpdate();
@ -87,8 +87,8 @@ public class OperationDAOImpl implements OperationDAO {
PreparedStatement stmt = null;
try {
Connection connection = OperationManagementDAOFactory.getConnection();
stmt = connection.prepareStatement("UPDATE DM_ENROLMENT_OP_MAPPING O SET O.STATUS=? " +
"WHERE O.ENROLMENT_ID=? and O.OPERATION_ID=?");
stmt = connection.prepareStatement("UPDATE DM_ENROLMENT_OP_MAPPING SET STATUS=? " +
"WHERE ENROLMENT_ID=? and OPERATION_ID=?");
stmt.setString(1, status.toString());
stmt.setInt(2, enrolmentId);
stmt.setInt(3, operationId);

@ -90,8 +90,8 @@ public class PolicyOperationDAOImpl extends OperationDAOImpl {
try {
super.updateOperation(operation);
Connection connection = OperationManagementDAOFactory.getConnection();
stmt = connection.prepareStatement("UPDATE DM_POLICY_OPERATION O SET O.OPERATION_DETAILS=? " +
"WHERE O.OPERATION_ID=?");
stmt = connection.prepareStatement("UPDATE DM_POLICY_OPERATION SET OPERATION_DETAILS=? " +
"WHERE OPERATION_ID=?");
bao = new ByteArrayOutputStream();
oos = new ObjectOutputStream(bao);
oos.writeObject(operation);

@ -90,8 +90,8 @@ public class ProfileOperationDAOImpl extends OperationDAOImpl {
try {
super.updateOperation(operation);
Connection connection = OperationManagementDAOFactory.getConnection();
stmt = connection.prepareStatement("UPDATE DM_PROFILE_OPERATION O SET O.OPERATION_DETAILS=? " +
"WHERE O.OPERATION_ID=?");
stmt = connection.prepareStatement("UPDATE DM_PROFILE_OPERATION SET OPERATION_DETAILS=? " +
"WHERE OPERATION_ID=?");
bao = new ByteArrayOutputStream();
oos = new ObjectOutputStream(bao);

Loading…
Cancel
Save