Esempio n. 1
0
 public virtual void CreateEntryClass(PersistenceContext context, string className
     , string[] fieldNames, string[] fieldTypes)
 {
     LogMethodCall("createEntryClass", context, className);
     var repository = Repository(context);
     repository.DefineClass(className, fieldNames, fieldTypes);
     UpdateMetadata(context, repository);
 }
		private void MarkIndexedField(PersistenceContext context, string className, string
			 fieldName, bool indexed)
		{
			CustomField field = CustomClass(context, className).CustomField(fieldName);
			field.Indexed(indexed);
			UpdateMetadata(context, field);
			Restart(context);
		}
Esempio n. 3
0
 // TODO Auto-generated method stub
 public virtual void InitContext(PersistenceContext context)
 {
     LogMethodCall("initContext", context);
     var metadata = OpenMetadata(context.Url());
     try
     {
         var repository = InitializeClassRepository(metadata);
         var reflector = new CustomReflector(repository);
         var data = OpenData(reflector, context.Url());
         context.SetProviderContext(new MyContext(repository, metadata
             , data));
     }
     catch (Exception e)
     {
         Runtime.PrintStackTrace(e);
         // make sure metadata container is not left open
         // in case something goes wrong with the setup
         CloseIgnoringExceptions(metadata);
         // cant use exception chaining here because the
         // test must run in jdk 1.1
         throw new Db4oException(e);
     }
 }
Esempio n. 4
0
 private CustomClass CustomClass(PersistenceContext context, string className)
 {
     return(Repository(context).ForName(className));
 }
Esempio n. 5
0
 public virtual int Delete(PersistenceContext context, string className, object uid
     )
 {
     // TODO Auto-generated method stub
     return 0;
 }
Esempio n. 6
0
 public virtual void CreateIndex(PersistenceContext context, string className, string
     fieldName)
 {
     MarkIndexedField(context, className, fieldName, true);
 }
Esempio n. 7
0
 private void UpdateMetadata(PersistenceContext context, object metadata)
 {
     Store(MetadataContainer(context), metadata);
 }
Esempio n. 8
0
 private IQuery NewQuery(PersistenceContext context, string className)
 {
     var query = DataContainer(context).Query();
     AddClassConstraint(context, query, className);
     return query;
 }
Esempio n. 9
0
 private IObjectContainer MetadataContainer(PersistenceContext context)
 {
     return My(context).metadata;
 }
		public virtual void TearDown()
		{
			ShutdownProvider(true);
			_context = null;
		}
		private void InitializeContext()
		{
			_context = new PersistenceContext(DataFile());
		}
		private Db4oPersistenceProvider.MyContext My(PersistenceContext context)
		{
			return ((Db4oPersistenceProvider.MyContext)context.GetProviderContext());
		}
Esempio n. 13
0
 private IObjectContainer MetadataContainer(PersistenceContext context)
 {
     return(My(context).metadata);
 }
Esempio n. 14
0
 public virtual IObjectContainer DataContainer(PersistenceContext context)
 {
     return(My(context).data);
 }
Esempio n. 15
0
 private Db4oPersistenceProvider.MyContext My(PersistenceContext context)
 {
     return((Db4oPersistenceProvider.MyContext)context.GetProviderContext());
 }
Esempio n. 16
0
 private MyContext My(PersistenceContext context)
 {
     return ((MyContext) context.GetProviderContext());
 }
Esempio n. 17
0
 public virtual IObjectContainer DataContainer(PersistenceContext context)
 {
     return My(context).data;
 }
Esempio n. 18
0
 public virtual IEnumerator Select(PersistenceContext context, PersistentEntryTemplate
     template)
 {
     LogMethodCall("select", context, template);
     var query = QueryFromTemplate(context, template);
     return new ObjectSetIterator(query.Execute());
 }
Esempio n. 19
0
 private IQuery QueryFromTemplate(PersistenceContext context, PersistentEntryTemplate
     template)
 {
     var query = NewQuery(context, template.className);
     AddFieldConstraints(query, template);
     return query;
 }
Esempio n. 20
0
 public virtual void Update(PersistenceContext context, PersistentEntry entry)
 {
     var existing = SelectByUid(context, entry.className, entry.uid);
     existing.fieldValues = entry.fieldValues;
     DataContainer(context).Store(existing);
 }
Esempio n. 21
0
 private CustomClassRepository Repository(PersistenceContext context)
 {
     return My(context).repository;
 }
Esempio n. 22
0
 public virtual void CloseContext(PersistenceContext context)
 {
     LogMethodCall("closeContext", context);
     var customContext = My(context);
     if (null != customContext)
     {
         CloseIgnoringExceptions(customContext.metadata);
         CloseIgnoringExceptions(customContext.data);
         context.SetProviderContext(null);
     }
 }
Esempio n. 23
0
 private void Restart(PersistenceContext context)
 {
     CloseContext(context);
     InitContext(context);
 }
Esempio n. 24
0
 private PersistentEntry SelectByUid(PersistenceContext context, string className,
     object uid)
 {
     var query = NewQuery(context, className);
     query.Descend("uid").Constrain(uid);
     return (PersistentEntry) query.Execute().Next();
 }
Esempio n. 25
0
 public virtual void DropIndex(PersistenceContext context, string className, string
     fieldName)
 {
     MarkIndexedField(context, className, fieldName, false);
 }
Esempio n. 26
0
 private void AddClassConstraint(PersistenceContext context, IQuery query, string
     className)
 {
     query.Constrain(CustomClass(context, className));
 }
Esempio n. 27
0
 public virtual void DropEntryClass(PersistenceContext context, string className)
 {
 }
Esempio n. 28
0
 private CustomClass CustomClass(PersistenceContext context, string className)
 {
     return Repository(context).ForName(className);
 }
Esempio n. 29
0
 public virtual void Insert(PersistenceContext context, PersistentEntry entry)
 {
     LogMethodCall("insert", context, entry);
     // clone the entry because clients are allowed to reuse
     // entry objects
     DataContainer(context).Store(Clone(entry));
 }
Esempio n. 30
0
 private void AddClassConstraint(PersistenceContext context, IQuery query, string
                                 className)
 {
     query.Constrain(CustomClass(context, className));
 }