Search in sources :

Example 1 with IPeppolDocumentTypeIdentifierParts

use of com.helger.peppolid.peppol.doctype.IPeppolDocumentTypeIdentifierParts in project peppol-commons by phax.

the class MainCreatePredefinedEnumsFromXML_v8x method _handleDocumentTypes.

private static void _handleDocumentTypes(final Document aDocumentSheet) {
    final PCLDocumentTypesType aList = new GenericJAXBMarshaller<>(PCLDocumentTypesType.class, new QName("dummy")).read(aDocumentSheet);
    // Create Java source
    try {
        final JDefinedClass jEnum = CM._package(RESULT_PACKAGE_PREFIX + "doctype")._enum("EPredefinedDocumentTypeIdentifier")._implements(IPeppolPredefinedDocumentTypeIdentifier.class);
        jEnum.annotate(CodingStyleguideUnaware.class);
        jEnum.javadoc().add(DO_NOT_EDIT);
        // Add metadata
        jEnum.field(JMod.PUBLIC_STATIC_FINAL, CM.ref(String.class), "CODE_LIST_VERSION", JExpr.lit(aList.getVersion()));
        jEnum.field(JMod.PUBLIC_STATIC_FINAL, CM.INT, "CODE_LIST_ENTRY_COUNT", JExpr.lit(aList.getEntryCount().intValue()));
        final ICommonsSet<String> aAllShortcutNames = new CommonsHashSet<>();
        // Add all enum constants
        for (final PCLDocumentTypeType aRow : aList.getDocumentType()) {
            final String sProfileCode = aRow.getName();
            final String sScheme = aRow.getScheme();
            final String sValue = aRow.getValue();
            final String sInitialRelease = aRow.getInitialRelease();
            final EPeppolCodeListItemState eState = _getState(aRow.getState());
            final boolean bDeprecated = !eState.isActive();
            final String sDeprecationRelease = aRow.getDeprecationRelease();
            final LocalDate aRemovalDate = aRow.getRemovalDateLocal();
            // Split ID in it's pieces
            final IPeppolDocumentTypeIdentifierParts aDocIDParts = PeppolDocumentTypeIdentifierParts.extractFromString(sValue);
            final String sEnumConstName = RegExHelper.getAsIdentifier(sValue);
            if (jEnum.getEnumConstantOfName(sEnumConstName) != null) {
                // Avoid weird side effects
                throw new IllegalStateException("The enum constant '" + sEnumConstName + "' is already in use");
            }
            final JEnumConstant jEnumConst = jEnum.enumConstant(sEnumConstName);
            if (bDeprecated) {
                jEnumConst.annotate(Deprecated.class);
                jEnumConst.javadoc().addDeprecated().add("since " + sDeprecationRelease + " - this item should not be used to issue new identifiers!");
            }
            jEnumConst.arg(JExpr.lit(sScheme));
            {
                final JInvocation aNew = JExpr._new(CM.ref(PeppolDocumentTypeIdentifierParts.class)).arg(aDocIDParts.getRootNS()).arg(aDocIDParts.getLocalName()).arg(aDocIDParts.getCustomizationID()).arg(aDocIDParts.getVersion());
                jEnumConst.arg(aNew);
            }
            jEnumConst.arg(JExpr.lit(sProfileCode));
            jEnumConst.arg(CM.ref(Version.class).staticInvoke("parse").arg(sInitialRelease));
            jEnumConst.arg(CM.ref(EPeppolCodeListItemState.class).enumConstantRef(eState));
            jEnumConst.arg(bDeprecated ? CM.ref(Version.class).staticInvoke("parse").arg(sDeprecationRelease) : JExpr._null());
            jEnumConst.arg(_asExpr(aRemovalDate));
            jEnumConst.arg(JExpr.lit(aRow.isIssuedByOpenpeppol()));
            jEnumConst.arg(JExpr.lit(StringParser.parseInt(aRow.getBisVersion(), -1)));
            jEnumConst.arg(aRow.getDomainCommunity() == null ? JExpr._null() : JExpr.lit(aRow.getDomainCommunity()));
            {
                final JInvocation aNew = JExpr._new(CM.ref(CommonsArrayList.class).narrowEmpty());
                for (final PCLProcessIDType aProcID : aRow.getProcessId()) aNew.arg(CIdentifier.getURIEncoded(aProcID.getScheme(), aProcID.getValue()));
                jEnumConst.arg(aNew);
            }
            jEnumConst.javadoc().add("<code>" + sValue + "</code><br>");
            jEnumConst.javadoc().addTag(JDocComment.TAG_SINCE).add("code list " + sInitialRelease);
            // Also create a shortcut for more readable names
            final String sShortcutName = CodeGenerationHelper.createShortcutDocumentTypeIDName(aDocIDParts);
            if (sShortcutName != null) {
                // Make unique name
                int nNext = 2;
                String sRealShortcutName = sShortcutName;
                while (!aAllShortcutNames.add(sRealShortcutName)) {
                    sRealShortcutName = sShortcutName + nNext;
                    nNext++;
                }
                final JFieldVar aShortcut = jEnum.field(JMod.PUBLIC | JMod.STATIC | JMod.FINAL, jEnum, sRealShortcutName, jEnumConst);
                aShortcut.javadoc().add("Same as {@link #" + sEnumConstName + "}");
                if (bDeprecated) {
                    aShortcut.annotate(Deprecated.class);
                    aShortcut.javadoc().addDeprecated().add("since " + sDeprecationRelease + " - this item should not be used to issue new identifiers!");
                }
                jEnumConst.javadoc().add("\nSame as {@link #" + sRealShortcutName + "}");
            }
        }
        // fields
        final JFieldVar fScheme = jEnum.field(JMod.PRIVATE | JMod.FINAL, String.class, "m_sScheme");
        final JFieldVar fParts = jEnum.field(JMod.PRIVATE | JMod.FINAL, IPeppolDocumentTypeIdentifierParts.class, "m_aParts");
        final JFieldVar fID = jEnum.field(JMod.PRIVATE | JMod.FINAL, String.class, "m_sID");
        final JFieldVar fProfileCode = jEnum.field(JMod.PRIVATE | JMod.FINAL, String.class, "m_sProfileCode");
        final JFieldVar fInitialRelease = jEnum.field(JMod.PRIVATE | JMod.FINAL, Version.class, "m_aInitialRelease");
        final JFieldVar fState = jEnum.field(JMod.PRIVATE | JMod.FINAL, EPeppolCodeListItemState.class, "m_eState");
        final JFieldVar fDeprecationRelease = jEnum.field(JMod.PRIVATE | JMod.FINAL, Version.class, "m_aDeprecationRelease");
        final JFieldVar fRemovalDate = jEnum.field(JMod.PRIVATE | JMod.FINAL, LocalDate.class, "m_aRemovalDate");
        final JFieldVar fIssuedByOpenPeppol = jEnum.field(JMod.PRIVATE | JMod.FINAL, boolean.class, "m_bIssuedByOpenPeppol");
        final JFieldVar fBISVersion = jEnum.field(JMod.PRIVATE | JMod.FINAL, int.class, "m_nBISVersion");
        final JFieldVar fDomainCommunity = jEnum.field(JMod.PRIVATE | JMod.FINAL, String.class, "m_sDomainCommunity");
        final JFieldVar fProcessIDs = jEnum.field(JMod.PRIVATE | JMod.FINAL, CM.ref(ICommonsList.class).narrow(IProcessIdentifier.class), "m_aProcessIDs");
        // Constructor
        final JMethod jCtor = jEnum.constructor(0);
        final JVar jScheme = jCtor.param(JMod.FINAL, String.class, "sScheme");
        jScheme.annotate(Nonnull.class);
        jScheme.annotate(Nonempty.class);
        final JVar jParts = jCtor.param(JMod.FINAL, IPeppolDocumentTypeIdentifierParts.class, "aParts");
        jParts.annotate(Nonnull.class);
        final JVar jProfileCode = jCtor.param(JMod.FINAL, String.class, "sProfileCode");
        jProfileCode.annotate(Nonnull.class);
        jProfileCode.annotate(Nonempty.class);
        final JVar jInitialRelease = jCtor.param(JMod.FINAL, Version.class, "aInitialRelease");
        jInitialRelease.annotate(Nonnull.class);
        final JVar jState = jCtor.param(JMod.FINAL, EPeppolCodeListItemState.class, "eState");
        jState.annotate(Nonnull.class);
        final JVar jDeprecationRelease = jCtor.param(JMod.FINAL, Version.class, "aDeprecationRelease");
        jDeprecationRelease.annotate(Nullable.class);
        final JVar jRemovalDate = jCtor.param(JMod.FINAL, LocalDate.class, "aRemovalDate");
        jRemovalDate.annotate(Nullable.class);
        final JVar jIssuedByOpenPeppol = jCtor.param(JMod.FINAL, boolean.class, "bIssuedByOpenPeppol");
        final JVar jBISVersion = jCtor.param(JMod.FINAL, int.class, "nBISVersion");
        final JVar jDomainCommunity = jCtor.param(JMod.FINAL, String.class, "sDomainCommunity");
        jDomainCommunity.annotate(Nullable.class);
        final JVar jProcessIDs = jCtor.param(JMod.FINAL, CM.ref(ICommonsList.class).narrow(String.class), "aProcessIDs");
        jCtor.body().assign(fScheme, jScheme).assign(fParts, jParts).assign(fProfileCode, jProfileCode).assign(fID, fParts.invoke("getAsDocumentTypeIdentifierValue")).assign(fInitialRelease, jInitialRelease).assign(fState, jState).assign(fDeprecationRelease, jDeprecationRelease).assign(fRemovalDate, jRemovalDate).assign(fIssuedByOpenPeppol, jIssuedByOpenPeppol).assign(fBISVersion, jBISVersion).assign(fDomainCommunity, jDomainCommunity).assign(fProcessIDs, CM.ref(CommonsArrayList.class).narrowEmpty()._new().arg(jProcessIDs).arg(new JLambdaMethodRef(CM.ref(PeppolIdentifierFactory.class).staticRef("INSTANCE"), "parseProcessIdentifier")));
        // public String getScheme ()
        JMethod m = jEnum.method(JMod.PUBLIC, String.class, "getScheme");
        m.annotate(Nonnull.class);
        m.annotate(Nonempty.class);
        m.body()._return(fScheme);
        // public String getValue ()
        m = jEnum.method(JMod.PUBLIC, String.class, "getValue");
        m.annotate(Nonnull.class);
        m.annotate(Nonempty.class);
        m.body()._return(fID);
        // public String getRootNS ()
        m = jEnum.method(JMod.PUBLIC, String.class, "getRootNS");
        m.annotate(Nonnull.class);
        m.annotate(Nonempty.class);
        m.body()._return(fParts.invoke(m.name()));
        // public String getLocalName ()
        m = jEnum.method(JMod.PUBLIC, String.class, "getLocalName");
        m.annotate(Nonnull.class);
        m.annotate(Nonempty.class);
        m.body()._return(fParts.invoke(m.name()));
        // public String getSubTypeIdentifier ()
        m = jEnum.method(JMod.PUBLIC, String.class, "getSubTypeIdentifier");
        m.annotate(Nonnull.class);
        m.annotate(Nonempty.class);
        m.body()._return(fParts.invoke(m.name()));
        if (false) {
            // public String getTransactionID ()
            m = jEnum.method(JMod.PUBLIC, String.class, "getTransactionID");
            m.annotate(Nonnull.class);
            m.annotate(Nonempty.class);
            m.body()._return(fParts.invoke(m.name()));
            // public List<String> getExtensionIDs ()
            m = jEnum.method(JMod.PUBLIC, CM.ref(ICommonsList.class).narrow(String.class), "getExtensionIDs");
            m.annotate(Nonnull.class);
            m.annotate(ReturnsMutableCopy.class);
            m.body()._return(fParts.invoke(m.name()));
        }
        // public String getCustomizationID ()
        m = jEnum.method(JMod.PUBLIC, String.class, "getCustomizationID");
        m.annotate(Nonnull.class);
        m.annotate(Nonempty.class);
        m.body()._return(fParts.invoke(m.name()));
        // public String getVersion ()
        m = jEnum.method(JMod.PUBLIC, String.class, "getVersion");
        m.annotate(Nonnull.class);
        m.annotate(Nonempty.class);
        m.body()._return(fParts.invoke(m.name()));
        // public String getCommonName ()
        m = jEnum.method(JMod.PUBLIC, String.class, "getCommonName");
        m.annotate(Nonnull.class);
        m.annotate(Nonempty.class);
        m.body()._return(fProfileCode);
        // public String getAsDocumentTypeIdentifierValue ()
        m = jEnum.method(JMod.PUBLIC, String.class, "getAsDocumentTypeIdentifierValue");
        m.annotate(Nonnull.class);
        m.annotate(Nonempty.class);
        m.body()._return(fID);
        // public PeppolDocumentTypeIdentifier getAsDocumentTypeIdentifier ()
        m = jEnum.method(JMod.PUBLIC, PeppolDocumentTypeIdentifier.class, "getAsDocumentTypeIdentifier");
        m.annotate(Nonnull.class);
        m.body()._return(JExpr._new(CM.ref(PeppolDocumentTypeIdentifier.class)).arg(JExpr._this()));
        // public IPeppolDocumentTypeIdentifierParts getParts
        m = jEnum.method(JMod.PUBLIC, IPeppolDocumentTypeIdentifierParts.class, "getParts");
        m.annotate(Nonnull.class);
        m.body()._return(fParts);
        // public Version getInitialRelease ()
        m = jEnum.method(JMod.PUBLIC, Version.class, "getInitialRelease");
        m.annotate(Nonnull.class);
        m.body()._return(fInitialRelease);
        // public EPeppolCodeListItemState getState ()
        m = jEnum.method(JMod.PUBLIC, EPeppolCodeListItemState.class, "getState");
        m.annotate(Nonnull.class);
        m.body()._return(fState);
        // public Version getDeprecationRelease ()
        m = jEnum.method(JMod.PUBLIC, Version.class, "getDeprecationRelease");
        m.annotate(Nullable.class);
        m.body()._return(fDeprecationRelease);
        // public LocalDate getRemovalDate ()
        m = jEnum.method(JMod.PUBLIC, LocalDate.class, "getRemovalDate");
        m.annotate(Nullable.class);
        m.body()._return(fRemovalDate);
        // public boolean isIssuedByOpenPeppol ()
        m = jEnum.method(JMod.PUBLIC, boolean.class, "isIssuedByOpenPeppol");
        m.body()._return(fIssuedByOpenPeppol);
        // public int getBISVersion ()
        m = jEnum.method(JMod.PUBLIC, int.class, "getBISVersion");
        m.annotate(CheckForSigned.class);
        m.body()._return(fBISVersion);
        // since 7.3 this method is nullable
        // public String getDomainCommunity ()
        m = jEnum.method(JMod.PUBLIC, String.class, "getDomainCommunity");
        m.annotate(Nullable.class);
        m.body()._return(fDomainCommunity);
        // public ICommonsList<IProcessIdentifier> getAllProcessIDs()
        m = jEnum.method(JMod.PUBLIC, CM.ref(ICommonsList.class).narrow(IProcessIdentifier.class), "getAllProcessIDs");
        m.annotate(Nonnull.class);
        m.annotate(Nonempty.class);
        m.annotate(ReturnsMutableCopy.class);
        m.body()._return(fProcessIDs.invoke("getClone"));
        // @Nullable
        // public static EPredefinedDocumentTypeIdentifier
        // getFromDocumentTypeIdentifierOrNull(@Nullable final
        // IDocumentTypeIdentifier aDocTypeID)
        m = jEnum.method(JMod.PUBLIC | JMod.STATIC, jEnum, "getFromDocumentTypeIdentifierOrNull");
        {
            m.annotate(Nullable.class);
            final JVar jValue = m.param(JMod.FINAL, IDocumentTypeIdentifier.class, "aDocTypeID");
            jValue.annotate(Nullable.class);
            final JBlock jIf = m.body()._if(jValue.neNull())._then();
            final JForEach jForEach = jIf.forEach(jEnum, "e", jEnum.staticInvoke("values"));
            jForEach.body()._if(jForEach.var().invoke("hasScheme").arg(jValue.invoke("getScheme")).cand(jForEach.var().invoke("hasValue").arg(jValue.invoke("getValue"))))._then()._return(jForEach.var());
            m.body()._return(JExpr._null());
        }
    } catch (final JCodeModelException ex) {
        LOGGER.error("Failed to create source", ex);
    }
}
Also used : ICommonsList(com.helger.commons.collection.impl.ICommonsList) IDocumentTypeIdentifier(com.helger.peppolid.IDocumentTypeIdentifier) JLambdaMethodRef(com.helger.jcodemodel.JLambdaMethodRef) LocalDate(java.time.LocalDate) IProcessIdentifier(com.helger.peppolid.IProcessIdentifier) IPeppolDocumentTypeIdentifierParts(com.helger.peppolid.peppol.doctype.IPeppolDocumentTypeIdentifierParts) PCLDocumentTypesType(com.helger.xsds.peppol.codelists2.PCLDocumentTypesType) JEnumConstant(com.helger.jcodemodel.JEnumConstant) Version(com.helger.commons.version.Version) JForEach(com.helger.jcodemodel.JForEach) CommonsHashSet(com.helger.commons.collection.impl.CommonsHashSet) JCodeModelException(com.helger.jcodemodel.JCodeModelException) JVar(com.helger.jcodemodel.JVar) JDefinedClass(com.helger.jcodemodel.JDefinedClass) QName(javax.xml.namespace.QName) PCLProcessIDType(com.helger.xsds.peppol.codelists2.PCLProcessIDType) JInvocation(com.helger.jcodemodel.JInvocation) EPeppolCodeListItemState(com.helger.peppolid.peppol.EPeppolCodeListItemState) PCLDocumentTypeType(com.helger.xsds.peppol.codelists2.PCLDocumentTypeType) JFieldVar(com.helger.jcodemodel.JFieldVar) PeppolDocumentTypeIdentifier(com.helger.peppolid.peppol.doctype.PeppolDocumentTypeIdentifier) JBlock(com.helger.jcodemodel.JBlock) JMethod(com.helger.jcodemodel.JMethod) CommonsArrayList(com.helger.commons.collection.impl.CommonsArrayList) Nullable(javax.annotation.Nullable)

