コード例 #1
0
 @Test
 public void testListAllSerbianCountries() {
   for (final Locale aLocale :
       CollectionHelper.getSorted(Locale.getAvailableLocales(), new ComparatorLocale()))
     if (aLocale.getLanguage().equals("sr")
         || aLocale.getLanguage().equals("sh")
         || aLocale.getLanguage().equals("bs"))
       s_aLogger.info(aLocale.toString() + ": " + aLocale.getDisplayName());
 }
コード例 #2
0
 @Test
 public void testListAllCountries() {
   for (final Locale aLocale :
       CollectionHelper.getSorted(
           Locale.getAvailableLocales(), new CollatingComparatorLocaleCountry(Locale.US)))
     if (aLocale.getCountry().length() > 0)
       s_aLogger.info(
           aLocale.getCountry()
               + " "
               + aLocale.getDisplayCountry()
               + " ("
               + aLocale.toString()
               + ")");
 }
コード例 #3
0
 protected final void logThirdpartyModules() {
   // List all third party modules for later evaluation
   final Set<IThirdPartyModule> aModules =
       ThirdPartyModuleRegistry.getInstance().getAllRegisteredThirdPartyModules();
   if (!aModules.isEmpty()) {
     s_aLogger.info("Using the following third party modules:");
     for (final IThirdPartyModule aModule :
         CollectionHelper.getSorted(
             aModules,
             new CollatingComparatorHasDisplayName<IHasDisplayName>(
                 SystemHelper.getSystemLocale())))
       if (!aModule.isOptional()) {
         String sMsg = "  " + aModule.getDisplayName();
         if (aModule.getVersion() != null) sMsg += ' ' + aModule.getVersion().getAsString(true);
         sMsg += " licensed under " + aModule.getLicense().getDisplayName();
         if (aModule.getLicense().getVersion() != null)
           sMsg += ' ' + aModule.getLicense().getVersion().getAsString();
         s_aLogger.info(sMsg);
       }
   }
 }
