|
|
@ -112,8 +112,6 @@ public class ApplicationDAOImpl implements ApplicationDAO {
|
|
|
|
Connection conn;
|
|
|
|
Connection conn;
|
|
|
|
PreparedStatement stmt = null;
|
|
|
|
PreparedStatement stmt = null;
|
|
|
|
ResultSet rs;
|
|
|
|
ResultSet rs;
|
|
|
|
ByteArrayOutputStream bao = null;
|
|
|
|
|
|
|
|
ObjectOutputStream oos = null;
|
|
|
|
|
|
|
|
List<Integer> applicationIds = new ArrayList<>();
|
|
|
|
List<Integer> applicationIds = new ArrayList<>();
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
conn = this.getConnection();
|
|
|
|
conn = this.getConnection();
|
|
|
@ -133,14 +131,15 @@ public class ApplicationDAOImpl implements ApplicationDAO {
|
|
|
|
stmt.setString(7, application.getImageUrl());
|
|
|
|
stmt.setString(7, application.getImageUrl());
|
|
|
|
stmt.setInt(8, tenantId);
|
|
|
|
stmt.setInt(8, tenantId);
|
|
|
|
|
|
|
|
|
|
|
|
bao = new ByteArrayOutputStream();
|
|
|
|
// Removing the application properties saving from the application table.
|
|
|
|
oos = new ObjectOutputStream(bao);
|
|
|
|
stmt.setBigDecimal(9, null);
|
|
|
|
oos.writeObject(application.getAppProperties());
|
|
|
|
|
|
|
|
stmt.setBytes(9, bao.toByteArray());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
stmt.setString(10, application.getApplicationIdentifier());
|
|
|
|
stmt.setString(10, application.getApplicationIdentifier());
|
|
|
|
stmt.setInt(11, application.getMemoryUsage());
|
|
|
|
|
|
|
|
stmt.setBoolean(12, application.isActive());
|
|
|
|
// Removing the application memory
|
|
|
|
|
|
|
|
stmt.setInt(11, 0);
|
|
|
|
|
|
|
|
stmt.setBoolean(12, true);
|
|
|
|
|
|
|
|
|
|
|
|
stmt.executeUpdate();
|
|
|
|
stmt.executeUpdate();
|
|
|
|
|
|
|
|
|
|
|
|
rs = stmt.getGeneratedKeys();
|
|
|
|
rs = stmt.getGeneratedKeys();
|
|
|
@ -151,23 +150,7 @@ public class ApplicationDAOImpl implements ApplicationDAO {
|
|
|
|
return applicationIds;
|
|
|
|
return applicationIds;
|
|
|
|
} catch (SQLException e) {
|
|
|
|
} catch (SQLException e) {
|
|
|
|
throw new DeviceManagementDAOException("Error occurred while adding bulk application list", e);
|
|
|
|
throw new DeviceManagementDAOException("Error occurred while adding bulk application list", e);
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
|
|
|
throw new DeviceManagementDAOException("Error occurred while serializing application properties object", e);
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
if (bao != null) {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
bao.close();
|
|
|
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
|
|
|
log.error("Error occurred while closing ByteArrayOutputStream", e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (oos != null) {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
oos.close();
|
|
|
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
|
|
|
log.error("Error occurred while closing ObjectOutputStream", e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
DeviceManagementDAOUtil.cleanupResources(stmt, null);
|
|
|
|
DeviceManagementDAOUtil.cleanupResources(stmt, null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -264,6 +247,38 @@ public class ApplicationDAOImpl implements ApplicationDAO {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public Application getApplication(String identifier, String version, int deviceId, int tenantId) throws DeviceManagementDAOException {
|
|
|
|
|
|
|
|
Connection conn;
|
|
|
|
|
|
|
|
PreparedStatement stmt = null;
|
|
|
|
|
|
|
|
ResultSet rs = null;
|
|
|
|
|
|
|
|
Application application = null;
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
conn = this.getConnection();
|
|
|
|
|
|
|
|
stmt = conn.prepareStatement("SELECT ID, NAME, APP_IDENTIFIER, PLATFORM, CATEGORY, VERSION, TYPE, " +
|
|
|
|
|
|
|
|
"LOCATION_URL, IMAGE_URL, appmap.APP_PROPERTIES, appmap.MEMORY_USAGE, appmap.IS_ACTIVE, TENANT_ID " +
|
|
|
|
|
|
|
|
"FROM DM_APPLICATION app INNER JOIN " +
|
|
|
|
|
|
|
|
"(SELECT APPLICATION_ID, APP_PROPERTIES, MEMORY_USAGE, IS_ACTIVE FROM DM_DEVICE_APPLICATION_MAPPING W" +
|
|
|
|
|
|
|
|
"HERE DEVICE_ID = ?) appmap WHERE app.APP_IDENTIFIER = ? AND app.VERSION = ? AND " +
|
|
|
|
|
|
|
|
"appmap.APPLICATION_ID = app.id AND TENANT_ID = ?");
|
|
|
|
|
|
|
|
stmt.setInt(1, deviceId);
|
|
|
|
|
|
|
|
stmt.setString(2, identifier);
|
|
|
|
|
|
|
|
stmt.setString(3, version);
|
|
|
|
|
|
|
|
stmt.setInt(4, tenantId);
|
|
|
|
|
|
|
|
rs = stmt.executeQuery();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (rs.next()) {
|
|
|
|
|
|
|
|
application = this.loadApplication(rs);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return application;
|
|
|
|
|
|
|
|
} catch (SQLException e) {
|
|
|
|
|
|
|
|
throw new DeviceManagementDAOException("Error occurred while retrieving application application '" +
|
|
|
|
|
|
|
|
identifier + "' and version '" + version + "'.", e);
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
DeviceManagementDAOUtil.cleanupResources(stmt, rs);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private Connection getConnection() throws SQLException {
|
|
|
|
private Connection getConnection() throws SQLException {
|
|
|
|
return DeviceManagementDAOFactory.getConnection();
|
|
|
|
return DeviceManagementDAOFactory.getConnection();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -278,9 +293,10 @@ public class ApplicationDAOImpl implements ApplicationDAO {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
conn = this.getConnection();
|
|
|
|
conn = this.getConnection();
|
|
|
|
stmt = conn.prepareStatement("Select ID, NAME, APP_IDENTIFIER, PLATFORM, CATEGORY, VERSION, TYPE, " +
|
|
|
|
stmt = conn.prepareStatement("Select ID, NAME, APP_IDENTIFIER, PLATFORM, CATEGORY, VERSION, TYPE, " +
|
|
|
|
"LOCATION_URL, IMAGE_URL, APP_PROPERTIES, MEMORY_USAGE, IS_ACTIVE, TENANT_ID From DM_APPLICATION app " +
|
|
|
|
"LOCATION_URL, IMAGE_URL, APPMAP.APP_PROPERTIES, APPMAP.MEMORY_USAGE, APPMAP.IS_ACTIVE, " +
|
|
|
|
"INNER JOIN " +
|
|
|
|
"TENANT_ID From DM_APPLICATION app INNER JOIN " +
|
|
|
|
"(Select APPLICATION_ID From DM_DEVICE_APPLICATION_MAPPING WHERE DEVICE_ID=?) APPMAP " +
|
|
|
|
"(Select APPLICATION_ID, APP_PROPERTIES, MEMORY_USAGE, IS_ACTIVE" +
|
|
|
|
|
|
|
|
" From DM_DEVICE_APPLICATION_MAPPING WHERE DEVICE_ID=?) APPMAP " +
|
|
|
|
"ON " +
|
|
|
|
"ON " +
|
|
|
|
"app.ID = APPMAP.APPLICATION_ID ");
|
|
|
|
"app.ID = APPMAP.APPLICATION_ID ");
|
|
|
|
|
|
|
|
|
|
|
|