Search in sources :

Example 1 with PDStoredIdentifier

use of com.helger.pd.indexer.storage.PDStoredIdentifier in project phoss-directory by phax.

the class PDCommonUI method showBusinessInfoDetails.

@Nonnull
public static BootstrapViewForm showBusinessInfoDetails(@Nonnull final PDStoredBusinessEntity aStoredDoc, @Nonnull final Locale aDisplayLocale) {
    final BootstrapViewForm aViewForm = new BootstrapViewForm();
    if (aStoredDoc.hasCountryCode()) {
        final HCNodeList aCountryCtrl = new HCNodeList();
        final String sCountryCode = aStoredDoc.getCountryCode();
        aCountryCtrl.addChild(getFlagNode(sCountryCode));
        final Locale aCountry = CountryCache.getInstance().getCountry(sCountryCode);
        if (aCountry != null)
            aCountryCtrl.addChild(" " + aCountry.getDisplayCountry(aDisplayLocale) + " [" + sCountryCode + "]");
        else
            aCountryCtrl.addChild(" " + sCountryCode);
        aViewForm.addFormGroup(new BootstrapFormGroup().setLabel("Country").setCtrl(aCountryCtrl));
    }
    if (aStoredDoc.names().isNotEmpty()) {
        final ICommonsList<PDStoredMLName> aNames = getUIFilteredNames(aStoredDoc.names(), aDisplayLocale);
        IHCNode aNameCtrl;
        if (aNames.size() == 1)
            aNameCtrl = getMLNameNode(aNames.getFirst(), aDisplayLocale);
        else {
            final HCUL aNameUL = new HCUL();
            aNames.forEach(x -> aNameUL.addItem(getMLNameNode(x, aDisplayLocale)));
            aNameCtrl = aNameUL;
        }
        aViewForm.addFormGroup(new BootstrapFormGroup().setLabel("Entity Name").setCtrl(aNameCtrl));
    }
    if (aStoredDoc.hasGeoInfo())
        aViewForm.addFormGroup(new BootstrapFormGroup().setLabel("Geographical information").setCtrl(HCExtHelper.nl2divList(aStoredDoc.getGeoInfo())));
    if (aStoredDoc.identifiers().isNotEmpty()) {
        final BootstrapTable aIDTable = new BootstrapTable(HCCol.star(), HCCol.star()).setStriped(true).setBordered(true).setCondensed(true);
        aIDTable.addHeaderRow().addCells("Scheme", "Value");
        for (final PDStoredIdentifier aStoredID : aStoredDoc.identifiers()) aIDTable.addBodyRow().addCells(aStoredID.getScheme(), aStoredID.getValue());
        aViewForm.addFormGroup(new BootstrapFormGroup().setLabel("Additional identifiers").setCtrl(aIDTable));
    }
    if (aStoredDoc.websiteURIs().isNotEmpty()) {
        final HCOL aOL = new HCOL();
        for (final String sWebsiteURI : aStoredDoc.websiteURIs()) aOL.addItem(HCA.createLinkedWebsite(sWebsiteURI, HC_Target.BLANK));
        aViewForm.addFormGroup(new BootstrapFormGroup().setLabel("Website URIs").setCtrl(aOL));
    }
    if (aStoredDoc.contacts().isNotEmpty()) {
        final BootstrapTable aContactTable = new BootstrapTable(HCCol.star(), HCCol.star(), HCCol.star(), HCCol.star()).setStriped(true).setBordered(true);
        aContactTable.addHeaderRow().addCells("Type", "Name", "Phone Number", "Email");
        for (final PDStoredContact aStoredContact : aStoredDoc.contacts()) aContactTable.addBodyRow().addCells(aStoredContact.getType(), aStoredContact.getName(), aStoredContact.getPhone(), aStoredContact.getEmail());
        aViewForm.addFormGroup(new BootstrapFormGroup().setLabel("Contacts").setCtrl(aContactTable));
    }
    if (aStoredDoc.hasAdditionalInformation())
        aViewForm.addFormGroup(new BootstrapFormGroup().setLabel("Additional information").setCtrl(HCExtHelper.nl2divList(aStoredDoc.getAdditionalInformation())));
    if (aStoredDoc.hasRegistrationDate())
        aViewForm.addFormGroup(new BootstrapFormGroup().setLabel("Registration date").setCtrl(PDTToString.getAsString(aStoredDoc.getRegistrationDate(), aDisplayLocale)));
    return aViewForm;
}
Also used : Locale(java.util.Locale) HCNodeList(com.helger.html.hc.impl.HCNodeList) PDStoredMLName(com.helger.pd.indexer.storage.PDStoredMLName) BootstrapViewForm(com.helger.photon.bootstrap4.form.BootstrapViewForm) PDTToString(com.helger.commons.datetime.PDTToString) HCUL(com.helger.html.hc.html.grouping.HCUL) BootstrapTable(com.helger.photon.bootstrap4.table.BootstrapTable) PDStoredIdentifier(com.helger.pd.indexer.storage.PDStoredIdentifier) HCOL(com.helger.html.hc.html.grouping.HCOL) BootstrapFormGroup(com.helger.photon.bootstrap4.form.BootstrapFormGroup) PDStoredContact(com.helger.pd.indexer.storage.PDStoredContact) IHCNode(com.helger.html.hc.IHCNode) Nonnull(javax.annotation.Nonnull)

