Changeset 6430
- Timestamp:
- Mar 10, 2014, 11:16:36 AM (9 years ago)
- Location:
- trunk/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/core/net/sf/basedb/core/log/db/DbLogManagerFactory.java
r6420 r6430 37 37 import net.sf.basedb.core.log.LogManager; 38 38 import net.sf.basedb.core.log.LogManagerFactory; 39 import net.sf.basedb.core.log.db.AnnotationLogger; 40 import net.sf.basedb.core.log.db.AnnotationSetLogger; 41 import net.sf.basedb.core.log.db.AnyToAnyLogger; 42 import net.sf.basedb.core.log.db.BioMaterialEventLogger; 43 import net.sf.basedb.core.log.db.DefaultEntityLogger; 44 import net.sf.basedb.core.log.db.FileSetMemberLogger; 45 import net.sf.basedb.core.log.db.PlateEventLogger; 39 46 import net.sf.basedb.util.extensions.ActionFactory; 40 47 import net.sf.basedb.util.extensions.InvokationContext; … … 60 67 public DbLogManagerFactory() 61 68 { 69 this(Config.getBoolean("changelog.dblogger.detailed-properties"), Config.getBoolean("changelog.dblogger.old-property-values")); 70 } 71 72 public DbLogManagerFactory(boolean detailedProperties, boolean oldValues) 73 { 62 74 this.specialLoggers = new HashMap<Class, EntityLogger>(); 63 this.detailedProperties = Config.getBoolean("changelog.dblogger.detailed-properties");64 this.oldPropertyValues = detailedProperties ? Config.getBoolean("changelog.dblogger.old-property-values") : false;75 this.detailedProperties = detailedProperties; 76 this.oldPropertyValues = detailedProperties && oldValues; 65 77 66 78 this.defaultLogger = new DefaultEntityLogger(this); … … 71 83 setSpecialLogger(AnnotationSetData.class, new AnnotationSetLogger(this)); 72 84 setSpecialLogger(AnyToAnyData.class, new AnyToAnyLogger(this)); 85 73 86 } 74 87 -
trunk/src/test/TestChangeHistory.java
r6100 r6430 28 28 import net.sf.basedb.core.BasicItem; 29 29 import net.sf.basedb.core.ChangeHistory; 30 import net.sf.basedb.core.Sample; 30 31 import net.sf.basedb.core.DbControl; 31 32 import net.sf.basedb.core.Item; … … 79 80 80 81 Extension<LogManagerFactory> logger = new ExtensionBean<LogManagerFactory>( 81 "test.db-logger", "net.sf.basedb.core.log-manager", 1, null, new DbLogManagerFactory( ), null);82 "test.db-logger", "net.sf.basedb.core.log-manager", 1, null, new DbLogManagerFactory(true, true), null); 82 83 xtRegistry.registerExtension(logger, null); 83 84 … … 86 87 int bioSourceId = TestBioSource.test_create("Biosource 1", false); 87 88 int sampleId = TestSample.test_create(bioSourceId, "Sample 1", 0, false); 89 test_update_sample(sampleId); 88 90 int annotationTypeId = TestAnnotationType.test_create("change", Type.INT, 0, null, null, Item.SAMPLE, 1, null, false); 89 91 TestAnnotation.test_annotatate(Item.SAMPLE, sampleId, annotationTypeId, 0, 1); … … 94 96 95 97 test_list_by_item(Item.BIOSOURCE, bioSourceId, 1); 96 test_list_by_item(Item.SAMPLE, sampleId, 6);98 test_list_by_item(Item.SAMPLE, sampleId, 7); 97 99 /* 98 100 Total change log events: 99 4 CREATE (biosource, sample, annotationtype, extract)100 5 UPDATE (when adding,updating and removing the annotation from the sample)101 1 DELETE (extract)101 5 CREATE (biosource, sample, annotationtype, extract, annotation) 102 4 UPDATE (when updating and removing the annotation from the sample) 103 2 DELETE (extract, annotation) 102 104 */ 103 test_list_by_user(TestUtil.getSessionControl().getLoggedInUserId(), since, 1 0);105 test_list_by_user(TestUtil.getSessionControl().getLoggedInUserId(), since, 11); 104 106 105 107 if (TestUtil.waitBeforeDelete()) TestUtil.waitForEnter(); … … 108 110 TestBioSource.test_delete(bioSourceId); 109 111 TestAnnotationType.test_delete(annotationTypeId); 110 // 1 3 = The original 10create+update + 3 delete111 test_delete_stray(1 3);112 // 14 = The original 11 create+update + 3 delete 113 test_delete_stray(14); 112 114 113 115 xtRegistry.unregisterExtension("test.db-logger"); … … 194 196 if (!TestUtil.getSilent()) 195 197 { 196 write(" \tID \tTime \tType\tItem \tChange info\t User");197 write("-- \t-- \t---------\t----\t------\t-----------\t---- ");198 write(" \tID \tTime \tType\tItem \tChange info\tOld value\tNew value\tUser"); 199 write("-- \t-- \t---------\t----\t------\t-----------\t---------\t---------\t----"); 198 200 } 199 201 } … … 212 214 } 213 215 if (!TestUtil.getSilent()) System.out.println(i+":\t"+c.getId()+"\t"+c.getTime()+"\t"+ 214 c.getChangeType() + "\t" + item + "\t" + c.getChangeInfo()+"\t"+c.get User(null));216 c.getChangeType() + "\t" + item + "\t" + c.getChangeInfo()+"\t"+c.getOldValue()+"\t"+c.getNewValue()+"\t"+c.getUser(null)); 215 217 } 216 218 static void write(String message) … … 242 244 } 243 245 246 static void test_update_sample(int sampleId) 247 { 248 DbControl dc = null; 249 try 250 { 251 dc = TestUtil.getDbControl(); 252 Sample s = Sample.getById(dc, sampleId); 253 s.setName("Updated name"); 254 s.setExternalId("Added external id"); 255 dc.commit(); 256 write("--Updated sample OK"); 257 } 258 catch (Throwable ex) 259 { 260 write("--Updated sample FAILED"); 261 ex.printStackTrace(); 262 ok = false; 263 } 264 finally 265 { 266 if (dc != null) dc.close(); 267 } 268 } 244 269 } 245 270
Note: See TracChangeset
for help on using the changeset viewer.