Clover Coverage Report - Kuali Student 1.2-M6-SNAPSHOT (Aggregated)
Coverage timestamp: Mon Sep 12 2011 05:03:53 EDT
../../../../../../../../../img/srcFileCovDistChart0.png 42% of files have more coverage
48   139   10   6.86
6   110   0.21   7
7     1.43  
1    
 
  SelectVersionsView       Line # 33 48 0% 10 61 0% 0.0
 
No Tests
 
1    package org.kuali.student.lum.lu.ui.course.client.views;
2   
3    import java.util.ArrayList;
4    import java.util.List;
5   
6    import org.kuali.student.common.assembly.data.LookupMetadata;
7    import org.kuali.student.common.assembly.data.Metadata;
8    import org.kuali.student.common.assembly.data.QueryPath;
9    import org.kuali.student.common.search.dto.SearchParam;
10    import org.kuali.student.common.search.dto.SearchRequest;
11    import org.kuali.student.common.search.dto.SortDirection;
12    import org.kuali.student.common.ui.client.application.ViewContext;
13    import org.kuali.student.common.ui.client.configurable.mvc.SectionTitle;
14    import org.kuali.student.common.ui.client.mvc.Callback;
15    import org.kuali.student.common.ui.client.mvc.ViewComposite;
16    import org.kuali.student.common.ui.client.mvc.history.HistoryManager;
17    import org.kuali.student.common.ui.client.service.MetadataRpcService;
18    import org.kuali.student.common.ui.client.service.MetadataRpcServiceAsync;
19    import org.kuali.student.common.ui.client.widgets.KSButton;
20    import org.kuali.student.common.ui.client.widgets.KSButtonAbstract.ButtonStyle;
21    import org.kuali.student.common.ui.client.widgets.field.layout.button.ButtonLayout;
22    import org.kuali.student.common.ui.client.widgets.field.layout.layouts.VerticalFieldLayout;
23    import org.kuali.student.common.ui.client.widgets.search.SearchResultsTable;
24    import org.kuali.student.common.ui.shared.IdAttributes.IdType;
25    import org.kuali.student.lum.common.client.widgets.AppLocations;
26    import org.kuali.student.lum.lu.ui.course.client.controllers.VersionsController;
27   
28    import com.google.gwt.core.client.GWT;
29    import com.google.gwt.event.dom.client.ClickEvent;
30    import com.google.gwt.event.dom.client.ClickHandler;
31    import com.google.gwt.user.client.Window;
32   
 
33    public class SelectVersionsView extends ViewComposite{
34   
35   
36    private VerticalFieldLayout layout = new VerticalFieldLayout();
37    //private KSDocumentHeader header = new KSDocumentHeader();
38    private ButtonLayout buttons = new ButtonLayout();
39    SearchResultsTable table = new SearchResultsTable();
40    MetadataRpcServiceAsync metadataServiceAsync = GWT.create(MetadataRpcService.class);
41    private String id1;
42    private String id2;
43   
44    private VersionsController parent;
45   
 
46  0 toggle public SelectVersionsView(VersionsController controller, String name,
47    Enum<?> viewType) {
48  0 super(controller, name, viewType);
49  0 this.initWidget(layout);
50  0 layout.addStyleName("selectVersions");
51    //layout.add(header);
52    //header.addStyleName("Lum-DocumentHeader-Spacing");
53    //header.setTitle(name);
54  0 layout.addWidget(table);
55  0 layout.addButtonLayout(buttons);
56  0 parent = controller;
57    //layout.addWidget(widget)
58  0 layout.setLayoutTitle(SectionTitle.generateH2Title("Select Versions"));
59  0 layout.setInstructions("Select two drafts to compare, or select one to view");
60  0 buttons.addButton(new KSButton("Show Version(s)", new ClickHandler(){
61   
 
62  0 toggle @Override
63    public void onClick(ClickEvent event) {
64  0 if(table.getSelectedIds().size() == 1){
65  0 id1 = table.getSelectedIds().get(0);
66  0 id2 = null;
67  0 ViewContext context = new ViewContext();
68  0 context.setId(id1);
69  0 getController().setViewContext(context);
70  0 getController().showView(VersionsController.Views.VERSION_VIEW);
71    }
72  0 else if(table.getSelectedIds().size() == 2){
73  0 id1 = table.getSelectedIds().get(0);
74  0 id2 = table.getSelectedIds().get(1);
75  0 ViewContext context = new ViewContext();
76  0 context.setId(id1);
77  0 context.setAttribute("docId2", id2);
78  0 getController().setViewContext(context);
79  0 getController().showView(VersionsController.Views.VERSION_COMPARE);
80    }
81    else{
82  0 Window.alert("Please select either a single version to VIEW or two versions to COMPARE");
83    }
84    }
85    }));
86  0 buttons.addButton(new KSButton("Return to Current Course", ButtonStyle.ANCHOR_LARGE_CENTERED, new ClickHandler(){
87   
 
88  0 toggle @Override
89    public void onClick(ClickEvent event) {
90  0 ViewContext context = new ViewContext();
91  0 context.setId(parent.getCurrentVersionId());
92  0 context.setIdType(IdType.OBJECT_ID);
93  0 HistoryManager.navigate(AppLocations.Locations.VIEW_COURSE.getLocation(), context);
94    }
95    }));
96    }
97   
 
98  0 toggle @Override
99    public void beforeShow(final Callback<Boolean> onReadyCallback) {
100   
101  0 Metadata searchMetadata = parent.getDefinition().getMetadata(QueryPath.concat("searchCourseVersions"));
102    //List<LookupMetadata> additionalLookups = searchMetadata.getAdditionalLookups();
103  0 LookupMetadata versionSearch = searchMetadata.getInitialLookup();
104    /* for(int i = 0; i < additionalLookups.size(); i++){
105    if(additionalLookups.get(i).getWidget() == LookupMetadata.Widget.ADVANCED_LIGHTBOX){
106    versionSearch = additionalLookups.get(i);
107    break;
108    }
109    }*/
110  0 table.performSearch(generateRequest(versionSearch), versionSearch.getResults(), versionSearch.getResultReturnKey(), false);
111  0 onReadyCallback.exec(true);
112   
113    }
114   
 
115  0 toggle private SearchRequest generateRequest(LookupMetadata versionSearch){
116  0 SearchRequest sr = new SearchRequest();
117  0 List<SearchParam> params = new ArrayList<SearchParam>();
118  0 SearchParam param = new SearchParam();
119  0 param.setKey("lu.queryParam.cluVersionIndId");
120  0 param.setValue(parent.getVersionIndId());
121  0 params.add(param);
122  0 sr.setSortDirection(SortDirection.DESC);
123  0 sr.setParams(params);
124  0 sr.setSearchKey(versionSearch.getSearchTypeId());
125  0 if (versionSearch.getResultSortKey() != null) {
126  0 sr.setSortColumn(versionSearch.getResultSortKey());
127    }
128  0 return sr;
129    }
130   
131   
 
132  0 toggle public String getId1() {
133  0 return id1;
134    }
135   
 
136  0 toggle public String getId2() {
137  0 return id2;
138    }
139    }