Search in sources :

Example 6 with WorksheetSpec

use of org.isisaddons.module.excel.dom.WorksheetSpec in project estatio by estatio.

the class BudgetImportExportManager method importBudget.

@Action(publishing = Publishing.DISABLED, semantics = SemanticsOf.IDEMPOTENT)
@ActionLayout()
@CollectionLayout()
public Budget importBudget(@Parameter(fileAccept = ".xlsx") @ParameterLayout(named = "Excel spreadsheet") final Blob spreadsheet) {
    WorksheetSpec spec1 = new WorksheetSpec(BudgetImportExport.class, "budget");
    WorksheetSpec spec2 = new WorksheetSpec(KeyItemImportExportLineItem.class, "keyItems");
    WorksheetSpec spec3 = new WorksheetSpec(BudgetOverrideImportExport.class, "overrides");
    WorksheetSpec spec4 = new WorksheetSpec(ChargeImport.class, "charges");
    List<List<?>> objects = excelService.fromExcel(spreadsheet, Arrays.asList(spec1, spec2, spec3, spec4));
    // first upsert charges
    List<ChargeImport> chargeImportLines = (List<ChargeImport>) objects.get(3);
    for (ChargeImport lineItem : chargeImportLines) {
        lineItem.importData(null);
    }
    // import budget en items
    List<BudgetImportExport> budgetItemLines = importBudgetAndItems(objects);
    // import keyTables
    importKeyTables(budgetItemLines, objects);
    // import overrides
    importOverrides(objects);
    return getBudget();
}
Also used : WorksheetSpec(org.isisaddons.module.excel.dom.WorksheetSpec) ChargeImport(org.estatio.module.charge.imports.ChargeImport) ArrayList(java.util.ArrayList) List(java.util.List) Action(org.apache.isis.applib.annotation.Action) ActionLayout(org.apache.isis.applib.annotation.ActionLayout) CollectionLayout(org.apache.isis.applib.annotation.CollectionLayout)

Example 7 with WorksheetSpec

use of org.isisaddons.module.excel.dom.WorksheetSpec in project estatio by estatio.

the class Budget_DownloadCalculations method downloadCalculations.

@Action(semantics = SemanticsOf.SAFE)
@ActionLayout(cssClassFa = "fa-download")
public Blob downloadCalculations() {
    final String fileName = budget.title() + ".xlsx";
    WorksheetSpec spec = new WorksheetSpec(CalculationResultViewModel.class, "values");
    WorksheetContent worksheetContent = new WorksheetContent(budgetAssignmentService.getCalculationResults(budget), spec);
    return excelService.toExcelPivot(worksheetContent, fileName);
}
Also used : WorksheetSpec(org.isisaddons.module.excel.dom.WorksheetSpec) WorksheetContent(org.isisaddons.module.excel.dom.WorksheetContent) Action(org.apache.isis.applib.annotation.Action) ActionLayout(org.apache.isis.applib.annotation.ActionLayout)

Example 8 with WorksheetSpec

use of org.isisaddons.module.excel.dom.WorksheetSpec in project estatio by estatio.

the class CodaMappingManager method downloadToExcel.

@Action(semantics = SemanticsOf.SAFE)
@MemberOrder(name = "mappings", sequence = "1")
public Blob downloadToExcel(final String fileName) {
    final List<CodaMappingImport> exports = getMappings().stream().map(x -> new CodaMappingImport(x)).collect(Collectors.toList());
    WorksheetSpec spec = new WorksheetSpec(CodaMappingImport.class, SHEET_NAME);
    WorksheetContent worksheetContent = new WorksheetContent(exports, spec);
    return excelService.toExcel(worksheetContent, fileName);
}
Also used : Action(org.apache.isis.applib.annotation.Action) Nature(org.apache.isis.applib.annotation.Nature) CodaMappingRepository(org.estatio.module.capex.dom.coda.CodaMappingRepository) Collectors(java.util.stream.Collectors) MemberOrder(org.apache.isis.applib.annotation.MemberOrder) Inject(javax.inject.Inject) ActionLayout(org.apache.isis.applib.annotation.ActionLayout) CollectionLayout(org.apache.isis.applib.annotation.CollectionLayout) SemanticsOf(org.apache.isis.applib.annotation.SemanticsOf) List(java.util.List) WorksheetContent(org.isisaddons.module.excel.dom.WorksheetContent) DomainObject(org.apache.isis.applib.annotation.DomainObject) CodaMapping(org.estatio.module.capex.dom.coda.CodaMapping) WorksheetSpec(org.isisaddons.module.excel.dom.WorksheetSpec) Contributed(org.apache.isis.applib.annotation.Contributed) Parameter(org.apache.isis.applib.annotation.Parameter) Publishing(org.apache.isis.applib.annotation.Publishing) ExcelService(org.isisaddons.module.excel.dom.ExcelService) Blob(org.apache.isis.applib.value.Blob) WorksheetSpec(org.isisaddons.module.excel.dom.WorksheetSpec) WorksheetContent(org.isisaddons.module.excel.dom.WorksheetContent) Action(org.apache.isis.applib.annotation.Action) MemberOrder(org.apache.isis.applib.annotation.MemberOrder)

