Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
V
VIPSCommon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
VIPS
VIPSCommon
Commits
3ece4bf9
Commit
3ece4bf9
authored
5 years ago
by
Tor-Einar Skog
Browse files
Options
Downloads
Patches
Plain Diff
Serialization/deserialization issue fixed for good
parent
1cc36d17
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/no/nibio/vips/util/ModelUtil.java
+30
-0
30 additions, 0 deletions
src/main/java/no/nibio/vips/util/ModelUtil.java
with
30 additions
and
0 deletions
src/main/java/no/nibio/vips/util/ModelUtil.java
+
30
−
0
View file @
3ece4bf9
...
...
@@ -19,12 +19,16 @@
package
no.nibio.vips.util
;
import
com.fasterxml.jackson.core.type.TypeReference
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
java.io.BufferedInputStream
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.net.URLConnection
;
import
java.util.List
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
import
no.nibio.vips.entity.WeatherObservation
;
import
org.apache.commons.codec.binary.Base64
;
import
org.apache.commons.io.IOUtils
;
...
...
@@ -115,4 +119,30 @@ public class ModelUtil {
return
Base64
.
encodeBase64String
(
bytes
);
}
/**
* This solves the problem of the model not knowing if the ModelConfiguration
* contains a halfway serialized List of WeatherObservation (typically LinkedHashMap)
* OR a List of actual WeatherObservations.
* @param unknownClassList
* @return
*/
public
List
<
WeatherObservation
>
extractWeatherObservationList
(
Object
unknownClassList
)
{
try
{
// These are real WeatherObservation classes
List
<
WeatherObservation
>
obsList
=
(
List
<
WeatherObservation
>)
unknownClassList
;
if
(
obsList
!=
null
&&
obsList
.
size
()
>
0
)
{
WeatherObservation
o
=
obsList
.
get
(
0
);
}
return
obsList
;
}
catch
(
ClassCastException
ex
)
{
// These are semi serialized, tell ObjectMapper/Jackson how to do it
ObjectMapper
mapper
=
new
ObjectMapper
();
return
mapper
.
convertValue
(
unknownClassList
,
new
TypeReference
<
List
<
WeatherObservation
>>(){});
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment