Changeset 2613
- Timestamp:
- 01/31/10 09:59:16 (2 years ago)
- Location:
- molgenis/3.3/src/org/molgenis
- Files:
-
- 2 edited
-
generators/csv/CsvImportGen.java.ftl (modified) (5 diffs)
-
model/elements/Entity.java (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
molgenis/3.3/src/org/molgenis/generators/csv/CsvImportGen.java.ftl
r2589 r2613 72 72 public static void importAll(File directory, Database db, Tuple defaults) throws Exception 73 73 { 74 importAll(directory,db,defaults,null, DatabaseAction.ADD, "NA", false); 75 } 76 77 public static void importAll(File directory, Database db, Tuple defaults, boolean forceCommits) throws Exception 78 { 79 importAll(directory,db,defaults,null, DatabaseAction.ADD, "NA", forceCommits); 74 importAll(directory, db, defaults, null, DatabaseAction.ADD, "NA"); 80 75 } 81 76 … … 84 79 * TODO: add filter parameters... 85 80 */ 86 public static ImportResult importAll(File directory, Database db, Tuple defaults, List<String> components, DatabaseAction dbAction, String missingValue , boolean forceCommits) throws Exception81 public static ImportResult importAll(File directory, Database db, Tuple defaults, List<String> components, DatabaseAction dbAction, String missingValue) throws Exception 87 82 { 88 83 ImportResult result = new ImportResult(); … … 90 85 try 91 86 { 92 if(!db.inTx()){ db.beginTx(); } 87 if (!db.inTx()) 88 { 89 db.beginTx(); 90 }else{ 91 throw new DatabaseException("Cannot continue CsvImport: database already in transaction."); 92 } 93 93 94 94 if(dbAction.toString().startsWith("REMOVE")) … … 117 117 { 118 118 try { 119 if(forceCommits && !db.inTx()){ db.beginTx(); }120 119 int count = new ${JavaName(entity)}CsvReader().importCsv(db, new File(directory+"/${entity.name?lower_case}.txt"), defaults, dbAction, missingValue); 121 120 result.getProgressLog().add("${entity.name?lower_case}"); 122 121 result.getMessages().put("${entity.name?lower_case}", "evaluated "+count+" ${entity.name?lower_case} elements"); 123 if(forceCommits){ db.commitTx(); }124 122 } catch (Exception e) { 125 123 result.setErrorItem("${entity.name?lower_case}"); … … 131 129 } 132 130 133 // insert back again...134 131 logger.debug("commiting transactions..."); 135 if(db.inTx() && !forceCommits) db.commitTx(); 132 if (db.inTx()){ 133 db.commitTx(); 134 }else{ 135 throw new DatabaseException("Cannot commit CsvImport: database not in transaction."); 136 } 136 137 } 137 138 catch (Exception e) 138 139 { 139 logger.error("import failed: " + e.getMessage()); 140 logger.debug("rolling back transactions..."); 141 if(db.inTx()) db.rollbackTx(); 142 140 logger.error("Import failed: " + e.getMessage()); 141 if (db.inTx()){ 142 logger.debug("Db in transaction, rolling back..."); 143 db.rollbackTx(); 144 }else{ 145 logger.debug("Db not in transaction"); 146 } 143 147 e.printStackTrace(); 148 149 //Don't throw to avoid 'try-catch' on usage. No harm done. 144 150 //throw e; 145 151 } -
molgenis/3.3/src/org/molgenis/model/elements/Entity.java
r2612 r2613 570 570 all_fields.put(f.getName(), f); 571 571 } 572 573 574 logger.info("herken " + all_fields.keySet());575 572 return new Vector(all_fields.values()); 576 573 }
Note: See TracChangeset
for help on using the changeset viewer.