Package org.drools.repository

Examples of org.drools.repository.AssetHistoryIterator


        if ( Contexts.isSessionContextActive() ) {
            Identity.instance().checkPermission( new PackageUUIDType( item.getPackage().getUUID() ),
                                                 RoleTypes.PACKAGE_READONLY );
        }

        AssetHistoryIterator it = item.getHistory();

        // MN Note: this uses the lazy iterator, but then loads the whole lot
        // up, and returns it.
        // The reason for this is that the GUI needs to show things in numeric
        // order by the version number.
        // When a version is restored, its previous version is NOT what you
        // thought it was - due to how JCR works
        // (its more like CVS then SVN). So to get a linear progression of
        // versions, we use the incrementing version number,
        // and load it all up and sort it. This is not ideal.
        // In future, we may do a "restore" instead just by copying content into
        // a new version, not restoring a node,
        // in which case the iterator will be in order (or you can just walk all
        // the way back).
        // So if there are performance problems with looking at lots of
        // historical versions, look at this nasty bit of code.
        while ( it.hasNext() ) {
            AssetItem historical = (AssetItem) it.next();// new
            // AssetItem(repo,
            // element);
            long versionNumber = historical.getVersionNumber();
            if ( !(versionNumber == 0) && !(versionNumber == item.getVersionNumber()) ) {
                TableDataRow row = new TableDataRow();
View Full Code Here


        RepositoryAssetOperations repositoryAssetOperations = new RepositoryAssetOperations();
        repositoryAssetOperations.setRulesRepositoryForTest(rulesRepository);

        AssetItem assetItem = mock( AssetItem.class );

        AssetHistoryIterator assetHistoryIterator = mock( AssetHistoryIterator.class );
        when( assetItem.getHistory() ).thenReturn( assetHistoryIterator );
        Calendar calendar = GregorianCalendar.getInstance();
        when( assetItem.getLastModified() ).thenReturn( calendar );

        TableDataResult result = repositoryAssetOperations.loadItemHistory( assetItem );
View Full Code Here

        RepositoryAssetOperations repositoryAssetOperations = new RepositoryAssetOperations();
        repositoryAssetOperations.setRulesRepositoryForTest(rulesRepository);

        AssetItem assetItem = initializeAssetItemMockForLoadAssetHistory();

        AssetHistoryIterator assetHistoryIterator = mock( AssetHistoryIterator.class );
        when( assetItem.getHistory() ).thenReturn( assetHistoryIterator );
        when( assetHistoryIterator.hasNext() ).thenReturn( true,
                                                           false );
        AssetItem historicalAssetItem = initializeAssetItemHistoryMockForLoadAssetHistory( assetHistoryIterator );
        when( historicalAssetItem.getVersionNumber() ).thenReturn( 1324567L );
        Calendar calendar = GregorianCalendar.getInstance();
        when( historicalAssetItem.getLastModified() ).thenReturn( calendar );
View Full Code Here

        RepositoryAssetOperations repositoryAssetOperations = new RepositoryAssetOperations();
        repositoryAssetOperations.setRulesRepositoryForTest(rulesRepository);

        AssetItem assetItem = initializeAssetItemMockForLoadAssetHistory();

        AssetHistoryIterator assetHistoryIterator = mock( AssetHistoryIterator.class );
        when( assetItem.getHistory() ).thenReturn( assetHistoryIterator );
        when( assetHistoryIterator.hasNext() ).thenReturn( true,
                                                           false );

        AssetItem historicalAssetItem = initializeAssetItemHistoryMockForLoadAssetHistory( assetHistoryIterator );
        when( historicalAssetItem.getVersionNumber() ).thenReturn( 123456L );
View Full Code Here

            } else {
                base = uriInfo.getBaseUriBuilder().path("packages").path(asset.getPackageName()).path("assets").path(asset.getName()).path("versions");
            }
            f.setBaseUri(base.build().toString());
                       
            AssetHistoryIterator it = asset.getHistory();
            while (it.hasNext()) {
                    AssetItem historicalAsset = it.next();
                    if (historicalAsset.getVersionNumber() != 0) {
                        Entry e = factory.getAbdera().newEntry();
                        e.setTitle(Long.toString(historicalAsset
                                .getVersionNumber()));
                        e.setUpdated(historicalAsset.getLastModified().getTime());
View Full Code Here

                        .path("packages/{packageName}/assets/{assetName}/versions")
                        .build(asset.getModuleName(), asset.getName());
            }
            f.setBase(base);
                       
            AssetHistoryIterator it = asset.getHistory();
            while (it.hasNext()) {
                AssetItem historicalAsset = it.next();
                if (historicalAsset.getVersionNumber() != 0) {
                    Entry e = new Entry();
                    e.setTitle(Long.toString(historicalAsset
                            .getVersionNumber()));
                    e.setUpdated(historicalAsset.getLastModified().getTime());
View Full Code Here

                    Text r = new Text();
                    r.data = "";
                    return r;
                }
                if (version.equals("all")) {
                    AssetHistoryIterator it =  asset.getHistory();
                    StringBuilder buf = new StringBuilder();
                    while(it.hasNext()) {

                        AssetItem h = it.next();

                        if (h.getVersionNumber() != 0) {
                            String checkinComment = h.getCheckinComment();
                            //String lastMo ... hmm what is needed?
                            String lastMofiedBy = h.getLastContributor();
                            if (lastMofiedBy == null || lastMofiedBy.equals("")) {
                                lastMofiedBy = asset.getCreator();
                            }
                            SimpleDateFormat sdf = getISODateFormat();
                            Calendar lastModDate = h.getLastModified();
                            if (lastModDate == null ) {
                                lastModDate = asset.getCreatedDate();
                            }
                            String lastModifiedOn = sdf.format(lastModDate.getTime());
                            buf.append(h.getVersionNumber());
                            buf.append("=");
                            buf.append(lastModifiedOn + "," + lastMofiedBy + "," + checkinComment);
                            if (it.hasNext()) {
                                buf.append('\n');
                            }
                        }

                    }
                    Text r = new Text();
                    r.lastModified = asset.getLastModified();
                    r.data = buf.toString();
                    return r;
                } else {
                    long versionNumber = Long.parseLong(version);
                    AssetHistoryIterator it =  asset.getHistory();
                    while (it.hasNext()) {
                        AssetItem h = it.next();
                        if (h.getVersionNumber() == versionNumber) {
                            return buildAssetContentResponse(pkg, h);
                        }
                    }
                    //hmm... we didn't find it
View Full Code Here

                        .path("packages/{packageName}/assets/{assetName}/versions")
                        .build(asset.getPackageName(), asset.getName());
            }
            f.setBaseUri(base.toString());
                       
            AssetHistoryIterator it = asset.getHistory();
            while (it.hasNext()) {
                    AssetItem historicalAsset = it.next();
                    if (historicalAsset.getVersionNumber() != 0) {
                        Entry e = factory.getAbdera().newEntry();
                        e.setTitle(Long.toString(historicalAsset
                                .getVersionNumber()));
                        e.setUpdated(historicalAsset.getLastModified().getTime());
View Full Code Here

        if ( Contexts.isSessionContextActive() ) {
            Identity.instance().checkPermission( new PackageUUIDType( item.getPackage().getUUID() ), RoleTypes.PACKAGE_READONLY );
        }

        AssetHistoryIterator it = item.getHistory();

        // MN Note: this uses the lazy iterator, but then loads the whole lot
        // up, and returns it.
        // The reason for this is that the GUI needs to show things in numeric
        // order by the version number.
        // When a version is restored, its previous version is NOT what you
        // thought it was - due to how JCR works
        // (its more like CVS then SVN). So to get a linear progression of
        // versions, we use the incrementing version number,
        // and load it all up and sort it. This is not ideal.
        // In future, we may do a "restore" instead just by copying content into
        // a new version, not restoring a node,
        // in which case the iterator will be in order (or you can just walk all
        // the way back).
        // So if there are performance problems with looking at lots of
        // historical versions, look at this nasty bit of code.
        while ( it.hasNext() ) {
            AssetItem historical = (AssetItem) it.next();
            long versionNumber = historical.getVersionNumber();
            if ( isHistory( item, versionNumber ) ) {
                result.add( createHistoricalRow( result, historical ) );
            }
        }
View Full Code Here

        RepositoryAssetOperations repositoryAssetOperations = new RepositoryAssetOperations();
        repositoryAssetOperations.setRulesRepository( rulesRepository );

        AssetItem assetItem = mock( AssetItem.class );

        AssetHistoryIterator assetHistoryIterator = mock( AssetHistoryIterator.class );
        when( assetItem.getHistory() ).thenReturn( assetHistoryIterator );
        Calendar calendar = GregorianCalendar.getInstance();
        when( assetItem.getLastModified() ).thenReturn( calendar );

        TableDataResult result = repositoryAssetOperations.loadItemHistory( assetItem );
View Full Code Here

TOP

Related Classes of org.drools.repository.AssetHistoryIterator

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.