Search in sources :

Example 1 with SMPRestDataProvider

use of com.helger.phoss.smp.rest.SMPRestDataProvider in project phoss-smp by phax.

the class PagePublicStart method fillContent.

@Override
protected void fillContent(final WebPageExecutionContext aWPEC) {
    final HCNodeList aNodeList = aWPEC.getNodeList();
    final Locale aDisplayLocale = aWPEC.getDisplayLocale();
    final IRequestWebScopeWithoutResponse aRequestScope = aWPEC.getRequestScope();
    if (SMPWebAppConfiguration.isStartPageParticipantsNone()) {
        // New in v5.0.4
        aNodeList.addChild(info("This SMP has disabled the list of participants."));
    } else {
        final ISMPServiceGroupManager aSMPServiceGroupMgr = SMPMetaManager.getServiceGroupMgr();
        final ICommonsList<ISMPServiceGroup> aServiceGroups = aSMPServiceGroupMgr.getAllSMPServiceGroups();
        // Use dynamic or static table?
        final boolean bUseDataTables = SMPWebAppConfiguration.isStartPageDynamicTable();
        final boolean bShowExtensionDetails = SMPWebAppConfiguration.isStartPageExtensionsShow();
        AbstractHCTable<?> aFinalTable;
        if (bUseDataTables) {
            // Dynamic
            final HCTable aTable = new HCTable(new DTCol("Participant ID").setInitialSorting(ESortOrder.ASCENDING), new DTCol(bShowExtensionDetails ? "Extension" : "Extension?").setDataSort(1, 0), new BootstrapDTColAction(aDisplayLocale)).setID(getID());
            aFinalTable = aTable;
        } else {
            // Static
            final BootstrapTable aTable = new BootstrapTable();
            aTable.setBordered(true);
            aTable.setCondensed(true);
            aTable.setStriped(true);
            aTable.addHeaderRow().addCell("Participant ID").addCell(bShowExtensionDetails ? "Extension" : "Extension?").addCell(EPhotonCoreText.ACTIONS.getDisplayText(aDisplayLocale));
            aFinalTable = aTable;
            // Sort manually
            aServiceGroups.sort(Comparator.comparing(x -> x.getParticipantIdentifier().getURIEncoded()));
        }
        for (final ISMPServiceGroup aServiceGroup : aServiceGroups) {
            final String sDisplayName = aServiceGroup.getParticipantIdentifier().getURIEncoded();
            final HCRow aRow = aFinalTable.addBodyRow();
            aRow.addCell(sDisplayName);
            if (bShowExtensionDetails) {
                if (aServiceGroup.extensions().isNotEmpty())
                    aRow.addCell(code(HCExtHelper.nl2divList(aServiceGroup.getFirstExtensionXML())));
                else
                    aRow.addCell();
            } else {
                aRow.addCell(EPhotonCoreText.getYesOrNo(aServiceGroup.extensions().isNotEmpty(), aDisplayLocale));
            }
            final SMPRestDataProvider aDP = new SMPRestDataProvider(aRequestScope, aServiceGroup.getParticipantIdentifier().getURIEncoded());
            aRow.addCell(new HCA(new SimpleURL(aDP.getServiceGroupHref(aServiceGroup.getParticipantIdentifier()))).setTitle("Perform SMP query on " + sDisplayName).setTargetBlank().addChild(EFamFamIcon.SCRIPT_GO.getAsNode()));
        }
        if (aFinalTable.hasBodyRows()) {
            aNodeList.addChild(aFinalTable);
            if (bUseDataTables) {
                final BootstrapDataTables aDataTables = BootstrapDataTables.createDefaultDataTables(aWPEC, aFinalTable);
                aNodeList.addChild(aDataTables);
            }
        } else
            aNodeList.addChild(info("This SMP does not manage any participant yet."));
    }
}
Also used : Locale(java.util.Locale) WebPageExecutionContext(com.helger.photon.uicore.page.WebPageExecutionContext) AbstractHCTable(com.helger.html.hc.html.tabular.AbstractHCTable) HCRow(com.helger.html.hc.html.tabular.HCRow) SMPRestDataProvider(com.helger.phoss.smp.rest.SMPRestDataProvider) SimpleURL(com.helger.commons.url.SimpleURL) AbstractSMPWebPage(com.helger.phoss.smp.ui.AbstractSMPWebPage) BootstrapTable(com.helger.photon.bootstrap4.table.BootstrapTable) ISMPServiceGroup(com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroup) Nonempty(com.helger.commons.annotation.Nonempty) BootstrapDataTables(com.helger.photon.bootstrap4.uictrls.datatables.BootstrapDataTables) Locale(java.util.Locale) HCA(com.helger.html.hc.html.textlevel.HCA) BootstrapDTColAction(com.helger.photon.bootstrap4.uictrls.datatables.BootstrapDTColAction) Nonnull(javax.annotation.Nonnull) Nullable(javax.annotation.Nullable) HCNodeList(com.helger.html.hc.impl.HCNodeList) IRequestWebScopeWithoutResponse(com.helger.web.scope.IRequestWebScopeWithoutResponse) HCTable(com.helger.html.hc.html.tabular.HCTable) SMPMetaManager(com.helger.phoss.smp.domain.SMPMetaManager) EPhotonCoreText(com.helger.photon.core.EPhotonCoreText) ICommonsList(com.helger.commons.collection.impl.ICommonsList) EFamFamIcon(com.helger.photon.uictrls.famfam.EFamFamIcon) HCExtHelper(com.helger.html.hc.ext.HCExtHelper) ESortOrder(com.helger.commons.compare.ESortOrder) DTCol(com.helger.photon.uictrls.datatables.column.DTCol) Comparator(java.util.Comparator) SMPWebAppConfiguration(com.helger.phoss.smp.app.SMPWebAppConfiguration) ISMPServiceGroupManager(com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroupManager) ISMPServiceGroupManager(com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroupManager) HCNodeList(com.helger.html.hc.impl.HCNodeList) ISMPServiceGroup(com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroup) HCA(com.helger.html.hc.html.textlevel.HCA) HCRow(com.helger.html.hc.html.tabular.HCRow) SMPRestDataProvider(com.helger.phoss.smp.rest.SMPRestDataProvider) SimpleURL(com.helger.commons.url.SimpleURL) IRequestWebScopeWithoutResponse(com.helger.web.scope.IRequestWebScopeWithoutResponse) AbstractHCTable(com.helger.html.hc.html.tabular.AbstractHCTable) HCTable(com.helger.html.hc.html.tabular.HCTable) BootstrapTable(com.helger.photon.bootstrap4.table.BootstrapTable) DTCol(com.helger.photon.uictrls.datatables.column.DTCol) BootstrapDataTables(com.helger.photon.bootstrap4.uictrls.datatables.BootstrapDataTables) BootstrapDTColAction(com.helger.photon.bootstrap4.uictrls.datatables.BootstrapDTColAction)

