Package org.drools.workbench.models.datamodel.imports

Examples of org.drools.workbench.models.datamodel.imports.Imports


        //Check external imports are available. These are loaded when a DMO is requested, but it's better to report them early
        final org.uberfire.java.nio.file.Path nioExternalImportsPath = moduleDirectory.resolve( "project.imports" );
        if ( Files.exists( nioExternalImportsPath ) ) {
            final org.uberfire.backend.vfs.Path externalImportsPath = Paths.convert( nioExternalImportsPath );
            final ProjectImports projectImports = projectService.load( externalImportsPath );
            final Imports imports = projectImports.getImports();
            for ( final Import item : imports.getImports() ) {
                try {
                    Class clazz = this.getClass().getClassLoader().loadClass( item.getType() );
                } catch ( ClassNotFoundException cnfe ) {
                    results.addBuildMessage( makeMessage( ERROR_CLASS_NOT_FOUND,
                                                          cnfe ) );
View Full Code Here


        //De-serialize Package name
        final String packageName = PackageNameParser.parsePackageName( expandedDRLInfo.plainDrl );
        model.setPackageName( packageName );

        //De-serialize imports
        final Imports imports = ImportsParser.parseImports( expandedDRLInfo.plainDrl );
        for ( Import item : imports.getImports() ) {
            model.getImports().addImport( item );
        }

        boolean isJavaDialect = parseAttributes( model,
                                                 ruleDescr.getAttributes() );
View Full Code Here

        //De-serialize Package name
        final String packageName = PackageNameParser.parsePackageName( expandedDRLInfo.plainDrl );
        model.setPackageName( packageName );

        //De-serialize imports
        final Imports imports = ImportsParser.parseImports( expandedDRLInfo.plainDrl );
        for ( Import item : imports.getImports() ) {
            model.getImports().addImport( item );
        }

        boolean isJavaDialect = parseAttributes( model,
                                                 ruleDescr.getAttributes() );
View Full Code Here

    private ImportsParser() {
    }

    public static Imports parseImports( final String content ) {
        Imports imports = new Imports();

        if ( content == null || content.trim().equals( "" ) ) {
            return imports;
        } else {
            final String[] lines = content.split( "\\n" );

            for ( int i = 0; i < lines.length; i++ ) {
                String line = lines[ i ].trim();
                if ( !( line.equals( "" ) || line.startsWith( "#" ) ) ) {
                    if ( line.startsWith( KEYWORD ) ) {
                        line = line.substring( KEYWORD.length() ).trim();
                        if ( line.endsWith( ";" ) ) {
                            line = line.substring( 0, line.length() - 1 );
                        }
                        imports.addImport( new Import( line ) );
                    }
                }
            }

            return imports;
View Full Code Here

        //De-serialize Package name
        final String packageName = PackageNameParser.parsePackageName( expandedDRLInfo.plainDrl );
        model.setPackageName( packageName );

        //De-serialize imports
        final Imports imports = ImportsParser.parseImports( expandedDRLInfo.plainDrl );
        for ( Import item : imports.getImports() ) {
            model.getImports().addImport( item );
        }

        boolean isJavaDialect = parseAttributes( model,
                                                 ruleDescr.getAttributes() );
View Full Code Here

            //Check external imports are available. These are loaded when a DMO is requested, but it's better to report them early
            final org.uberfire.java.nio.file.Path nioExternalImportsPath = moduleDirectory.resolve( "project.imports" );
            if ( Files.exists( nioExternalImportsPath ) ) {
                final org.uberfire.backend.vfs.Path externalImportsPath = Paths.convert( nioExternalImportsPath );
                final ProjectImports projectImports = projectService.load( externalImportsPath );
                final Imports imports = projectImports.getImports();
                for ( final Import item : imports.getImports() ) {
                    final String fullyQualifiedClassName = item.getType();
                    try {
                        Class clazz = this.getClass().getClassLoader().loadClass( item.getType() );
                    } catch ( ClassNotFoundException cnfe ) {
                        logger.error( cnfe.getMessage() );
View Full Code Here

        //De-serialize Package name
        final String packageName = PackageNameParser.parsePackageName( drl );
        model.setPackageName( packageName );

        //De-serialize imports
        final Imports imports = ImportsParser.parseImports( drl );
        for ( Import item : imports.getImports() ) {
            model.getImports().addImport( item );
        }

        //Split DRL into separate rules
        final List<String> rules = new ArrayList<String>();
View Full Code Here

        //De-serialize Package name
        final String packageName = PackageNameParser.parsePackageName( expandedDRLInfo.plainDrl );
        model.setPackageName( packageName );

        //De-serialize imports
        final Imports imports = ImportsParser.parseImports( expandedDRLInfo.plainDrl );
        for ( Import item : imports.getImports() ) {
            model.getImports().addImport( item );
        }

        boolean isJavaDialect = parseAttributes( model,
                                                 ruleDescr.getAttributes() );
View Full Code Here

                                          final Path resource ) {
        if ( packageHeaderInfo.getHeader() == null ) {
            return drl;
        }

        final Imports imports = ImportsParser.parseImports( packageHeaderInfo.getHeader() );
        if ( imports == null || drl.toLowerCase().indexOf("import ")!=-1) {
            return drl;
        }
        StringBuilder sb = new StringBuilder();
        sb.append( imports.toString() );
        if ( imports.getImports().size() > 0 ) {
            sb.append( "\n" );
        }

        sb.append( drl );
        return sb.toString();
View Full Code Here

                                          final Path resource ) {
        if ( packageHeaderInfo.getHeader() == null ) {
            return xml;
        }

        final Imports imports = ImportsParser.parseImports( packageHeaderInfo.getHeader() );
        if ( imports == null ) {
            return xml;
        }

        DocumentBuilderFactory domfac = DocumentBuilderFactory.newInstance();

        try {
            DocumentBuilder dombuilder = domfac.newDocumentBuilder();
            Document doc = dombuilder.parse( new ByteArrayInputStream( xml.getBytes( Charsets.UTF_8 ) ) );

            if ( doc.getElementsByTagName( "imports" ).getLength() != 0 ) {
                return xml;
            }

            /* The imports should have following format (used by the workbench):
             *  <imports>
             *    <imports>
             *      <org.drools.workbench.models.datamodel.imports.Import>
             *        <type>java.lang.Number</type>
             *      </org.drools.workbench.models.datamodel.imports.Import>
             *   </imports>
             *  </imports>
             */
            Element root = doc.getDocumentElement();
            Element topImportsElement = doc.createElement( "imports" );
            Element nestedImportsElement = doc.createElement( "imports" );
            topImportsElement.appendChild(nestedImportsElement);

            for ( final Import i : imports.getImports() ) {
                Element importElement = doc.createElement( Import.class.getCanonicalName() );
                Element typeElement = doc.createElement( "type" );
                typeElement.appendChild( doc.createTextNode( i.getType() ) );
                importElement.appendChild( typeElement );
                nestedImportsElement.appendChild( importElement );
View Full Code Here

TOP

Related Classes of org.drools.workbench.models.datamodel.imports.Imports

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.