Skip to content

Commit

Permalink
Master data service (mosip#300)
Browse files Browse the repository at this point in the history
* Added null check conditions

Signed-off-by: Piyush7034 <[email protected]>

* Some code refactor

Signed-off-by: Piyush7034 <[email protected]>

* Code clean on login page

Signed-off-by: Piyush7034 <[email protected]>

* Resolved lint issues for login page

Signed-off-by: Piyush7034 <[email protected]>

* Refactored code on home page

Signed-off-by: Piyush7034 <[email protected]>

* Removed method channel code

Signed-off-by: Piyush7034 <[email protected]>

* Moved required code from MasterDataService to MasterSyncApi

Signed-off-by: Piyush7034 <[email protected]>

* Widgets code refactoring

Signed-off-by: Piyush7034 <[email protected]>

* Fixed null exception on new registration from acknowledgement page

Signed-off-by: Piyush7034 <[email protected]>

* MasterDataServiceImpl refactoring

Signed-off-by: Piyush7034 <[email protected]>

* Added some conditions for manual sync

Signed-off-by: Piyush7034 <[email protected]>

* Fixed login language change on manual sync

Signed-off-by: Piyush7034 <[email protected]>

* Fixed disable continue button on field value change

Signed-off-by: Piyush7034 <[email protected]>

* Some changes

Signed-off-by: Piyush7034 <[email protected]>

* Form key null state fixed

Signed-off-by: Piyush7034 <[email protected]>

* Removed unwanted file

Signed-off-by: Piyush7034 <[email protected]>

* Auto sync failing issue fixed

Signed-off-by: Piyush7034 <[email protected]>

* RCF-557 app crash fixed

Signed-off-by: Piyush7034 <[email protected]>

---------

Signed-off-by: Piyush7034 <[email protected]>
  • Loading branch information
Piyush7034 authored Apr 10, 2024
1 parent 33c943c commit e0b5e1f
Show file tree
Hide file tree
Showing 5 changed files with 124 additions and 106 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,11 @@ public void getLastSyncTime(@NonNull MasterDataSyncPigeon.Result<MasterDataSyncP
public void getPolicyKeySync(@NonNull Boolean isManualSync, @NonNull MasterDataSyncPigeon.Result<MasterDataSyncPigeon.Sync> result) {
CenterMachineDto centerMachineDto = masterDataService.getRegistrationCenterMachineDetails();

if(centerMachineDto == null) {
result.success(syncResult("PolicyKeySync", 5, "policy_key_sync_failed"));
return;
}

try {
masterDataService.syncCertificate(() -> {
Log.i(TAG, "Policy Key Sync Completed");
Expand Down Expand Up @@ -198,7 +203,7 @@ public void getMasterDataSync(@NonNull Boolean isManualSync, @NonNull MasterData
try {
masterDataService.syncMasterData(() -> {
Log.i(TAG, "Master Data Sync Completed.");
result.success(syncResult("MasterDataSync", 1, masterDataService.onResponseComplete()));
result.success(syncResult("MasterDataSync", 2, masterDataService.onResponseComplete()));
}, 0, isManualSync);
} catch (Exception e) {
Log.e(TAG, "Master Data Sync Failed.", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,16 +177,25 @@ public void onResponse(Call<ResponseWrapper<CertificateResponse>> call, Response
if (response.isSuccessful()) {
ServiceError error = SyncRestUtil.getServiceError(response.body());
if (error == null) {
CertificateRequestDto certificateRequestDto = new CertificateRequestDto();
certificateRequestDto.setApplicationId(setApplicationId);
certificateRequestDto.setReferenceId(setReferenceId);
certificateRequestDto.setCertificateData(response.body().getResponse().getCertificate());
certificateManagerService.uploadOtherDomainCertificate(certificateRequestDto);
if(isManualSync) {
Toast.makeText(context, "Policy key Sync Completed", Toast.LENGTH_LONG).show();
try {
CertificateRequestDto certificateRequestDto = new CertificateRequestDto();
certificateRequestDto.setApplicationId(setApplicationId);
certificateRequestDto.setReferenceId(setReferenceId);
certificateRequestDto.setCertificateData(response.body().getResponse().getCertificate());
certificateManagerService.uploadOtherDomainCertificate(certificateRequestDto);
if(isManualSync) {
Toast.makeText(context, "Policy key Sync Completed", Toast.LENGTH_LONG).show();
}
result = "";
onFinish.run();
} catch (Exception e) {
result = "policy_key_sync_failed";
Log.e(TAG, "Policy key Sync failed.", e);
if(isManualSync) {
Toast.makeText(context, "Policy key Sync failed " + error.getMessage(), Toast.LENGTH_LONG).show();
}
onFinish.run();
}
result = "";
onFinish.run();
} else {
result = "policy_key_sync_failed";
if(isManualSync) {
Expand Down
40 changes: 16 additions & 24 deletions ios/Runner/pigeon.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,38 +10,30 @@

NS_ASSUME_NONNULL_BEGIN

@class AuthResponse;
@class DashBoardData;

@interface AuthResponse : NSObject
@interface DashBoardData : NSObject
/// `init` unavailable to enforce nonnull fields, see the `make` class method.
- (instancetype)init NS_UNAVAILABLE;
+ (instancetype)makeWithResponse:(NSString *)response
userId:(NSString *)userId
username:(NSString *)username
userEmail:(NSString *)userEmail
isOfficer:(NSNumber *)isOfficer
isDefault:(NSNumber *)isDefault
isSupervisor:(NSNumber *)isSupervisor
isOperator:(NSNumber *)isOperator
errorCode:(nullable NSString *)errorCode;
@property(nonatomic, copy) NSString * response;
+ (instancetype)makeWithUserId:(NSString *)userId
userName:(NSString *)userName
userStatus:(NSNumber *)userStatus
userIsOnboarded:(NSNumber *)userIsOnboarded;
@property(nonatomic, copy) NSString * userId;
@property(nonatomic, copy) NSString * username;
@property(nonatomic, copy) NSString * userEmail;
@property(nonatomic, strong) NSNumber * isOfficer;
@property(nonatomic, strong) NSNumber * isDefault;
@property(nonatomic, strong) NSNumber * isSupervisor;
@property(nonatomic, strong) NSNumber * isOperator;
@property(nonatomic, copy, nullable) NSString * errorCode;
@property(nonatomic, copy) NSString * userName;
@property(nonatomic, strong) NSNumber * userStatus;
@property(nonatomic, strong) NSNumber * userIsOnboarded;
@end

/// The codec used by AuthResponseApi.
NSObject<FlutterMessageCodec> *AuthResponseApiGetCodec(void);
/// The codec used by DashBoardApi.
NSObject<FlutterMessageCodec> *DashBoardApiGetCodec(void);

@protocol AuthResponseApi
- (void)loginUsername:(NSString *)username password:(NSString *)password isConnected:(NSNumber *)isConnected completion:(void (^)(AuthResponse *_Nullable, FlutterError *_Nullable))completion;
@protocol DashBoardApi
- (void)getDashBoardDetailsWithCompletion:(void (^)(NSArray<DashBoardData *> *_Nullable, FlutterError *_Nullable))completion;
- (void)getPacketUploadedDetailsWithCompletion:(void (^)(NSNumber *_Nullable, FlutterError *_Nullable))completion;
- (void)getPacketUploadedPendingDetailsWithCompletion:(void (^)(NSNumber *_Nullable, FlutterError *_Nullable))completion;
@end

extern void AuthResponseApiSetup(id<FlutterBinaryMessenger> binaryMessenger, NSObject<AuthResponseApi> *_Nullable api);
extern void DashBoardApiSetup(id<FlutterBinaryMessenger> binaryMessenger, NSObject<DashBoardApi> *_Nullable api);

NS_ASSUME_NONNULL_END
148 changes: 77 additions & 71 deletions ios/Runner/pigeon.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,91 +26,67 @@ static id GetNullableObjectAtIndex(NSArray *array, NSInteger key) {
return (result == [NSNull null]) ? nil : result;
}

@interface AuthResponse ()
+ (AuthResponse *)fromList:(NSArray *)list;
+ (nullable AuthResponse *)nullableFromList:(NSArray *)list;
@interface DashBoardData ()
+ (DashBoardData *)fromList:(NSArray *)list;
+ (nullable DashBoardData *)nullableFromList:(NSArray *)list;
- (NSArray *)toList;
@end

@implementation AuthResponse
+ (instancetype)makeWithResponse:(NSString *)response
userId:(NSString *)userId
username:(NSString *)username
userEmail:(NSString *)userEmail
isOfficer:(NSNumber *)isOfficer
isDefault:(NSNumber *)isDefault
isSupervisor:(NSNumber *)isSupervisor
isOperator:(NSNumber *)isOperator
errorCode:(nullable NSString *)errorCode {
AuthResponse* pigeonResult = [[AuthResponse alloc] init];
pigeonResult.response = response;
@implementation DashBoardData
+ (instancetype)makeWithUserId:(NSString *)userId
userName:(NSString *)userName
userStatus:(NSNumber *)userStatus
userIsOnboarded:(NSNumber *)userIsOnboarded {
DashBoardData* pigeonResult = [[DashBoardData alloc] init];
pigeonResult.userId = userId;
pigeonResult.username = username;
pigeonResult.userEmail = userEmail;
pigeonResult.isOfficer = isOfficer;
pigeonResult.isDefault = isDefault;
pigeonResult.isSupervisor = isSupervisor;
pigeonResult.isOperator = isOperator;
pigeonResult.errorCode = errorCode;
pigeonResult.userName = userName;
pigeonResult.userStatus = userStatus;
pigeonResult.userIsOnboarded = userIsOnboarded;
return pigeonResult;
}
+ (AuthResponse *)fromList:(NSArray *)list {
AuthResponse *pigeonResult = [[AuthResponse alloc] init];
pigeonResult.response = GetNullableObjectAtIndex(list, 0);
NSAssert(pigeonResult.response != nil, @"");
pigeonResult.userId = GetNullableObjectAtIndex(list, 1);
+ (DashBoardData *)fromList:(NSArray *)list {
DashBoardData *pigeonResult = [[DashBoardData alloc] init];
pigeonResult.userId = GetNullableObjectAtIndex(list, 0);
NSAssert(pigeonResult.userId != nil, @"");
pigeonResult.username = GetNullableObjectAtIndex(list, 2);
NSAssert(pigeonResult.username != nil, @"");
pigeonResult.userEmail = GetNullableObjectAtIndex(list, 3);
NSAssert(pigeonResult.userEmail != nil, @"");
pigeonResult.isOfficer = GetNullableObjectAtIndex(list, 4);
NSAssert(pigeonResult.isOfficer != nil, @"");
pigeonResult.isDefault = GetNullableObjectAtIndex(list, 5);
NSAssert(pigeonResult.isDefault != nil, @"");
pigeonResult.isSupervisor = GetNullableObjectAtIndex(list, 6);
NSAssert(pigeonResult.isSupervisor != nil, @"");
pigeonResult.isOperator = GetNullableObjectAtIndex(list, 7);
NSAssert(pigeonResult.isOperator != nil, @"");
pigeonResult.errorCode = GetNullableObjectAtIndex(list, 8);
pigeonResult.userName = GetNullableObjectAtIndex(list, 1);
NSAssert(pigeonResult.userName != nil, @"");
pigeonResult.userStatus = GetNullableObjectAtIndex(list, 2);
NSAssert(pigeonResult.userStatus != nil, @"");
pigeonResult.userIsOnboarded = GetNullableObjectAtIndex(list, 3);
NSAssert(pigeonResult.userIsOnboarded != nil, @"");
return pigeonResult;
}
+ (nullable AuthResponse *)nullableFromList:(NSArray *)list {
return (list) ? [AuthResponse fromList:list] : nil;
+ (nullable DashBoardData *)nullableFromList:(NSArray *)list {
return (list) ? [DashBoardData fromList:list] : nil;
}
- (NSArray *)toList {
return @[
(self.response ?: [NSNull null]),
(self.userId ?: [NSNull null]),
(self.username ?: [NSNull null]),
(self.userEmail ?: [NSNull null]),
(self.isOfficer ?: [NSNull null]),
(self.isDefault ?: [NSNull null]),
(self.isSupervisor ?: [NSNull null]),
(self.isOperator ?: [NSNull null]),
(self.errorCode ?: [NSNull null]),
(self.userName ?: [NSNull null]),
(self.userStatus ?: [NSNull null]),
(self.userIsOnboarded ?: [NSNull null]),
];
}
@end

@interface AuthResponseApiCodecReader : FlutterStandardReader
@interface DashBoardApiCodecReader : FlutterStandardReader
@end
@implementation AuthResponseApiCodecReader
@implementation DashBoardApiCodecReader
- (nullable id)readValueOfType:(UInt8)type {
switch (type) {
case 128:
return [AuthResponse fromList:[self readValue]];
return [DashBoardData fromList:[self readValue]];
default:
return [super readValueOfType:type];
}
}
@end

@interface AuthResponseApiCodecWriter : FlutterStandardWriter
@interface DashBoardApiCodecWriter : FlutterStandardWriter
@end
@implementation AuthResponseApiCodecWriter
@implementation DashBoardApiCodecWriter
- (void)writeValue:(id)value {
if ([value isKindOfClass:[AuthResponse class]]) {
if ([value isKindOfClass:[DashBoardData class]]) {
[self writeByte:128];
[self writeValue:[value toList]];
} else {
Expand All @@ -119,42 +95,72 @@ - (void)writeValue:(id)value {
}
@end

@interface AuthResponseApiCodecReaderWriter : FlutterStandardReaderWriter
@interface DashBoardApiCodecReaderWriter : FlutterStandardReaderWriter
@end
@implementation AuthResponseApiCodecReaderWriter
@implementation DashBoardApiCodecReaderWriter
- (FlutterStandardWriter *)writerWithData:(NSMutableData *)data {
return [[AuthResponseApiCodecWriter alloc] initWithData:data];
return [[DashBoardApiCodecWriter alloc] initWithData:data];
}
- (FlutterStandardReader *)readerWithData:(NSData *)data {
return [[AuthResponseApiCodecReader alloc] initWithData:data];
return [[DashBoardApiCodecReader alloc] initWithData:data];
}
@end

NSObject<FlutterMessageCodec> *AuthResponseApiGetCodec(void) {
NSObject<FlutterMessageCodec> *DashBoardApiGetCodec(void) {
static FlutterStandardMessageCodec *sSharedObject = nil;
static dispatch_once_t sPred = 0;
dispatch_once(&sPred, ^{
AuthResponseApiCodecReaderWriter *readerWriter = [[AuthResponseApiCodecReaderWriter alloc] init];
DashBoardApiCodecReaderWriter *readerWriter = [[DashBoardApiCodecReaderWriter alloc] init];
sSharedObject = [FlutterStandardMessageCodec codecWithReaderWriter:readerWriter];
});
return sSharedObject;
}

void AuthResponseApiSetup(id<FlutterBinaryMessenger> binaryMessenger, NSObject<AuthResponseApi> *api) {
void DashBoardApiSetup(id<FlutterBinaryMessenger> binaryMessenger, NSObject<DashBoardApi> *api) {
{
FlutterBasicMessageChannel *channel =
[[FlutterBasicMessageChannel alloc]
initWithName:@"dev.flutter.pigeon.registration_client.AuthResponseApi.login"
initWithName:@"dev.flutter.pigeon.registration_client.DashBoardApi.getDashBoardDetails"
binaryMessenger:binaryMessenger
codec:AuthResponseApiGetCodec()];
codec:DashBoardApiGetCodec()];
if (api) {
NSCAssert([api respondsToSelector:@selector(loginUsername:password:isConnected:completion:)], @"AuthResponseApi api (%@) doesn't respond to @selector(loginUsername:password:isConnected:completion:)", api);
NSCAssert([api respondsToSelector:@selector(getDashBoardDetailsWithCompletion:)], @"DashBoardApi api (%@) doesn't respond to @selector(getDashBoardDetailsWithCompletion:)", api);
[channel setMessageHandler:^(id _Nullable message, FlutterReply callback) {
NSArray *args = message;
NSString *arg_username = GetNullableObjectAtIndex(args, 0);
NSString *arg_password = GetNullableObjectAtIndex(args, 1);
NSNumber *arg_isConnected = GetNullableObjectAtIndex(args, 2);
[api loginUsername:arg_username password:arg_password isConnected:arg_isConnected completion:^(AuthResponse *_Nullable output, FlutterError *_Nullable error) {
[api getDashBoardDetailsWithCompletion:^(NSArray<DashBoardData *> *_Nullable output, FlutterError *_Nullable error) {
callback(wrapResult(output, error));
}];
}];
} else {
[channel setMessageHandler:nil];
}
}
{
FlutterBasicMessageChannel *channel =
[[FlutterBasicMessageChannel alloc]
initWithName:@"dev.flutter.pigeon.registration_client.DashBoardApi.getPacketUploadedDetails"
binaryMessenger:binaryMessenger
codec:DashBoardApiGetCodec()];
if (api) {
NSCAssert([api respondsToSelector:@selector(getPacketUploadedDetailsWithCompletion:)], @"DashBoardApi api (%@) doesn't respond to @selector(getPacketUploadedDetailsWithCompletion:)", api);
[channel setMessageHandler:^(id _Nullable message, FlutterReply callback) {
[api getPacketUploadedDetailsWithCompletion:^(NSNumber *_Nullable output, FlutterError *_Nullable error) {
callback(wrapResult(output, error));
}];
}];
} else {
[channel setMessageHandler:nil];
}
}
{
FlutterBasicMessageChannel *channel =
[[FlutterBasicMessageChannel alloc]
initWithName:@"dev.flutter.pigeon.registration_client.DashBoardApi.getPacketUploadedPendingDetails"
binaryMessenger:binaryMessenger
codec:DashBoardApiGetCodec()];
if (api) {
NSCAssert([api respondsToSelector:@selector(getPacketUploadedPendingDetailsWithCompletion:)], @"DashBoardApi api (%@) doesn't respond to @selector(getPacketUploadedPendingDetailsWithCompletion:)", api);
[channel setMessageHandler:^(id _Nullable message, FlutterReply callback) {
[api getPacketUploadedPendingDetailsWithCompletion:^(NSNumber *_Nullable output, FlutterError *_Nullable error) {
callback(wrapResult(output, error));
}];
}];
Expand Down
8 changes: 7 additions & 1 deletion lib/ui/process_ui/new_process.dart
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,13 @@ class _NewProcessState extends State<NewProcess> with WidgetsBindingObserver {
}

customValidation(globalProvider.newProcessTabIndex).then((value) {
continueButton = value && globalProvider.formKey.currentState!.validate();
continueButton = value &&
globalProvider.formKey.currentState != null &&
globalProvider.formKey.currentState!.validate();

if(globalProvider.newProcessTabIndex >= size) {
continueButton = true;
}
});

return WillPopScope(
Expand Down

0 comments on commit e0b5e1f

Please sign in to comment.