io.mosip.kernel.packetmanager.dto.PacketInfoDto Maven / Gradle / Ivy
package io.mosip.kernel.packetmanager.dto;
import io.mosip.kernel.core.util.DateUtils;
import io.mosip.kernel.packetmanager.constants.PacketManagerConstants;
import io.mosip.kernel.packetmanager.datatype.BiometricsType;
import io.mosip.kernel.packetmanager.datatype.DocumentType;
import io.mosip.kernel.packetmanager.datatype.SimpleType;
import io.mosip.kernel.packetmanager.dto.metadata.BiometricsException;
import io.mosip.kernel.packetmanager.dto.metadata.DeviceMetaInfo;
import io.mosip.kernel.packetmanager.dto.metadata.FieldValue;
import lombok.Data;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Data
public class PacketInfoDto {
private String registrationId;
private double idSchemaVersion;
private String creationDate;
private Map demographics;
private Map documents;
private Map> biometrics;
private Map> exceptionBiometrics;
private List metaData;
private List operationsData;
private List capturedRegisteredDevices;
private List capturedNonRegisteredDevices;
private List checkSum;
private List printingName;
private List officerBiometrics;
private List supervisorBiometrics;
private List audits;
private byte[] acknowledgeReceipt;
private String acknowledgeReceiptName;
public PacketInfoDto() {
this.creationDate = DateUtils.formatToISOString(LocalDateTime.now());
this.demographics = new HashMap();
this.documents = new HashMap();
this.biometrics = new HashMap>();
this.exceptionBiometrics = new HashMap>();
this.metaData = new ArrayList();
this.operationsData = new ArrayList();
this.checkSum = new ArrayList();
this.printingName = new ArrayList();
}
public void setField(String fieldName, Object value) {
this.demographics.put(fieldName, value);
}
public void setField(String fieldName, List value) {
List list = new ArrayList();
for(SimpleDto dto : value) {
list.add(new SimpleType(dto.getLanguage(), dto.getValue()));
}
this.demographics.put(fieldName, list);
}
public void setBiometricField(String fieldName, List list) {
this.biometrics.put(fieldName, list);
}
public void setDocumentField(String fieldName, DocumentDto dto) {
this.documents.put(fieldName, dto);
}
public void setExceptionBiometrics(String fieldName, List exceptionList) {
this.exceptionBiometrics.put(fieldName, exceptionList);
}
public void setMetaData(String label, String value) {
if(!this.metaData.contains(new FieldValue(label, value)))
this.metaData.add(new FieldValue(label, value));
}
public void setMetaData(FieldValue fieldValue) {
if(!this.metaData.contains(fieldValue))
this.metaData.add(fieldValue);
}
public void setOperationsData(String key, String value) {
if(!this.operationsData.contains(new FieldValue(key, value)))
this.operationsData.add(new FieldValue(key, value));
}
public void setChecksum(String key, String value) {
if(!this.checkSum.contains(new FieldValue(key, value)))
this.checkSum.add(new FieldValue(key, value));
}
public void setPrintingName(String language, String value) {
this.getPrintingName().add(new SimpleType(language, value));
}
public Map getIdentityObject() {
Map identityData = new HashMap();
identityData.put(PacketManagerConstants.IDSCHEMA_VERSION, idSchemaVersion);
identityData.putAll(this.demographics);
this.documents.forEach((k, v) ->{
Map data = new HashMap<>();
data.put("value", k);
data.put("type", v.getType());
data.put("format", v.getFormat());
identityData.put(k, data);
});
this.biometrics.forEach((k, v) -> {
Map data = new HashMap<>();
data.put("value", String.format(PacketManagerConstants.CBEFF_FILENAME, k));
data.put("version", PacketManagerConstants.CBEFF_VERSION);
data.put("format", PacketManagerConstants.CBEFF_FILE_FORMAT);
identityData.put(k, data);
});
Map idObject = new HashMap();
idObject.put(PacketManagerConstants.IDENTITY, identityData);
return idObject;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy