| Line 1... |
Line 1... |
| 1 |
package com.spice.profitmandi.web.config;
|
1 |
package com.spice.profitmandi.web.config;
|
| 2 |
|
2 |
|
| - |
|
3 |
import com.fasterxml.jackson.core.JsonParser;
|
| - |
|
4 |
import com.fasterxml.jackson.databind.DeserializationContext;
|
| 3 |
import com.fasterxml.jackson.databind.DeserializationFeature;
|
5 |
import com.fasterxml.jackson.databind.DeserializationFeature;
|
| 4 |
import com.fasterxml.jackson.databind.ObjectMapper;
|
6 |
import com.fasterxml.jackson.databind.ObjectMapper;
|
| - |
|
7 |
import com.fasterxml.jackson.databind.deser.std.StringDeserializer;
|
| - |
|
8 |
import com.fasterxml.jackson.databind.module.SimpleModule;
|
| 5 |
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
|
9 |
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
|
| 6 |
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
10 |
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
| 7 |
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
|
11 |
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
|
| 8 |
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
|
12 |
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
|
| 9 |
import com.fasterxml.jackson.module.paramnames.ParameterNamesModule;
|
13 |
import com.fasterxml.jackson.module.paramnames.ParameterNamesModule;
|
| Line 90... |
Line 94... |
| 90 |
attributesMap.put("dateMonthYearFormatter", dateMonthYearFormatter);
|
94 |
attributesMap.put("dateMonthYearFormatter", dateMonthYearFormatter);
|
| 91 |
attributesMap.put("dateMonthChYear", dateMonthChYear);
|
95 |
attributesMap.put("dateMonthChYear", dateMonthChYear);
|
| 92 |
attributesMap.put("decimalFormatter", decimalFormatter);
|
96 |
attributesMap.put("decimalFormatter", decimalFormatter);
|
| 93 |
attributesMap.put("noData", "<tr><td colspan=\"20\" style=\"text-align:center;\">No results found for the given criteria</td></tr>");
|
97 |
attributesMap.put("noData", "<tr><td colspan=\"20\" style=\"text-align:center;\">No results found for the given criteria</td></tr>");
|
| 94 |
attributesMap.put("dateTimeFormatter", dateTimeFormatter);
|
98 |
attributesMap.put("dateTimeFormatter", dateTimeFormatter);
|
| 95 |
attributesMap.put("version", "193");
|
99 |
attributesMap.put("version", "194");
|
| 96 |
attributesMap.put("cssVersion", "12");
|
100 |
attributesMap.put("cssVersion", "12");
|
| 97 |
attributesMap.put("isDev", getActiveProfile().equals("dev"));
|
101 |
attributesMap.put("isDev", getActiveProfile().equals("dev"));
|
| 98 |
attributesMap.put("vmUtils", new Utils());
|
102 |
attributesMap.put("vmUtils", new Utils());
|
| 99 |
//attributesMap.put("esc", new EscapeTool());
|
103 |
//attributesMap.put("esc", new EscapeTool());
|
| 100 |
attributesMap.put("ru", RoundingMode.HALF_UP);
|
104 |
attributesMap.put("ru", RoundingMode.HALF_UP);
|
| Line 265... |
Line 269... |
| 265 |
LocalDateTimeSerializer serializer = new LocalDateTimeSerializer(sf);
|
269 |
LocalDateTimeSerializer serializer = new LocalDateTimeSerializer(sf);
|
| 266 |
LocalDateTimeDeserializer deserializer = new LocalDateTimeDeserializer(df);
|
270 |
LocalDateTimeDeserializer deserializer = new LocalDateTimeDeserializer(df);
|
| 267 |
JavaTimeModule jtm = new JavaTimeModule();
|
271 |
JavaTimeModule jtm = new JavaTimeModule();
|
| 268 |
jtm.addSerializer(LocalDateTime.class, serializer);
|
272 |
jtm.addSerializer(LocalDateTime.class, serializer);
|
| 269 |
jtm.addDeserializer(LocalDateTime.class, deserializer);
|
273 |
jtm.addDeserializer(LocalDateTime.class, deserializer);
|
| - |
|
274 |
SimpleModule stringModule = new SimpleModule("String trimmer deserialize module");
|
| - |
|
275 |
stringModule.addDeserializer(String.class, new CustomStringDeserializer());
|
| 270 |
ObjectMapper mapper = new ObjectMapper()
|
276 |
ObjectMapper mapper = new ObjectMapper()
|
| 271 |
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
|
277 |
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
|
| 272 |
.registerModule(new ParameterNamesModule()).registerModule(new Jdk8Module()).registerModule(jtm); // new module, NOT JSR310Module
|
278 |
.registerModule(new ParameterNamesModule()).registerModule(new Jdk8Module()).registerModule(jtm)
|
| - |
|
279 |
.registerModule(stringModule); // new module, NOT JSR310Module
|
| 273 |
return mapper;
|
280 |
return mapper;
|
| 274 |
}
|
281 |
}
|
| 275 |
|
282 |
|
| - |
|
283 |
class CustomStringDeserializer extends StringDeserializer {
|
| - |
|
284 |
@Override
|
| - |
|
285 |
public String deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
|
| - |
|
286 |
String text = super.deserialize(p, ctxt);
|
| - |
|
287 |
//clean up value
|
| - |
|
288 |
return text.trim();
|
| - |
|
289 |
}
|
| - |
|
290 |
}
|
| - |
|
291 |
|
| - |
|
292 |
|
| 276 |
}
|
293 |
}
|
| 277 |
|
294 |
|