[ 
https://issues.apache.org/jira/browse/ISIS-648?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Dan Haywood updated ISIS-648:
-----------------------------

    Description: 
As originally described in http://markmail.org/message/7uqgptkwkspai276

~~~
The requirement is to be able to:
a) provide the ability for some actions to be bulk-only
b) provide a mechanism so that all objects selected to have a bulk action upon 
be able to interact with each other in the context of that action
    - for example, to pass information along
c) for the return type of a bulk action to be respected rather than ignore
    - because there are many such returns, only the value of the last one 
should be acted up

Tackling (a) first, that is an extension to the @Bulk annotation: 
@Bulk(BULK_AND_REGULAR) or @Bulk(BULK_ONLY)

For (b), enhance the existing @Bulk.InteractionContext class so that can put or 
get user data.

For (c), this is an enhancement to the Wicket viewer


~~~
As a worked example of how to use these capabilties: we want to be able to 
update a bunch of objects, which then add themselves to some sort of wizard.

public class ToDoItem {

    @Bulk(BULK_ONLY)
    public ToDoItemBulkChangeWizard bulkUpdate() {
        Bulk.InteractionContext ctxt = Bulk.InteractionContext.get();
        ToDoItemBulkChangeWizard wizard = 
(ToDoItemBulkChangeWizard)ctxt.getIserData("wizard");
        if(wizard == null) { 
            wizard = 
container.newViewModelInstance(ToDoItemBulkChangeWizard.class, new 
UUID().toString());
            ctxt.setUserData("wizard", wizard);
        }

        wizard.add(this);
        return wizard;       
    }

}


public class ToDoItemBulkChangeWizard extends AbstractViewModel {

    // viewModelInit() and viewModelMemento() omitted

    private List<ToDoItem> _items = Lists.newArrayList();
    public List<ToDoItem> getItems() { return _items; }

    @Programmatic
    public void add(ToDoItem item) { _items.add(item); }

    public ToDoItemBulkChangeWizard markAllAsCompleted() {
        for(ToDoItem item: _items) {
           item.complete();
        }
    }

    public ToDoItemBulkChangeWizard markAllAsNotYetCompleted() {
        for(ToDoItem item: _items) {
           item.notYetComplete();
        }
    }   
}


Note that the wizard above would need to serialize the _sites field somehow.  
The BookmarkServiceDefault (serialize each object to its oid string) and the 
ViewModelSupportDefault class (serialize a bunch of strings to a single string) 
should allow you to do this.



  was:
Perhaps as described in http://markmail.org/message/7uqgptkwkspai276



> Improve support for bulk update
> -------------------------------
>
>                 Key: ISIS-648
>                 URL: https://issues.apache.org/jira/browse/ISIS-648
>             Project: Isis
>          Issue Type: New Feature
>          Components: Core, Viewer: Wicket
>    Affects Versions: viewer-wicket-1.3.1, core-1.3.0
>            Reporter: Dan Haywood
>            Assignee: Dan Haywood
>             Fix For: viewer-wicket-1.4.0, core-1.4.0
>
>
> As originally described in http://markmail.org/message/7uqgptkwkspai276
> ~~~
> The requirement is to be able to:
> a) provide the ability for some actions to be bulk-only
> b) provide a mechanism so that all objects selected to have a bulk action 
> upon be able to interact with each other in the context of that action
>     - for example, to pass information along
> c) for the return type of a bulk action to be respected rather than ignore
>     - because there are many such returns, only the value of the last one 
> should be acted up
> Tackling (a) first, that is an extension to the @Bulk annotation: 
> @Bulk(BULK_AND_REGULAR) or @Bulk(BULK_ONLY)
> For (b), enhance the existing @Bulk.InteractionContext class so that can put 
> or get user data.
> For (c), this is an enhancement to the Wicket viewer
> ~~~
> As a worked example of how to use these capabilties: we want to be able to 
> update a bunch of objects, which then add themselves to some sort of wizard.
> public class ToDoItem {
>     @Bulk(BULK_ONLY)
>     public ToDoItemBulkChangeWizard bulkUpdate() {
>         Bulk.InteractionContext ctxt = Bulk.InteractionContext.get();
>         ToDoItemBulkChangeWizard wizard = 
> (ToDoItemBulkChangeWizard)ctxt.getIserData("wizard");
>         if(wizard == null) { 
>             wizard = 
> container.newViewModelInstance(ToDoItemBulkChangeWizard.class, new 
> UUID().toString());
>             ctxt.setUserData("wizard", wizard);
>         }
>         wizard.add(this);
>         return wizard;       
>     }
> }
> public class ToDoItemBulkChangeWizard extends AbstractViewModel {
>     // viewModelInit() and viewModelMemento() omitted
>     private List<ToDoItem> _items = Lists.newArrayList();
>     public List<ToDoItem> getItems() { return _items; }
>     @Programmatic
>     public void add(ToDoItem item) { _items.add(item); }
>     public ToDoItemBulkChangeWizard markAllAsCompleted() {
>         for(ToDoItem item: _items) {
>            item.complete();
>         }
>     }
>     public ToDoItemBulkChangeWizard markAllAsNotYetCompleted() {
>         for(ToDoItem item: _items) {
>            item.notYetComplete();
>         }
>     }   
> }
> Note that the wizard above would need to serialize the _sites field somehow.  
> The BookmarkServiceDefault (serialize each object to its oid string) and the 
> ViewModelSupportDefault class (serialize a bunch of strings to a single 
> string) should allow you to do this.



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)

Reply via email to