ODI selective Reverse Engineering through groovy script - groovy

I try to use ODI-SDK with groovy scripting to automate selective reverse-engineering datastores to model. To do this, i used following script doStandardReverse() method, but getting error. I am trying to execute below script.
I have used API mentioned in below documentation
https://docs.oracle.com/middleware/12211/odi/reference-java-api/oracle/odi/core/service/reverse/ReverseService.html
import oracle.odi.domain.project.finder.IOdiProjectFinder
import oracle.odi.domain.model.finder.IOdiDataStoreFinder
import oracle.odi.domain.model.finder.IOdiModelFinder
import oracle.odi.domain.model.OdiModel
import oracle.odi.domain.model.OdiModelFolder
import oracle.odi.domain.model.OdiModel.ReverseObjectType
import oracle.odi.domain.project.finder.IOdiFolderFinder
import oracle.odi.domain.project.finder.IOdiUserProcedureFinder
import oracle.odi.domain.project.finder.IOdiKMFinder
import oracle.odi.domain.mapping.finder.IMappingFinder
import oracle.odi.domain.adapter.project.IKnowledgeModule.ProcessingType
import oracle.odi.domain.topology.finder.IOdiContextFinder
import oracle.odi.domain.topology.finder.IOdiLogicalSchemaFinder
import oracle.odi.domain.topology.finder.IOdiTechnologyFinder
import oracle.odi.domain.topology.OdiContext
import oracle.odi.domain.topology.OdiTechnology
import oracle.odi.domain.topology.OdiLogicalSchema
import oracle.odi.domain.model.OdiDataStore
import oracle.odi.domain.xrefs.expression.Expression
import oracle.odi.domain.xrefs.expression.Expression.SqlGroupType
import oracle.odi.domain.project.OdiProcedureLine.LogCounter
import oracle.odi.domain.project.OdiProcedureLineCmd
import oracle.odi.domain.project.OdiUserProcedure
import oracle.odi.domain.project.OdiUserProcedureLine
import oracle.odi.domain.project.OdiPackage
import oracle.odi.core.persistence.transaction.support.DefaultTransactionDefinition
import oracle.odi.core.service.reverse.ReverseService
import oracle.odi.domain.project.StepModel.ReverseModel
txnDef = new DefaultTransactionDefinition()
tm = odiInstance.getTransactionManager()
tme = odiInstance.getTransactionalEntityManager()
txnStatus = tm.getTransaction(txnDef)
def myList = ["SNP_CHECK_TAB","SRC_CITY"]
OdiModel srcModel = ((IOdiModelFinder)tme.getFinder(OdiModel.class)).findByCode("TEST_MOD");
//call reverse engeneering
rs = new ReverseService();
rm = rs.doStandardReverse(odiInstance, srcModel.getModelId(), ReverseService.DataStoreSelection.SELECTED, myList);
println('Data Store/s created.');
tm.commit(txnStatus)
I am getting error below
java.lang.String cannot be cast to oracle.odi.core.service.reverse.OdiDataStoreNameAndType
(Subtract 18 from the error line number to account for the standard imports)
java.lang.ClassCastException: java.lang.String cannot be cast to oracle.odi.core.service.reverse.OdiDataStoreNameAndType
at oracle.odi.core.service.reverse.ReverseService.convertDataStoreListToSnpsStringPair(ReverseService.java:452)
at oracle.odi.core.service.reverse.ReverseService.doStandardReverse(ReverseService.java:169)
at oracle.odi.core.service.reverse.ReverseService$doStandardReverse.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:149)
at di.run(di.groovy:61)
at groovy.lang.GroovyShell.runScriptOrMainOrTestOrRunnable(GroovyShell.java:263)
at groovy.lang.GroovyShell.run(GroovyShell.java:518)
at groovy.lang.GroovyShell.run(GroovyShell.java:497)
at groovy.lang.GroovyShell.run(GroovyShell.java:170)
at oracle.di.studio.groovy.GroovyScriptRunInstance.run(GroovyScriptRunInstance.java:222)
Script exited.

Your list contains Strings where it should contain OdiDataStore objects.
findByName method of interface IOdiDataStoreFinder can be used to find a specific OdiDataStore object.

Related

