Package org.drools.guvnor.server.builder

Examples of org.drools.guvnor.server.builder.ContentPackageAssembler$ErrorLogger


        //impl.buildPackage(pkg.getUUID(), true);
        pkg.checkin( "version3" );

        //Verify the latest version
        PackageItem item = impl.getRulesRepository().loadPackage( "testGetHistoryPackageSource" );
        ContentPackageAssembler asm = new ContentPackageAssembler( item,
                                                                   false );
        String drl = asm.getDRL();

        System.out.println( drl );

        assertEquals( "version3",
                      item.getCheckinComment() );
        assertTrue( drl.indexOf( "global com.billasurf.Person customer2" ) >= 0 );
        assertTrue( drl.indexOf( "System.out.println(version 2)" ) >= 0 );
        assertTrue( drl.indexOf( "FooBarBaz2()" ) >= 0 );
        assertTrue( drl.indexOf( "rule 'foo' when Goo2() then end" ) >= 0 );
        assertTrue( drl.indexOf( "foo" ) >= 0 );
        assertTrue( drl.indexOf( "declare Album2" ) >= 0 );
        //assertEquals(12, item.getCompiledPackageBytes().length);

        //Verify version 2
        PackageItem item2 = impl.getRulesRepository().loadPackage( "testGetHistoryPackageSource",
                                                                   2 );
        ContentPackageAssembler asm2 = new ContentPackageAssembler( item2,
                                                                    false );
        String drl2 = asm2.getDRL();

        System.out.println( drl2 );

        assertEquals( "version2",
                      item2.getCheckinComment() );
