22
33import cz .zcu .fav .kiv .antipatterndetectionapp .detecting .detectors .AntiPatternDetector ;
44import cz .zcu .fav .kiv .antipatterndetectionapp .model .AntiPattern ;
5+ import cz .zcu .fav .kiv .antipatterndetectionapp .model .CacheablesValues ;
6+ import cz .zcu .fav .kiv .antipatterndetectionapp .model .QueryResult ;
57import cz .zcu .fav .kiv .antipatterndetectionapp .repository .AntiPatternRepository ;
68import org .springframework .beans .factory .annotation .Autowired ;
79import org .springframework .stereotype .Service ;
@@ -17,6 +19,9 @@ public class AntiPatternServiceImpl implements AntiPatternService {
1719 @ Autowired
1820 private AntiPatternRepository antiPatternRepository ;
1921
22+ // class that stores cached values
23+ private CacheablesValues cacheablesValues = new CacheablesValues ();
24+
2025 @ Override
2126 public List <AntiPatternDetector > getAllAntiPatterns () {
2227 return antiPatternRepository .getAllAntiPatterns ();
@@ -66,19 +71,22 @@ public boolean saveNewConfiguration(String[] configNames, String[] configValues)
6671 if (antiPatternDetector .getAntiPatternModel ().getConfigurations ().get (configNames [i ]).getValue ().getClass () == Integer .class ) {
6772 try {
6873 antiPatternDetector .getAntiPatternModel ().getConfigurations ().get (configNames [i ]).setValue ((Integer .parseInt (configValues [i ])));
74+ setConfigurationChanged (true );
6975 } catch (NumberFormatException e ) {
7076 return false ;
7177 }
7278
7379 } else if (antiPatternDetector .getAntiPatternModel ().getConfigurations ().get (configNames [i ]).getValue ().getClass () == Float .class ) {
7480 try {
7581 antiPatternDetector .getAntiPatternModel ().getConfigurations ().get (configNames [i ]).setValue ((Float .parseFloat (configValues [i ])));
82+ setConfigurationChanged (true );
7683 } catch (NumberFormatException e ) {
7784 return false ;
7885 }
7986 } else if (antiPatternDetector .getAntiPatternModel ().getConfigurations ().get (configNames [i ]).getValue ().getClass () == Double .class ) {
8087 try {
8188 antiPatternDetector .getAntiPatternModel ().getConfigurations ().get (configNames [i ]).setValue ((Double .parseDouble (configValues [i ])));
89+ setConfigurationChanged (true );
8290 } catch (NumberFormatException e ) {
8391 return false ;
8492 }
@@ -88,4 +96,40 @@ public boolean saveNewConfiguration(String[] configNames, String[] configValues)
8896 }
8997 return true ;
9098 }
99+
100+ @ Override
101+ public void saveAnalyzedProjects (String [] selectedProjects , String [] selectedAntiPatterns ) {
102+ this .cacheablesValues .setAnalyzedProjects (selectedProjects );
103+ this .cacheablesValues .setAnalyzedAntiPatterns (selectedAntiPatterns );
104+ }
105+
106+ @ Override
107+ public String [] getAnalyzedProjects () {
108+ return this .cacheablesValues .getAnalyzedProjects ();
109+ }
110+
111+ @ Override
112+ public String [] getAnalyzedAntiPatterns () {
113+ return this .cacheablesValues .getAnalyzedAntiPatterns ();
114+ }
115+
116+ @ Override
117+ public void setConfigurationChanged (boolean configurationChanged ) {
118+ this .cacheablesValues .setConfigurationChanged (configurationChanged );
119+ }
120+
121+ @ Override
122+ public boolean isConfigurationChanged () {
123+ return this .cacheablesValues .isConfigurationChanged ();
124+ }
125+
126+ @ Override
127+ public void saveResults (List <QueryResult > results ) {
128+ this .cacheablesValues .setResults (results );
129+ }
130+
131+ @ Override
132+ public List <QueryResult > getResults () {
133+ return this .cacheablesValues .getResults ();
134+ }
91135}
0 commit comments