Skip to content

Commit

Permalink
Merge pull request #232 from tw-mosip/injiweb-570-render-avl-fields-i…
Browse files Browse the repository at this point in the history
…n-pdf

[INJIWEB-570]: render only the fields that has values in the PDF template
  • Loading branch information
vijay151096 authored May 31, 2024
2 parents 6022894 + 3206c79 commit fd0782a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import lombok.Data;

import java.util.List;
import java.util.Set;

@Data
public class CredentialsSupportedResponse {
Expand All @@ -21,5 +22,5 @@ public class CredentialsSupportedResponse {
private CredentialDefinitionResponseDto credentialDefinition;

private List<CredentialSupportedDisplayResponse> display;
private List<String> order;
private Set<String> order;
}
20 changes: 8 additions & 12 deletions src/main/java/io/mosip/mimoto/service/impl/IssuersServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,7 @@
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.StringWriter;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Properties;
import java.util.*;
import java.util.stream.Collectors;

@Service
Expand Down Expand Up @@ -167,12 +162,13 @@ public ByteArrayInputStream generatePdfForVerifiableCredentials(String accessTok
if (vcCredentialResponse == null) throw new RuntimeException("VC Credential Issue API not accessible");
Map<String, Object> credentialProperties = vcCredentialResponse.getCredential().getCredentialSubject();
LinkedHashMap<String,Object> displayProperties = new LinkedHashMap<>();
List<String> orderProperty = credentialsSupportedResponse.getOrder();
if(orderProperty == null) {
vcPropertiesFromWellKnown.keySet().forEach(vcProperty -> displayProperties.put(vcPropertiesFromWellKnown.get(vcProperty), credentialProperties.get(vcProperty)));
} else {
orderProperty.forEach(vcProperty -> displayProperties.put(vcPropertiesFromWellKnown.get(vcProperty), credentialProperties.get(vcProperty)));
}
Set<String> orderProperty = credentialsSupportedResponse.getOrder();
Set<String> fieldProperty = orderProperty != null ? orderProperty : vcPropertiesFromWellKnown.keySet();
fieldProperty.forEach(vcProperty -> {
if(credentialProperties.get(vcProperty) != null && !"".equals(credentialProperties.get(vcProperty))) {
displayProperties.put(vcPropertiesFromWellKnown.get(vcProperty), credentialProperties.get(vcProperty));
}
});
return getPdfResourceFromVcProperties(displayProperties, credentialsSupportedResponse, vcCredentialResponse,
issuerDTO.getDisplay().stream().map(d -> d.getLogo().getUrl()).findFirst().orElse(""));
}
Expand Down

0 comments on commit fd0782a

Please sign in to comment.