@@ -42,22 +42,25 @@ public PulseResponseCreateDTO get(
4242 final Map <String , Object > values =
4343 (Map <String , Object >)state .get ("values" );
4444
45+ dumpMap (values , "" );
46+
4547 // Create the pulse DTO and fill in the values.
4648 PulseResponseCreateDTO response = new PulseResponseCreateDTO ();
4749 response .setTeamMemberId (lookupUser (memberProfileServices , map ));
4850 response .setSubmissionDate (LocalDate .now ());
4951
50- response .setInternalScore (Integer .parseInt (
51- getMappedValue ( values , "internalScore" , true )));
52- response .setInternalFeelings (
53- getMappedValue ( values , "internalFeelings" , false ));
52+ response .setInternalScore (Integer .parseInt (getMappedValue (
53+ values , "internalNumber" , "internalScore" , true )));
54+ response .setInternalFeelings (getMappedValue (
55+ values , "internaltext" , "internalFeelings" , false ));
5456
55- String score = getMappedValue (values , "externalScore" , false );
57+ String score = getMappedValue (values , "externalScore" ,
58+ "externalScore" , false );
5659 if (!score .isEmpty ()) {
5760 response .setExternalScore (Integer .parseInt (score ));
5861 }
59- response .setExternalFeelings (
60- getMappedValue ( values , "externalFeelings" , false ));
62+ response .setExternalFeelings (getMappedValue (
63+ values , "externalText" , "externalFeelings" , false ));
6164
6265 return response ;
6366 } catch (JsonProcessingException ex ) {
@@ -69,20 +72,32 @@ public PulseResponseCreateDTO get(
6972 }
7073 }
7174
72- private String getMappedValue (Map <String , Object > map ,
75+ private String getMappedValue (Map <String , Object > map , String blockId ,
7376 String key , boolean required ) {
77+ if (!map .containsKey (blockId )) {
78+ if (required ) {
79+ throw new BadArgException (
80+ String .format ("Block ID - %s was not found" , blockId ));
81+ } else {
82+ return "" ;
83+ }
84+ }
85+ Map <String , Object > blockMap = (Map <String , Object >)map .get (blockId );
86+
7487 final String valueKey = "value" ;
75- if (map .containsKey (key )) {
76- final Map <String , Object > other = (Map <String , Object >)map .get (key );
88+ if (blockMap .containsKey (key )) {
89+ final Map <String , Object > other =
90+ (Map <String , Object >)blockMap .get (key );
7791 if (other .containsKey (valueKey )) {
7892 return (String )other .get (valueKey );
7993 }
8094 }
8195
8296 if (required ) {
83- LOG .error ("Expected {}.{} was not found" , key , valueKey );
97+ LOG .error ("Expected {}.{}.{} was not found" , blockId , key , valueKey );
8498 throw new BadArgException (
85- String .format ("Expected %s.%s was not found" , key , valueKey ));
99+ String .format ("Expected %s.%s.%s was not found" ,
100+ blockId , key , valueKey ));
86101 } else {
87102 return "" ;
88103 }
@@ -101,4 +116,15 @@ private UUID lookupUser(MemberProfileServices memberProfileServices,
101116 MemberProfile member = memberProfileServices .findByWorkEmail (email );
102117 return member .getId ();
103118 }
119+
120+ // DEBUG Only
121+ private void dumpMap (Map <?, ?> map , String indent ) {
122+ for (Map .Entry <?, ?> entry : map .entrySet ()) {
123+ LOG .info (indent + entry .getKey () + " : " + entry .getValue ());
124+
125+ if (entry .getValue () instanceof Map ) {
126+ dumpMap ((Map <?, ?>) entry .getValue (), indent + " " );
127+ }
128+ }
129+ }
104130}
0 commit comments