Example 2 with PDStoredIdentifier

use of com.helger.pd.indexer.storage.PDStoredIdentifier in project phoss-directory by phax.

the class ExportAllManager method queryAllContainedBusinessCardsAsCSV.

public static void queryAllContainedBusinessCardsAsCSV(@Nonnull final EQueryMode eQueryMode, @Nonnull @WillNotClose final CSVWriter aCSVWriter) throws IOException {
    _unify(aCSVWriter);
    final Query aQuery = eQueryMode.getEffectiveQuery(new MatchAllDocsQuery());
    aCSVWriter.writeNext("Participant ID", "Names (per-row)", "Country code", "Geo info", "Identifier schemes", "Identifier values", "Websites", "Contact type", "Contact name", "Contact phone", "Contact email", "Additional info", "Registration date", "Document types");
    final Consumer<? super PDStoredBusinessEntity> aConsumer = aEntity -> {
        aCSVWriter.writeNext(aEntity.getParticipantID().getURIEncoded(), StringHelper.getImplodedMapped("\n", aEntity.names(), PDStoredMLName::getNameAndLanguageCode), aEntity.getCountryCode(), aEntity.getGeoInfo(), StringHelper.getImplodedMapped("\n", aEntity.identifiers(), PDStoredIdentifier::getScheme), StringHelper.getImplodedMapped("\n", aEntity.identifiers(), PDStoredIdentifier::getValue), StringHelper.getImploded("\n", aEntity.websiteURIs()), StringHelper.getImplodedMapped("\n", aEntity.contacts(), PDStoredContact::getType), StringHelper.getImplodedMapped("\n", aEntity.contacts(), PDStoredContact::getName), StringHelper.getImplodedMapped("\n", aEntity.contacts(), PDStoredContact::getPhone), StringHelper.getImplodedMapped("\n", aEntity.contacts(), PDStoredContact::getEmail), aEntity.getAdditionalInformation(), aEntity.getRegistrationDate() == null ? "" : aEntity.getRegistrationDate().toString(), StringHelper.getImplodedMapped("\n", aEntity.documentTypeIDs(), IDocumentTypeIdentifier::getURIEncoded));
    };
    PDMetaManager.getStorageMgr().searchAllDocuments(aQuery, -1, aConsumer);
    aCSVWriter.flush();
}
Also used : Query(org.apache.lucene.search.Query) EExcelVersion(com.helger.poi.excel.EExcelVersion) CommonsTreeSet(com.helger.commons.collection.impl.CommonsTreeSet) IDocumentTypeIdentifier(com.helger.peppolid.IDocumentTypeIdentifier) PDMetaManager(com.helger.pd.indexer.mgr.PDMetaManager) LoggerFactory(org.slf4j.LoggerFactory) IMicroDocument(com.helger.xml.microdom.IMicroDocument) PDTFactory(com.helger.commons.datetime.PDTFactory) IMicroElement(com.helger.xml.microdom.IMicroElement) PDStoredBusinessEntity(com.helger.pd.indexer.storage.PDStoredBusinessEntity) PDField(com.helger.pd.indexer.storage.field.PDField) ThreadSafe(javax.annotation.concurrent.ThreadSafe) MatchAllDocsQuery(org.apache.lucene.search.MatchAllDocsQuery) ICommonsOrderedMap(com.helger.commons.collection.impl.ICommonsOrderedMap) StandardCharsets(java.nio.charset.StandardCharsets) JsonObject(com.helger.json.JsonObject) WorkbookCreationHelper(com.helger.poi.excel.WorkbookCreationHelper) ICommonsList(com.helger.commons.collection.impl.ICommonsList) IJsonArray(com.helger.json.IJsonArray) UnifiedResponse(com.helger.servlet.response.UnifiedResponse) CSVWriter(com.helger.commons.csv.CSVWriter) PDStoredContact(com.helger.pd.indexer.storage.PDStoredContact) Writer(java.io.Writer) WebFileIO(com.helger.photon.app.io.WebFileIO) ESuccess(com.helger.commons.state.ESuccess) FileSystemResource(com.helger.commons.io.resource.FileSystemResource) IJsonObject(com.helger.json.IJsonObject) MicroDocument(com.helger.xml.microdom.MicroDocument) CHttpHeader(com.helger.commons.http.CHttpHeader) JsonArray(com.helger.json.JsonArray) FileHelper(com.helger.commons.io.file.FileHelper) PDStoredIdentifier(com.helger.pd.indexer.storage.PDStoredIdentifier) ICommonsSortedSet(com.helger.commons.collection.impl.ICommonsSortedSet) IParticipantIdentifier(com.helger.peppolid.IParticipantIdentifier) Nonnull(javax.annotation.Nonnull) WillNotClose(javax.annotation.WillNotClose) Logger(org.slf4j.Logger) CommonsArrayList(com.helger.commons.collection.impl.CommonsArrayList) StringHelper(com.helger.commons.string.StringHelper) PDTWebDateHelper(com.helger.commons.datetime.PDTWebDateHelper) IOException(java.io.IOException) File(java.io.File) JsonWriter(com.helger.json.serialize.JsonWriter) SimpleReadWriteLock(com.helger.commons.concurrent.SimpleReadWriteLock) MicroWriter(com.helger.xml.microdom.serialize.MicroWriter) Consumer(java.util.function.Consumer) PDStoredMLName(com.helger.pd.indexer.storage.PDStoredMLName) EQueryMode(com.helger.pd.indexer.storage.EQueryMode) CommonsLinkedHashMap(com.helger.commons.collection.impl.CommonsLinkedHashMap) ExcelStyle(com.helger.poi.excel.style.ExcelStyle) Comparator(java.util.Comparator) Query(org.apache.lucene.search.Query) MatchAllDocsQuery(org.apache.lucene.search.MatchAllDocsQuery) PDStoredIdentifier(com.helger.pd.indexer.storage.PDStoredIdentifier) PDStoredMLName(com.helger.pd.indexer.storage.PDStoredMLName) IDocumentTypeIdentifier(com.helger.peppolid.IDocumentTypeIdentifier) MatchAllDocsQuery(org.apache.lucene.search.MatchAllDocsQuery) PDStoredContact(com.helger.pd.indexer.storage.PDStoredContact)

