Persistency rule does not work anymore

Lately i moved from Oh 2.5.12 to Oh3.4.2
In oh2 I had a rule dicovering if my heat radiators were on while the window has been opened. If yes, i storred necessery thermostat settings and brought them back when the window was closed again.

this is the Oh2 rule:

import java.util.Map
var int TempVarOffice = 0
var Map ThermostatOfficePresistency

rule "Action on Window open in Office"

when
    Item BS_Office_Window changed
    
then
    // If Window is open and Theremostat is NOT OFF. If Thermostat is OFF no influence on it while window is open
       
    if ((BS_Office_Window.state == OPEN) && (BS_Office_Thermostat_Mode.state != 0)) {
        TempVarOffice = 1                                     // remember previous window status. Is open
        ThermostatOfficePresistency = storeStates(BS_Office_Thermostat_Valve, BS_Office_Thermostat_Temp, BS_Office_Thermostat_Mode, BS_Office_Thermostat_SetpointHeat, BS_Office_Thermostat_SetpointEHeat)
        logInfo("Thermostat Office:", "Thermostat Settings stored: " + ThermostatOfficePresistency )
        BS_Office_Thermostat_Mode.sendCommand (0)       // Close thermostat in the office
    }

    // If window is closed and previously was opened.
    if ((BS_Office_Window.state == CLOSED) && (TempVarOffice == 1)) {  

        restoreStates(ThermostatOfficePresistency)
        logInfo("Thermostat Office:", "Check Thermostat Mode after restore" )
        TempVarOffice = 0
    }
    
end

the rule has been working.
With hte OH3 (new items new names) i receive an error when the rule is launched.

2023-03-27 09:07:33.998 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Office_FIBARO_Window_Sensor_Door' changed from CLOSED to OPEN
==> /var/log/openhab/openhab.log <==
2023-03-27 09:07:34.597 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'thermostatOfficePersistancy' failed:  ___ import  ___ java.util.Map
var int TempVarOffice = 0
var Map ThermostatOfficePresistency
  
if ((Office_FIBARO_Window_Sensor_Door.state == OPEN) && (Office_Thermostatic_Valve_Thermostat_mode.state != 0)) {
   TempVarOffice = 1                                     // remember previous window status. Is open
   ThermostatOfficePresistency = storeStates(Office_Thermostatic_Valve_Setpoint_energy_heat, Office_Thermostatic_Valve_Thermostat_mode, Office_Thermostatic_Valve_Setpoint_heat)
   logInfo("Thermostat Office:", "Thermostat Settings stored: " + ThermostatOfficePresistency )
   Office_Thermostatic_Valve_Thermostat_mode.sendCommand (0)       // Close thermostat in the office
}
// If window is closed and previously was opened.
if ((Office_FIBARO_Window_Sensor_Door.state == CLOSED) && (TempVarOffice == 1)) {  
restoreStates(ThermostatOfficePresistency)
logInfo("Thermostat Office:", "Check Thermostat Mode after restore" )
TempVarOffice = 0
}
   1. Map cannot be resolved to a type.; line 3, column 51, length 3
   2. The method or field import is undefined; line 1, column 0, length 6
   3. This expression is not allowed in this context, since it doesn't cause any side effects.; line 1, column 7, length 13

How can I implement the rule with persistency feature in OH3?

changing the variable definition does not help :frowning:

var Map <String, Number> ThermostatOfficePresistency = createHashMap
   1. Map cannot be resolved to a type.; line 3, column 51, length 3
   2. The method or field import is undefined; line 1, column 0, length 6
   3. This expression is not allowed in this context, since it doesn't cause any side effects.; line 1, column 7, length 13

The problem was already at the first line:

import java.util.Map

Instead of making a rule under UI i made a file.rules and saved it under \\oh3\openHAB-conf\rules
It works now.