@@ -34,6 +34,20 @@ protected RCV_Model(DBContext context, SSheet sheet, String tableName) {
3434 loadMetaData (context );
3535 }
3636
37+ protected RCV_Model (DBContext context , SSheet sheet , String tableName , RCV_Model source ) {
38+ this .sheet = sheet ;
39+ rowMapping = source .rowMapping .clone (context , tableName + "_row_idx" );
40+ colMapping = source .colMapping .clone (context , tableName + "_col_idx" );
41+ this .tableName = tableName ;
42+ copySchema (context , source .tableName );
43+ source .bs .clone (context , tableName + "_rcv_meta" );
44+ loadMetaData (context );
45+ }
46+
47+ @ Override
48+ public Model clone (DBContext context , SSheet sheet , String tableName ) {
49+ return new RCV_Model (context , sheet , tableName , this );
50+ }
3751
3852 private void loadMetaData (DBContext context ) {
3953 bs = new BlockStore (context , tableName + "_rcv_meta" );
@@ -45,6 +59,22 @@ private void loadMetaData(DBContext context) {
4559 }
4660 }
4761
62+ //Copy the table
63+ private void copySchema (DBContext dbContext , String sourceTable ) {
64+ createSchema (dbContext );
65+ String copyTable = (new StringBuffer ())
66+ .append ("INSERT INTO " )
67+ .append (tableName )
68+ .append (" SELECT * FROM " )
69+ .append (sourceTable )
70+ .toString ();
71+ AutoRollbackConnection connection = dbContext .getConnection ();
72+ try (Statement stmt = connection .createStatement ()) {
73+ stmt .execute (copyTable );
74+ } catch (SQLException e ) {
75+ e .printStackTrace ();
76+ }
77+ }
4878
4979 //Create a table from the database
5080 private void createSchema (DBContext dbContext ) {
0 commit comments