Search in sources :

Example 11 with SimpleDocumentTypeIdentifier

use of com.helger.peppolid.simple.doctype.SimpleDocumentTypeIdentifier in project phoss-smp by phax.

the class SMPServiceInformationManagerJDBC method getAllSMPServiceInformation.

@Nonnull
@ReturnsMutableCopy
public ICommonsList<ISMPServiceInformation> getAllSMPServiceInformation() {
    final ICommonsList<ISMPServiceInformation> ret = new CommonsArrayList<>();
    final ICommonsList<DBResultRow> aDBResult = newExecutor().queryAll("SELECT sm.businessIdentifierScheme, sm.businessIdentifier, sm.documentIdentifierScheme, sm.documentIdentifier, sm.extension," + "   sp.processIdentifierType, sp.processIdentifier, sp.extension," + "   se.transportProfile, se.endpointReference, se.requireBusinessLevelSignature, se.minimumAuthenticationLevel," + "     se.serviceActivationDate, se.serviceExpirationDate, se.certificate, se.serviceDescription," + "     se.technicalContactUrl, se.technicalInformationUrl, se.extension" + " FROM smp_service_metadata AS sm" + " INNER JOIN smp_process AS sp" + "   ON sm.businessIdentifierScheme=sp.businessIdentifierScheme AND sm.businessIdentifier=sp.businessIdentifier" + "   AND sm.documentIdentifierScheme=sp.documentIdentifierScheme AND sm.documentIdentifier=sp.documentIdentifier" + " INNER JOIN smp_endpoint AS se" + "   ON sp.businessIdentifierScheme=se.businessIdentifierScheme AND sp.businessIdentifier=se.businessIdentifier" + "   AND sp.documentIdentifierScheme=se.documentIdentifierScheme AND sp.documentIdentifier=se.documentIdentifier" + "   AND sp.processIdentifierType=se.processIdentifierType AND sp.processIdentifier=se.processIdentifier");
    final ICommonsMap<IParticipantIdentifier, ICommonsMap<DocTypeAndExtension, ICommonsMap<SMPProcess, ICommonsList<SMPEndpoint>>>> aGrouping = new CommonsHashMap<>();
    if (aDBResult != null)
        for (final DBResultRow aDBRow : aDBResult) {
            // Participant ID
            final IParticipantIdentifier aParticipantID = new SimpleParticipantIdentifier(aDBRow.getAsString(0), aDBRow.getAsString(1));
            // Document type ID and extension
            final IDocumentTypeIdentifier aDocTypeID = new SimpleDocumentTypeIdentifier(aDBRow.getAsString(2), aDBRow.getAsString(3));
            final String sServiceInformationExtension = aDBRow.getAsString(4);
            // Process without endpoints
            final SMPProcess aProcess = new SMPProcess(new SimpleProcessIdentifier(aDBRow.getAsString(5), aDBRow.getAsString(6)), null, aDBRow.getAsString(7));
            // Don't add endpoint to process, because that impacts
            // SMPProcess.equals/hashcode
            final SMPEndpoint aEndpoint = new SMPEndpoint(aDBRow.getAsString(8), aDBRow.getAsString(9), aDBRow.getAsBoolean(10, SMPEndpoint.DEFAULT_REQUIRES_BUSINESS_LEVEL_SIGNATURE), aDBRow.getAsString(11), aDBRow.getAsXMLOffsetDateTime(12), aDBRow.getAsXMLOffsetDateTime(13), aDBRow.getAsString(14), aDBRow.getAsString(15), aDBRow.getAsString(16), aDBRow.getAsString(17), aDBRow.getAsString(18));
            aGrouping.computeIfAbsent(aParticipantID, k -> new CommonsHashMap<>()).computeIfAbsent(new DocTypeAndExtension(aDocTypeID, sServiceInformationExtension), k -> new CommonsHashMap<>()).computeIfAbsent(aProcess, k -> new CommonsArrayList<>()).add(aEndpoint);
        }
    // Per participant ID
    for (final Map.Entry<IParticipantIdentifier, ICommonsMap<DocTypeAndExtension, ICommonsMap<SMPProcess, ICommonsList<SMPEndpoint>>>> aEntry : aGrouping.entrySet()) {
        final ISMPServiceGroup aServiceGroup = m_aServiceGroupMgr.getSMPServiceGroupOfID(aEntry.getKey());
        if (aServiceGroup == null)
            throw new IllegalStateException("Failed to resolve service group for participant ID '" + aEntry.getKey().getURIEncoded() + "'");
        // Per document type ID
        for (final Map.Entry<DocTypeAndExtension, ICommonsMap<SMPProcess, ICommonsList<SMPEndpoint>>> aEntry2 : aEntry.getValue().entrySet()) {
            // Flatten list
            final ICommonsList<SMPProcess> aProcesses = new CommonsArrayList<>();
            for (final Map.Entry<SMPProcess, ICommonsList<SMPEndpoint>> aEntry3 : aEntry2.getValue().entrySet()) {
                final SMPProcess aProcess = aEntry3.getKey();
                aProcess.addEndpoints(aEntry3.getValue());
                aProcesses.add(aProcess);
            }
            final DocTypeAndExtension aDE = aEntry2.getKey();
            ret.add(new SMPServiceInformation(aServiceGroup, aDE.m_aDocTypeID, aProcesses, aDE.m_sExt));
        }
    }
    return ret;
}
Also used : ESuccess(com.helger.commons.state.ESuccess) Nonnegative(javax.annotation.Nonnegative) IDocumentTypeIdentifier(com.helger.peppolid.IDocumentTypeIdentifier) SimpleProcessIdentifier(com.helger.peppolid.simple.process.SimpleProcessIdentifier) MustImplementEqualsAndHashcode(com.helger.commons.annotation.MustImplementEqualsAndHashcode) EChange(com.helger.commons.state.EChange) SMPServiceInformation(com.helger.phoss.smp.domain.serviceinfo.SMPServiceInformation) Supplier(java.util.function.Supplier) CallbackList(com.helger.commons.callback.CallbackList) DBValueHelper(com.helger.db.api.helper.DBValueHelper) IProcessIdentifier(com.helger.peppolid.IProcessIdentifier) AbstractJDBCEnabledManager(com.helger.db.jdbc.mgr.AbstractJDBCEnabledManager) ISMPServiceGroup(com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroup) MutableBoolean(com.helger.commons.mutable.MutableBoolean) SMPProcess(com.helger.phoss.smp.domain.serviceinfo.SMPProcess) Map(java.util.Map) DBExecutor(com.helger.db.jdbc.executor.DBExecutor) ISMPServiceInformationCallback(com.helger.phoss.smp.domain.serviceinfo.ISMPServiceInformationCallback) ReturnsMutableCopy(com.helger.commons.annotation.ReturnsMutableCopy) IParticipantIdentifier(com.helger.peppolid.IParticipantIdentifier) Nonnull(javax.annotation.Nonnull) Nullable(javax.annotation.Nullable) HashCodeGenerator(com.helger.commons.hashcode.HashCodeGenerator) SMPEndpoint(com.helger.phoss.smp.domain.serviceinfo.SMPEndpoint) CommonsArrayList(com.helger.commons.collection.impl.CommonsArrayList) ConstantPreparedStatementDataProvider(com.helger.db.jdbc.callback.ConstantPreparedStatementDataProvider) SimpleDocumentTypeIdentifier(com.helger.peppolid.simple.doctype.SimpleDocumentTypeIdentifier) StringHelper(com.helger.commons.string.StringHelper) SimpleParticipantIdentifier(com.helger.peppolid.simple.participant.SimpleParticipantIdentifier) ISMPProcess(com.helger.phoss.smp.domain.serviceinfo.ISMPProcess) EqualsHelper(com.helger.commons.equals.EqualsHelper) ValueEnforcer(com.helger.commons.ValueEnforcer) DBResultRow(com.helger.db.jdbc.executor.DBResultRow) CommonsHashMap(com.helger.commons.collection.impl.CommonsHashMap) AuditHelper(com.helger.photon.audit.AuditHelper) ISMPServiceInformationManager(com.helger.phoss.smp.domain.serviceinfo.ISMPServiceInformationManager) ICommonsList(com.helger.commons.collection.impl.ICommonsList) Wrapper(com.helger.commons.wrapper.Wrapper) ISMPServiceInformation(com.helger.phoss.smp.domain.serviceinfo.ISMPServiceInformation) ISMPEndpoint(com.helger.phoss.smp.domain.serviceinfo.ISMPEndpoint) ReturnsMutableObject(com.helger.commons.annotation.ReturnsMutableObject) ICommonsMap(com.helger.commons.collection.impl.ICommonsMap) ISMPTransportProfile(com.helger.peppol.smp.ISMPTransportProfile) ISMPServiceGroupManager(com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroupManager) ICommonsList(com.helger.commons.collection.impl.ICommonsList) SimpleDocumentTypeIdentifier(com.helger.peppolid.simple.doctype.SimpleDocumentTypeIdentifier) IDocumentTypeIdentifier(com.helger.peppolid.IDocumentTypeIdentifier) ICommonsMap(com.helger.commons.collection.impl.ICommonsMap) SimpleParticipantIdentifier(com.helger.peppolid.simple.participant.SimpleParticipantIdentifier) SMPProcess(com.helger.phoss.smp.domain.serviceinfo.SMPProcess) ISMPProcess(com.helger.phoss.smp.domain.serviceinfo.ISMPProcess) SimpleProcessIdentifier(com.helger.peppolid.simple.process.SimpleProcessIdentifier) CommonsHashMap(com.helger.commons.collection.impl.CommonsHashMap) ISMPServiceGroup(com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroup) SMPServiceInformation(com.helger.phoss.smp.domain.serviceinfo.SMPServiceInformation) ISMPServiceInformation(com.helger.phoss.smp.domain.serviceinfo.ISMPServiceInformation) SMPEndpoint(com.helger.phoss.smp.domain.serviceinfo.SMPEndpoint) ISMPEndpoint(com.helger.phoss.smp.domain.serviceinfo.ISMPEndpoint) ISMPServiceInformation(com.helger.phoss.smp.domain.serviceinfo.ISMPServiceInformation) DBResultRow(com.helger.db.jdbc.executor.DBResultRow) Map(java.util.Map) CommonsHashMap(com.helger.commons.collection.impl.CommonsHashMap) ICommonsMap(com.helger.commons.collection.impl.ICommonsMap) CommonsArrayList(com.helger.commons.collection.impl.CommonsArrayList) IParticipantIdentifier(com.helger.peppolid.IParticipantIdentifier) ReturnsMutableCopy(com.helger.commons.annotation.ReturnsMutableCopy) Nonnull(javax.annotation.Nonnull)

