Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AUT-1760 Refresh dashboard claims table content dynamically
- Loading branch information
Showing
5 changed files
with
61 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
src/main/java/ee/ria/govsso/client/util/DemoResponseUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package ee.ria.govsso.client.util; | ||
|
||
import lombok.experimental.UtilityClass; | ||
|
||
import java.util.Date; | ||
import java.util.Map; | ||
import java.util.SortedMap; | ||
import java.util.TreeMap; | ||
|
||
@UtilityClass | ||
public class DemoResponseUtil { | ||
|
||
public Map<String, String> flattenClaims(Map<?, ?> claims) { | ||
SortedMap<String, String> flatClaims = new TreeMap<>(); | ||
for (Map.Entry<?, ?> claim : claims.entrySet()) { | ||
java.lang.String key = claim.getKey().toString(); | ||
Object value = claim.getValue(); | ||
if (value instanceof Map<?, ?> innerClaims) { | ||
Map<java.lang.String, java.lang.String> flattenedInnerClaims = flattenClaims(innerClaims); | ||
for (Map.Entry<java.lang.String, java.lang.String> innerClaim : flattenedInnerClaims.entrySet()) { | ||
flatClaims.put(key + "." + innerClaim.getKey(), innerClaim.getValue()); | ||
} | ||
continue; | ||
} | ||
flatClaims.put(key, renderClaimValue(value)); | ||
} | ||
return flatClaims; | ||
} | ||
|
||
private static String renderClaimValue(Object value) { | ||
if (value instanceof Date date) { | ||
return date.toInstant().toString(); | ||
} | ||
return value.toString(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters