Search in sources :

Example 1 with HCHR

use of com.helger.html.hc.html.grouping.HCHR 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;
}
Also used : HCH1(com.helger.html.hc.html.sections.HCH1) HCOL(com.helger.html.hc.html.grouping.HCOL) IDocumentTypeIdentifier(com.helger.peppolid.IDocumentTypeIdentifier) BootstrapWebPageUIHandler(com.helger.photon.bootstrap4.pages.BootstrapWebPageUIHandler) PDMetaManager(com.helger.pd.indexer.mgr.PDMetaManager) LoggerFactory(org.slf4j.LoggerFactory) Function(java.util.function.Function) NiceNameUI(com.helger.pd.publisher.nicename.NiceNameUI) PDCommonUI(com.helger.pd.publisher.ui.PDCommonUI) IHCNode(com.helger.html.hc.IHCNode) ParticipantIdentifierSchemeManager(com.helger.peppolid.peppol.pidscheme.ParticipantIdentifierSchemeManager) BootstrapPageHeader(com.helger.photon.bootstrap4.utils.BootstrapPageHeader) Nonempty(com.helger.commons.annotation.Nonempty) Locale(java.util.Locale) PDServerConfiguration(com.helger.pd.indexer.settings.PDServerConfiguration) IHasID(com.helger.commons.id.IHasID) EnumHelper(com.helger.commons.lang.EnumHelper) IParticipantIdentifierScheme(com.helger.peppolid.peppol.pidscheme.IParticipantIdentifierScheme) GlobalDebug(com.helger.commons.debug.GlobalDebug) IParticipantIdentifier(com.helger.peppolid.IParticipantIdentifier) Nonnull(javax.annotation.Nonnull) Nullable(javax.annotation.Nullable) PDTToString(com.helger.commons.datetime.PDTToString) BootstrapViewForm(com.helger.photon.bootstrap4.form.BootstrapViewForm) BootstrapTabBox(com.helger.photon.bootstrap4.nav.BootstrapTabBox) HCNodeList(com.helger.html.hc.impl.HCNodeList) PDStoredBusinessEntity(com.helger.pd.indexer.storage.PDStoredBusinessEntity) HCLI(com.helger.html.hc.html.grouping.HCLI) PDStorageManager(com.helger.pd.indexer.storage.PDStorageManager) BootstrapFormGroup(com.helger.photon.bootstrap4.form.BootstrapFormGroup) Logger(org.slf4j.Logger) CommonsArrayList(com.helger.commons.collection.impl.CommonsArrayList) PeppolIdentifierFactory(com.helger.peppolid.factory.PeppolIdentifierFactory) StringHelper(com.helger.commons.string.StringHelper) AbstractAppWebPage(com.helger.pd.publisher.ui.AbstractAppWebPage) Collection(java.util.Collection) ValueEnforcer(com.helger.commons.ValueEnforcer) BootstrapCard(com.helger.photon.bootstrap4.card.BootstrapCard) PDStoredMLName(com.helger.pd.indexer.storage.PDStoredMLName) ICommonsList(com.helger.commons.collection.impl.ICommonsList) HCHR(com.helger.html.hc.html.grouping.HCHR) ICommonsMap(com.helger.commons.collection.impl.ICommonsMap) DefaultCSSClassProvider(com.helger.html.css.DefaultCSSClassProvider) ICSSClassProvider(com.helger.html.css.ICSSClassProvider) ICommonsList(com.helger.commons.collection.impl.ICommonsList) BootstrapCard(com.helger.photon.bootstrap4.card.BootstrapCard) HCNodeList(com.helger.html.hc.impl.HCNodeList) HCHR(com.helger.html.hc.html.grouping.HCHR) HCH1(com.helger.html.hc.html.sections.HCH1) PDStoredMLName(com.helger.pd.indexer.storage.PDStoredMLName) BootstrapViewForm(com.helger.photon.bootstrap4.form.BootstrapViewForm) IDocumentTypeIdentifier(com.helger.peppolid.IDocumentTypeIdentifier) BootstrapTabBox(com.helger.photon.bootstrap4.nav.BootstrapTabBox) BootstrapPageHeader(com.helger.photon.bootstrap4.utils.BootstrapPageHeader) PDStoredBusinessEntity(com.helger.pd.indexer.storage.PDStoredBusinessEntity) IParticipantIdentifierScheme(com.helger.peppolid.peppol.pidscheme.IParticipantIdentifierScheme) HCOL(com.helger.html.hc.html.grouping.HCOL) HCLI(com.helger.html.hc.html.grouping.HCLI) BootstrapFormGroup(com.helger.photon.bootstrap4.form.BootstrapFormGroup) IParticipantIdentifier(com.helger.peppolid.IParticipantIdentifier) IHCNode(com.helger.html.hc.IHCNode) Nonnull(javax.annotation.Nonnull)

Example 2 with HCHR

use of com.helger.html.hc.html.grouping.HCHR in project phoss-smp by phax.

the class SMPCommonUI method getExtensionDisplay.

@Nullable
public static IHCNode getExtensionDisplay(@Nonnull final ISMPHasExtension aHasExtension) {
    final ICommonsList<com.helger.xsds.bdxr.smp1.ExtensionType> aExtensions = aHasExtension.extensions();
    if (aExtensions.isEmpty())
        return null;
    final HCNodeList aNL = new HCNodeList();
    for (final com.helger.xsds.bdxr.smp1.ExtensionType aExtension : aExtensions) {
        if (aNL.hasChildren()) {
            // add a separator line
            aNL.addChild(new HCHR());
        }
        // Use only the XML element of the first extension
        final Element aAny = (Element) aExtension.getAny();
        final String sXML = XMLWriter.getNodeAsString(aAny);
        aNL.addChild(new HCPrismJS(EPrismLanguage.MARKUP).addChild(sXML));
    }
    return aNL;
}
Also used : HCNodeList(com.helger.html.hc.impl.HCNodeList) HCHR(com.helger.html.hc.html.grouping.HCHR) Element(org.w3c.dom.Element) HCPrismJS(com.helger.photon.uictrls.prism.HCPrismJS) PDTToString(com.helger.commons.datetime.PDTToString) Nullable(javax.annotation.Nullable)

Example 3 with HCHR

use of com.helger.html.hc.html.grouping.HCHR in project phoss-directory by phax.

the class PageSecureParticipantCount method fillContent.

