Skip to content

Commit

Permalink
Replaced static properties in singleton classes by instance propertie…
Browse files Browse the repository at this point in the history
…s to ensure complete data wipeout whenever DisposeInstance is called.
  • Loading branch information
IvanRibakov committed Jun 7, 2018
1 parent c59da20 commit 2afd810
Show file tree
Hide file tree
Showing 9 changed files with 65 additions and 21 deletions.
2 changes: 1 addition & 1 deletion ExpertModule/Its.ExpertModule/ExpertControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class ExpertControl
/// <summary>
/// The instance domain actions factory.
/// </summary>
private static DomainActionsFactory _instanceDomainActionsFactory;
private DomainActionsFactory _instanceDomainActionsFactory;
/// <summary>
/// The instance student control.
/// </summary>
Expand Down
10 changes: 8 additions & 2 deletions Factories/Its.Factories/DomainActionsFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ public class DomainActionsFactory
/// <summary>
/// The ontology.
/// </summary>
private static OntologyAccess ONTOLOGY;// = OntologyAccess.Instance;
private OntologyAccess ONTOLOGY;// = OntologyAccess.Instance;
/// <summary>
/// The action access.
/// </summary>
private static ActionAccess ACTION_ACCESS; //= ActionAccess.Instance;
private ActionAccess ACTION_ACCESS; //= ActionAccess.Instance;
/// <summary>
/// The DomainActionsFactory singleton instance.
/// </summary>
Expand Down Expand Up @@ -1247,5 +1247,11 @@ private TutorMessage createTutorMsgHelper(string msg)

return tutorMsg;
}

public static void DisposeInstance() {
if (_instance != null) {
_instance = null;
}
}
}
}
8 changes: 7 additions & 1 deletion Factories/Its.Factories/DomainLogFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class DomainLogFactory
/// <summary>
/// The ONTOLOG.
/// </summary>
private static OntologyAccess ONTOLOGY; //= OntologyAccess.Instance;
private OntologyAccess ONTOLOGY; //= OntologyAccess.Instance;
/// <summary>
/// LogFactory singleton instance.
/// </summary>
Expand Down Expand Up @@ -213,5 +213,11 @@ from error in otherErrors
//Returns the DomainLog.
return domainLog;
}

public static void DisposeInstance() {
if (_instance != null) {
_instance = null;
}
}
}
}
2 changes: 1 addition & 1 deletion Factories/Its.Factories/ErrorFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class ErrorFactory
/// <summary>
/// The ontology.
/// </summary>
private static OntologyAccess ONTOLOGY; //= OntologyAccess.Instance;
private OntologyAccess ONTOLOGY; //= OntologyAccess.Instance;
/// <summary>
/// The instance.
/// </summary>
Expand Down
8 changes: 7 additions & 1 deletion Factories/Its.Factories/StudentFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class StudentFactory
/// <summary>
/// The ontology.
/// </summary>
private static OntologyAccess ONTOLOGY;
private OntologyAccess ONTOLOGY;
/// <summary>
/// The instance.
/// </summary>
Expand Down Expand Up @@ -60,6 +60,12 @@ public Dictionary<string, Student> CreateStudents ()
//Returns the list.
return students;
}

public static void DisposeInstance() {
if (_instance != null) {
_instance = null;
}
}
}
}

