Package org.drools.guvnor.client.rpc

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


        return userName;
    }

    protected RuleAsset loadAsset(AssetItem item) throws SerializationException {

        RuleAsset asset = new RuleAsset();
        asset.setUuid( item.getUUID() );
        asset.setName( item.getName() );
        asset.setDescription( item.getDescription() );
        asset.setLastModified( item.getLastModified().getTime() );
        asset.setLastContributor( item.getLastContributor() );
        asset.setState( (item.getState() != null) ? item.getState().getName() : "" );
        asset.setDateCreated( item.getCreatedDate().getTime() );
        asset.setCheckinComment( item.getCheckinComment() );
        asset.setVersionNumber( item.getVersionNumber() );

        asset.setMetaData( populateMetaData( item ) );
        ContentHandler handler = ContentManager.getHandler( asset.getMetaData().getFormat() );
        handler.retrieveAssetContent( asset,
                                      item );

        return asset;
    }
View Full Code Here


import org.drools.guvnor.client.rpc.RuleAsset;
import org.drools.repository.AssetItem;

public class RuleAssetPopulator {
    public RuleAsset populateFrom(final AssetItem assetItem) {
        RuleAsset ruleAsset = new RuleAsset();
        ruleAsset.setUuid( assetItem.getUUID() );
        ruleAsset.setName( assetItem.getName() );
        ruleAsset.setDescription( assetItem.getDescription() );
        ruleAsset.setLastModified( assetItem.getLastModified().getTime() );
        ruleAsset.setLastContributor( assetItem.getLastContributor() );
        ruleAsset.setState( (assetItem.getState() != null) ? assetItem.getState().getName() : "" );
        ruleAsset.setDateCreated( assetItem.getCreatedDate().getTime() );
        ruleAsset.setCheckinComment( assetItem.getCheckinComment() );
        ruleAsset.setVersionNumber( assetItem.getVersionNumber() );
        return ruleAsset;
    }
View Full Code Here

                throw new ServletException( new IllegalArgumentException( "The load action requires the parameter uuid" ) );
            }
            ServletOutputStream outputStream = response.getOutputStream();

            try {
                RuleAsset asset = RepositoryServiceServlet.getAssetService().loadRuleAsset( uuid );
                if ( asset.getContent() != null ) {
                    response.setContentType( "application/json" );
                    String content = null;
                    if ( asset.getContent() instanceof RuleFlowContentModel ) {
                        content = ((RuleFlowContentModel) asset.getContent()).getXml();
                    } else {
                        content = asset.getContent().toString();
                    }
                    try {
                        // TODO fix for non-localhost <---- Can someone please describe what is problem so it can be fixed?
                        content = deserialize( "http://localhost:8080/designer/bpmn2_0deserialization",
                                               content );
View Full Code Here

        }

        log.debug("Successful login");

        try {
            RuleAsset asset = RepositoryServiceServlet.getAssetService().loadRuleAsset(uuid);
            if (asset.getContent() != null) {
                response.setContentType("application/xml");
                response.setCharacterEncoding("UTF-8");
                String content = asset.getContent().toString();
                if (asset.getContent() instanceof RuleFlowContentModel) {
                    content = ((RuleFlowContentModel) asset.getContent()).getXml();
                } else {
                    content = asset.getContent().toString();
                }
                if (content != null) {
                    response.getOutputStream().write(content.getBytes("UTF-8"));
                    response.getOutputStream().close();
                } else {
View Full Code Here

        return assets.toArray(new RuleAsset[assets.size()]);
    }

    private RuleAsset createAsset(RuleModel ruleModel) {
        RuleAsset asset = new RuleAsset();

        asset.setUuid("mock");
        asset.setContent(ruleModel);
        asset.setName(ruleModel.name);
        asset.setMetaData(createMetaData());

        return asset;
    }
View Full Code Here

                                                "s",
                                                "sc",
                                                pkg.getName(),
                                                AssetFormats.TEST_SCENARIO );
        RepositoryAssetService repositoryAssetService = getRepositoryAssetService();
        RuleAsset asset = repositoryAssetService.loadRuleAsset( scenarioId );
        assertNotNull( asset.content );
        assertTrue( asset.content instanceof Scenario );

        Scenario sc_ = (Scenario) asset.content;
        sc_.getFixtures().add( new ExecutionTrace() );
View Full Code Here

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

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

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

        //create version head
        RuleAsset assetWrapper3 = repositoryAssetService.loadRuleAsset( uuidLink );
        assetWrapper3.description= "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( 3,
                      rows.length );
        assertFalse( rows[0].id.equals( uuidLink ) );
        assertFalse( rows[1].id.equals( uuidLink ) );
        assertFalse( rows[2].id.equals( uuidLink ) );

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

        //verify the history info of the original AssetItem
        result = repositoryAssetService.loadItemHistory( uuid );
        assertNotNull( result );
        rows = result.data;
        assertEquals( 3,
                      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.versionNumber == version2.versionNumber );
        assertFalse( version1.versionNumber == versionHead.versionNumber );
        assertTrue( version1.description.equals( "an initial desc" ) );
        assertTrue( version2.description.equals( "version 1" ) );
        assertTrue( versionHead.description.equals( "version head" ) );

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

        RuleAsset newHead = repositoryAssetService.loadRuleAsset( uuid );

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

        assertFalse( res.hasNext );

        TableDataRow row = res.data[0];
        String uuid = row.id;
        RepositoryAssetService repositoryAssetService = getRepositoryAssetService();
        RuleAsset asset = repositoryAssetService.loadRuleAsset( uuid );
        assertNotNull( asset );

        assertEquals( uuid,
                      asset.uuid );
View Full Code Here

                                          "testLoadAssetHistory",
                                          AssetFormats.DRL );
        long nowTime3 = System.currentTimeMillis();
        System.out.println( "CreateNewRule: " + (nowTime3 - nowTime2) );
        RepositoryAssetService repositoryAssetService = getRepositoryAssetService();
        RuleAsset 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( 2,
                      rows.length );
        assertFalse( rows[0].id.equals( uuid ) );
        assertFalse( rows[1].id.equals( uuid ) );

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

        RuleAsset head = repositoryAssetService.loadRuleAsset( uuid );

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

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

        RuleAsset newHead = repositoryAssetService.loadRuleAsset( uuid );

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

    }
View Full Code Here

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

        RuleAsset asset = repositoryAssetService.loadRuleAsset( uuid2 );
        assertNotNull( asset );
        assertEquals( RulesRepository.DEFAULT_PACKAGE,
                      asset.metaData.packageName );
        assertEquals( "testCopyAsset2",
                      asset.name );
View Full Code Here

TOP

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

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.