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

Examples of org.guvnor.common.services.project.builder.model.IncrementalBuildResults


        checkNotNull( "resource",
                      resource );

        //Only files can be processed
        if ( !Files.isRegularFile( resource ) ) {
            return new IncrementalBuildResults( gav );
        }

        //Check a full build has been performed
        if ( !isBuilt() ) {
            throw new IllegalStateException( "A full build needs to be performed before any incremental operations." );
        }

        //Resource Type might require "external" validation (i.e. it's not covered by Kie)
        final IncrementalBuildResults results = new IncrementalBuildResults( gav );
        final BuildValidationHelper validator = getBuildValidationHelper( resource );
        if ( validator != null ) {
            final List<ValidationMessage> addedValidationMessages = validator.validate( Paths.convert( resource ) );

            if ( !( addedValidationMessages == null || addedValidationMessages.isEmpty() ) ) {
                for ( ValidationMessage validationMessage : addedValidationMessages ) {
                    results.addAddedMessage( convertValidationMessage( validationMessage ) );
                }
            }

            final List<ValidationMessage> removedValidationMessages = nonKieResourceValidationHelperMessages.remove( resource );
            if ( !( removedValidationMessages == null || removedValidationMessages.isEmpty() ) ) {
                for ( ValidationMessage validationMessage : removedValidationMessages ) {
                    results.addRemovedMessage( convertValidationMessage( validationMessage ) );
                }
            }
            nonKieResourceValidationHelperMessages.put( resource,
                                                        addedValidationMessages );
        }

        //Add new resource
        final String destinationPath = resource.toUri().toString().substring( projectPrefix.length() + 1 );
        final InputStream is = ioService.newInputStream( resource );
        final BufferedInputStream bis = new BufferedInputStream( is );
        kieFileSystem.write( destinationPath,
                             KieServices.Factory.get().getResources().newInputStreamResource( bis ) );
        addJavaClass( resource );
        handles.put( destinationPath,
                     Paths.convert( resource ) );

        //Incremental build
        final IncrementalResults incrementalResults = ( (InternalKieBuilder) kieBuilder ).createFileSet( destinationPath ).build();
        for ( final Message message : incrementalResults.getAddedMessages() ) {
            results.addAddedMessage( convertMessage( message ) );
        }
        for ( final Message message : incrementalResults.getRemovedMessages() ) {
            results.addRemovedMessage( convertMessage( message ) );
        }

        //Tidy-up removed message handles
        for ( Message message : incrementalResults.getRemovedMessages() ) {
            handles.remove( RESOURCE_PATH + "/" + message.getPath() );
View Full Code Here


        kieFileSystem.delete( destinationPath );
        removeJavaClass( resource );

        //Incremental build
        final IncrementalResults incrementalResults = ( (InternalKieBuilder) kieBuilder ).createFileSet( destinationPath ).build();
        final IncrementalBuildResults results = convertMessages( incrementalResults );

        //Tidy-up removed message handles
        for ( Message message : incrementalResults.getRemovedMessages() ) {
            handles.remove( RESOURCE_PATH + "/" + message.getPath() );
        }

        //Resource Type might have been validated "externally" (i.e. it's not covered by Kie). Clear any errors.
        final BuildValidationHelper validator = getBuildValidationHelper( resource );
        if ( validator != null ) {
            final List<ValidationMessage> removedValidationMessages = nonKieResourceValidationHelperMessages.remove( resource );
            if ( !( removedValidationMessages == null || removedValidationMessages.isEmpty() ) ) {
                for ( ValidationMessage validationMessage : removedValidationMessages ) {
                    results.addRemovedMessage( convertValidationMessage( validationMessage ) );
                }
            }
        }

        fireRuleNameUpdateEvent();
View Full Code Here

        final String[] kieBuilderPaths = new String[ changedFilesKieBuilderPaths.size() ];
        changedFilesKieBuilderPaths.toArray( kieBuilderPaths );
        final IncrementalResults incrementalResults = ( (InternalKieBuilder) kieBuilder ).createFileSet( kieBuilderPaths ).build();

        //Messages from incremental build
        final IncrementalBuildResults results = convertMessages( incrementalResults );

        //Copy in BuildMessages for non-KIE resources
        for ( ValidationMessage addedValidationMessage : nonKieResourceValidatorAddedMessages ) {
            results.addAddedMessage( convertValidationMessage( addedValidationMessage ) );
        }
        for ( ValidationMessage removedValidationMessage : nonKieResourceValidatorRemovedMessages ) {
            results.addRemovedMessage( convertValidationMessage( removedValidationMessage ) );
        }

        //Tidy-up removed message handles
        for ( Message message : incrementalResults.getRemovedMessages() ) {
            handles.remove( RESOURCE_PATH + "/" + message.getPath() );
View Full Code Here

        }
        return results;
    }

    private IncrementalBuildResults convertMessages( final IncrementalResults kieIncrementalResults ) {
        final IncrementalBuildResults results = new IncrementalBuildResults( gav );
        for ( final Message message : kieIncrementalResults.getAddedMessages() ) {
            results.addAddedMessage( convertMessage( message ) );
        }
        for ( final Message message : kieIncrementalResults.getRemovedMessages() ) {
            results.addRemovedMessage( convertMessage( message ) );
        }
        return results;
    }
