Changeset 1287 for trunk/sources/HeuristicLab.CEDMA.Core/DataSet.cs
- Timestamp:
- 03/08/09 12:48:18 (15 years ago)
- File:
-
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.CEDMA.Core/DataSet.cs
r957 r1287 30 30 31 31 namespace HeuristicLab.CEDMA.Core { 32 public class DataSet {32 public class DataSet : IViewable { 33 33 public IStore Store { get; set; } 34 public long Id { get; set; } 35 public string Name { get; set; } 34 35 private Guid guid; 36 public Guid Guid { 37 get { return guid; } 38 } 39 40 private string name; 41 public string Name { 42 get { return name; } 43 set { name = value; } 44 } 45 36 46 private Problem problem; 37 38 47 public Problem Problem { 39 get { return problem; } 48 get { 49 // lazy loading of problem from DB 50 if (problem == null) { 51 //var serializedDataVar = new HeuristicLab.CEDMA.DB.Interfaces.Variable("SerializedData"); 52 //var persistedData = Store.Query( 53 // new Statement[] { new Statement(new Entity(Ontology.CedmaNameSpace + Guid), Ontology.PredicateSerializedData, serializedDataVar)}); 54 var persistedData = Store.Query( 55 "<" + Ontology.CedmaNameSpace + Guid + "> <" + Ontology.PredicateSerializedData.Uri + "> ?SerializedData ."); 56 if (persistedData.Count() == 1) { 57 Literal persistedLiteral = (Literal)persistedData.First().Get("SerializedData"); 58 this.problem = (Problem)PersistenceManager.RestoreFromGZip(Convert.FromBase64String((string)persistedLiteral.Value)); 59 } else 60 this.problem = new Problem(); // no entry in the DB => create a new problem 61 } 62 return problem; 63 } 40 64 } 41 65 42 66 public DataSet() 43 67 : base() { 44 problem = new Problem(); 68 guid = Guid.NewGuid(); 69 name = "Data set"; 45 70 } 46 71 47 public DataSet(IStore store, long id)72 public DataSet(IStore store, Entity dataSetEntity) 48 73 : this() { 49 74 Store = store; 50 Id = id; 51 } 52 53 public void Save() { 54 throw new NotImplementedException(); 75 guid = new Guid(dataSetEntity.Uri.Remove(0, Ontology.CedmaNameSpace.Length)); 76 name = guid.ToString(); 55 77 } 56 78 57 79 public void Activate() { 58 throw new NotImplementedException(); 59 } 60 61 private void UpdateDataSet(long Id, byte[] p) { 62 throw new NotImplementedException(); 80 Entity myEntity = new Entity(Ontology.CedmaNameSpace + Guid); 81 Store.Add(new Statement(myEntity, Ontology.PredicateInstanceOf, Ontology.TypeDataSet)); 82 Store.Add(new Statement(myEntity, Ontology.PredicateSerializedData, new Literal(Convert.ToBase64String(PersistenceManager.SaveToGZip(problem))))); 83 Store.Add(new Statement(myEntity, Ontology.PredicateName, new Literal(name))); 63 84 } 64 85 … … 66 87 return new DataSetView(this); 67 88 } 89 90 internal Results GetResults() { 91 Results results = new Results(Store); 92 results.FilterDataSet(new Entity(Ontology.CedmaNameSpace + Guid)); 93 return results; 94 } 68 95 } 69 96 }
Note: See TracChangeset
for help on using the changeset viewer.