Skip to content

Commit

Permalink
Refactoring Database to ResourceNetwork
Browse files Browse the repository at this point in the history
  • Loading branch information
lmorisse committed Sep 8, 2020
1 parent 460aea0 commit ee5e1a8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 23 deletions.
31 changes: 10 additions & 21 deletions SourceCode/Symu/Classes/Organization/OrganizationEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#region using directives

using System.Collections.Generic;
using System.Linq;
using Symu.Classes.Agents;
using Symu.Classes.Agents.Models.CognitiveTemplates;
using Symu.Classes.Murphies;
Expand Down Expand Up @@ -71,7 +72,7 @@ public MetaNetwork MetaNetwork
/// List of all databases accessible to everyone
/// </summary>
//todo _network.Resource
public List<DatabaseEntity> Databases { get; } = new List<DatabaseEntity>();
public IEnumerable<DatabaseEntity> Databases => MetaNetwork.Resource.List.OfType<DatabaseEntity>();//{ get; } = new List<DatabaseEntity>();

/// <summary>
/// List of all knowledge
Expand All @@ -96,13 +97,14 @@ public IId NextEntityId()
/// <summary>
/// Add a database accessible to everyone
/// </summary>
/// <param name="database"></param>
public void AddDatabase(DatabaseEntity database)
/// <param name="resource"></param>
public void AddResource(IResource resource)
{
if (!Databases.Contains(database))
{
Databases.Add(database);
}
//if (!Databases.Contains(database))
//{
// Databases.Add(database);
//}
MetaNetwork.Resource.List.Add(resource);
}

/// <summary>
Expand All @@ -119,10 +121,6 @@ public void ClearKnowledge()
/// <param name="knowledge"></param>
public void AddKnowledge(IKnowledge knowledge)
{
//if (!Knowledges.Contains(knowledge))
//{
// Knowledges.Add(knowledge);
//}
MetaNetwork.Knowledge.Add(knowledge);
}

Expand All @@ -135,17 +133,12 @@ public void AddKnowledge(IEnumerable<IKnowledge> knowledge)
MetaNetwork.Knowledge.Add(knowledge);
}


/// <summary>
/// Add a task (activity) to the repository of Tasks
/// </summary>
/// <param name="task"></param>
public void AddTask(ITask task)
{
//if (!Knowledges.Contains(knowledge))
//{
// Knowledges.Add(knowledge);
//}
MetaNetwork.Task.Add(task);
}
/// <summary>
Expand All @@ -154,10 +147,6 @@ public void AddTask(ITask task)
/// <param name="tasks"></param>
public void AddTasks(IEnumerable<ITask> tasks)
{
//if (!Knowledges.Contains(knowledge))
//{
// Knowledges.Add(knowledge);
//}
MetaNetwork.Task.Add(tasks);
}

Expand All @@ -166,7 +155,7 @@ public void AddTasks(IEnumerable<ITask> tasks)
/// </summary>
public void Clear()
{
Databases.Clear();
//Databases.Clear();
MetaNetwork.Clear();
EntityIndex = 1;
}
Expand Down
3 changes: 2 additions & 1 deletion SourceCode/Symu/Repository/Entity/DatabaseEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using System;
using Symu.Classes.Agents.Models.CognitiveModels;
using Symu.Common.Interfaces.Entity;
using Symu.DNA.Networks.OneModeNetworks;
using Symu.Messaging.Templates;

#endregion
Expand All @@ -21,7 +22,7 @@ namespace Symu.Repository.Entity
/// <summary>
/// Entity for DataBase class, used to store and search information during the simulation
/// </summary>
public class DatabaseEntity
public class DatabaseEntity : IResource
{
public IId Id { get; }
public DatabaseEntity(IId id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public override void AddOrganizationDatabase()
base.AddOrganizationDatabase();

var wikiEntity = new DatabaseEntity(Organization.AgentId.Id, Organization.Communication.Email);
Organization.AddDatabase(wikiEntity);
Organization.AddResource(wikiEntity);
}

public override void SetAgents()
Expand Down

0 comments on commit ee5e1a8

Please sign in to comment.