use of org.eclipse.persistence.sessions.DatabaseRecord in project eclipselink by eclipse-ee4j.
the class PLSQLTestModel method getCollectionTestSuite.
public static TestSuite getCollectionTestSuite() {
TestSuite suite = new TestSuite();
suite.setName("PLSQLCollectionTestSuite");
suite.setDescription("This suite tests calling PLSQL procedures that take collections.");
Address address = new Address();
address.setId(new BigDecimal(123));
address.setNumber(17);
address.setStreet("Bank");
address.setCity("Ottawa");
address.setState("ON");
Phone phone = new Phone();
phone.setAreaCode("613");
phone.setNumber("7927711");
Employee employee = new Employee();
employee.setId(new BigDecimal(123));
employee.setName("Bob Jones");
employee.setAddress(address);
employee.getPhones().add(phone);
List args = new ArrayList();
DatabaseRecord result = new DatabaseRecord();
List collection = new ArrayList();
collection.add("Ottawa");
result.put("P_CITY_LIST", collection);
result.put("P_CITY", "Nepean");
PLSQLTest test = new PLSQLTest("CityListOut", Address.class, args, result);
test.setName("CityListOutTest");
suite.addTest(test);
args = new ArrayList();
collection = new ArrayList(Arrays.asList("Ottawa", "Toronto"));
args.add(collection);
args.add("Nepean");
result = new DatabaseRecord();
result.put("P_CITY_LIST", collection);
result.put("P_CITY", "Nepean");
test = new PLSQLTest("CityListInOut", Address.class, args, result);
test.setName("CityListInOutTest");
suite.addTest(test);
args = new ArrayList();
args.add(new Object[] { address, address });
args.add("Nepean");
test = new PLSQLTest("AddressListIn", Address.class, args);
test.setName("AddressListInTest");
suite.addTest(test);
args = new ArrayList();
result = new DatabaseRecord();
result.put("P_ADDRESS_LIST", new ArrayList());
result.put("P_CITY", "Nepean");
test = new PLSQLTest("AddressListOut", Address.class, args, result);
test.setName("AddressListOutTest");
suite.addTest(test);
args = new ArrayList();
collection = new ArrayList(Arrays.asList(address, address));
args.add(collection);
args.add("Nepean");
result = new DatabaseRecord();
result.put("P_ADDRESS_LIST", collection);
result.put("P_CITY", "Nepean");
test = new PLSQLTest("AddressListInOut", Address.class, args, result);
test.setName("AddressListInOutTest");
suite.addTest(test);
args = new ArrayList();
args.add(new Object[] { employee, employee });
args.add("Nepean");
test = new PLSQLTest("EmployeeListIn", Employee.class, args);
test.setName("EmployeeListInTest");
suite.addTest(test);
args = new ArrayList();
result = new DatabaseRecord();
result.put("P_EMP_LIST", new ArrayList());
result.put("P_CITY", "Nepean");
test = new PLSQLTest("EmployeeListOut", Employee.class, args, result);
test.setName("EmployeeListOutTest");
suite.addTest(test);
args = new ArrayList();
collection = new ArrayList(Arrays.asList(employee, employee));
args.add(collection);
args.add("Nepean");
result = new DatabaseRecord();
result.put("P_EMP_LIST", collection);
result.put("P_CITY", "Nepean");
test = new PLSQLTest("EmployeeListInOut", Employee.class, args, result);
test.setName("EmployeeListInOutTest");
suite.addTest(test);
return suite;
}
use of org.eclipse.persistence.sessions.DatabaseRecord in project eclipselink by eclipse-ee4j.
the class Address method getData.
static Vector<DatabaseRecord> getData(ClassDescriptor desc) {
Vector<DatabaseRecord> rows = new Vector<>();
Vector<DatabaseField> fields = desc.getAllFields();
DatabaseField[] fieldsArray = fields.toArray(new DatabaseField[0]);
rows.add(new ArrayRecord(fields, fieldsArray, new Object[] { 51, "Calgary", "Canada", "J5J2B5", "ALB", "1111 Moose Rd." }));
rows.add(new ArrayRecord(fields, fieldsArray, new Object[] { 52, "Metcalfe", "Canada", "Y4F7V6", "ONT", "2 Anderson Rd." }));
rows.add(new ArrayRecord(fields, fieldsArray, new Object[] { 53, "Montreal", "Canada", "Q2S5Z5", "QUE", "1 Habs Place" }));
return rows;
}
use of org.eclipse.persistence.sessions.DatabaseRecord in project eclipselink by eclipse-ee4j.
the class IndirectListTest method setUp.
/**
* set up the test fixture:
* 1. an IndirectList based on a Vector
*/
@Before
public void setUp() {
list = setUpList();
Object temp = new Vector<>(list);
ValueHolderInterface vh = new QueryBasedValueHolder(new ReadAllQuery(), new DatabaseRecord(), new TestSession(temp));
if (cls == null) {
testList = IndirectCollectionsFactory.createIndirectList();
} else {
try {
testList = cls.getConstructor().newInstance();
} catch (ReflectiveOperationException e) {
throw new RuntimeException(e);
}
}
testList.setValueHolder(vh);
if (useListener) {
testListLsn = new Listener();
testList._persistence_setPropertyChangeListener(testListLsn);
}
}
use of org.eclipse.persistence.sessions.DatabaseRecord in project eclipselink by eclipse-ee4j.
the class IndirectMapTest method setUp.
/**
* set up the test fixture:
* 1. an IndirectMap based on a Hashtable
*/
@Before
public void setUp() {
map = this.setUpMap();
Object temp = new Hashtable(map);
ValueHolderInterface vh = new QueryBasedValueHolder(new ReadAllQuery(), new DatabaseRecord(), new TestSession(temp));
if (cls == null) {
testMap = IndirectCollectionsFactory.createIndirectMap();
} else {
try {
testMap = cls.getConstructor().newInstance();
} catch (ReflectiveOperationException e) {
throw new RuntimeException(e);
}
}
testMap.setValueHolder(vh);
if (useListener) {
testMapLsn = new Listener();
testMap._persistence_setPropertyChangeListener(testMapLsn);
}
}
use of org.eclipse.persistence.sessions.DatabaseRecord in project eclipselink by eclipse-ee4j.
the class MappedInteraction method buildRow.
/**
* Build a database row from the record returned from the interaction.
*/
@Override
public AbstractRecord buildRow(jakarta.resource.cci.Record record, EISAccessor accessor) {
if (record == null) {
return null;
}
AbstractRecord row = null;
if (record instanceof IndexedRecord) {
IndexedRecord indexedRecord = (IndexedRecord) record;
if (indexedRecord.isEmpty()) {
return null;
}
if (indexedRecord.get(0) instanceof jakarta.resource.cci.Record) {
return buildRow((jakarta.resource.cci.Record) indexedRecord.get(0), accessor);
}
}
// If not a mapped record then just put it as a result value in the row.
if (!(record instanceof MappedRecord)) {
row = new DatabaseRecord(1);
row.put(getOutputResultPath(), record);
return row;
}
MappedRecord mappedRecord = (MappedRecord) record;
// or a translation of the output with the output arguments.
if (hasOutputArguments()) {
row = new DatabaseRecord(getOutputArgumentNames().size());
for (int index = 0; index < getOutputArgumentNames().size(); index++) {
DatabaseField field = getOutputArguments().get(index);
row.put(field, mappedRecord.get(getOutputArgumentNames().get(index)));
}
return row;
} else if (getOutputResultPath().length() > 0) {
// Extract the desired nested record from the output.
mappedRecord = (MappedRecord) mappedRecord.get(getOutputResultPath());
}
// Wrapped the record in a database to avoid lossing any information in conversion to database row,
// also gets around problem of some adatpers not supporting keySet or entrySet.
row = new EISMappedRecord(mappedRecord, accessor);
return row;
}
Aggregations