use of com.helger.db.jdbc.executor.DBResultRow in project phoss-smp by phax.
the class SMPServiceGroupManagerJDBC method getAllSMPServiceGroupsOfOwner.
@Nonnull
@ReturnsMutableCopy
public ICommonsList<ISMPServiceGroup> getAllSMPServiceGroupsOfOwner(@Nonnull final String sOwnerID) {
if (LOGGER.isDebugEnabled())
LOGGER.debug("getAllSMPServiceGroupsOfOwner(" + sOwnerID + ")");
final ICommonsList<DBResultRow> aDBResult = newExecutor().queryAll("SELECT sg.businessIdentifierScheme, sg.businessIdentifier, sg.extension" + " FROM smp_service_group sg, smp_ownership so" + " WHERE so.username=?" + " AND so.businessIdentifierScheme=sg.businessIdentifierScheme AND so.businessIdentifier=sg.businessIdentifier", new ConstantPreparedStatementDataProvider(sOwnerID));
final ICommonsList<ISMPServiceGroup> ret = new CommonsArrayList<>();
if (aDBResult != null)
for (final DBResultRow aRow : aDBResult) ret.add(new SMPServiceGroup(sOwnerID, new SimpleParticipantIdentifier(aRow.getAsString(0), aRow.getAsString(1)), aRow.getAsString(2)));
return ret;
}
use of com.helger.db.jdbc.executor.DBResultRow 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.db.jdbc.executor.DBResultRow in project phoss-smp by phax.
the class SMPServiceInformationManagerJDBC method getSMPServiceInformationOfServiceGroupAndDocumentType.
@Nullable
public ISMPServiceInformation getSMPServiceInformationOfServiceGroupAndDocumentType(@Nullable final ISMPServiceGroup aServiceGroup, @Nullable final IDocumentTypeIdentifier aDocTypeID) {
if (aServiceGroup == null)
return null;
if (aDocTypeID == null)
return null;
final IParticipantIdentifier aPID = aServiceGroup.getParticipantIdentifier();
final ICommonsList<DBResultRow> aDBResult = newExecutor().queryAll("SELECT 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" + " WHERE sm.businessIdentifierScheme=? AND sm.businessIdentifier=? AND sm.documentIdentifierScheme=? AND sm.documentIdentifier=?", new ConstantPreparedStatementDataProvider(aPID.getScheme(), aPID.getValue(), aDocTypeID.getScheme(), aDocTypeID.getValue()));
if (aDBResult != null && aDBResult.isNotEmpty()) {
final String sServiceInformationExtension = aDBResult.getFirst().getAsString(0);
final ICommonsMap<SMPProcess, ICommonsList<SMPEndpoint>> aEndpoints = new CommonsHashMap<>();
for (final DBResultRow aDBRow : aDBResult) {
// Process without endpoints as key
final SMPProcess aProcess = new SMPProcess(new SimpleProcessIdentifier(aDBRow.getAsString(1), aDBRow.getAsString(2)), null, aDBRow.getAsString(3));
final SMPEndpoint aEndpoint = new SMPEndpoint(aDBRow.getAsString(4), aDBRow.getAsString(5), aDBRow.getAsBoolean(6, SMPEndpoint.DEFAULT_REQUIRES_BUSINESS_LEVEL_SIGNATURE), aDBRow.getAsString(7), aDBRow.getAsXMLOffsetDateTime(8), aDBRow.getAsXMLOffsetDateTime(9), aDBRow.getAsString(10), aDBRow.getAsString(11), aDBRow.getAsString(12), aDBRow.getAsString(13), aDBRow.getAsString(14));
aEndpoints.computeIfAbsent(aProcess, k -> new CommonsArrayList<>()).add(aEndpoint);
}
// Flatten list
final ICommonsList<SMPProcess> aProcesses = new CommonsArrayList<>();
for (final Map.Entry<SMPProcess, ICommonsList<SMPEndpoint>> aEntry : aEndpoints.entrySet()) {
final SMPProcess aProcess = aEntry.getKey();
aProcess.addEndpoints(aEntry.getValue());
aProcesses.add(aProcess);
}
return new SMPServiceInformation(aServiceGroup, aDocTypeID, aProcesses, sServiceInformationExtension);
}
return null;
}
use of com.helger.db.jdbc.executor.DBResultRow in project phoss-smp by phax.
the class SMPBusinessCardManagerJDBC method getSMPBusinessCardOfID.
@Nullable
public ISMPBusinessCard getSMPBusinessCardOfID(@Nullable final IParticipantIdentifier aID) {
if (aID == null)
return null;
final ICommonsList<DBResultRow> aDBResult = newExecutor().queryAll("SELECT id, name, country, geoinfo, identifiers, websites, contacts, addon, regdate" + " FROM smp_bce" + " WHERE pid=?", new ConstantPreparedStatementDataProvider(aID.getURIEncoded()));
if (aDBResult == null)
return null;
if (aDBResult.isEmpty())
return null;
final ICommonsList<SMPBusinessCardEntity> aEntities = new CommonsArrayList<>();
for (final DBResultRow aRow : aDBResult) {
final SMPBusinessCardEntity aEntity = new SMPBusinessCardEntity(aRow.getAsString(0));
// Single name only
aEntity.names().add(new SMPBusinessCardName(aRow.getAsString(1), null));
aEntity.setCountryCode(aRow.getAsString(2));
aEntity.setGeographicalInformation(aRow.getAsString(3));
aEntity.identifiers().setAll(getJsonAsBCI(aRow.getAsString(4)));
aEntity.websiteURIs().setAll(getJsonAsString(aRow.getAsString(5)));
aEntity.contacts().setAll(getJsonAsBCC(aRow.getAsString(6)));
aEntity.setAdditionalInformation(aRow.getAsString(7));
aEntity.setRegistrationDate(aRow.get(8).getAsLocalDate());
aEntities.add(aEntity);
}
return new SMPBusinessCard(aID, aEntities);
}
use of com.helger.db.jdbc.executor.DBResultRow in project phoss-smp by phax.
the class SMPBusinessCardManagerJDBC method getAllSMPBusinessCards.
@Nonnull
@ReturnsMutableCopy
public ICommonsList<ISMPBusinessCard> getAllSMPBusinessCards() {
final ICommonsList<ISMPBusinessCard> ret = new CommonsArrayList<>();
final ICommonsList<DBResultRow> aDBResult = newExecutor().queryAll("SELECT id, pid, name, country, geoinfo, identifiers, websites, contacts, addon, regdate" + " FROM smp_bce");
if (aDBResult != null) {
final IIdentifierFactory aIF = SMPMetaManager.getIdentifierFactory();
// Group by ID
final ICommonsMap<IParticipantIdentifier, ICommonsList<SMPBusinessCardEntity>> aEntityMap = new CommonsHashMap<>();
for (final DBResultRow aRow : aDBResult) {
final SMPBusinessCardEntity aEntity = new SMPBusinessCardEntity(aRow.getAsString(0));
// Single name only
aEntity.names().add(new SMPBusinessCardName(aRow.getAsString(2), null));
aEntity.setCountryCode(aRow.getAsString(3));
aEntity.setGeographicalInformation(aRow.getAsString(4));
aEntity.identifiers().setAll(getJsonAsBCI(aRow.getAsString(5)));
aEntity.websiteURIs().setAll(getJsonAsString(aRow.getAsString(6)));
aEntity.contacts().setAll(getJsonAsBCC(aRow.getAsString(7)));
aEntity.setAdditionalInformation(aRow.getAsString(8));
aEntity.setRegistrationDate(aRow.get(9).getAsLocalDate());
aEntityMap.computeIfAbsent(aIF.parseParticipantIdentifier(aRow.getAsString(1)), k -> new CommonsArrayList<>()).add(aEntity);
}
// Convert
for (final Map.Entry<IParticipantIdentifier, ICommonsList<SMPBusinessCardEntity>> aEntry : aEntityMap.entrySet()) {
final IParticipantIdentifier aPID = aEntry.getKey();
ret.add(new SMPBusinessCard(aPID, aEntry.getValue()));
}
}
return ret;
}
Aggregations