Skip to content
Snippets Groups Projects
Commit 7225f646 authored by Robert Goldmann's avatar Robert Goldmann
Browse files

#576 - refactored ImportEntityType enum:

added localiazation key and icon
parent a775c3fe
No related branches found
No related tags found
No related merge requests found
package de.deadlocker8.budgetmaster.services;
public enum EntityType
{
ACCOUNT("account_balance"),
TRANSACTION("list"),
CATEGORY("label"),
TEMPLATE("file_copy"),
CHART("show_chart"),
IMAGE("image");
private final String icon;
EntityType(String icon)
{
this.icon = icon;
}
public String getIcon()
{
return icon;
}
public String getLocalizationKey()
{
return "entity." + this.name().toLowerCase();
}
}
package de.deadlocker8.budgetmaster.services;
public enum ImportEntityType
{
ACCOUNT,
TRANSACTION,
CATEGORY,
TEMPLATE,
CHART,
IMAGE
}
......@@ -59,19 +59,19 @@ public class ImportService
this.repeatingTransactionUpdater = repeatingTransactionUpdater;
}
public Map<ImportEntityType, Integer> importDatabase(Database database, AccountMatchList accountMatchList)
public Map<EntityType, Integer> importDatabase(Database database, AccountMatchList accountMatchList)
{
this.database = database;
final Map<ImportEntityType, Integer> numberOfImportedEntitiesByType = new EnumMap<>(ImportEntityType.class);
final Map<EntityType, Integer> numberOfImportedEntitiesByType = new EnumMap<>(EntityType.class);
LOGGER.debug("Importing database...");
numberOfImportedEntitiesByType.put(ImportEntityType.CATEGORY, importCategories());
numberOfImportedEntitiesByType.put(ImportEntityType.ACCOUNT, importAccounts(accountMatchList));
numberOfImportedEntitiesByType.put(ImportEntityType.TRANSACTION, importTransactions());
numberOfImportedEntitiesByType.put(ImportEntityType.CHART, importCharts());
numberOfImportedEntitiesByType.put(ImportEntityType.IMAGE, importImages());
numberOfImportedEntitiesByType.put(ImportEntityType.TEMPLATE, importTemplates());
numberOfImportedEntitiesByType.put(EntityType.CATEGORY, importCategories());
numberOfImportedEntitiesByType.put(EntityType.ACCOUNT, importAccounts(accountMatchList));
numberOfImportedEntitiesByType.put(EntityType.TRANSACTION, importTransactions());
numberOfImportedEntitiesByType.put(EntityType.CHART, importCharts());
numberOfImportedEntitiesByType.put(EntityType.IMAGE, importImages());
numberOfImportedEntitiesByType.put(EntityType.TEMPLATE, importTemplates());
LOGGER.debug("Updating repeating transactions...");
repeatingTransactionUpdater.updateRepeatingTransactions(DateTime.now());
......
......@@ -11,7 +11,7 @@ import de.deadlocker8.budgetmaster.database.Database;
import de.deadlocker8.budgetmaster.database.DatabaseParser;
import de.deadlocker8.budgetmaster.database.DatabaseService;
import de.deadlocker8.budgetmaster.database.accountmatches.AccountMatchList;
import de.deadlocker8.budgetmaster.services.ImportEntityType;
import de.deadlocker8.budgetmaster.services.EntityType;
import de.deadlocker8.budgetmaster.services.ImportService;
import de.deadlocker8.budgetmaster.services.UpdateCheckService;
import de.deadlocker8.budgetmaster.update.BudgetMasterUpdateService;
......@@ -283,17 +283,17 @@ public class SettingsController extends BaseController
@PostMapping("/database/import")
public String importDatabase(WebRequest request, @ModelAttribute("Import") AccountMatchList accountMatchList, Model model)
{
final Map<ImportEntityType, Integer> numberOfImportedEntitiesByType = importService.importDatabase((Database) request.getAttribute("database", WebRequest.SCOPE_SESSION), accountMatchList);
final Map<EntityType, Integer> numberOfImportedEntitiesByType = importService.importDatabase((Database) request.getAttribute("database", WebRequest.SCOPE_SESSION), accountMatchList);
request.removeAttribute("database", RequestAttributes.SCOPE_SESSION);
prepareBasicModel(model, settingsService.getSettings());
final String message = Localization.getString("notification.settings.database.import.success",
numberOfImportedEntitiesByType.get(ImportEntityType.ACCOUNT),
numberOfImportedEntitiesByType.get(ImportEntityType.TRANSACTION),
numberOfImportedEntitiesByType.get(ImportEntityType.CATEGORY),
numberOfImportedEntitiesByType.get(ImportEntityType.TEMPLATE),
numberOfImportedEntitiesByType.get(ImportEntityType.CHART),
numberOfImportedEntitiesByType.get(ImportEntityType.IMAGE));
numberOfImportedEntitiesByType.get(EntityType.ACCOUNT),
numberOfImportedEntitiesByType.get(EntityType.TRANSACTION),
numberOfImportedEntitiesByType.get(EntityType.CATEGORY),
numberOfImportedEntitiesByType.get(EntityType.TEMPLATE),
numberOfImportedEntitiesByType.get(EntityType.CHART),
numberOfImportedEntitiesByType.get(EntityType.IMAGE));
WebRequestUtils.putNotification(request, new Notification(message, NotificationType.SUCCESS));
return "settings/settings";
......
......@@ -538,3 +538,10 @@ statistics.number.of.templates={0} Vorlagen
statistics.number.of.custom.charts={0} Eigene Diagramme
statistics.number.of.categories={0} Kategorien
statistics.first.transaction=Erste Buchung {0}
entity.account=Konten
entity.category=Kategorien
entity.transaction=Buchungen
entity.template=Vorlagen
entity.chart=Diagramme
entity.image=Bilder
......@@ -536,3 +536,10 @@ statistics.number.of.templates={0} Templates
statistics.number.of.custom.charts={0} Custom Charts
statistics.number.of.categories={0} Categories
statistics.first.transaction=First Transaction {0}
entity.account=Accounts
entity.category=Categories
entity.transaction=Transactions
entity.template=Templates
entity.chart=Charts
entity.image=Images
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment