Search in sources :

Example 1 with FormattedDateTimeType

use of un.unece.uncefact.data.standard.qualifieddatatype._100.FormattedDateTimeType in project en16931-cii2ubl by phax.

the class CIIToUBL21Converter method _convertDocumentReference.

@Nullable
private static DocumentReferenceType _convertDocumentReference(@Nullable final ReferencedDocumentType aRD, @Nonnull final IErrorList aErrorList) {
    if (aRD == null)
        return null;
    final String sID = aRD.getIssuerAssignedIDValue();
    if (StringHelper.hasNoText(sID))
        return null;
    final DocumentReferenceType ret = new DocumentReferenceType();
    // ID value is a mandatory field
    ret.setID(sID).setSchemeID(aRD.getReferenceTypeCodeValue());
    // IssueDate is optional
    final FormattedDateTimeType aFDT = aRD.getFormattedIssueDateTime();
    if (aFDT != null)
        ret.setIssueDate(_parseDate(aFDT.getDateTimeString(), aErrorList));
    // Name is optional
    for (final TextType aItem : aRD.getName()) {
        final DocumentDescriptionType aUBLDocDesc = new DocumentDescriptionType();
        aUBLDocDesc.setValue(aItem.getValue());
        aUBLDocDesc.setLanguageID(aItem.getLanguageID());
        aUBLDocDesc.setLanguageLocaleID(aItem.getLanguageLocaleID());
        ret.addDocumentDescription(aUBLDocDesc);
    }
    // Attachment (0..1 for CII)
    if (aRD.getAttachmentBinaryObjectCount() > 0) {
        final BinaryObjectType aBinObj = aRD.getAttachmentBinaryObjectAtIndex(0);
        final AttachmentType aUBLAttachment = new AttachmentType();
        final EmbeddedDocumentBinaryObjectType aEmbeddedDoc = new EmbeddedDocumentBinaryObjectType();
        aEmbeddedDoc.setMimeCode(aBinObj.getMimeCode());
        aEmbeddedDoc.setFilename(aBinObj.getFilename());
        aEmbeddedDoc.setValue(aBinObj.getValue());
        aUBLAttachment.setEmbeddedDocumentBinaryObject(aEmbeddedDoc);
        final String sURI = aRD.getURIIDValue();
        if (StringHelper.hasText(sURI)) {
            final ExternalReferenceType aUBLExtRef = new ExternalReferenceType();
            aUBLExtRef.setURI(sURI);
            aUBLAttachment.setExternalReference(aUBLExtRef);
        }
        ret.setAttachment(aUBLAttachment);
    }
    return ret;
}
Also used : BinaryObjectType(un.unece.uncefact.data.standard.unqualifieddatatype._100.BinaryObjectType) FormattedDateTimeType(un.unece.uncefact.data.standard.qualifieddatatype._100.FormattedDateTimeType) TextType(un.unece.uncefact.data.standard.unqualifieddatatype._100.TextType) Nullable(javax.annotation.Nullable)

Example 2 with FormattedDateTimeType

use of un.unece.uncefact.data.standard.qualifieddatatype._100.FormattedDateTimeType in project en16931-cii2ubl by phax.

the class CIIToUBL22Converter method _convertDocumentReference.

@Nullable
private static DocumentReferenceType _convertDocumentReference(@Nullable final ReferencedDocumentType aRD, @Nonnull final IErrorList aErrorList) {
    if (aRD == null)
        return null;
    final String sID = aRD.getIssuerAssignedIDValue();
    if (StringHelper.hasNoText(sID))
        return null;
    final DocumentReferenceType ret = new DocumentReferenceType();
    // ID value is a mandatory field
    ret.setID(sID).setSchemeID(aRD.getReferenceTypeCodeValue());
    // IssueDate is optional
    final FormattedDateTimeType aFDT = aRD.getFormattedIssueDateTime();
    if (aFDT != null)
        ret.setIssueDate(_parseDate(aFDT.getDateTimeString(), aErrorList));
    // Name is optional
    for (final TextType aItem : aRD.getName()) {
        final DocumentDescriptionType aUBLDocDesc = new DocumentDescriptionType();
        aUBLDocDesc.setValue(aItem.getValue());
        aUBLDocDesc.setLanguageID(aItem.getLanguageID());
        aUBLDocDesc.setLanguageLocaleID(aItem.getLanguageLocaleID());
        ret.addDocumentDescription(aUBLDocDesc);
    }
    // Attachment (0..1 for CII)
    if (aRD.getAttachmentBinaryObjectCount() > 0) {
        final BinaryObjectType aBinObj = aRD.getAttachmentBinaryObjectAtIndex(0);
        final AttachmentType aUBLAttachment = new AttachmentType();
        final EmbeddedDocumentBinaryObjectType aEmbeddedDoc = new EmbeddedDocumentBinaryObjectType();
        aEmbeddedDoc.setMimeCode(aBinObj.getMimeCode());
        aEmbeddedDoc.setFilename(aBinObj.getFilename());
        aEmbeddedDoc.setValue(aBinObj.getValue());
        aUBLAttachment.setEmbeddedDocumentBinaryObject(aEmbeddedDoc);
        final String sURI = aRD.getURIIDValue();
        if (StringHelper.hasText(sURI)) {
            final ExternalReferenceType aUBLExtRef = new ExternalReferenceType();
            aUBLExtRef.setURI(sURI);
            aUBLAttachment.setExternalReference(aUBLExtRef);
        }
        ret.setAttachment(aUBLAttachment);
    }
    return ret;
}
Also used : BinaryObjectType(un.unece.uncefact.data.standard.unqualifieddatatype._100.BinaryObjectType) FormattedDateTimeType(un.unece.uncefact.data.standard.qualifieddatatype._100.FormattedDateTimeType) TextType(un.unece.uncefact.data.standard.unqualifieddatatype._100.TextType) Nullable(javax.annotation.Nullable)

