@Override public final TableDropBuilder dropTable(Schema schema, String tableName) throws IllegalArgumentException, IllegalStateException, UnsupportedOperationException { final Table table = schema.getTableByName(tableName); if (table == null) { throw new IllegalArgumentException("Nu such table '" + tableName + "' found in schema: " + schema + ". Available tables are: " + Arrays.toString(schema.getTableNames().toArray())); } return dropTable(table); }
@Override public final TableDropBuilder dropTable(Schema schema, String tableName) throws IllegalArgumentException, IllegalStateException, UnsupportedOperationException { final Table table = schema.getTableByName(tableName); if (table == null) { throw new IllegalArgumentException("Nu such table '" + tableName + "' found in schema: " + schema + ". Available tables are: " + Arrays.toString(schema.getTableNames().toArray())); } return dropTable(table); }
@Override public TableFromBuilder from(Schema schema, String tableName) { Table table = schema.getTableByName(tableName); if (table == null) { throw new IllegalArgumentException("Nu such table '" + tableName + "' found in schema: " + schema + ". Available tables are: " + Arrays.toString(schema.getTableNames().toArray())); } return from(table); }
private Table getTable(String schemaName, String tableName) { final Schema schema = getSchema(schemaName); final Table table = schema.getTableByName(tableName); if (table == null) { throw new IllegalArgumentException("Nu such table '" + tableName + "' found in schema: " + schema + ". Available tables are: " + Arrays.toString(schema.getTableNames().toArray())); } return table; }
@Override public TableFromBuilder from(Schema schema, String tableName) { Table table = schema.getTableByName(tableName); if (table == null) { throw new IllegalArgumentException("Nu such table '" + tableName + "' found in schema: " + schema + ". Available tables are: " + Arrays.toString(schema.getTableNames().toArray())); } return from(table); }
private Table getTable(String schemaName, String tableName) { final Schema schema = getSchema(schemaName); final Table table = schema.getTableByName(tableName); if (table == null) { throw new IllegalArgumentException("Nu such table '" + tableName + "' found in schema: " + schema + ". Available tables are: " + Arrays.toString(schema.getTableNames().toArray())); } return table; }
public Table convertToTable(final String schemaName, final String tableName) { final Schema schema; if (schemaName == null) { schema = getDefaultSchema(); } else { schema = getSchemaByName(schemaName); } if (schema == null) { throw new IllegalArgumentException( "Schema " + schemaName + " not found. Available schema names are: " + dataContext.getSchemaNames()); } final Table table; if (tableName == null) { if (schema.getTables().stream().filter(t -> t.getType() == TableType.TABLE).count() == 1) { table = schema.getTables().stream().filter(t -> t.getType() == TableType.TABLE).findFirst().get(); } else { throw new IllegalArgumentException( "No table name specified, and multiple options exist. Available table names are: " + schema.getTableNames()); } } else { table = schema.getTableByName(tableName); } if (table == null) { throw new IllegalArgumentException( "Table not found. Available table names are: " + schema.getTableNames()); } return table; }
@Validate public void validate() { sheetName = sheetName.trim(); if (sheetName.length() > SHEET_NAME_MAX_LENGTH) { throw new IllegalStateException("Sheet name must be maximum " + SHEET_NAME_MAX_LENGTH + " characters long"); } for (final char c : SHEET_NAME_ILLEGAL_CHARS) { if (sheetName.indexOf(c) != -1) { throw new IllegalStateException("Sheet name cannot contain '" + c + "'"); } } if (!overwriteSheetIfExists && file.exists()) { final Datastore datastore = new ExcelDatastore(file.getName(), new FileResource(file), file.getAbsolutePath()); try (DatastoreConnection connection = datastore.openConnection()) { final List<String> tableNames = connection.getDataContext().getDefaultSchema().getTableNames(); for (String tableName : tableNames) { if (tableName.equals(sheetName)) { throw new IllegalStateException( "The sheet '" + sheetName + "' already exists. Please select another sheet name."); } } } } if (!FilenameUtils.isExtension(file.getName(), excelExtension)) { throw new IllegalStateException("Please add the '.xlsx' or '.xls' extension to the filename"); } }
private final Column getColumn(final Schema schema, final String tableAndColumnPath) { Table table = null; String columnPath = tableAndColumnPath; final List<String> tableNames = schema.getTableNames(); for (final String tableName : tableNames) { if (tableName != null) {
private final Column getColumn(final Schema schema, final String tableAndColumnPath) { Table table = null; String columnPath = tableAndColumnPath; final List<String> tableNames = schema.getTableNames(); for (final String tableName : tableNames) { if (tableName != null) {
@Override public OutputWriter createOutputWriter() { if (file.exists()) { final ExcelDatastore datastore = new ExcelDatastore(file.getName(), new FileResource(file), file.getAbsolutePath()); try (UpdateableDatastoreConnection connection = datastore.openConnection()) { final DataContext dataContext = connection.getDataContext(); final List<String> tableNames = dataContext.getDefaultSchema().getTableNames(); for (String tableName : tableNames) { if (tableName.equals(sheetName)) { if (overwriteSheetIfExists) { final Table tableSheet = dataContext.getTableByQualifiedLabel(sheetName); final UpdateableDataContext updateableDataContext = connection.getUpdateableDataContext(); updateableDataContext.executeUpdate(new DropTable(tableSheet)); } } } } } // If the user wants the file sorted after a column we create a // temporary file and return a CSV writer in order // to make a MergeSort on it, otherwise we return a normal Excel writer if (columnToBeSortedOn != null) { return createTemporaryCsvWriter(); } else { return ExcelOutputWriterFactory.getWriter(file.getPath(), sheetName, fields, columns); } }
dc.refreshSchemas(); final Schema schema = dc.getDefaultSchema(); final List<String> tableNames = schema.getTableNames();
System.err.println("No such schema: " + schemaName); } else { final List<String> tableNames = schema.getTableNames(); if (tableNames == null || tableNames.isEmpty()) { System.err.println("No tables in schema!");
@Override public List<TableIdentifier> getTables(final TenantIdentifier tenant, final SchemaIdentifier schemaId) { final TenantContext tenantContext = _tenantContextFactory.getContext(tenant); final Datastore datastore = tenantContext.getDatastore(schemaId.getDatastore()); if (datastore == null) { return null; } try (final DatastoreConnection con = datastore.openConnection()) { final Schema schema = con.getDataContext().getSchemaByName(schemaId.getName()); final String[] tableNames = schema.getTableNames(); final List<TableIdentifier> tableIdentifiers = CollectionUtils.map(tableNames, new Func<String, TableIdentifier>() { @Override public TableIdentifier eval(String tableName) { return new TableIdentifier(schemaId, tableName); } }); return tableIdentifiers; } }
String[] tableNames = schema.getTableNames(); for (String tableName : tableNames) { usageSchema.addTable(new MutableTable(tableName).setSchema(usageSchema).setRemarks(