@Singleton
public class JsonUtils
extends java.lang.Object
JsonObjectMapper.| Modifier and Type | Class and Description |
|---|---|
static class |
JsonUtils.JsonForIO
Helper class for selectively marshaling an Object to JSON.
|
static class |
JsonUtils.JsonForPublix
Helper class for selectively marshaling an Object to JSON.
|
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
DATA |
static java.lang.String |
VERSION |
| Constructor and Description |
|---|
JsonUtils() |
| Modifier and Type | Method and Description |
|---|---|
com.fasterxml.jackson.databind.JsonNode |
allBatchesByStudyForUI(java.util.List<Batch> batchList,
java.util.List<java.lang.Integer> resultCountList,
java.util.List<java.lang.Integer> groupCountList)
Returns a JSON string of all batches that belong to the given study.
|
com.fasterxml.jackson.databind.JsonNode |
allComponentsForUI(java.util.List<Component> componentList,
java.util.List<java.lang.Integer> resultCountList)
Returns a JSON string of all components in the given list.
|
com.fasterxml.jackson.databind.JsonNode |
allGroupResultsForUI(java.util.List<GroupResult> groupResultList)
Returns all GroupResults as a JSON string intended for GUI.
|
static java.lang.String |
asJson(java.lang.Object obj)
Generic JSON marshaler.
|
java.lang.String |
asJsonForPublix(java.lang.Object obj)
Marshalling an Object into an JSON string.
|
com.fasterxml.jackson.databind.JsonNode |
asJsonNode(java.lang.Object obj)
Generic JSON marshaler.
|
static java.lang.String |
asStringForDB(java.lang.String jsonData)
Formats a JSON string into a minimized form suitable for storing into a
DB.
|
com.fasterxml.jackson.databind.JsonNode |
componentAsJsonForIO(Component component)
Marshals the given component into JSON, adds the current component serial
version, and returns it as JsonNode.
|
com.fasterxml.jackson.databind.JsonNode |
componentResultAsJsonNode(ComponentResult componentResult,
boolean withData)
Returns an ObjectNode of the given ComponentResult.
|
java.lang.String |
componentResultDataForUI(ComponentResult result)
Returns the data string of a componentResult limited to
MAX_CHAR_PER_RESULT characters.
|
com.fasterxml.jackson.databind.node.ObjectNode |
getBatchByStudyForUI(Batch batch,
java.lang.Integer resultCount,
java.lang.Integer groupCount)
Returns a JSON string of one batch.
|
com.fasterxml.jackson.databind.JsonNode |
getComponentResultsByStudyResult(StudyResult studyResult) |
com.fasterxml.jackson.databind.JsonNode |
initData(Batch batch,
StudyResult studyResult,
Study study,
Component component)
Returns init data that are requested during initialisation of each
component run: Marshals the study properties and the component properties
and puts them together with the session data (stored in StudyResult) into
a new JSON object.
|
static boolean |
isValid(java.lang.String json)
Checks whether the given string is a valid JSON string.
|
com.fasterxml.jackson.databind.JsonNode |
memberUserArrayOfStudy(java.util.List<User> userList,
Study study)
Returns JsonNode with all users of this study.
|
com.fasterxml.jackson.databind.node.ObjectNode |
memberUserOfStudy(User user,
Study study)
Returns JsonNode with the given user.
|
com.fasterxml.jackson.databind.JsonNode |
sidebarStudyList(java.util.List<Study> studyList)
Returns the JSON data for the sidebar (study title, ID and components)
|
void |
studyAsJsonForIO(Study study,
java.io.File file)
Marshals the given study into JSON, adds the current study serial
version, and saves it into the given File.
|
com.fasterxml.jackson.databind.JsonNode |
studyLinksData(java.util.List<StudyLink> studyLinkList) |
com.fasterxml.jackson.databind.JsonNode |
studyLinksSetupData(Batch batch,
java.util.Map<java.lang.String,java.lang.Integer> studyResultCountsPerWorker,
java.lang.Integer personalSingleLinkCount,
java.lang.Integer personalMultipleLinkCount) |
com.fasterxml.jackson.databind.JsonNode |
studyResultAsJsonNode(StudyResult studyResult,
java.lang.Integer componentResultCount)
Returns ObjectNode of the given StudyResult.
|
com.fasterxml.jackson.databind.JsonNode |
userData(User user)
Returns a JsonNode with the usual user fields plus from all studies where
the user is member of the title and the number of members.
|
com.fasterxml.jackson.databind.JsonNode |
workersForTableData(java.util.Set<Worker> workerSet,
Study study)
Returns a JSON string with the given set of workers wrapped in a data
object.
|
public static final java.lang.String DATA
public static final java.lang.String VERSION
public java.lang.String asJsonForPublix(java.lang.Object obj)
throws com.fasterxml.jackson.core.JsonProcessingException
com.fasterxml.jackson.core.JsonProcessingExceptionpublic static java.lang.String asStringForDB(java.lang.String jsonData)
public static boolean isValid(java.lang.String json)
public com.fasterxml.jackson.databind.JsonNode initData(Batch batch, StudyResult studyResult, Study study, Component component) throws java.io.IOException
java.io.IOExceptionpublic com.fasterxml.jackson.databind.JsonNode allGroupResultsForUI(java.util.List<GroupResult> groupResultList)
public java.lang.String componentResultDataForUI(ComponentResult result)
public com.fasterxml.jackson.databind.JsonNode studyResultAsJsonNode(StudyResult studyResult, java.lang.Integer componentResultCount)
public com.fasterxml.jackson.databind.JsonNode getComponentResultsByStudyResult(StudyResult studyResult)
public com.fasterxml.jackson.databind.JsonNode componentResultAsJsonNode(ComponentResult componentResult, boolean withData)
public com.fasterxml.jackson.databind.JsonNode memberUserArrayOfStudy(java.util.List<User> userList, Study study)
public com.fasterxml.jackson.databind.node.ObjectNode memberUserOfStudy(User user, Study study)
public com.fasterxml.jackson.databind.JsonNode userData(User user)
public com.fasterxml.jackson.databind.JsonNode sidebarStudyList(java.util.List<Study> studyList)
public com.fasterxml.jackson.databind.JsonNode allBatchesByStudyForUI(java.util.List<Batch> batchList, java.util.List<java.lang.Integer> resultCountList, java.util.List<java.lang.Integer> groupCountList)
public com.fasterxml.jackson.databind.node.ObjectNode getBatchByStudyForUI(Batch batch, java.lang.Integer resultCount, java.lang.Integer groupCount)
public com.fasterxml.jackson.databind.JsonNode allComponentsForUI(java.util.List<Component> componentList, java.util.List<java.lang.Integer> resultCountList)
public com.fasterxml.jackson.databind.JsonNode workersForTableData(java.util.Set<Worker> workerSet, Study study)
public com.fasterxml.jackson.databind.JsonNode studyLinksSetupData(Batch batch, java.util.Map<java.lang.String,java.lang.Integer> studyResultCountsPerWorker, java.lang.Integer personalSingleLinkCount, java.lang.Integer personalMultipleLinkCount)
public com.fasterxml.jackson.databind.JsonNode studyLinksData(java.util.List<StudyLink> studyLinkList)
public static java.lang.String asJson(java.lang.Object obj)
public com.fasterxml.jackson.databind.JsonNode asJsonNode(java.lang.Object obj)
public com.fasterxml.jackson.databind.JsonNode componentAsJsonForIO(Component component) throws java.io.IOException
java.io.IOExceptionpublic void studyAsJsonForIO(Study study, java.io.File file) throws java.io.IOException
java.io.IOException