Modified Application Mapping DAO classes

revert-70aa11f8
Dileesha Rajapakse 9 years ago
parent 7b2cfd69f5
commit 6f0276ab2f

@ -26,7 +26,7 @@ public interface ApplicationMappingDAO {
int addApplicationMapping(int deviceId, int applicationId, int tenantId) throws DeviceManagementDAOException; int addApplicationMapping(int deviceId, int applicationId, int tenantId) throws DeviceManagementDAOException;
List<Integer> addApplicationMappings(int deviceId, List<Integer> applicationIds, int tenantId) void addApplicationMappings(int deviceId, List<Integer> applicationIds, int tenantId)
throws DeviceManagementDAOException; throws DeviceManagementDAOException;
void removeApplicationMapping(int deviceId, List<Integer> appIdList, int tenantId) void removeApplicationMapping(int deviceId, List<Integer> appIdList, int tenantId)

@ -49,7 +49,7 @@ public class ApplicationMappingDAOImpl implements ApplicationMappingDAO {
conn = this.getConnection(); conn = this.getConnection();
String sql = "INSERT INTO DM_DEVICE_APPLICATION_MAPPING (DEVICE_ID, APPLICATION_ID, " + String sql = "INSERT INTO DM_DEVICE_APPLICATION_MAPPING (DEVICE_ID, APPLICATION_ID, " +
"TENANT_ID) VALUES (?, ?, ?)"; "TENANT_ID) VALUES (?, ?, ?)";
stmt = conn.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS); stmt = conn.prepareStatement(sql, new String[] {"id"});
stmt.setInt(1, deviceId); stmt.setInt(1, deviceId);
stmt.setInt(2, applicationId); stmt.setInt(2, applicationId);
stmt.setInt(3, tenantId); stmt.setInt(3, tenantId);
@ -68,7 +68,7 @@ public class ApplicationMappingDAOImpl implements ApplicationMappingDAO {
} }
@Override @Override
public List<Integer> addApplicationMappings(int deviceId, List<Integer> applicationIds, public void addApplicationMappings(int deviceId, List<Integer> applicationIds,
int tenantId) throws DeviceManagementDAOException { int tenantId) throws DeviceManagementDAOException {
Connection conn; Connection conn;
PreparedStatement stmt = null; PreparedStatement stmt = null;
@ -78,7 +78,7 @@ public class ApplicationMappingDAOImpl implements ApplicationMappingDAO {
conn = this.getConnection(); conn = this.getConnection();
String sql = "INSERT INTO DM_DEVICE_APPLICATION_MAPPING (DEVICE_ID, APPLICATION_ID, " + String sql = "INSERT INTO DM_DEVICE_APPLICATION_MAPPING (DEVICE_ID, APPLICATION_ID, " +
"TENANT_ID) VALUES (?, ?, ?)"; "TENANT_ID) VALUES (?, ?, ?)";
stmt = conn.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS); stmt = conn.prepareStatement(sql);
for (int applicationId : applicationIds) { for (int applicationId : applicationIds) {
stmt.setInt(1, deviceId); stmt.setInt(1, deviceId);
@ -88,11 +88,11 @@ public class ApplicationMappingDAOImpl implements ApplicationMappingDAO {
} }
stmt.executeBatch(); stmt.executeBatch();
rs = stmt.getGeneratedKeys(); // rs = stmt.getGeneratedKeys();
while (rs.next()) { // while (rs.next()) {
mappingIds.add(rs.getInt(1)); // mappingIds.add(rs.getInt(1));
} // }
return mappingIds; // return mappingIds;
} catch (SQLException e) { } catch (SQLException e) {
throw new DeviceManagementDAOException("Error occurred while adding device application mappings", e); throw new DeviceManagementDAOException("Error occurred while adding device application mappings", e);
} finally { } finally {
@ -109,7 +109,7 @@ public class ApplicationMappingDAOImpl implements ApplicationMappingDAO {
conn = this.getConnection(); conn = this.getConnection();
String sql = "DELETE DM_DEVICE_APPLICATION_MAPPING WHERE DEVICE_ID = ? AND " + String sql = "DELETE DM_DEVICE_APPLICATION_MAPPING WHERE DEVICE_ID = ? AND " +
"APPLICATION_ID = ? AND TENANT_ID = ?"; "APPLICATION_ID = ? AND TENANT_ID = ?";
stmt = conn.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS); stmt = conn.prepareStatement(sql);
for (Integer appId : appIdList) { for (Integer appId : appIdList) {
stmt.setInt(1, deviceId); stmt.setInt(1, deviceId);

@ -162,7 +162,7 @@ CREATE TABLE DM_DEVICE_OPERATION_RESPONSE (
OPERATION_RESPONSE BLOB DEFAULT NULL, OPERATION_RESPONSE BLOB DEFAULT NULL,
CONSTRAINT PK_DM_DEVICE_OP_RESPONSE PRIMARY KEY (ID), CONSTRAINT PK_DM_DEVICE_OP_RESPONSE PRIMARY KEY (ID),
CONSTRAINT FK_DM_DEVICE_OP_RES_DEVICE FOREIGN KEY (ENROLMENT_ID) REFERENCES CONSTRAINT FK_DM_DEVICE_OP_RES_DEVICE FOREIGN KEY (ENROLMENT_ID) REFERENCES
DM_DEVICE (ID), DM_ENROLMENT (ID),
CONSTRAINT FK_DM_DEVICE_OP_RES_OPERATION FOREIGN KEY (OPERATION_ID) REFERENCES CONSTRAINT FK_DM_DEVICE_OP_RES_OPERATION FOREIGN KEY (OPERATION_ID) REFERENCES
DM_OPERATION (ID) DM_OPERATION (ID)
) )

Loading…
Cancel
Save