View Full Code Here

            checkNotNull( "resource",
                          resource );

            //Only files can be processed
            if ( !Files.isRegularFile( resource ) ) {
                return new IncrementalBuildResults( gav );
            }

            //Check a full build has been performed
            if ( !isBuilt() ) {
                throw new IllegalStateException( "A full build needs to be performed before any incremental operations." );
            }

            //Resource Type might require "external" validation (i.e. it's not covered by Kie)
            final IncrementalBuildResults results = new IncrementalBuildResults( gav );
            final BuildValidationHelper validator = getBuildValidationHelper( resource );
            if ( validator != null ) {
                final List<ValidationMessage> addedValidationMessages = validator.validate( Paths.convert( resource ) );

                if ( !( addedValidationMessages == null || addedValidationMessages.isEmpty() ) ) {
                    for ( ValidationMessage validationMessage : addedValidationMessages ) {
                        results.addAddedMessage( convertValidationMessage( validationMessage ) );
                    }
                }

                final List<ValidationMessage> removedValidationMessages = nonKieResourceValidationHelperMessages.remove( resource );
                if ( !( removedValidationMessages == null || removedValidationMessages.isEmpty() ) ) {
                    for ( ValidationMessage validationMessage : removedValidationMessages ) {
                        results.addRemovedMessage( convertValidationMessage( validationMessage ) );
                    }
                }
                nonKieResourceValidationHelpers.put( resource,
                                                     validator );
                nonKieResourceValidationHelperMessages.put( resource,
                                                            addedValidationMessages );
            }

            //Add new resource
            final String destinationPath = resource.toUri().toString().substring( projectPrefix.length() + 1 );
            final InputStream is = ioService.newInputStream( resource );
            final BufferedInputStream bis = new BufferedInputStream( is );
            kieFileSystem.write( destinationPath,
                                 KieServices.Factory.get().getResources().newInputStreamResource( bis ) );
            addJavaClass( resource );
            handles.put( destinationPath,
                         Paths.convert( resource ) );

            //Incremental build
            try {
                final IncrementalResults incrementalResults = ( (InternalKieBuilder) kieBuilder ).createFileSet( destinationPath ).build();
                for ( final Message message : incrementalResults.getAddedMessages() ) {
                    results.addAddedMessage( convertMessage( message ) );
                }
                for ( final Message message : incrementalResults.getRemovedMessages() ) {
                    results.addRemovedMessage( convertMessage( message ) );
                }

                //Tidy-up removed message handles
                for ( Message message : incrementalResults.getRemovedMessages() ) {
                    handles.remove( RESOURCE_PATH + "/" + message.getPath() );
                }

            } catch ( LinkageError e ) {
                final String msg = MessageFormat.format( ERROR_CLASS_NOT_FOUND,
                                                         e.getLocalizedMessage() );
                logger.warn( msg );
                results.addAddedMessage( makeWarningMessage( msg ) );
            } catch ( Throwable e ) {
                final String msg = e.getLocalizedMessage();
                logger.error( msg );
                results.addAddedMessage( makeErrorMessage( msg ) );
            }

            return results;
        }
    }
View Full Code Here

            if ( !isBuilt() ) {
                throw new IllegalStateException( "A full build needs to be performed before any incremental operations." );
            }

            //Resource Type might have been validated "externally" (i.e. it's not covered by Kie). Clear any errors.
            final IncrementalBuildResults results = new IncrementalBuildResults( gav );
            final BuildValidationHelper validator = getBuildValidationHelper( resource );
            if ( validator != null ) {
                nonKieResourceValidationHelpers.remove( resource );
                final List<ValidationMessage> removedValidationMessages = nonKieResourceValidationHelperMessages.remove( resource );
                if ( !( removedValidationMessages == null || removedValidationMessages.isEmpty() ) ) {
                    for ( ValidationMessage validationMessage : removedValidationMessages ) {
                        results.addRemovedMessage( convertValidationMessage( validationMessage ) );
                    }
                }
            }

            //Delete resource
            final String destinationPath = resource.toUri().toString().substring( projectPrefix.length() + 1 );
            kieFileSystem.delete( destinationPath );
            removeJavaClass( resource );

            //Incremental build
            try {
                final IncrementalResults incrementalResults = ( (InternalKieBuilder) kieBuilder ).createFileSet( destinationPath ).build();
                for ( final Message message : incrementalResults.getAddedMessages() ) {
                    results.addAddedMessage( convertMessage( message ) );
                }
                for ( final Message message : incrementalResults.getRemovedMessages() ) {
                    results.addRemovedMessage( convertMessage( message ) );
                }

                //Tidy-up removed message handles
                for ( Message message : incrementalResults.getRemovedMessages() ) {
                    handles.remove( RESOURCE_PATH + "/" + message.getPath() );
                }

            } catch ( LinkageError e ) {
                final String msg = MessageFormat.format( ERROR_CLASS_NOT_FOUND,
                                                         e.getLocalizedMessage() );
                logger.warn( msg );
                results.addAddedMessage( makeWarningMessage( msg ) );
            } catch ( Throwable e ) {
                final String msg = e.getLocalizedMessage();
                logger.error( msg );
                results.addAddedMessage( makeErrorMessage( msg ) );
            }

            return results;
        }
    }