31 changes: 19 additions & 12 deletions StudentModule/Its.StudentModule.DataAccess/OntologyAccess.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,57 +72,58 @@ public static OntologyAccess Instance (string ontologyPath, string logsPath){
/// <summary>
/// The ontology model in which it will be saved student information.
/// </summary>
private static OntModel _studentDataModel;
private OntModel _studentDataModel;
/// <summary>
/// The ontology model in which it will be worked with domain and action information.
/// </summary>
private static OntModel _domainDataModel;
private OntModel _domainDataModel;
/// <summary>
/// The other data model.
/// </summary>
private static OntModel _otherDataModel;
private OntModel _otherDataModel;
/// <summary>
/// The world data model.
/// </summary>
private static OntModel _worldDataModel;
private OntModel _worldDataModel;
/// <summary>
/// The general ontology model.
/// </summary>
private static OntModel _ontModel;
private OntModel _ontModel;
/// <summary>
/// The student ontology.
/// </summary>
private static Ontology _studentOnto;
private Ontology _studentOnto;
/// <summary>
/// The domain ontology.
/// </summary>
private static Ontology _domainOnto;
private Ontology _domainOnto;
/// <summary>
/// The other ontology.
/// </summary>
private static Ontology _otherOnto;
private Ontology _otherOnto;
/// <summary>
/// The world ontology.
/// </summary>
private static Ontology _worldOnto;
private Ontology _worldOnto;
/// <summary>
/// The ont models.
/// </summary>
private static Dictionary<string, OntModel> _logModels = new Dictionary<string, OntModel>();
private Dictionary<string, OntModel> _logModels;
/// <summary>
/// The ontology path.
/// </summary>
private static string _ontologyPath;
private string _ontologyPath;
/// <summary>
/// The logs path.
/// </summary>
private static string _logsPath;
private string _logsPath;

/// <summary>
/// Initializes a new instance of the <see cref="Its.Student.DataAccess.OntologyAccess"/> class.
/// </summary>
private OntologyAccess (string ontologyPath, string logsPath)
{
_logModels = new Dictionary<string, OntModel>();
//Creates an ontology model empty instance.
_studentDataModel = ModelFactory.createOntologyModel ();
//Creates an ontology model empty instance.
Expand Down Expand Up @@ -2274,5 +2275,11 @@ public void SaveStudentTraceOnto(string domainKey, string studentKey)
bw.close();
}
}

public static void DisposeInstance() {
if (_instance != null) {
_instance = null;
}
}
}
}
4 changes: 2 additions & 2 deletions StudentModule/Its.StudentModule/StudentControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ public class StudentControl
/// <summary>
/// The ontology.
/// </summary>
private static OntologyAccess ONTOLOGY; //= OntologyAccess.Instance;
private OntologyAccess ONTOLOGY; //= OntologyAccess.Instance;
/// <summary>
/// The instance.
/// </summary>
private static StudentControl _instance = null;
/// <summary>
/// The instance domain log factory.
/// </summary>
private static DomainLogFactory _instanceDomainLogFactory;
private DomainLogFactory _instanceDomainLogFactory;
/// <summary>
/// Gets the instance.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
using System;
using System.CodeDom;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Its.ExpertModule;
using Its.ExpertModule.ObjectModel;
using Its.Factories;
using Its.StudentModule;
using Its.StudentModule.DataAccess;
using Its.StudentModule.ObjectModel;
using Its.TutoringModule.CMTutor.SBP;
using Its.TutoringModule.CMTutor.SBP.OM;
Expand Down Expand Up @@ -43,6 +46,8 @@ public string ToString()

public class Util
{
public const double DOUBLE_PRECISION = 0.0001;

public static void GenerateLogs(ITutor tutor, string domainName, string objectName, List<Group> groupConfiguration)
{
Console.OutputEncoding = System.Text.Encoding.UTF8;
Expand Down Expand Up @@ -109,5 +114,19 @@ public static void InitModel(ITutorConfig config, string strDomainName, ClusterM
DomainLog logs = StudentControl.Instance(ontologyPath, logsPath, expertConfPath).GetDomainLogsFromOntology(domain, expert.OtherErrors, world.WorldErrors);
StudentBehaviorPredictorControl.Instance(config).AddModel(logs, cluMet, includeNoPlanActions, inPhases);
}

public static void DestroyModel()
{
DomainLogFactory.DisposeInstance();
DomainActionsFactory.DisposeInstance();
StudentFactory.DisposeInstance();

StudentBehaviorPredictorControl.DisposeInstance();

OntologyAccess.DisposeInstance();
ExpertControl.DisposeInstance();
WorldControl.DisposeInstance();
StudentControl.DisposeInstance();
}
}
}
2 changes: 1 addition & 1 deletion WorldModule/Its.WorldModule/WorldControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class WorldControl
/// <summary>
/// The ONTOLOGY.
/// </summary>
private static OntologyAccess ONTOLOGY; //= OntologyAccess.Instance;
private OntologyAccess ONTOLOGY; //= OntologyAccess.Instance;
/// <summary>
/// The world objects.
/// </summary>
Expand Down

0 comments on commit 2afd810

Please sign in to comment.