use of com.google.api.ads.admanager.jaxws.v202205.ColumnType in project googleads-java-lib by googleads.
the class Pql method combineResultSets.
/**
* Combines the first and second result sets, if and only if, the columns of both result sets
* match.
*
* @throws IllegalArgumentException if the columns of the first result set don't match the second
*/
public static ResultSet combineResultSets(ResultSet first, ResultSet second) {
Function<ColumnType, String> columnTypeToString = new Function<ColumnType, String>() {
@Override
public String apply(ColumnType input) {
return input.getLabelName();
}
};
List<String> firstColumns = Lists.transform(Lists.newArrayList(first.getColumnTypes()), columnTypeToString);
List<String> secondColumns = Lists.transform(Lists.newArrayList(second.getColumnTypes()), columnTypeToString);
if (!firstColumns.equals(secondColumns)) {
throw new IllegalArgumentException(String.format("First result set columns [%s] do not match second columns [%s]", Joiner.on(",").join(firstColumns), Joiner.on(",").join(secondColumns)));
}
List<Row> combinedRows = Lists.newArrayList(first.getRows());
if (second.getRows() != null) {
Collections.addAll(combinedRows, second.getRows());
}
ResultSet combinedResultSet = new ResultSet();
combinedResultSet.setColumnTypes(first.getColumnTypes());
combinedResultSet.setRows(combinedRows.toArray(new Row[] {}));
return combinedResultSet;
}
use of com.google.api.ads.admanager.jaxws.v202205.ColumnType in project googleads-java-lib by googleads.
the class Pql method combineResultSets.
/**
* Combines the first and second result sets, if and only if, the columns of both result sets
* match.
*
* @throws IllegalArgumentException if the columns of the first result set don't match the second
*/
public static ResultSet combineResultSets(ResultSet first, ResultSet second) {
Function<ColumnType, String> columnTypeToString = new Function<ColumnType, String>() {
public String apply(ColumnType input) {
return input.getLabelName();
}
};
List<String> firstColumns = Lists.transform(Lists.newArrayList(first.getColumnTypes()), columnTypeToString);
List<String> secondColumns = Lists.transform(Lists.newArrayList(second.getColumnTypes()), columnTypeToString);
if (!firstColumns.equals(secondColumns)) {
throw new IllegalArgumentException(String.format("First result set columns [%s] do not match second columns [%s]", Joiner.on(",").join(firstColumns), Joiner.on(",").join(secondColumns)));
}
List<Row> combinedRows = Lists.newArrayList(first.getRows());
if (second.getRows() != null) {
combinedRows.addAll(Lists.newArrayList(second.getRows()));
}
ResultSet combinedResultSet = new ResultSet();
combinedResultSet.getColumnTypes().addAll(first.getColumnTypes());
combinedResultSet.getRows().addAll(combinedRows);
return combinedResultSet;
}
use of com.google.api.ads.admanager.jaxws.v202205.ColumnType in project molgenis-emx2 by molgenis.
the class TestOpenApi method constructApi.
@Test
public void constructApi() throws IOException {
SchemaMetadata schema = new SchemaMetadata("test");
TableMetadata table = schema.create(TableMetadata.table("TypeTest"));
for (ColumnType columnType : ColumnType.values()) {
if (columnType.isReference()) {
// TODO: outside of test for now
} else {
table.add(Column.column(columnType.toString().toLowerCase() + "Column").setType(columnType));
}
}
TableMetadata personTable = schema.create(TableMetadata.table("Person").add(Column.column("First_Name")).add(Column.column("Last_Name")));
OpenAPI api = OpenApiYamlGenerator.createOpenApi(schema);
// useless test
Assert.assertEquals(1, api.getComponents().getSchemas().size());
// useless test
Assert.assertEquals(1, api.getComponents().getSchemas().size());
StringWriter writer = new StringWriter();
Yaml.pretty().writeValue(writer, api);
System.out.println(writer);
}
use of com.google.api.ads.admanager.jaxws.v202205.ColumnType in project molgenis-emx2 by molgenis.
the class TestGetSetAllTypesOnRows method addContents.
private void addContents(SchemaMetadata m, List<ColumnType> columnTypes) {
TableMetadata t = m.create(table("TypeTest"));
for (ColumnType columnType : columnTypes) {
t.add(column("test" + columnType).setType(columnType).setRequired(true));
t.add(column("test" + columnType + "_nullable").setType(columnType));
t.add(column("test" + columnType + "_readonly").setType(columnType).setReadonly(true));
}
}
use of com.google.api.ads.admanager.jaxws.v202205.ColumnType in project molgenis-emx2 by molgenis.
the class TestMapPojoToTable method testTypeTestToTable.
@Test
public void testTypeTestToTable() {
TableMetadata table = Mapper.map(TypeTestBean.class);
for (ColumnType columnType : new ColumnType[] { STRING, INT, DECIMAL, BOOL, DATE, DATETIME }) {
String columnName = "a" + columnType.toString().substring(0, 1).toUpperCase() + columnType.toString().substring(1).toLowerCase();
assertEquals(columnType, table.getColumn(columnName).getColumnType());
}
}
Aggregations