groovy script - create Hashmap as global variable [message #1750930] |
Mon, 02 January 2017 11:50 |
fabrizio maggioni Messages: 3 Registered: January 2017 |
Junior Member |
|
|
Hello Support,
I am working on this function's script:
def synchronized createUcmdbCache () {
try {
Map<String, Map<String,String>> localHM = new HashMap()
String line
// leggo dal ucmdb cache file
FileReader fr = new FileReader(ucmdbCacheDumpFile)
s_log.trace("Process > >> createUcmdbCache > FileReader > OK Reader");
BufferedReader textReader = new BufferedReader(fr)
s_log.trace("Process > >> createUcmdbCache > BufferedReader > OK Buffered");
// creazione della hashmap annidata
while((line = textReader.readLine()) != null) {
String[] parts = line.split("~")
// parts[0]=relatedCI
// parts[1]=File System Type
// parts[2]=Admin group
if (localHM.containsKey(parts[0])) {
// tempHM = mappa più interna che contiene FileSystemTipe,AdminGroup
Map<String,String> tempHM = localHM.get(parts[0])
tempHM.put(parts[1], parts[2])
localHM.put(parts[0], tempHM)
s_log.trace("Process > >> createUcmdbCache > localHasMap > set TEMP e LOCAL HM");
}
else {
Map<String,String> tempHM = new HashMap()
tempHM.put(parts[1], parts[2])
// aggiunta alla hashmap più esterna di RelatedCI,(tempHM) dove tempHM=FileSystemTipe,AdminGroup
localHM.put(parts[0], tempHM)
s_log.trace("Process > >> createUcmdbCache > localHasMap > ELSE set TEMP e LOCAL HM");
}
}
textReader.close()
// set variabile globale ucmdbCache con il valore della hashmap localHM
ucmdbCache = Collections.synchronizedMap(localHM)
s_log.trace("Process > >> createUcmdbCache > localHasMap > AFTER Text Reader Close:" + localHM.getValue() + tempHM.getValue() + ucmdbCache.getValue() + e.getMessage() + myFsName + relCiID);
} catch (IOException e) {
}
}[/i]
where "ucmdbCacheDumpFile" is defined as public string on top of the script:
[i]public static final String ucmdbCacheDumpFile = "F:\\HPBSM\\Temp\\ENI-HandleIncomingEventsAR-ExtUcmdbCache.dump";[/i]
in order to pass "ucmdbCache" variable as global value to another function's script in this way:
[i]String adminGrp = ucmdbCache.get(relCiID).get(myFsName)[/i]
But i got this error:
Reason: No signature of method: java.util.HashMap.getValue() is applicable for argument types: () values: []
Please do you have any suggestion about it? It seems localHM hasmap has been not set correctly.
Thanks.
Regards,
Fabrizio
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04470 seconds