Example 12 with SimpleDocumentTypeIdentifier

use of com.helger.peppolid.simple.doctype.SimpleDocumentTypeIdentifier in project phoss-smp by phax.

the class SMPServiceInformation method getAsJAXBObjectPeppol.

@Nullable
public com.helger.xsds.peppol.smp1.ServiceMetadataType getAsJAXBObjectPeppol() {
    if (m_aProcesses.isEmpty()) {
        // "ProcessList" is mandatory and MUST contain at least 1 value
        return null;
    }
    final com.helger.xsds.peppol.smp1.ServiceInformationType aSI = new com.helger.xsds.peppol.smp1.ServiceInformationType();
    // Explicit constructor call is needed here!
    aSI.setParticipantIdentifier(new SimpleParticipantIdentifier(m_aServiceGroup.getParticipantIdentifier()));
    aSI.setDocumentIdentifier(new SimpleDocumentTypeIdentifier(m_aDocumentTypeIdentifier));
    final com.helger.xsds.peppol.smp1.ProcessListType aProcesses = new com.helger.xsds.peppol.smp1.ProcessListType();
    for (final ISMPProcess aProcess : m_aProcesses.values()) {
        final com.helger.xsds.peppol.smp1.ProcessType aJAXBProcess = aProcess.getAsJAXBObjectPeppol();
        if (aJAXBProcess != null)
            aProcesses.addProcess(aJAXBProcess);
    }
    if (aProcesses.hasNoProcessEntries()) {
        // "ProcessList" is mandatory and MUST contain at least 1 value
        return null;
    }
    aSI.setProcessList(aProcesses);
    aSI.setExtension(getAsPeppolExtension());
    final com.helger.xsds.peppol.smp1.ServiceMetadataType ret = new com.helger.xsds.peppol.smp1.ServiceMetadataType();
    ret.setServiceInformation(aSI);
    return ret;
}
Also used : SimpleDocumentTypeIdentifier(com.helger.peppolid.simple.doctype.SimpleDocumentTypeIdentifier) SimpleParticipantIdentifier(com.helger.peppolid.simple.participant.SimpleParticipantIdentifier) Nullable(javax.annotation.Nullable)

