use of com.helger.peppolid.simple.participant.SimpleParticipantIdentifier 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;
}
use of com.helger.peppolid.simple.participant.SimpleParticipantIdentifier in project phoss-smp by phax.
the class SMPParticipantMigrationManagerMongoDBTest method testConversion.
@Test
public void testConversion() {
final SMPParticipantMigration a = SMPParticipantMigration.createInbound(new SimpleParticipantIdentifier("iso6523-actorid-upis", "9901:test"), "abc123");
final Document d = SMPParticipantMigrationManagerMongoDB.toBson(a);
assertNotNull(d);
final SMPParticipantMigration a2 = SMPParticipantMigrationManagerMongoDB.toDomain(d);
assertNotNull(a2);
assertEquals(a, a2);
assertEquals(d, SMPParticipantMigrationManagerMongoDB.toBson(a2));
}
use of com.helger.peppolid.simple.participant.SimpleParticipantIdentifier 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;
}
Aggregations