Tuesday, July 6, 2021

OIC - Integration properties

Why we need Integration properties and uses:

  • OIC allows us to externalize the properties whose values can be updated without modifying the integration.
  • Developer can define the properties with their default values.
  • Max 10 perperties can be created per integration.
  • These properties values cant be modified inside the integration using any action like assign.
  • This feature is available in both app driven and scheduled orchestration. 
  • You can update the integration properties value from outside of the regular integration design time.
  • To override the integration properties, for scheduled integration - it must be in active state and for app driven - it must be in draft or configured state.
  • Integration properties are user defined properties available for usage by activities like Notification, Log etc. as read only data.

Use case
: we will create 2 intergration properties To and From to use them to notify email in a app driven orchestration.


Steps:

Step1: Create an app driven integrarion and drag and drop a rest trigger connection and set response as below:

{

"status": "messgae sent"

}

Step2: Click on the rest trigger and click on more actions and click on edit integration properties.

Add the parametes From and To and set their default values.

Close

Step3: Drag and drop Notification from action and assign these 2 paramaters From and To and provide some default value to subject and body.

Step4: Save and add a tracking like rest method etc.

Save and it will be now in configure state.

Step5: Go to the integration actions and click on update property values. Click on respective parameter and update with new value if needed. And submit it.

Step6: Activate and test.


OIC - Replace existing connection with the new connection in OIC integration

Why do we need this?

  • This new update allows us to replace any existing connection used in an integration with another connection of same Type and Role. In earlier version, first we need to delete the exisitng connection used in the integration amd then create  a new connecrion for that. So lot of changes needed in the downstream flow or integrations.
  • Sometimes we may need to change the connection name used in an integration.

In simple, it saves a lot time and reduces rework.


Steps to follow:

Step1: Deactivate the integration.

Step2: Click on the actions(hamburger sign) and then click Configure.

Step3: Select the connection which you want to replace and click the replace button to select the new connection of the same type and role. For instance suppose your connection type is rest and role is trigger so you have to choose same rest type and role for the new connection. 

Step4: Done and click save and close.

Step5: Activate your integration ans check from open details if the new connection is showing and then test.

Note: Suppose all your integrations are in a package then whole package components will be showing in the actions --configure step and you can change the connection used for the entire package too.

Monday, July 5, 2021

Django - Introduction & Install django and PyCharm CE

 Introduction:

"Django is a high-level Python web framework that enables rapid development of secure and maintainable websites. Built by experienced developers, Django takes care of much of the hassle of web development, so you can focus on writing your app without needing to reinvent the wheel. It is free and open source, has a thriving and active community, great documentation, and many options for free and paid-for support. "

Where did it come from?

"Django was initially developed between 2003 and 2005 by a web team who were responsible for creating and maintaining newspaper websites. After creating a number of sites, the team began to factor out and reuse lots of common code and design patterns. This common code evolved into a generic web development framework, which was open-sourced as the "Django" project in July 2005. "


Django MVT

The MVT (Model View Template) is a software design pattern. It is a collection of three important components Model View and Template. 

  • The Model helps to handle database. It is a data access layer which handles the data.
  • The Template is a presentation layer which handles User Interface part completely.
  •  The View is used to execute the business logic and interact with a model to carry data and renders a template.


Here, a user requests for a resource to the Django, Django works as a controller and check to the available resource in URL. If URL maps, a view is called that interact with model and template, it renders a template. Django responds back to the user and sends a template as a response.


Install Django:

go to the windows power shell and run the following cmd:

pip install django

Check installed django version:

python -m django --version

3.2.5

Check python version:

python --version

Python 3.9.5

Install PyCharm CE:

go to the browser and search with PyCharm download and go to the 1st one Jetbrains.com download PyCharm community edition. It will download around 366MB space.





OIC - Global variable and Data Stitch action

Global variables are the variables which will be available throughout the integration. The variable can be any types as mentioned:

  • String
  • Boolean
  • Date
  • DateTime
  • Object
  • Number
Data Stitch allows us to create assignments to complex types variables.

Where we need this?
Suppose we have a scope or if block from where we need to take some response to the outside of the block or scope, in simple we cant achieve it. In this regards, we need to implement global variable and data stitch concepts.

Implementation steps:

Here, we will use rest trigger to post file name and file path and read the csv file from remote directory in a scope and map to the rest response.

Step1: Create an app driven integration and drag and drop a rest trigger and provide a name and verb as POST and select the following

Configure a request payload for this endpoint
Configure this endpoint to receive the response

Next
Provide request Json sample:
{
"fileName": "emp.csv",
"filePath": "inbound/poc"
}

Next
Provide response json sample:
{
"empName" : "asd",
"EmpId": "123"
}

Step2: Take a scope for read file
Drag and drop file ftp connection and map the file name and file path.

Step3: Global variable creation:
Now go to (x) variable section and add variable. Provide variable name and select object in this case. Now choose the ftp response part  as type.





Step4: Data stitch:
After the read file part, drag and drop data stitch action and choose the global just created and operation as assign and choose value as the response of the ftp read .










Step5: Now after the scope, map the response of the global variable to the response of the rest.






Sunday, July 4, 2021

PowerShell - Solution to “Running Scripts Is Disabled On This System” Error On Powershell

 While I was trying to create a virtual environment in VS code with PS, I got below error:


Error:

.\env1\Scripts\activate.ps1 : File C:\Users\abc\Desktop\python\script\inheritance\env1\Scripts\activate.ps1 cannot be loaded because 

running scripts is disabled on this system. For more information, see about_Execution_Policies at http://go.microsoft.com/fwlink/?LinkID=135170.

At line:1 char:1

