WIP: subscription / Refactored the code in subscription management #483

Draft
ruwin wants to merge 6 commits from ruwin/device-mgt-core:subscription into master
ruwin commented 2 months ago

Purpose

Description

  • This pull request addresses an improvement to code redundancy and repetition.

The following changes have been made:

  • SubscriptionManager and SubscriptionManagerImpl were changed.
  • Deleted DeviceBasedSubscriptionManagementHelperServiceImpl, GroupBasedSubscriptionManagementHelperServiceImpl, RoleBasedSubscriptionManagementHelperServiceImpl, UserBasedSubscriptionManagementHelperServiceImpl, SubscriptionManagementHelperService and SubscriptionManagementServiceProvider
## Purpose * Fixed https://roadmap.entgra.net/issues/11745 ## Description * This pull request addresses an improvement to code redundancy and repetition. The following changes have been made: * SubscriptionManager and SubscriptionManagerImpl were changed. * Deleted DeviceBasedSubscriptionManagementHelperServiceImpl, GroupBasedSubscriptionManagementHelperServiceImpl, RoleBasedSubscriptionManagementHelperServiceImpl, UserBasedSubscriptionManagementHelperServiceImpl, SubscriptionManagementHelperService and SubscriptionManagementServiceProvider
ruwin added 3 commits 2 months ago
ba5333242c
Refactor subscription related methods
d9375135a1
Refactored the code in subscription management.
ruwin added 1 commit 1 month ago
ruwin added 1 commit 1 month ago
tcdlpds requested changes 1 month ago
SubscriptionResponse getStatusBaseSubscriptions(SubscriptionInfo subscriptionInfo, int limit, int offset)
throws ApplicationManagementException;
Owner

Remove unnecessary new line

Remove unnecessary new line
ruwin marked this conversation as resolved
* @return {@link SubscriptionResponse}
* @throws ApplicationManagementException Throws when error encountered while getting subscription data
*/
@Override
Owner

Why did you remove this annotation?

Why did you remove this annotation?
ruwin marked this conversation as resolved
import io.entgra.device.mgt.core.application.mgt.common.dto.ApplicationPolicyDTO;
import io.entgra.device.mgt.core.application.mgt.common.dto.VppAssetDTO;
import io.entgra.device.mgt.core.application.mgt.common.dto.VppUserDTO;
import io.entgra.device.mgt.core.application.mgt.common.*;
Owner

do not use wild card imports.

do not use wild card imports.
ruwin marked this conversation as resolved
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import java.util.*;
Owner

Do not use wild card imports

Do not use wild card imports
ruwin marked this conversation as resolved
* @return {@link SubscriptionResponse}
* @throws ApplicationManagementException Throws when error encountered while getting subscription data
*/
Owner

Remove unnecessary new line

Remove unnecessary new line
ruwin marked this conversation as resolved
* @return {@link SubscriptionStatistics} The subscription statistics for the specified subscription type and identifier.
* @throws ApplicationManagementException Throws when an error is encountered while getting subscription statistics.
*/
Owner

Remove unnecessary new line

Remove unnecessary new line
ruwin marked this conversation as resolved
List<Integer> deviceIdsOwnByGroup = devices.stream().map(Device::getId).collect(Collectors.toList());
SubscriptionStatisticDTO subscriptionStatisticDTO = subscriptionDAO.
getSubscriptionStatistic(deviceIdsOwnByGroup, isUnsubscribe, tenantId, applicationReleaseDTO.getId());
int allDeviceCount = HelperUtil.getGroupManagementProviderService().getDeviceCount(subscriptionInfo.getIdentifier());
Owner

It is not required to assign the return value into a variable here.

It is not required to assign the return value into a variable here.
ruwin marked this conversation as resolved
* @throws ApplicationManagementException Throws when error encountered while getting subscription data
*/
@Override
Owner

Remove unnecessary new line

Remove unnecessary new line
ruwin marked this conversation as resolved
return getStatusBaseSubscriptionsRoleUser(subscriptionInfo, limit, offset);
}
}
Owner

Remove unnecessary new line

Remove unnecessary new line
ruwin marked this conversation as resolved
}
public SubscriptionResponse getStatusBaseSubscriptionsDevice(SubscriptionInfo subscriptionInfo, int limit, int offset)
Owner

Do we need to define this as a public method?

Do we need to define this as a public method?
ruwin marked this conversation as resolved
return deviceListOwnByUser.stream().map(Device::getId).collect(Collectors.toList());
}
private List<Integer> getAllDeviceIds (SubscriptionInfo subscriptionInfo) throws DeviceManagementException, UserStoreException {
Owner

Add Java doc comment

Add Java doc comment
ruwin marked this conversation as resolved
}
if (Objects.equals(type,SubscriptionMetadata.SubscriptionTypes.USER)){
return getDeviceIdsOwnByUser(subscriptionInfo.getIdentifier());
}else
Owner

Fix formatting issue

Fix formatting issue
ruwin marked this conversation as resolved
ruwin added 1 commit 1 month ago
32ff2cfe93
Refactored the code in subscription management.

Reviewers

tcdlpds requested changes 1 month ago
This pull request has changes conflicting with the target branch.
components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/impl/UserBasedSubscriptionManagementHelperServiceImpl.java
components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java
components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/impl/GroupBasedSubscriptionManagementHelperServiceImpl.java
components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/impl/RoleBasedSubscriptionManagementHelperServiceImpl.java
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#483
Loading…
There is no content yet.