use of com.helger.html.hc.impl.HCNodeList in project phoss-directory by phax.
the class PageSecureListIndex method fillContent.
@Override
protected void fillContent(final WebPageExecutionContext aWPEC) {
final HCNodeList aNodeList = aWPEC.getNodeList();
final Locale aDisplayLocale = aWPEC.getDisplayLocale();
// Add toolbar
{
final BootstrapButtonToolbar aToolbar = aNodeList.addAndReturnChild(new BootstrapButtonToolbar(aWPEC));
aToolbar.addChild(new BootstrapButton().addChild("Refresh").setIcon(EDefaultIcon.REFRESH).setOnClick(aWPEC.getSelfHref()));
aToolbar.addChild(span("Current server time: " + PDTToString.getAsString(PDTFactory.getCurrentLocalTime(), aDisplayLocale)).addClass(PDCommonUI.CSS_CLASS_VERTICAL_PADDED_TEXT));
}
final LinkedBlockingQueue<Object> aQueue = PDMetaManager.getIndexerMgr().getIndexerWorkQueue().getQueue();
final int nLength = aQueue.size();
if (nLength == 0) {
aNodeList.addChild(success("The Index Queue is currently empty"));
} else {
aNodeList.addChild(info("The Index Queue contains " + nLength + " entries"));
final BootstrapTable aTable = new BootstrapTable(new DTCol("Queue date time").setDisplayType(EDTColType.DATETIME, aDisplayLocale).setInitialSorting(ESortOrder.DESCENDING), new DTCol("Participant ID"), new DTCol("Action"), new DTCol("Owner"), new DTCol("Requestor")).setID("indexqueue");
for (final Object o : aQueue) if (o instanceof IIndexerWorkItem) {
final IIndexerWorkItem aObj = (IIndexerWorkItem) o;
final HCRow aRow = aTable.addBodyRow();
aRow.addCell(PDTToString.getAsString(aObj.getCreationDateTime(), aDisplayLocale));
aRow.addCell(aObj.getParticipantID().getURIEncoded());
aRow.addCell(aObj.getType().getDisplayName());
aRow.addCell(aObj.getOwnerID());
aRow.addCell(aObj.getRequestingHost());
}
aNodeList.addChild(aTable).addChild(BootstrapDataTables.createDefaultDataTables(aWPEC, aTable));
}
}
use of com.helger.html.hc.impl.HCNodeList in project phoss-directory by phax.
the class PageSecureParticipantActions method _deleteDuplicateIDs.
private void _deleteDuplicateIDs(@Nonnull final WebPageExecutionContext aWPEC) {
LOGGER.info("Deleting all duplicate participant identifiers");
final Locale aDisplayLocale = aWPEC.getDisplayLocale();
final ICommonsMap<IParticipantIdentifier, ICommonsSortedSet<String>> aDupMap = _getDuplicateSourceMap();
final ICommonsSortedSet<String> aPIsToDelete = new CommonsTreeSet<>();
final ICommonsSortedSet<String> aPIsToAdd = new CommonsTreeSet<>();
for (final Map.Entry<IParticipantIdentifier, ICommonsSortedSet<String>> aEntry : aDupMap.entrySet()) {
final ICommonsSortedSet<String> aSet = aEntry.getValue();
final IParticipantIdentifier aPI = aEntry.getKey();
final String sDesiredVersion = aPI.getURIEncoded();
if (aSet.contains(sDesiredVersion)) {
// Simple kill the other ones
aPIsToDelete.addAll(aSet, x -> !x.equals(sDesiredVersion));
} else {
// Remove all and index the correct version
aPIsToDelete.addAll(aSet);
aPIsToAdd.add(sDesiredVersion);
}
}
if (aPIsToDelete.isNotEmpty()) {
final HCNodeList aNL = new HCNodeList();
// Important to use this identifier factory so that the correct key is
// created
final IIdentifierFactory aIF = SimpleIdentifierFactory.INSTANCE;
final PDIndexerManager aIndexerMgr = PDMetaManager.getIndexerMgr();
String sMsg = "Deleting " + aPIsToDelete.size() + " participant ID(s):";
LOGGER.info(sMsg);
aNL.addChild(h2(sMsg));
HCOL aOL = aNL.addAndReturnChild(new HCOL());
for (final String s : aPIsToDelete.getSorted(IComparator.getComparatorCollating(aDisplayLocale))) {
aOL.addItem(s);
aIndexerMgr.queueWorkItem(aIF.parseParticipantIdentifier(s), EIndexerWorkItemType.DELETE, "duplicate-elimination", PDIndexerManager.HOST_LOCALHOST);
}
if (aPIsToAdd.isNotEmpty()) {
sMsg = "Adding " + aPIsToAdd.size() + " participant ID(s) instead:";
LOGGER.info(sMsg);
aNL.addChild(h2(sMsg));
aOL = aNL.addAndReturnChild(new HCOL());
for (final String s : aPIsToAdd.getSorted(IComparator.getComparatorCollating(aDisplayLocale))) {
aOL.addItem(s);
aIndexerMgr.queueWorkItem(aIF.parseParticipantIdentifier(s), EIndexerWorkItemType.CREATE_UPDATE, "duplicate-elimination", PDIndexerManager.HOST_LOCALHOST);
}
}
aWPEC.postRedirectGetInternal(aNL);
} else {
final String sMsg = "Found no duplicate entries to remove";
LOGGER.info(sMsg);
aWPEC.postRedirectGetInternal(success(sMsg));
}
}
use of com.helger.html.hc.impl.HCNodeList in project phoss-directory by phax.
the class PageSecureParticipantActions method _showDuplicateIDs.
private void _showDuplicateIDs(@Nonnull final WebPageExecutionContext aWPEC) {
// This method can take a couple of minutes
LOGGER.info("Showing all duplicate participant identifiers");
final Locale aDisplayLocale = aWPEC.getDisplayLocale();
final ICommonsMap<IParticipantIdentifier, ICommonsSortedSet<String>> aDupMap = _getDuplicateSourceMap();
final HCNodeList aNL = new HCNodeList();
for (final Map.Entry<IParticipantIdentifier, ICommonsSortedSet<String>> aEntry : aDupMap.entrySet()) {
final ICommonsSortedSet<String> aSet = aEntry.getValue();
final IParticipantIdentifier aPI = aEntry.getKey();
final String sDesiredVersion = aPI.getURIEncoded();
final HCDiv aDiv = div("Found " + aSet.size() + " duplicate IDs for ").addChild(code(sDesiredVersion)).addChild(":");
final HCOL aOL = aDiv.addAndReturnChild(new HCOL());
for (final String sVersion : aSet.getSorted(IComparator.getComparatorCollating(aDisplayLocale))) {
final boolean bIsDesired = sDesiredVersion.equals(sVersion);
final IHCLI<?> aLI = aOL.addAndReturnItem(code(sVersion));
if (bIsDesired)
aLI.addChild(" ").addChild(badgeSuccess("desired version"));
}
aNL.addChild(aDiv);
}
if (aNL.hasChildren()) {
final String sMsg = "Found duplicate entries for " + aDupMap.size() + " " + (aDupMap.size() == 1 ? "participant" : "participants");
LOGGER.info(sMsg);
aNL.addChildAt(0, h2(sMsg));
aWPEC.postRedirectGetInternal(aNL);
} else
aWPEC.postRedirectGetInternal(success("Found no duplicate entries"));
}
use of com.helger.html.hc.impl.HCNodeList 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));
}
}
use of com.helger.html.hc.impl.HCNodeList 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;
}
Aggregations