Search in sources :

Example 61 with IJsonObject

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

the class PModeLegJsonConverter method convertToNative.

@Nonnull
public static PModeLeg convertToNative(@Nonnull final IJsonObject aElement) {
    final IJsonObject aProt = aElement.getAsObject(PROTOCOL);
    final PModeLegProtocol aProtocol = aProt == null ? null : PModeLegProtocolJsonConverter.convertToNative(aProt);
    final IJsonObject aBI = aElement.getAsObject(BUSINESS_INFORMATION);
    final PModeLegBusinessInformation aBusinessInformation = aBI == null ? null : PModeLegBusinessInformationJsonConverter.convertToNative(aBI);
    final IJsonObject aEH = aElement.getAsObject(ERROR_HANDLING);
    final PModeLegErrorHandling aErrorHandling = aEH == null ? null : PModeLegErrorHandlingJsonConverter.convertToNative(aEH);
    final IJsonObject aR = aElement.getAsObject(RELIABILITY);
    final PModeLegReliability aReliability = aR == null ? null : PModeLegReliabilityJsonConverter.convertToNative(aR);
    final IJsonObject aS = aElement.getAsObject(SECURITY);
    final PModeLegSecurity aSecurity = aS == null ? null : PModeLegSecurityJsonConverter.convertToNative(aS);
    return new PModeLeg(aProtocol, aBusinessInformation, aErrorHandling, aReliability, aSecurity);
}
Also used : IJsonObject(com.helger.json.IJsonObject) Nonnull(javax.annotation.Nonnull)

Example 62 with IJsonObject

use of com.helger.json.IJsonObject 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 63 with IJsonObject

use of com.helger.json.IJsonObject 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 64 with IJsonObject

use of com.helger.json.IJsonObject 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)

Example 65 with IJsonObject

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

the class PModeLegBusinessInformationJsonConverter method convertToNative.

@Nonnull
public static PModeLegBusinessInformation convertToNative(@Nonnull final IJsonObject aElement) {
    final String sService = aElement.getAsString(SERVICE);
    final String sServiceType = aElement.getAsString(SERVICE_TYPE);
    final String sAction = aElement.getAsString(ACTION);
    final ICommonsOrderedMap<String, PModeProperty> aProperties = new CommonsLinkedHashMap<>();
    final IJsonArray aProps = aElement.getAsArray(PROPERTIES);
    if (aProps != null)
        for (final IJsonObject aPropertyElement : aProps.iteratorObjects()) {
            final PModeProperty aProperty = PModePropertyJsonConverter.convertToNative(aPropertyElement);
            aProperties.put(aProperty.getName(), aProperty);
        }
    final ICommonsOrderedMap<String, PModePayloadProfile> aPayloadProfiles = new CommonsLinkedHashMap<>();
    final IJsonArray aPayloadProfs = aElement.getAsArray(PAYLOAD_PROFILE);
    if (aPayloadProfs != null)
        for (final IJsonObject aPayloadElement : aPayloadProfs.iteratorObjects()) {
            final PModePayloadProfile aPayloadProfile = PModePayloadProfileJsonConverter.convertToNative(aPayloadElement);
            aPayloadProfiles.put(aPayloadProfile.getName(), aPayloadProfile);
        }
    final Long aPayloadProfileMaxKB = aElement.getAsLongObj(PAYLOAD_PROFILE_MAX_KB);
    final String sMPCID = aElement.getAsString(MPCID);
    return new PModeLegBusinessInformation(sService, sServiceType, sAction, aProperties, aPayloadProfiles, aPayloadProfileMaxKB, sMPCID);
}
Also used : CommonsLinkedHashMap(com.helger.commons.collection.impl.CommonsLinkedHashMap) IJsonObject(com.helger.json.IJsonObject) IJsonArray(com.helger.json.IJsonArray) Nonnull(javax.annotation.Nonnull)

Aggregations

IJsonObject (com.helger.json.IJsonObject)79 JsonObject (com.helger.json.JsonObject)44 Nonnull (javax.annotation.Nonnull)41 IJsonArray (com.helger.json.IJsonArray)22 JsonArray (com.helger.json.JsonArray)19 Test (org.junit.Test)15 JsonWriter (com.helger.json.serialize.JsonWriter)12 IJson (com.helger.json.IJson)10 Map (java.util.Map)10 StopWatch (com.helger.commons.timing.StopWatch)9 IParticipantIdentifier (com.helger.peppolid.IParticipantIdentifier)9 ZonedDateTime (java.time.ZonedDateTime)9 CommonsArrayList (com.helger.commons.collection.impl.CommonsArrayList)7 IError (com.helger.commons.error.IError)7 PDBusinessCard (com.helger.pd.businesscard.generic.PDBusinessCard)5 IDocumentTypeIdentifier (com.helger.peppolid.IDocumentTypeIdentifier)5 Nullable (javax.annotation.Nullable)5 Nonempty (com.helger.commons.annotation.Nonempty)4 ReturnsMutableCopy (com.helger.commons.annotation.ReturnsMutableCopy)3 CommonsLinkedHashMap (com.helger.commons.collection.impl.CommonsLinkedHashMap)3