diff --git a/client/app/src/main/AndroidManifest.xml b/client/app/src/main/AndroidManifest.xml
index 95053e42c..a976e8d13 100644
--- a/client/app/src/main/AndroidManifest.xml
+++ b/client/app/src/main/AndroidManifest.xml
@@ -5,8 +5,10 @@
+
+
+
+
+
@@ -51,6 +59,12 @@
android:exported="true">
+
+
+
{
+ // update UI
+ ArrayAdapter adapter = new ArrayAdapter<>(this,
+ android.R.layout.simple_list_item_1, android.R.id.text2, list);
+ // Assign adapter to ListView
+ listView.setAdapter(new CustomListViewAdapter(this, R.layout.custom_list_view_job, list));
+ progressBar.setVisibility(View.GONE);
+ });
+ }
+
+ private class CustomListViewAdapter extends ArrayAdapter {
+
+ private List mObjects;
+ private int layout;
+
+ public CustomListViewAdapter(@NonNull Context context, int resource, @NonNull List objects) {
+ super(context, resource, objects);
+ mObjects = objects;
+ layout = resource;
+ }
+
+ @NonNull
+ @Override
+ public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
+
+ JobServiceModel jobServiceModel = this.mObjects.get(position);
+ ViewHolder mainViewHolder = null;
+ if (convertView == null) {
+ LayoutInflater layoutInflater = LayoutInflater.from(getContext());
+ convertView = layoutInflater.inflate(layout, parent, false);
+
+ ViewHolder viewHolder = new ViewHolder();
+ viewHolder.jobName = convertView.findViewById(R.id.jobName);
+ viewHolder.triggerJobButton = convertView.findViewById(R.id.triggerJob);
+ viewHolder.toggleActiveButton = convertView.findViewById(R.id.toggleActive);
+ viewHolder.toggleActiveButton.setChecked(jobServiceModel.getEnabled());
+
+ if (jobServiceModel.getActive() && jobServiceModel.getImplemented())
+ viewHolder.jobName.setText(jobServiceModel.getName());
+ else {
+ String name = "";
+ if (!jobServiceModel.getActive())
+ name = jobServiceModel.getName() + " (Not Active)";
+ else
+ name = jobServiceModel.getName() + " (Not implemented)";
+ viewHolder.jobName.setText(name);
+ viewHolder.toggleActiveButton.setEnabled(false);
+ viewHolder.triggerJobButton.setEnabled(false);
+ }
+
+ convertView.setTag(viewHolder);
+ }
+
+ mainViewHolder = (ViewHolder) convertView.getTag();
+
+ mainViewHolder.triggerJobButton.setOnClickListener(v -> {
+ Toast.makeText(JobServiceActivity.this, "Starting Job " + jobServiceModel.getName(), Toast.LENGTH_SHORT).show();
+ try {
+ boolean triggered = jobServiceHelper.triggerJobService(jobServiceModel.getId());
+ if(!triggered)
+ Toast.makeText(JobServiceActivity.this, jobServiceModel.getName() + " job failed. Cannot trigger disabled job.", Toast.LENGTH_SHORT).show();
+
+ } catch (Exception e) {
+ Log.e(TAG, jobServiceModel.getApiName() + " job failed", e);
+ Toast.makeText(JobServiceActivity.this, jobServiceModel.getName() + " job failed", Toast.LENGTH_SHORT).show();
+ }
+ });
+
+ mainViewHolder.toggleActiveButton.setOnCheckedChangeListener((compoundButton, isChecked) -> {
+ Toast.makeText(JobServiceActivity.this, "Setting up job", Toast.LENGTH_SHORT).show();
+ if (isChecked) {
+ try {
+ int resultCode = jobServiceHelper.scheduleJob(jobServiceModel.getId(), jobServiceModel.getApiName());
+
+ if (resultCode == JobScheduler.RESULT_SUCCESS) {
+ Log.d(TAG, "Job scheduled");
+ Toast.makeText(JobServiceActivity.this, "Job scheduled", Toast.LENGTH_SHORT).show();
+ } else {
+ Log.d(TAG, "Job scheduling failed");
+ Toast.makeText(JobServiceActivity.this, "Job scheduling failed", Toast.LENGTH_SHORT).show();
+ }
+ } catch (ClassNotFoundException e) {
+ Log.e(TAG, "Job scheduling failed : service " + jobServiceModel.getApiName() + " not implemented", e);
+ Toast.makeText(JobServiceActivity.this, "Job scheduling failed : service " + jobServiceModel.getApiName() + " not implemented", Toast.LENGTH_SHORT).show();
+ compoundButton.setChecked(false);
+ } catch (Exception e) {
+ Log.e(TAG, "Job scheduling failed", e);
+ Toast.makeText(JobServiceActivity.this, "Job scheduling failed : " + e.getMessage(), Toast.LENGTH_SHORT).show();
+ compoundButton.setChecked(false);
+ }
+ } else {
+ Toast.makeText(JobServiceActivity.this, "Cancelling Job", Toast.LENGTH_SHORT).show();
+ try {
+ jobServiceHelper.cancelJob(jobServiceModel.getId());
+ Log.d(TAG, "Job cancelled");
+ Toast.makeText(JobServiceActivity.this, "Job cancelled", Toast.LENGTH_SHORT).show();
+ } catch (Exception e) {
+ Log.e(TAG, "Cancelling Job failed", e);
+ Toast.makeText(JobServiceActivity.this, "Cancelling Job failed", Toast.LENGTH_SHORT).show();
+ }
+ }
+ });
+
+ return convertView;
+ }
+ }
+
+ public class ViewHolder {
+ TextView jobName;
+ Button triggerJobButton;
+ Switch toggleActiveButton;
+ }
+}
\ No newline at end of file
diff --git a/client/app/src/main/java/io/mosip/registration/app/activites/ListingActivity.java b/client/app/src/main/java/io/mosip/registration/app/activites/ListingActivity.java
index f078e4824..67f51ff32 100644
--- a/client/app/src/main/java/io/mosip/registration/app/activites/ListingActivity.java
+++ b/client/app/src/main/java/io/mosip/registration/app/activites/ListingActivity.java
@@ -12,7 +12,7 @@
import androidx.lifecycle.ViewModelProvider;
import dagger.android.support.DaggerAppCompatActivity;
import io.mosip.registration.app.R;
-import io.mosip.registration.app.viewmodel.ListingViewModel;
+import io.mosip.registration.app.viewmodel.RegistrationPacketViewModel;
import io.mosip.registration.app.viewmodel.ViewModelFactory;
import io.mosip.registration.clientmanager.entity.Registration;
import io.mosip.registration.clientmanager.spi.PacketService;
@@ -40,9 +40,9 @@ public void onCreate(Bundle savedInstanceState) {
getSupportActionBar().setTitle("Registrations");
getSupportActionBar().setSubtitle("Note : Packets are auto approved");
- ViewModelFactory viewModelFactory = new ViewModelFactory(new ListingViewModel(packetService));
- ListingViewModel model = new ViewModelProvider(this, viewModelFactory).get(ListingViewModel.class);
- model.getRegistrationList().observe(this, list -> {
+ ViewModelFactory viewModelFactory = new ViewModelFactory(new RegistrationPacketViewModel(packetService));
+ RegistrationPacketViewModel model = new ViewModelProvider(this, viewModelFactory).get(RegistrationPacketViewModel.class);
+ model.getList().observe(this, list -> {
// update UI
ArrayAdapter adapter = new ArrayAdapter<>(this,
android.R.layout.simple_list_item_1, android.R.id.text2, list);
@@ -118,3 +118,4 @@ public class ViewHolder {
Button uploadButton;
}
}
+
diff --git a/client/app/src/main/java/io/mosip/registration/app/activites/MainActivity.java b/client/app/src/main/java/io/mosip/registration/app/activites/MainActivity.java
index 6e0a8f7ce..4d5cea6be 100644
--- a/client/app/src/main/java/io/mosip/registration/app/activites/MainActivity.java
+++ b/client/app/src/main/java/io/mosip/registration/app/activites/MainActivity.java
@@ -52,5 +52,8 @@ public void click_list_packets(View view) {
startActivity(intent);
}
-
+ public void click_list_JobService(View view) {
+ Intent intent = new Intent(this, JobServiceActivity.class);
+ startActivity(intent);
+ }
}
\ No newline at end of file
diff --git a/client/app/src/main/java/io/mosip/registration/app/activites/ScreenActivity.java b/client/app/src/main/java/io/mosip/registration/app/activites/ScreenActivity.java
index 1e59b2313..5521ce798 100644
--- a/client/app/src/main/java/io/mosip/registration/app/activites/ScreenActivity.java
+++ b/client/app/src/main/java/io/mosip/registration/app/activites/ScreenActivity.java
@@ -9,12 +9,16 @@
import android.view.View;
import android.view.ViewGroup;
import android.widget.*;
+
import androidx.annotation.Nullable;
+import androidx.annotation.OptIn;
import androidx.core.app.ActivityCompat;
+
import com.google.android.material.badge.BadgeDrawable;
import com.google.android.material.badge.BadgeUtils;
import com.scanlibrary.ScanActivity;
import com.scanlibrary.ScanConstants;
+
import dagger.android.support.DaggerAppCompatActivity;
import io.mosip.registration.app.R;
import io.mosip.registration.app.dynamicviews.DynamicComponentFactory;
@@ -26,11 +30,13 @@
import io.mosip.registration.clientmanager.repository.IdentitySchemaRepository;
import io.mosip.registration.clientmanager.spi.MasterDataService;
import io.mosip.registration.clientmanager.spi.RegistrationService;
+
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import javax.inject.Inject;
+
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
@@ -74,7 +80,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
String[] screens = getIntent().getExtras().getStringArray("screens");
int currentScreenIndex = getIntent().getExtras().getInt("nextScreenIndex");
- if(currentScreenIndex < screens.length) {
+ if (currentScreenIndex < screens.length) {
ProcessSpecDto processSpecDto = identitySchemaRepository.getNewProcessSpec(getApplicationContext(),
registrationService.getRegistrationDto().getSchemaVersion());
Optional screen = processSpecDto.getScreens().stream()
@@ -82,38 +88,36 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
.findFirst();
//this can't happen at this stage
- if(!screen.isPresent())
+ if (!screen.isPresent())
throw new Exception("Invalid screen name found");
getSupportActionBar().setTitle(screen.get().getLabel().get(languages.get(0)));
getSupportActionBar().setSubtitle(processSpecDto.getFlow());
loadScreenFields(screen.get(), languages);
- }
- else {
+ } else {
//No more screens start loading preview screen
Intent intent = new Intent(this, PreviewActivity.class);
startActivity(intent);
}
final Button nextButton = findViewById(R.id.next);
- nextButton.setOnClickListener( v -> {
+ nextButton.setOnClickListener(v -> {
Optional view = currentDynamicViews.values()
.stream()
- .filter( d -> (d.isRequired() && !d.isValidValue()))
+ .filter(d -> (d.isRequired() && !d.isValidValue()))
.findFirst();
- if(view.isPresent()) {
- ((View)view.get()).requestFocus();
+ if (view.isPresent()) {
+ ((View) view.get()).requestFocus();
nextButton.setError("Invalid value found");
- }
- else {
+ } else {
nextButton.setError(null);
//start activity to render next screen
Intent intent = new Intent(this, ScreenActivity.class);
intent.putExtra("screens", screens);
- intent.putExtra("nextScreenIndex", currentScreenIndex+1);
+ intent.putExtra("nextScreenIndex", currentScreenIndex + 1);
startActivity(intent);
finish();
}
@@ -129,8 +133,8 @@ private void loadScreenFields(ScreenSpecDto screenSpecDto, List language
fieldPanel.removeAllViews();
DynamicComponentFactory factory = new DynamicComponentFactory(getApplicationContext(), masterDataService);
- for(FieldSpecDto fieldSpecDto : screenSpecDto.getFields()) {
- if(fieldSpecDto.getInputRequired()) {
+ for (FieldSpecDto fieldSpecDto : screenSpecDto.getFields()) {
+ if (fieldSpecDto.getInputRequired()) {
DynamicView dynamicView = null;
switch (fieldSpecDto.getControlType().toLowerCase()) {
case "textbox":
@@ -160,8 +164,8 @@ private void loadScreenFields(ScreenSpecDto screenSpecDto, List language
break;
}
- if(dynamicView != null) {
- fieldPanel.addView((View)dynamicView);
+ if (dynamicView != null) {
+ fieldPanel.addView((View) dynamicView);
currentDynamicViews.put(fieldSpecDto.getId(), dynamicView);
this.registrationService.getRegistrationDto().addObserver((Observer) dynamicView);
}
@@ -175,12 +179,13 @@ public void goToHome() {
}
@Override
+ @OptIn(markerClass = com.google.android.material.badge.ExperimentalBadgeUtils.class)
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
String fieldId = requestCodeMap.get(requestCode);
- if(resultCode == Activity.RESULT_OK) {
+ if (resultCode == Activity.RESULT_OK) {
switch (requestCode) {
- case 1 :
+ case 1:
parseDiscoverResponse(data.getStringExtra("Response"));
break;
case 2:
@@ -192,20 +197,19 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
default:
if (requestCodeMap.containsKey(requestCode)) {
Uri uri = data.getExtras().getParcelable(ScanConstants.SCANNED_RESULT);
- try(InputStream iStream = getContentResolver().openInputStream(uri)) {
+ try (InputStream iStream = getContentResolver().openInputStream(uri)) {
Spinner sItems = ((Spinner) ((View) currentDynamicViews.get(fieldId)).findViewById(R.id.doctypes_dropdown));
this.registrationService.getRegistrationDto().addDocument(fieldId, sItems.getSelectedItem().toString(), getBytes(iStream));
View view = ((View) currentDynamicViews.get(fieldId)).findViewById(R.id.doc_saved);
view.setVisibility(View.VISIBLE);
- BadgeDrawable badgeDrawable = BadgeDrawable.create(this);
+ BadgeDrawable badgeDrawable = BadgeDrawable.create(this);
badgeDrawable.setNumber(this.registrationService.getRegistrationDto().getScannedPages(fieldId).size());
badgeDrawable.setVisible(true);
BadgeUtils.attachBadgeDrawable(badgeDrawable, view);
} catch (Exception e) {
Log.e(TAG, "Failed to set document to registration dto", e);
}
- }
- else
+ } else
Toast.makeText(this, "Scan failed", Toast.LENGTH_LONG).show();
break;
}
@@ -214,14 +218,14 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
private void setRCaptureButtonListener(View view) {
Button faceButton = view.findViewById(R.id.rcapture_face);
- faceButton.setOnClickListener( v -> {
+ faceButton.setOnClickListener(v -> {
discoverSBI("face");
});
}
private void setScanButtonListener(int requestCode, View view, FieldSpecDto fieldSpecDto) {
Button button = view.findViewById(R.id.scan_doc);
- button.setOnClickListener( v -> {
+ button.setOnClickListener(v -> {
int preference = ScanConstants.OPEN_CAMERA;
Intent intent = new Intent(this, ScanActivity.class);
intent.putExtra(ScanConstants.OPEN_INTENT_PREFERENCE, preference);
@@ -229,7 +233,7 @@ private void setScanButtonListener(int requestCode, View view, FieldSpecDto fiel
});
ImageButton previewButton = view.findViewById(R.id.doc_saved);
- previewButton.setOnClickListener( v -> {
+ previewButton.setOnClickListener(v -> {
Intent intent = new Intent(this, PreviewDocumentActivity.class);
intent.putExtra("fieldId", fieldSpecDto.getId());
//TODO get label based on logged in language
@@ -239,7 +243,7 @@ private void setScanButtonListener(int requestCode, View view, FieldSpecDto fiel
}
private byte[] getBytes(InputStream inputStream) throws IOException {
- try(ByteArrayOutputStream byteBuffer = new ByteArrayOutputStream()) {
+ try (ByteArrayOutputStream byteBuffer = new ByteArrayOutputStream()) {
int bufferSize = 1024;
byte[] buffer = new byte[bufferSize];
@@ -257,7 +261,7 @@ private void discoverSBI(String currentModality) {
intent.setAction("sbi.reg.device");
List activities = this.getPackageManager().queryIntentActivities(intent, MATCH_DEFAULT_ONLY);
if (activities.size() > 0) {
- intent.putExtra("input", "{\"type\":\""+currentModality+"\"}");
+ intent.putExtra("input", "{\"type\":\"" + currentModality + "\"}");
this.startActivityForResult(intent, 1);
} else {
Toast.makeText(getApplicationContext(), "Supported apps not found!", Toast.LENGTH_LONG).show();
@@ -265,8 +269,7 @@ private void discoverSBI(String currentModality) {
}
private void info(String callbackId) {
- if (callbackId == null)
- {
+ if (callbackId == null) {
Toast.makeText(this, "No SBI found!", Toast.LENGTH_LONG).show();
return;
}
@@ -282,8 +285,7 @@ private void info(String callbackId) {
}
private void rcapture(String callbackId, String deviceId) {
- if (deviceId == null || callbackId == null)
- {
+ if (deviceId == null || callbackId == null) {
Toast.makeText(this, "No SBI found!", Toast.LENGTH_LONG).show();
return;
}
@@ -365,12 +367,11 @@ private void parseRCaptureResponse(String response) {
JSONArray jsonObject = new JSONObject(response).getJSONArray("biometrics");
String specVersion = jsonObject.getJSONObject(0).getString("specVersion");
String data = jsonObject.getJSONObject(0).getString("data");
- if(data == null || data.isEmpty()) {
+ if (data == null || data.isEmpty()) {
JSONObject error = jsonObject.getJSONObject(0).getJSONObject("error");
Toast.makeText(getApplicationContext(), "Biometric Capture failed : " + error.toString(2),
Toast.LENGTH_LONG).show();
- }
- else {
+ } else {
String signature = this.getSignature(data);
byte[] payloadBuffer = this.getPayloadBuffer(data);
String decodedPayload = new String(payloadBuffer);
@@ -381,7 +382,7 @@ private void parseRCaptureResponse(String response) {
//TODO - better way to handle all modalities
BiometricsDto biometricsDto = new BiometricsDto("face", "face", specVersion, false,
decodedPayload, signature, bioValue, qualityScore);
- ((TextView)((View) currentDynamicViews.get("individualBiometrics")).findViewById(R.id.sbi_result))
+ ((TextView) ((View) currentDynamicViews.get("individualBiometrics")).findViewById(R.id.sbi_result))
.setText(String.format("\nSpecVersion : %s \nQualityScore : %s", specVersion, qualityScore));
this.registrationService.getRegistrationDto().addBiometric("individualBiometrics",
"face", biometricsDto);
diff --git a/client/app/src/main/java/io/mosip/registration/app/util/JobServiceHelper.java b/client/app/src/main/java/io/mosip/registration/app/util/JobServiceHelper.java
new file mode 100644
index 000000000..47bfb1ea8
--- /dev/null
+++ b/client/app/src/main/java/io/mosip/registration/app/util/JobServiceHelper.java
@@ -0,0 +1,79 @@
+package io.mosip.registration.app.util;
+
+import android.app.job.JobInfo;
+import android.app.job.JobScheduler;
+import android.content.ComponentName;
+import android.content.Context;
+
+import io.mosip.registration.clientmanager.jobservice.PacketStatusSyncJob;
+import io.mosip.registration.clientmanager.spi.PacketService;
+import kotlin.NotImplementedError;
+
+public class JobServiceHelper {
+
+ private static final String TAG = JobServiceHelper.class.getSimpleName();
+ Context context;
+ JobScheduler jobScheduler;
+ PacketService packetService;
+
+ public JobServiceHelper(Context context, JobScheduler jobScheduler, PacketService packetService) {
+ this.context = context;
+ this.jobScheduler = jobScheduler;
+ this.packetService = packetService;
+ }
+
+ public int scheduleJob(int jobId, String apiName) throws ClassNotFoundException {
+ Class> clientJobService = getJobServiceImplClass(apiName);
+
+ if (clientJobService == null) {
+ throw new NotImplementedError("Job service : " + apiName + " not implemented");
+ }
+
+ ComponentName componentName = new ComponentName(context, clientJobService);
+ JobInfo info = new JobInfo.Builder(jobId, componentName)
+ .setRequiresCharging(false)
+ //.setRequiredNetworkType(JobInfo.NETWORK_TYPE_UNMETERED)
+ .setPersisted(true)
+ .setPeriodic(15 * 60 * 1000)
+ .build();
+
+ return jobScheduler.schedule(info);
+ }
+
+ public boolean triggerJobService(int jobId) {
+ JobInfo info = jobScheduler.getPendingJob(jobId);
+ if (info == null) {
+ return false;
+ }
+ jobScheduler.schedule(info);
+ return true;
+ }
+
+ public void cancelJob(int jobId) {
+ jobScheduler.cancel(jobId);
+ }
+
+ public boolean isJobEnabled(int jobId) {
+ JobInfo jobinfo = jobScheduler.getPendingJob(jobId);
+ if (jobinfo == null) {
+ return false;
+ }
+ return true;
+ }
+
+ public boolean isJobImplemented(String jobAPIName) {
+ if (getJobServiceImplClass(jobAPIName) == null) {
+ return false;
+ }
+ return true;
+ }
+
+ public Class> getJobServiceImplClass(String jobAPIName) {
+ switch (jobAPIName) {
+ case "packetSyncStatusJob":
+ return PacketStatusSyncJob.class;
+ default:
+ return null;
+ }
+ }
+}
diff --git a/client/app/src/main/java/io/mosip/registration/app/viewmodel/IListingViewModel.java b/client/app/src/main/java/io/mosip/registration/app/viewmodel/IListingViewModel.java
new file mode 100644
index 000000000..ef1a93108
--- /dev/null
+++ b/client/app/src/main/java/io/mosip/registration/app/viewmodel/IListingViewModel.java
@@ -0,0 +1,9 @@
+package io.mosip.registration.app.viewmodel;
+
+import androidx.lifecycle.LiveData;
+
+import java.util.List;
+
+public interface IListingViewModel {
+ LiveData> getList();
+}
diff --git a/client/app/src/main/java/io/mosip/registration/app/viewmodel/JobServiceViewModel.java b/client/app/src/main/java/io/mosip/registration/app/viewmodel/JobServiceViewModel.java
new file mode 100644
index 000000000..47ffc22b3
--- /dev/null
+++ b/client/app/src/main/java/io/mosip/registration/app/viewmodel/JobServiceViewModel.java
@@ -0,0 +1,77 @@
+package io.mosip.registration.app.viewmodel;
+
+import android.util.Log;
+
+import androidx.lifecycle.LiveData;
+import androidx.lifecycle.MutableLiveData;
+import androidx.lifecycle.ViewModel;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import io.mosip.registration.app.util.JobServiceHelper;
+import io.mosip.registration.app.viewmodel.model.JobServiceModel;
+import io.mosip.registration.clientmanager.entity.SyncJobDef;
+import io.mosip.registration.clientmanager.spi.PacketService;
+
+public class JobServiceViewModel extends ViewModel implements IListingViewModel {
+
+ private static final String TAG = JobServiceViewModel.class.getSimpleName();
+ private static final int numLengthLimit = 5;
+
+ JobServiceHelper jobServiceHelper;
+ PacketService packetService;
+
+ public JobServiceViewModel(JobServiceHelper jobServiceHelper, PacketService packetService) {
+ this.jobServiceHelper = jobServiceHelper;
+ this.packetService = packetService;
+ }
+
+ private MutableLiveData> jobServiceList;
+
+ @Override
+ public LiveData> getList() {
+ if (jobServiceList == null) {
+ jobServiceList = new MutableLiveData<>();
+ loadServices();
+ }
+ return jobServiceList;
+ }
+
+ private void loadServices() {
+ List jobServices = new ArrayList<>();
+
+ List syncJobDefList = packetService.getAllSyncJobDefList();
+ for (SyncJobDef jobDef : syncJobDefList) {
+
+ boolean isImplemented = jobServiceHelper.isJobImplemented(jobDef.getApiName());
+ boolean isEnabled = jobServiceHelper.isJobEnabled(getId(jobDef.getId()));
+
+ jobServices.add(new JobServiceModel(
+ getId(jobDef.getId()),
+ jobDef.getName(),
+ jobDef.getApiName(),
+ jobDef.getParentSyncJobId(),
+ jobDef.getSyncFreq(),
+ jobDef.getLockDuration(),
+ jobDef.getLangCode(),
+ jobDef.getIsDeleted(),
+ jobDef.getIsActive(),
+ isImplemented,
+ isEnabled
+ ));
+ }
+
+ jobServiceList.setValue(jobServices);
+ }
+
+ private int getId(String jobId) {
+ try {
+ String lastCharsWithNumLengthLimit = jobId.substring(jobId.length() - numLengthLimit);
+ return Integer.parseInt(lastCharsWithNumLengthLimit);
+ } catch (Exception ex) {
+ Log.e(TAG, "Conversion of jobId : " + jobId + "to int failed for length " + numLengthLimit + ex.getMessage());
+ throw ex;
+ }
+ }
+}
diff --git a/client/app/src/main/java/io/mosip/registration/app/viewmodel/ListingViewModel.java b/client/app/src/main/java/io/mosip/registration/app/viewmodel/RegistrationPacketViewModel.java
similarity index 76%
rename from client/app/src/main/java/io/mosip/registration/app/viewmodel/ListingViewModel.java
rename to client/app/src/main/java/io/mosip/registration/app/viewmodel/RegistrationPacketViewModel.java
index 6431bb275..0122aeed2 100644
--- a/client/app/src/main/java/io/mosip/registration/app/viewmodel/ListingViewModel.java
+++ b/client/app/src/main/java/io/mosip/registration/app/viewmodel/RegistrationPacketViewModel.java
@@ -1,6 +1,5 @@
package io.mosip.registration.app.viewmodel;
-import android.os.Handler;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;
@@ -9,19 +8,20 @@
import java.util.List;
-public class ListingViewModel extends ViewModel {
+public class RegistrationPacketViewModel extends ViewModel implements IListingViewModel {
- private static final String TAG = ListingViewModel.class.getSimpleName();
+ private static final String TAG = RegistrationPacketViewModel.class.getSimpleName();
private PacketService packetService;
- public ListingViewModel(PacketService packetService) {
+ public RegistrationPacketViewModel(PacketService packetService) {
this.packetService = packetService;
}
private MutableLiveData> registrationList;
- public LiveData> getRegistrationList() {
+ @Override
+ public LiveData> getList() {
if (registrationList == null) {
registrationList = new MutableLiveData<>();
loadRegistrations();
diff --git a/client/app/src/main/java/io/mosip/registration/app/viewmodel/ViewModelFactory.java b/client/app/src/main/java/io/mosip/registration/app/viewmodel/ViewModelFactory.java
index 19568b5e6..bb92294d3 100644
--- a/client/app/src/main/java/io/mosip/registration/app/viewmodel/ViewModelFactory.java
+++ b/client/app/src/main/java/io/mosip/registration/app/viewmodel/ViewModelFactory.java
@@ -4,19 +4,19 @@
import androidx.lifecycle.ViewModel;
import androidx.lifecycle.ViewModelProvider;
-public class ViewModelFactory implements ViewModelProvider.Factory {
+public class ViewModelFactory implements ViewModelProvider.Factory {
- private ListingViewModel listingViewModel;
+ private T viewModel;
- public ViewModelFactory(ListingViewModel listingViewModel) {
- this.listingViewModel = listingViewModel;
+ public ViewModelFactory(T viewModel) {
+ this.viewModel = viewModel;
}
@NonNull
@Override
public T create(@NonNull Class modelClass) {
- if(modelClass == ListingViewModel.class){
- return (T) this.listingViewModel;
+ if(IListingViewModel.class.isAssignableFrom(modelClass)){
+ return (T) this.viewModel;
}else{
throw new IllegalStateException("Unknown entity");
}
diff --git a/client/app/src/main/java/io/mosip/registration/app/viewmodel/model/JobServiceModel.java b/client/app/src/main/java/io/mosip/registration/app/viewmodel/model/JobServiceModel.java
new file mode 100644
index 000000000..86b443e36
--- /dev/null
+++ b/client/app/src/main/java/io/mosip/registration/app/viewmodel/model/JobServiceModel.java
@@ -0,0 +1,119 @@
+package io.mosip.registration.app.viewmodel.model;
+
+
+public class JobServiceModel {
+
+ private int id;
+ private String name;
+ private String apiName;
+ private String parentSyncJobId;
+ private String syncFreq;
+ private String lockDuration;
+ private String langCode;
+ private Boolean isDeleted;
+ private Boolean isActive;
+ private Boolean isImplemented;
+ private Boolean isEnabled;
+
+ public JobServiceModel(int id, String name, String apiName, String parentSyncJobId, String syncFreq, String lockDuration, String langCode, Boolean isDeleted, Boolean isActive, Boolean isImplemented, Boolean isEnabled) {
+ this.id = id;
+ this.name = name;
+ this.apiName = apiName;
+ this.parentSyncJobId = parentSyncJobId;
+ this.syncFreq = syncFreq;
+ this.lockDuration = lockDuration;
+ this.langCode = langCode;
+ this.isDeleted = isDeleted;
+ this.isActive = isActive;
+ this.isImplemented = isImplemented;
+ this.isEnabled = isEnabled;
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getApiName() {
+ return apiName;
+ }
+
+ public void setApiName(String apiName) {
+ this.apiName = apiName;
+ }
+
+ public String getParentSyncJobId() {
+ return parentSyncJobId;
+ }
+
+ public void setParentSyncJobId(String parentSyncJobId) {
+ this.parentSyncJobId = parentSyncJobId;
+ }
+
+ public String getSyncFreq() {
+ return syncFreq;
+ }
+
+ public void setSyncFreq(String syncFreq) {
+ this.syncFreq = syncFreq;
+ }
+
+ public String getLockDuration() {
+ return lockDuration;
+ }
+
+ public void setLockDuration(String lockDuration) {
+ this.lockDuration = lockDuration;
+ }
+
+ public String getLangCode() {
+ return langCode;
+ }
+
+ public void setLangCode(String langCode) {
+ this.langCode = langCode;
+ }
+
+ public Boolean getDeleted() {
+ return isDeleted;
+ }
+
+ public void setDeleted(Boolean deleted) {
+ isDeleted = deleted;
+ }
+
+ public Boolean getActive() {
+ return isActive;
+ }
+
+ public void setActive(Boolean active) {
+ isActive = active;
+ }
+
+ public Boolean getImplemented() {
+ return isImplemented;
+ }
+
+ public void setImplemented(Boolean implemented) {
+ isImplemented = implemented;
+ }
+
+ public Boolean getEnabled() {
+ return isEnabled;
+ }
+
+ public void setEnabled(Boolean enabled) {
+ isEnabled = enabled;
+ }
+}
diff --git a/client/app/src/main/res/layout/activity_job_service.xml b/client/app/src/main/res/layout/activity_job_service.xml
new file mode 100644
index 000000000..e97b4c1aa
--- /dev/null
+++ b/client/app/src/main/res/layout/activity_job_service.xml
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/client/app/src/main/res/layout/activity_main.xml b/client/app/src/main/res/layout/activity_main.xml
index 6fcf2fccb..91385d2ad 100644
--- a/client/app/src/main/res/layout/activity_main.xml
+++ b/client/app/src/main/res/layout/activity_main.xml
@@ -30,6 +30,14 @@
android:layout_height="wrap_content"
android:onClick="click_list_packets"
android:id="@+id/button15" />
+
+
\ No newline at end of file
diff --git a/client/app/src/main/res/layout/custom_list_view_job.xml b/client/app/src/main/res/layout/custom_list_view_job.xml
new file mode 100644
index 000000000..bcdeeb8b2
--- /dev/null
+++ b/client/app/src/main/res/layout/custom_list_view_job.xml
@@ -0,0 +1,52 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/client/app/src/main/res/layout/listing_activity.xml b/client/app/src/main/res/layout/listing_activity.xml
index a60a8e834..262a4699a 100644
--- a/client/app/src/main/res/layout/listing_activity.xml
+++ b/client/app/src/main/res/layout/listing_activity.xml
@@ -5,23 +5,27 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".activites.ListingActivity">
+
+
-
-
-
+
-
-
-
+ android:layout_height="wrap_content" />
+
+
\ No newline at end of file
diff --git a/client/clientmanager/src/main/java/io/mosip/registration/clientmanager/config/ClientDatabase.java b/client/clientmanager/src/main/java/io/mosip/registration/clientmanager/config/ClientDatabase.java
index 99e277437..847b2aca8 100644
--- a/client/clientmanager/src/main/java/io/mosip/registration/clientmanager/config/ClientDatabase.java
+++ b/client/clientmanager/src/main/java/io/mosip/registration/clientmanager/config/ClientDatabase.java
@@ -15,7 +15,7 @@
MachineMaster.class, DocumentType.class, DynamicField.class,
ApplicantValidDocument.class, Template.class, KeyStore.class,
Location.class, GlobalParam.class, IdentitySchema.class, LocationHierarchy.class,
- BlocklistedWord.class, UserDetail.class},
+ BlocklistedWord.class, SyncJobDef.class, UserDetail.class},
version = 1, exportSchema = false)
public abstract class ClientDatabase extends RoomDatabase {
@@ -47,6 +47,7 @@ public static ClientDatabase getDatabase(Context context){
public abstract IdentitySchemaDao identitySchemaDao();
public abstract LocationHierarchyDao locationHierarchyDao();
public abstract BlocklistedWordDao blocklistedWordDao();
+ public abstract SyncJobDefDao syncJobDefDao();
public abstract UserDetailDao userDetailDao();
public static void destroyDB(){
diff --git a/client/clientmanager/src/main/java/io/mosip/registration/clientmanager/config/RoomModule.java b/client/clientmanager/src/main/java/io/mosip/registration/clientmanager/config/RoomModule.java
index 02bb1c5de..a65d23f05 100644
--- a/client/clientmanager/src/main/java/io/mosip/registration/clientmanager/config/RoomModule.java
+++ b/client/clientmanager/src/main/java/io/mosip/registration/clientmanager/config/RoomModule.java
@@ -116,6 +116,12 @@ BlocklistedWordDao providesBlocklistedWordDao(ClientDatabase clientDatabase) {
return clientDatabase.blocklistedWordDao();
}
+ @Singleton
+ @Provides
+ SyncJobDefDao providesSyncJobDefDao(ClientDatabase clientDatabase) {
+ return clientDatabase.syncJobDefDao();
+ }
+
@Singleton
@Provides
UserDetailDao providesUserDetailDao(ClientDatabase clientDatabase) {
@@ -195,6 +201,12 @@ BlocklistedWordRepository provideBlocklistedWordRepository(BlocklistedWordDao bl
return new BlocklistedWordRepository(blocklistedWordDao);
}
+ @Provides
+ @Singleton
+ SyncJobDefRepository provideSyncJobDefRepository(SyncJobDefDao syncJobDefDao) {
+ return new SyncJobDefRepository(syncJobDefDao);
+ }
+
@Provides
@Singleton
UserDetailRepository provideUserDetailRepository(UserDetailDao userDetailDao, UserTokenDao userTokenDao) {
diff --git a/client/clientmanager/src/main/java/io/mosip/registration/clientmanager/constant/RegistrationConstants.java b/client/clientmanager/src/main/java/io/mosip/registration/clientmanager/constant/RegistrationConstants.java
new file mode 100644
index 000000000..52b400400
--- /dev/null
+++ b/client/clientmanager/src/main/java/io/mosip/registration/clientmanager/constant/RegistrationConstants.java
@@ -0,0 +1,6 @@
+package io.mosip.registration.clientmanager.constant;
+
+public class RegistrationConstants {
+ public static final String PACKET_EXTERNAL_STATUS_READER_ID = "mosip.registration.packet.external.status";
+ public static final String PACKET_SYNC_VERSION = "1.0";
+}
diff --git a/client/clientmanager/src/main/java/io/mosip/registration/clientmanager/dao/SyncJobDefDao.java b/client/clientmanager/src/main/java/io/mosip/registration/clientmanager/dao/SyncJobDefDao.java
new file mode 100644
index 000000000..1f15fec3d
--- /dev/null
+++ b/client/clientmanager/src/main/java/io/mosip/registration/clientmanager/dao/SyncJobDefDao.java
@@ -0,0 +1,62 @@
+package io.mosip.registration.clientmanager.dao;
+
+import androidx.room.Dao;
+import androidx.room.Insert;
+import androidx.room.OnConflictStrategy;
+import androidx.room.Query;
+
+import java.util.List;
+
+import io.mosip.registration.clientmanager.entity.SyncJobDef;
+
+/**
+ * DAO class for all the Sync Job related details
+ *
+ * @author Anshul vanawat
+ */
+@Dao
+public interface SyncJobDefDao {
+
+ /**
+ * To get all jobs in the List of {@link SyncJobDef}
+ *
+ * @return list of sync jobs
+ */
+ @Query("SELECT * FROM sync_job_def order by id desc")
+ List findAll();
+
+ /**
+ * To get a job in the List of {@link SyncJobDef}
+ *
+ * @return sync job
+ */
+ @Query("select * from sync_job_def where id=:jobId")
+ SyncJobDef findOneById(String jobId);
+
+ /**
+ * To get all the List of active {@link SyncJobDef}
+ *
+ * @return list active sync jobs
+ */
+ @Query("select * from sync_job_def where is_active=:isActive")
+ List findAllByActiveStatus(Boolean isActive);
+
+ /**
+ * Update all the Syncjobs available in the {@link SyncJobDef} list
+ *
+ * @param jobId job to be updated
+ * @param isActive active or deactivate
+ * @return updated syncJobs
+ */
+ @Query("Update sync_job_def set is_active = :isActive where id = :jobId")
+ void updateJobActiveStatus(String jobId, boolean isActive);
+
+ /**
+ * To insert sync job list {@link SyncJobDef}
+ *
+ * @return list active sync jobs
+ */
+ @Insert(onConflict = OnConflictStrategy.REPLACE)
+ void insert(SyncJobDef syncJobDef);
+
+}
diff --git a/client/clientmanager/src/main/java/io/mosip/registration/clientmanager/dto/Error.java b/client/clientmanager/src/main/java/io/mosip/registration/clientmanager/dto/Error.java
new file mode 100644
index 000000000..a53a2ee87
--- /dev/null
+++ b/client/clientmanager/src/main/java/io/mosip/registration/clientmanager/dto/Error.java
@@ -0,0 +1,24 @@
+package io.mosip.registration.clientmanager.dto;
+
+import lombok.Data;
+import com.google.gson.annotations.Expose;
+import com.google.gson.annotations.SerializedName;
+
+/**
+ * The DTO Class PacketStatusReaderDTO.
+ *
+ * @author Anshul vanawat
+ * @since 1.0.0
+ */
+
+@Data
+public class Error {
+
+ @SerializedName("errorCode")
+ @Expose
+ private String errorCode;
+ @SerializedName("errorMessage")
+ @Expose
+ private String errorMessage;
+
+}
\ No newline at end of file
diff --git a/client/clientmanager/src/main/java/io/mosip/registration/clientmanager/dto/PacketIdDto.java b/client/clientmanager/src/main/java/io/mosip/registration/clientmanager/dto/PacketIdDto.java
new file mode 100644
index 000000000..f4da5b2d9
--- /dev/null
+++ b/client/clientmanager/src/main/java/io/mosip/registration/clientmanager/dto/PacketIdDto.java
@@ -0,0 +1,22 @@
+package io.mosip.registration.clientmanager.dto;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import com.google.gson.annotations.Expose;
+import com.google.gson.annotations.SerializedName;
+
+/**
+ * The DTO Class PacketStatusReaderDTO.
+ *
+ * @author Anshul vanawat
+ * @since 1.0.0
+ */
+
+@Data
+@AllArgsConstructor
+public class PacketIdDto {
+
+ @SerializedName("packetId")
+ @Expose
+ private String packetId;
+
+}
diff --git a/client/clientmanager/src/main/java/io/mosip/registration/clientmanager/dto/PacketStatusDto.java b/client/clientmanager/src/main/java/io/mosip/registration/clientmanager/dto/PacketStatusDto.java
new file mode 100644
index 000000000..2597134c0
--- /dev/null
+++ b/client/clientmanager/src/main/java/io/mosip/registration/clientmanager/dto/PacketStatusDto.java
@@ -0,0 +1,25 @@
+package io.mosip.registration.clientmanager.dto;
+
+import com.google.gson.annotations.Expose;
+import com.google.gson.annotations.SerializedName;
+
+import lombok.Data;
+
+/**
+ * The DTO Class PacketStatusReaderDTO.
+ *
+ * @author Anshul vanawat
+ * @since 1.0.0
+ */
+
+@Data
+public class PacketStatusDto {
+
+ @SerializedName("packetId")
+ @Expose
+ private String packetId;
+ @SerializedName("statusCode")
+ @Expose
+ private String statusCode;
+
+}
diff --git a/client/clientmanager/src/main/java/io/mosip/registration/clientmanager/dto/PacketStatusRequest.java b/client/clientmanager/src/main/java/io/mosip/registration/clientmanager/dto/PacketStatusRequest.java
new file mode 100644
index 000000000..2a3812bdf
--- /dev/null
+++ b/client/clientmanager/src/main/java/io/mosip/registration/clientmanager/dto/PacketStatusRequest.java
@@ -0,0 +1,34 @@
+
+package io.mosip.registration.clientmanager.dto;
+
+import java.util.List;
+import com.google.gson.annotations.Expose;
+import com.google.gson.annotations.SerializedName;
+
+import lombok.Data;
+
+/**
+ * The DTO Class PacketStatusReaderDTO.
+ *
+ * @author Anshul vanawat
+ * @since 1.0.0
+ */
+
+
+@Data
+public class PacketStatusRequest {
+
+ @SerializedName("id")
+ @Expose
+ private String id;
+ @SerializedName("request")
+ @Expose
+ private List request = null;
+ @SerializedName("requesttime")
+ @Expose
+ private String requesttime;
+ @SerializedName("version")
+ @Expose
+ private String version;
+
+}
\ No newline at end of file
diff --git a/client/clientmanager/src/main/java/io/mosip/registration/clientmanager/dto/PacketStatusResponse.java b/client/clientmanager/src/main/java/io/mosip/registration/clientmanager/dto/PacketStatusResponse.java
new file mode 100644
index 000000000..abc35ba8e
--- /dev/null
+++ b/client/clientmanager/src/main/java/io/mosip/registration/clientmanager/dto/PacketStatusResponse.java
@@ -0,0 +1,34 @@
+package io.mosip.registration.clientmanager.dto;
+
+import java.util.List;
+import lombok.Data;
+import com.google.gson.annotations.Expose;
+import com.google.gson.annotations.SerializedName;
+
+/**
+ * The DTO Class PacketStatusReaderDTO.
+ *
+ * @author Anshul vanawat
+ * @since 1.0.0
+ */
+
+@Data
+public class PacketStatusResponse {
+
+ @SerializedName("response")
+ @Expose
+ private List response = null;
+ @SerializedName("errors")
+ @Expose
+ private List errors = null;
+ @SerializedName("id")
+ @Expose
+ private String id;
+ @SerializedName("version")
+ @Expose
+ private String version;
+ @SerializedName("responsetime")
+ @Expose
+ private String responsetime;
+
+}
diff --git a/client/clientmanager/src/main/java/io/mosip/registration/clientmanager/dto/http/PacketStatusUpdateDto.java b/client/clientmanager/src/main/java/io/mosip/registration/clientmanager/dto/http/PacketStatusUpdateDto.java
new file mode 100644
index 000000000..9d7ad031f
--- /dev/null
+++ b/client/clientmanager/src/main/java/io/mosip/registration/clientmanager/dto/http/PacketStatusUpdateDto.java
@@ -0,0 +1,20 @@
+package io.mosip.registration.clientmanager.dto.http;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ *
+ * @author Anshul vanawat
+ *
+ */
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class PacketStatusUpdateDto {
+
+ private String registrationId;
+
+ private String statusCode;
+}
diff --git a/client/clientmanager/src/main/java/io/mosip/registration/clientmanager/dto/http/PacketStatusUpdateResponseDto.java b/client/clientmanager/src/main/java/io/mosip/registration/clientmanager/dto/http/PacketStatusUpdateResponseDto.java
new file mode 100644
index 000000000..93ea936a8
--- /dev/null
+++ b/client/clientmanager/src/main/java/io/mosip/registration/clientmanager/dto/http/PacketStatusUpdateResponseDto.java
@@ -0,0 +1,16 @@
+package io.mosip.registration.clientmanager.dto.http;
+
+import java.util.List;
+import lombok.Data;
+
+/**
+ *
+ * @author Anshul vanawat
+ *
+ */
+@Data
+public class PacketStatusUpdateResponseDto {
+
+ /** The packet status update list. */
+ private List packetStatusUpdateList;
+}
\ No newline at end of file
diff --git a/client/clientmanager/src/main/java/io/mosip/registration/clientmanager/entity/SyncJobDef.java b/client/clientmanager/src/main/java/io/mosip/registration/clientmanager/entity/SyncJobDef.java
new file mode 100644
index 000000000..776be2416
--- /dev/null
+++ b/client/clientmanager/src/main/java/io/mosip/registration/clientmanager/entity/SyncJobDef.java
@@ -0,0 +1,43 @@
+package io.mosip.registration.clientmanager.entity;
+
+import androidx.annotation.NonNull;
+import androidx.room.ColumnInfo;
+import androidx.room.Entity;
+import androidx.room.PrimaryKey;
+
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * The Entity class for sync job def
+ *
+ * @author Anshul vanawat
+ */
+
+@Entity(tableName = "sync_job_def")
+@Data
+@EqualsAndHashCode(callSuper = false)
+public class SyncJobDef {
+
+ @NonNull
+ @PrimaryKey
+ @ColumnInfo(name = "id")
+ private String id;
+ @ColumnInfo(name = "name")
+ private String name;
+ @ColumnInfo(name = "api_name")
+ private String apiName;
+ @ColumnInfo(name = "parent_syncjob_id")
+ private String parentSyncJobId;
+ @ColumnInfo(name = "sync_freq")
+ private String syncFreq;
+ @ColumnInfo(name = "lock_duration")
+ private String lockDuration;
+ @ColumnInfo(name = "lang_code")
+ private String langCode;
+ @ColumnInfo(name = "is_deleted")
+ private Boolean isDeleted;
+ @ColumnInfo(name = "is_active")
+ private Boolean isActive;
+
+}
diff --git a/client/clientmanager/src/main/java/io/mosip/registration/clientmanager/jobservice/PacketStatusSyncJob.java b/client/clientmanager/src/main/java/io/mosip/registration/clientmanager/jobservice/PacketStatusSyncJob.java
new file mode 100644
index 000000000..90777a9c6
--- /dev/null
+++ b/client/clientmanager/src/main/java/io/mosip/registration/clientmanager/jobservice/PacketStatusSyncJob.java
@@ -0,0 +1,70 @@
+package io.mosip.registration.clientmanager.jobservice;
+
+import android.app.job.JobParameters;
+import android.app.job.JobService;
+import android.util.Log;
+
+import androidx.work.Configuration;
+
+import javax.inject.Inject;
+
+import dagger.android.AndroidInjection;
+import io.mosip.registration.clientmanager.spi.PacketService;
+
+public class PacketStatusSyncJob extends JobService {
+
+ private static final String TAG = PacketStatusSyncJob.class.getSimpleName();
+ private Thread jobThread;
+
+ @Inject
+ PacketService packetService;
+
+ public PacketStatusSyncJob() {
+ Configuration.Builder builder = new Configuration.Builder();
+ builder.setJobSchedulerJobIdRange(0, 1000);
+ }
+
+ @Override
+ public void onCreate() {
+ super.onCreate();
+ AndroidInjection.inject(this);
+ }
+
+ @Override
+ public boolean onStartJob(JobParameters params) {
+ Log.d(TAG, "Job started");
+
+ jobThread = new Thread(() -> {
+ if (triggerJob())
+ Log.d(TAG, "Job succeeded");
+ else
+ Log.d(TAG, "Job failed");
+ jobFinished(params, false);
+ });
+
+ jobThread.start();
+
+ return true;
+ }
+
+ @Override
+ public boolean onStopJob(JobParameters params) {
+ if (jobThread != null && jobThread.isAlive()) {
+ jobThread.interrupt();
+ }
+ return true;
+ }
+
+ private boolean triggerJob() {
+ Log.d(TAG, TAG + " Started");
+ try {
+ packetService.syncAllPacketStatus();
+ return true;
+ } catch (Exception e) {
+ Log.e(TAG, TAG + " failed", e);
+ }
+ Log.d(TAG, TAG + " Completed");
+ return false;
+ }
+
+}
\ No newline at end of file
diff --git a/client/clientmanager/src/main/java/io/mosip/registration/clientmanager/repository/SyncJobDefRepository.java b/client/clientmanager/src/main/java/io/mosip/registration/clientmanager/repository/SyncJobDefRepository.java
new file mode 100644
index 000000000..8fb15622e
--- /dev/null
+++ b/client/clientmanager/src/main/java/io/mosip/registration/clientmanager/repository/SyncJobDefRepository.java
@@ -0,0 +1,45 @@
+package io.mosip.registration.clientmanager.repository;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import java.util.List;
+
+import javax.inject.Inject;
+
+import io.mosip.registration.clientmanager.dao.SyncJobDefDao;
+import io.mosip.registration.clientmanager.entity.SyncJobDef;
+
+/**
+ * DAO class for all the Sync Job related details
+ *
+ * @author Anshul vanawat
+ */
+
+public class SyncJobDefRepository {
+
+ private SyncJobDefDao syncJobDefDao;
+
+ @Inject
+ public SyncJobDefRepository(SyncJobDefDao syncJobDefDao) {
+ this.syncJobDefDao = syncJobDefDao;
+ }
+
+ public void saveSyncJobDef(JSONObject jsonObject) throws JSONException {
+ SyncJobDef syncJobDef = new SyncJobDef(jsonObject.getString("id"));
+ syncJobDef.setName(jsonObject.getString("name"));
+ syncJobDef.setApiName(jsonObject.getString("apiName"));
+ syncJobDef.setParentSyncJobId(jsonObject.getString("parentSyncJobId"));
+ syncJobDef.setSyncFreq(jsonObject.getString("syncFreq"));
+ syncJobDef.setLockDuration(jsonObject.getString("lockDuration"));
+ syncJobDef.setLangCode(jsonObject.getString("langCode"));
+ syncJobDef.setIsDeleted(jsonObject.getBoolean("isDeleted"));
+ syncJobDef.setIsActive(jsonObject.getBoolean("isActive"));
+ syncJobDefDao.insert(syncJobDef);
+ }
+
+ public List getAllSyncJobDefList() {
+ return this.syncJobDefDao.findAll();
+ }
+
+}
diff --git a/client/clientmanager/src/main/java/io/mosip/registration/clientmanager/service/MasterDataServiceImpl.java b/client/clientmanager/src/main/java/io/mosip/registration/clientmanager/service/MasterDataServiceImpl.java
index 17949d8bd..013c948cd 100644
--- a/client/clientmanager/src/main/java/io/mosip/registration/clientmanager/service/MasterDataServiceImpl.java
+++ b/client/clientmanager/src/main/java/io/mosip/registration/clientmanager/service/MasterDataServiceImpl.java
@@ -3,9 +3,11 @@
import android.content.Context;
import android.util.Log;
import android.widget.Toast;
+
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JsonNode;
+
import io.mosip.registration.clientmanager.BuildConfig;
import io.mosip.registration.clientmanager.dto.CenterMachineDto;
import io.mosip.registration.clientmanager.dto.http.*;
@@ -23,15 +25,18 @@
import io.mosip.registration.keymanager.util.CryptoUtil;
import io.mosip.registration.packetmanager.util.JsonUtils;
import okhttp3.ResponseBody;
+
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
+
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import javax.inject.Inject;
import javax.inject.Singleton;
+
import java.io.IOException;
import java.util.*;
import java.util.stream.Collectors;
@@ -58,6 +63,7 @@ public class MasterDataServiceImpl implements MasterDataService {
private GlobalParamRepository globalParamRepository;
private IdentitySchemaRepository identitySchemaRepository;
private BlocklistedWordRepository blocklistedWordRepository;
+ private SyncJobDefRepository syncJobDefRepository;
private UserDetailRepository userDetailRepository;
@Inject
@@ -74,6 +80,7 @@ public MasterDataServiceImpl(Context context, SyncRestService syncRestService,
GlobalParamRepository globalParamRepository,
IdentitySchemaRepository identitySchemaRepository,
BlocklistedWordRepository blocklistedWordRepository,
+ SyncJobDefRepository syncJobDefRepository,
UserDetailRepository userDetailRepository) {
this.context = context;
this.syncRestService = syncRestService;
@@ -89,6 +96,7 @@ public MasterDataServiceImpl(Context context, SyncRestService syncRestService,
this.globalParamRepository = globalParamRepository;
this.identitySchemaRepository = identitySchemaRepository;
this.blocklistedWordRepository = blocklistedWordRepository;
+ this.syncJobDefRepository = syncJobDefRepository;
this.userDetailRepository = userDetailRepository;
}
@@ -96,11 +104,11 @@ public MasterDataServiceImpl(Context context, SyncRestService syncRestService,
public CenterMachineDto getRegistrationCenterMachineDetails() {
CenterMachineDto centerMachineDto = null;
MachineMaster machineMaster = this.machineRepository.getMachine(clientCryptoManagerService.getMachineName());
- if(machineMaster == null)
+ if (machineMaster == null)
return centerMachineDto;
List centers = this.registrationCenterRepository.getRegistrationCenter(machineMaster.getRegCenterId());
- if(centers == null || centers.isEmpty())
+ if (centers == null || centers.isEmpty())
return centerMachineDto;
centerMachineDto = new CenterMachineDto();
@@ -109,7 +117,7 @@ public CenterMachineDto getRegistrationCenterMachineDetails() {
centerMachineDto.setMachineStatus(machineMaster.getIsActive());
centerMachineDto.setCenterId(centers.get(0).getId());
centerMachineDto.setCenterStatus(centers.get(0).getIsActive());
- centerMachineDto.setMachineRefId(centerMachineDto.getCenterId()+"_"+centerMachineDto.getMachineId());
+ centerMachineDto.setMachineRefId(centerMachineDto.getCenterId() + "_" + centerMachineDto.getMachineId());
centerMachineDto.setCenterNames(centers.stream().collect(Collectors.toMap(RegistrationCenter::getLangCode, RegistrationCenter::getName)));
return centerMachineDto;
}
@@ -131,7 +139,7 @@ public void manualSync() {
@Override
public void syncCertificate() {
CenterMachineDto centerMachineDto = getRegistrationCenterMachineDetails();
- if(centerMachineDto == null)
+ if (centerMachineDto == null)
return;
Call> call = syncRestService.getCertificate(REG_APP_ID,
@@ -139,15 +147,14 @@ public void syncCertificate() {
call.enqueue(new Callback>() {
@Override
public void onResponse(Call> call, Response> response) {
- if(response.isSuccessful()) {
+ if (response.isSuccessful()) {
ServiceError error = SyncRestUtil.getServiceError(response.body());
if (error == null) {
keyStoreRepository.saveKeyStore(centerMachineDto.getMachineRefId(), response.body().getResponse().getCertificate());
Toast.makeText(context, "Policy key Sync Completed", Toast.LENGTH_LONG).show();
} else
Toast.makeText(context, "Policy key Sync failed " + error.getMessage(), Toast.LENGTH_LONG).show();
- }
- else
+ } else
Toast.makeText(context, "Policy key Sync failed with status code : " + response.code(), Toast.LENGTH_LONG).show();
}
@@ -166,11 +173,11 @@ public void syncMasterData() throws Exception {
queryParams.put("keyindex", this.clientCryptoManagerService.getClientKeyIndex());
queryParams.put("version", BuildConfig.CLIENT_VERSION);
- if(centerMachineDto != null)
+ if (centerMachineDto != null)
queryParams.put("regcenterId", centerMachineDto.getCenterId());
String delta = this.globalParamRepository.getGlobalParamValue(MASTER_DATA_LAST_UPDATED);
- if(delta != null)
+ if (delta != null)
queryParams.put("lastUpdated", delta);
Call> call = syncRestService.fetchMasterDate(queryParams);
@@ -178,16 +185,14 @@ public void syncMasterData() throws Exception {
call.enqueue(new Callback>() {
@Override
public void onResponse(Call> call, Response> response) {
- if(response.isSuccessful()) {
+ if (response.isSuccessful()) {
ServiceError error = SyncRestUtil.getServiceError(response.body());
- if(error == null) {
+ if (error == null) {
saveMasterData(response.body().getResponse());
Toast.makeText(context, "Master Data Sync Completed", Toast.LENGTH_LONG).show();
- }
- else
+ } else
Toast.makeText(context, "Master Data Sync failed " + error.getMessage(), Toast.LENGTH_LONG).show();
- }
- else
+ } else
Toast.makeText(context, "Master Data Sync failed with status code : " + response.code(), Toast.LENGTH_LONG).show();
}
@@ -206,18 +211,18 @@ public void syncLatestIdSchema() throws Exception {
@Override
public void onResponse(Call call,
Response response) {
- if(response.isSuccessful()) {
+ if (response.isSuccessful()) {
try {
ResponseWrapper wrapper = JsonUtils.jsonStringToJavaObject(response.body().string(),
- new TypeReference>() {});
+ new TypeReference>() {
+ });
identitySchemaRepository.saveIdentitySchema(context, wrapper.getResponse());
Toast.makeText(context, "Identity schema and UI Spec Sync Completed", Toast.LENGTH_LONG).show();
} catch (Exception e) {
Log.e(TAG, "Failed to save IDSchema", e);
}
- }
- else
+ } else
Toast.makeText(context, "Identity schema and UI Spec Sync failed with status code : " +
response.code(), Toast.LENGTH_LONG).show();
}
@@ -236,16 +241,14 @@ public void syncUserDetails() throws Exception {
call.enqueue(new Callback>() {
@Override
public void onResponse(Call> call, Response> response) {
- if(response.isSuccessful()) {
+ if (response.isSuccessful()) {
ServiceError error = SyncRestUtil.getServiceError(response.body());
- if(error == null) {
+ if (error == null) {
saveUserDetails(response.body().getResponse().getUserDetails());
Toast.makeText(context, "User Sync Completed", Toast.LENGTH_LONG).show();
- }
- else
+ } else
Toast.makeText(context, "User Sync failed " + error.getMessage(), Toast.LENGTH_LONG).show();
- }
- else
+ } else
Toast.makeText(context, "User Sync failed with status code : " + response.code(), Toast.LENGTH_LONG).show();
}
@@ -271,13 +274,13 @@ public Integer getHierarchyLevel(String hierarchyLevelName) {
private void saveMasterData(ClientSettingDto clientSettingDto) {
boolean foundErrors = false;
- for(MasterData masterData : clientSettingDto.getDataToSync()) {
+ for (MasterData masterData : clientSettingDto.getDataToSync()) {
try {
- switch(masterData.getEntityType()) {
- case "structured" :
+ switch (masterData.getEntityType()) {
+ case "structured":
saveStructuredData(masterData.getEntityName(), masterData.getData());
break;
- case "dynamic" :
+ case "dynamic":
saveDynamicData(masterData.getData());
}
} catch (Throwable e) {
@@ -286,7 +289,7 @@ private void saveMasterData(ClientSettingDto clientSettingDto) {
}
}
- if(!foundErrors) {
+ if (!foundErrors) {
Log.i(TAG, "Masterdata lastSyncTime : " + clientSettingDto.getLastSyncTime());
this.globalParamRepository.saveGlobalParam(MASTER_DATA_LAST_UPDATED, clientSettingDto.getLastSyncTime());
}
@@ -307,52 +310,58 @@ private void saveStructuredData(String entityName, String data) throws JSONExcep
break;
case "RegistrationCenter":
JSONArray centers = getDecryptedDataList(data);
- for(int i =0 ;i < centers.length(); i++) {
+ for (int i = 0; i < centers.length(); i++) {
registrationCenterRepository.saveRegistrationCenter(centers.getJSONObject(i));
}
break;
case "DocumentType":
JSONArray doctypes = getDecryptedDataList(data);
- for(int i =0 ;i < doctypes.length(); i++) {
+ for (int i = 0; i < doctypes.length(); i++) {
documentTypeRepository.saveDocumentType(doctypes.getJSONObject(i));
}
break;
case "ApplicantValidDocument":
JSONArray appValidDocs = getDecryptedDataList(data);
- for(int i =0 ;i < appValidDocs.length(); i++) {
+ for (int i = 0; i < appValidDocs.length(); i++) {
applicantValidDocRepository.saveApplicantValidDocument(appValidDocs.getJSONObject(i));
}
break;
case "Template":
JSONArray templates = getDecryptedDataList(data);
- for(int i =0 ;i < templates.length(); i++) {
+ for (int i = 0; i < templates.length(); i++) {
templateRepository.saveTemplate(templates.getJSONObject(i));
}
break;
case "Location":
JSONArray locations = getDecryptedDataList(data);
- for(int i =0 ;i < locations.length(); i++) {
+ for (int i = 0; i < locations.length(); i++) {
locationRepository.saveLocationData(locations.getJSONObject(i));
}
break;
case "LocationHierarchy":
JSONArray locationHierarchies = getDecryptedDataList(data);
- for(int i =0 ;i < locationHierarchies.length(); i++) {
+ for (int i = 0; i < locationHierarchies.length(); i++) {
locationRepository.saveLocationHierarchyData(locationHierarchies.getJSONObject(i));
}
break;
- case "BlocklistedWords" :
+ case "BlocklistedWords":
JSONArray words = getDecryptedDataList(data);
- for(int i =0 ;i < words.length(); i++) {
+ for (int i = 0; i < words.length(); i++) {
blocklistedWordRepository.saveBlocklistedWord(words.getJSONObject(i));
}
break;
+ case "SyncJobDef":
+ JSONArray syncJobDefsJsonArray = getDecryptedDataList(data);
+ for (int i = 0; i < syncJobDefsJsonArray.length(); i++) {
+ syncJobDefRepository.saveSyncJobDef(syncJobDefsJsonArray.getJSONObject(i));
+ }
+ break;
}
}
private void saveDynamicData(String data) throws JSONException {
JSONArray list = getDecryptedDataList(data);
- for(int i =0 ;i < list.length(); i++) {
+ for (int i = 0; i < list.length(); i++) {
dynamicFieldRepository.saveDynamicField(list.getJSONObject(i));
}
}
@@ -386,7 +395,7 @@ public List findLocationByParentHierarchyCode(String parentCode, String
@Override
public List findLocationByHierarchyLevel(String hierarchyLevelName, String langCode) {
Integer level = getHierarchyLevel(hierarchyLevelName);
- if(level == null)
+ if (level == null)
return Collections.EMPTY_LIST;
return this.locationRepository.getLocationsBasedOnHierarchyLevel(level, langCode);
}
diff --git a/client/clientmanager/src/main/java/io/mosip/registration/clientmanager/service/PacketServiceImpl.java b/client/clientmanager/src/main/java/io/mosip/registration/clientmanager/service/PacketServiceImpl.java
index 8c12bdde5..c7fa0a68a 100644
--- a/client/clientmanager/src/main/java/io/mosip/registration/clientmanager/service/PacketServiceImpl.java
+++ b/client/clientmanager/src/main/java/io/mosip/registration/clientmanager/service/PacketServiceImpl.java
@@ -3,12 +3,21 @@
import android.content.Context;
import android.util.Log;
import android.widget.Toast;
+
import io.mosip.registration.clientmanager.constant.PacketClientStatus;
import io.mosip.registration.clientmanager.constant.PacketServerStatus;
+import io.mosip.registration.clientmanager.constant.RegistrationConstants;
import io.mosip.registration.clientmanager.dto.CenterMachineDto;
+import io.mosip.registration.clientmanager.dto.Error;
+import io.mosip.registration.clientmanager.dto.PacketIdDto;
+import io.mosip.registration.clientmanager.dto.PacketStatusDto;
+import io.mosip.registration.clientmanager.dto.PacketStatusRequest;
+import io.mosip.registration.clientmanager.dto.PacketStatusResponse;
import io.mosip.registration.clientmanager.dto.http.*;
import io.mosip.registration.clientmanager.entity.Registration;
+import io.mosip.registration.clientmanager.entity.SyncJobDef;
import io.mosip.registration.clientmanager.repository.RegistrationRepository;
+import io.mosip.registration.clientmanager.repository.SyncJobDefRepository;
import io.mosip.registration.clientmanager.spi.MasterDataService;
import io.mosip.registration.clientmanager.spi.PacketService;
import io.mosip.registration.clientmanager.spi.SyncRestService;
@@ -22,13 +31,16 @@
import okhttp3.MediaType;
import okhttp3.MultipartBody;
import okhttp3.RequestBody;
+
import org.json.JSONObject;
+
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import javax.inject.Inject;
import javax.inject.Singleton;
+
import java.io.File;
import java.io.FileInputStream;
import java.math.BigInteger;
@@ -53,16 +65,18 @@ public class PacketServiceImpl implements PacketService {
private Context context;
private RegistrationRepository registrationRepository;
+ private SyncJobDefRepository syncJobDefRepository;
private IPacketCryptoService packetCryptoService;
private SyncRestService syncRestService;
private MasterDataService masterDataService;
@Inject
- public PacketServiceImpl(Context context, RegistrationRepository registrationRepository,
+ public PacketServiceImpl(Context context, RegistrationRepository registrationRepository, SyncJobDefRepository syncJobDefRepository,
IPacketCryptoService packetCryptoService, SyncRestService syncRestService,
MasterDataService masterDataService) {
this.context = context;
this.registrationRepository = registrationRepository;
+ this.syncJobDefRepository = syncJobDefRepository;
this.packetCryptoService = packetCryptoService;
this.syncRestService = syncRestService;
this.masterDataService = masterDataService;
@@ -74,7 +88,7 @@ public void syncRegistration(@NonNull String packetId) throws Exception {
Registration registration = registrationRepository.getRegistration(packetId);
- if(registration.getClientStatus() != null && !PACKET_UNSYNCED_STATUS.contains(registration.getClientStatus())) {
+ if (registration.getClientStatus() != null && !PACKET_UNSYNCED_STATUS.contains(registration.getClientStatus())) {
Log.i(TAG, "Packet already synced >> " + registration.getClientStatus());
Toast.makeText(context, "Packet already synced", Toast.LENGTH_LONG).show();
return;
@@ -119,16 +133,14 @@ public void syncRegistration(@NonNull String packetId) throws Exception {
@Override
public void onResponse(Call>> call,
Response>> response) {
- if(response.isSuccessful()) {
+ if (response.isSuccessful()) {
ServiceError error = SyncRestUtil.getServiceError(response.body());
- if(error == null && response.body().getResponse().get(0).getStatus().equalsIgnoreCase("SUCCESS")) {
+ if (error == null && response.body().getResponse().get(0).getStatus().equalsIgnoreCase("SUCCESS")) {
registrationRepository.updateStatus(packetId, null, PacketClientStatus.SYNCED.name());
Toast.makeText(context, "Packet synced successfully", Toast.LENGTH_LONG).show();
- }
- else
+ } else
Toast.makeText(context, "Packet sync failed : " + error.getMessage(), Toast.LENGTH_LONG).show();
- }
- else
+ } else
Toast.makeText(context, "Packet sync failed with Status Code : " + response.code(), Toast.LENGTH_LONG).show();
}
@@ -144,7 +156,7 @@ public void onFailure(Call>> call,
public void uploadRegistration(String packetId) {
Registration registration = registrationRepository.getRegistration(packetId);
- if(registration.getServerStatus() != null && !PACKET_UPLOAD_STATUS.contains(registration.getServerStatus())) {
+ if (registration.getServerStatus() != null && !PACKET_UPLOAD_STATUS.contains(registration.getServerStatus())) {
Log.i(TAG, "Packet already uploaded >> " + registration.getClientStatus());
Toast.makeText(context, "Packet already uploaded", Toast.LENGTH_LONG).show();
return;
@@ -158,17 +170,15 @@ public void uploadRegistration(String packetId) {
call.enqueue(new Callback>() {
@Override
public void onResponse(Call> call, Response> response) {
- if(response.isSuccessful()) {
+ if (response.isSuccessful()) {
ServiceError error = SyncRestUtil.getServiceError(response.body());
- if(error == null) {
+ if (error == null) {
registrationRepository.updateStatus(packetId, response.body().getResponse().getStatus(),
PacketClientStatus.UPLOADED.name());
Toast.makeText(context, "Packet uploaded successfully", Toast.LENGTH_LONG).show();
- }
- else
+ } else
Toast.makeText(context, "Packet uploaded failed : " + error.getMessage(), Toast.LENGTH_LONG).show();
- }
- else
+ } else
Toast.makeText(context, "Packet uploaded failed with Status Code : " + response.code(), Toast.LENGTH_LONG).show();
}
@@ -184,4 +194,63 @@ public void onFailure(Call> call, Throwab
public List getAllRegistrations(int page, int pageLimit) {
return this.registrationRepository.getAllRegistrations();
}
+
+ @Override
+ public List getAllSyncJobDefList() {
+ return this.syncJobDefRepository.getAllSyncJobDefList();
+ }
+
+ @Override
+ public void syncAllPacketStatus() {
+ List registrations = this.registrationRepository.getAllRegistrations();
+
+ if (registrations == null || registrations.size() == 0)
+ return;
+
+ PacketStatusRequest packetStatusRequest = new PacketStatusRequest();
+ packetStatusRequest.setId(RegistrationConstants.PACKET_EXTERNAL_STATUS_READER_ID);
+ packetStatusRequest.setVersion(RegistrationConstants.PACKET_SYNC_VERSION);
+ packetStatusRequest.setRequesttime(DateUtils.formatToISOString(LocalDateTime.now(ZoneOffset.UTC)));
+
+ List packets = new ArrayList<>();
+
+ for (Registration reg : registrations) {
+ packets.add(new PacketIdDto(reg.getPacketId()));
+ }
+
+ packetStatusRequest.setRequest(packets);
+
+ Call call = this.syncRestService.getPacketStatus(packetStatusRequest);
+ call.enqueue(new Callback() {
+ @Override
+ public void onResponse(Call call, Response response) {
+ if (response.isSuccessful()) {
+ List error = response.body().getErrors();
+
+ if (error == null || error.size() == 0 || error.get(0).getErrorCode() == null) {
+ List packetStatusList = response.body().getResponse();
+
+ for (PacketStatusDto packetStatus : packetStatusList) {
+ PacketStatusUpdateDto updateDto = new PacketStatusUpdateDto(packetStatus.getPacketId(), packetStatus.getStatusCode());
+
+ registrationRepository.updateStatus(updateDto.getRegistrationId(), updateDto.getStatusCode(),
+ PacketClientStatus.UPLOADED.name());
+ }
+
+ Toast.makeText(context, "Packet status sync completed", Toast.LENGTH_LONG).show();
+ } else {
+ Toast.makeText(context, "Packet status sync failed : " + error.get(0).getErrorMessage(), Toast.LENGTH_LONG).show();
+ }
+ } else {
+ Toast.makeText(context, "Packet status sync failed with status code : " + response.code(), Toast.LENGTH_LONG).show();
+ }
+ }
+
+ @Override
+ public void onFailure(Call call, Throwable t) {
+ Log.e(TAG, "Packet status sync failed", t);
+ Toast.makeText(context, "Packet status sync failed", Toast.LENGTH_LONG).show();
+ }
+ });
+ }
}
diff --git a/client/clientmanager/src/main/java/io/mosip/registration/clientmanager/spi/PacketService.java b/client/clientmanager/src/main/java/io/mosip/registration/clientmanager/spi/PacketService.java
index 798cd40d6..77dc71953 100644
--- a/client/clientmanager/src/main/java/io/mosip/registration/clientmanager/spi/PacketService.java
+++ b/client/clientmanager/src/main/java/io/mosip/registration/clientmanager/spi/PacketService.java
@@ -1,6 +1,7 @@
package io.mosip.registration.clientmanager.spi;
import io.mosip.registration.clientmanager.entity.Registration;
+import io.mosip.registration.clientmanager.entity.SyncJobDef;
import java.util.List;
@@ -28,4 +29,15 @@ public interface PacketService {
*/
List getAllRegistrations(int page, int pageLimit);
+ /**
+ *
+ * @return
+ */
+ List getAllSyncJobDefList();
+
+ /**
+ *
+ * @return
+ */
+ void syncAllPacketStatus();
}
diff --git a/client/clientmanager/src/main/java/io/mosip/registration/clientmanager/spi/SyncRestService.java b/client/clientmanager/src/main/java/io/mosip/registration/clientmanager/spi/SyncRestService.java
index 6dec82979..467671fcd 100644
--- a/client/clientmanager/src/main/java/io/mosip/registration/clientmanager/spi/SyncRestService.java
+++ b/client/clientmanager/src/main/java/io/mosip/registration/clientmanager/spi/SyncRestService.java
@@ -1,5 +1,11 @@
package io.mosip.registration.clientmanager.spi;
+import org.json.JSONObject;
+
+import io.mosip.registration.clientmanager.dto.PacketIdDto;
+import io.mosip.registration.clientmanager.dto.PacketStatusDto;
+import io.mosip.registration.clientmanager.dto.PacketStatusRequest;
+import io.mosip.registration.clientmanager.dto.PacketStatusResponse;
import io.mosip.registration.clientmanager.dto.http.*;
import okhttp3.MultipartBody;
import okhttp3.ResponseBody;
@@ -19,7 +25,7 @@ public interface SyncRestService {
@GET("/v1/syncdata/getCertificate")
Call> getCertificate(@Query("applicationId") String applicationId,
- @Query("referenceId") String referenceId);
+ @Query("referenceId") String referenceId);
@GET("/v1/syncdata/latestidschema")
Call getLatestIdSchema();
@@ -28,15 +34,16 @@ Call> getCertificate(@Query("applicationId"
Call> fetchCenterUserDetails(@Query("keyindex") String keyIndex);
@POST("/registrationprocessor/v1/registrationstatus/syncV2")
- Call>> syncRID(@Header ("timestamp") String timestamp,
- @Header ("Center-Machine-RefId") String refId,
- @Body String encryptedData);
-
+ Call>> syncRID(@Header("timestamp") String timestamp,
+ @Header("Center-Machine-RefId") String refId,
+ @Body String encryptedData);
@Multipart
@POST("/registrationprocessor/v1/packetreceiver/registrationpackets")
Call> uploadPacket(@Part MultipartBody.Part filePart);
+ //https://dev.mosip.net/v1/admin/packetstatusupdate?rid=asdf&langCode=eng
-
+ @POST("/registrationprocessor/v1/registrationstatus/packetexternalstatus")
+ Call getPacketStatus(@Body PacketStatusRequest packetStatusRequestDto);
}