Archive

Archive for the ‘Entity Model’ Category

 

Example preview

November 21st, 2008

Here are drafts of a source code and a class diagram of what it should be about the usage of the database.

Exemple Preview Class Diagram

//-----------------------------------------------------------------------------
[Serializable]
public class AlarmPeriodicity
{
  public int PeriodType { get; set; };
  public DateTime Value { get; set; };
}

//-----------------------------------------------------------------------------
[Serializable]
public class AlarmPeriodicityProperty : EntityProperty < AlarmPeriodicity >
{
  public AlarmPeriodicityProperty(EntityItem owneritem)
    : base(owneritem) { }
  public AlarmPeriodicityProperty(EntityItem owneritem, AlarmPeriodicity value)
    : base(owneritem, value) { }
}

//-----------------------------------------------------------------------------
[Serializable]
public class AlarmItem : EntityItem
{
  public StringEntityProperty Title { get { return _Title; } }
  private StringEntityProperty _Title;

  public AlarmPeriodicityProperty Periodicity { get { return _Periodicity; } }
  private AlarmPeriodicityProperty _Periodicity;

  public AlarmItem(IEntityCollection ownerset, UserItem creator)
    : base(ownerset, creator)
  {
  }
}

//-----------------------------------------------------------------------------
[Serializable]
public class AlarmsCollection : EntityCollection < AlarmItem >
{
  public AlarmsCollection(SessionManager manager)
    : base(manager, "Alarms")
  {
  }
}

//-----------------------------------------------------------------------------
// Methods raise an exception if user have no access right to the element.
//-----------------------------------------------------------------------------
[Serializable]
public class DatabaseConnexion : SessionManager
{
  public AlarmsCollection Alarms { get { return _Alarms; } }
  static private AlarmsCollection _Alarms;

  public DatabaseConnexion(string usercode, string userpwd)
    : base(usercode, userpwd) { }

  static public void RunSample()
  {
    DatabaseConnexion session = new DatabaseConnexion("user", "password");

    AlarmItem item1 = (AlarmItem)session.Alarms.CreateEntity();
    item1.Lock();
    item1.Edit();
    item1.Title.Value = "Title";
    item1.Periodicity.Value.PeriodType = 1;
    item1.Apply();
    item1.Unlock();

    AlarmItem item2 = (AlarmItem)session.Alarms.CreateEntity();
    item2.LockEdit();
    item2.Title.Value = "Title";
    item2.Periodicity.Value.PeriodType = 2;
    item2.ApplyUnlock();

    var list = from AlarmItem item
               in session.Alarms
               where ( item.Title.Value == "Title" )
               select item;

    session.Alarms.Lock();
    session.Alarms.Edit();
    foreach ( var item in list )
    {
      Console.WriteLine(item.Title.Value);
      item.Title.Value = "Another Title";
    }
    session.Alarms.Cancel();
    session.Alarms.Remove(item2);
    session.Alarms.Unlock();
  }
}

Print Print      Email Email

 

Composition of the Entity Model

November 26th, 2008

Lockable

  • KeyID : Generic base class for IDs.
  • Lockable : Base class for lockable and editable objects with rights management.
  • Users : System users entity.
  • Params : System parameters entity.

Entity

  • EntityProperty : Base class for entity properties.
  • OrdinalProperty : Base class for ordinal entity properties.
  • EntityItem : Base class for entity that contains properties and processings.
  • EntityCollection : Generic base class for entities collection management.
  • SessionManager : Base class for a database session to access managed collections.

Print Print      Email Email

 

Persistence guidelines

July 13th, 2009

The XOODBS goal is to provide a simple and powerful Persistence Framework that allows programmers :

  • To define classes structure,
  • To implement operations,
  • To create, modify and delete instances,
  • As they use the standard features of a .NET object language,
  • And nothing else but select the type of a container and its location, as well as locking items.

Through a caching system, an ObjectEntityMapper handles in a transparent manner the presence of data items in the memories of the SessionManager and in the storage namespaces provided by the ObjectContainer.

In this way, instances of items stored in the database are conventionally used as if there is an unlimited and persistent 64 bits memory, according to the limits and performances provided by container, operating system, hardware and network connection.

The last limit is that an object, or a set of objects working together, whose size is not loadable in the physical and virtual memory of the system is not usable, unless they manage their own aggregated buffers, ie it is better to store data such as large multimedia items in separate files on disk.

You can see the Example Preview for more details.

// Remark : only value modifications can be cancelled or applied, not insert or delete
SessionManager session = new SessionManager < SQLiteContainer > ("db.bin", "user", "pwd");
session.AutoLockEdit = true;
var list = session.Alarms.FindInactive();
foreach (var item in list)
{
    session.Alarms.Remove(item);
    session.Recycle.Add(item);
}
session.Close();

Print Print      Email Email