in importer/src/main/java/org/apache/fineract/cn/accounting/importer/AccountImporter.java [91:152]
private RecordFromLineNumber<Account> toAccount(final CSVRecord csvRecord) {
try {
final String ledgerIdentifier = csvRecord.get(PARENT_IDENTIFIER_COLUMN);
String type;
try {
type = csvRecord.get(TYPE_COLUMN);
}
catch (final IllegalArgumentException e) {
final Ledger ledger = ledgerManager.findLedger(ledgerIdentifier);
type = ledger.getType();
}
final String identifier = csvRecord.get(IDENTIFIER_COLUMN);
String name;
try {
name = csvRecord.get(NAME_COLUMN);
}
catch (final IllegalArgumentException e) {
name = identifier;
}
Set<String> holders;
try {
holders = new HashSet<>(Arrays.asList(csvRecord.get(HOLDERS_COLUMN).split("/")));
}
catch (final IllegalArgumentException e) {
holders = Collections.emptySet();
}
Set<String> authorities;
try {
authorities = new HashSet<>(Arrays.asList(csvRecord.get(AUTHORITIES_COLUMN).split("/")));
}
catch (final IllegalArgumentException e) {
authorities = Collections.emptySet();
}
Double balance;
try {
balance = Double.valueOf(csvRecord.get(BALANCE_COLUMN));
}
catch (final IllegalArgumentException e) {
balance = 0.0;
}
final Account account = new Account();
account.setType(type);
account.setIdentifier(identifier);
account.setName(name);
account.setHolders(holders);
account.setSignatureAuthorities(authorities);
account.setLedger(ledgerIdentifier);
account.setBalance(balance);
return new RecordFromLineNumber<>(csvRecord.getRecordNumber(), account);
}
catch (final NumberFormatException e) {
logger.warn("Number parsing failed on record {}", csvRecord.getRecordNumber());
throw e;
}
catch (final IllegalArgumentException e) {
logger.warn("Parsing failed on record {}", csvRecord.getRecordNumber());
throw e;
}
}