Sunday, October 27, 2024

OIC - "How to Modify an OIC .iar File from the Backend"

Usecase:

In many projects, we often face last-minute requirements to rename database assets or variables to comply with specific customer naming standards. Renaming everything through the front end can be challenging, especially when it results in invalid mappings that require a complete rebuild from scratch. Recently, we encountered similar situations where we needed to adjust several variable names and update the database schema name to meet customer standards.

To address this, we decided to create a script using Groovy (though this could be done in any language) to review each file in the .iar and apply the necessary changes. Before beginning this bulk update, please ensure you have backed up the current code, as there is a risk of the .iar file becoming corrupted during the process.


Solution steps:

Step1: You must first export the iar file from your OIC instance in order to start the procedure. Then rename the extension from iar to zip. Now you should open the zip file using 7zip.

Step2:

I wrote a simple Groovy script that searches for a specified string across the entire icspackage folder and replaces it with a new string. The script goes through each file, finds the target string, and replaces it. For example, I searched for the variable name localVar_before_demo, which appeared in four files (logged for reference), and replaced it with localVar_after_demo. To use this for other variables or package names, simply update the script and run it.

Groovry script used:

def dir = new File("C:/Users/Work/Software/DEMO/icspackage")


println "=============================START================================"


dir.eachFileRecurse (groovy.io.FileType.FILES) { file ->

    def fileText = file.text

    def first = fileText.indexOf("localVar_before_demo")

    if (first != -1) {

        def searchString = "localVar_before_demo"

        def replaceString = "localVar_after_demo"


        fileText = fileText.replace(searchString, replaceString)

        file.write(fileText)

        println "Change File ==> " + file.path

    }

}


println "=============================END=================================="





No comments:

Post a Comment

Featured Post

11g to 12c OSB projects migration points

1. Export 11g OSB code and import in 12c Jdeveloper. Steps to import OSB project in Jdeveloper:   File⇾Import⇾Service Bus Resources⇾ Se...