use of com.helger.poi.excel.WorkbookCreationHelper in project phoss-directory by phax.
the class ExportAllManager method writeFileBusinessCardExcel.
@Nonnull
static ESuccess writeFileBusinessCardExcel(@Nonnull final EQueryMode eQueryMode) throws IOException {
try (final WorkbookCreationHelper aWBCH = queryAllContainedBusinessCardsAsExcel(eQueryMode, true)) {
final File f = _getInternalFileBusinessCardExcel();
// Do it in a write lock!
RW_LOCK.writeLock().lock();
try {
if (aWBCH.writeTo(f).isFailure()) {
if (LOGGER.isErrorEnabled())
LOGGER.error("Failed to export all BCs as XLSX to " + f.getAbsolutePath());
return ESuccess.FAILURE;
}
LOGGER.info("Successfully exported all BCs as XLSX to " + f.getAbsolutePath());
} finally {
RW_LOCK.writeLock().unlock();
}
}
return ESuccess.SUCCESS;
}
use of com.helger.poi.excel.WorkbookCreationHelper in project phoss-directory by phax.
the class ExportAllManager method writeFileBusinessCardExcel.
@Nonnull
static ESuccess writeFileBusinessCardExcel() throws IOException {
try (final WorkbookCreationHelper aWBCH = queryAllContainedBusinessCardsAsExcel(true)) {
final File f = _getInternalFileBusinessCardExcel();
// Do it in a write lock!
RW_LOCK.writeLock().lock();
try {
if (aWBCH.writeTo(f).isFailure()) {
if (LOGGER.isErrorEnabled())
LOGGER.error("Failed to export all BCs as XLSX to " + f.getAbsolutePath());
return ESuccess.FAILURE;
}
LOGGER.info("Successfully exported all BCs as XLSX to " + f.getAbsolutePath());
} finally {
RW_LOCK.writeLock().unlock();
}
}
return ESuccess.SUCCESS;
}
use of com.helger.poi.excel.WorkbookCreationHelper in project phoss-directory by phax.
the class ExportAllManager method queryAllContainedBusinessCardsAsExcel.
@Nonnull
public static WorkbookCreationHelper queryAllContainedBusinessCardsAsExcel(final boolean bIncludeDocTypes) throws IOException {
final Query aQuery = 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;
}
use of com.helger.poi.excel.WorkbookCreationHelper 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;
}
Aggregations