Package org.drools.guvnor.client.rpc

Examples of org.drools.guvnor.client.rpc.Asset


        asset2.checkin( "" );

        RuleModel model2 = new RuleModel();
        assertNull( model2.name );

        Asset asset = repositoryAssetService.loadRuleAsset( asset2.getUUID() );
        asset.setContent( (PortableObject) model2 );

        repositoryAssetService.checkinVersion( asset );

        asset = repositoryAssetService.loadRuleAsset( asset2.getUUID() );

        model2 = (RuleModel) asset.getContent();
        assertNotNull( model2 );
        assertNotNull( model2.name );
        assertEquals( asset2.getName(),
                      model2.name );
View Full Code Here


        //this should trigger the fact that the first user edited something
        AssetItem as = rulesRepository.loadDefaultModule().addAsset( "testLoadInbox",
                                                                                "" );
        as.checkin( "" );
        Asset ras = repositoryAssetService.loadRuleAsset( as.getUUID() );

        TableDataResult res = serviceImplementation.loadInbox( ExplorerNodeConfig.RECENT_EDITED_ID );
        boolean found = false;
        for ( TableDataRow row : res.data ) {
            if ( row.id.equals( ras.getUuid() ) ) found = true;
        }
        assertTrue( found );

        //but should not be in "incoming" yet
        found = false;
View Full Code Here

        String uuidLink = serviceImplementation.createNewImportedRule( "testLinkedAssetItemHistoryRelatedRule",
                                                      "testLinkedAssetItemHistoryRelatedPack" );
        assertTrue( uuidLink.equals( uuid ) );

        //create version 1.
        Asset assetWrapper = repositoryAssetService.loadRuleAsset( uuidLink );
        assertEquals( assetWrapper.getDescription(),
                      "an initial desc" );
        assetWrapper.setDescription( "version 1" );
        String uuidLink1 = repositoryAssetService.checkinVersion( assetWrapper );

        //create version 2
        Asset assetWrapper2 = repositoryAssetService.loadRuleAsset( uuidLink );
        assetWrapper2.setDescription( "version 2" );
        String uuidLink2 = repositoryAssetService.checkinVersion( assetWrapper2 );

        //create version head
        Asset assetWrapper3 = repositoryAssetService.loadRuleAsset( uuidLink );
        assetWrapper3.setDescription( "version head" );
        @SuppressWarnings("unused")
        String uuidLink3 = repositoryAssetService.checkinVersion( assetWrapper3 );

        assertEquals( uuidLink,
                      uuidLink1 );
        assertEquals( uuidLink,
                      uuidLink2 );

        //verify the history info of LinkedAssetItem
        TableDataResult result = repositoryAssetService.loadItemHistory( uuidLink );
        assertNotNull( result );
        TableDataRow[] rows = result.data;
        assertEquals( 4,
                      rows.length );
        assertFalse( rows[0].id.equals( uuidLink ) );
        assertFalse( rows[1].id.equals( uuidLink ) );
        assertFalse( rows[2].id.equals( uuidLink ) );

        Asset version1 = repositoryAssetService.loadRuleAsset( rows[0].id );
        Asset version2 = repositoryAssetService.loadRuleAsset( rows[1].id );
        Asset version3 = repositoryAssetService.loadRuleAsset( rows[2].id );
        Asset versionHead = repositoryAssetService.loadRuleAsset( uuidLink );
        assertFalse( version1.getVersionNumber() == version2.getVersionNumber() );
        assertFalse( version1.getVersionNumber() == versionHead.getVersionNumber() );
        assertEquals( version1.getDescription(),
                      "an initial desc" );
        assertEquals( version2.getDescription(),
                      "version 1" );
        assertEquals( version3.getDescription(),
                      "version 2" );
        assertEquals( versionHead.getDescription(),
                      "version head" );

        //verify the history info of the original AssetItem
        result = repositoryAssetService.loadItemHistory( uuid );
        assertNotNull( result );
        rows = result.data;
        assertEquals( 4,
                      rows.length );
        assertFalse( rows[0].id.equals( uuid ) );
        assertFalse( rows[1].id.equals( uuid ) );

        version1 = repositoryAssetService.loadRuleAsset( rows[0].id );
        version2 = repositoryAssetService.loadRuleAsset( rows[1].id );
        versionHead = repositoryAssetService.loadRuleAsset( uuid );
        assertFalse( version1.getVersionNumber() == version2.getVersionNumber() );
        assertFalse( version1.getVersionNumber() == versionHead.getVersionNumber() );
        assertTrue( version1.getDescription().equals( "an initial desc" ) );
        assertTrue( version2.getDescription().equals( "version 1" ) );
        assertTrue( versionHead.getDescription().equals( "version head" ) );

        //test restore
        repositoryAssetService.restoreVersion( version1.getUuid(),
                                               versionHead.getUuid(),
                                               "this was cause of a mistake" );

        Asset newHead = repositoryAssetService.loadRuleAsset( uuid );

        assertEquals( "this was cause of a mistake",
                      newHead.getCheckinComment() );
    }
