@@ -345,6 +345,92 @@ public static void generateFlatFileSampleToFile(String name, SourceGenerator sg,
345
345
sg .close ();
346
346
}
347
347
348
+ /**
349
+ * generates the code for a local flat file loader action
350
+ *
351
+ * @param name data object name
352
+ * @param sg source generator
353
+ * @param module parent module
354
+ * @throws IOException if anything bad happens during code generation
355
+ * @since 1.15
356
+ */
357
+ public static void generateFlatFileLocalLoaderToFile (String name , SourceGenerator sg , Module module ,DataObjectDefinition object ) throws IOException {
358
+ String objectclass = StringFormatter .formatForJavaClass (object .getName ());
359
+ String objectvariable = StringFormatter .formatForAttribute (object .getName ());
360
+ String loadername = StringFormatter .formatForJavaClass (name );
361
+
362
+ sg .wl ("package " + module .getPath () + ".action.generated;" );
363
+ sg .wl ("" );
364
+ sg .wl ("import java.util.function.Function;" );
365
+ sg .wl ("" );
366
+ sg .wl ("import org.openlowcode.module.system.data.choice.ApplocaleChoiceDefinition;" );
367
+ sg .wl ("import org.openlowcode.module.system.data.choice.PreferedfileencodingChoiceDefinition;" );
368
+ sg .wl ("import org.openlowcode.module.system.page.ShowloadingreportforchildrenPage;" );
369
+ sg .wl ("import org.openlowcode.server.data.ChoiceValue;" );
370
+ sg .wl ("import org.openlowcode.server.data.loader.FlatFileLoader;" );
371
+ sg .wl ("import org.openlowcode.server.data.loader.FlatFileLoaderReport;" );
372
+ sg .wl ("import org.openlowcode.server.data.properties.DataObjectId;" );
373
+ sg .wl ("import org.openlowcode.server.data.storage.QueryFilter;" );
374
+ sg .wl ("import org.openlowcode.server.data.storage.TableAlias;" );
375
+ sg .wl ("import org.openlowcode.server.graphic.SPage;" );
376
+ sg .wl ("import org.openlowcode.server.runtime.SModule;" );
377
+ sg .wl ("import org.openlowcode.tools.messages.SFile;" );
378
+ sg .wl ("" );
379
+ sg .wl ("" );
380
+ sg .wl ("import " + module .getPath () + ".data." +objectclass +";" );
381
+ sg .wl ("" );
382
+ sg .wl ("public class Atg" +loadername +"Action" );
383
+ sg .wl (" extends" );
384
+ sg .wl (" Abs" +loadername +"Action {" );
385
+ sg .wl ("" );
386
+ sg .wl (" public Atg" +loadername +"Action(SModule parent) {" );
387
+ sg .wl (" super(parent);" );
388
+ sg .wl ("" );
389
+ sg .wl (" }" );
390
+ sg .wl ("" );
391
+ sg .wl (" @Override" );
392
+ sg .wl (" public ActionOutputData executeActionLogic(" );
393
+ sg .wl (" DataObjectId<" +objectclass +"> " +objectvariable +"id," );
394
+ sg .wl (" ChoiceValue<ApplocaleChoiceDefinition> locale," );
395
+ sg .wl (" ChoiceValue<PreferedfileencodingChoiceDefinition> encoding," );
396
+ sg .wl (" SFile file," );
397
+ sg .wl (" Function<TableAlias, QueryFilter> datafilter) {" );
398
+ sg .wl (" " +objectclass +" " +objectvariable +" = " +objectclass +".readone(" +objectvariable +"id);" );
399
+ sg .wl (" FlatFileLoader<" +objectclass +"> loader = new FlatFileLoader<" +objectclass +">(" +objectclass +".getDefinition(),locale,encoding);" );
400
+ sg .wl (" loader.setHardObject(" +objectvariable +");" );
401
+ sg .wl (" FlatFileLoaderReport returnmessage = loader.load(file);" );
402
+ sg .wl (" return new ActionOutputData(returnmessage.getContext()," );
403
+ sg .wl (" returnmessage.getInserted()," );
404
+ sg .wl (" returnmessage.getUpdated()," );
405
+ sg .wl (" returnmessage.getError()," );
406
+ sg .wl (" returnmessage.getPostprocError()," );
407
+ sg .wl (" (int)(returnmessage.getLoadingtimems()/1000)," );
408
+ sg .wl (" returnmessage.getErrordetails()," );
409
+ sg .wl (" " +objectvariable +"id);" );
410
+ sg .wl (" }" );
411
+ sg .wl ("" );
412
+ sg .wl (" @Override" );
413
+ sg .wl (" public SPage choosePage(ActionOutputData logicoutput) {" );
414
+ sg .wl (" return new ShowloadingreportforchildrenPage(logicoutput.getLoadingcontext()," );
415
+ sg .wl (" logicoutput.getInserted()," );
416
+ sg .wl (" logicoutput.getUpdated()," );
417
+ sg .wl (" logicoutput.getErrors()," );
418
+ sg .wl (" logicoutput.getPostprocerrors()," );
419
+ sg .wl (" logicoutput.getLoadingtime()," );
420
+ sg .wl (" logicoutput.getErrordetail()," );
421
+ sg .wl (" logicoutput.get" +objectclass +"id_thru());" );
422
+ sg .wl (" }" );
423
+ sg .wl ("" );
424
+ sg .wl ("}" );
425
+
426
+
427
+
428
+
429
+
430
+
431
+ sg .close ();
432
+ }
433
+
348
434
/**
349
435
* generates the code for the flat file loader action
350
436
*
0 commit comments