http://git-wip-us.apache.org/repos/asf/metamodel/blob/2d156bcd/pojo/src/test/java/org/apache/metamodel/pojo/PojoDataContextTest.java ---------------------------------------------------------------------- diff --git a/pojo/src/test/java/org/apache/metamodel/pojo/PojoDataContextTest.java b/pojo/src/test/java/org/apache/metamodel/pojo/PojoDataContextTest.java index d5e093c..97f1a9f 100644 --- a/pojo/src/test/java/org/apache/metamodel/pojo/PojoDataContextTest.java +++ b/pojo/src/test/java/org/apache/metamodel/pojo/PojoDataContextTest.java @@ -65,7 +65,7 @@ public class PojoDataContextTest extends TestCase { DataSet dataSet = dc.query().from("persons").innerJoin("titles").on("name", "name").selectAll().execute(); assertEquals("[persons.age, persons.name, titles.name, titles.title]", - Arrays.toString(dataSet.getSelectItems())); + Arrays.toString(dataSet.getSelectItems().toArray())); assertTrue(dataSet.next()); assertEquals("Row[values=[42, Elvis Presley, Elvis Presley, The King]]", dataSet.getRow().toString()); assertFalse(dataSet.next()); @@ -117,7 +117,7 @@ public class PojoDataContextTest extends TestCase { final Table table = schema.getTable(0); assertEquals("foo.bar", table.getQualifiedLabel()); - assertEquals("[col1, col2, col3]", Arrays.toString(table.getColumnNames())); + assertEquals("[col1, col2, col3]", Arrays.toString(table.getColumnNames().toArray())); DataSet ds = dc.query().from("bar").select("col2").where("col3").eq(true).execute(); assertTrue(ds.next());
http://git-wip-us.apache.org/repos/asf/metamodel/blob/2d156bcd/salesforce/src/main/java/org/apache/metamodel/salesforce/SalesforceDataContext.java ---------------------------------------------------------------------- diff --git a/salesforce/src/main/java/org/apache/metamodel/salesforce/SalesforceDataContext.java b/salesforce/src/main/java/org/apache/metamodel/salesforce/SalesforceDataContext.java index 37467b7..8d25bf4 100644 --- a/salesforce/src/main/java/org/apache/metamodel/salesforce/SalesforceDataContext.java +++ b/salesforce/src/main/java/org/apache/metamodel/salesforce/SalesforceDataContext.java @@ -19,10 +19,7 @@ package org.apache.metamodel.salesforce; import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.List; -import java.util.Locale; -import java.util.TimeZone; +import java.util.*; import com.sforce.ws.ConnectorConfig; @@ -167,14 +164,14 @@ public class SalesforceDataContext extends QueryPostprocessDataContext implement try { sb.append("SELECT "); int i = 0; - final Column[] columns = new Column[selectItems.size()]; + final List<Column> columns = new ArrayList(selectItems.size()); for (SelectItem selectItem : selectItems) { validateSoqlSupportedSelectItem(selectItem); - columns[i] = selectItem.getColumn(); + columns.set(i,selectItem.getColumn()); if (i != 0) { sb.append(", "); } - sb.append(columns[i].getName()); + sb.append(columns.get(i).getName()); i++; } @@ -366,14 +363,14 @@ public class SalesforceDataContext extends QueryPostprocessDataContext implement } @Override - protected DataSet materializeMainSchemaTable(Table table, Column[] columns, int maxRows) { + protected DataSet materializeMainSchemaTable(Table table, List<Column> columns, int maxRows) { final StringBuilder sb = new StringBuilder(); sb.append("SELECT "); - for (int i = 0; i < columns.length; i++) { + for (int i = 0; i < columns.size(); i++) { if (i != 0) { sb.append(','); } - sb.append(columns[i].getName()); + sb.append(columns.get(i).getName()); } sb.append(" FROM "); sb.append(table.getName()); http://git-wip-us.apache.org/repos/asf/metamodel/blob/2d156bcd/salesforce/src/main/java/org/apache/metamodel/salesforce/SalesforceDataSet.java ---------------------------------------------------------------------- diff --git a/salesforce/src/main/java/org/apache/metamodel/salesforce/SalesforceDataSet.java b/salesforce/src/main/java/org/apache/metamodel/salesforce/SalesforceDataSet.java index 85f2d9a..55993bc 100644 --- a/salesforce/src/main/java/org/apache/metamodel/salesforce/SalesforceDataSet.java +++ b/salesforce/src/main/java/org/apache/metamodel/salesforce/SalesforceDataSet.java @@ -20,13 +20,16 @@ package org.apache.metamodel.salesforce; import java.text.ParseException; import java.text.SimpleDateFormat; +import java.util.List; import java.util.Locale; import java.util.concurrent.atomic.AtomicInteger; +import java.util.stream.Collectors; import org.apache.metamodel.data.AbstractDataSet; import org.apache.metamodel.data.DataSetHeader; import org.apache.metamodel.data.DefaultRow; import org.apache.metamodel.data.Row; +import org.apache.metamodel.query.SelectItem; import org.apache.metamodel.schema.Column; import org.apache.metamodel.schema.ColumnType; import org.apache.metamodel.util.BooleanComparator; @@ -48,8 +51,8 @@ final class SalesforceDataSet extends AbstractDataSet { private SObject[] _records; private SObject _record; - public SalesforceDataSet(Column[] columns, QueryResult queryResult, PartnerConnection connection) { - super(columns); + public SalesforceDataSet(List<Column> columns, QueryResult queryResult, PartnerConnection connection) { + super(columns.stream().map(SelectItem::new).collect(Collectors.toList())); _connection = connection; _queryResult = queryResult; _records = _queryResult.getRecords(); http://git-wip-us.apache.org/repos/asf/metamodel/blob/2d156bcd/salesforce/src/main/java/org/apache/metamodel/salesforce/SalesforceSchema.java ---------------------------------------------------------------------- diff --git a/salesforce/src/main/java/org/apache/metamodel/salesforce/SalesforceSchema.java b/salesforce/src/main/java/org/apache/metamodel/salesforce/SalesforceSchema.java index d5f70c9..b11add5 100644 --- a/salesforce/src/main/java/org/apache/metamodel/salesforce/SalesforceSchema.java +++ b/salesforce/src/main/java/org/apache/metamodel/salesforce/SalesforceSchema.java @@ -19,6 +19,7 @@ package org.apache.metamodel.salesforce; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.function.Supplier; @@ -78,9 +79,8 @@ final class SalesforceSchema extends AbstractSchema { } @Override - public Table[] getTables() { - List<Table> tables = _tableRef.get(); - return tables.toArray(new Table[tables.size()]); + public List<Table> getTables() { + return Collections.unmodifiableList(_tableRef.get()); } @Override http://git-wip-us.apache.org/repos/asf/metamodel/blob/2d156bcd/salesforce/src/main/java/org/apache/metamodel/salesforce/SalesforceTable.java ---------------------------------------------------------------------- diff --git a/salesforce/src/main/java/org/apache/metamodel/salesforce/SalesforceTable.java b/salesforce/src/main/java/org/apache/metamodel/salesforce/SalesforceTable.java index 5db2b47..9648bb9 100644 --- a/salesforce/src/main/java/org/apache/metamodel/salesforce/SalesforceTable.java +++ b/salesforce/src/main/java/org/apache/metamodel/salesforce/SalesforceTable.java @@ -19,6 +19,7 @@ package org.apache.metamodel.salesforce; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.function.Supplier; @@ -135,12 +136,12 @@ final class SalesforceTable extends AbstractTable { } @Override - public Column[] getColumns() { + public List<Column> getColumns() { if (_columnRef == null) { - return new Column[0]; + return new ArrayList<>(); } List<Column> columns = _columnRef.get(); - return columns.toArray(new Column[columns.size()]); + return Collections.unmodifiableList(columns); } @Override @@ -154,8 +155,8 @@ final class SalesforceTable extends AbstractTable { } @Override - public Relationship[] getRelationships() { - return new Relationship[0]; + public List<Relationship> getRelationships() { + return new ArrayList<>(); } @Override http://git-wip-us.apache.org/repos/asf/metamodel/blob/2d156bcd/salesforce/src/test/java/org/apache/metamodel/salesforce/SalesforceDataContextTest.java ---------------------------------------------------------------------- diff --git a/salesforce/src/test/java/org/apache/metamodel/salesforce/SalesforceDataContextTest.java b/salesforce/src/test/java/org/apache/metamodel/salesforce/SalesforceDataContextTest.java index 7cb6fb6..64f4eac 100644 --- a/salesforce/src/test/java/org/apache/metamodel/salesforce/SalesforceDataContextTest.java +++ b/salesforce/src/test/java/org/apache/metamodel/salesforce/SalesforceDataContextTest.java @@ -51,7 +51,7 @@ public class SalesforceDataContextTest extends SalesforceTestCase { } SalesforceDataContext dc = getSalesforceDataContext(); - Column[] timeColumns = dc.getDefaultSchema().getTableByName("Contact").getTimeBasedColumns(); + List<Column> timeColumns = dc.getDefaultSchema().getTableByName("Contact").getTimeBasedColumns(); assertEquals( "[Column[name=Birthdate,columnNumber=30,type=DATE,nullable=true,nativeType=date,columnSize=0], " + "Column[name=CreatedDate,columnNumber=33,type=TIMESTAMP,nullable=false,nativeType=datetime,columnSize=0], " @@ -61,7 +61,7 @@ public class SalesforceDataContextTest extends SalesforceTestCase { + "Column[name=LastCURequestDate,columnNumber=39,type=TIMESTAMP,nullable=true,nativeType=datetime,columnSize=0], " + "Column[name=LastCUUpdateDate,columnNumber=40,type=TIMESTAMP,nullable=true,nativeType=datetime,columnSize=0], " + "Column[name=EmailBouncedDate,columnNumber=42,type=TIMESTAMP,nullable=true,nativeType=datetime,columnSize=0]]", - Arrays.toString(timeColumns)); + Arrays.toString(timeColumns.toArray())); DataSet ds = dc.query().from("Contact").select("LastModifiedDate").where("Id").eq("003b0000006xfAUAAY") .execute(); if (ds.next()) { @@ -121,15 +121,15 @@ public class SalesforceDataContextTest extends SalesforceTestCase { assertEquals("Salesforce", schema.getName()); - String[] tableNames = schema.getTableNames(); + List<String> tableNames = schema.getTableNames(); - System.out.println("All tables:\n" + Arrays.toString(tableNames)); + System.out.println("All tables:\n" + Arrays.toString(tableNames.toArray())); Table accountTable = schema.getTableByName("Account"); assertNotNull(accountTable); - String[] columnNames = accountTable.getColumnNames(); - System.out.println("Account table columns: " + Arrays.toString(columnNames)); + List<String> columnNames = accountTable.getColumnNames(); + System.out.println("Account table columns: " + Arrays.toString(columnNames.toArray())); Column idColumn = accountTable.getColumnByName("Id"); Column nameColumn = accountTable.getColumnByName("Name"); @@ -165,7 +165,7 @@ public class SalesforceDataContextTest extends SalesforceTestCase { q.setMaxRows(1); final DataSet ds = dc.executeQuery(q); - final SelectItem[] selectItems = ds.getSelectItems(); + final List<SelectItem> selectItems = ds.getSelectItems(); while (ds.next()) { Row row = ds.getRow(); http://git-wip-us.apache.org/repos/asf/metamodel/blob/2d156bcd/salesforce/src/test/java/org/apache/metamodel/salesforce/SalesforceDataSetTest.java ---------------------------------------------------------------------- diff --git a/salesforce/src/test/java/org/apache/metamodel/salesforce/SalesforceDataSetTest.java b/salesforce/src/test/java/org/apache/metamodel/salesforce/SalesforceDataSetTest.java index 838e386..a16cf13 100644 --- a/salesforce/src/test/java/org/apache/metamodel/salesforce/SalesforceDataSetTest.java +++ b/salesforce/src/test/java/org/apache/metamodel/salesforce/SalesforceDataSetTest.java @@ -18,18 +18,21 @@ */ package org.apache.metamodel.salesforce; +import com.google.common.collect.Lists; import com.sforce.soap.partner.QueryResult; import com.sforce.ws.ConnectionException; import com.sforce.ws.bind.TypeMapper; import com.sforce.ws.parser.PullParserException; import com.sforce.ws.parser.XmlInputStream; import org.apache.metamodel.data.Row; +import org.apache.metamodel.query.SelectItem; import org.apache.metamodel.schema.Column; import org.apache.metamodel.schema.ColumnType; import org.apache.metamodel.schema.MutableColumn; import org.junit.Test; import java.io.IOException; +import java.util.ArrayList; import java.util.List; import static org.junit.Assert.assertEquals; @@ -41,7 +44,7 @@ public class SalesforceDataSetTest { QueryResult qr = queryResult("/result/double-value.xml"); MutableColumn version = new MutableColumn("Version", ColumnType.DOUBLE); - SalesforceDataSet dataSet = new SalesforceDataSet(new Column[] { version }, qr, null); + SalesforceDataSet dataSet = new SalesforceDataSet(Lists.newArrayList(version), qr, null); List<Row> rows = dataSet.toRows(); assertEquals(5386.21, rows.get(0).getValue(version)); http://git-wip-us.apache.org/repos/asf/metamodel/blob/2d156bcd/spring/src/test/java/org/apache/metamodel/spring/CsvDefaultConfigurationFromResourceTest.java ---------------------------------------------------------------------- diff --git a/spring/src/test/java/org/apache/metamodel/spring/CsvDefaultConfigurationFromResourceTest.java b/spring/src/test/java/org/apache/metamodel/spring/CsvDefaultConfigurationFromResourceTest.java index 87ffef0..c43bf9d 100644 --- a/spring/src/test/java/org/apache/metamodel/spring/CsvDefaultConfigurationFromResourceTest.java +++ b/spring/src/test/java/org/apache/metamodel/spring/CsvDefaultConfigurationFromResourceTest.java @@ -53,6 +53,6 @@ public class CsvDefaultConfigurationFromResourceTest { assertEquals("example.csv", resource.getName()); - assertEquals("[foo, bar]", Arrays.toString(csv.getDefaultSchema().getTable(0).getColumnNames())); + assertEquals("[foo, bar]", Arrays.toString(csv.getDefaultSchema().getTable(0).getColumnNames().toArray())); } } http://git-wip-us.apache.org/repos/asf/metamodel/blob/2d156bcd/spring/src/test/java/org/apache/metamodel/spring/CsvSpecifiedConfigurationFromFilenameTest.java ---------------------------------------------------------------------- diff --git a/spring/src/test/java/org/apache/metamodel/spring/CsvSpecifiedConfigurationFromFilenameTest.java b/spring/src/test/java/org/apache/metamodel/spring/CsvSpecifiedConfigurationFromFilenameTest.java index 01b6120..ec97106 100644 --- a/spring/src/test/java/org/apache/metamodel/spring/CsvSpecifiedConfigurationFromFilenameTest.java +++ b/spring/src/test/java/org/apache/metamodel/spring/CsvSpecifiedConfigurationFromFilenameTest.java @@ -51,7 +51,7 @@ public class CsvSpecifiedConfigurationFromFilenameTest { assertEquals("example.csv", resource.getName()); - assertEquals("[\"foo\", bar]", Arrays.toString(csv.getDefaultSchema().getTable(0).getColumnNames())); + assertEquals("[\"foo\", bar]", Arrays.toString(csv.getDefaultSchema().getTable(0).getColumnNames().toArray())); Assert.assertFalse(csv.getConfiguration().isMultilineValues()); } http://git-wip-us.apache.org/repos/asf/metamodel/blob/2d156bcd/spring/src/test/java/org/apache/metamodel/spring/ExcelSpecifiedConfigurationFromFilenameTest.java ---------------------------------------------------------------------- diff --git a/spring/src/test/java/org/apache/metamodel/spring/ExcelSpecifiedConfigurationFromFilenameTest.java b/spring/src/test/java/org/apache/metamodel/spring/ExcelSpecifiedConfigurationFromFilenameTest.java index 58a9317..a4589fc 100644 --- a/spring/src/test/java/org/apache/metamodel/spring/ExcelSpecifiedConfigurationFromFilenameTest.java +++ b/spring/src/test/java/org/apache/metamodel/spring/ExcelSpecifiedConfigurationFromFilenameTest.java @@ -51,7 +51,7 @@ public class ExcelSpecifiedConfigurationFromFilenameTest { assertEquals("example.xlsx", resource.getName()); - assertEquals("[hello, world]", Arrays.toString(excel.getDefaultSchema().getTable(0).getColumnNames())); + assertEquals("[hello, world]", Arrays.toString(excel.getDefaultSchema().getTable(0).getColumnNames().toArray())); Assert.assertTrue(excel.getConfiguration().isSkipEmptyLines()); Assert.assertTrue(excel.getConfiguration().isSkipEmptyColumns()); http://git-wip-us.apache.org/repos/asf/metamodel/blob/2d156bcd/spring/src/test/java/org/apache/metamodel/spring/PojoDataContextFactoryBeanDelegateTest.java ---------------------------------------------------------------------- diff --git a/spring/src/test/java/org/apache/metamodel/spring/PojoDataContextFactoryBeanDelegateTest.java b/spring/src/test/java/org/apache/metamodel/spring/PojoDataContextFactoryBeanDelegateTest.java index 558cda4..471dc96 100644 --- a/spring/src/test/java/org/apache/metamodel/spring/PojoDataContextFactoryBeanDelegateTest.java +++ b/spring/src/test/java/org/apache/metamodel/spring/PojoDataContextFactoryBeanDelegateTest.java @@ -39,15 +39,15 @@ public class PojoDataContextFactoryBeanDelegateTest extends TestCase { Schema schema = dataContext.getDefaultSchema(); assertEquals("my db", schema.getName()); - assertEquals("[foo, hello world]", Arrays.toString(schema.getTableNames())); + assertEquals("[foo, hello world]", Arrays.toString(schema.getTableNames().toArray())); assertEquals( "[Column[name=greeting,columnNumber=0,type=VARCHAR,nullable=true,nativeType=null,columnSize=null], " + "Column[name=who,columnNumber=1,type=VARCHAR,nullable=true,nativeType=null,columnSize=null]]", - Arrays.toString(schema.getTableByName("hello world").getColumns())); + Arrays.toString(schema.getTableByName("hello world").getColumns().toArray())); assertEquals("[Column[name=bar,columnNumber=0,type=INTEGER,nullable=true,nativeType=null,columnSize=null], " + "Column[name=baz,columnNumber=1,type=DATE,nullable=true,nativeType=null,columnSize=null]]", - Arrays.toString(schema.getTableByName("foo").getColumns())); + Arrays.toString(schema.getTableByName("foo").getColumns().toArray())); } } http://git-wip-us.apache.org/repos/asf/metamodel/blob/2d156bcd/sugarcrm/src/main/java/org/apache/metamodel/sugarcrm/SugarCrmDataContext.java ---------------------------------------------------------------------- diff --git a/sugarcrm/src/main/java/org/apache/metamodel/sugarcrm/SugarCrmDataContext.java b/sugarcrm/src/main/java/org/apache/metamodel/sugarcrm/SugarCrmDataContext.java index e3908c0..9abe5da 100644 --- a/sugarcrm/src/main/java/org/apache/metamodel/sugarcrm/SugarCrmDataContext.java +++ b/sugarcrm/src/main/java/org/apache/metamodel/sugarcrm/SugarCrmDataContext.java @@ -38,7 +38,7 @@ import org.apache.metamodel.util.LazyRef; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.sugarcrm.ws.soapyxyx.EntryValue; +import com.sugarcrm.ws.soap.EntryValue; import com.sugarcrm.ws.soap.GetEntriesCountResult; import com.sugarcrm.ws.soap.GetEntryListResultVersion2; import com.sugarcrm.ws.soap.LinkNamesToFieldsArray; @@ -147,7 +147,7 @@ public class SugarCrmDataContext extends QueryPostprocessDataContext implements } @Override - protected DataSet materializeMainSchemaTable(final Table table, final Column[] columns, final int maxRows) { + protected DataSet materializeMainSchemaTable(final Table table, final List<Column> columns, final int maxRows) { final String session = _sessionId.get(); final String moduleName = table.getName(); http://git-wip-us.apache.org/repos/asf/metamodel/blob/2d156bcd/sugarcrm/src/main/java/org/apache/metamodel/sugarcrm/SugarCrmDataSet.java ---------------------------------------------------------------------- diff --git a/sugarcrm/src/main/java/org/apache/metamodel/sugarcrm/SugarCrmDataSet.java b/sugarcrm/src/main/java/org/apache/metamodel/sugarcrm/SugarCrmDataSet.java index a754ce6..7558c6d 100644 --- a/sugarcrm/src/main/java/org/apache/metamodel/sugarcrm/SugarCrmDataSet.java +++ b/sugarcrm/src/main/java/org/apache/metamodel/sugarcrm/SugarCrmDataSet.java @@ -22,6 +22,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.concurrent.atomic.AtomicInteger; +import java.util.stream.Collectors; import org.apache.metamodel.data.AbstractDataSet; import org.apache.metamodel.data.DataSetHeader; @@ -54,9 +55,9 @@ final class SugarCrmDataSet extends AbstractDataSet { private List<Object> _records; private Node _record; - public SugarCrmDataSet(Column[] columns, SugarsoapPortType service, String session, + public SugarCrmDataSet(List<Column> columns, SugarsoapPortType service, String session, GetEntryListResultVersion2 entryList) { - super(columns); + super(columns.stream().map(SelectItem::new).collect(Collectors.toList())); _recordIndex = new AtomicInteger(); _service = service; _session = session; @@ -80,12 +81,9 @@ final class SugarCrmDataSet extends AbstractDataSet { } final DataSetHeader header = getHeader(); - final SelectItem[] selectItems = header.getSelectItems(); - final Column[] columns = new Column[selectItems.length]; - for (int i = 0; i < columns.length; i++) { - columns[i] = selectItems[i].getColumn(); - } - final String moduleName = selectItems[0].getColumn().getTable().getName(); + final List<SelectItem> selectItems = header.getSelectItems(); + final List<Column> columns = selectItems.stream().map(si -> si.getColumn()).collect(Collectors.toList()); + final String moduleName = selectItems.get(0).getColumn().getTable().getName(); final SelectFields selectFields = SugarCrmXmlHelper.createSelectFields(columns); _entryList = _service.getEntryList(_session, moduleName, "", "", nextOffset, selectFields, http://git-wip-us.apache.org/repos/asf/metamodel/blob/2d156bcd/sugarcrm/src/main/java/org/apache/metamodel/sugarcrm/SugarCrmSchema.java ---------------------------------------------------------------------- diff --git a/sugarcrm/src/main/java/org/apache/metamodel/sugarcrm/SugarCrmSchema.java b/sugarcrm/src/main/java/org/apache/metamodel/sugarcrm/SugarCrmSchema.java index 49e24e7..1db4090 100644 --- a/sugarcrm/src/main/java/org/apache/metamodel/sugarcrm/SugarCrmSchema.java +++ b/sugarcrm/src/main/java/org/apache/metamodel/sugarcrm/SugarCrmSchema.java @@ -19,6 +19,7 @@ package org.apache.metamodel.sugarcrm; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.function.Supplier; @@ -58,8 +59,8 @@ final class SugarCrmSchema extends AbstractSchema { } @Override - public Table[] getTables() { - return _tables.toArray(new Table[_tables.size()]); + public List<Table> getTables() { + return Collections.unmodifiableList(_tables); } @Override http://git-wip-us.apache.org/repos/asf/metamodel/blob/2d156bcd/sugarcrm/src/main/java/org/apache/metamodel/sugarcrm/SugarCrmTable.java ---------------------------------------------------------------------- diff --git a/sugarcrm/src/main/java/org/apache/metamodel/sugarcrm/SugarCrmTable.java b/sugarcrm/src/main/java/org/apache/metamodel/sugarcrm/SugarCrmTable.java index 1926d83..7ef82bf 100644 --- a/sugarcrm/src/main/java/org/apache/metamodel/sugarcrm/SugarCrmTable.java +++ b/sugarcrm/src/main/java/org/apache/metamodel/sugarcrm/SugarCrmTable.java @@ -18,10 +18,7 @@ */ package org.apache.metamodel.sugarcrm; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.function.Supplier; import org.apache.metamodel.schema.AbstractTable; @@ -119,9 +116,9 @@ final class SugarCrmTable extends AbstractTable { } @Override - public Column[] getColumns() { + public List<Column> getColumns() { final List<Column> columns = _columnsRef.get(); - return columns.toArray(new Column[columns.size()]); + return Collections.unmodifiableList(columns); } @Override @@ -135,8 +132,8 @@ final class SugarCrmTable extends AbstractTable { } @Override - public Relationship[] getRelationships() { - return new Relationship[0]; + public List<Relationship> getRelationships() { + return new ArrayList<>(); } @Override http://git-wip-us.apache.org/repos/asf/metamodel/blob/2d156bcd/sugarcrm/src/main/java/org/apache/metamodel/sugarcrm/SugarCrmXmlHelper.java ---------------------------------------------------------------------- diff --git a/sugarcrm/src/main/java/org/apache/metamodel/sugarcrm/SugarCrmXmlHelper.java b/sugarcrm/src/main/java/org/apache/metamodel/sugarcrm/SugarCrmXmlHelper.java index a49b934..394cd6d 100644 --- a/sugarcrm/src/main/java/org/apache/metamodel/sugarcrm/SugarCrmXmlHelper.java +++ b/sugarcrm/src/main/java/org/apache/metamodel/sugarcrm/SugarCrmXmlHelper.java @@ -39,7 +39,7 @@ import com.sugarcrm.ws.soap.SelectFields; */ final class SugarCrmXmlHelper { - public static SelectFields createSelectFields(Column ... columns) { + public static SelectFields createSelectFields(List<Column> columns) { final SelectFields selectFields = new SelectFields(); selectFields.setArrayType("xsd:string[]"); http://git-wip-us.apache.org/repos/asf/metamodel/blob/2d156bcd/sugarcrm/src/test/java/org/apache/metamodel/sugarcrm/SugarCrmDataContextTest.java ---------------------------------------------------------------------- diff --git a/sugarcrm/src/test/java/org/apache/metamodel/sugarcrm/SugarCrmDataContextTest.java b/sugarcrm/src/test/java/org/apache/metamodel/sugarcrm/SugarCrmDataContextTest.java index d9cf1e8..4fa4a7c 100644 --- a/sugarcrm/src/test/java/org/apache/metamodel/sugarcrm/SugarCrmDataContextTest.java +++ b/sugarcrm/src/test/java/org/apache/metamodel/sugarcrm/SugarCrmDataContextTest.java @@ -20,6 +20,7 @@ package org.apache.metamodel.sugarcrm; import java.util.Arrays; import java.util.Date; +import java.util.List; import org.apache.metamodel.data.DataSet; import org.apache.metamodel.data.InMemoryDataSet; @@ -107,12 +108,12 @@ public class SugarCrmDataContextTest extends SugarCrmTestCase { final Schema schema = dataContext.getDefaultSchema(); final Table table = schema.getTableByName("Prospects"); - final Column[] numberColumns = table.getNumberColumns(); - final Column[] booleanColumns = table.getBooleanColumns(); - final Column[] timeBasedColumns = table.getTimeBasedColumns(); - assertTrue(numberColumns.length > 0); - assertTrue(booleanColumns.length > 0); - assertTrue(timeBasedColumns.length > 0); + final List<Column> numberColumns = table.getNumberColumns(); + final List<Column> booleanColumns = table.getBooleanColumns(); + final List<Column> timeBasedColumns = table.getTimeBasedColumns(); + assertTrue(numberColumns.size() > 0); + assertTrue(booleanColumns.size() > 0); + assertTrue(timeBasedColumns.size() > 0); DataSet ds = dataContext.query().from(table).selectAll().limit(5).execute(); int rowCounter = 0; @@ -146,9 +147,9 @@ public class SugarCrmDataContextTest extends SugarCrmTestCase { } ds.close(); assertTrue(rowCounter > 0); - assertTrue("No non-null values found in: " + Arrays.toString(numberColumns), numberCounter > 0); - assertTrue("No non-null values found in: " + Arrays.toString(booleanColumns), booleanCounter > 0); - assertTrue("No non-null values found in: " + Arrays.toString(timeBasedColumns), timeBasedCounter > 0); + assertTrue("No non-null values found in: " + Arrays.toString(numberColumns.toArray()), numberCounter > 0); + assertTrue("No non-null values found in: " + Arrays.toString(booleanColumns.toArray()), booleanCounter > 0); + assertTrue("No non-null values found in: " + Arrays.toString(timeBasedColumns.toArray()), timeBasedCounter > 0); } public void testMaxRowsQuery() throws Exception { @@ -189,7 +190,7 @@ public class SugarCrmDataContextTest extends SugarCrmTestCase { Table table = schema.getTableByName("Accounts"); - String[] columnNames = table.getColumnNames(); + List<String> columnNames = table.getColumnNames(); assertEquals( "[id, name, date_entered, date_modified, modified_user_id, modified_by_name, created_by, created_by_name, " + "description, deleted, assigned_user_id, assigned_user_name, account_type, industry, annual_revenue, phone_fax, " @@ -199,7 +200,7 @@ public class SugarCrmDataContextTest extends SugarCrmTestCase { + "shipping_address_street_2, shipping_address_street_3, shipping_address_street_4, shipping_address_city, " + "shipping_address_state, shipping_address_postalcode, shipping_address_country, email1, parent_id, sic_code, parent_name, " + "email_opt_out, invalid_email, email, campaign_id, campaign_name]", - Arrays.toString(columnNames)); + Arrays.toString(columnNames.toArray())); Column nameColumn = table.getColumnByName("name"); String nativeType = nameColumn.getNativeType(); @@ -207,8 +208,7 @@ public class SugarCrmDataContextTest extends SugarCrmTestCase { ColumnType type = nameColumn.getType(); assertEquals("name|Name:|VARCHAR", nativeType + "|" + remarks + "|" + type); - Column[] columns = table.getColumns(); - for (Column column : columns) { + for (Column column : table.getColumns()) { type = column.getType(); if (type == null || type == ColumnType.OTHER) { fail("No type mapping for native type: " + column.getNativeType() + " (found in column: " + column @@ -228,10 +228,9 @@ public class SugarCrmDataContextTest extends SugarCrmTestCase { + "alt_address_postalcode, alt_address_country, assistant, assistant_phone, email_and_name1, lead_source, account_name, account_id, " + "opportunity_role_fields, opportunity_role_id, opportunity_role, reports_to_id, report_to_name, birthdate, campaign_id, campaign_name, " + "c_accept_status_fields, m_accept_status_fields, accept_status_id, accept_status_name, sync_contact]", - Arrays.toString(columnNames)); + Arrays.toString(columnNames.toArray())); - columns = table.getColumns(); - for (Column column : columns) { + for (Column column : table.getColumns()) { type = column.getType(); if (type == null || type == ColumnType.OTHER) { fail("No type mapping for native type: " + column.getNativeType() + " (found in column: " + column http://git-wip-us.apache.org/repos/asf/metamodel/blob/2d156bcd/xml/src/main/java/org/apache/metamodel/xml/XmlDomDataContext.java ---------------------------------------------------------------------- diff --git a/xml/src/main/java/org/apache/metamodel/xml/XmlDomDataContext.java b/xml/src/main/java/org/apache/metamodel/xml/XmlDomDataContext.java index 0d0bebb..3c4d0cd 100644 --- a/xml/src/main/java/org/apache/metamodel/xml/XmlDomDataContext.java +++ b/xml/src/main/java/org/apache/metamodel/xml/XmlDomDataContext.java @@ -511,8 +511,8 @@ public class XmlDomDataContext extends QueryPostprocessDataContext { .map(ftRel -> ftRel.getForeignTable().getName()).collect(Collectors.joining(", "))); } - List<Column> primaryColumns = primaryTable.getColumns(); - List<Column> foreignColumns = foreignTable.getColumns(); + List<Column> primaryColumns = new ArrayList<>(primaryTable.getColumns()); + List<Column> foreignColumns = new ArrayList<>(foreignTable.getColumns()); // Remove the surrogate id String primaryTableName = primaryTable.getName();