use of com.helger.html.hc.html.grouping.HCLI in project phoss-directory by phax.
the class AbstractPagePublicSearch method createParticipantDetails.
@Nonnull
protected HCNodeList createParticipantDetails(@Nonnull final Locale aDisplayLocale, @Nonnull final String sParticipantID, @Nonnull final IParticipantIdentifier aParticipantID, final boolean bIsLoggedInUserAdministrator) {
final HCNodeList aDetails = new HCNodeList();
// Search document matching participant ID
final ICommonsList<PDStoredBusinessEntity> aResultDocs = PDMetaManager.getStorageMgr().getAllDocumentsOfParticipant(aParticipantID);
// Group by participant ID
final ICommonsMap<IParticipantIdentifier, ICommonsList<PDStoredBusinessEntity>> aGroupedDocs = PDStorageManager.getGroupedByParticipantID(aResultDocs);
if (aGroupedDocs.isEmpty())
LOGGER.error("No stored document matches participant identifier '" + sParticipantID + "' - cannot show details");
else {
if (aGroupedDocs.size() > 1)
LOGGER.warn("Found " + aGroupedDocs.size() + " entries for participant identifier '" + sParticipantID + "' - weird");
// Get the first one
final ICommonsList<PDStoredBusinessEntity> aStoredEntities = aGroupedDocs.getFirstValue();
// Details header
{
IHCNode aDetailsHeader = null;
final boolean bIsPeppolDefault = aParticipantID.hasScheme(PeppolIdentifierFactory.INSTANCE.getDefaultParticipantIdentifierScheme());
if (bIsPeppolDefault) {
final IParticipantIdentifierScheme aIIA = ParticipantIdentifierSchemeManager.getSchemeOfIdentifier(aParticipantID);
if (aIIA != null) {
final HCH1 aH1 = h1("Details for: " + aParticipantID.getValue());
if (StringHelper.hasText(aIIA.getSchemeAgency()))
aH1.addChild(small(" (" + aIIA.getSchemeAgency() + ")"));
aDetailsHeader = new BootstrapPageHeader().addChild(aH1);
}
}
if (aDetailsHeader == null) {
// Fallback
aDetailsHeader = BootstrapWebPageUIHandler.INSTANCE.createPageHeader("Details for " + sParticipantID);
}
aDetails.addChild(aDetailsHeader);
}
final BootstrapTabBox aTabBox = new BootstrapTabBox();
// Business information
{
final HCNodeList aOL = new HCNodeList();
int nIndex = 1;
for (final PDStoredBusinessEntity aStoredEntity : aStoredEntities) {
final BootstrapCard aCard = aOL.addAndReturnChild(new BootstrapCard());
aCard.addClass(CSS_CLASS_RESULT_PANEL);
if (aStoredEntities.size() > 1)
aCard.createAndAddHeader().addChild("Business information entity " + nIndex);
final BootstrapViewForm aViewForm = PDCommonUI.showBusinessInfoDetails(aStoredEntity, aDisplayLocale);
aViewForm.addFormGroup(new BootstrapFormGroup().setLabel("Full Peppol participant ID").setCtrl(code(sParticipantID)));
if (GlobalDebug.isDebugMode() || bIsLoggedInUserAdministrator) {
aViewForm.addChild(new HCHR());
aViewForm.addFormGroup(new BootstrapFormGroup().setLabel("[Debug] Creation DT").setCtrl(PDTToString.getAsString(aStoredEntity.getMetaData().getCreationDT(), aDisplayLocale)));
aViewForm.addFormGroup(new BootstrapFormGroup().setLabel("[Debug] Owner ID").setCtrl(code(aStoredEntity.getMetaData().getOwnerID())));
aViewForm.addFormGroup(new BootstrapFormGroup().setLabel("[Debug] Requesting Host").setCtrl(code(aStoredEntity.getMetaData().getRequestingHost())));
}
aCard.createAndAddBody().addChild(aViewForm);
++nIndex;
}
// Add whole list or just the first item?
final IHCNode aTabLabel = span("Business information ").addChild(badgePrimary(aStoredEntities.size()));
aTabBox.addTab("businessinfo", aTabLabel, aOL, true);
}
// Document types
{
final HCNodeList aDocTypeCtrl = new HCNodeList();
final ICommonsList<String> aNames = new CommonsArrayList<>();
for (final PDStoredBusinessEntity aStoredEntity : aStoredEntities) aNames.addAllMapped(aStoredEntity.names(), PDStoredMLName::getName);
aDocTypeCtrl.addChild(info("The following document types are supported by " + _getImplodedMapped(", ", " and ", aNames, x -> "'" + x + "'") + ":"));
HCOL aDocTypeOL = null;
final ICommonsList<IDocumentTypeIdentifier> aDocTypeIDs = aResultDocs.getFirst().documentTypeIDs().getSorted(IDocumentTypeIdentifier.comparator());
for (final IDocumentTypeIdentifier aDocTypeID : aDocTypeIDs) {
if (aDocTypeOL == null)
aDocTypeOL = aDocTypeCtrl.addAndReturnChild(new HCOL());
final HCLI aLI = aDocTypeOL.addItem();
aLI.addChild(NiceNameUI.getDocumentTypeID(aDocTypeID));
}
if (aDocTypeOL == null)
aDocTypeCtrl.addChild(warn("This participant does not support any document types!"));
aTabBox.addTab("doctypes", span("Supported document types ").addChild(badgePrimary(aDocTypeIDs.size())), aDocTypeCtrl, false);
}
aDetails.addChild(aTabBox);
}
return aDetails;
}
use of com.helger.html.hc.html.grouping.HCLI in project phoss-smp by phax.
the class PageSecureEndpointTree method showListOfExistingObjects.
@Override
protected void showListOfExistingObjects(@Nonnull final WebPageExecutionContext aWPEC) {
final HCNodeList aNodeList = aWPEC.getNodeList();
final ISMPServiceGroupManager aServiceGroupMgr = SMPMetaManager.getServiceGroupMgr();
final ISMPServiceInformationManager aServiceInfoMgr = SMPMetaManager.getServiceInformationMgr();
final BootstrapButtonToolbar aToolbar = new BootstrapButtonToolbar(aWPEC);
aToolbar.addButton("Create new Endpoint", createCreateURL(aWPEC), EDefaultIcon.NEW);
aToolbar.addButton("Refresh", aWPEC.getSelfHref(), EDefaultIcon.REFRESH);
aToolbar.addButton("List view", aWPEC.getLinkToMenuItem(CMenuSecure.MENU_ENDPOINT_LIST), EDefaultIcon.MAGNIFIER);
aNodeList.addChild(aToolbar);
// Create list of service groups
final ICommonsMap<ISMPServiceGroup, ICommonsList<ISMPServiceInformation>> aMap = new CommonsHashMap<>();
aServiceInfoMgr.getAllSMPServiceInformation().forEach(x -> aMap.computeIfAbsent(x.getServiceGroup(), k -> new CommonsArrayList<>()).add(x));
final HCUL aULSG = new HCUL();
final ICommonsList<ISMPServiceGroup> aServiceGroups = aServiceGroupMgr.getAllSMPServiceGroups().getSortedInline(ISMPServiceGroup.comparator());
for (final ISMPServiceGroup aServiceGroup : aServiceGroups) {
// Print service group
final IParticipantIdentifier aParticipantID = aServiceGroup.getParticipantIdentifier();
final HCLI aLISG = aULSG.addAndReturnItem(new HCA(createViewURL(aWPEC, CMenuSecure.MENU_SERVICE_GROUPS, aServiceGroup)).addChild(aParticipantID.getURIEncoded()));
final HCUL aULDT = new HCUL();
final ICommonsList<ISMPServiceInformation> aServiceInfos = aMap.get(aServiceGroup);
if (aServiceInfos != null) {
for (final ISMPServiceInformation aServiceInfo : aServiceInfos.getSortedInline(ISMPServiceInformation.comparator())) {
final HCUL aULP = new HCUL();
final IDocumentTypeIdentifier aDocTypeID = aServiceInfo.getDocumentTypeIdentifier();
final ICommonsList<ISMPProcess> aProcesses = aServiceInfo.getAllProcesses().getSortedInline(ISMPProcess.comparator());
for (final ISMPProcess aProcess : aProcesses) {
final BootstrapTable aEPTable = new BootstrapTable(HCCol.perc(40), HCCol.perc(40), HCCol.perc(20)).setBordered(true);
final ICommonsList<ISMPEndpoint> aEndpoints = aProcess.getAllEndpoints().getSortedInline(ISMPEndpoint.comparator());
for (final ISMPEndpoint aEndpoint : aEndpoints) {
final StringMap aParams = createParamMap(aServiceInfo, aProcess, aEndpoint);
final HCRow aBodyRow = aEPTable.addBodyRow();
final String sTransportProfile = aEndpoint.getTransportProfile();
final ISimpleURL aViewURL = createViewURL(aWPEC, aServiceInfo, aParams);
aBodyRow.addCell(new HCA(aViewURL).addChild(NiceNameUI.getTransportProfile(sTransportProfile, false)));
aBodyRow.addCell(aEndpoint.getEndpointReference());
final ISimpleURL aEditURL = createEditURL(aWPEC, aServiceInfo).addAll(aParams);
final ISimpleURL aCopyURL = createCopyURL(aWPEC, aServiceInfo).addAll(aParams);
final ISimpleURL aDeleteURL = createDeleteURL(aWPEC, aServiceInfo).addAll(aParams);
final ISimpleURL aPreviewURL = LinkHelper.getURLWithServerAndContext(aParticipantID.getURIPercentEncoded() + SMPRestFilter.PATH_SERVICES + aDocTypeID.getURIPercentEncoded());
aBodyRow.addAndReturnCell(new HCA(aViewURL).setTitle("View endpoint").addChild(EDefaultIcon.MAGNIFIER.getAsNode()), new HCTextNode(" "), new HCA(aEditURL).setTitle("Edit endpoint").addChild(EDefaultIcon.EDIT.getAsNode()), new HCTextNode(" "), new HCA(aCopyURL).setTitle("Copy endpoint").addChild(EDefaultIcon.COPY.getAsNode()), new HCTextNode(" "), new HCA(aDeleteURL).setTitle("Delete endpoint").addChild(EDefaultIcon.DELETE.getAsNode()), new HCTextNode(" "), new HCA(aPreviewURL).setTitle("Perform SMP query on endpoint").setTargetBlank().addChild(EFamFamIcon.SCRIPT_GO.getAsNode())).addClass(CSS_CLASS_RIGHT);
}
// Show process + endpoints
final HCLI aLI = aULP.addItem();
final HCDiv aDiv = div(NiceNameUI.getProcessID(aDocTypeID, aProcess.getProcessIdentifier(), false));
aLI.addChild(aDiv);
if (aEndpoints.isEmpty()) {
aDiv.addChild(" ").addChild(new HCA(aWPEC.getSelfHref().addAll(createParamMap(aServiceInfo, aProcess, (ISMPEndpoint) null)).add(CPageParam.PARAM_ACTION, ACTION_DELETE_PROCESS)).setTitle("Delete process").addChild(EDefaultIcon.DELETE.getAsNode()));
} else
aLI.addChild(aEPTable);
}
// Show document types + children
final HCLI aLI = aULDT.addItem();
final HCDiv aDiv = div().addChild(NiceNameUI.getDocumentTypeID(aServiceInfo.getDocumentTypeIdentifier(), false)).addChild(" ").addChild(new HCA(LinkHelper.getURLWithServerAndContext(aParticipantID.getURIPercentEncoded() + SMPRestFilter.PATH_SERVICES + aDocTypeID.getURIPercentEncoded())).setTitle("Perform SMP query on document type ").setTargetBlank().addChild(EFamFamIcon.SCRIPT_GO.getAsNode()));
aLI.addChild(aDiv);
if (aProcesses.isEmpty()) {
aDiv.addChild(" ").addChild(new HCA(aWPEC.getSelfHref().addAll(createParamMap(aServiceInfo, (ISMPProcess) null, (ISMPEndpoint) null)).add(CPageParam.PARAM_ACTION, ACTION_DELETE_DOCUMENT_TYPE)).setTitle("Delete document type").addChild(EDefaultIcon.DELETE.getAsNode()));
} else
aLI.addChild(aULP);
}
}
if (aServiceInfos == null || aServiceInfos.isEmpty() || aULDT.hasNoChildren())
aLISG.addChild(" ").addChild(badgeInfo("This service group has no assigned endpoints!"));
else
aLISG.addChild(aULDT);
}
aNodeList.addChild(aULSG);
}
Aggregations