View Full Code Here


                                                      SerializationException {
        RepositoryPackageOperations localRepositoryPackageOperations = initSpyingOnRealRepositoryPackageOperations();
        final String packageName = "packageName";
        PackageItem packageItem = mock( PackageItem.class );
        when( this.rulesRepository.loadPackage( packageName ) ).thenReturn( packageItem );
        ContentPackageAssembler contentPackageAssembler = mock( ContentPackageAssembler.class );
        doReturn( contentPackageAssembler ).when( localRepositoryPackageOperations ).createContentPackageAssembler( packageItem,
                                                                                                                    false );
        //doNothing().when( localRepositoryPackageOperations ).parseRulesToPackageList( contentPackageAssembler, new ArrayList<String>() );
        when( contentPackageAssembler.getDRL() ).thenReturn( null );
        assertArrayEquals( localRepositoryPackageOperations.listRulesInPackage( packageName ),
                           new String[]{} );
        verify( localRepositoryPackageOperations,
                never() ).parseRulesToPackageList( Mockito.any( ContentPackageAssembler.class ),
                                                   Mockito.anyList() );
View Full Code Here

                                                           SerializationException {
        RepositoryPackageOperations localRepositoryPackageOperations = initSpyingOnRealRepositoryPackageOperations();
        final String packageName = "packageName";
        PackageItem packageItem = mock( PackageItem.class );
        when( this.rulesRepository.loadPackage( packageName ) ).thenReturn( packageItem );
        ContentPackageAssembler contentPackageAssembler = mock( ContentPackageAssembler.class );
        doReturn( contentPackageAssembler ).when( localRepositoryPackageOperations ).createContentPackageAssembler( packageItem,
                                                                                                                    false );
        doNothing().when( localRepositoryPackageOperations ).parseRulesToPackageList( contentPackageAssembler,
                                                                                      new ArrayList<String>() );
        when( contentPackageAssembler.getDRL() ).thenReturn( "DRL" );
        assertArrayEquals( localRepositoryPackageOperations.listRulesInPackage( packageName ),
                           new String[]{} );
        verify( localRepositoryPackageOperations ).parseRulesToPackageList( Mockito.any( ContentPackageAssembler.class ),
                                                                            Mockito.anyList() );
View Full Code Here

                                    boolean isLatest,
                                    OutputStream out) throws IOException {
        PackageItem item = null;
        if ( isLatest ) {
            item = repository.loadPackage( packageName );
            ContentPackageAssembler asm = new ContentPackageAssembler( item,
                                                                       false );
            String drl = asm.getDRL();
            out.write( drl.getBytes() );
            out.flush();
            return packageName + ".drl";
        } else {
            item = repository.loadPackageSnapshot( packageName,
                                                   packageVersion );
            ContentPackageAssembler asm = new ContentPackageAssembler( item,
                                                                       false );
            String drl = asm.getDRL();
            out.write( drl.getBytes() );
            out.flush();
            return packageName + "_" + URLEncoder.encode( packageVersion,
                                                          "UTF-8" ) + ".drl";
        }
View Full Code Here

                                       String selectorConfigName) throws DetailedSerializableException {
        if ( !force && item.isBinaryUpToDate() ) {
            // we can just return all OK if its up to date.
            return null;
        }
        ContentPackageAssembler asm = new ContentPackageAssembler( item,
                                                                   true,
                                                                   buildMode,
                                                                   statusOperator,
                                                                   statusDescriptionValue,
                                                                   enableStatusSelector,
                                                                   categoryOperator,
                                                                   category,
                                                                   enableCategorySelector,
                                                                   selectorConfigName );
        if ( asm.hasErrors() ) {
            BuilderResult result = new BuilderResult();
            result.lines = generateBuilderResults( asm );
            return result;
        } else {
            try {
                ByteArrayOutputStream bout = new ByteArrayOutputStream();
                ObjectOutput out = new DroolsObjectOutputStream( bout );
                out.writeObject( asm.getBinaryPackage() );

                item.updateCompiledPackage( new ByteArrayInputStream( bout.toByteArray() ) );
                out.flush();
                out.close();
View Full Code Here

            Identity.instance().checkPermission( new PackageUUIDType( packageUUID ),
                                                 RoleTypes.PACKAGE_DEVELOPER );
        }

        PackageItem item = repository.loadPackageByUUID( packageUUID );
        ContentPackageAssembler asm = new ContentPackageAssembler( item,
                                                                   false );
        return asm.getDRL();
    }
View Full Code Here

            if ( handler instanceof IValidating ) {
                return ((IValidating) handler).validateAsset( item );
            } else {

                ContentPackageAssembler asm = new ContentPackageAssembler( item );
                if ( !asm.hasErrors() ) {
                    return null;
                } else {
                    result.lines = generateBuilderResults( asm );
                }
            }
View Full Code Here

        }

        // load package
        PackageItem item = repository.loadPackage( packageName );

        ContentPackageAssembler asm = new ContentPackageAssembler( item,
                                                                   false );

        List<String> result = new ArrayList<String>();
        try {

            String drl = asm.getDRL();
            if ( drl == null || "".equals( drl ) ) {
                return new String[0];
            } else {
                int count = 0;

                StringTokenizer st = new StringTokenizer( asm.getDRL(),
                                                          "\n\r" );
                while ( st.hasMoreTokens() ) {
                    String line = st.nextToken().trim();
                    if ( line.startsWith( "rule " ) ) {
                        String name = getRuleName( line );
View Full Code Here

                                    boolean isLatest,
                                    OutputStream out) throws IOException {
        PackageItem item = null;
        if ( isLatest ) {
            item = repository.loadPackage( packageName );
            ContentPackageAssembler asm = new ContentPackageAssembler( item,
                                                                       false );
            String drl = asm.getDRL();
            out.write( drl.getBytes() );
            out.flush();
            return packageName + ".drl";
        } else {
            item = repository.loadPackageSnapshot( packageName,
                                                   packageVersion );
            ContentPackageAssembler asm = new ContentPackageAssembler( item,
                                                                       false );
            String drl = asm.getDRL();
            out.write( drl.getBytes() );
            out.flush();
            return packageName + "_" + URLEncoder.encode( packageVersion,
                                                          "UTF-8" ) + ".drl";
        }
View Full Code Here

                                       String selectorConfigName) throws DetailedSerializationException {
        if ( !force && item.isBinaryUpToDate() ) {
            // we can just return all OK if its up to date.
            return null;
        }
        ContentPackageAssembler asm = new ContentPackageAssembler( item,
                                                                   true,
                                                                   buildMode,
                                                                   statusOperator,
                                                                   statusDescriptionValue,
                                                                   enableStatusSelector,
                                                                   categoryOperator,
                                                                   category,
                                                                   enableCategorySelector,
                                                                   selectorConfigName );
        if ( asm.hasErrors() ) {
            BuilderResult result = new BuilderResult();
            result.lines = generateBuilderResults( asm );
            return result;
        } else {
            try {
                ByteArrayOutputStream bout = new ByteArrayOutputStream();
                ObjectOutput out = new DroolsObjectOutputStream( bout );
                out.writeObject( asm.getBinaryPackage() );

                item.updateCompiledPackage( new ByteArrayInputStream( bout.toByteArray() ) );
                out.flush();
                out.close();
View Full Code Here

TOP

Related Classes of org.drools.guvnor.server.builder.ContentPackageAssembler$ErrorLogger

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.