When migrating projects from version 3.x to 4.x or 5.x some APIs has changed and calls has to be rewritten.

In versions > 4.x most APIs returns List, however similar APIs in 3.x returns Recordsets.

Therefore, what is the easiest way to convert a List (of a specific type) to a Recordset, so that I only has to change the calls and I do not have to touch the existing process?

asked 31.10.2013 at 14:30

Flavio%20Sadeghi's gravatar image

Flavio Sadeghi ♦♦
(suspended)
accept rate: 75%


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("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);
link

answered 31.10.2013 at 14:32

Flavio%20Sadeghi's gravatar image

Flavio Sadeghi ♦♦
(suspended)
accept rate: 75%

edited 31.10.2013 at 14:35

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×33
×4

Asked: 31.10.2013 at 14:30

Seen: 3,702 times

Last updated: 31.10.2013 at 14:35