fixing App Version not updating in portal after being initially set

revert-70aa11f8
hasuniea 8 years ago
parent 4549452634
commit 349c3bdb63

@ -150,6 +150,9 @@ public class Application implements Serializable {
if (applicationIdentifier != null ? !applicationIdentifier.equals(that.applicationIdentifier) : that.applicationIdentifier != null) { if (applicationIdentifier != null ? !applicationIdentifier.equals(that.applicationIdentifier) : that.applicationIdentifier != null) {
return false; return false;
} }
if (version != null ? !version.equals(that.version) : that.version != null) {
return false;
}
return true; return true;
} }

@ -217,13 +217,14 @@ public class ApplicationManagerProviderServiceImpl implements ApplicationManagem
appIdsToRemove.add(installedApp.getId()); appIdsToRemove.add(installedApp.getId());
} }
} }
applicationMappingDAO.removeApplicationMapping(device.getId(), appIdsToRemove, tenantId);
Application installedApp; Application installedApp;
List<Integer> applicationIds = new ArrayList<>(); List<Integer> applicationIds = new ArrayList<>();
for (Application application : applications) { for (Application application : applications) {
if (!installedAppList.contains(application)) { if (!installedAppList.contains(application)) {
installedApp = applicationDAO.getApplication(application.getApplicationIdentifier(), tenantId); installedApp = applicationDAO.getApplication(application.getApplicationIdentifier(),
application.getVersion(), tenantId);
if (installedApp == null) { if (installedApp == null) {
appsToAdd.add(application); appsToAdd.add(application);
} else { } else {
@ -244,7 +245,7 @@ public class ApplicationManagerProviderServiceImpl implements ApplicationManagem
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("num of remove app Ids:" + appIdsToRemove.size()); log.debug("num of remove app Ids:" + appIdsToRemove.size());
} }
applicationMappingDAO.removeApplicationMapping(device.getId(), appIdsToRemove, tenantId);
DeviceManagementDAOFactory.commitTransaction(); DeviceManagementDAOFactory.commitTransaction();
} catch (DeviceManagementDAOException e) { } catch (DeviceManagementDAOException e) {
DeviceManagementDAOFactory.rollbackTransaction(); DeviceManagementDAOFactory.rollbackTransaction();

@ -32,5 +32,7 @@ public interface ApplicationDAO {
Application getApplication(String identifier, int tenantId) throws DeviceManagementDAOException; Application getApplication(String identifier, int tenantId) throws DeviceManagementDAOException;
Application getApplication(String identifier, String version,int tenantId) throws DeviceManagementDAOException;
List<Application> getInstalledApplications(int deviceId) throws DeviceManagementDAOException; List<Application> getInstalledApplications(int deviceId) throws DeviceManagementDAOException;
} }

@ -228,6 +228,34 @@ public class ApplicationDAOImpl implements ApplicationDAO {
} }
} }
@Override
public Application getApplication(String identifier, String version, 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, APP_PROPERTIES, MEMORY_USAGE, IS_ACTIVE, TENANT_ID FROM DM_APPLICATION WHERE APP_IDENTIFIER = ? " +
"AND VERSION = ? AND TENANT_ID = ?");
stmt.setString(1, identifier);
stmt.setString(2, version);
stmt.setInt(3, 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();
} }

Loading…
Cancel
Save