Skip to content

Commit

Permalink
Tf dev sp2 (#18)
Browse files Browse the repository at this point in the history
* nin handle

* update_nin
  • Loading branch information
Karthik-TF committed Sep 19, 2024
1 parent 4e95bb9 commit 9cf7cb2
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import io.mosip.registration.controller.GenericController;
import io.mosip.registration.dto.schema.ProcessSpecDto;
import io.mosip.registration.dto.schema.UiFieldDTO;
import io.mosip.registration.util.common.NinValidator;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
Expand Down Expand Up @@ -101,6 +102,8 @@ public class UpdateUINController extends BaseController implements Initializable
@FXML
private RadioButton updateCheckbox;

@Autowired
private NinValidator ninValidator;
/*
* (non-Javadoc)
*
Expand Down Expand Up @@ -289,8 +292,8 @@ public void submitUINUpdate(ActionEvent event) {
return;
}

if (uinValidatorImpl.validateId(uinId.getText()) && !selectedFieldGroups.isEmpty()) {
getRegistrationDTOFromSession().addDemographicField("UIN", uinId.getText());
if (ninValidator.validate(uinId.getText()) && !selectedFieldGroups.isEmpty()) {
getRegistrationDTOFromSession().addDemographicField("NIN", uinId.getText());
getRegistrationDTOFromSession().setUpdatableFieldGroups(selectedFieldGroups);
getRegistrationDTOFromSession().setUpdatableFields(new ArrayList<>());
getRegistrationDTOFromSession().setBiometricMarkedForUpdate(selectedFieldGroups.contains(RegistrationConstants.BIOMETRICS_GROUP) ? true : false);
Expand All @@ -305,7 +308,8 @@ public void submitUINUpdate(ActionEvent event) {
}
} catch (InvalidIDException invalidIdException) {
LOGGER.error(invalidIdException.getMessage(), invalidIdException);
generateAlert(RegistrationConstants.ERROR, RegistrationUIConstants.getMessageLanguageSpecific(RegistrationUIConstants.UPDATE_UIN_VALIDATION_ALERT));
//generateAlert(RegistrationConstants.ERROR, RegistrationUIConstants.getMessageLanguageSpecific(RegistrationUIConstants.UPDATE_UIN_VALIDATION_ALERT));
generateAlert(RegistrationConstants.ERROR, "Please Enter a Valid NIN ID");
} catch (Throwable exception) {
LOGGER.error(exception.getMessage(), exception);
generateAlert(RegistrationConstants.ERROR, RegistrationUIConstants.getMessageLanguageSpecific(RegistrationUIConstants.UNABLE_LOAD_REG_PAGE));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package io.mosip.registration.util.common;

import org.springframework.stereotype.Component;

import io.mosip.kernel.core.idvalidator.exception.InvalidIDException;

import java.util.regex.Matcher;
import java.util.regex.Pattern;
/*
kar Nin validator for validating with new regex pattern of nin
*/
@Component
public class NinValidator {
public boolean validate(String input) {
String regexPattern = "^[a-zA-Z0-9]{14,14}$";
Pattern pattern = Pattern.compile(regexPattern);
Matcher matcher = pattern.matcher(input);
if(matcher.matches()) {
return true;
}
else {
throw new InvalidIDException("NIN 1","Enter a Valid NIN");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ private void setDemographics(RegistrationDTO registrationDTO) throws RegBaseChec
switch (registrationDTO.getFlowType()) {
case UPDATE:
if (demographics.get(fieldName) != null && (registrationDTO.getUpdatableFields().contains(fieldName) ||
fieldName.equals("UIN")))
fieldName.equals("NIN")))
setField(registrationDTO.getRegistrationId(), fieldName, demographics.get(fieldName),
registrationDTO.getProcessId().toUpperCase(), source);
break;
Expand Down

0 comments on commit 9cf7cb2

Please sign in to comment.