Example 2 with IPeppolDocumentTypeIdentifierParts

use of com.helger.peppolid.peppol.doctype.IPeppolDocumentTypeIdentifierParts in project phase4 by phax.

the class Phase4PeppolSender method createSBDH.

/**
 * @param aSenderID
 *        Sender participant ID. May not be <code>null</code>.
 * @param aReceiverID
 *        Receiver participant ID. May not be <code>null</code>.
 * @param aDocTypeID
 *        Document type ID. May not be <code>null</code>.
 * @param aProcID
 *        Process ID. May not be <code>null</code>.
 * @param sInstanceIdentifier
 *        SBDH instance identifier. May be <code>null</code> to create a
 *        random ID.
 * @param sTypeVersion
 *        SBDH syntax version ID (e.g. "2.1" for OASIS UBL 2.1). May be
 *        <code>null</code> to use the default.
 * @param aPayloadElement
 *        Payload element to be wrapped. May not be <code>null</code>.
 * @return The domain object representation of the created SBDH or
 *         <code>null</code> if not all parameters are present.
 */
@Nullable
public static StandardBusinessDocument createSBDH(@Nonnull final IParticipantIdentifier aSenderID, @Nonnull final IParticipantIdentifier aReceiverID, @Nonnull final IDocumentTypeIdentifier aDocTypeID, @Nonnull final IProcessIdentifier aProcID, @Nullable final String sInstanceIdentifier, @Nullable final String sTypeVersion, @Nonnull final Element aPayloadElement) {
    final PeppolSBDHDocument aData = new PeppolSBDHDocument(IF);
    aData.setSender(aSenderID.getScheme(), aSenderID.getValue());
    aData.setReceiver(aReceiverID.getScheme(), aReceiverID.getValue());
    aData.setDocumentType(aDocTypeID.getScheme(), aDocTypeID.getValue());
    aData.setProcess(aProcID.getScheme(), aProcID.getValue());
    String sRealTypeVersion = sTypeVersion;
    if (StringHelper.hasNoText(sRealTypeVersion)) {
        // Determine from document type
        try {
            final IPeppolDocumentTypeIdentifierParts aParts = PeppolDocumentTypeIdentifierParts.extractFromIdentifier(aDocTypeID);
            sRealTypeVersion = aParts.getVersion();
        } catch (final IllegalArgumentException ex) {
        // failure
        }
    }
    if (StringHelper.hasNoText(sRealTypeVersion)) {
        LOGGER.warn("No TypeVersion was provided and none could be deduced from the document type identifier '" + aDocTypeID.getURIEncoded() + "'");
        return null;
    }
    String sRealInstanceIdentifier = sInstanceIdentifier;
    if (StringHelper.hasNoText(sRealInstanceIdentifier)) {
        sRealInstanceIdentifier = UUID.randomUUID().toString();
        if (LOGGER.isDebugEnabled())
            LOGGER.debug("As no SBDH InstanceIdentifier was provided, a random one was created: '" + sRealInstanceIdentifier + "'");
    }
    aData.setDocumentIdentification(aPayloadElement.getNamespaceURI(), sRealTypeVersion, aPayloadElement.getLocalName(), sRealInstanceIdentifier, XMLOffsetDateTime.of(MetaAS4Manager.getTimestampMgr().getCurrentDateTime()));
    aData.setBusinessMessage(aPayloadElement);
    return new PeppolSBDHDocumentWriter().createStandardBusinessDocument(aData);
}
Also used : IPeppolDocumentTypeIdentifierParts(com.helger.peppolid.peppol.doctype.IPeppolDocumentTypeIdentifierParts) PeppolSBDHDocument(com.helger.peppol.sbdh.PeppolSBDHDocument) PeppolSBDHDocumentWriter(com.helger.peppol.sbdh.write.PeppolSBDHDocumentWriter) Nullable(javax.annotation.Nullable)

