This page provides the steps to integrate with the IDGen Service. Each application needs to have a unique ID. The IDGen service generates these unique IDs. ID format can be customised via configuration in MDMS.
Copy {
"format": "PB-BTR-[cy:yyyy-MM-dd]-[SEQ_EG_BTR_ID]",
"idname": "btr.registrationid"
}
Copy kubectl port-forward <IDGEN_SERVICE_POD_NAME> 8285:8080
Copy curl --location --request POST 'http://localhost:8285/egov-idgen/id/_generate' \
--header 'Content-Type: application/json' \
--data-raw '{
"RequestInfo": {
"apiId": "string",
"ver": "string",
"ts": null,
"action": "string",
"did": "string",
"key": "string",
"msgId": "string",
"authToken": "6456b2cf-49ca-47c7-b7b6-c179f19614c7",
"correlationId": "e721639b-c095-40b3-86e2-acecb2cb6efb",
"userInfo": {
"id": 23299,
"uuid": "e721639b-c095-40b3-86e2-acecb2cb6efb",
"userName": "9337682030",
"name": "Abhilash Seth",
"type": "EMPLOYEE",
"mobileNumber": "9337682030",
"emailId": "abhilash.seth@gmail.com",
"roles": [
{
"id": 281,
"name": "Employee"
}
]
}
},
"idRequests": [
{
"tenantId": "pb.amritsar",
"idName": "btr.registrationid"
}
]
}'
Copy package digit . web . models ;
import com . fasterxml . jackson . annotation . JsonProperty ;
import lombok . AllArgsConstructor ;
import lombok . Builder ;
import lombok . Data ;
import lombok . NoArgsConstructor ;
import org . egov . common . contract . request . RequestInfo ;
import java . util . List ;
@ Data
@ AllArgsConstructor
@ NoArgsConstructor
@ Builder
public class IdGenerationRequest {
@ JsonProperty ( "RequestInfo" )
private RequestInfo requestInfo;
private List < IdRequest > idRequests;
}
Copy package digit . web . models ;
import lombok . AllArgsConstructor ;
import lombok . Builder ;
import lombok . Data ;
import lombok . NoArgsConstructor ;
import org . egov . common . contract . response . ResponseInfo ;
import java . util . List ;
@ Data
@ AllArgsConstructor
@ NoArgsConstructor
@ Builder
public class IdGenerationResponse {
private ResponseInfo responseInfo;
private List < IdResponse > idResponses;
}
Copy package digit . web . models ;
import com . fasterxml . jackson . annotation . JsonProperty ;
import lombok . AllArgsConstructor ;
import lombok . Builder ;
import lombok . Data ;
import lombok . NoArgsConstructor ;
import javax . validation . constraints . NotNull ;
@ Data
@ AllArgsConstructor
@ NoArgsConstructor
@ Builder
public class IdRequest {
@ JsonProperty ( "idName" )
@ NotNull
private String idName;
@ NotNull
@ JsonProperty ( "tenantId" )
private String tenantId;
@ JsonProperty ( "format" )
private String format;
}
Copy package digit . web . models ;
import lombok . AllArgsConstructor ;
import lombok . Builder ;
import lombok . Data ;
import lombok . NoArgsConstructor ;
@ Data
@ AllArgsConstructor
@ NoArgsConstructor
@ Builder
public class IdResponse {
private String id;
}
Copy public void enrichBirthApplication( BirthRegistrationRequest birthRegistrationRequest) {
//Retrieve list of IDs from IDGen service
List<String> birthRegistrationIdList = idgenUtil.getIdList(birthRegistrationRequest.getRequestInfo(), birthRegistrationRequest.getBirthRegistrationApplications().get(0).getTenantId(), "btr.registrationid", "", birthRegistrationRequest.getBirthRegistrationApplications().size());
Integer index = 0 ;
for ( BirthRegistrationApplication application : birthRegistrationRequest . getBirthRegistrationApplications ()) {
// Enrich audit details
AuditDetails auditDetails = AuditDetails.builder().createdBy(birthRegistrationRequest.getRequestInfo().getUserInfo().getUuid()).createdTime(System.currentTimeMillis()).lastModifiedBy(birthRegistrationRequest.getRequestInfo().getUserInfo().getUuid()).lastModifiedTime(System.currentTimeMillis()).build();
application . setAuditDetails (auditDetails);
// Enrich UUID
application . setId ( UUID . randomUUID () . toString ());
// Set application number from IdGen
application . setApplicationNumber ( birthRegistrationIdList . get (index ++ ));
// Enrich registration Id
application . getAddress () . setRegistrationId ( application . getId ());
// Enrich address UUID
application . getAddress () . setId ( UUID . randomUUID () . toString ());
}
}
Copy #Idgen Config
egov.idgen.host= http://localhost:8285/ #REPLACE
egov.idgen.path= egov-idgen/id/_generate