mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Refactored ApplicationMapping and ProfileOperation DAO classes
This commit is contained in:
parent
27254cc922
commit
91d9db1ffa
@ -73,7 +73,7 @@ public class ApplicationMappingDAOImpl implements ApplicationMappingDAO {
|
|||||||
Connection conn;
|
Connection conn;
|
||||||
PreparedStatement stmt = null;
|
PreparedStatement stmt = null;
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
List<Integer> mappingIds = new ArrayList<>();
|
|
||||||
try {
|
try {
|
||||||
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, " +
|
||||||
|
|||||||
@ -37,22 +37,46 @@ public class ProfileOperationDAOImpl extends OperationDAOImpl {
|
|||||||
|
|
||||||
public int addOperation(Operation operation) throws OperationManagementDAOException {
|
public int addOperation(Operation operation) throws OperationManagementDAOException {
|
||||||
PreparedStatement stmt = null;
|
PreparedStatement stmt = null;
|
||||||
|
ByteArrayOutputStream bao = null;
|
||||||
|
ObjectOutputStream oos = null;
|
||||||
|
|
||||||
int operationId;
|
int operationId;
|
||||||
try {
|
try {
|
||||||
operationId = super.addOperation(operation);
|
operationId = super.addOperation(operation);
|
||||||
operation.setCreatedTimeStamp(new Timestamp(new java.util.Date().getTime()).toString());
|
operation.setCreatedTimeStamp(new Timestamp(new java.util.Date().getTime()).toString());
|
||||||
operation.setId(operationId);
|
operation.setId(operationId);
|
||||||
operation.setEnabled(true);
|
operation.setEnabled(true);
|
||||||
ProfileOperation profileOp = (ProfileOperation) operation;
|
//ProfileOperation profileOp = (ProfileOperation) operation;
|
||||||
Connection conn = OperationManagementDAOFactory.getConnection();
|
Connection conn = OperationManagementDAOFactory.getConnection();
|
||||||
stmt = conn.prepareStatement("INSERT INTO DM_PROFILE_OPERATION(OPERATION_ID, OPERATION_DETAILS) " +
|
stmt = conn.prepareStatement("INSERT INTO DM_PROFILE_OPERATION(OPERATION_ID, OPERATION_DETAILS) " +
|
||||||
"VALUES(?, ?)");
|
"VALUES(?, ?)");
|
||||||
|
|
||||||
|
bao = new ByteArrayOutputStream();
|
||||||
|
oos = new ObjectOutputStream(bao);
|
||||||
|
oos.writeObject(operation);
|
||||||
|
|
||||||
stmt.setInt(1, operationId);
|
stmt.setInt(1, operationId);
|
||||||
stmt.setObject(2, profileOp);
|
stmt.setBytes(2, bao.toByteArray());
|
||||||
stmt.executeUpdate();
|
stmt.executeUpdate();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw new OperationManagementDAOException("Error occurred while adding profile operation", e);
|
throw new OperationManagementDAOException("Error occurred while adding profile operation", e);
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new OperationManagementDAOException("Error occurred while serializing profile operation object", e);
|
||||||
} finally {
|
} finally {
|
||||||
|
if (bao != null) {
|
||||||
|
try {
|
||||||
|
bao.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
log.warn("Error occurred while closing ByteArrayOutputStream", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (oos != null) {
|
||||||
|
try {
|
||||||
|
oos.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
log.warn("Error occurred while closing ObjectOutputStream", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
OperationManagementDAOUtil.cleanupResources(stmt);
|
OperationManagementDAOUtil.cleanupResources(stmt);
|
||||||
}
|
}
|
||||||
return operationId;
|
return operationId;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user