Aggregations

Nonempty (com.helger.commons.annotation.Nonempty)1 ICommonsList (com.helger.commons.collection.impl.ICommonsList)1 ESortOrder (com.helger.commons.compare.ESortOrder)1 SimpleURL (com.helger.commons.url.SimpleURL)1 HCExtHelper (com.helger.html.hc.ext.HCExtHelper)1 AbstractHCTable (com.helger.html.hc.html.tabular.AbstractHCTable)1 HCRow (com.helger.html.hc.html.tabular.HCRow)1 HCTable (com.helger.html.hc.html.tabular.HCTable)1 HCA (com.helger.html.hc.html.textlevel.HCA)1 HCNodeList (com.helger.html.hc.impl.HCNodeList)1 SMPWebAppConfiguration (com.helger.phoss.smp.app.SMPWebAppConfiguration)1 SMPMetaManager (com.helger.phoss.smp.domain.SMPMetaManager)1 ISMPServiceGroup (com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroup)1 ISMPServiceGroupManager (com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroupManager)1 SMPRestDataProvider (com.helger.phoss.smp.rest.SMPRestDataProvider)1 AbstractSMPWebPage (com.helger.phoss.smp.ui.AbstractSMPWebPage)1 BootstrapTable (com.helger.photon.bootstrap4.table.BootstrapTable)1 BootstrapDTColAction (com.helger.photon.bootstrap4.uictrls.datatables.BootstrapDTColAction)1 BootstrapDataTables (com.helger.photon.bootstrap4.uictrls.datatables.BootstrapDataTables)1 EPhotonCoreText (com.helger.photon.core.EPhotonCoreText)1