Package org.drools.repository

Examples of org.drools.repository.AssetItemIterator


        AssetItem a1 = mock( AssetItem.class );
        when( a1.getFormat() ).thenReturn( "formatInList" );
        when( a1.getCreatedDate() ).thenReturn( Calendar.getInstance() );
        when( a1.getLastModified() ).thenReturn( Calendar.getInstance() );

        AssetItemIterator assetItemIterator = mock( AssetItemIterator.class );
        when( assetItemIterator.hasNext() ).thenReturn( true,
                                                        false );
        when( assetItemIterator.next() ).thenReturn( a1 );

        when( packageItem.listAssetsByFormat( assetPageRequest.getFormatInList() ) ).thenReturn( assetItemIterator );

        PageResponse<AssetPageRow> pageResponse = repositoryAssetOperations.findAssetPage( assetPageRequest );
View Full Code Here


        AssetItem a1 = mock( AssetItem.class );
        when( a1.getFormat() ).thenReturn( "formatNotInList" );
        when( a1.getCreatedDate() ).thenReturn( Calendar.getInstance() );
        when( a1.getLastModified() ).thenReturn( Calendar.getInstance() );

        AssetItemIterator assetItemIterator = mock( AssetItemIterator.class );
        when( assetItemIterator.hasNext() ).thenReturn( true,
                                                        false );
        when( assetItemIterator.next() ).thenReturn( a1 );

        String[] registeredFormats = registeredFormats();

        when( packageItem.listAssetsNotOfFormat( registeredFormats ) )
                .thenReturn( assetItemIterator );
View Full Code Here

        assertTrue( referredItem.getCategories().size() == 1 );
        assertTrue( referredItem.getCategorySummary().contains( "testCreateNewRuleAsLinkCat1" ) );

        //now verify AssetItemIterator works by calling search
        AssetItemIterator it = impl.getRulesRepository().findAssetsByName( "testCreateLinkedAssetItemRule%",
                                                                           true );
        //NOTE, getSize() may return -1
        /*       assertEquals( 1,
                             it.getSize() );*/
        int size = 0;
        while ( it.hasNext() ) {
            size++;
            AssetItem ai = it.next();
            if ( ai.getUUID().equals( uuid ) ) {
                assertEquals( ai.getPackage().getName(),
                              "globalArea" );
                assertEquals( ai.getDescription(),
                              "an initial desc" );
View Full Code Here

    /**
     * Load up all the DSL mappping files for the given package.
     */
    public static List<DSLTokenizedMappingFile> getDSLMappingFiles(PackageItem pkg, DSLErrorEvent err) {
        List<DSLTokenizedMappingFile> result = new ArrayList<DSLTokenizedMappingFile>();
        AssetItemIterator it = pkg.listAssetsByFormat( new String[]{AssetFormats.DSL} );
        while ( it.hasNext() ) {
            AssetItem item = it.next();
            if (!item.getDisabled()) {
                String dslData = item.getContent();
                DSLTokenizedMappingFile file = new DSLTokenizedMappingFile();
                try {
                    if ( file.parseAndLoad( new StringReader( dslData ) ) ) {
View Full Code Here

    /**
     * Load up all the Jars for the given package.
     */
    public static List<JarInputStream> getJars(PackageItem pkg) {
        List<JarInputStream> result = new ArrayList<JarInputStream>();
        AssetItemIterator ait = pkg.listAssetsByFormat( new String[]{AssetFormats.MODEL} );
        while ( ait.hasNext() ) {
            AssetItem item = (AssetItem) ait.next();
            if ( item.getBinaryContentAttachment() != null ) {
                try {
                    result.add( new JarInputStream( item.getBinaryContentAttachment(),
                                                    false ) );
                } catch ( IOException e ) {
View Full Code Here

    /**
     * Load all the .properties and .conf files into one big happy Properties instance.
     */
    Properties loadConfProperties(PackageItem pkg) throws IOException {
        Properties ps = new Properties();
        AssetItemIterator iter = pkg.listAssetsByFormat(new String[] {"properties", "conf"});
        while(iter.hasNext()) {
            AssetItem conf = iter.next();
            conf.getContent();
            Properties p = new Properties();
            p.load(conf.getBinaryContentAttachment());
            ps.putAll(p);
        }
View Full Code Here

    }

    loadDSLFiles();

    // finally, any functions we will load at this point.
    AssetItemIterator it = this.pkg
        .listAssetsByFormat(new String[] { AssetFormats.FUNCTION });
   
        // Adds the function DRLs as one string because they might be calling each others.
        StringBuilder stringBuilder = new StringBuilder();
        while ( it.hasNext() ) {
            AssetItem func = it.next();
            if ( !func.getDisabled() ) {
                stringBuilder.append( func.getContent() );
            }
        }
        addDrl( stringBuilder.toString() );
        // If the function part had errors we need to add them one by one to find out which one is bad.
        if ( builder.hasErrors() ) {
            builder.clearErrors();
            it = this.pkg.listAssetsByFormat( new String[]{AssetFormats.FUNCTION} );
            while ( it.hasNext() ) {
                AssetItem func = it.next();
                if ( !func.getDisabled() ) {
                    addDrl( func.getContent() );
                    if ( builder.hasErrors() ) {
                        recordBuilderErrors( func );
                        builder.clearErrors();
View Full Code Here

        return errors.size() == 0;
  }

  private void loadDeclaredTypes() {
    AssetItemIterator it = this.pkg
        .listAssetsByFormat(new String[] { AssetFormats.DRL_MODEL });
    while (it.hasNext()) {
      AssetItem as = it.next();
            if (!as.getDisabled()) {
                try {
                    String content = as.getContent();
                    if (nonEmpty(content)) {
                        builder.addPackageFromDrl(new StringReader(as.getContent()));
View Full Code Here

            errors.add(new ContentAssemblyError(asset, message));
          }
        }));

    // do the functions and declared types.
    AssetItemIterator it = this.pkg.listAssetsByFormat(new String[] {
        AssetFormats.FUNCTION, AssetFormats.DRL_MODEL });
    while (it.hasNext()) {
      AssetItem func = it.next();
      if (!func.isArchived() && !func.getDisabled()) {
                src.append(func.getContent()).append("\n\n");
      }
    }
View Full Code Here

        }
    }

    private void addToRulesVerifier() {

        AssetItemIterator rules = packageItem.listAssetsByFormat( AssetFormats.BUSINESS_RULE_FORMATS );

        while ( rules.hasNext() ) {
            AssetItem rule = rules.next();

            ContentHandler contentHandler = ContentManager.getHandler( rule.getFormat() );
            if ( contentHandler.isRuleAsset() ) {
                IRuleAsset ruleAsset = (IRuleAsset) contentHandler;
                String drl = ruleAsset.getRawDRL( rule );
View Full Code Here

TOP

Related Classes of org.drools.repository.AssetItemIterator

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.