- Timestamp:
- 09/10/08 10:29:28 (16 years ago)
- Location:
- trunk/sources
- Files:
-
- 5 deleted
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.CEDMA.DB.Interfaces/HeuristicLab.CEDMA.DB.Interfaces.csproj
r537 r543 55 55 <ItemGroup> 56 56 <Compile Include="AgentEntry.cs" /> 57 <Compile Include="ItemEntry.cs" />58 57 <Compile Include="OperatorEntry.cs" /> 59 58 <Compile Include="ProcessStatus.cs" /> -
trunk/sources/HeuristicLab.CEDMA.DB.Interfaces/IDatabase.cs
r537 r543 82 82 [OperationContract] 83 83 OperatorEntry GetOperator(long id); 84 85 [OperationContract]86 IList<ItemEntry> GetOntologyItems();87 88 [OperationContract]89 IList<ItemEntry> GetItems(Guid predicate, Guid property);90 91 [OperationContract]92 void LinkItems(ItemEntry subject, ItemEntry predicate, ItemEntry property);93 84 } 94 85 } -
trunk/sources/HeuristicLab.CEDMA.DB/Database.cs
r541 r543 66 66 using(DbCommand cmd = cnn.CreateCommand()) { 67 67 cmd.CommandText = "CREATE TABLE Operator (ID integer primary key autoincrement, Name text, RawData Blob)"; 68 cmd.Transaction = t;69 cmd.ExecuteNonQuery();70 }71 using(DbCommand cmd = cnn.CreateCommand()) {72 cmd.CommandText = "CREATE TABLE Item (guid GUID primary key, RawData Blob)";73 cmd.Transaction = t;74 cmd.ExecuteNonQuery();75 }76 using(DbCommand cmd = cnn.CreateCommand()) {77 cmd.CommandText = "CREATE TABLE Statement (id integer primary key autoincrement, subject GUID, predicate GUID, property GUID, CreationTime DateTime)";78 68 cmd.Transaction = t; 79 69 cmd.ExecuteNonQuery(); … … 629 619 } 630 620 #endregion 631 632 public IList<ItemEntry> GetOntologyItems() {633 List<ItemEntry> ontologies = new List<ItemEntry>();634 List<ItemEntry> items = new List<ItemEntry>();635 rwLock.EnterReadLock();636 try {637 using(DbConnection cnn = new SQLiteConnection(connectionString)) {638 cnn.Open();639 using(DbCommand c = cnn.CreateCommand()) {640 c.CommandText = "Select guid, rawdata from Item,(select subject from Statement where subject=property) where subject=guid";641 using(DbDataReader r = c.ExecuteReader()) {642 while(r.Read()) {643 ItemEntry ontology = new ItemEntry();644 ontology.Guid = r.GetGuid(0);645 ontology.RawData = (byte[])r.GetValue(1);646 ontologies.Add(ontology);647 }648 }649 }650 foreach(ItemEntry ontology in ontologies) {651 using(DbCommand c = cnn.CreateCommand()) {652 c.CommandText = "Select guid, rawdata from Item,(select property from Statement where subject=@ontology) where guid=property";653 DbParameter ontologyParam = c.CreateParameter();654 ontologyParam.ParameterName = "@ontology";655 ontologyParam.Value = ontology.Guid.ToString();656 c.Parameters.Add(ontologyParam);657 using(DbDataReader r = c.ExecuteReader()) {658 while(r.Read()) {659 ItemEntry item = new ItemEntry();660 item.Guid = r.GetGuid(0);661 item.RawData = (byte[])r.GetValue(1);662 items.Add(item);663 }664 }665 }666 }667 }668 } finally {669 rwLock.ExitReadLock();670 }671 return items;672 }673 674 public IList<ItemEntry> GetItems(Guid predicate, Guid property) {675 List<ItemEntry> items = new List<ItemEntry>();676 rwLock.EnterReadLock();677 try {678 using(DbConnection cnn = new SQLiteConnection(connectionString)) {679 cnn.Open();680 using(DbCommand c = cnn.CreateCommand()) {681 c.CommandText = "Select guid, rawdata from Item,(select subject from Statement where predicate=@Predicate and property=@Property) where subject=guid";682 DbParameter predParam = c.CreateParameter();683 predParam.ParameterName = "@Predicate";684 predParam.Value = predicate.ToString();685 c.Parameters.Add(predParam);686 DbParameter propertyParam = c.CreateParameter();687 propertyParam.ParameterName = "@Property";688 propertyParam.Value = property.ToString();689 c.Parameters.Add(propertyParam);690 using(DbDataReader r = c.ExecuteReader()) {691 while(r.Read()) {692 ItemEntry item = new ItemEntry();693 item.Guid = r.GetGuid(0);694 item.RawData = (byte[])r.GetValue(1);695 items.Add(item);696 }697 }698 }699 }700 } finally {701 rwLock.ExitReadLock();702 }703 return items;704 }705 706 public void LinkItems(ItemEntry subject, ItemEntry predicate, ItemEntry property) {707 rwLock.EnterWriteLock();708 try {709 using(SQLiteConnection cnn = new SQLiteConnection(connectionString)) {710 cnn.Open();711 using(SQLiteTransaction t = cnn.BeginTransaction()) {712 ItemEntry[] items = new ItemEntry[] { subject, predicate, property };713 foreach(ItemEntry item in items) {714 long n = 0;715 using(SQLiteCommand c = cnn.CreateCommand()) {716 c.Transaction = t;717 c.CommandText = "select count(guid) from item where guid=@guid";718 DbParameter guidParam = c.CreateParameter();719 guidParam.ParameterName = "@guid";720 guidParam.Value = item.Guid.ToString();721 c.Parameters.Add(guidParam);722 n = (long)c.ExecuteScalar();723 }724 if(n == 0) using(SQLiteCommand c = cnn.CreateCommand()) {725 c.Transaction = t;726 c.CommandText = "insert into item (Guid, RawData) values (@Guid, @RawData)";727 DbParameter guidParam = c.CreateParameter();728 guidParam.ParameterName = "@Guid";729 guidParam.Value = item.Guid.ToString();730 c.Parameters.Add(guidParam);731 DbParameter rawDataParam = c.CreateParameter();732 rawDataParam.ParameterName = "@RawData";733 rawDataParam.Value = item.RawData;734 c.Parameters.Add(rawDataParam);735 c.ExecuteNonQuery();736 }737 }738 using(SQLiteCommand c = cnn.CreateCommand()) {739 c.Transaction = t;740 c.CommandText = "insert into Statement (Subject, Predicate, Property, CreationTime) values (@Subject, @Predicate, @Property, @CreationTime)";741 DbParameter subjectParam = c.CreateParameter();742 subjectParam.ParameterName = "@Subject";743 subjectParam.Value = subject.Guid.ToString();744 c.Parameters.Add(subjectParam);745 DbParameter predParam = c.CreateParameter();746 predParam.ParameterName = "@Predicate";747 predParam.Value = predicate.Guid.ToString();748 c.Parameters.Add(predParam);749 DbParameter propertyParam = c.CreateParameter();750 propertyParam.ParameterName = "@Property";751 propertyParam.Value = property.Guid.ToString();752 c.Parameters.Add(propertyParam);753 DbParameter timeParam = c.CreateParameter();754 timeParam.ParameterName = "@CreationTime";755 timeParam.Value = DateTime.Now;756 c.Parameters.Add(timeParam);757 c.ExecuteNonQuery();758 }759 t.Commit();760 }761 }762 } finally {763 rwLock.ExitWriteLock();764 }765 }766 621 } 767 622 } -
trunk/sources/HeuristicLab.CEDMA.Operators/HeuristicLab.CEDMA.Operators.csproj
r542 r543 54 54 </ItemGroup> 55 55 <ItemGroup> 56 <Compile Include="VariableExtractor.cs" />57 <Compile Include="SubScopesExtractor.cs" />58 <Compile Include="OntologyExtractor.cs" />59 56 <Compile Include="ResultsExtractor.cs" /> 60 <Compile Include="MakeStatement.cs" />61 57 <Compile Include="InjectedVariableExtractor.cs" /> 62 58 <Compile Include="SplitScopeToItemsResultWriter.cs" /> -
trunk/sources/HeuristicLab.CEDMA.Server/HeuristicLab.CEDMA.Server.csproj
r419 r543 4 4 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> 5 5 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> 6 <ProductVersion>9.0. 21022</ProductVersion>6 <ProductVersion>9.0.30729</ProductVersion> 7 7 <SchemaVersion>2.0</SchemaVersion> 8 8 <ProjectGuid>{F05D261A-4F7D-46C9-AB9C-21FD4566D719}</ProjectGuid> -
trunk/sources/HeuristicLab.CEDMA.Server/ServerForm.cs
r540 r543 70 70 database = new Database(connectionString); 71 71 database.CreateNew(); 72 InitDefaultOntology();73 72 } else { 74 73 database = new Database(connectionString); 75 if(database.GetOntologyItems().Count == 0) InitDefaultOntology();76 74 } 77 }78 79 private void InitDefaultOntology() {80 // init default ontology81 StringData[] entities = new StringData[] {82 new StringData("CedmaOntology"),83 new StringData("definesEntity"),84 new StringData("class:GpFunctionTree"),85 new StringData("class:Dataset"),86 new StringData("instanceOf"),87 new StringData("hasModel"),88 new StringData("modelOf"),89 new StringData("targetVariable"),90 new StringData("trainingSamplesStart"),91 new StringData("trainingSamplesEnd"),92 new StringData("validationSamplesStart"),93 new StringData("validationSamplesEnd"),94 new StringData("testSamplesStart"),95 new StringData("testSamplesEnd"),96 new StringData("trainingMeanSquaredError"),97 new StringData("validationMeanSquaredError"),98 new StringData("testMeanSquaredError"),99 new StringData("trainingMeanAbsolutePercentageError"),100 new StringData("validationMeanAbsolutePercentageError"),101 new StringData("testMeanAbsolutePercentageError"),102 new StringData("treeSize"),103 new StringData("treeHeight")104 };105 foreach(StringData entity in entities) {106 LinkItems(entities[0], entities[1], entity);107 }108 }109 110 private void LinkItems(StringData subj, StringData pred, StringData prop) {111 ItemEntry subjEntry = new ItemEntry();112 ItemEntry predEntry = new ItemEntry();113 ItemEntry propEntry = new ItemEntry();114 subjEntry.Guid = subj.Guid;115 subjEntry.RawData = PersistenceManager.SaveToGZip(subj);116 predEntry.Guid = pred.Guid;117 predEntry.RawData = PersistenceManager.SaveToGZip(pred);118 propEntry.Guid = prop.Guid;119 propEntry.RawData = PersistenceManager.SaveToGZip(prop);120 121 database.LinkItems(subjEntry, predEntry, propEntry);122 75 } 123 76
Note: See TracChangeset
for help on using the changeset viewer.