Subscription info related API restructuring #465

Merged
tcdlpds merged 27 commits from APPM_Imp into master 4 months ago
Collaborator

Purpose

## Purpose
rajitha added 16 commits 4 months ago
tcdlpds requested changes 4 months ago
append(" DESC ");
if (offset >= 0 && limit >= 0) {
sql.append("LIMIT ? OFFSET ?");
Owner

Have we added the query for Oracle database? Please check all other queries that we have used offset and limit and do the modification.

Have we added the query for Oracle database? Please check all other queries that we have used offset and limit and do the modification.
try {
Connection conn = this.getDBConnection();
StringBuilder sql = new StringBuilder("SELECT COUNT(DISTINCT DS.DM_DEVICE_ID) AS COUNT "
Owner

Move this part out of the try block and use the constructed query to log in the error log. Do this for all the methods.

Further, format the query to improve the readability of it.

Move this part out of the try block and use the constructed query to log in the error log. Do this for all the methods. Further, format the query to improve the readability of it.
}
// @Override
// public List<DeviceSubscriptionDTO> getSubscriptionDetailsByDeviceIds(int appReleaseId, boolean unsubscribe, int tenantId,
Owner

Remove commented code blocks.

Remove commented code blocks.
public int getAllSubscriptionsCount(int appReleaseId, boolean unsubscribe, int tenantId,
List<String> actionStatus, String actionType, String actionTriggeredBy)
throws ApplicationManagementDAOException {
int deviceCount = 0;
Owner

This can be removed if we improve the code more.

This can be removed if we improve the code more.
+ appReleaseId);
}
if (rs.next()) {
deviceCount = rs.getInt("COUNT");
Owner

This can be replaced with return rs.getInt("COUNT");

This can be replaced with return rs.getInt("COUNT");
deviceCount = rs.getInt("COUNT");
}
}
return deviceCount;
Owner

This can be replaced with return 0;

This can be replaced with return 0;
return HelperUtil.getDeviceManagementProviderService().getDeviceCountByDeviceIds(paginationRequest, deviceIds);
}
private static List<DeviceSubscription> populateDeviceData(List<DeviceSubscriptionDTO> deviceSubscriptionDTOS,
Owner

Add Java Doc comment

Add Java Doc comment
return deviceSubscriptions;
}
private static SubscriptionData getSubscriptionData(boolean isUnsubscribed, DeviceSubscriptionDTO deviceSubscriptionDTO) {
Owner

Add Java Doc comment

Add Java Doc comment
return subscriptionData;
}
public static String getDeviceSubscriptionStatus(SubscriptionInfo subscriptionInfo) {
Owner

Add Java Doc comment

Add Java Doc comment
getFilteringDeviceSubscriptionStatus(), subscriptionInfo.getDeviceSubscriptionStatus());
}
public static String getDeviceSubscriptionStatus(String deviceSubscriptionStatusFilter, String deviceSubscriptionStatus) {
Owner

Add Java Doc comment

Add Java Doc comment
deviceSubscriptionStatusFilter : deviceSubscriptionStatus;
}
public static SubscriptionStatistics getSubscriptionStatistics(SubscriptionStatisticDTO subscriptionStatisticDTO, int allDeviceCount) {
Owner

Add Java Doc comment

Add Java Doc comment
return subscriptionStatistics;
}
public static float getPercentage(int numerator, int denominator) {
Owner

Add Java Doc comment

Add Java Doc comment
return ((float) numerator / (float) denominator) * 100;
}
public static List<String> getDBSubscriptionStatus(String deviceSubscriptionStatus) {
Owner

Add Java Doc comment

Add Java Doc comment
private SubscriptionManagementServiceProvider() {
}
public static SubscriptionManagementServiceProvider getInstance() {
Owner

This is not required, check all the placed and do the required improvement.

This is not required, check all the placed and do the required improvement.
}
// @Override
// public OwnerWithDeviceDTO getOwnersWithDevices(String owner, List<String> allowingDeviceStatuses, int tenantId,
Owner

Remove commented code

Remove commented code
tcdlpds requested changes 4 months ago
import java.util.Map;
public class SubscriptionMetadata {
public static final class DeviceSubscriptionStatus {
Owner

Don't we have a constant file to have this?

Don't we have a constant file to have this?
import java.util.Objects;
import java.util.stream.Collectors;
public class UserBasedSubscriptionManagementHelperServiceImpl implements SubscriptionManagementHelperService {
Owner

In these
UserBasedSubscriptionManagementHelperServiceImpl.java, GroupBasedSubscriptionManagementHelperServiceImpl.java, RoleBasedSubscriptionManagementHelperServiceImpl.java, DeviceBasedSubscriptionManagementHelperServiceImpl.java

Files contain repeating code blocks, so think a better approach to have reusable source. Either you can have service methods or common util methods to reuse in these classes.

In these UserBasedSubscriptionManagementHelperServiceImpl.java, GroupBasedSubscriptionManagementHelperServiceImpl.java, RoleBasedSubscriptionManagementHelperServiceImpl.java, DeviceBasedSubscriptionManagementHelperServiceImpl.java Files contain repeating code blocks, so think a better approach to have reusable source. Either you can have service methods or common util methods to reuse in these classes.
rajitha added 3 commits 4 months ago
tcdlpds added 3 commits 4 months ago
tcdlpds requested changes 4 months ago
public int getDeviceSubscriptionCount(int appReleaseId, boolean unsubscribe, int tenantId,
List<Integer> deviceIds, List<String> actionStatus, String actionType,
String actionTriggeredBy) throws ApplicationManagementDAOException {
int deviceCount = 0;
Owner

This line can be removed if we improve the method.

This line can be removed if we improve the method.
+ appReleaseId + " and device ids " + deviceIds);
}
if (rs.next()) {
deviceCount = rs.getInt("COUNT");
Owner

This line can replace with

return rs.getInt("COUNT");

This line can replace with return rs.getInt("COUNT");
if (rs.next()) {
deviceCount = rs.getInt("COUNT");
}
return deviceCount;
Owner

This line can replace with

return 0;

This line can replace with return 0;
package io.entgra.device.mgt.core.application.mgt.core.util;
public class SubscriptionManagementUtil {
public static final class DeviceSubscriptionStatus {
Owner

Can't we remove this file.

Can't we remove this file.
return HelperUtil.getDeviceManagementProviderService().getDeviceCountByDeviceIds(paginationRequest, deviceIds);
}
private static List<DeviceSubscription> populateDeviceData(List<DeviceSubscriptionDTO> deviceSubscriptionDTOS,
Owner

Add Java Doc comment

Add Java Doc comment
return deviceSubscriptions;
}
private static SubscriptionData getSubscriptionData(boolean isUnsubscribed, DeviceSubscriptionDTO deviceSubscriptionDTO) {
Owner

Add Java Doc comment.

Add Java Doc comment.
tcdlpds added 2 commits 4 months ago
tcdlpds added 3 commits 4 months ago
7a0299419a
Merge branch 'APPM_Imp' of https://repository.entgra.net/community/device-mgt-core into apim-issues
tcdlpds merged commit 40c12875ac into master 4 months ago

Reviewers

tcdlpds requested changes 4 months ago
The pull request has been merged as 40c12875ac.
Sign in to join this conversation.
No reviewers
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date

No due date set.

Dependencies

No dependencies set.

Reference: community/device-mgt-core#465
Loading…
There is no content yet.