View Full Code Here

            final String[] kieBuilderPaths = new String[ changedFilesKieBuilderPaths.size() ];
            changedFilesKieBuilderPaths.toArray( kieBuilderPaths );

            //Messages from incremental build

            final IncrementalBuildResults results = new IncrementalBuildResults( gav );
            try {
                final IncrementalResults incrementalResults = ( (InternalKieBuilder) kieBuilder ).createFileSet( kieBuilderPaths ).build();
                for ( final Message message : incrementalResults.getAddedMessages() ) {
                    results.addAddedMessage( convertMessage( message ) );
                }
                for ( final Message message : incrementalResults.getRemovedMessages() ) {
                    results.addRemovedMessage( convertMessage( message ) );
                }

                //Tidy-up removed message handles
                for ( Message message : incrementalResults.getRemovedMessages() ) {
                    handles.remove( RESOURCE_PATH + "/" + message.getPath() );
                }

            } catch ( LinkageError e ) {
                final String msg = MessageFormat.format( ERROR_CLASS_NOT_FOUND,
                                                         e.getLocalizedMessage() );
                logger.warn( msg );
                results.addAddedMessage( makeWarningMessage( msg ) );
            } catch ( Throwable e ) {
                final String msg = e.getLocalizedMessage();
                logger.error( msg );
                results.addAddedMessage( makeErrorMessage( msg ) );
            }

            //Copy in BuildMessages for non-KIE resources
            for ( ValidationMessage addedValidationMessage : nonKieResourceValidatorAddedMessages ) {
                results.addAddedMessage( convertValidationMessage( addedValidationMessage ) );
            }
            for ( ValidationMessage removedValidationMessage : nonKieResourceValidatorRemovedMessages ) {
                results.addRemovedMessage( convertValidationMessage( removedValidationMessage ) );
            }

            return results;
        }
    }
View Full Code Here

                      buildResults.getMessages().size() );

        //Perform incremental build
        buildChangeListener.addResource( resourcePath );

        final IncrementalBuildResults incrementalBuildResults = buildResultsObserver.getIncrementalBuildResults();
        assertNotNull( incrementalBuildResults );
        assertEquals( 0,
                      incrementalBuildResults.getAddedMessages().size() );
        assertEquals( 0,
                      incrementalBuildResults.getRemovedMessages().size() );

        assertEquals( "Updated",
                      ruleNamesService.getRuleNames( resourcePath ).get( 0 ) );
        assertEquals( "Deleted",
                      ruleNamesService.getRuleNames( resourcePath ).get( 1 ) );
View Full Code Here

                      buildResults.getMessages().size() );

        //Perform incremental build
        buildChangeListener.updateResource( resourcePath );

        final IncrementalBuildResults incrementalBuildResults = buildResultsObserver.getIncrementalBuildResults();
        assertNotNull( incrementalBuildResults );
        assertEquals( 0,
                      incrementalBuildResults.getAddedMessages().size() );
        assertEquals( 0,
                      incrementalBuildResults.getRemovedMessages().size() );

        assertEquals( "Updated",
                      ruleNamesService.getRuleNames( resourcePath ).get( 0 ) );
        assertEquals( "Deleted",
                      ruleNamesService.getRuleNames( resourcePath ).get( 1 ) );
View Full Code Here

                      buildResults.getMessages().size() );

        //Perform incremental build (Without a full Build first)
        buildChangeListener.updateResource( resourcePath );

        final IncrementalBuildResults incrementalBuildResults = buildResultsObserver.getIncrementalBuildResults();
        assertNull( incrementalBuildResults );

    }
View Full Code Here

TOP

Related Classes of org.guvnor.common.services.project.builder.model.IncrementalBuildResults

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.