Example 3 with IPeppolDocumentTypeIdentifierParts

use of com.helger.peppolid.peppol.doctype.IPeppolDocumentTypeIdentifierParts in project phoss-smp by phax.

the class AbstractPageSecureEndpoint method showSelectedObject.

@Override
protected void showSelectedObject(@Nonnull final WebPageExecutionContext aWPEC, @Nonnull final ISMPServiceInformation aSelectedObject) {
    final HCNodeList aNodeList = aWPEC.getNodeList();
    final Locale aDisplayLocale = aWPEC.getDisplayLocale();
    final IDocumentTypeIdentifier aDocumentTypeID = aSelectedObject.getDocumentTypeIdentifier();
    final ISMPProcess aSelectedProcess = aWPEC.getRequestScope().attrs().getCastedValue(REQUEST_ATTR_PROCESS);
    final ISMPEndpoint aSelectedEndpoint = aWPEC.getRequestScope().attrs().getCastedValue(REQUEST_ATTR_ENDPOINT);
    final LocalDateTime aNowLDT = PDTFactory.getCurrentLocalDateTime();
    aNodeList.addChild(getUIHandler().createActionHeader("Show details of endpoint"));
    final BootstrapViewForm aForm = new BootstrapViewForm();
    aForm.addFormGroup(new BootstrapFormGroup().setLabel("Service group").setCtrl(new HCA(createViewURL(aWPEC, CMenuSecure.MENU_SERVICE_GROUPS, aSelectedObject.getServiceGroup())).addChild(aSelectedObject.getServiceGroupID())));
    // Document type identifier
    {
        final HCNodeList aCtrl = new HCNodeList();
        aCtrl.addChild(div(NiceNameUI.getDocumentTypeID(aDocumentTypeID, true)));
        try {
            final IPeppolDocumentTypeIdentifierParts aParts = PeppolDocumentTypeIdentifierParts.extractFromIdentifier(aDocumentTypeID);
            aCtrl.addChild(SMPCommonUI.getDocumentTypeIDDetails(aParts));
        } catch (final IllegalArgumentException ex) {
            if (false)
                aCtrl.addChild(error("Failed to parse document type identifier: " + ex.getMessage()));
        }
        aForm.addFormGroup(new BootstrapFormGroup().setLabel("Document type ID").setCtrl(aCtrl));
    }
    aForm.addFormGroup(new BootstrapFormGroup().setLabel("Process ID").setCtrl(NiceNameUI.getProcessID(aSelectedObject.getDocumentTypeIdentifier(), aSelectedProcess.getProcessIdentifier(), true)));
    aForm.addFormGroup(new BootstrapFormGroup().setLabel("Transport profile").setCtrl(new HCA(createViewURL(aWPEC, CMenuSecure.MENU_TRANSPORT_PROFILES, aSelectedEndpoint.getTransportProfile())).addChild(NiceNameUI.getTransportProfile(aSelectedEndpoint.getTransportProfile(), true))));
    aForm.addFormGroup(new BootstrapFormGroup().setLabel("Endpoint reference").setCtrl(StringHelper.hasText(aSelectedEndpoint.getEndpointReference()) ? HCA.createLinkedWebsite(aSelectedEndpoint.getEndpointReference(), HC_Target.BLANK) : em("none")));
    aForm.addFormGroup(new BootstrapFormGroup().setLabel("Requires business level signature").setCtrl(EPhotonCoreText.getYesOrNo(aSelectedEndpoint.isRequireBusinessLevelSignature(), aDisplayLocale)));
    if (aSelectedEndpoint.hasMinimumAuthenticationLevel())
        aForm.addFormGroup(new BootstrapFormGroup().setLabel("Minimum authentication level").setCtrl(aSelectedEndpoint.getMinimumAuthenticationLevel()));
    if (aSelectedEndpoint.hasServiceActivationDateTime()) {
        aForm.addFormGroup(new BootstrapFormGroup().setLabel("Not before").setCtrl(PDTToString.getAsString(aSelectedEndpoint.getServiceActivationDateTime(), aDisplayLocale)));
    }
    if (aSelectedEndpoint.hasServiceExpirationDateTime()) {
        aForm.addFormGroup(new BootstrapFormGroup().setLabel("Not after").setCtrl(PDTToString.getAsString(aSelectedEndpoint.getServiceExpirationDateTime(), aDisplayLocale)));
    }
    if (aSelectedEndpoint.hasCertificate()) {
        final X509Certificate aEndpointCert = CertificateHelper.convertStringToCertficateOrNull(aSelectedEndpoint.getCertificate());
        aForm.addFormGroup(new BootstrapFormGroup().setLabel("Certificate").setCtrl(aEndpointCert == null ? strong("!!!FAILED TO INTERPRETE!!!") : SMPCommonUI.createCertificateDetailsTable(null, aEndpointCert, aNowLDT, aDisplayLocale).setResponsive(true)));
    }
    if (aSelectedEndpoint.hasServiceDescription())
        aForm.addFormGroup(new BootstrapFormGroup().setLabel("Service description").setCtrl(aSelectedEndpoint.getServiceDescription()));
    if (aSelectedEndpoint.hasTechnicalContactUrl())
        aForm.addFormGroup(new BootstrapFormGroup().setLabel("Technical contact").setCtrl(HCA_MailTo.createLinkedEmail(aSelectedEndpoint.getTechnicalContactUrl())));
    if (aSelectedEndpoint.hasTechnicalInformationUrl())
        aForm.addFormGroup(new BootstrapFormGroup().setLabel("Technical information").setCtrl(HCA.createLinkedWebsite(aSelectedEndpoint.getTechnicalInformationUrl(), HC_Target.BLANK)));
    if (aSelectedEndpoint.extensions().isNotEmpty())
        aForm.addFormGroup(new BootstrapFormGroup().setLabel("Extension").setCtrl(SMPCommonUI.getExtensionDisplay(aSelectedEndpoint)));
    aNodeList.addChild(aForm);
}
Also used : Locale(java.util.Locale) LocalDateTime(java.time.LocalDateTime) IPeppolDocumentTypeIdentifierParts(com.helger.peppolid.peppol.doctype.IPeppolDocumentTypeIdentifierParts) HCNodeList(com.helger.html.hc.impl.HCNodeList) HCA(com.helger.html.hc.html.textlevel.HCA) BootstrapViewForm(com.helger.photon.bootstrap4.form.BootstrapViewForm) IDocumentTypeIdentifier(com.helger.peppolid.IDocumentTypeIdentifier) ISMPEndpoint(com.helger.phoss.smp.domain.serviceinfo.ISMPEndpoint) BootstrapFormGroup(com.helger.photon.bootstrap4.form.BootstrapFormGroup) ISMPProcess(com.helger.phoss.smp.domain.serviceinfo.ISMPProcess) X509Certificate(java.security.cert.X509Certificate)

