use of org.cytoscape.model.CyNetwork in project cytoscape-impl by cytoscape.
the class CreateFilterTaskTest method testCreateColumnFilterBoolean.
@Test
public void testCreateColumnFilterBoolean() {
CreateFilterTask task = new CreateFilterTask(serviceRegistrar, "MyFilter");
task.jsonTunable.json = "{ \"id\" : \"ColumnFilter\", \"parameters\" : { \"criterion\" : false, \"columnName\" : \"name\", \"predicate\" : \"IS\"} }";
TaskMonitor tm = mock(TaskMonitor.class);
task.run(tm);
verify(tm, times(0)).showMessage(any(), any());
NamedTransformer<CyNetwork, CyIdentifiable> transformer = transformerContainer.getNamedTransformer(task.name);
assertNotNull(transformer);
ColumnFilter columnFilter = (ColumnFilter) transformer.getTransformers().get(0);
assertEquals(Predicate.IS, columnFilter.getPredicate());
assertEquals(false, columnFilter.getCriterion());
assertEquals("name", columnFilter.getColumnName());
}
use of org.cytoscape.model.CyNetwork in project cytoscape-impl by cytoscape.
the class CreateFilterTaskTest method testCreateDegreeFilter.
@Test
public void testCreateDegreeFilter() {
CreateFilterTask task = new CreateFilterTask(serviceRegistrar, "MyFilter");
task.jsonTunable.json = "{ \"id\" : \"DegreeFilter\", \"parameters\" : { \"predicate\" : \"BETWEEN\", \"criterion\" : [ 0, 1 ], \"edgeType\" : \"ANY\" } }";
TaskMonitor tm = mock(TaskMonitor.class);
task.run(tm);
verify(tm, times(0)).showMessage(any(), any());
NamedTransformer<CyNetwork, CyIdentifiable> transformer = transformerContainer.getNamedTransformer(task.name);
assertNotNull(transformer);
DegreeFilter filter = (DegreeFilter) transformer.getTransformers().get(0);
assertEquals(Predicate.BETWEEN, filter.getPredicate());
assertArrayEquals(new Number[] { 0l, 1l }, (Number[]) filter.getCriterion());
assertEquals(CyEdge.Type.ANY, filter.getEdgeType());
}
use of org.cytoscape.model.CyNetwork in project cytoscape-impl by cytoscape.
the class CreateFilterTaskTest method testCreateColumnFilterString.
@Test
public void testCreateColumnFilterString() {
CreateFilterTask task = new CreateFilterTask(serviceRegistrar, "MyFilter");
task.jsonTunable.json = "{ \"id\" : \"ColumnFilter\", \"parameters\" : { \"criterion\" : \"1\", \"columnName\" : \"name\", \"predicate\" : \"CONTAINS\"} }";
TaskMonitor tm = mock(TaskMonitor.class);
task.run(tm);
verify(tm, times(0)).showMessage(any(), any());
NamedTransformer<CyNetwork, CyIdentifiable> transformer = transformerContainer.getNamedTransformer(task.name);
assertNotNull(transformer);
ColumnFilter columnFilter = (ColumnFilter) transformer.getTransformers().get(0);
assertEquals(Predicate.CONTAINS, columnFilter.getPredicate());
assertEquals("1", columnFilter.getCriterion());
assertEquals("name", columnFilter.getColumnName());
}
use of org.cytoscape.model.CyNetwork in project cytoscape-impl by cytoscape.
the class CreateFilterTaskTest method testCreateCompositeFilter.
@Test
public void testCreateCompositeFilter() {
CreateFilterTask task = new CreateFilterTask(serviceRegistrar, "MyFilter");
String subFilterJson = "{ \"id\" : \"ColumnFilter\", \"parameters\" : { \"criterion\" : \"1\", \"columnName\" : \"name\", \"predicate\" : \"CONTAINS\"} }";
task.jsonTunable.json = "{ \"id\" : \"org.cytoscape.CompositeFilter\", \"parameters\" : { \"type\" : \"ALL\" }, \"transformers\" : [ " + subFilterJson + " ] }";
TaskMonitor tm = mock(TaskMonitor.class);
task.run(tm);
verify(tm, times(0)).showMessage(any(), any());
NamedTransformer<CyNetwork, CyIdentifiable> transformer = transformerContainer.getNamedTransformer(task.name);
assertNotNull(transformer);
@SuppressWarnings("rawtypes") CompositeFilter compositeFilter = (CompositeFilter) transformer.getTransformers().get(0);
assertEquals(CompositeFilter.Type.ALL, compositeFilter.getType());
assertEquals(1, compositeFilter.getLength());
ColumnFilter columnFilter = (ColumnFilter) compositeFilter.get(0);
assertEquals(Predicate.CONTAINS, columnFilter.getPredicate());
assertEquals("1", columnFilter.getCriterion());
assertEquals("name", columnFilter.getColumnName());
}
use of org.cytoscape.model.CyNetwork in project cytoscape-impl by cytoscape.
the class MapTableToNetworkTablesTaskFactoryImpl method createTaskIterator.
@Override
public TaskIterator createTaskIterator(CyTable globalTable, boolean selectedNetworksOnly, List<CyNetwork> networksList, Class<? extends CyIdentifiable> type) {
TableType tableType = getTableType(type);
if (tableType == null)
throw new IllegalArgumentException("The specified type " + type + " is not acceptable.");
ListSingleSelection<TableType> tableTypes = new ListSingleSelection<TableType>(tableType);
tableTypes.setSelectedValue(tableType);
List<String> networkNames = new ArrayList<String>();
for (CyNetwork net : networksList) {
networkNames.add(net.getRow(net).get(CyNetwork.NAME, String.class));
}
ListMultipleSelection<String> networksListTunable = new ListMultipleSelection<String>(networkNames);
networksListTunable.setSelectedValues(networkNames);
final Map<String, Object> m = new HashMap<String, Object>();
m.put("dataTypeOptions", tableTypes);
m.put("selectedNetworksOnly", selectedNetworksOnly);
m.put("networkList", networksListTunable);
return tunableSetter.createTaskIterator(createTaskIterator(globalTable), m);
}
Aggregations