module 'subprocess' has no attribute '_subprocess'

I used python3.7 in windows7.
When I tried to run this line: suinfo.dwFlags |= subprocess._subprocess.STARTF_USESHOWWINDOW
error occurs: module 'subprocess' has no attribute '_subprocess'
import os
import sqlite3
import subprocess
import time
import re
from django.core.mail import send_mail
from django.http import HttpResponse
suinfo = subprocess.STARTUPINFO()
suinfo.dwFlags |= subprocess._subprocess.STARTF_USESHOWWINDOW
How to deal with that?
There is no such thing as subprocess._subprocess, the constant is straight under subprocess:
suinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
See the docs: https://docs.python.org/3/library/subprocess.html#subprocess.STARTF_USESHOWWINDOW

ModuleNotFoundError using items.py

Trying to implement an Item Loader.
my class name in items.py:
SiemensLinkcontentItem
my import statements inside my spider:
import scrapy
from scrapy.loader import ItemLoader
from siemens_linkcontent.siemens_linkcontent.items import SiemensLinkcontentItem
I get the following error:
No module named 'siemens_linkcontent.siemens_linkcontent'
My path diagramm is the following:
Use This One
- from siemens_linkcontent.items import SiemensLinkcontentItem

Import sequences in Python 3.7

I want to organize a package with this structure:
/program.py
/__init__.py
/data/
/data/__init__.py
/data/method_1.py
/data/method_2.py
/data/classes.py
program imports method_1 and method_2, method_1 and method_2 import classes. But I get an error: ModuleNotFoundError: No module named 'method_1'. How should I organize this package and what should I write in init.py files?
program.py:
import __init__
from data import classes
from data import method_1
from data import method_2
...
__init__.py:
__all__ = ['data']
from data import *
/data/__init__.py:
__all__ = ['classes', 'method_1', 'method_2']
from method_1 import *
from method_2 import *
from classes import *
/data/method_1.py: (and also /data/method_2.py)
import classes
...
method_1, method_2, and classes are all in the data package, hence:
# data/__init__.py
from .method_1 import *
from .method_2 import *
from .classes import *
...
# data/method_1.py
from . import classes
Because the data package is in the same directory with program this should work:
#program.py
from .data import classes
from .data import method_1
from .data import method_2
# data/__init__.py
from .method_1 import *
from .method_2 import *
from .classes import *
#data/method_1.py
from . import classes
#data/method_2.py
from . import classes

Using NASDAQ API, can't use decode on urlopen

I'm trying to use the NASDAQ API from https://github.com/Nasdaq/DataOnDemand but cannot seem to get it to work in Python 3.
I fixed the urllib stuff and first got an error at line 92 which I fixed by encoding it to utf-8
Before:
request_parameters = urllib.parse.urlencode(values)
Fix:
request_parameters = urllib.parse.urlencode(values).encode('utf-8')
But now i get an error on:
response = urllib.request.urlopen(req)
>>>TypeError: cannot use a string pattern on a bytes-like object
When i try to fix it by decoding i get:
response = urllib.request.urlopen(req).decode()
OR
response = urllib.request.urlopen(req).decode('utf-8')
>>>AttributeError: 'HTTPResponse' object has no attribute 'decode'
This is what my imports look like:
import urllib.request
import urllib.parse
import xml.etree.cElementTree as ElementTree
import re
from pprint import pprint
import matplotlib.dates as mdates
import matplotlib.pyplot as plt
import datetime as dt
Any help is appreciated

Error while reading Excel file in SOAPUI using Groovy

I am trying to read an Excel file, inside SOAPUi (Free version) using Groovy.
Code :
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.xssf.usermodel.*;
import org.apache.poi.ss.util.*;
import org.apache.poi.ss.usermodel.*;
import java.io.*;
def path = "D:\\Automation\\Testdata\\testdata.xlsx"
def inputStream = new FileInputStream(path)
def wb=new XSSFWorkbook(inputStream)
def workSheet=wb.getSheet("sheet1")
def rows=workSheet.getPhysicalNumberOfRows()
long.info rows
Error :
java.lang.reflect.invocationtargetexception
I am new to SOAPUI and Groovy, but I have a decent knowledge on java. Couldnt find a proper solution for this.

Resources