コード例 #4
0
  @Override
  protected void fillContent(final WebPageExecutionContext aWPEC) {
    final HCNodeList aNodeList = aWPEC.getNodeList();
    final Locale aDisplayLocale = aWPEC.getDisplayLocale();
    final IIdentifierFactory aIdentifierFactory = PDMetaManager.getIdentifierFactory();

    {
      final BootstrapRow aHeaderRow = aNodeList.addAndReturnChild(new BootstrapRow());
      // The logo
      aHeaderRow.createColumn(12, 12, 1, 2).addClass(CBootstrapCSS.HIDDEN_SM);
      aHeaderRow
          .createColumn(12, 6, 5, 4)
          .addChild(
              new HCExtImg(new SimpleURL("/imgs/pd-logo.png")).addClass(CBootstrapCSS.PULL_LEFT));
      aHeaderRow
          .createColumn(12, 6, 5, 4)
          .addChild(
              new HCExtImg(new SimpleURL("/imgs/peppol.png")).addClass(CBootstrapCSS.PULL_RIGHT));
      aHeaderRow.createColumn(12, 12, 1, 2).addClass(CBootstrapCSS.HIDDEN_SM);
    }

    final String sQuery = aWPEC.getAttributeAsString(FIELD_QUERY);
    final String sParticipantID = aWPEC.getAttributeAsString(FIELD_PARTICIPANT_ID);
    boolean bShowQuery = true;

    if (aWPEC.hasAction(CPageParam.ACTION_VIEW) && StringHelper.hasText(sParticipantID)) {
      final IParticipantIdentifier aParticipantID =
          aIdentifierFactory.parseParticipantIdentifier(sParticipantID);
      if (aParticipantID != null) {
        // Show small query box
        aNodeList.addChild(_createSmallQueryBox(aWPEC));

        // Search document matching participant ID
        final ICommonsList<PDStoredDocument> aResultDocs =
            PDMetaManager.getStorageMgr().getAllDocumentsOfParticipant(aParticipantID);
        // Group by participant ID
        final IMultiMapListBased<IParticipantIdentifier, PDStoredDocument> aGroupedDocs =
            PDStorageManager.getGroupedByParticipantID(aResultDocs);
        if (aGroupedDocs.isEmpty())
          s_aLogger.warn(
              "No stored document matches participant identifier '" + sParticipantID + "'");
        else {
          if (aGroupedDocs.size() > 1)
            s_aLogger.warn(
                "Found "
                    + aGroupedDocs.size()
                    + " entries for participant identifier '"
                    + sParticipantID
                    + "' - weird");
          // Get the first one
          final List<PDStoredDocument> aDocuments =
              CollectionHelper.getFirstElement(aGroupedDocs.values());
          bShowQuery = false;

          aNodeList.addChild(getUIHandler().createPageHeader("Details for " + sParticipantID));

          final BootstrapTabBox aTabBox = aNodeList.addAndReturnChild(new BootstrapTabBox());

          // Business information
          {
            final HCNodeList aOL = new HCNodeList();
            int nIndex = 1;
            for (final PDStoredDocument aStoredDoc : aDocuments) {
              final BootstrapPanel aPanel = aOL.addAndReturnChild(new BootstrapPanel());
              if (aDocuments.size() > 1)
                aPanel.getOrCreateHeader().addChild("Business information entity " + nIndex);
              aPanel
                  .getBody()
                  .addChild(PDCommonUI.showBusinessInfoDetails(aStoredDoc, aDisplayLocale));
              ++nIndex;
            }
            // Add whole list or just the first item?
            final IHCNode aTabLabel =
                new HCSpan()
                    .addChild("Business information ")
                    .addChild(new BootstrapBadge().addChild(Integer.toString(aDocuments.size())));
            aTabBox.addTab("businessinfo", aTabLabel, aOL, true);
          }

          // Document types
          {
            final HCOL aDocTypeCtrl = new HCOL();
            final List<IDocumentTypeIdentifier> aDocTypeIDs =
                CollectionHelper.getSorted(
                    aResultDocs.get(0).getAllDocumentTypeIDs(),
                    IDocumentTypeIdentifier.comparator());
            for (final IDocumentTypeIdentifier aDocTypeID : aDocTypeIDs) {
              final IHCLI<?> aLI = aDocTypeCtrl.addItem();
              aLI.addChild(PDCommonUI.getDocumentTypeID(aDocTypeID));
              try {
                final IPeppolDocumentTypeIdentifierParts aParts =
                    PeppolIdentifierHelper.getDocumentTypeIdentifierParts(aDocTypeID);
                aLI.addChild(PDCommonUI.getDocumentTypeIDDetails(aParts));
              } catch (final IllegalArgumentException ex) {
                // Happens for non-PEPPOL identifiers
              }
            }
            aTabBox.addTab(
                "doctypes",
                new HCSpan()
                    .addChild("Document types ")
                    .addChild(new BootstrapBadge().addChild(Integer.toString(aDocTypeIDs.size()))),
                aDocTypeCtrl.hasChildren()
                    ? aDocTypeCtrl
                    : new BootstrapWarnBox()
                        .addChild("No document types available for this participant"),
                false);
          }
        }
      } else s_aLogger.warn("Failed to parse participant identifier '" + sParticipantID + "'");
    }

    if (bShowQuery) {
      if (StringHelper.hasText(sQuery)) {
        // Show small query box
        aNodeList.addChild(_createSmallQueryBox(aWPEC));

        s_aLogger.info("Searching for '" + sQuery + "'");

        // Build Lucene query
        final Query aLuceneQuery =
            PDQueryManager.convertQueryStringToLuceneQuery(PDMetaManager.getLucene(), sQuery);

        if (s_aLogger.isDebugEnabled())
          s_aLogger.debug("Created query for '" + sQuery + "' is <" + aLuceneQuery + ">");

        // Search all documents
        final ICommonsList<PDStoredDocument> aResultDocs =
            PDMetaManager.getStorageMgr().getAllDocuments(aLuceneQuery);

        s_aLogger.info(
            "  Result for <" + aLuceneQuery + "> are " + aResultDocs.size() + " documents");

        // Group by participant ID
        final IMultiMapListBased<IParticipantIdentifier, PDStoredDocument> aGroupedDocs =
            PDStorageManager.getGroupedByParticipantID(aResultDocs);

        final int nMaxResults = 10;

        // Display results
        if (aGroupedDocs.isEmpty()) {
          aNodeList.addChild(
              new BootstrapInfoBox()
                  .addChild("No search results found for query '" + sQuery + "'"));
        } else {
          final HCOL aOL = new HCOL().setStart(1);
          for (final Map.Entry<IParticipantIdentifier, ICommonsList<PDStoredDocument>> aEntry :
              aGroupedDocs.entrySet()) {
            final IParticipantIdentifier aDocParticipantID = aEntry.getKey();
            final ICommonsList<PDStoredDocument> aDocs = aEntry.getValue();

            // Start result document
            final HCDiv aResultItem = new HCDiv().addClass(CSS_CLASS_RESULT_DOC);
            final HCDiv aHeadRow = aResultItem.addAndReturnChild(new HCDiv());
            aHeadRow.addChild(aDocParticipantID.getURIEncoded());
            if (aDocs.size() > 1) aHeadRow.addChild(" (" + aDocs.size() + " entities)");
            aHeadRow
                .addChild(" ")
                .addChild(
                    new BootstrapButton(EBootstrapButtonType.SUCCESS, EBootstrapButtonSize.MINI)
                        .addChild("Show details")
                        .setIcon(EDefaultIcon.MAGNIFIER)
                        .setOnClick(
                            aWPEC
                                .getSelfHref()
                                .add(FIELD_QUERY, sQuery)
                                .add(CPageParam.PARAM_ACTION, CPageParam.ACTION_VIEW)
                                .add(FIELD_PARTICIPANT_ID, aDocParticipantID.getURIEncoded())));

            // Show all entities of the stored document
            final HCUL aUL = aResultItem.addAndReturnChild(new HCUL());
            for (final PDStoredDocument aStoredDoc : aEntry.getValue()) {
              final IHCLI<?> aLI =
                  aUL.addAndReturnItem(new HCLI().addClass(CSS_CLASS_RESULT_DOC_HEADER));
              final HCDiv aDocHeadRow = new HCDiv();
              if (aStoredDoc.hasCountryCode()) {
                // Add country flag (if available)
                aDocHeadRow.addChild(PDCommonUI.getFlagNode(aStoredDoc.getCountryCode()));
                aDocHeadRow.addChild(
                    new HCSpan()
                        .addChild(aStoredDoc.getCountryCode())
                        .addClass(CSS_CLASS_RESULT_DOC_COUNTRY_CODE));
              }
              if (aStoredDoc.hasName())
                aDocHeadRow.addChild(
                    new HCSpan()
                        .addChild(aStoredDoc.getName())
                        .addClass(CSS_CLASS_RESULT_DOC_NAME));
              if (aDocHeadRow.hasChildren()) aLI.addChild(aDocHeadRow);

              if (aStoredDoc.hasGeoInfo())
                aLI.addChild(
                    new HCDiv()
                        .addChildren(HCExtHelper.nl2divList(aStoredDoc.getGeoInfo()))
                        .addClass(CSS_CLASS_RESULT_DOC_GEOINFO));
              if (aStoredDoc.hasAdditionalInformation())
                aLI.addChild(
                    new HCDiv()
                        .addChildren(HCExtHelper.nl2divList(aStoredDoc.getAdditionalInformation()))
                        .addClass(CSS_CLASS_RESULT_DOC_FREETEXT));
            }

            aOL.addItem(aResultItem);

            // Break at 10 results
            if (aOL.getChildCount() >= nMaxResults) break;
          }
          aNodeList.addChild(aOL);
        }
      } else {
        // Show big query box
        final HCForm aBigQueryBox =
            new HCForm().setAction(aWPEC.getSelfHref()).setMethod(EHCFormMethod.GET);
        aBigQueryBox.addChild(
            new HCDiv().addClass(CSS_CLASS_BIG_QUERY_BOX).addChild(_createQueryEdit()));
        aBigQueryBox.addChild(
            new HCDiv()
                .addClass(CSS_CLASS_BIG_QUERY_BUTTONS)
                .addChild(
                    new BootstrapSubmitButton()
                        .addChild("Search PEPPOL Directory")
                        .setIcon(EDefaultIcon.MAGNIFIER)));

        final BootstrapRow aBodyRow = aNodeList.addAndReturnChild(new BootstrapRow());
        aBodyRow.createColumn(12, 1, 2, 3).addClass(CBootstrapCSS.HIDDEN_XS);
        aBodyRow.createColumn(12, 10, 8, 6).addChild(aBigQueryBox);
        aBodyRow.createColumn(12, 1, 2, 3).addClass(CBootstrapCSS.HIDDEN_XS);
      }
    }
  }