Search in sources :

Example 1 with SimpleIdentifierFactory

use of com.helger.peppolid.factory.SimpleIdentifierFactory in project phoss-directory by phax.

the class PageSecureParticipantActions method fillContent.

@Override
protected void fillContent(@Nonnull final WebPageExecutionContext aWPEC) {
    final HCNodeList aNodeList = aWPEC.getNodeList();
    final Locale aDisplayLocale = aWPEC.getDisplayLocale();
    final IRequestWebScopeWithoutResponse aRequestScope = aWPEC.getRequestScope();
    if (aWPEC.hasAction(ACTION_UPDATE_EXPORTED_BCS)) {
        LOGGER.info("Manually exporting all Business Cards now");
        // run in the background
        ExportAllDataJob.exportAllBusinessCardsInBackground();
        aWPEC.postRedirectGetInternal(success("The new exported data is (hopefully) available in a few minutes. Check the 'is running' state below."));
    } else if (aWPEC.hasAction(ACTION_SYNC_BCS_UNFORCED)) {
        LOGGER.info("Manually synchronizing all Business Cards now (unforced)");
        if (SyncAllBusinessCardsJob.syncAllBusinessCards(false).isChanged())
            aWPEC.postRedirectGetInternal(success("The unforced synchronization was started successfully and is now running in the background."));
        else
            aWPEC.postRedirectGetInternal(warn("The synchronization was not started because the last sync was at " + PDTToString.getAsString(SyncAllBusinessCardsJob.getLastSync(), aDisplayLocale)));
    } else if (aWPEC.hasAction(ACTION_SYNC_BCS_FORCED)) {
        LOGGER.info("Manually synchronizing all Business Cards now (FORCED)");
        if (SyncAllBusinessCardsJob.syncAllBusinessCards(true).isChanged())
            aWPEC.postRedirectGetInternal(success("The forced synchronization was started successfully and is now running in the background."));
        else
            aWPEC.postRedirectGetInternal(error("Force synchronization should always work"));
    } else if (aWPEC.hasAction(ACTION_SHOW_DUPLICATES)) {
        _showDuplicateIDs(aWPEC);
    } else if (aWPEC.hasAction(ACTION_DELETE_DUPLICATES)) {
        _deleteDuplicateIDs(aWPEC);
    }
    {
        final BootstrapButtonToolbar aToolbar = new BootstrapButtonToolbar(aWPEC);
        aToolbar.addButton("Refresh", aWPEC.getSelfHref(), EDefaultIcon.MAGNIFIER);
        aNodeList.addChild(aToolbar);
    }
    final BootstrapCard aCard = aNodeList.addAndReturnChild(new BootstrapCard());
    aCard.createAndAddHeader().addChild("Live data downloads - Danger zone").addClasses(CBootstrapCSS.BG_DANGER, CBootstrapCSS.TEXT_WHITE);
    BootstrapCardBody aBody = aCard.createAndAddBody();
    aBody.addChild(new BootstrapButton(EBootstrapButtonType.DANGER).addChild("Download all IDs (XML, live)").setOnClick(AJAX_DOWNLOAD_ALL_IDS_XML.getInvocationURL(aRequestScope)).setIcon(EDefaultIcon.SAVE_ALL));
    aBody.addChild(new BootstrapButton(EBootstrapButtonType.DANGER).addChild("Download all Business Cards (XML, full, live) (may take long)").setOnClick(AJAX_DOWNLOAD_ALL_BCS_XML_FULL.getInvocationURL(aRequestScope)).setIcon(EDefaultIcon.SAVE_ALL));
    aBody.addChild(new BootstrapButton(EBootstrapButtonType.DANGER).addChild("Download all Business Cards (XML, no document types, live) (may take long)").setOnClick(AJAX_DOWNLOAD_ALL_BCS_XML_NO_DOCTYPES.getInvocationURL(aRequestScope)).setIcon(EDefaultIcon.SAVE_ALL));
    aBody.addChild(new BootstrapButton(EBootstrapButtonType.DANGER).addChild("Download all Business Cards (Excel, live) (may take long)").setOnClick(AJAX_DOWNLOAD_ALL_BCS_EXCEL.getInvocationURL(aRequestScope)).setIcon(EDefaultIcon.SAVE_ALL));
    aBody.addChild(new BootstrapButton(EBootstrapButtonType.DANGER).addChild("Download all Business Cards (CSV, live) (may take long)").setOnClick(AJAX_DOWNLOAD_ALL_BCS_CSV.getInvocationURL(aRequestScope)).setIcon(EDefaultIcon.SAVE_ALL));
    aCard.createAndAddHeader().addChild("Cached data downloads");
    aBody = aCard.createAndAddBody();
    aBody.addChild(new BootstrapButton().addChild("Download all Business Cards (XML, full, cached)").setOnClick(LinkHelper.getURLWithContext(aRequestScope, ExportServlet.SERVLET_DEFAULT_PATH + ExportDeliveryHttpHandler.SPECIAL_BUSINESS_CARDS_XML_FULL)).setIcon(EDefaultIcon.SAVE_ALL));
    aBody.addChild(new BootstrapButton().addChild("Download all Business Cards (XML, no document types, cached)").setOnClick(LinkHelper.getURLWithContext(aRequestScope, ExportServlet.SERVLET_DEFAULT_PATH + ExportDeliveryHttpHandler.SPECIAL_BUSINESS_CARDS_XML_NO_DOC_TYPES)).setIcon(EDefaultIcon.SAVE_ALL));
    if (CPDPublisher.EXPORT_BUSINESS_CARDS_EXCEL) {
        aBody.addChild(new BootstrapButton().addChild("Download all Business Cards (Excel, cached)").setOnClick(LinkHelper.getURLWithContext(aRequestScope, ExportServlet.SERVLET_DEFAULT_PATH + ExportDeliveryHttpHandler.SPECIAL_BUSINESS_CARDS_EXCEL)).setIcon(EDefaultIcon.SAVE_ALL));
    }
    if (CPDPublisher.EXPORT_BUSINESS_CARDS_CSV) {
        aBody.addChild(new BootstrapButton().addChild("Download all Business Cards (CSV, cached)").setOnClick(LinkHelper.getURLWithContext(aRequestScope, ExportServlet.SERVLET_DEFAULT_PATH + ExportDeliveryHttpHandler.SPECIAL_BUSINESS_CARDS_CSV)).setIcon(EDefaultIcon.SAVE_ALL));
    }
    if (CPDPublisher.EXPORT_PARTICIPANTS_XML) {
        aBody.addChild(new BootstrapButton().addChild("Download all Participants (XML, cached)").setOnClick(LinkHelper.getURLWithContext(aRequestScope, ExportServlet.SERVLET_DEFAULT_PATH + ExportDeliveryHttpHandler.SPECIAL_PARTICIPANTS_XML)).setIcon(EDefaultIcon.SAVE_ALL));
    }
    if (CPDPublisher.EXPORT_PARTICIPANTS_JSON) {
        aBody.addChild(new BootstrapButton().addChild("Download all Participants (JSON, cached)").setOnClick(LinkHelper.getURLWithContext(aRequestScope, ExportServlet.SERVLET_DEFAULT_PATH + ExportDeliveryHttpHandler.SPECIAL_PARTICIPANTS_JSON)).setIcon(EDefaultIcon.SAVE_ALL));
    }
    if (CPDPublisher.EXPORT_PARTICIPANTS_CSV) {
        aBody.addChild(new BootstrapButton().addChild("Download all Participants (CSV, cached)").setOnClick(LinkHelper.getURLWithContext(aRequestScope, ExportServlet.SERVLET_DEFAULT_PATH + ExportDeliveryHttpHandler.SPECIAL_PARTICIPANTS_CSV)).setIcon(EDefaultIcon.SAVE_ALL));
    }
    aCard.createAndAddHeader().addChild("Cache management");
    aBody = aCard.createAndAddBody();
    final boolean bIsRunning = ExportAllDataJob.isExportCurrentlyRunning();
    if (bIsRunning) {
        final LocalDateTime aStartDT = ExportAllDataJob.getExportAllBusinessCardsStartDT();
        aBody.addChild(info("Export of Business Card cache is currently running. Started at " + PDTToString.getAsString(aStartDT, aDisplayLocale)));
    }
    aBody.addChild(new BootstrapButton().addChild("Update Business Card export cache (in background; takes too long)").setOnClick(aWPEC.getSelfHref().add(CPageParam.PARAM_ACTION, ACTION_UPDATE_EXPORTED_BCS)).setIcon(EDefaultIcon.INFO).setDisabled(bIsRunning));
    aCard.createAndAddHeader().addChild("Data Synchronization");
    aBody = aCard.createAndAddBody();
    aBody.addChild(new BootstrapButton().addChild("Synchronize all Business Cards (re-query from SMP - unforced)").setOnClick(aWPEC.getSelfHref().add(CPageParam.PARAM_ACTION, ACTION_SYNC_BCS_UNFORCED)).setIcon(EDefaultIcon.REFRESH));
    aBody.addChild(new BootstrapButton(EBootstrapButtonType.DANGER).addChild("Synchronize all Business Cards (re-query from SMP - forced)").setOnClick(aWPEC.getSelfHref().add(CPageParam.PARAM_ACTION, ACTION_SYNC_BCS_FORCED)).setIcon(EDefaultIcon.REFRESH));
    aCard.createAndAddHeader().addChild("Duplication handling");
    aBody = aCard.createAndAddBody();
    if (PDMetaManager.getIdentifierFactory() instanceof SimpleIdentifierFactory) {
        aBody.addChild(info("Since the simple identifier factory is used, duplicates cannot be determined"));
    } else {
        aBody.addChild(new BootstrapButton().addChild("Show all duplicate entries").setOnClick(aWPEC.getSelfHref().add(CPageParam.PARAM_ACTION, ACTION_SHOW_DUPLICATES)).setIcon(EDefaultIcon.MAGNIFIER));
        aBody.addChild(new BootstrapButton(EBootstrapButtonType.DANGER).addChild("Delete all duplicate entries").setOnClick(aWPEC.getSelfHref().add(CPageParam.PARAM_ACTION, ACTION_DELETE_DUPLICATES)).setIcon(EDefaultIcon.DELETE));
    }
}
Also used : Locale(java.util.Locale) LocalDateTime(java.time.LocalDateTime) IRequestWebScopeWithoutResponse(com.helger.web.scope.IRequestWebScopeWithoutResponse) BootstrapCard(com.helger.photon.bootstrap4.card.BootstrapCard) HCNodeList(com.helger.html.hc.impl.HCNodeList) SimpleIdentifierFactory(com.helger.peppolid.factory.SimpleIdentifierFactory) BootstrapCardBody(com.helger.photon.bootstrap4.card.BootstrapCardBody) BootstrapButton(com.helger.photon.bootstrap4.button.BootstrapButton) BootstrapButtonToolbar(com.helger.photon.bootstrap4.buttongroup.BootstrapButtonToolbar)

Aggregations

HCNodeList (com.helger.html.hc.impl.HCNodeList)1 SimpleIdentifierFactory (com.helger.peppolid.factory.SimpleIdentifierFactory)1 BootstrapButton (com.helger.photon.bootstrap4.button.BootstrapButton)1 BootstrapButtonToolbar (com.helger.photon.bootstrap4.buttongroup.BootstrapButtonToolbar)1 BootstrapCard (com.helger.photon.bootstrap4.card.BootstrapCard)1 BootstrapCardBody (com.helger.photon.bootstrap4.card.BootstrapCardBody)1 IRequestWebScopeWithoutResponse (com.helger.web.scope.IRequestWebScopeWithoutResponse)1 LocalDateTime (java.time.LocalDateTime)1 Locale (java.util.Locale)1