+ .\env1\Scripts\activate.ps1

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : SecurityError: (:) [], PSSecurityException

    + FullyQualifiedErrorId : UnauthorizedAccess


Solution:

Step1 : Open windows in powershell as admin.

Open the Start menu on Windows and search for powershell and right-click on it. Click on “run as administrator”.

Step2: run below command:

set-executionpolicy remotesigned

Step3: You will be prompted to run accept the change, type Y(Yes) and press enter on your keyboard to allow the change.

Step4: When you are done, you can set the policy back to its default value with:

Set-ExecutionPolicy Restricted



Saturday, July 3, 2021

Python - Virtual env, pip freeze, Lambda function, join method, format method and map, filter, reduce

 Virtual Env:

An environment which is same as the system interpreter but is isolated from the other python environments on the system.

Installation:

to use virtual environment:

    pip install virtualenv

to create:

    virtualenv myprojectenv

to activate:

    activate

pip freeze:

It returns all the packages installed in a given env along with the versions.

    pip freeze > list.txt

we can share the this file to other user and they can recreate the same env using:

    pip install -r list.txt

Lambda function:

syntax:

    lambda arguments: expressions

instance:

    square = lambda a : a * a

    square(2) 

Join method:

It creates a string from iterable objects.

l=["apple","mango","banana"]

" and ".join(l)

output: "apple and mango and banana"

format method:

formats the values inside a string into a desired output.

template.format(arguments)

example:

"{} is a good {}".format("john","boy")

or

"{1} is a good {0}".format("boy","john")

output: john is a good boy

Map, filter and reduce:

Map:

map applies a function to all the items in a input list.

map(function,list)

Filter:

It creates a list of items for which the function returns true.

list(filter(function,list))

Reduce:

It applies a rolling computation to sequential pair of elements.

from functools import reduce

val=reduce(function, list)

if the function computes the sum of two numbers and the list is [1,2,3,4], the output will be 10.


Practice:

Create two virtual environments , install few packages in the first one. create a similar env in the 2nd one.

pip install virtualenv

virtualenv env1

virtualenv env2

.\env1\Scripts\activate.ps1

pip install pandas

pip freeze > 2.txt

deactivate

 .\env2\Scripts\activate.ps1

pip install -r .\2.txt

deactivate

WAP to input name, marks and phone numbers of a student and format it using the format function like "The name of the student is Sri and his marks are 65 and phone number is 0000000000.

nameinput("Please enter your name: ")
marksinput("Please enter your marks: ")
phoneinput("Please enter phone number: ")
template="the name of the Stdent is {} and his marks are {} and his phone number is {}."
print(template.format(name,marks,phone))


a list contains the multiplication table of 7. WAP to convert to a vertical string of the same numbers.

num = int(input("Enter a number: "))
table = [str(num * ifor i in range(1,11)]
print(table)
vertical="\n".join(table)
print(vertical)

WAP to filter a list of numbers which are divisible by 5.

myList=[1,2,4,6,7,8,9,123,54,67,90,45,5,56,50]

newList=filter(lambda a:a % 5 ==0,myList)

print(list(newList))

WAP to find the max of the numbers in a list using reduce function.

from functools import reduce
numberList=[1,2,4,6,7,8,9,123,54,67,90,45,5,56,50]

maxnumber=reduce(max,numberList)

print(maxnumber)







Thursday, July 1, 2021

Python - Exception handling

There are many built in exceptions which are raised in python when something goes wrong. Exceptions in python can be handled using a try statement. The code that handles the exception is written in the except clause.

try:

    #code

except Exception as e:

    print(e)

when the exception is handled the code flow continues without program interruption.

try:

    #code

except ZeroDivisionError:

    #code

except TypeError:

    #code

except:

    #code

Raising Exceptions:

We can raise custom exceptions using the raise keuword.

try with else clause:

sometimes we want to run a piece of code when try was successful.

try:

    #code

except:

    #code

else:

    #code

try with finally:

python offers a finally clause which ensures execution of a piece of code irrespective of the exception.

try:

    #code

except:

    #code

finally:

#code

if __name__ = '__main__':

__name__ evaluates to the name of the module in python from where the program is run. if the module is being run directly from the cmd line the __name__ is set to string "__main__".

thus this behaviour is used to check if the module is run directly or imported to another file.

Global keyword:

global keyword is used to modify the variable outside of the current scope.

enumerate function:

It adds counter to an iterable and returns it.

for i,item in enumerate(list1):

    print(i,item)

list comprehensions:

It is an elegant way to create lists based on existing lists.

list1=[1,7,12,11,22]

list2=[i for item in list1 if item >8]


Practice:

Write a program to open 3 files 1.txt,2.txt and 3.txt.if any one of the files do not present then a message without exiting the program must be printed prompting the same.

def readFile(fileName):
    try:    
        with open(fileName,'r'as f:
            print(f.read())
    except:
        print(f"the file {fileName} does not exist")


readFile("1.txt")
readFile("2.txt")
readFile("3.txt")       


WAP to print 3rd,5th and 7th element from a list using enumerate function.

myList=[1,2,3,4,5,6,7,8,8,9,10]

for i,item in enumerate(myList):
    if i==2 or i==4 or i==6:
        print(f"the {i+1} element is {item}")


Write a list comprehension to print a list which contains the multiplication table of a user entered number.


numint(input("Please enter a number: "))

table = [num*i for i in range(1,11) ]
print(table)

WAP to display a/b  where a and b are integers. if b=0, display infinite by handling the ZeroDivisionError.

aint(input("Please enter 1st number: "))
bint(input("Please enter 2nd number: "))

try:
    print(a/b)
except ZeroDivisionError:
    print("Infinite")
except Exception as e:
    print(e)
finally:
    print("Thanks!")



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...