throw new ApplicationException(i18n.tr("CSV-Datei enth�lt keine weiteren Daten"));
int created = 0;
int error = 0;
int skipped = 0;
DBObject object = null;
String value = null;
List<Column> cols = p.getColumns();
ImportListener l = f.getImportListener();
DBService service = (DBService) Application.getServiceFactory().lookup(HBCI.class,"database");
do
{
monitor.log(i18n.tr("Importiere Zeile {0}",Integer.toString(csv.getLineNumber())));
monitor.addPercentComplete(1);
try
{
object = service.createObject(f.getType(),null);
// Spalten zuordnen
Map<String, Object> values = new HashMap<String,Object>();
for (int i=0;i<line.size();++i)
{
Column column = null;
for (Column c:cols)
{
if (c.getColumn() == i)
{
column = c;
break;
}
}
if (column == null)
continue; // Spalte nicht zugeordnet
// Checken, ob in der Spalte was steht
value = line.get(i);
if (value == null)
continue;
value = value.trim();
if (value.length() == 0)
continue;
try
{
// Werte zwischenspeichern
Object prev = values.get(column.getProperty());
values.put(column.getProperty(),column.getSerializer().unserialize(prev,value));
}
catch (Exception e)
{
Logger.error("unable to unserialize " + column.getProperty() + " for line " + csv.getLineNumber() + ", value: " + value,e);
monitor.log(" " + i18n.tr("Ung�ltiger Wert \"{0}\" in Spalte \"{1}\": {2}",value,column.getName(),e.getMessage()));
}
}
// beforeSet-Listener ausloesen
if (l != null)
{
ImportEvent e = new ImportEvent();
e.context = context;
e.data = values;
try
{
l.beforeSet(e);
}
catch (OperationCanceledException oce)
{
skipped++;
String msg = oce.getMessage();
if (msg != null && msg.length() > 0)
monitor.log(" " + msg);
continue;
}
}
// Werte in die Bean uebernehmen
Iterator<String> it = values.keySet().iterator();
while (it.hasNext())
{
String name = it.next();
Object o = values.get(name);
try
{
BeanUtil.set(object,name,o);
}
catch (Exception e)
{
Logger.error("unable to apply property " + name + " for line " + csv.getLineNumber() + ", value: " + o,e);
String[] s = new String[]{value,
name,
e.getMessage()};
monitor.log(" " + i18n.tr("Ung�ltiger Wert \"{0}\" in Spalte \"{1}\": {2}",s));
}
}
if (l != null)
{
ImportEvent e = new ImportEvent();
e.context = context;
e.data = object;
try
{
l.beforeStore(e);
}
catch (OperationCanceledException oce)
{
skipped++;
String msg = oce.getMessage();
if (msg != null && msg.length() > 0)
monitor.log(" " + msg);
continue;
}
}
object.store();
Application.getMessagingFactory().sendMessage(new ImportMessage(object));
created++;
}
catch (Exception e)
{