Example 13 with SimpleDocumentTypeIdentifier

use of com.helger.peppolid.simple.doctype.SimpleDocumentTypeIdentifier in project phoss-smp by phax.

the class SMPServiceInformationMicroTypeConverter method convertToNative.

@Nonnull
public static SMPServiceInformation convertToNative(@Nonnull final IMicroElement aElement, @Nonnull final ISMPServiceGroupProvider aSGProvider) {
    final IIdentifierFactory aIdentifierFactory = SMPMetaManager.getIdentifierFactory();
    final String sServiceGroupID = aElement.getAttributeValue(ATTR_SERVICE_GROUP_ID);
    final ISMPServiceGroup aServiceGroup = aSGProvider.getSMPServiceGroupOfID(aIdentifierFactory.parseParticipantIdentifier(sServiceGroupID));
    if (aServiceGroup == null)
        throw new IllegalStateException("Failed to resolve service group with ID '" + sServiceGroupID + "'");
    final SimpleDocumentTypeIdentifier aDocTypeIdentifier = MicroTypeConverter.convertToNative(aElement.getFirstChildElement(ELEMENT_DOCUMENT_TYPE_IDENTIFIER), SimpleDocumentTypeIdentifier.class);
    final ICommonsList<SMPProcess> aProcesses = new CommonsArrayList<>();
    for (final IMicroElement aProcess : aElement.getAllChildElements(ELEMENT_PROCESS)) aProcesses.add(MicroTypeConverter.convertToNative(aProcess, SMPProcess.class));
    final String sExtension = MicroHelper.getChildTextContentTrimmed(aElement, ELEMENT_EXTENSION);
    return new SMPServiceInformation(aServiceGroup, aDocTypeIdentifier, aProcesses, sExtension);
}
Also used : SimpleDocumentTypeIdentifier(com.helger.peppolid.simple.doctype.SimpleDocumentTypeIdentifier) ISMPServiceGroup(com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroup) IMicroElement(com.helger.xml.microdom.IMicroElement) IIdentifierFactory(com.helger.peppolid.factory.IIdentifierFactory) CommonsArrayList(com.helger.commons.collection.impl.CommonsArrayList) Nonnull(javax.annotation.Nonnull)