View Full Code Here

        assertFalse( res.hasNext );

        TableDataRow row = res.data[0];
        String uuid = row.id;

        Asset asset = repositoryAssetService.loadRuleAsset( uuid );
        assertNotNull( asset );

        assertEquals( uuid,
                      asset.getUuid() );

        assertEquals( "description",
                      asset.getDescription() );

        assertNotNull( asset.getContent() );
        assertTrue( asset.getContent() instanceof RuleContentText );
        assertEquals( "testLoadRuleAsset",
                      asset.getName() );
        assertEquals( "testLoadRuleAsset",
                      asset.getMetaData().getTitle() );
        assertEquals( "testLoadRuleAsset",
                      asset.getMetaData().getModuleName() );
        assertEquals( AssetFormats.DRL,
                      asset.getFormat() );
        assertNotNull( asset.getDateCreated() );

        assertEquals( 1,
                      asset.getMetaData().getCategories().length );
        assertEquals( "testLoadRuleAsset",
                      asset.getMetaData().getCategories()[0] );

        AssetItem rule = rulesRepository.loadModule( "testLoadRuleAsset" ).loadAsset( "testLoadRuleAsset" );
        rulesRepository.createState("whee");
        rule.updateState("whee");
        rule.checkin("changed state");
        asset = repositoryAssetService.loadRuleAsset( uuid );

        assertEquals( "whee",
                      asset.getState() );
        assertEquals( "changed state",
                      asset.getCheckinComment() );

        uuid = serviceImplementation.createNewRule( "testBRLFormatSugComp",
                                   "description",
                                   "testLoadRuleAsset",
                                   "testLoadRuleAsset",
                                   AssetFormats.BUSINESS_RULE );
        asset = repositoryAssetService.loadRuleAsset( uuid );
        assertTrue(asset.getContent() instanceof RuleModel);

        uuid = serviceImplementation.createNewRule( "testLoadRuleAssetBRL",
                                   "description",
                                   "testLoadRuleAsset",
                                   "testLoadRuleAsset",
                                   AssetFormats.DSL_TEMPLATE_RULE );
        asset = repositoryAssetService.loadRuleAsset( uuid );
        assertTrue( asset.getContent() instanceof RuleContentText );
    }
View Full Code Here

                                          "testLoadAssetHistory",
                                          AssetFormats.DRL );
        long nowTime3 = System.currentTimeMillis();
        System.out.println( "CreateNewRule: " + (nowTime3 - nowTime2) );

        Asset asset = repositoryAssetService.loadRuleAsset( uuid );
        repositoryAssetService.checkinVersion( asset ); // 1
        long nowTime4 = System.currentTimeMillis();
        System.out.println( "Checkin 1: " + (nowTime4 - nowTime3) );
        asset = repositoryAssetService.loadRuleAsset( uuid );
        long nowTime5 = System.currentTimeMillis();
        System.out.println( "load ruleasset: " + (nowTime5 - nowTime4) );
        repositoryAssetService.checkinVersion( asset ); // 2
        long nowTime6 = System.currentTimeMillis();
        System.out.println( "Checkin 2: " + (nowTime6 - nowTime5) );
        asset = repositoryAssetService.loadRuleAsset( uuid );
        repositoryAssetService.checkinVersion( asset ); // HEAD

        TableDataResult result = repositoryAssetService.loadItemHistory( uuid );
        assertNotNull( result );
        TableDataRow[] rows = result.data;
        assertEquals( 3,
                      rows.length );
        assertFalse( rows[0].id.equals( uuid ) );
        assertFalse( rows[1].id.equals( uuid ) );

        Asset old = repositoryAssetService.loadRuleAsset( rows[0].id );
        Asset newer = repositoryAssetService.loadRuleAsset( rows[1].id );
        assertFalse( old.getVersionNumber() == newer.getVersionNumber() );

        Asset head = repositoryAssetService.loadRuleAsset( uuid );

        long oldVersion = old.getVersionNumber();
        assertFalse( oldVersion == head.getVersionNumber() );

        repositoryAssetService.restoreVersion( old.getUuid(),
                                               head.getUuid(),
                                               "this was cause of a mistake" );

        Asset newHead = repositoryAssetService.loadRuleAsset( uuid );

        assertEquals( "this was cause of a mistake",
                      newHead.getCheckinComment() );

    }
View Full Code Here

                                                         RulesRepository.DEFAULT_PACKAGE,
                                                         "testCopyAsset2" );
        assertNotSame( uuid,
                       uuid2 );

        Asset asset = repositoryAssetService.loadRuleAsset( uuid2 );
        assertNotNull( asset );
        assertEquals( RulesRepository.DEFAULT_PACKAGE,
                      asset.getMetaData().getModuleName() );
        assertEquals( "testCopyAsset2",
                      asset.getName() );
    }
