Skip to content
This repository has been archived by the owner on Aug 23, 2018. It is now read-only.

Commit

Permalink
enhancement: Added the option to also use panels as targets in the
Browse files Browse the repository at this point in the history
applyProtocol module/plugin.
  • Loading branch information
paraiko committed Aug 22, 2013
1 parent 1b4a7f3 commit 70a69a8
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 16 deletions.
11 changes: 11 additions & 0 deletions modules/protocol/org/molgenis/protocol/ApplyProtocolPlugin.java
Expand Up @@ -55,6 +55,10 @@ public Show handleRequest(Database db, MolgenisRequest request, OutputStream out
ui.targetMatrixViewer.handleRequest(db, request);
action = "init";
}
if (action.equals("setTargetType"))
{
message = handleSetTargetType(request, db);
}
if (action.equals("Select"))
{
message = handleSelect(db, request);
Expand Down Expand Up @@ -129,6 +133,13 @@ public ScreenView getView()
return form;
}

ScreenMessage handleSetTargetType(MolgenisRequest request, Database db) throws Exception
{
ui.setObservationTargetType(request.getString("observationTargetType"));
ui.initScreen(db, this, db.getLogin().getUserId(), db.getLogin().getUserName());
return null;
}

ScreenMessage handleApply(MolgenisRequest request, Database db)
{

Expand Down
86 changes: 70 additions & 16 deletions modules/protocol/org/molgenis/protocol/ApplyProtocolUI.java
Expand Up @@ -37,22 +37,26 @@
import org.molgenis.pheno.Measurement;
import org.molgenis.pheno.ObservationTarget;
import org.molgenis.pheno.ObservedValue;
import org.molgenis.pheno.Panel;
import org.molgenis.util.ValueLabel;

public class ApplyProtocolUI
{

private Container protocolApplicationContainer = null;
private DivPanel mTypeDiv;
private DivPanel protocolDiv;
private DivPanel tableDiv;
private Table valueTable;
private SelectInput mType;
private SelectInput protocols;
MatrixViewer targetMatrixViewer = null;
static String TARGETMATRIX = "targetmatrix";
private SelectMultipleInput batches;
private RadioInput newOrEditButtons;
private CheckboxInput timeBox;
private CheckboxInput allValuesBox;
private String observationTargetType = "Individuals";

private ApplyProtocolPluginModel model;
private ApplyProtocolService service;
Expand All @@ -74,9 +78,11 @@ public void initScreen(Database db, ScreenController<?> plugin, int userId, Stri
model.setNewProtocolApplication(false);
model.setTimeInfo(false);
protocolApplicationContainer = new Container();
mTypeDiv = new DivPanel("mTypePanel", null);
protocolDiv = new DivPanel("ProtocolPanel", null);
tableDiv = new DivPanel("TablePanel", null);
tableDiv.setStyle("width:0");
makeTargetTypeSelect();
makeProtocolSelect(db);
makeTargetsMatrix(db, plugin, userId);
makeBatchSelect(db);
Expand Down Expand Up @@ -232,9 +238,25 @@ public void makeDateInputAndSetCell(int col, int row, int order, Date theTime)
*/
public void fillContainer()
{
protocolApplicationContainer.add(mTypeDiv);
protocolApplicationContainer.add(protocolDiv);
}

public void makeTargetTypeSelect()
{
mType = new SelectInput("observationTargetType");
mType.setLabel("Choose ObservationTarget Type:");
mType.addOption("Individuals", "Individuals");
mType.addOption("Panels", "Panels");
mType.setValue(this.observationTargetType);

ActionInput targetTypeSelectButton = new ActionInput("setTargetType", "", "Set TargetType");

mTypeDiv.add(mType);
mTypeDiv.add(targetTypeSelectButton);
mTypeDiv.add(new HorizontalRuler());
}

/**
*
*/
Expand Down Expand Up @@ -282,22 +304,43 @@ public void makeProtocolSelect(Database db)

public void makeTargetsMatrix(Database db, ScreenController<?> plugin, int userId) throws Exception
{

List<String> investigationNames = service.getAllUserInvestigationNames(db, userId);
List<String> measurementsToShow = new ArrayList<String>();
measurementsToShow.add("Species");
measurementsToShow.add("Sex");
measurementsToShow.add("Active");
List<MatrixQueryRule> filterRules = new ArrayList<MatrixQueryRule>();
filterRules.add(new MatrixQueryRule(MatrixQueryRule.Type.rowHeader, Individual.INVESTIGATION_NAME, Operator.IN,
investigationNames));
targetMatrixViewer = new MatrixViewer(plugin, TARGETMATRIX, new SliceablePhenoMatrix<Individual, Measurement>(
Individual.class, Measurement.class), true, 2, false, false, filterRules, new MatrixQueryRule(
MatrixQueryRule.Type.colHeader, Measurement.NAME, Operator.IN, measurementsToShow));
targetMatrixViewer.setDatabase(db);
targetMatrixViewer.setLabel("Choose animals:");
protocolDiv.add(targetMatrixViewer);
protocolDiv.add(new HorizontalRuler());
if (this.observationTargetType.equals("Individuals"))
{
List<String> investigationNames = service.getAllUserInvestigationNames(db, userId);
List<String> measurementsToShow = new ArrayList<String>();
measurementsToShow.add("Species");
measurementsToShow.add("Sex");
measurementsToShow.add("Active");
List<MatrixQueryRule> filterRules = new ArrayList<MatrixQueryRule>();
filterRules.add(new MatrixQueryRule(MatrixQueryRule.Type.rowHeader, Individual.INVESTIGATION_NAME,
Operator.IN, investigationNames));
targetMatrixViewer = new MatrixViewer(plugin, TARGETMATRIX,
new SliceablePhenoMatrix<Individual, Measurement>(Individual.class, Measurement.class), true, 2,
false, false, filterRules, new MatrixQueryRule(MatrixQueryRule.Type.colHeader, Measurement.NAME,
Operator.IN, measurementsToShow));
targetMatrixViewer.setDatabase(db);
targetMatrixViewer.setLabel("Choose animals:");
protocolDiv.add(targetMatrixViewer);
protocolDiv.add(new HorizontalRuler());
}
else if (this.observationTargetType.equals("Panels"))
{
List<String> investigationNames = service.getAllUserInvestigationNames(db, userId);
List<String> measurementsToShow = new ArrayList<String>();
measurementsToShow.add("TypeOfGroup");
// measurementsToShow.add("Sex");
// measurementsToShow.add("Active");
List<MatrixQueryRule> filterRules = new ArrayList<MatrixQueryRule>();
filterRules.add(new MatrixQueryRule(MatrixQueryRule.Type.rowHeader, Individual.INVESTIGATION_NAME,
Operator.IN, investigationNames));
targetMatrixViewer = new MatrixViewer(plugin, TARGETMATRIX, new SliceablePhenoMatrix<Panel, Measurement>(
Panel.class, Measurement.class), true, 2, false, false, filterRules, new MatrixQueryRule(
MatrixQueryRule.Type.colHeader, Measurement.NAME, Operator.IN, measurementsToShow));
targetMatrixViewer.setDatabase(db);
targetMatrixViewer.setLabel("Choose panel:");
protocolDiv.add(targetMatrixViewer);
protocolDiv.add(new HorizontalRuler());
}
}

/**
Expand Down Expand Up @@ -384,6 +427,7 @@ public void makeSelectButton()
* Create a button to clear selections
*
*/

public void makeClearButton()
{
ActionInput clearButton = new ActionInput("Clear", "", "Reset");
Expand Down Expand Up @@ -698,4 +742,14 @@ public void fixCellValue(Database db, int col, int row, Object value)
valueTable.setCell(col, row, input);
}

public String getObservationTargetType()
{
return observationTargetType;
}

public void setObservationTargetType(String observationTargetType)
{
this.observationTargetType = observationTargetType;
}

}

0 comments on commit 70a69a8

Please sign in to comment.