An easy way is to create a utility method, directly in java. The method takes a List and returns the analogue Recordset. The java implementation could look as follows:
package xpertivy.migration3x.util;
import java.util.Arrays;
import ch.ivyteam.ivy.scripting.objects.List;
import ch.ivyteam.ivy.scripting.objects.Recordset;
import ch.ivyteam.ivy.scripting.objects.util.MetaType;
public class Ivy3MigrationUtils {
private Ivy3MigrationUtils() {}
public static Recordset getListOfTypeXAsRecordset(List<TypeX> listOfX) {
List<String> columns = List.create(String.class, Arrays.asList("ColumnNameA", "ColumnNameB"));
Arrays.asList("ColumnA", "ColumnB"));
List<List<Object>> rows = List.create(MetaType.listOf(Object.class));
for (TypeX typeX : listOfX)
{
List<Object> recordsetEntry = List.create(Object.class);
recordsetEntry.add(typeX.getA());
recordsetEntry.add(typeX.getB());
/* add further column values here */
rows.add(recordsetEntry);
}
return new Recordset(columns , rows);
}
}
The call of the utility-method in a process-step could look as follows:
import xpertivy.migration3x.util.Ivy3MigrationUtils;
List<TypeX> listOfTypeX = ivy.foo.getListOfX();
in.myRecordset = Ivy3MigrationUtils.getListOfTypeXAsRecordset(listOfTypeX);