Changes to DB queries

feature/appm-store/pbac
Chatura Dilan 7 years ago
parent c6263ae22d
commit f09905a2ec

@ -56,6 +56,7 @@ public class ApplicationManagementServiceImpl {
ApplicationList applications = applicationManager.getApplications(filter);
return Response.status(Response.Status.OK).entity(applications).build();
} catch (Exception e) {
String msg = "Error occurred while getting the application list";
log.error(msg, e);

@ -23,7 +23,7 @@ import org.apache.commons.logging.LogFactory;
import org.json.JSONArray;
import org.json.JSONException;
import org.wso2.carbon.device.application.mgt.core.dto.Application;
import org.wso2.carbon.device.application.mgt.core.dto.ApplicationType;
import org.wso2.carbon.device.application.mgt.core.dto.Platform;
import org.wso2.carbon.device.application.mgt.core.dto.Category;
import java.sql.PreparedStatement;
@ -39,6 +39,7 @@ public class ApplicationManagementDAOUtil {
private static final Log log = LogFactory.getLog(ApplicationManagementDAOUtil.class);
public static Application loadApplication(ResultSet rs , ResultSet rsProperties) throws SQLException, JSONException {
Application application = new Application();
application.setId(rs.getInt("ID"));
application.setName(rs.getString("NAME"));
@ -48,13 +49,12 @@ public class ApplicationManagementDAOUtil {
application.setBannerName(rs.getString("BANNER_NAME"));
application.setVideoName(rs.getString("VIDEO_NAME"));
application.setScreenshots(jsonArrayStringToList(rs.getString("SCREENSHOTS")));
application.setTags(jsonArrayStringToList(rs.getString("TAGS")));
application.setCreatedAt(rs.getDate("CREATED_AT"));
application.setModifiedAt(rs.getDate("MODIFIED_AT"));
ApplicationType applicationType = new ApplicationType();
applicationType.setName(rs.getString("AT_NAME"));
applicationType.setCode(rs.getString("AT_CODE"));
Platform applicationType = new Platform();
applicationType.setName(rs.getString("APL_NAME"));
applicationType.setCode(rs.getString("APL_CODE"));
application.setApplicationType(applicationType);
Map<String, String> properties = new HashMap<>();
@ -64,7 +64,7 @@ public class ApplicationManagementDAOUtil {
application.setProperties(properties);
Category category = new Category();
category.setName(rs.getString("CT_NAME"));
category.setName(rs.getString("CAT_NAME"));
application.setCategory(category);
return application;
}

@ -64,12 +64,13 @@ public class GenericAppManagementDAO implements ApplicationManagementDAO {
conn = ConnectionManagerUtil.getCurrentConnection().get();
sql += "SELECT SQL_CALC_FOUND_ROWS AP.*, AT.NAME AS AT_NAME, AT.CODE AS AT_CODE, CT.NAME AS CT_NAME ";
sql += "FROM APPM_APPLICATION AS AP ";
sql += "INNER JOIN APPM_APPLICATION_TYPE AS AT ON AP.APPLICATION_TYPE_ID = AT.ID ";
sql += "INNER JOIN APPM_APPLICATION_CATEGORY AS CT ON AP.CATEGORY_ID = CT.ID ";
sql += "SELECT SQL_CALC_FOUND_ROWS APP.*, APL.NAME AS APL_NAME, APL.CODE AS APL_CODE, CAT.NAME AS CAT_NAME ";
sql += "FROM APPM_APPLICATION AS APP ";
sql += "INNER JOIN APPM_PLATFORM_APPLICATION_MAPPING AS APM ON APP.PLATFORM_APPLICATION_MAPPING_ID = APM.ID ";
sql += "INNER JOIN APPM_PLATFORM AS APL ON APM.PLATFORM_ID = APL.ID ";
sql += "INNER JOIN APPM_APPLICATION_CATEGORY AS CAT ON APP.APPLICATION_CATEGORY_ID = CAT.ID ";
if (filter.getSearchQuery() != null || "".equals(filter.getSearchQuery())) {
sql += "WHERE AP.NAME LIKE ? ";
sql += "WHERE APP.NAME LIKE ? ";
}
sql += "LIMIT ? ";
sql += "OFFSET ?;";
@ -95,7 +96,7 @@ public class GenericAppManagementDAO implements ApplicationManagementDAO {
while (rs.next()) {
//Getting properties
sql = "SELECT * FROM APPM_APPLICATION_PROPERTIES WHERE APPLICATION_ID=?";
sql = "SELECT * FROM APPM_APPLICATION_PROPERTY WHERE APPLICATION_ID=?";
stmt = conn.prepareStatement(sql);
stmt.setInt(1, rs.getInt("ID"));
ResultSet rsProperties = stmt.executeQuery();

@ -50,7 +50,7 @@ public class Application {
private Date modifiedAt;
private ApplicationType applicationType;
private Platform platform;
private Category category;
@ -147,12 +147,12 @@ public class Application {
this.modifiedAt = modifiedAt;
}
public ApplicationType getApplicationType() {
return applicationType;
public Platform getPlatform() {
return platform;
}
public void setApplicationType(ApplicationType applicationType) {
this.applicationType = applicationType;
public void setPlatform(Platform platform) {
this.platform = platform;
}
public Category getCategory() {

@ -20,16 +20,24 @@ package org.wso2.carbon.device.application.mgt.core.dto;
import org.wso2.carbon.device.application.mgt.core.jaxrs.Exclude;
public class ApplicationType {
import java.util.List;
public class Platform {
@Exclude
private int id;
private String name;
private String description;
private String code;
private String parameters;
private String iconName;
private String properties;
private List<Application> applications;
public int getId() {
return id;
@ -47,6 +55,14 @@ public class ApplicationType {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getCode() {
return code;
}
@ -55,11 +71,27 @@ public class ApplicationType {
this.code = code;
}
public String getParameters() {
return parameters;
public String getIconName() {
return iconName;
}
public void setIconName(String iconName) {
this.iconName = iconName;
}
public String getProperties() {
return properties;
}
public void setProperties(String properties) {
this.properties = properties;
}
public List<Application> getApplications() {
return applications;
}
public void setParameters(String parameters) {
this.parameters = parameters;
public void setApplications(List<Application> applications) {
this.applications = applications;
}
}
Loading…
Cancel
Save