git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/branches/mutateops@1030 f203690c-595d-4dc9-a70b-905162fa7fd2tags/jackcess-2.1.5
- fix long text index entries (for new general sort order) | - fix long text index entries (for new general sort order) | ||||
* ??? | * ??? | ||||
- implement foreign key index creation & relationship creation | |||||
* MEDIUM | |||||
- implement table creation w/ complex columns | - implement table creation w/ complex columns | ||||
* MEDIUM | * MEDIUM | ||||
- implement table, column, index renaming | - implement table, column, index renaming | ||||
- Table - update table def, queries, relationships, complex tables? | - Table - update table def, queries, relationships, complex tables? | ||||
- Column - update table def, queries, relationships, complex tables? | - Column - update table def, queries, relationships, complex tables? | ||||
- Index - update table def | - Index - update table def | ||||
Index add (fk impl) | |||||
- Database.addIndex(IndexBuilder) - use TableCreator internal | |||||
- add indexes separately from adding fk info, (backing indexes need to be | |||||
added first) | |||||
- require baking indexes to be created first (does MSAccess?) | |||||
- need to populate index after creation! populate first, then add? | |||||
- add relationships | |||||
- flush all non-system tables from DbImpl._tableCache (references to old table | |||||
impls) |
* existing Table using the {@link #addToTable(Table)} method. | * existing Table using the {@link #addToTable(Table)} method. | ||||
* | * | ||||
* @author James Ahlborn | * @author James Ahlborn | ||||
* @see TableBuilder | |||||
* @usage _general_class_ | * @usage _general_class_ | ||||
*/ | */ | ||||
public class ColumnBuilder { | public class ColumnBuilder { |
* existing Table using the {@link #addToTable(Table)} method. | * existing Table using the {@link #addToTable(Table)} method. | ||||
* | * | ||||
* @author James Ahlborn | * @author James Ahlborn | ||||
* @see TableBuilder | |||||
* @usage _general_class_ | * @usage _general_class_ | ||||
*/ | */ | ||||
public class IndexBuilder | public class IndexBuilder |
/** | /** | ||||
* Builder style class for constructing a {@link Relationship}, and, | * Builder style class for constructing a {@link Relationship}, and, | ||||
* optionally, the associated backing foreign key (if referential integrity | * optionally, the associated backing foreign key (if referential integrity | ||||
* enforcement is enabled). | |||||
* enforcement is enabled). A Relationship can only be constructed for | |||||
* {@link Table}s which already exist in the {@link Database}. Additionally, | |||||
* if integrity enforcement is enabled, there must already be a unique index | |||||
* on the "from" Table for the relevant columns (same requirement as MS | |||||
* Access). | |||||
* <p/> | |||||
* Example: | |||||
* <pre> | |||||
* Relationship rel = new RelationshipBuilder("FromTable", "ToTable") | |||||
* .addColumns("ID", "FK_ID") | |||||
* .setReferentialIntegrity() | |||||
* .setCascadeDeletes() | |||||
* .toRelationship(db); | |||||
* </pre> | |||||
* | * | ||||
* @author James Ahlborn | * @author James Ahlborn | ||||
* @see TableBuilder | |||||
* @usage _general_class_ | |||||
*/ | */ | ||||
public class RelationshipBuilder | public class RelationshipBuilder | ||||
{ | { |
* </pre> | * </pre> | ||||
* | * | ||||
* @author James Ahlborn | * @author James Ahlborn | ||||
* @see ColumnBuilder | |||||
* @see IndexBuilder | |||||
* @see RelationshipBuilder | |||||
* @usage _general_class_ | * @usage _general_class_ | ||||
*/ | */ | ||||
public class TableBuilder { | public class TableBuilder { |
* Create a new table in this database | * Create a new table in this database | ||||
* @param name Name of the table to create | * @param name Name of the table to create | ||||
* @param columns List of Columns in the table | * @param columns List of Columns in the table | ||||
* @usage _general_method_ | |||||
* @deprecated use {@link TableBuilder} instead | |||||
*/ | */ | ||||
@Deprecated | |||||
public void createTable(String name, List<ColumnBuilder> columns) | public void createTable(String name, List<ColumnBuilder> columns) | ||||
throws IOException | throws IOException | ||||
{ | { | ||||
* @param name Name of the table to create | * @param name Name of the table to create | ||||
* @param columns List of Columns in the table | * @param columns List of Columns in the table | ||||
* @param indexes List of IndexBuilders describing indexes for the table | * @param indexes List of IndexBuilders describing indexes for the table | ||||
* @usage _general_method_ | |||||
* @deprecated use {@link TableBuilder} instead | |||||
*/ | */ | ||||
@Deprecated | |||||
public void createTable(String name, List<ColumnBuilder> columns, | public void createTable(String name, List<ColumnBuilder> columns, | ||||
List<IndexBuilder> indexes) | List<IndexBuilder> indexes) | ||||
throws IOException | throws IOException |
import java.util.ArrayList; | import java.util.ArrayList; | ||||
import java.util.Arrays; | import java.util.Arrays; | ||||
import java.util.Calendar; | import java.util.Calendar; | ||||
import java.util.Collections; | |||||
import java.util.Date; | import java.util.Date; | ||||
import java.util.HashSet; | import java.util.HashSet; | ||||
import java.util.LinkedHashMap; | import java.util.LinkedHashMap; | ||||
Database db = create(fileFormat); | Database db = create(fileFormat); | ||||
try { | try { | ||||
((DatabaseImpl)db).createTable("test", Collections.<ColumnBuilder>emptyList()); | |||||
new TableBuilder("test").toTable(db); | |||||
fail("created table with no columns?"); | fail("created table with no columns?"); | ||||
} catch(IllegalArgumentException e) { | } catch(IllegalArgumentException e) { | ||||
// success | // success | ||||
columns.add(new ColumnBuilder(colName, DataType.TEXT).toColumn()); | columns.add(new ColumnBuilder(colName, DataType.TEXT).toColumn()); | ||||
} | } | ||||
((DatabaseImpl)db).createTable("test", columns); | |||||
Table t = db.getTable("test"); | |||||
Table t = new TableBuilder("test") | |||||
.addColumns(columns) | |||||
.toTable(db); | |||||
List<String> row = new ArrayList<String>(); | List<String> row = new ArrayList<String>(); | ||||
Map<String,Object> expectedRowData = new LinkedHashMap<String, Object>(); | Map<String,Object> expectedRowData = new LinkedHashMap<String, Object>(); |