Aggregations

IPeppolDocumentTypeIdentifierParts (com.helger.peppolid.peppol.doctype.IPeppolDocumentTypeIdentifierParts)3 IDocumentTypeIdentifier (com.helger.peppolid.IDocumentTypeIdentifier)2 Nullable (javax.annotation.Nullable)2 CommonsArrayList (com.helger.commons.collection.impl.CommonsArrayList)1 CommonsHashSet (com.helger.commons.collection.impl.CommonsHashSet)1 ICommonsList (com.helger.commons.collection.impl.ICommonsList)1 Version (com.helger.commons.version.Version)1 HCA (com.helger.html.hc.html.textlevel.HCA)1 HCNodeList (com.helger.html.hc.impl.HCNodeList)1 JBlock (com.helger.jcodemodel.JBlock)1 JCodeModelException (com.helger.jcodemodel.JCodeModelException)1 JDefinedClass (com.helger.jcodemodel.JDefinedClass)1 JEnumConstant (com.helger.jcodemodel.JEnumConstant)1 JFieldVar (com.helger.jcodemodel.JFieldVar)1 JForEach (com.helger.jcodemodel.JForEach)1 JInvocation (com.helger.jcodemodel.JInvocation)1 JLambdaMethodRef (com.helger.jcodemodel.JLambdaMethodRef)1 JMethod (com.helger.jcodemodel.JMethod)1 JVar (com.helger.jcodemodel.JVar)1 PeppolSBDHDocument (com.helger.peppol.sbdh.PeppolSBDHDocument)1