Search in sources :

Example 26 with JsonObject

use of com.helger.json.JsonObject in project phive by phax.

the class PhiveJsonHelperTest method testValidationResults.

@Test
public void testValidationResults() {
    final IJsonObject aObj = new JsonObject();
    final Locale aDisplayLocale = Locale.US;
    final VESID aVESID = new VESID("group", "art", "1.0");
    final IValidationExecutorSet<?> aVES = new ValidationExecutorSet<>(aVESID, "name", false);
    PhiveJsonHelper.applyValidationResultList(aObj, aVES, new CommonsArrayList<>(), aDisplayLocale, 123, null, null);
    final String sJson = aObj.getAsJsonString();
    assertEquals("{\"ves\":{\"vesid\":\"group:art:1.0\",\"name\":\"name\",\"deprecated\":false}," + "\"success\":true," + "\"interrupted\":false," + "\"mostSevereErrorLevel\":\"SUCCESS\"," + "\"results\":[]," + "\"durationMS\":123}", sJson);
}
Also used : Locale(java.util.Locale) ValidationExecutorSet(com.helger.phive.api.executorset.ValidationExecutorSet) IValidationExecutorSet(com.helger.phive.api.executorset.IValidationExecutorSet) VESID(com.helger.phive.api.executorset.VESID) IJsonObject(com.helger.json.IJsonObject) IJsonObject(com.helger.json.IJsonObject) JsonObject(com.helger.json.JsonObject) Test(org.junit.Test)

Example 27 with JsonObject

use of com.helger.json.JsonObject in project phase4 by phax.

the class PModePropertyJsonConverter method convertToJson.

@Nonnull
public static IJsonObject convertToJson(@Nonnull final PModeProperty aValue) {
    final IJsonObject ret = new JsonObject();
    ret.add(NAME, aValue.getName());
    if (aValue.hasDescription())
        ret.add(DESCRIPTION, aValue.getDescription());
    ret.add(DATA_TYPE, aValue.getDataType());
    ret.add(MANDATORY, aValue.isMandatory());
    return ret;
}
Also used : IJsonObject(com.helger.json.IJsonObject) IJsonObject(com.helger.json.IJsonObject) JsonObject(com.helger.json.JsonObject) Nonnull(javax.annotation.Nonnull)

Example 28 with JsonObject

use of com.helger.json.JsonObject in project phase4 by phax.

the class PModePartyJsonConverter method convertToJson.

@Nonnull
public static IJsonObject convertToJson(@Nonnull final PModeParty aValue) {
    final IJsonObject ret = new JsonObject();
    if (aValue.hasIDType())
        ret.add(ID_TYPE, aValue.getIDType());
    ret.add(ID_VALUE, aValue.getIDValue());
    ret.add(ROLE, aValue.getRole());
    if (aValue.hasUserName())
        ret.add(USER_NAME, aValue.getUserName());
    if (aValue.hasPassword())
        ret.add(PASSWORD, aValue.getPassword());
    return ret;
}
Also used : IJsonObject(com.helger.json.IJsonObject) IJsonObject(com.helger.json.IJsonObject) JsonObject(com.helger.json.JsonObject) Nonnull(javax.annotation.Nonnull)

Example 29 with JsonObject

use of com.helger.json.JsonObject in project phase4 by phax.

the class PModeReceptionAwarenessJsonConverter method convertToJson.

@Nonnull
public static IJsonObject convertToJson(@Nonnull final PModeReceptionAwareness aValue) {
    final IJsonObject ret = new JsonObject();
    if (aValue.isReceptionAwarenessDefined())
        ret.add(RECEPTION_AWARENESS, aValue.isReceptionAwareness());
    if (aValue.isRetryDefined())
        ret.add(RETRY, aValue.isRetry());
    ret.add(MAX_RETRIES, aValue.getMaxRetries());
    ret.add(RETRY_INTERVAL_MS, aValue.getRetryIntervalMS());
    if (aValue.isDuplicateDetectionDefined())
        ret.add(DUPLICATE_DETECTION, aValue.isDuplicateDetection());
    return ret;
}
Also used : IJsonObject(com.helger.json.IJsonObject) IJsonObject(com.helger.json.IJsonObject) JsonObject(com.helger.json.JsonObject) Nonnull(javax.annotation.Nonnull)

Example 30 with JsonObject

use of com.helger.json.JsonObject in project phase4 by phax.

the class PModeJsonConverter method convertToJson.

@Nonnull
public static IJsonObject convertToJson(@Nonnull final IPMode aValue) {
    final IJsonObject ret = new JsonObject();
    setObjectFields(aValue, ret);
    if (aValue.hasInitiator())
        ret.addJson(ELEMENT_INITIATOR, PModePartyJsonConverter.convertToJson(aValue.getInitiator()));
    if (aValue.hasResponder())
        ret.addJson(ELEMENT_RESPONDER, PModePartyJsonConverter.convertToJson(aValue.getResponder()));
    if (aValue.hasAgreement())
        ret.add(ATTR_AGREEMENT, aValue.getAgreement());
    ret.add(ATTR_MEP, aValue.getMEPID());
    ret.add(ATTR_MEP_BINDING, aValue.getMEPBindingID());
    if (aValue.hasLeg1())
        ret.addJson(ELEMENT_LEG1, PModeLegJsonConverter.convertToJson(aValue.getLeg1()));
    if (aValue.hasLeg2())
        ret.addJson(ELEMENT_LEG2, PModeLegJsonConverter.convertToJson(aValue.getLeg2()));
    if (aValue.hasPayloadService())
        ret.addJson(ELEMENT_PAYLOADSERVICE, PModePayloadServiceJsonConverter.convertToJson(aValue.getPayloadService()));
    if (aValue.hasReceptionAwareness())
        ret.addJson(ELEMENT_RECEPETIONAWARENESS, PModeReceptionAwarenessJsonConverter.convertToJson(aValue.getReceptionAwareness()));
    return ret;
}
Also used : IJsonObject(com.helger.json.IJsonObject) IJsonObject(com.helger.json.IJsonObject) JsonObject(com.helger.json.JsonObject) Nonnull(javax.annotation.Nonnull)

Aggregations

JsonObject (com.helger.json.JsonObject)40 IJsonObject (com.helger.json.IJsonObject)38 Nonnull (javax.annotation.Nonnull)27 JsonArray (com.helger.json.JsonArray)16 IJsonArray (com.helger.json.IJsonArray)13 Map (java.util.Map)5 ReturnsMutableCopy (com.helger.commons.annotation.ReturnsMutableCopy)3 CommonsArrayList (com.helger.commons.collection.impl.CommonsArrayList)3 ICommonsList (com.helger.commons.collection.impl.ICommonsList)3 ICommonsMap (com.helger.commons.collection.impl.ICommonsMap)3 StopWatch (com.helger.commons.timing.StopWatch)3 IParticipantIdentifier (com.helger.peppolid.IParticipantIdentifier)3 ZonedDateTime (java.time.ZonedDateTime)3 Locale (java.util.Locale)3 Nonempty (com.helger.commons.annotation.Nonempty)2 CommonsTreeMap (com.helger.commons.collection.impl.CommonsTreeMap)2 IError (com.helger.commons.error.IError)2 ClassPathResource (com.helger.commons.io.resource.ClassPathResource)2 IHCNode (com.helger.html.hc.IHCNode)2 JsonWriter (com.helger.json.serialize.JsonWriter)2