1818import org .lara .interpreter .weaver .options .WeaverOption ;
1919import org .suikasoft .jOptions .Datakey .DataKey ;
2020import org .suikasoft .jOptions .Interfaces .DataStore ;
21- import org .suikasoft .jOptions .JOptionsUtils ;
2221import pt .up .fe .specs .util .SpecsIo ;
23- import pt .up .fe .specs .util .SpecsLogs ;
2422import java .io .File ;
2523import java .util .*;
2624
3432public class LaraIDataStore implements LaraiKeys {
3533
3634 public static final String CONFIG_FILE_NAME = "larai.properties" ;
37- private static final String SYSTEM_OPTIONS_FILENAME = "system_options.xml" ;
3835
3936 public static String getConfigFileName () {
4037 return CONFIG_FILE_NAME ;
4138 }
4239
43- public static String getSystemOptionsFilename () {
44- return SYSTEM_OPTIONS_FILENAME ;
45- }
46-
4740 private final DataStore dataStore ;
4841
4942 public LaraIDataStore (LaraI lara , DataStore dataStore , WeaverEngine weaverEngine ) {
5043
51- // Merge system-wise options with local options
52-
53- // this.dataStore = dataStore;
54- this .dataStore = mergeSystemAndLocalOptions (weaverEngine , dataStore );
44+ this .dataStore = dataStore ;
5545
5646 for (WeaverOption option : weaverEngine .getOptions ()) {
5747 DataKey <?> key = option .dataKey ();
@@ -61,59 +51,6 @@ public LaraIDataStore(LaraI lara, DataStore dataStore, WeaverEngine weaverEngine
6151 setLaraProperties ();
6252 }
6353
64- private DataStore mergeSystemAndLocalOptions (WeaverEngine weaverEngine , DataStore localArgs ) {
65- var systemOptionsFilename = weaverEngine .getName () + "_" + getSystemOptionsFilename ();
66-
67- var storeDef = localArgs .getStoreDefinitionTry ().orElse (null );
68-
69- if (storeDef == null ) {
70- SpecsLogs .debug (() -> "Local data store does not have a store definition, system-wide options in file '"
71- + systemOptionsFilename + "' not supported" );
72- return localArgs ;
73- }
74-
75- var persistence = localArgs .getPersistence ().orElse (null );
76-
77- if (persistence == null ) {
78- SpecsLogs .debug (
79- () -> "Local data store does not have an instance of AppPersistence set, system-wide options in file '"
80- + systemOptionsFilename + "' not supported" );
81- return localArgs ;
82- }
83-
84- DataStore defaultOptions = JOptionsUtils .loadDataStore (systemOptionsFilename , getClass (),
85- storeDef , persistence );
86-
87- defaultOptions .getConfigFile ().ifPresent (defaultOptionsFile -> SpecsLogs
88- .debug ("Loading default options in file '" + defaultOptionsFile .getAbsolutePath () + "'" ));
89-
90- SpecsLogs .debug (() -> "Loading system-wide options" );
91- SpecsLogs .debug (() -> "Original options: " + localArgs );
92-
93- // Merge default values in localArgs
94- var localArgsKeys = localArgs .getKeysWithValues ();
95-
96- for (var key : defaultOptions .getKeysWithValues ()) {
97-
98- // Only set if no value is set yet
99- if (localArgsKeys .contains (key )) {
100- continue ;
101- }
102-
103- // And if key is part of the store definition
104- if (!storeDef .hasKey (key )) {
105- continue ;
106- }
107-
108- localArgs .setRaw (key , defaultOptions .get (key ));
109- }
110-
111- SpecsLogs .debug (() -> "Merged options : " + localArgs );
112-
113- // return mergedOptions;
114- return localArgs ;
115- }
116-
11754 /**
11855 * Set an option on lara according to the value given, if the option exists on
11956 * the enum {@link Argument}
0 commit comments