Example 3 with PDStoredIdentifier

use of com.helger.pd.indexer.storage.PDStoredIdentifier in project phoss-directory by phax.

the class ExportAllManager method queryAllContainedBusinessCardsAsExcel.

@Nonnull
public static WorkbookCreationHelper queryAllContainedBusinessCardsAsExcel(@Nonnull final EQueryMode eQueryMode, final boolean bIncludeDocTypes) throws IOException {
    final Query aQuery = eQueryMode.getEffectiveQuery(new MatchAllDocsQuery());
    final ExcelStyle ES_DATE = new ExcelStyle().setDataFormat("yyyy-mm-dd");
    final ExcelStyle ES_WRAP = new ExcelStyle().setWrapText(true);
    @WillNotClose final WorkbookCreationHelper aWBCH = new WorkbookCreationHelper(EExcelVersion.XLSX);
    aWBCH.createNewSheet();
    aWBCH.addRow();
    aWBCH.addCell("Participant ID");
    aWBCH.addCell("Names (per-row)");
    aWBCH.addCell("Country code");
    aWBCH.addCell("Geo info");
    aWBCH.addCell("Identifier schemes");
    aWBCH.addCell("Identifier values");
    aWBCH.addCell("Websites");
    aWBCH.addCell("Contact type");
    aWBCH.addCell("Contact name");
    aWBCH.addCell("Contact phone");
    aWBCH.addCell("Contact email");
    aWBCH.addCell("Additional info");
    aWBCH.addCell("Registration date");
    if (bIncludeDocTypes)
        aWBCH.addCell("Document types");
    final Consumer<? super PDStoredBusinessEntity> aConsumer = aEntity -> {
        aWBCH.addRow();
        aWBCH.addCell(aEntity.getParticipantID().getURIEncoded());
        aWBCH.addCell(StringHelper.getImplodedMapped("\n", aEntity.names(), PDStoredMLName::getNameAndLanguageCode));
        aWBCH.addCellStyle(ES_WRAP);
        aWBCH.addCell(aEntity.getCountryCode());
        aWBCH.addCell(aEntity.getGeoInfo());
        aWBCH.addCellStyle(ES_WRAP);
        aWBCH.addCell(StringHelper.getImplodedMapped("\n", aEntity.identifiers(), PDStoredIdentifier::getScheme));
        aWBCH.addCellStyle(ES_WRAP);
        aWBCH.addCell(StringHelper.getImplodedMapped("\n", aEntity.identifiers(), PDStoredIdentifier::getValue));
        aWBCH.addCellStyle(ES_WRAP);
        aWBCH.addCell(StringHelper.getImploded("\n", aEntity.websiteURIs()));
        aWBCH.addCellStyle(ES_WRAP);
        aWBCH.addCell(StringHelper.getImplodedMapped("\n", aEntity.contacts(), PDStoredContact::getType));
        aWBCH.addCellStyle(ES_WRAP);
        aWBCH.addCell(StringHelper.getImplodedMapped("\n", aEntity.contacts(), PDStoredContact::getName));
        aWBCH.addCellStyle(ES_WRAP);
        aWBCH.addCell(StringHelper.getImplodedMapped("\n", aEntity.contacts(), PDStoredContact::getPhone));
        aWBCH.addCellStyle(ES_WRAP);
        aWBCH.addCell(StringHelper.getImplodedMapped("\n", aEntity.contacts(), PDStoredContact::getEmail));
        aWBCH.addCellStyle(ES_WRAP);
        aWBCH.addCell(aEntity.getAdditionalInformation());
        aWBCH.addCellStyle(ES_WRAP);
        aWBCH.addCell(aEntity.getRegistrationDate());
        aWBCH.addCellStyle(ES_DATE);
        if (bIncludeDocTypes) {
            aWBCH.addCell(StringHelper.getImplodedMapped("\n", aEntity.documentTypeIDs(), IDocumentTypeIdentifier::getURIEncoded));
            aWBCH.addCellStyle(ES_WRAP);
        }
    };
    // Query all and group by participant ID
    PDMetaManager.getStorageMgr().searchAllDocuments(aQuery, -1, aConsumer);
    aWBCH.autoSizeAllColumns();
    aWBCH.autoFilterAllColumns();
    return aWBCH;
}
Also used : Query(org.apache.lucene.search.Query) EExcelVersion(com.helger.poi.excel.EExcelVersion) CommonsTreeSet(com.helger.commons.collection.impl.CommonsTreeSet) IDocumentTypeIdentifier(com.helger.peppolid.IDocumentTypeIdentifier) PDMetaManager(com.helger.pd.indexer.mgr.PDMetaManager) LoggerFactory(org.slf4j.LoggerFactory) IMicroDocument(com.helger.xml.microdom.IMicroDocument) PDTFactory(com.helger.commons.datetime.PDTFactory) IMicroElement(com.helger.xml.microdom.IMicroElement) PDStoredBusinessEntity(com.helger.pd.indexer.storage.PDStoredBusinessEntity) PDField(com.helger.pd.indexer.storage.field.PDField) ThreadSafe(javax.annotation.concurrent.ThreadSafe) MatchAllDocsQuery(org.apache.lucene.search.MatchAllDocsQuery) ICommonsOrderedMap(com.helger.commons.collection.impl.ICommonsOrderedMap) StandardCharsets(java.nio.charset.StandardCharsets) JsonObject(com.helger.json.JsonObject) WorkbookCreationHelper(com.helger.poi.excel.WorkbookCreationHelper) ICommonsList(com.helger.commons.collection.impl.ICommonsList) IJsonArray(com.helger.json.IJsonArray) UnifiedResponse(com.helger.servlet.response.UnifiedResponse) CSVWriter(com.helger.commons.csv.CSVWriter) PDStoredContact(com.helger.pd.indexer.storage.PDStoredContact) Writer(java.io.Writer) WebFileIO(com.helger.photon.app.io.WebFileIO) ESuccess(com.helger.commons.state.ESuccess) FileSystemResource(com.helger.commons.io.resource.FileSystemResource) IJsonObject(com.helger.json.IJsonObject) MicroDocument(com.helger.xml.microdom.MicroDocument) CHttpHeader(com.helger.commons.http.CHttpHeader) JsonArray(com.helger.json.JsonArray) FileHelper(com.helger.commons.io.file.FileHelper) PDStoredIdentifier(com.helger.pd.indexer.storage.PDStoredIdentifier) ICommonsSortedSet(com.helger.commons.collection.impl.ICommonsSortedSet) IParticipantIdentifier(com.helger.peppolid.IParticipantIdentifier) Nonnull(javax.annotation.Nonnull) WillNotClose(javax.annotation.WillNotClose) Logger(org.slf4j.Logger) CommonsArrayList(com.helger.commons.collection.impl.CommonsArrayList) StringHelper(com.helger.commons.string.StringHelper) PDTWebDateHelper(com.helger.commons.datetime.PDTWebDateHelper) IOException(java.io.IOException) File(java.io.File) JsonWriter(com.helger.json.serialize.JsonWriter) SimpleReadWriteLock(com.helger.commons.concurrent.SimpleReadWriteLock) MicroWriter(com.helger.xml.microdom.serialize.MicroWriter) Consumer(java.util.function.Consumer) PDStoredMLName(com.helger.pd.indexer.storage.PDStoredMLName) EQueryMode(com.helger.pd.indexer.storage.EQueryMode) CommonsLinkedHashMap(com.helger.commons.collection.impl.CommonsLinkedHashMap) ExcelStyle(com.helger.poi.excel.style.ExcelStyle) Comparator(java.util.Comparator) Query(org.apache.lucene.search.Query) MatchAllDocsQuery(org.apache.lucene.search.MatchAllDocsQuery) ExcelStyle(com.helger.poi.excel.style.ExcelStyle) PDStoredIdentifier(com.helger.pd.indexer.storage.PDStoredIdentifier) PDStoredMLName(com.helger.pd.indexer.storage.PDStoredMLName) IDocumentTypeIdentifier(com.helger.peppolid.IDocumentTypeIdentifier) MatchAllDocsQuery(org.apache.lucene.search.MatchAllDocsQuery) WillNotClose(javax.annotation.WillNotClose) WorkbookCreationHelper(com.helger.poi.excel.WorkbookCreationHelper) PDStoredContact(com.helger.pd.indexer.storage.PDStoredContact) Nonnull(javax.annotation.Nonnull)

