| 1 |
|
package org.kuali.student.lum.program.client.versions; |
| 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.DataModel; |
| 16 |
|
import org.kuali.student.common.ui.client.mvc.ViewComposite; |
| 17 |
|
import org.kuali.student.common.ui.client.mvc.history.HistoryManager; |
| 18 |
|
import org.kuali.student.common.ui.client.service.MetadataRpcService; |
| 19 |
|
import org.kuali.student.common.ui.client.service.MetadataRpcServiceAsync; |
| 20 |
|
import org.kuali.student.common.ui.client.widgets.KSButton; |
| 21 |
|
import org.kuali.student.common.ui.client.widgets.KSButtonAbstract.ButtonStyle; |
| 22 |
|
import org.kuali.student.common.ui.client.widgets.field.layout.button.ButtonLayout; |
| 23 |
|
import org.kuali.student.common.ui.client.widgets.field.layout.layouts.VerticalFieldLayout; |
| 24 |
|
import org.kuali.student.common.ui.client.widgets.search.SearchResultsTable; |
| 25 |
|
import org.kuali.student.lum.common.client.widgets.AppLocations; |
| 26 |
|
import org.kuali.student.lum.program.client.ProgramConstants; |
| 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 org.kuali.student.lum.program.client.ProgramRegistry; |
| 32 |
|
|
|
|
|
| 0% |
Uncovered Elements: 62 (62) |
Complexity: 12 |
Complexity Density: 0.24 |
|
| 33 |
|
public class ProgramSelectVersionsView extends ViewComposite{ |
| 34 |
|
|
| 35 |
|
private VerticalFieldLayout layout = new VerticalFieldLayout(); |
| 36 |
|
private ButtonLayout buttons = new ButtonLayout(); |
| 37 |
|
SearchResultsTable table = new SearchResultsTable(); |
| 38 |
|
MetadataRpcServiceAsync metadataServiceAsync = GWT.create(MetadataRpcService.class); |
| 39 |
|
|
| 40 |
|
private ProgramVersionsController parent; |
| 41 |
|
private DataModel programModel; |
| 42 |
|
|
|
|
|
| 0% |
Uncovered Elements: 13 (13) |
Complexity: 1 |
Complexity Density: 0.08 |
|
| 43 |
0
|
public ProgramSelectVersionsView(DataModel model, ProgramVersionsController controller,String name, Enum<?> viewType) {... |
| 44 |
0
|
super(controller, name, viewType); |
| 45 |
0
|
this.initWidget(layout); |
| 46 |
0
|
layout.addStyleName("selectVersions"); |
| 47 |
0
|
layout.addWidget(table); |
| 48 |
0
|
table.setWithMslable(false); |
| 49 |
0
|
layout.addButtonLayout(buttons); |
| 50 |
0
|
parent = controller; |
| 51 |
0
|
this.programModel = model; |
| 52 |
0
|
layout.setLayoutTitle(SectionTitle.generateH2Title("Program Versions")); |
| 53 |
0
|
layout.setInstructions("Select a version to view"); |
| 54 |
|
|
| 55 |
0
|
table.setMutipleSelect(false); |
| 56 |
0
|
buttons.addButton(new KSButton("Select", new ClickHandler(){ |
| 57 |
|
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
| 58 |
0
|
@Override... |
| 59 |
|
public void onClick(ClickEvent event) { |
| 60 |
0
|
if(table.getSelectedIds().size() == 1){ |
| 61 |
0
|
String id = table.getSelectedIds().get(0); |
| 62 |
0
|
ViewContext viewContext = parent.getViewContext(); |
| 63 |
0
|
viewContext.setId(id); |
| 64 |
0
|
navigateToProgramView(viewContext); |
| 65 |
|
} |
| 66 |
|
} |
| 67 |
|
})); |
| 68 |
|
|
| 69 |
0
|
buttons.addButton(new KSButton("Return to Selected Program", ButtonStyle.ANCHOR_LARGE_CENTERED, new ClickHandler(){ |
| 70 |
|
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 71 |
0
|
@Override... |
| 72 |
|
public void onClick(ClickEvent event) { |
| 73 |
0
|
ViewContext viewContext = parent.getViewContext(); |
| 74 |
0
|
viewContext.setId((String)programModel.get(ProgramConstants.ID)); |
| 75 |
0
|
navigateToProgramView(viewContext); |
| 76 |
|
} |
| 77 |
|
})); |
| 78 |
|
} |
| 79 |
|
|
|
|
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 4 |
Complexity Density: 0.36 |
|
| 80 |
0
|
private void navigateToProgramView(ViewContext viewContext){... |
| 81 |
0
|
ProgramRegistry.setCreateNew(true); |
| 82 |
0
|
switch (parent.getType()){ |
| 83 |
0
|
case MAJOR: HistoryManager.navigate(AppLocations.Locations.VIEW_PROGRAM.getLocation(), viewContext); break; |
| 84 |
0
|
case CORE: HistoryManager.navigate(AppLocations.Locations.VIEW_CORE_PROGRAM.getLocation(), viewContext); break; |
| 85 |
0
|
case CREDENTIAL: HistoryManager.navigate(AppLocations.Locations.VIEW_BACC_PROGRAM.getLocation(), viewContext); break; |
| 86 |
|
} |
| 87 |
|
} |
| 88 |
|
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
| 89 |
0
|
@Override... |
| 90 |
|
public void beforeShow(final Callback<Boolean> onReadyCallback) { |
| 91 |
0
|
Metadata searchMetadata = programModel.getDefinition().getMetadata(QueryPath.concat("searchProgramVersions")); |
| 92 |
0
|
LookupMetadata versionSearch = searchMetadata.getInitialLookup(); |
| 93 |
0
|
table.performSearch(generateRequest(versionSearch), versionSearch.getResults(), versionSearch.getResultReturnKey(), false); |
| 94 |
0
|
onReadyCallback.exec(true); |
| 95 |
|
} |
| 96 |
|
|
|
|
|
| 0% |
Uncovered Elements: 18 (18) |
Complexity: 3 |
Complexity Density: 0.21 |
|
| 97 |
0
|
private SearchRequest generateRequest(LookupMetadata versionSearch){... |
| 98 |
0
|
SearchRequest sr = new SearchRequest(); |
| 99 |
0
|
List<SearchParam> params = new ArrayList<SearchParam>(); |
| 100 |
0
|
SearchParam param = new SearchParam(); |
| 101 |
0
|
param.setKey("lu.queryParam.cluVersionIndId"); |
| 102 |
0
|
String versionIndId = programModel.get(ProgramConstants.VERSION_IND_ID); |
| 103 |
0
|
versionIndId = (versionIndId == null ? "":versionIndId); |
| 104 |
0
|
param.setValue(versionIndId); |
| 105 |
0
|
params.add(param); |
| 106 |
0
|
sr.setSortDirection(SortDirection.DESC); |
| 107 |
0
|
sr.setParams(params); |
| 108 |
0
|
sr.setSearchKey(versionSearch.getSearchTypeId()); |
| 109 |
0
|
if (versionSearch.getResultSortKey() != null) { |
| 110 |
0
|
sr.setSortColumn(versionSearch.getResultSortKey()); |
| 111 |
|
} |
| 112 |
0
|
return sr; |
| 113 |
|
} |
| 114 |
|
|
| 115 |
|
|
| 116 |
|
} |