use of com.helger.html.hc.html.grouping.HCDiv in project peppol-practical by phax.
the class AppCommonUI method getTechnicalDetailsUI.
@Nullable
public static HCNodeList getTechnicalDetailsUI(@Nullable final Throwable t, final boolean bLogException) {
if (t == null)
return null;
if (bLogException)
LOGGER.warn("Technical details", t);
final HCNodeList ret = new HCNodeList();
Throwable aCur = t;
while (aCur != null) {
if (ret.hasNoChildren())
ret.addChild(new HCDiv().addChild("Technical details: " + _getString(aCur)));
else
ret.addChild(new HCDiv().addChild("Caused by: " + _getString(aCur)));
aCur = aCur.getCause();
}
return ret;
}
use of com.helger.html.hc.html.grouping.HCDiv in project phoss-directory by phax.
the class PDLoginManager method createLoginScreen.
@Override
protected IHTMLProvider createLoginScreen(final boolean bLoginError, @Nonnull final ICredentialValidationResult aLoginResult) {
return new BootstrapLoginHTMLProvider(bLoginError, aLoginResult, getPageTitle()) {
@Override
@Nullable
protected IHCNode createFormFooter(@Nonnull final ISimpleWebExecutionContext aSWEC) {
final HCDiv aDiv = new HCDiv().addClass(CBootstrapCSS.D_FLEX).addClass(CBootstrapCSS.MT_5);
aDiv.addChild(new HCSmall().addChild(CPDPublisher.getApplicationTitleWithVersion() + " / " + CDirectoryVersion.BUILD_TIMESTAMP));
return aDiv;
}
};
}
use of com.helger.html.hc.html.grouping.HCDiv 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.html.grouping.HCDiv in project phoss-directory by phax.
the class PagePublicSearchSimple method _showResultList.
private void _showResultList(@Nonnull final WebPageExecutionContext aWPEC, @Nonnull @Nonempty final String sQuery, @Nonnegative final int nMaxResults) {
final HCNodeList aNodeList = aWPEC.getNodeList();
final Locale aDisplayLocale = aWPEC.getDisplayLocale();
final IRequestWebScopeWithoutResponse aRequestScope = aWPEC.getRequestScope();
final PDStorageManager aStorageMgr = PDMetaManager.getStorageMgr();
// Search all documents
if (LOGGER.isInfoEnabled())
LOGGER.info("Searching generically for '" + sQuery + "'");
// Build Lucene query
final Query aLuceneQuery = PDQueryManager.convertQueryStringToLuceneQuery(PDMetaManager.getLucene(), CPDStorage.FIELD_ALL_FIELDS, sQuery);
if (LOGGER.isDebugEnabled())
LOGGER.debug("Created query for '" + sQuery + "' is <" + aLuceneQuery + ">");
PDSessionSingleton.getInstance().setLastQuery(aLuceneQuery);
// Search all documents
final ICommonsList<PDStoredBusinessEntity> aResultBEs = aStorageMgr.getAllDocuments(aLuceneQuery, nMaxResults);
// Also get the total hit count for UI display. May be < 0 in case of
// error
final int nTotalBEs = aStorageMgr.getCount(aLuceneQuery);
if (LOGGER.isInfoEnabled())
LOGGER.info(" Result for <" + aLuceneQuery + "> (max=" + nMaxResults + ") " + (aResultBEs.size() == 1 ? "is 1 document" : "are " + aResultBEs.size() + " documents") + "." + (nTotalBEs >= 0 ? " " + nTotalBEs + " total hits are available." : ""));
// Group by participant ID
final ICommonsMap<IParticipantIdentifier, ICommonsList<PDStoredBusinessEntity>> aGroupedBEs = PDStorageManager.getGroupedByParticipantID(aResultBEs);
// Display results
if (aGroupedBEs.isEmpty()) {
aNodeList.addChild(info("No search results found for query '" + sQuery + "'"));
} else {
aNodeList.addChild(div(badgeSuccess("Found " + (aGroupedBEs.size() == 1 ? "1 entity" : aGroupedBEs.size() + " entities") + " matching '" + sQuery + "'")));
if (nTotalBEs > nMaxResults) {
aNodeList.addChild(div(badgeWarn("Found more entities than displayed (" + nTotalBEs + " entries exist). Try to be more specific.")));
}
// Show basic information
final HCOL aOL = new HCOL().setStart(1);
for (final Map.Entry<IParticipantIdentifier, ICommonsList<PDStoredBusinessEntity>> aEntry : aGroupedBEs.entrySet()) {
final IParticipantIdentifier aDocParticipantID = aEntry.getKey();
final ICommonsList<PDStoredBusinessEntity> aDocs = aEntry.getValue();
// Start result document
final HCDiv aResultItem = div().addClass(CSS_CLASS_RESULT_DOC);
final HCDiv aHeadRow = aResultItem.addAndReturnChild(new HCDiv());
{
final boolean bIsPeppolDefault = aDocParticipantID.hasScheme(PEPPOL_DEFAULT_SCHEME);
IHCNode aParticipantNode = null;
if (bIsPeppolDefault) {
final IParticipantIdentifierScheme aScheme = ParticipantIdentifierSchemeManager.getSchemeOfIdentifier(aDocParticipantID);
if (aScheme != null) {
aParticipantNode = new HCNodeList().addChild(aDocParticipantID.getValue());
if (StringHelper.hasText(aScheme.getSchemeAgency()))
((HCNodeList) aParticipantNode).addChild(" (" + aScheme.getSchemeAgency() + ")");
}
}
if (aParticipantNode == null) {
// Fallback
aParticipantNode = code(aDocParticipantID.getURIEncoded());
}
aHeadRow.addChild("Participant ID: ").addChild(aParticipantNode);
}
if (aDocs.size() > 1)
aHeadRow.addChild(" (" + aDocs.size() + " entities)");
// Show all entities of the stored document
final HCUL aUL = aResultItem.addAndReturnChild(new HCUL());
for (final PDStoredBusinessEntity aStoredDoc : aEntry.getValue()) {
final BootstrapTable aTable = new BootstrapTable(HCCol.perc(20), HCCol.star());
aTable.setCondensed(true);
if (aStoredDoc.hasCountryCode()) {
// Add country flag (if available)
final String sCountryCode = aStoredDoc.getCountryCode();
final Locale aCountry = CountryCache.getInstance().getCountry(sCountryCode);
aTable.addBodyRow().addCell("Country:").addCell(new HCNodeList().addChild(PDCommonUI.getFlagNode(sCountryCode)).addChild(" ").addChild(span(aCountry != null ? aCountry.getDisplayCountry(aDisplayLocale) + " (" + sCountryCode + ")" : sCountryCode).addClass(CSS_CLASS_RESULT_DOC_COUNTRY_CODE)));
}
if (aStoredDoc.names().isNotEmpty()) {
// TODO add locale filter here
final ICommonsList<PDStoredMLName> aNames = PDCommonUI.getUIFilteredNames(aStoredDoc.names(), aDisplayLocale);
IHCNode aNameCtrl;
if (aNames.size() == 1)
aNameCtrl = PDCommonUI.getMLNameNode(aNames.getFirst(), aDisplayLocale);
else {
final HCUL aNameUL = new HCUL();
aNames.forEach(x -> aNameUL.addItem(PDCommonUI.getMLNameNode(x, aDisplayLocale)));
aNameCtrl = aNameUL;
}
aTable.addBodyRow().addCell("Entity Name:").addCell(span(aNameCtrl).addClass(CSS_CLASS_RESULT_DOC_NAME));
}
if (aStoredDoc.hasGeoInfo())
aTable.addBodyRow().addCell("Geographical information:").addCell(div(HCExtHelper.nl2divList(aStoredDoc.getGeoInfo())).addClass(CSS_CLASS_RESULT_DOC_GEOINFO));
if (aStoredDoc.hasAdditionalInformation())
aTable.addBodyRow().addCell("Additional information:").addCell(div(HCExtHelper.nl2divList(aStoredDoc.getAdditionalInformation())).addClass(CSS_CLASS_RESULT_DOC_FREETEXT));
aUL.addAndReturnItem(aTable).addClass(CSS_CLASS_RESULT_DOC_HEADER);
}
final BootstrapButton aShowDetailsBtn = new BootstrapButton(EBootstrapButtonType.SUCCESS, EBootstrapButtonSize.DEFAULT).addChild("Show details").setIcon(EDefaultIcon.MAGNIFIER).addClass(CSS_CLASS_RESULT_DOC_SDBUTTON).setOnClick(aWPEC.getSelfHref().add(FIELD_QUERY, sQuery).add(CPageParam.PARAM_ACTION, CPageParam.ACTION_VIEW).add(FIELD_PARTICIPANT_ID, aDocParticipantID.getURIEncoded()));
aResultItem.addChild(div(aShowDetailsBtn));
aOL.addItem(aResultItem);
// Is the max result limit reached?
if (aOL.getChildCount() >= nMaxResults)
break;
}
aNodeList.addChild(aOL);
aNodeList.addChild(div(new BootstrapButton().setOnClick(AJAX_EXPORT_LAST.getInvocationURL(aRequestScope)).addChild("Download results as XML").setIcon(EDefaultIcon.SAVE_ALL)));
}
}
use of com.helger.html.hc.html.grouping.HCDiv in project phoss-directory by phax.
the class PagePublicSearchSimple method fillContent.
@Override
protected void fillContent(@Nonnull final WebPageExecutionContext aWPEC) {
final HCNodeList aNodeList = aWPEC.getNodeList();
final Locale aDisplayLocale = aWPEC.getDisplayLocale();
final IIdentifierFactory aIdentifierFactory = PDMetaManager.getIdentifierFactory();
final HCDiv aLogoContainer = new HCDiv().addClass(CSS_CLASS_BIG_QUERY_IMAGE_CONTAINER);
aLogoContainer.addClass(CBootstrapCSS.MY_2);
final HCDiv aLogo = new HCDiv().addClass(CSS_CLASS_BIG_QUERY_IMAGE).addStyle(CCSSProperties.BACKGROUND_IMAGE.newValue(CSSURLHelper.getAsCSSURL(CPDPublisher.getLogoImageURL(), true)));
aLogoContainer.addChild(aLogo);
aNodeList.addChild(aLogoContainer);
final String sQuery = aWPEC.params().getAsStringTrimmed(FIELD_QUERY);
final String sParticipantID = aWPEC.params().getAsStringTrimmed(FIELD_PARTICIPANT_ID);
int nMaxResults = aWPEC.params().getAsInt(PARAM_MAX, DEFAULT_MAX);
if (nMaxResults < 1) {
// Avoid "all" results
nMaxResults = 1;
} else if (nMaxResults > MAX_MAX) {
// Avoid too many results
nMaxResults = MAX_MAX;
}
boolean bShowQuery = true;
if (aWPEC.hasAction(CPageParam.ACTION_VIEW) && StringHelper.hasText(sParticipantID)) {
// Show details of a participant
final IParticipantIdentifier aParticipantID = aIdentifierFactory.parseParticipantIdentifier(sParticipantID);
if (aParticipantID != null) {
// Show participant details
final HCNodeList aDetails = createParticipantDetails(aDisplayLocale, sParticipantID, aParticipantID, aWPEC.isLoggedInUserAdministrator());
if (aDetails.hasChildren()) {
// Show small query box
aLogo.addChild(_createInitialSearchForm(aWPEC));
// Show details afterwards
aNodeList.addChild(aDetails);
bShowQuery = false;
}
} else {
aLogo.addChild(error("Failed to parse participant identifier '" + sParticipantID + "'"));
}
}
if (bShowQuery) {
if (StringHelper.hasText(sQuery)) {
// Show small query box
aLogo.addChild(_createInitialSearchForm(aWPEC));
// After Logo
_showResultList(aWPEC, sQuery, nMaxResults);
} else {
// Show big query box
aLogo.addChild(_createInitialSearchForm(aWPEC));
}
}
}
Aggregations