Search in sources :

Example 1 with CollectionLayout

use of org.apache.isis.applib.annotation.CollectionLayout in project estatio by estatio.

the class ChargeImportManager method importBlob.

// region > importBlob (action)
@Action(publishing = Publishing.DISABLED, semantics = SemanticsOf.IDEMPOTENT)
@CollectionLayout(paged = -1)
public List<ChargeImport> importBlob(@Parameter(fileAccept = ".xlsx") @ParameterLayout(named = "Excel spreadsheet") final Blob spreadsheet) {
    List<ChargeImport> lineItems = excelService.fromExcel(spreadsheet, ChargeImport.class, ChargeImport.class.getSimpleName());
    ChargeImport previous = null;
    for (ChargeImport lineItem : lineItems) {
        lineItem.importData(previous);
        previous = lineItem;
    }
    return lineItems;
}
Also used : ChargeImport(org.estatio.module.charge.imports.ChargeImport) Action(org.apache.isis.applib.annotation.Action) CollectionLayout(org.apache.isis.applib.annotation.CollectionLayout)

Example 2 with CollectionLayout

use of org.apache.isis.applib.annotation.CollectionLayout 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)

Aggregations

Action (org.apache.isis.applib.annotation.Action)2 CollectionLayout (org.apache.isis.applib.annotation.CollectionLayout)2 ChargeImport (org.estatio.module.charge.imports.ChargeImport)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 ActionLayout (org.apache.isis.applib.annotation.ActionLayout)1 WorksheetSpec (org.isisaddons.module.excel.dom.WorksheetSpec)1