use of com.helger.json.IJsonObject in project phase4 by phax.
the class PModeJsonConverter method convertToNative.
@Nonnull
public static PMode convertToNative(@Nonnull final IJsonObject aElement) {
final IJsonObject aInit = aElement.getAsObject(ELEMENT_INITIATOR);
final PModeParty aInitiator = aInit == null ? null : PModePartyJsonConverter.convertToNative(aInit);
final IJsonObject aResp = aElement.getAsObject(ELEMENT_RESPONDER);
final PModeParty aResponder = aResp == null ? null : PModePartyJsonConverter.convertToNative(aResp);
final String sAgreement = aElement.getAsString(ATTR_AGREEMENT);
final String sMEP = aElement.getAsString(ATTR_MEP);
final EMEP eMEP = EMEP.getFromIDOrNull(sMEP);
if (eMEP == null)
throw new IllegalStateException("Failed to resolve MEP '" + sMEP + "'");
final String sMEPBinding = aElement.getAsString(ATTR_MEP_BINDING);
final EMEPBinding eMEPBinding = EMEPBinding.getFromIDOrNull(sMEPBinding);
if (eMEPBinding == null)
throw new IllegalStateException("Failed to resolve MEPBinding '" + sMEPBinding + "'");
final IJsonObject aL1 = aElement.getAsObject(ELEMENT_LEG1);
final PModeLeg aLeg1 = aL1 == null ? null : PModeLegJsonConverter.convertToNative(aL1);
final IJsonObject aL2 = aElement.getAsObject(ELEMENT_LEG2);
final PModeLeg aLeg2 = aL2 == null ? null : PModeLegJsonConverter.convertToNative(aL2);
final IJsonObject aPS = aElement.getAsObject(ELEMENT_PAYLOADSERVICE);
final PModePayloadService aPayloadService = aPS == null ? null : PModePayloadServiceJsonConverter.convertToNative(aPS);
final IJsonObject aRA = aElement.getAsObject(ELEMENT_RECEPETIONAWARENESS);
final PModeReceptionAwareness aReceptionAwareness = aRA == null ? null : PModeReceptionAwarenessJsonConverter.convertToNative(aRA);
return new PMode(getStubObject(aElement), aInitiator, aResponder, sAgreement, eMEP, eMEPBinding, aLeg1, aLeg2, aPayloadService, aReceptionAwareness);
}
use of com.helger.json.IJsonObject in project phase4 by phax.
the class PModeJsonConverter method setObjectFields.
public static void setObjectFields(@Nonnull final IBusinessObject aValue, @Nonnull final IJsonObject aElement) {
aElement.add(ATTR_ID, aValue.getID());
if (aValue.hasCreationDateTime())
aElement.add(ATTR_CREATIONLDT, PDTWebDateHelper.getAsStringXSD(aValue.getCreationDateTime()));
if (aValue.hasCreationUserID())
aElement.add(ATTR_CREATIONUSERID, aValue.getCreationUserID());
if (aValue.hasLastModificationDateTime())
aElement.add(ATTR_LASTMODLDT, PDTWebDateHelper.getAsStringXSD(aValue.getLastModificationDateTime()));
if (aValue.hasLastModificationUserID())
aElement.add(ATTR_LASTMODUSERID, aValue.getLastModificationUserID());
if (aValue.hasDeletionDateTime())
aElement.add(ATTR_DELETIONLDT, PDTWebDateHelper.getAsStringXSD(aValue.getDeletionDateTime()));
if (aValue.hasDeletionUserID())
aElement.add(ATTR_DELETIONUSERID, aValue.getDeletionUserID());
if (aValue.attrs().isNotEmpty()) {
final IJsonArray aCustomArray = new JsonArray();
for (final Map.Entry<String, String> aEntry : CollectionHelper.getSortedByKey(aValue.attrs()).entrySet()) {
final IJsonObject eCustom = new JsonObject();
eCustom.add(ATTR_ID, aEntry.getKey());
if (aEntry.getValue() != null)
eCustom.add(VALUE, aEntry.getValue());
aCustomArray.add(eCustom);
}
aElement.addJson(ELEMENT_CUSTOM, aCustomArray);
}
}
use of com.helger.json.IJsonObject in project phase4 by phax.
the class PModeJsonConverter method getStubObject.
@Nonnull
public static StubObject getStubObject(@Nonnull final IJsonObject aElement) {
// ID
final String sID = aElement.getAsString(ATTR_ID);
// Creation
final LocalDateTime aCreationLDT = PDTWebDateHelper.getLocalDateTimeFromXSD(aElement.getAsString(ATTR_CREATIONLDT));
final String sCreationUserID = aElement.getAsString(ATTR_CREATIONUSERID);
// Last modification
final LocalDateTime aLastModificationLDT = PDTWebDateHelper.getLocalDateTimeFromXSD(aElement.getAsString(ATTR_LASTMODLDT));
final String sLastModificationUserID = aElement.getAsString(ATTR_LASTMODUSERID);
// Deletion
final LocalDateTime aDeletionLDT = PDTWebDateHelper.getLocalDateTimeFromXSD(aElement.getAsString(ATTR_DELETIONLDT));
final String sDeletionUserID = aElement.getAsString(ATTR_DELETIONUSERID);
final ICommonsOrderedMap<String, String> aCustomAttrs = new CommonsLinkedHashMap<>();
final IJsonArray aCustom = aElement.getAsArray(ELEMENT_CUSTOM);
if (aCustom != null)
for (final IJsonObject eCustom : aCustom.iteratorObjects()) aCustomAttrs.put(eCustom.getAsString(ATTR_ID), eCustom.getAsString(VALUE));
return new StubObject(sID, aCreationLDT, sCreationUserID, aLastModificationLDT, sLastModificationUserID, aDeletionLDT, sDeletionUserID, aCustomAttrs);
}
use of com.helger.json.IJsonObject in project phoss-directory by phax.
the class PDBusinessCard method getAsJson.
@Nonnull
public IJsonObject getAsJson() {
final IJsonObject ret = new JsonObject();
ret.addJson("participant", m_aParticipantIdentifier.getAsJson());
ret.addJson("entity", new JsonArray().addAllMapped(m_aBusinessEntities, PDBusinessEntity::getAsJson));
return ret;
}
use of com.helger.json.IJsonObject in project phoss-directory by phax.
the class PDContact method getAsJson.
@Nonnull
public IJsonObject getAsJson() {
final IJsonObject ret = new JsonObject();
ret.add("type", m_sType);
ret.add("name", m_sName);
ret.add("phonenumber", m_sPhoneNumber);
ret.add("email", m_sEmail);
return ret;
}
Aggregations