Example 9 with WorksheetSpec

use of org.isisaddons.module.excel.dom.WorksheetSpec in project estatio by estatio.

the class IncomingInvoiceDownloadManager method downloadToExcel.

@Action(semantics = SemanticsOf.SAFE)
public Blob downloadToExcel(final String fileName) {
    final List<IncomingInvoiceExport> exports = getInvoiceItems().stream().map(item -> new IncomingInvoiceExport(item, documentNumberFor(item), codaElementFor(item), commentsFor(item))).sorted(// guard only for (demo)fixtures because in production a document can be expected
    Comparator.comparing(x -> x.getDocumentNumber() != null ? x.getDocumentNumber() : "_No_Document")).collect(Collectors.toList());
    WorksheetSpec spec = new WorksheetSpec(IncomingInvoiceDownloadManager.exportClass, "invoiceExport");
    WorksheetContent worksheetContent = new WorksheetContent(exports, spec);
    return excelService.toExcel(worksheetContent, fileName);
}
Also used : WorksheetSpec(org.isisaddons.module.excel.dom.WorksheetSpec) WorksheetContent(org.isisaddons.module.excel.dom.WorksheetContent) Action(org.apache.isis.applib.annotation.Action)

Example 10 with WorksheetSpec

use of org.isisaddons.module.excel.dom.WorksheetSpec in project estatio by estatio.

the class KeyItemImportExportManager method importBlob.

// endregion
// region > import (action)
@Action(publishing = Publishing.DISABLED, semantics = SemanticsOf.IDEMPOTENT)
@ActionLayout(named = "Import", cssClassFa = "fa-upload")
@MemberOrder(name = "keyItems", sequence = "2")
public List<KeyItemImportExportLineItem> importBlob(@Parameter(fileAccept = ".xlsx") @ParameterLayout(named = "Excel spreadsheet") final Blob spreadsheet) {
    WorksheetSpec spec = new WorksheetSpec(KeyItemImportExportLineItem.class, "keyItems");
    List<KeyItemImportExportLineItem> lineItems = excelService.fromExcel(spreadsheet, spec);
    container.informUser(lineItems.size() + " items imported");
    List<KeyItemImportExportLineItem> newItems = new ArrayList<>();
    for (KeyItemImportExportLineItem item : lineItems) {
        item.validate();
        newItems.add(new KeyItemImportExportLineItem(item));
    }
    for (KeyItem keyItem : keyTable.getItems()) {
        Boolean keyItemFound = false;
        for (KeyItemImportExportLineItem lineItem : newItems) {
            if (lineItem.getUnitReference().equals(keyItem.getUnit().getReference())) {
                keyItemFound = true;
                break;
            }
        }
        if (!keyItemFound) {
            KeyItemImportExportLineItem deletedItem = new KeyItemImportExportLineItem(keyItem);
            deletedItem.setStatus(Status.DELETED);
            newItems.add(deletedItem);
        }
    }
    return newItems;
}
Also used : WorksheetSpec(org.isisaddons.module.excel.dom.WorksheetSpec) ArrayList(java.util.ArrayList) KeyItem(org.estatio.module.budget.dom.keyitem.KeyItem) Action(org.apache.isis.applib.annotation.Action) MemberOrder(org.apache.isis.applib.annotation.MemberOrder) ActionLayout(org.apache.isis.applib.annotation.ActionLayout)

Aggregations

WorksheetSpec (org.isisaddons.module.excel.dom.WorksheetSpec)12 Action (org.apache.isis.applib.annotation.Action)10 ActionLayout (org.apache.isis.applib.annotation.ActionLayout)9 WorksheetContent (org.isisaddons.module.excel.dom.WorksheetContent)8 MemberOrder (org.apache.isis.applib.annotation.MemberOrder)5 List (java.util.List)3 CollectionLayout (org.apache.isis.applib.annotation.CollectionLayout)3 ArrayList (java.util.ArrayList)2 Collectors (java.util.stream.Collectors)2 Contributed (org.apache.isis.applib.annotation.Contributed)2 DomainObject (org.apache.isis.applib.annotation.DomainObject)2 Nature (org.apache.isis.applib.annotation.Nature)2 SemanticsOf (org.apache.isis.applib.annotation.SemanticsOf)2 Blob (org.apache.isis.applib.value.Blob)2 ExcelService (org.isisaddons.module.excel.dom.ExcelService)2 Inject (javax.inject.Inject)1 Getter (lombok.Getter)1 NoArgsConstructor (lombok.NoArgsConstructor)1 Setter (lombok.Setter)1 Parameter (org.apache.isis.applib.annotation.Parameter)1