dilanua 8 years ago
commit d7eed8bc1d

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

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

@ -32,5 +32,7 @@ public interface ApplicationDAO {
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;
}

@ -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 {
return DeviceManagementDAOFactory.getConnection();
}

Loading…
Cancel
Save