Aggregations

PDStoredContact (com.helger.pd.indexer.storage.PDStoredContact)3 PDStoredIdentifier (com.helger.pd.indexer.storage.PDStoredIdentifier)3 PDStoredMLName (com.helger.pd.indexer.storage.PDStoredMLName)3 CommonsArrayList (com.helger.commons.collection.impl.CommonsArrayList)2 CommonsLinkedHashMap (com.helger.commons.collection.impl.CommonsLinkedHashMap)2 CommonsTreeSet (com.helger.commons.collection.impl.CommonsTreeSet)2 ICommonsList (com.helger.commons.collection.impl.ICommonsList)2 ICommonsOrderedMap (com.helger.commons.collection.impl.ICommonsOrderedMap)2 ICommonsSortedSet (com.helger.commons.collection.impl.ICommonsSortedSet)2 SimpleReadWriteLock (com.helger.commons.concurrent.SimpleReadWriteLock)2 CSVWriter (com.helger.commons.csv.CSVWriter)2 PDTFactory (com.helger.commons.datetime.PDTFactory)2 PDTWebDateHelper (com.helger.commons.datetime.PDTWebDateHelper)2 CHttpHeader (com.helger.commons.http.CHttpHeader)2 FileHelper (com.helger.commons.io.file.FileHelper)2 FileSystemResource (com.helger.commons.io.resource.FileSystemResource)2 ESuccess (com.helger.commons.state.ESuccess)2 StringHelper (com.helger.commons.string.StringHelper)2 IJsonArray (com.helger.json.IJsonArray)2 IJsonObject (com.helger.json.IJsonObject)2