Package hu.sztaki.ilab.longneck.process.block

Examples of hu.sztaki.ilab.longneck.process.block.Block


        // Create new kernel state, if record doesn't carry one
        if (kernelState == null || kernelState.isAfterProcessing()) {
            kernelState = newKernelState();
        }
       
        Block currentBlock;
        ExecutionFrame currentFrame = null;
       
        // Iterate sequence
        for (;;) {
            try {
                currentFrame = kernelState.getLastExecutionFrame();

                if (currentFrame.getHostBlock().hasPosition(currentFrame.getPosition())) {                    
                    currentBlock = currentFrame.getHostBlock().getBlocks().get(currentFrame.getPosition());

                    // If compound, go into it
                    if (currentBlock instanceof CompoundBlock) {
                        ExecutionFrame childFrame =
                                new ExecutionFrame((CompoundBlock) currentBlock, currentFrame);
                        kernelState.addLastExecutionFrame(childFrame);
                        currentFrame = childFrame;

                        // Apply block changes
                        currentBlock.apply(record, currentFrame.getVariables());
                       
                        // Startup changing record
                        if (currentFrame.isRecordchangehandler()) {
                            try {
                                record = ((RecordChangeHandler) currentFrame.getControl()).changeRecord(record);
                            } catch (NoMappingException e) {
                                // do nothing
                                /*  Error if no mapping was added to the given blockreference.
                                 *  We don't consider this as error, we simply use the original records.
                                 *  If we need to sign this event this is the right place.
                                 */
                            }
                        }

                        // Startup handlers
                        if (currentFrame.isStartHandler()) {
                            try {
                                ((StartHandler) currentFrame.getControl()).beforeChildren(kernelState, record);
                            } catch (RedirectException ex) {
                                handleRedirect(kernelState, ex);
                            }
                        }
                    }
                    else if (currentBlock instanceof BlockReference) {
                        ExecutionFrame childFrame = new ExecutionFrame(
                                (BlockReference) currentBlock, currentFrame);

                        kernelState.addLastExecutionFrame(childFrame);
                        currentFrame = childFrame;
                       
                        // Startup changing record
                        if (currentFrame.isRecordchangehandler()) {
                            try {
                                record = ((RecordChangeHandler) currentFrame.getControl()).changeRecord(record);
                            } catch (NoMappingException e) {
                                // do nothing
                                /*  Error if no mapping was added to the given blockreference.
                                 *  We don't consider this as error, we simply use the original records.
                                 *  If we need to sign this event this is the right place.
                                 */
                            }
                        }

                        // Startup handlers
                        if (currentFrame.isStartHandler()) {
                            try {
                                ((StartHandler) currentFrame.getControl()).beforeChildren(kernelState, record);
                            } catch (RedirectException ex) {
                                handleRedirect(kernelState, ex);
                            }
                        }
                    } else {
                        // Atomic block processing

                        if (currentBlock instanceof CloneRecord) {
                            // Clone the record
                            Record clone = ((CloneRecord) currentBlock).getClonedRecord(
                                    record, currentFrame.getVariables());

                            // Clone the current kernel state and increase getPosition()
                            KernelState cloneState = new KernelState(kernelState);
                            cloneState.increasePosition();
                            clone.setKernelState(cloneState);

                            localCloneQueue.add(clone);
                        } else {
                            // Apply block changes
                            currentBlock.apply(record, currentFrame.getVariables());
                        }

                        // Success handler for atomic blocks
                        if (currentFrame.isSuccessHandler() && currentBlock instanceof Atomic) {
                            try {
View Full Code Here


    // Unmarshal document
    LongneckProcess process = (LongneckProcess) unmarshaller.unmarshal(doc);
    Record r = new RecordImpl();
    List<Block> blocks = process.getBlocks();
    Block setBlock = blocks.get(0);

    Assert.assertTrue("First block is not of type " + Set.class.getName(), setBlock instanceof Set);
    setBlock.apply(r, new VariableSpace());

    Block timestampBlock = blocks.get(1);
    Assert.assertTrue("Second block is not of type " +
      ExtractUnixtimestamp.class.getName(), timestampBlock instanceof ExtractUnixtimestamp);
   
        VariableSpace variables = new VariableSpace();
    timestampBlock.apply(r, variables);

    checkFields(variables, "year", "1963");
    checkFields(variables, "month", "12");
    checkFields(variables, "day", "4");
    checkFields(variables, "hour", "15");
View Full Code Here

TOP

Related Classes of hu.sztaki.ilab.longneck.process.block.Block

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.