Package org.guvnor.common.services.project.model

Examples of org.guvnor.common.services.project.model.ProjectImports


        assertTrue( handler.toString( new ProjectImports() ).contains( "<version>1.0</version>" ) );
    }

    @Test
    public void testNullSourceXml() throws Exception {
        ProjectImports imports = handler.toModel( null );
        assertNotNull( imports );
        assertEquals( 0,
                      imports.getImports().getImports().size() );
    }
View Full Code Here


                      imports.getImports().getImports().size() );
    }

    @Test
    public void testEmptySourceXml() throws Exception {
        ProjectImports imports = handler.toModel( "" );
        assertNotNull( imports );
        assertEquals( 0,
                      imports.getImports().getImports().size() );
    }
View Full Code Here

                      xml );
    }

    @Test
    public void testEmptyImports() throws Exception {
        String xml = handler.toString( new ProjectImports() );
        assertTrue( xml.contains( "<imports>" ) );
        assertTrue( xml.contains( "</imports>" ) );
    }
View Full Code Here

        assertTrue( xml.contains( "</imports>" ) );
    }

    @Test
    public void testImports() throws Exception {
        ProjectImports configuration = new ProjectImports();
        configuration.getImports().addImport( new Import( "java.util.List" ) );
        configuration.getImports().addImport( new Import( "org.test.Object" ) );
        String xml = handler.toString( configuration );
        assertTrue( xml.contains( "<import>" ) );
        assertTrue( xml.contains( "</import>" ) );
        assertTrue( xml.contains( "<type>java.util.List</type>" ) );
        assertTrue( xml.contains( "<type>org.test.Object</type>" ) );
View Full Code Here

        if ( imports == null || imports.isEmpty() ) {
            return;
        }

        //Load existing PackageImports
        ProjectImports projectImports = new ProjectImports();
        final org.uberfire.java.nio.file.Path nioExternalImportsPath = Paths.convert( context ).resolve( "project.imports" );
        final Path externalImportsPath = Paths.convert( nioExternalImportsPath );
        if ( Files.exists( nioExternalImportsPath ) ) {
            projectImports = projectService.load( externalImportsPath );
        }

        //Make collections of existing Imports so we don't duplicate them when adding the new
        List<String> existingImports = new ArrayList<String>();
        for ( org.drools.workbench.models.datamodel.imports.Import item : projectImports.getImports().getImports() ) {
            existingImports.add( item.getType() );
        }

        //Add imports
        boolean isModified = false;
        for ( Import item : imports ) {
            if ( !existingImports.contains( item.getClassName() ) ) {
                isModified = true;
                result.addMessage( "Created Import for '" + item.getClassName() + "'.",
                                   ConversionMessageType.INFO );
                projectImports.getImports().addImport( new org.drools.workbench.models.datamodel.imports.Import( item.getClassName() ) );
            }
        }

        //Save update
        if ( isModified ) {
View Full Code Here

            ioService.endBatch();
        }
    }

    private ProjectImports createProjectImports() {
        ProjectImports imports = new ProjectImports();
        imports.getImports().addImport( new Import( "java.lang.Number" ) );
        return imports;
    }
View Full Code Here

        if ( imports == null || imports.isEmpty() ) {
            return;
        }

        //Load existing PackageImports
        ProjectImports projectImports = new ProjectImports();
        final org.uberfire.java.nio.file.Path nioExternalImportsPath = Paths.convert( context ).resolve( "project.imports" );
        final Path externalImportsPath = Paths.convert( nioExternalImportsPath );
        if ( Files.exists( nioExternalImportsPath ) ) {
            projectImports = projectService.load( externalImportsPath );
        }

        //Make collections of existing Imports so we don't duplicate them when adding the new
        List<String> existingImports = new ArrayList<String>();
        for ( org.drools.workbench.models.datamodel.imports.Import item : projectImports.getImports().getImports() ) {
            existingImports.add( item.getType() );
        }

        //Add imports
        boolean isModified = false;
        for ( Import item : imports ) {
            if ( !existingImports.contains( item.getClassName() ) ) {
                isModified = true;
                result.addMessage( "Created Import for '" + item.getClassName() + "'.",
                                   ConversionMessageType.INFO );
                projectImports.getImports().addImport( new org.drools.workbench.models.datamodel.imports.Import( item.getClassName() ) );
            }
        }

        //Save update
        if ( isModified ) {
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 ) {
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.kie.commons.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,
View Full Code Here

TOP

Related Classes of org.guvnor.common.services.project.model.ProjectImports

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.