public DataSetStorageContext(Func <DataSchema> ontologyPrv)
        {
            InitStorageDS();
            StorageDalc = new DataSetDalc(StorageDS);

            StorageDbMgr           = new DataRowDalcMapper(StorageDalc, new StorageDataSetPrv(StorageDS).GetDataSet);
            ObjectContainerStorage = new ObjectContainerDalcStorage(StorageDbMgr, StorageDalc, ontologyPrv);
        }
Beispiel #2
0
        public SQLiteStorageContext(Func <DataRowDalcMapper, IObjectContainerStorage, IDataSchemaStorage> getSchemaStorage)
        {
            dbFileName = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName() + ".db");
            var connStr           = String.Format("Data Source={0};FailIfMissing=false;Pooling=False;", dbFileName);
            var sqliteDalcFactory = new SQLiteDalcFactory();

            Connection = sqliteDalcFactory.CreateConnection();
            Connection.ConnectionString = connStr;
            InternalDalc = new DbDalc(sqliteDalcFactory, Connection, new [] {
                new DbDalcView("objects_view", @"
					SELECT @SqlFields
					FROM objects
					@Joins
					@SqlWhere[where {0}]
					@SqlOrderBy[order by {0}]
				"                )
                {
                    FieldMapping = new Dictionary <string, string>()
                    {
                        { "id", "objects.id" },
                        { "compact_class_id", "objects.compact_class_id" }
                    }
                },

                new DbDalcView("object_relations_view", @"
					SELECT @SqlFields
					FROM object_relations r
					LEFT JOIN objects subj ON (subj.id=subject_id)
					LEFT JOIN objects obj ON (obj.id=object_id)
					@SqlWhere[where {0}]
					@SqlOrderBy[order by {0}]					
				"                ,
                               "subject_id,predicate_class_compact_id,object_id,subj.compact_class_id as subject_compact_class_id,obj.compact_class_id as object_compact_class_id",
                               "count(r.id)")
            });
            var dbEventsBroker = new DataEventBroker(InternalDalc);
            var sqlTraceLogger = new NI.Data.Triggers.SqlCommandTraceTrigger(dbEventsBroker);

            InitDbSchema();

            StorageDbMgr = new DataRowDalcMapper(InternalDalc, new StorageDataSetPrv(CreateStorageSchemaDS()).GetDataSet);

            var objStorage = new ObjectContainerSqlDalcStorage(StorageDbMgr, InternalDalc, () => { return(DataSchemaStorage.GetSchema()); });

            objStorage.DeriveTypeMapping = new Dictionary <string, string>()
            {
                { "getDateYear", "CAST(strftime('%Y', {0}) as integer)" }
            };
            DataSchemaStorage = getSchemaStorage(StorageDbMgr, objStorage);

            objStorage.ObjectViewName         = "objects_view";
            objStorage.ObjectRelationViewName = "object_relations_view";
            ObjectContainerStorage            = objStorage;

            StorageDalc = new StorageDalc(InternalDalc, ObjectContainerStorage, DataSchemaStorage.GetSchema);
        }
        public static void AddTestData(DataSchema testSchema, IObjectContainerStorage storage)
        {
            var googCompany = new ObjectContainer(testSchema.FindClassByID("companies"));

            googCompany["title"] = "Google";

            var msCompany = new ObjectContainer(testSchema.FindClassByID("companies"));

            msCompany["title"] = "Microsoft";

            storage.Insert(googCompany);
            storage.Insert(msCompany);

            var johnContact = new ObjectContainer(testSchema.FindClassByID("contacts"));

            johnContact["name"]       = "John";
            johnContact["is_primary"] = true;
            var maryContact = new ObjectContainer(testSchema.FindClassByID("contacts"));

            maryContact["name"]       = "Mary";
            maryContact["is_primary"] = false;
            maryContact["birthday"]   = new DateTime(1999, 5, 20);
            var bobContact = new ObjectContainer(testSchema.FindClassByID("contacts"));

            bobContact["name"]       = "Bob";
            bobContact["is_primary"] = true;

            storage.Insert(johnContact);
            storage.Insert(maryContact);
            storage.Insert(bobContact);

            var rel = testSchema.FindClassByID("contacts").FindRelationship(
                testSchema.FindClassByID("contactCompany"), testSchema.FindClassByID("companies"));

            storage.AddRelation(
                new ObjectRelation(johnContact.ID.Value, rel, googCompany.ID.Value)
                );
        }
Beispiel #4
0
 /// <summary>
 /// Initializes a new instance of StorageDalc with specified <see cref="IDalc"/>, <see cref="IObjectContainerStorage"/> implementations and schema provider delegate
 /// </summary>
 /// <param name="dalc">DALC instance for accessing underlying storage tables</param>
 /// <param name="objContainerStorage">object container storage instance</param>
 /// <param name="getSchema">storage schema provider delegate</param>
 public StorageDalc(IDalc dalc, IObjectContainerStorage objContainerStorage, Func <DataSchema> getSchema)
 {
     UnderlyingDalc         = dalc;
     GetSchema              = getSchema;
     ObjectContainerStorage = objContainerStorage;
 }
Beispiel #5
0
 public ChangeRow(DataSchema schema, IObjectContainerStorage objStorage, IDalc storageDalc)
 {
     Schema      = schema;
     ObjStorage  = objStorage;
     StorageDalc = storageDalc;
 }
Beispiel #6
0
 public StorageService(IObjectContainerStorage objPersister, IDalc storageDalc, Func <DataSchema> getOntology)
 {
     ObjPersister    = objPersister;
     ProvideOntology = getOntology;
     StorageDalc     = storageDalc;
 }
 public OwlEmbeddedSchemaStorage(IObjectContainerStorage objStorage)
 {
     ObjectStorage  = objStorage;
     OwlConfig      = OwlConfiguration.Default;
     ObjectPkColumn = "id";
 }