Package org.drools.guvnor.client.rpc

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


        if ( !AssetFormats.BUSINESS_RULE.equals( jcrAssetItem.getFormat() ) ) {
            throw new IllegalArgumentException( "The jcrAsset (" + jcrAssetItem.getName() + ") has the wrong format (" + jcrAssetItem.getFormat() + ")." );
        }

        try {
            Asset jcrAsset = jcrRepositoryAssetService.loadRuleAsset( jcrAssetItem.getUUID() );

            RuleModel ruleModel = getBrlXmlPersistence().unmarshal( jcrAssetItem.getContent() );

            Path path = null;
            if ( ruleModel.hasDSLSentences() ) {
View Full Code Here


    public Asset[] getRuleAssets() throws DetailedSerializationException {
        try {
            //creates a new empty asset with the given name and format in the
            //given package.
            String ruleUUID = serviceImplementation.createNewRule(assetName, "created by standalone editor", categoryName, packageName, this.assetFormat);
            Asset newRule = repositoryAssetService.loadRuleAsset(ruleUUID);

            return new Asset[]{newRule};
        } catch (SerializationException ex) {
            throw new DetailedSerializationException("Error creating rule asset", ex.getMessage());
        }
View Full Code Here

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

public class AssetPopulator {
    public Asset populateFrom(final AssetItem assetItem) {
        Asset ruleAsset = new Asset();
        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() );
        ruleAsset.setFormat(assetItem.getFormat());
        ruleAsset.setArchived(assetItem.isArchived());
        return ruleAsset;
    }
View Full Code Here

            throw new ServletException(new IllegalArgumentException("Unable to authenticate user."));
        }
        log.debug("Successful login");

        try {
            Asset asset = repositoryAssetService.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();
                }

                if (content != null) {
                    response.getOutputStream().write(content.getBytes("UTF-8"));
                    response.getOutputStream().close();
View Full Code Here

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

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

        asset.setUuid("mock-" + UUID.randomUUID().toString());
        asset.setContent(ruleModel);
        asset.setName(ruleModel.name);
        asset.setFormat(AssetFormats.BUSINESS_RULE);
        asset.setMetaData(createMetaData());
        asset.setState("temporal");

        return asset;
    }
View Full Code Here

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

            try {
                Asset asset = repositoryAssetService.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 {
                        content = deserialize( getDesignerURL()+"/bpmn2_0deserialization",
                                               content );
                    } catch ( IOException e ) {
View Full Code Here

           
            List<Asset> result = new ArrayList<Asset>();
           
            //for validFacts we need to create a temporal Working Set RuleAsset
            if (validFacts != null && validFacts.length > 0){
                final Asset workingSet = new Asset();
                workingSet.setUuid( "workingSetMock"+UUID.randomUUID().toString() );
           
                WorkingSetConfigData wsConfig = new WorkingSetConfigData();
                wsConfig.validFacts = validFacts;
           
                workingSet.setContent( wsConfig );
               
                result.add(workingSet);
            }
           
            //for each xml working set definition we need to unmarshall it
            //to WorkingSetConfigData and create a Working Set Rule Asset
            if (xmlDefinitions != null && xmlDefinitions.length > 0){
                //Unmarshal each definition and put it in the list
                XStream xt = new XStream(new DomDriver());
               
                for (String xml : xmlDefinitions) {
                    WorkingSetConfigData workingSetConfigData = (WorkingSetConfigData)xt.fromXML(xml);

                    final Asset workingSet = new Asset();
                    workingSet.setUuid( "workingSetMock"+UUID.randomUUID().toString() );

                    workingSet.setContent( workingSetConfigData );

                    result.add(workingSet);
                }
            }
           
View Full Code Here

    public Asset loadRuleAsset(String uuid) throws SerializationException {

        long time = System.currentTimeMillis();

        AssetItem item = rulesRepository.loadAssetByUUID( uuid );
        Asset asset = new AssetPopulator().populateFrom( item );

        asset.setMetaData( repositoryAssetOperations.populateMetaData( item ) );

        serviceSecurity.checkIsPackageReadOnlyOrAnalystReadOnly( asset );
        ModuleItem pkgItem = handlePackageItem( item,
                                                asset );
View Full Code Here

                                     packageName,
                                     format );

        //Set the Table Format and check-in
        //TODO Is it possible to alter the content and save without checking-in?
        Asset asset = repositoryAssetService.loadRuleAsset( uuid );
        GuidedDecisionTable52 content = (GuidedDecisionTable52) asset.getContent();
        content.setTableFormat( configuration.getTableFormat() );
        asset.setCheckinComment( "Table Format automatically set to [" + configuration.getTableFormat().toString() + "]" );
        repositoryAssetService.checkinVersion( asset );

        return uuid;
    }
View Full Code Here

        return userName;
    }

    protected Asset loadAsset(AssetItem item) throws SerializationException {

        Asset asset = new Asset();
        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.setFormat(item.getFormat());

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

        return asset;
    }
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.