Example 14 with SimpleDocumentTypeIdentifier

use of com.helger.peppolid.simple.doctype.SimpleDocumentTypeIdentifier in project phoss-smp by phax.

the class SMPRedirectMicroTypeConverter method convertToNative.

@Nonnull
public static SMPRedirect convertToNative(@Nonnull final IMicroElement aElement, @Nonnull final ISMPServiceGroupProvider aSGProvider) {
    final IIdentifierFactory aIdentifierFactory = SMPMetaManager.getIdentifierFactory();
    final String sServiceGroupID = aElement.getAttributeValue(ATTR_SERVICE_GROUPD_ID);
    final ISMPServiceGroup aServiceGroup = aSGProvider.getSMPServiceGroupOfID(aIdentifierFactory.parseParticipantIdentifier(sServiceGroupID));
    if (aServiceGroup == null)
        throw new IllegalStateException("Failed to resolve service group with ID '" + sServiceGroupID + "'");
    final SimpleDocumentTypeIdentifier aDocTypeIdentifier = MicroTypeConverter.convertToNative(aElement.getFirstChildElement(ELEMENT_DOCUMENT_TYPE_IDENTIFIER), SimpleDocumentTypeIdentifier.class);
    final String sTargetHref = aElement.getAttributeValue(ATTR_TARGET_HREF);
    final String sSubjectUniqueIdentifier = MicroHelper.getChildTextContentTrimmed(aElement, ELEMENT_CERTIFICATE_SUID);
    final X509Certificate aCertificate = CertificateHelper.convertStringToCertficateOrNull(MicroHelper.getChildTextContentTrimmed(aElement, ELEMENT_CERTIFICATE));
    final String sExtension = MicroHelper.getChildTextContentTrimmed(aElement, ELEMENT_EXTENSION);
    return new SMPRedirect(aServiceGroup, aDocTypeIdentifier, sTargetHref, sSubjectUniqueIdentifier, aCertificate, sExtension);
}
Also used : SimpleDocumentTypeIdentifier(com.helger.peppolid.simple.doctype.SimpleDocumentTypeIdentifier) ISMPServiceGroup(com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroup) IIdentifierFactory(com.helger.peppolid.factory.IIdentifierFactory) X509Certificate(java.security.cert.X509Certificate) Nonnull(javax.annotation.Nonnull)

