ode-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michele <iann...@gmail.com>
Subject Re: How create a BpelCompiler20
Date Wed, 20 Jan 2010 14:35:00 GMT
ok thanks, but I need to use these two functions from the class
"AssignGenerator"
private OAssign.RValue compileFrom(From from)
private OAssign.LValue compileTo(To to)


Can I use them on the object compiled   m_bpelCompiledProcess

m_bpelCompiledProcess =
bpelCompiler.compile(m_bpelProcessBOM,bpelResourceFinder);

?

My goal is to investigate on the "copy" in a BPEL file.
This is the code I wrote, I know is not correct because i didn't set the
BPEL process anywhere so it give me the error:

" [UndeclaredVariable]Attempt to reference undeclared variable "Search"  "

private void AnalyzeCopy(Copy cp){
    try{

            _context = new BpelCompiler20();
            Copy scopy = cp;
                    OAssign.Copy ocopy = new
OAssign.Copy(_context.getOProcess());
                    ocopy.keepSrcElementName = scopy.isKeepSrcElement();
                    try {
                        if (scopy.getFrom() == null){
                            System.out.println("Error: getFrom() == null");

                        }
                        ocopy.from = compileFrom(scopy.getFrom());
                        if (scopy.getTo() == null){
                            System.out.println("Error: getTo() == null");

                        }
                        //ocopy.to = compileTo(scopy.getTo());

                    } catch (CompilationException ce) {
                        _context.recoveredFromError(scopy, ce);
                    }

        }catch(Exception e){

        }
    }




    private OAssign.RValue compileFrom(From from) {
        assert from != null;
        try {
            if (from.isVariableVal()) {
                VariableVal vv = from.getAsVariableVal();
                OAssign.VariableRef vref = new
OAssign.VariableRef(_context.getOProcess());
                vref.variable = _context.resolveVariable(vv.getVariable());

                if (vv.getPart() != null) {
                    vref.part = _context.resolvePart(vref.variable,
vv.getPart());
                    if (vv.getLocation() != null &&
vv.getLocation().getExpression() != null)
                        vref.location =
_context.compileExpr(vv.getLocation());
                }
                return vref;
            } else {System.out.println("Error: compileFrom");return null;}
            } catch (CompilationException ce) {
                if (ce.getCompilationMessage().source == null)
                    ce.getCompilationMessage().source = from;
                throw ce;
            }
        }

    private OAssign.LValue compileTo(To to) {
        assert to != null;
            try {
                if (to.isVariableVal()) {
                    VariableVal vv = to.getAsVariableVal();
                    OAssign.VariableRef vref = new
OAssign.VariableRef(_context.getOProcess());
                    vref.variable =
_context.resolveVariable(vv.getVariable());
                    if (to.getAsVariableVal().getPart() != null) {
                        vref.part = _context.resolvePart(vref.variable,
vv.getPart());
                        if (vv.getLocation() != null &&
vv.getLocation().getExpression() != null)
                            vref.location =
_context.compileExpr(vv.getLocation());
                    }
                    return vref;
                } else {
                    System.out.println("Error: compileTo");return null;
                }
            } catch (CompilationException ce) {
                if (ce.getCompilationMessage().source == null)
                    ce.getCompilationMessage().source = to;
                throw ce;
            }
    }

2010/1/20 Dhanush Gopinath <dhanush.gopinath@altair.com>

> Hi Michele,
>
> Here is a sample snippet. uriBPELFile is the URI to the BPEL file
>
> ResourceFinder bpelResourceFinder = new DefaultResourceFinder();
>                        // build the input stream
>                        InputStream bpelFileIS = bpelResourceFinder
>                                        .openResource(uriBPELFile);
>                        m_bpelFile = new File(uriBPELFile);
>                        // parse the document
>                        Document bpelDocument =
> DOMUtils.parse(bpelFileIS);
>                        // get the process node
>                        NodeList processNodes = bpelDocument
>
> .getElementsByTagName("process");
> // Assuming only one process element
>                        Node processElement = processNodes.item(0);
>                        // create the Process Object
>                        m_bpelProcessBOM = new Process((Element)
> processElement);
>                        m_bpelProcessBOM.setURI(uriBPELFile);
>                        // create the Compiler
>                        BpelCompiler20 bpelCompiler = new
> BpelCompiler20();
>                        // compile the process and create a OProcess
> object
>                        m_bpelCompiledProcess =
> bpelCompiler.compile(m_bpelProcessBOM,
>                                        bpelResourceFinder);
>
>
> HTH,
> Thanks
> Dhanush
>
> -----Original Message-----
> From: Michele [mailto:ianno81@gmail.com]
> Sent: Wednesday, January 20, 2010 7:42 PM
> To: user@ode.apache.org
> Subject: How create a BpelCompiler20
>
> Hello, I have problem with BPELCompiler20()
> I have the following error:
> ERROR [main] (BpelCompiler.java:605) - null:57: error:
> [UndeclaredVariable]
> Attempt to reference undeclared variable "Search".
>
> The instruction that give the error is the following
> vref.variable = _context.resolveVariable(vv.getVariable());
>
> in the context:
> private OAssign.RValue compileFrom(From from) {
>        assert from != null;
>        try {
>              if (from.isVariableVal()) {
>                VariableVal vv = from.getAsVariableVal();
>                OAssign.VariableRef vref = new
> OAssign.VariableRef(_context.getOProcess());
>                vref.variable =
> _context.resolveVariable(vv.getVariable());
> .....
>
>
> Th problem is that I don't know how instante a BpelCompiler20() on my
> specific BPEL process
>
> BpelCompiler20 _context = new BpelCompiler20();
>
> How Can I compile the BPEL file with the BPELCompiler20?
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message