use of org.estatio.module.budgetassignment.imports.KeyItemImportExportLineItem in project estatio by estatio.
the class BudgetImportExportManager method importKeyTables.
private void importKeyTables(final List<BudgetImportExport> budgetItemLines, final List<List<?>> objects) {
List<KeyTable> keyTablesToImport = keyTablesToImport(budgetItemLines);
List<KeyItemImportExportLineItem> keyItemLines = (List<KeyItemImportExportLineItem>) objects.get(1);
// filter case where no key items are filled in
if (keyItemLines.size() == 0) {
return;
}
for (KeyTable keyTable : keyTablesToImport) {
List<KeyItemImportExportLineItem> itemsToImportForKeyTable = new ArrayList<>();
for (KeyItemImportExportLineItem keyItemLine : keyItemLines) {
if (keyItemLine.getKeyTableName().equals(keyTable.getName())) {
itemsToImportForKeyTable.add(new KeyItemImportExportLineItem(keyItemLine));
}
}
for (KeyItem keyItem : keyTable.getItems()) {
Boolean keyItemFound = false;
for (KeyItemImportExportLineItem lineItem : itemsToImportForKeyTable) {
if (lineItem.getUnitReference().equals(keyItem.getUnit().getReference())) {
keyItemFound = true;
break;
}
}
if (!keyItemFound) {
KeyItemImportExportLineItem deletedItem = new KeyItemImportExportLineItem(keyItem);
deletedItem.setStatus(Status.DELETED);
itemsToImportForKeyTable.add(deletedItem);
}
}
for (KeyItemImportExportLineItem item : itemsToImportForKeyTable) {
serviceRegistry2.injectServicesInto(item);
item.validate();
item.apply();
}
}
}
Aggregations