Example 15 with SimpleDocumentTypeIdentifier

use of com.helger.peppolid.simple.doctype.SimpleDocumentTypeIdentifier in project phoss-directory by phax.

the class PDExtendedBusinessCard method of.

@Nonnull
public static PDExtendedBusinessCard of(@Nonnull final IJsonObject aJson) {
    final PDBusinessCard aBC = PDBusinessCard.of(aJson.getAsObject("businesscard"));
    final ICommonsList<IDocumentTypeIdentifier> aDocTypes = CommonsArrayList.createFiltered(aJson.getAsArray("doctypes"), (Predicate<IJson>) IJson::isObject, x -> new SimpleDocumentTypeIdentifier(x.getAsObject().getAsString("scheme"), x.getAsObject().getAsString("value")));
    return new PDExtendedBusinessCard(aBC, aDocTypes);
}
Also used : PDBusinessCard(com.helger.pd.businesscard.generic.PDBusinessCard) SimpleDocumentTypeIdentifier(com.helger.peppolid.simple.doctype.SimpleDocumentTypeIdentifier) IDocumentTypeIdentifier(com.helger.peppolid.IDocumentTypeIdentifier) IJson(com.helger.json.IJson) Nonnull(javax.annotation.Nonnull)

Aggregations

SimpleDocumentTypeIdentifier (com.helger.peppolid.simple.doctype.SimpleDocumentTypeIdentifier)15 IDocumentTypeIdentifier (com.helger.peppolid.IDocumentTypeIdentifier)10 IParticipantIdentifier (com.helger.peppolid.IParticipantIdentifier)10 SimpleParticipantIdentifier (com.helger.peppolid.simple.participant.SimpleParticipantIdentifier)9 Nonnull (javax.annotation.Nonnull)8 ISMPServiceGroup (com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroup)7 CommonsArrayList (com.helger.commons.collection.impl.CommonsArrayList)6 IProcessIdentifier (com.helger.peppolid.IProcessIdentifier)6 SimpleProcessIdentifier (com.helger.peppolid.simple.process.SimpleProcessIdentifier)6 ReturnsMutableCopy (com.helger.commons.annotation.ReturnsMutableCopy)5 DBResultRow (com.helger.db.jdbc.executor.DBResultRow)5 Test (org.junit.Test)5 ConstantPreparedStatementDataProvider (com.helger.db.jdbc.callback.ConstantPreparedStatementDataProvider)4 SMPServiceGroup (com.helger.phoss.smp.domain.servicegroup.SMPServiceGroup)4 X509Certificate (java.security.cert.X509Certificate)3 ValueEnforcer (com.helger.commons.ValueEnforcer)2 MustImplementEqualsAndHashcode (com.helger.commons.annotation.MustImplementEqualsAndHashcode)2 ReturnsMutableObject (com.helger.commons.annotation.ReturnsMutableObject)2 CallbackList (com.helger.commons.callback.CallbackList)2 CommonsHashMap (com.helger.commons.collection.impl.CommonsHashMap)2