@Override
protected void fillContent(@Nonnull final WebPageExecutionContext aWPEC) {
    final IRequestWebScopeWithoutResponse aRequestScope = aWPEC.getRequestScope();
    final HCNodeList aNodeList = aWPEC.getNodeList();
    {
        final BootstrapButtonToolbar aToolbar = new BootstrapButtonToolbar(aWPEC);
        aToolbar.addButton("Refresh", aWPEC.getSelfHref(), EDefaultIcon.MAGNIFIER);
        aToolbar.addButton("Delete deleted", AJAX_DELETE_DELETED.getInvocationURL(aRequestScope), EDefaultIcon.DELETE);
        aNodeList.addChild(aToolbar);
    }
    final int nNotDeletedCount = PDMetaManager.getStorageMgr().getContainedParticipantCount(EQueryMode.NON_DELETED_ONLY);
    aNodeList.addChild(h3(nNotDeletedCount + " participants (entities) are contained"));
    final int nDeletedCount = PDMetaManager.getStorageMgr().getContainedParticipantCount(EQueryMode.DELETED_ONLY);
    aNodeList.addChild(h3(nDeletedCount + " deleted participants (entities) are contained"));
    final int nReIndexCount = PDMetaManager.getIndexerMgr().getReIndexList().getItemCount();
    aNodeList.addChild(h3(nReIndexCount + " re-index items are contained"));
    final int nDeadCount = PDMetaManager.getIndexerMgr().getDeadList().getItemCount();
    aNodeList.addChild(h3(nDeadCount + " dead items are contained"));
    if (false)
        try {
            final Collector aCollector = new AllDocumentsCollector(PDMetaManager.getLucene(), (aDoc, nIdx) -> {
                final BootstrapTable aTable = new BootstrapTable();
                for (final IndexableField f : aDoc.getFields()) aTable.addBodyRow().addCells(f.name(), f.fieldType().toString(), f.stringValue());
                aNodeList.addChild(aTable);
                aNodeList.addChild(new HCHR());
            });
            PDMetaManager.getStorageMgr().searchAtomic(new MatchAllDocsQuery(), aCollector);
        } catch (final IOException ex) {
        }
}
Also used : IRequestWebScopeWithoutResponse(com.helger.web.scope.IRequestWebScopeWithoutResponse) WebPageExecutionContext(com.helger.photon.uicore.page.WebPageExecutionContext) AbstractAppWebPage(com.helger.pd.publisher.ui.AbstractAppWebPage) EDefaultIcon(com.helger.photon.uicore.icon.EDefaultIcon) IndexableField(org.apache.lucene.index.IndexableField) PDMetaManager(com.helger.pd.indexer.mgr.PDMetaManager) IOException(java.io.IOException) Collector(org.apache.lucene.search.Collector) MatchAllDocsQuery(org.apache.lucene.search.MatchAllDocsQuery) BootstrapButtonToolbar(com.helger.photon.bootstrap4.buttongroup.BootstrapButtonToolbar) AjaxFunctionDeclaration(com.helger.photon.ajax.decl.AjaxFunctionDeclaration) BootstrapTable(com.helger.photon.bootstrap4.table.BootstrapTable) EQueryMode(com.helger.pd.indexer.storage.EQueryMode) Nonempty(com.helger.commons.annotation.Nonempty) HCHR(com.helger.html.hc.html.grouping.HCHR) AllDocumentsCollector(com.helger.pd.indexer.lucene.AllDocumentsCollector) Nonnull(javax.annotation.Nonnull) HCNodeList(com.helger.html.hc.impl.HCNodeList) IndexableField(org.apache.lucene.index.IndexableField) IRequestWebScopeWithoutResponse(com.helger.web.scope.IRequestWebScopeWithoutResponse) HCNodeList(com.helger.html.hc.impl.HCNodeList) BootstrapTable(com.helger.photon.bootstrap4.table.BootstrapTable) HCHR(com.helger.html.hc.html.grouping.HCHR) Collector(org.apache.lucene.search.Collector) AllDocumentsCollector(com.helger.pd.indexer.lucene.AllDocumentsCollector) AllDocumentsCollector(com.helger.pd.indexer.lucene.AllDocumentsCollector) BootstrapButtonToolbar(com.helger.photon.bootstrap4.buttongroup.BootstrapButtonToolbar) IOException(java.io.IOException) MatchAllDocsQuery(org.apache.lucene.search.MatchAllDocsQuery)

Aggregations

HCHR (com.helger.html.hc.html.grouping.HCHR)3 HCNodeList (com.helger.html.hc.impl.HCNodeList)3 Nonempty (com.helger.commons.annotation.Nonempty)2 PDTToString (com.helger.commons.datetime.PDTToString)2 PDMetaManager (com.helger.pd.indexer.mgr.PDMetaManager)2 AbstractAppWebPage (com.helger.pd.publisher.ui.AbstractAppWebPage)2 Nullable (javax.annotation.Nullable)2 ValueEnforcer (com.helger.commons.ValueEnforcer)1 CommonsArrayList (com.helger.commons.collection.impl.CommonsArrayList)1 ICommonsList (com.helger.commons.collection.impl.ICommonsList)1 ICommonsMap (com.helger.commons.collection.impl.ICommonsMap)1 GlobalDebug (com.helger.commons.debug.GlobalDebug)1 IHasID (com.helger.commons.id.IHasID)1 EnumHelper (com.helger.commons.lang.EnumHelper)1 StringHelper (com.helger.commons.string.StringHelper)1 DefaultCSSClassProvider (com.helger.html.css.DefaultCSSClassProvider)1 ICSSClassProvider (com.helger.html.css.ICSSClassProvider)1 IHCNode (com.helger.html.hc.IHCNode)1 HCLI (com.helger.html.hc.html.grouping.HCLI)1 HCOL (com.helger.html.hc.html.grouping.HCOL)1