Example 3 with FormattedDateTimeType

use of un.unece.uncefact.data.standard.qualifieddatatype._100.FormattedDateTimeType in project en16931-cii2ubl by phax.

the class CIIToUBL23Converter method _convertDocumentReference.

@Nullable
private static DocumentReferenceType _convertDocumentReference(@Nullable final ReferencedDocumentType aRD, @Nonnull final IErrorList aErrorList) {
    if (aRD == null)
        return null;
    final String sID = aRD.getIssuerAssignedIDValue();
    if (StringHelper.hasNoText(sID))
        return null;
    final DocumentReferenceType ret = new DocumentReferenceType();
    // ID value is a mandatory field
    ret.setID(sID).setSchemeID(aRD.getReferenceTypeCodeValue());
    // IssueDate is optional
    final FormattedDateTimeType aFDT = aRD.getFormattedIssueDateTime();
    if (aFDT != null)
        ret.setIssueDate(_parseDate(aFDT.getDateTimeString(), aErrorList));
    // Name is optional
    for (final TextType aItem : aRD.getName()) {
        final DocumentDescriptionType aUBLDocDesc = new DocumentDescriptionType();
        aUBLDocDesc.setValue(aItem.getValue());
        aUBLDocDesc.setLanguageID(aItem.getLanguageID());
        aUBLDocDesc.setLanguageLocaleID(aItem.getLanguageLocaleID());
        ret.addDocumentDescription(aUBLDocDesc);
    }
    // Attachment (0..1 for CII)
    if (aRD.getAttachmentBinaryObjectCount() > 0) {
        final BinaryObjectType aBinObj = aRD.getAttachmentBinaryObjectAtIndex(0);
        final AttachmentType aUBLAttachment = new AttachmentType();
        final EmbeddedDocumentBinaryObjectType aEmbeddedDoc = new EmbeddedDocumentBinaryObjectType();
        aEmbeddedDoc.setMimeCode(aBinObj.getMimeCode());
        aEmbeddedDoc.setFilename(aBinObj.getFilename());
        aEmbeddedDoc.setValue(aBinObj.getValue());
        aUBLAttachment.setEmbeddedDocumentBinaryObject(aEmbeddedDoc);
        final String sURI = aRD.getURIIDValue();
        if (StringHelper.hasText(sURI)) {
            final ExternalReferenceType aUBLExtRef = new ExternalReferenceType();
            aUBLExtRef.setURI(sURI);
            aUBLAttachment.setExternalReference(aUBLExtRef);
        }
        ret.setAttachment(aUBLAttachment);
    }
    return ret;
}
Also used : BinaryObjectType(un.unece.uncefact.data.standard.unqualifieddatatype._100.BinaryObjectType) FormattedDateTimeType(un.unece.uncefact.data.standard.qualifieddatatype._100.FormattedDateTimeType) TextType(un.unece.uncefact.data.standard.unqualifieddatatype._100.TextType) Nullable(javax.annotation.Nullable)

Aggregations

Nullable (javax.annotation.Nullable)3 FormattedDateTimeType (un.unece.uncefact.data.standard.qualifieddatatype._100.FormattedDateTimeType)3 BinaryObjectType (un.unece.uncefact.data.standard.unqualifieddatatype._100.BinaryObjectType)3 TextType (un.unece.uncefact.data.standard.unqualifieddatatype._100.TextType)3