As the import of HARA from Excel in Medini only support a part of it natively, is there existing scripts that permits to rebuild function, malfunction, hazard from a script ?
Cool! Glad it worked out. Please mark as "answered".
Happy Scripting
Jan
Hi Florent,
two questions before I post some scripts I have:
Regards
I meanwhile found an older script that imports everything in one step and migrated it to 2020 Rx.
Please find it attached. Note that the script created functions and malfunctions on demand if not found,
but not hazards, they need to exists before to get linked (assuming you always have a list of predefined hazards).
Note further that the script does not validate the S e and C parameter but should.
All in all I think quite a good basis for HARA Excel imports. You of course need the usual suspects (script libraries) in place.
Thanks a lot Jan..Such a file could be placed also on first page with latest scripts available.
Florent, you mean as a ZIP with the libs included? I can do that.
Which "first page" do you actually mean?
Yes we could have a dedicated section for scripts shared by you and potentially other users if they want ... collaborative / open source scripts..
How about adding them to the same page as the script libraries? So here: https://medini.freshdesk.com/a/solutions/articles/1000273630
Yes Jan
Maybe in a different table to not mix official vs. unofficial
Florent
Florent,
attached a version of finderEx.js that has findOrCreateHazard. In addition, the function findOrCreateFunction accepts a third parameter 'id':
function findOrCreateFunction(scope, name, id);
If is preferred over name.
Florent, seem my comment above and ... also see my new sticky article with the posted scripts.
I hesitated to put it to the same solution but started a new article instead,. Hope you like it.
Great, thanks!
In addition I had a last question that I can share also in the forum if you think it can be interesting.
In the original excel sheet from PHA we have identified the relevant operation situation with some id like after import in medini :
RUC_1 is the id of one relevant operation situation. and in the original excel pha I have another sheet where RUC_1 is detailed.
I have created a operation situation catalog in medini importing these detailed operation situation like :
Then I would like to create a script that is going through all HE of my selected HARA, then I could ask to select the right catalog, and then my idea is to go through all situations in the catalog, match the RUC id, and then in the hara selected change the different categories from the one from the catalog.
Is it possible ? ;o)
I think its possible (the images are unfortunately scrambled or lost somehow). There would be also the option to directly import it from Excel (basically from the other sheet).
Hi Jan
Strange for the picture because I can see them.
I would like first to create the new catalog by importing it from Excel.
Then when performing the HARA full import I would like that the user select the right OperatioSituation catalog.
but I tried : var OperationalCatalog = finder.findByType(Metamodel.hazard.OperationalSituation, true).asArray();
then using UI to allow user to select between the one found but nothing..What is wrong.
BR
I just realize that here I try to catch operational situation but then I should request the user to select between different catalog ?
Yes, and a catalog is currently a special HARA - a depth from the past.
That's why I mentioned that its tricky to do it this way.
Anyway, attached a not yet public library for some hara tricks.
See the "Test HARA.js" for usage.
Is it supposed to be working in 2019R2 too because I have an error message directly when I tried to execute your Test HARA file ?
Failed to execute Java Script: Wrapped java.lang.ClassNotFoundException: de.ikv.analyze.metamodel.hazard.HazardAnalysisUtils cannot be found by de.ikv.analyze.metamodel.hazard_1.0.0.201904301113 (E:\MEDINI_WORKSPACE\TEMP 2019R2\HARA_test\config\scripts\.lib\hara.js#19)
Wrapped java.lang.ClassNotFoundException: de.ikv.analyze.metamodel.hazard.HazardAnalysisUtils cannot be found by de.ikv.analyze.metamodel.hazard_1.0.0.201904301113 (E:\MEDINI_WORKSPACE\TEMP 2019R2\HARA_test\config\scripts\.lib\hara.js#19)
Ah. <?WORD FLAGGED?>, no, I think this lib was written with a dedicated version in mind. I have to check.
2019 R2 you say?
Yes. I am in 19R2..Maybe I would investigate another way.
Florent, I recognized that I extended the hara.js a while back without caring too much for older versions.
Simple solution: please remove all lines from #160 onwards + lines 19 and 20 or simply take the attached version which is the older one.
Thanks Jan
but executing Test_hara.js I still have an error
Well, of course the tests for the removed features have to be removed too, here we have an update (downgrade) to the version before.
OK Thanks. In // I did in a different way. When importing the HARA I have a parameter to identify the relevant use case..in the operational situation catalog, I have also a parameter with the same relevant use case..and then when I go through all the hazardous event, I can search for matching operation situation. If found, I modify the attribute for the he of interest with the operation situations.
Thanks for you global help.
Hi,
I'd like to transfer an existing HARA from Excel to Medini. Therfor I've already found this scipt in the forum and adaptet this one to the required layout for the project. Unfortunately the import of the existing hazards in't working, although there might is a solution in the script finderEx integrated. In addition some of the customer added columns like "Function" or "Anmerkung zum Sicherheitsziel" weren't filled either. I attached some screenshots and an example of the Excel HARA. Is there maybe an existing solution to fix this Issue, wich I haven't found yet?
Kind regards
Lukas
Lukas,
I am not sure what exactly is not working, could you be a bit more specific? The original script was made for an older version of medini, however, that part is quite robust so I am rather confident, that nothing has changed that may break it, except some change in 2020 R1 where we changed to domain specific attributes but they are in already.
there is an existing HARA in Excel, wich I would like to Import to Medini. At first I did the Item Definition to link the HARA, without naming Functions. I just named the System as you did in the ESL Example. After that I created an empty HARA Table and modified the columns to the reqiured layout. The next step was the adaption of the Script (to the column order of the empty HARA table) wich I have found here. The adaptetd script is attached. So now I am able to execute the script. If I do so most of the columns were filled, except the columns Hazards, Funktion, Safety Goal, Anmerkungen zum Sicherheitsziel, Safe State. Due to no Functions were created at the Item Definition, the Import script will do this. That is working pretty well as well as the linking of malfunctions to the functions. Unfortunately the function is not filled into the HARA. That is my first issue.
The second problem I have is that I am not sure about how to generate the new hazards from Excel (like it is done with functions) without creating them by hand in Medini. Your Script finderEX has such an option like it is written in the adaption history. But I am not sure how to call this function in the import script. Do have an example how it is done?
Hello Lukas,
I suppose you adjusted the script from the forum article on "Collection of script distributions" ...
If that is the case you will find in that code the following:
var hz = findHazard(finder.scope, hazardName); if (hz) { he.hazard= hz; }
you should change this to
var hz = findOrCreateHazard(finder.scope, hazardName); if (hz) { he.hazard= hz; }
That should automatically look-up the hazards and create them if they do not yet exist.
Concerning the display of Function: Function should be defined as a Derived property for hazardous event and not as a simple String property as your screenshot indicates. You may look this up in the BestPractice Project template of in the ESL Example project.
Best regards,
Eckhardt
Hi Eckhardt,
thank you for your advice. I changed the code but somehow it is not working. An error is occuring wich looks like: Wrapped org,eclipse.core.runtime.OperationCanceledException. I guess there is something wrong with the factory.js script in the lib. Do you have an idea what is wrong?
Sorry for the inconvenience!
That sounds to me that the target project is either write protected (frozen or SVN project without exclusive access?) or if the import script lacks some pragmas.
What do you have in the first line of the import script? Some (many) of the functions in the factory.js only work if the JS engine is configured with some pragmas.
Maybe you can post the error her for clarification.
the first line of the import script looks like the following:
// $EXPERIMENTAL$ $STRICT_MODE$ $WARNING_AS_ERROR$
as it comes with your solution.
Is there any option to check if there is a write protection activated? I have not found anything about it within your help.
I attached a screenshot of the diplayed error.
Sorry for the inconvenience, but it is my first time using Medini.
if you can rename any package or element in the browser, you have no write protection. That would be the easiest check.
The screenshot does not help 100%, please post the exception from the error log (complete).
I hesitate to propose to change the first line before we know the reasons.