View Full Code Here

        asset.updateFormat( AssetFormats.DRL );
        asset.updateContent( "rule 'MyGoodRule' \n when Personx() then System.err.println(42); \n end" );
        asset.checkin( "" );
        repo.save();

        Asset rule = repositoryAssetService.loadRuleAsset( asset.getUUID() );

        BuilderResult result = repositoryAssetService.validateAsset( rule );
        assertNotNull( result );
        assertEquals( -1,
                      result.getLines().get( 0 ).getMessage().indexOf( "Check log for" ) );
View Full Code Here

        asset.updateFormat( AssetFormats.DRL );
        asset.updateContent( "rule 'MyGoodRule' \n when Person() then System.err.println(42); \n end" );
        asset.checkin( "" );
        repo.save();

        Asset rule = repositoryAssetService.loadRuleAsset( asset.getUUID() );

        // check its all OK
        BuilderResult result = repositoryAssetService.validateAsset( rule );
        assertTrue(result.getLines().isEmpty());

        RuleBaseCache.getInstance().clearCache();

        // try it with a bad rule
        RuleContentText text = new RuleContentText();
        text.content = "rule 'MyBadRule' \n when Personx() then System.err.println(42); \n end";
        rule.setContent( text );

        result = repositoryAssetService.validateAsset( rule );
        assertNotNull( result );
        assertNotNull( result.getLines().get( 0 ).getMessage() );
        assertEquals( AssetFormats.DRL,
View Full Code Here

                                            "",
                                            "funkytest",
                                            "testBuildAssetMultipleFunctionsCallingEachOther",
                                            AssetFormats.FUNCTION );

        Asset t1 = repositoryAssetService.loadRuleAsset(uuidt1);
        RuleContentText t1Content = new RuleContentText();
        t1Content.content = "function void t1(){\n";
        t1Content.content += " t2();\n";
        t1Content.content += "}\n";
        t1.setContent( t1Content );
        repositoryAssetService.checkinVersion(t1);

        String uuidt2 = serviceImplementation.createNewRule( "t2",
                                            "",
                                            "funkytest",
                                            "testBuildAssetMultipleFunctionsCallingEachOther",
                                            AssetFormats.FUNCTION );
        Asset t2 = repositoryAssetService.loadRuleAsset( uuidt2 );
        RuleContentText t2Content = new RuleContentText();
        t2Content.content = "function void t2(){\n";
        t2Content.content += " t1();\n";
        t2Content.content += "}\n";
        t2.setContent( t2Content );
        repositoryAssetService.checkinVersion( t2 );

        BuilderResult result = repositoryAssetService.validateAsset( t1 );

        assertTrue(result.getLines().isEmpty());
View Full Code Here

                                          "",
                                          "brl",
                                          "testBuildAssetBRL",
                                          AssetFormats.BUSINESS_RULE );

        Asset rule = repositoryAssetService.loadRuleAsset( uuid );

        RuleModel m = (RuleModel) rule.getContent();
        assertNotNull( m );
        m.name = "testBRL";

        FactPattern p = new FactPattern( "Person" );
        p.setBoundName( "p" );
        SingleFieldConstraint con = new SingleFieldConstraint();
        con.setFieldName( "name" );
        con.setValue( "mark" );
        con.setOperator( "==" );
        con.setConstraintValueType( SingleFieldConstraint.TYPE_LITERAL );
        con.setFieldType( SuggestionCompletionEngine.TYPE_STRING );

        p.addConstraint( con );

        m.addLhsItem( p );

        ActionSetField set = new ActionSetField( "p" );
        ActionFieldValue f = new ActionFieldValue( "name",
                                                   "42-ngoo",
                                                   SuggestionCompletionEngine.TYPE_STRING );
        set.addFieldValue( f );

        m.addRhsItem( set );

        repositoryAssetService.checkinVersion( rule );

        // check its all OK
        BuilderResult result = repositoryAssetService.validateAsset( rule );
        assertTrue(result.getLines().isEmpty());

        List<AssetItem> assets = iteratorToList( pkg.getAssets() );
        assertEquals( 3,
                      assets.size() );
        // now lets copy...
        String newUUID = repositoryAssetService.copyAsset( rule.getUuid(),
                                                           rule.getMetaData().getModuleName(),
                                                           "ruleName2" );

        assets = iteratorToList( pkg.getAssets() );
        assertEquals( 4,
                      assets.size() ); //we have 4 due to the drools.package file.
        Asset asset = repositoryAssetService.loadRuleAsset( newUUID );

        String pkgSource = repositoryPackageService.buildModuleSource( pkg.getUUID() );

        assertTrue( pkgSource.indexOf( "ruleName2" ) > 0 );
        assertTrue( repositoryAssetService.buildAssetSource( asset ).indexOf( "ruleName2" ) > 0 );
View Full Code Here

TOP

Related Classes of org.drools.guvnor.client.rpc.Asset

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.