#region License Information
/* HeuristicLab
* Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
*
* This file is part of HeuristicLab.
*
* HeuristicLab is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* HeuristicLab is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with HeuristicLab. If not, see .
*/
#endregion
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using HeuristicLab.Core;
using System.Xml;
using HeuristicLab.CEDMA.DB.Interfaces;
using HeuristicLab.Operators;
namespace HeuristicLab.CEDMA.Core {
public class DataSet : IViewable {
public IStore Store { get; set; }
private Guid guid;
public Guid Guid {
get { return guid; }
}
private string name;
public string Name {
get { return name; }
}
private Problem problem;
public Problem Problem {
get { return problem; }
}
public DataSet()
: base() {
guid = Guid.NewGuid();
name = "Data set";
problem = new Problem();
}
public DataSet(IStore store, Entity dataSetEntity)
: this() {
Store = store;
guid = new Guid(dataSetEntity.Uri.Remove(0, Ontology.CedmaNameSpace.Length));
IList names = store.Select(new Statement(dataSetEntity, Ontology.PredicateName, Ontology.AnyEntity));
if(names.Count > 0) name = (string)((Literal)names[0].Property).Value;
else name = guid.ToString();
}
public void Activate() {
Entity myEntity = new Entity(Ontology.CedmaNameSpace + Guid);
Store.Add(new Statement(myEntity, Ontology.PredicateInstanceOf, Ontology.TypeDataSet));
Store.Add(new Statement(myEntity, Ontology.PredicateSerializedData, new Literal(PersistenceManager.SaveToGZip(problem))));
Store.Add(new Statement(myEntity, Ontology.PredicateName, new Literal(name)));
}
public IView CreateView() {
return new DataSetView(this);
}
}
}