Package org.drools.rule

Examples of org.drools.rule.Function


        }
    }

    private void processFunctions(PackageRegistry pkgRegistry, PackageDescr packageDescr) {
        for (FunctionDescr function : packageDescr.getFunctions()) {
            Function existingFunc = pkgRegistry.getPackage().getFunctions().get( function.getName() );
            if (existingFunc != null && function.getNamespace().equals( existingFunc.getNamespace() )) {
                this.results.add(
                        new DuplicateFunction( function,
                                               this.configuration ) );
            }
        }
View Full Code Here


        final String functionClassName = this.pkg.getName() + "." + StringUtils.ucFirst( functionDescr.getName() );
        functionDescr.setClassName( functionClassName );

        this.pkg.addStaticImport( functionClassName + "." + functionDescr.getName() );

        Function function = new Function( functionDescr.getNamespace(), functionDescr.getName(), ID );
        if ( resource != null && ((InternalResource) resource).hasURL() ) {
            function.setResource( resource );
        }
        this.pkg.addFunction( function );

        final String functionSrc = getFunctionBuilder().build( this.pkg,
                                                               functionDescr,
View Full Code Here

                this.listener.debug("KnowledgeAgent removing Process=" + process);
                this.kbase.removeProcess(process.getId());
            } else if (kd instanceof TypeDeclaration) {
                // @TODO Handle Type Declarations... is there a way to remove this?
            } else if (kd instanceof Function) {
                Function function = (Function) kd;
                this.kbase.removeFunction(function.getNamespace(), function.getName());
            }
        } catch (IllegalArgumentException e) {
            //it could be possible that a definition does not longer exists
            //in the kbase.
            this.listener.warning(e.getMessage());
View Full Code Here

    }

    public void visitFunction(final Function oldFunction){
        //ok, so I get an old function: is it modified in the new pkg? is it even present on it?
        Function newFunction = newPkg.getFunction(oldFunction.getName());

        if (newFunction == null){
            //the old function is not present on the new package. Add it to
            //removed rules list.
            listener.debug("BinaryResourceDiffProducerImpl: "+oldFunction+" is not present anymore. Adding to removed list.");
            this.removedDefinitions.add(oldFunction);
            return;
        }

        //it is possible that the old function doesn't exist anymore in the current
        //pkg. This is because maybe some other resouce updated its definition
        //and after that the same resource removed it. If that is the case,
        //this resource (the one we are processing) still contain a reference
        //to the function, but it is no present on kbase anymore. If this is the
        //case, we wan't to skip this function. Remember that someone
        //modified it and removed it before this resource. We don't even
        //add it to removedDefinitions, because it is no present on kbase. What
        //we have to do is remove it from the new pkg so it won't reapears.
        if (currentPkg.getFunction(oldFunction.getName()) == null){
            listener.debug("BinaryResourceDiffProducerImpl: "+oldFunction+" is not present on current PKG. Removing from new package.");
            newPkg.removeFunction(oldFunction.getName());
            return;
        }

        //is newFunction equal to oldFunction?
        if (newFunction.equals(oldFunction)){
            //if so, we don't need the function in the new Package.
            listener.debug("BinaryResourceDiffProducerImpl: "+oldFunction+" didn't change. Removing from diff package and adding it to unmodified list.");
            newPkg.removeFunction(newFunction.getName());
            this.unmodifiedDefinitions.add(oldFunction);
        }else{
            //it seams that the kbase doesn't overrides function's definitions.
            //that's why we need to mark this function as removed, but don't
            //remove it from the new pkg.
View Full Code Here

                this.listener.debug( "KnowledgeAgent removing Process=" + process );
                this.kbase.removeProcess( process.getId() );
            } else if ( kd instanceof TypeDeclaration ) {
                // @TODO Handle Type Declarations... is there a way to remove this?
            } else if ( kd instanceof Function ) {
                Function function = (Function) kd;
                this.kbase.removeFunction( function.getNamespace(),
                                           function.getName() );
            }
        } catch ( IllegalArgumentException e ) {
            //it could be possible that a definition does not longer exists
            //in the kbase.
            this.listener.warning( e.getMessage() );
View Full Code Here

        processEntryPointDeclarations( packageDescr );

        processTypeDeclarations( packageDescr );
        for ( FunctionDescr function : packageDescr.getFunctions() ) {
            Function existingFunc = pkgRegistry.getPackage().getFunctions().get( function.getName() );
            if ( existingFunc != null && function.getNamespace().equals( existingFunc.getNamespace() ) ) {
                this.results.add(
                        new DuplicateFunction( function,
                                               this.configuration ) );
            }
        }
View Full Code Here

                this.listener.debug( "KnowledgeAgent removing Process=" + process );
                this.kbase.removeProcess( process.getId() );
            } else if ( kd instanceof TypeDeclaration ) {
                // @TODO Handle Type Declarations... is there a way to remove this?
            } else if ( kd instanceof Function ) {
                Function function = (Function) kd;
                this.kbase.removeFunction( function.getNamespace(),
                                           function.getName() );
            }
        } catch ( IllegalArgumentException e ) {
            //it could be possible that a definition does not longer exists
            //in the kbase.
            this.listener.warning( e.getMessage() );
View Full Code Here

                this.listener.debug( "KnowledgeAgent removing Process=" + process );
                this.kbase.removeProcess( process.getId() );
            } else if ( kd instanceof TypeDeclaration ) {
                // @TODO Handle Type Declarations... is there a way to remove this?
            } else if ( kd instanceof Function ) {
                Function function = (Function) kd;
                this.kbase.removeFunction( function.getNamespace(),
                                           function.getName() );
            }
        } catch ( IllegalArgumentException e ) {
            //it could be possible that a definition does not longer exists
            //in the kbase.
            this.listener.warning( e.getMessage() );
View Full Code Here

    }

    public void visitFunction(final Function oldFunction){
        //ok, so I get an old function: is it modified in the new pkg? is it even present on it?
        Function newFunction = newPkg.getFunction(oldFunction.getName());

        if (newFunction == null){
            //the old function is not present on the new package. Add it to
            //removed rules list.
            listener.debug("BinaryResourceDiffProducerImpl: "+oldFunction+" is not present anymore. Adding to removed list.");
            this.removedDefinitions.add(oldFunction);
            return;
        }

        //it is possible that the old function doesn't exist anymore in the current
        //pkg. This is because maybe some other resouce updated its definition
        //and after that the same resource removed it. If that is the case,
        //this resource (the one we are processing) still contain a reference
        //to the function, but it is no present on kbase anymore. If this is the
        //case, we wan't to skip this function. Remember that someone
        //modified it and removed it before this resource. We don't even
        //add it to removedDefinitions, because it is no present on kbase. What
        //we have to do is remove it from the new pkg so it won't reapears.
        if (currentPkg.getFunction(oldFunction.getName()) == null){
            listener.debug("BinaryResourceDiffProducerImpl: "+oldFunction+" is not present on current PKG. Removing from new package.");
            newPkg.removeFunction(oldFunction.getName());
            return;
        }

        //is newFunction equal to oldFunction?
        if (newFunction.equals(oldFunction)){
            //if so, we don't need the function in the new Package.
            listener.debug("BinaryResourceDiffProducerImpl: "+oldFunction+" didn't change. Removing from diff package and adding it to unmodified list.");
            newPkg.removeFunction(newFunction.getName());
            this.unmodifiedDefinitions.add(oldFunction);
        }else{
            //it seems that the kbase doesn't overrides function's definitions.
            //that's why we need to mark this function as removed, but don't
            //remove it from the new pkg.
View Full Code Here

        final String functionClassName = this.pkg.getName() + "." + StringUtils.ucFirst( functionDescr.getName() );
        functionDescr.setClassName( functionClassName );

        this.pkg.addStaticImport( functionClassName + "." + functionDescr.getName() );

        Function function = new Function( functionDescr.getNamespace(), functionDescr.getName(),
                                          this.ID );
        if ( resource != null && ((InternalResource) resource).hasURL() ) {
            function.setResource( resource );
        }
        this.pkg.addFunction( function );

        final String functionSrc = getFunctionBuilder().build( this.pkg,
                                                               functionDescr,
View Full Code Here

TOP

Related Classes of org.drools.rule.Function

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.