use of org.cytoscape.service.util.CyServiceRegistrar in project EnrichmentMapApp by BaderLab.
the class TestUtils method mockServiceRegistrar.
public static CyServiceRegistrar mockServiceRegistrar() {
CyNetworkManager netManager = mock(CyNetworkManager.class);
CyServiceRegistrar serviceRegistrar = mock(CyServiceRegistrar.class);
when(serviceRegistrar.getService(CyNetworkManager.class)).thenReturn(netManager);
return serviceRegistrar;
}
use of org.cytoscape.service.util.CyServiceRegistrar in project cytoscape-impl by cytoscape.
the class CyActivator method start.
@Override
public void start(BundleContext bc) {
CyServiceRegistrar serviceRegistrar = getService(bc, CyServiceRegistrar.class);
CyEventHelper cyEventHelperRef = getService(bc, CyEventHelper.class);
CyNetworkNaming cyNetworkNamingServiceRef = getService(bc, CyNetworkNaming.class);
UndoSupport undoSupportServiceRef = getService(bc, UndoSupport.class);
CyNetworkViewFactory cyNetworkViewFactoryServiceRef = getService(bc, CyNetworkViewFactory.class);
CyNetworkFactory cyNetworkFactoryServiceRef = getService(bc, CyNetworkFactory.class);
CyRootNetworkManager cyRootNetworkFactoryServiceRef = getService(bc, CyRootNetworkManager.class);
VisualMappingManager visualMappingManagerServiceRef = getService(bc, VisualMappingManager.class);
CyNetworkViewWriterManager networkViewWriterManagerServiceRef = getService(bc, CyNetworkViewWriterManager.class);
CyNetworkManager cyNetworkManagerServiceRef = getService(bc, CyNetworkManager.class);
CyNetworkViewManager cyNetworkViewManagerServiceRef = getService(bc, CyNetworkViewManager.class);
CyApplicationManager cyApplicationManagerServiceRef = getService(bc, CyApplicationManager.class);
CySessionManager cySessionManagerServiceRef = getService(bc, CySessionManager.class);
CyTableFactory cyTableFactoryServiceRef = getService(bc, CyTableFactory.class);
CyTableManager cyTableManagerServiceRef = getService(bc, CyTableManager.class);
CyLayoutAlgorithmManager cyLayoutsServiceRef = getService(bc, CyLayoutAlgorithmManager.class);
CyTableWriterManager cyTableWriterManagerRef = getService(bc, CyTableWriterManager.class);
SynchronousTaskManager<?> synchronousTaskManagerServiceRef = getService(bc, SynchronousTaskManager.class);
TunableSetter tunableSetterServiceRef = getService(bc, TunableSetter.class);
CyRootNetworkManager rootNetworkManagerServiceRef = getService(bc, CyRootNetworkManager.class);
CyNetworkTableManager cyNetworkTableManagerServiceRef = getService(bc, CyNetworkTableManager.class);
RenderingEngineManager renderingEngineManagerServiceRef = getService(bc, RenderingEngineManager.class);
CyNetworkViewFactory nullNetworkViewFactory = getService(bc, CyNetworkViewFactory.class, "(id=NullCyNetworkViewFactory)");
CyGroupManager cyGroupManager = getService(bc, CyGroupManager.class);
CyGroupFactory cyGroupFactory = getService(bc, CyGroupFactory.class);
{
DynamicTaskFactoryProvisionerImpl factory = new DynamicTaskFactoryProvisionerImpl(serviceRegistrar);
registerAllServices(bc, factory);
}
createPreferencesTaskFactories(bc, serviceRegistrar);
createFilterTaskFactories(bc, serviceRegistrar);
createTableTaskFactories(bc, serviceRegistrar, undoSupportServiceRef, cyNetworkManagerServiceRef, cyApplicationManagerServiceRef, cyTableFactoryServiceRef, cyTableManagerServiceRef, cyTableWriterManagerRef, tunableSetterServiceRef, rootNetworkManagerServiceRef, cyNetworkTableManagerServiceRef);
createNetworkTaskFactories(bc, serviceRegistrar, cyEventHelperRef, cyNetworkNamingServiceRef, undoSupportServiceRef, cyNetworkViewFactoryServiceRef, cyNetworkFactoryServiceRef, cyRootNetworkFactoryServiceRef, visualMappingManagerServiceRef, cyNetworkManagerServiceRef, cyNetworkViewManagerServiceRef, cyApplicationManagerServiceRef, synchronousTaskManagerServiceRef, rootNetworkManagerServiceRef, cyNetworkTableManagerServiceRef, renderingEngineManagerServiceRef, nullNetworkViewFactory, cyGroupManager, cyGroupFactory, networkViewWriterManagerServiceRef, tunableSetterServiceRef);
createViewTaskFactories(bc, cyEventHelperRef, undoSupportServiceRef, visualMappingManagerServiceRef, networkViewWriterManagerServiceRef, cyNetworkViewManagerServiceRef, cyApplicationManagerServiceRef, cyLayoutsServiceRef, tunableSetterServiceRef, renderingEngineManagerServiceRef, cyNetworkManagerServiceRef, cySessionManagerServiceRef, serviceRegistrar);
createVizmapTaskFactories(bc, serviceRegistrar);
createSessionTaskFactories(bc, serviceRegistrar);
createGroupTaskFactories(bc, undoSupportServiceRef, cyApplicationManagerServiceRef, cyGroupManager, cyGroupFactory, serviceRegistrar);
createNodeEdgeTaskFactories(bc, serviceRegistrar, cyEventHelperRef, undoSupportServiceRef, cyNetworkViewManagerServiceRef, tunableSetterServiceRef, cyApplicationManagerServiceRef, cyTableManagerServiceRef, renderingEngineManagerServiceRef, visualMappingManagerServiceRef);
createLayoutTaskFactories(bc, serviceRegistrar);
createHelpTaskFactories(bc, serviceRegistrar);
}
use of org.cytoscape.service.util.CyServiceRegistrar in project cytoscape-impl by cytoscape.
the class CyActivator method start.
@Override
public void start(BundleContext bc) {
final CyServiceRegistrar serviceRegistrar = getService(bc, CyServiceRegistrar.class);
final StreamUtil streamUtil = getService(bc, StreamUtil.class);
{
// ".xls"
WildCardCyFileFilter filter = new WildCardCyFileFilter(new String[] { "xls", "xlsx" }, new String[] { "application/excel" }, "Excel", TABLE, streamUtil);
ImportAttributeTableReaderFactory factory = new ImportAttributeTableReaderFactory(filter, serviceRegistrar);
Properties props = new Properties();
props.setProperty("readerDescription", "Attribute Table file reader");
props.setProperty("readerId", "attributeTableReader");
registerService(bc, factory, InputStreamTaskFactory.class, props);
}
{
// ".txt"
WildCardCyFileFilter filter = new WildCardCyFileFilter(new String[] { "csv", "tsv", "txt", "tab", "net", "" }, new String[] { "text/csv", "text/tab-separated-values", "text/plain", "" }, "Comma or Tab Separated Value", TABLE, streamUtil);
filter.setBlacklist("xml", "xgmml", "rdf", "owl", "zip", "rar", "jar", "doc", "docx", "ppt", "pptx", "pdf", "jpg", "jpeg", "gif", "png", "svg", "tiff", "ttf", "mp3", "mp4", "mpg", "mpeg", "exe", "dmg", "iso", "cys");
ImportAttributeTableReaderFactory factory = new ImportAttributeTableReaderFactory(filter, serviceRegistrar);
Properties props = new Properties();
props.setProperty("readerDescription", "Attribute Table file reader");
props.setProperty("readerId", "attributeTableReader_txt");
registerService(bc, factory, InputStreamTaskFactory.class, props);
}
{
// BasicCyFileFilter filter = new BasicCyFileFilter(
// new String[] { "obo" },
// new String[] { "text/obo" },
// "OBO",
// NETWORK,
// streamUtil
// );
// OBONetworkReaderFactory factory = new OBONetworkReaderFactory(filter, serviceRegistrar);
// Properties props = new Properties();
// props.setProperty("readerDescription", "Open Biomedical Ontology (OBO) file reader");
// props.setProperty("readerId", "oboReader");
// registerService(bc, factory, InputStreamTaskFactory.class, props);
//
// ImportOntologyAndAnnotationAction action = new ImportOntologyAndAnnotationAction(factory, serviceRegistrar);
// registerService(bc, action, CyAction.class);
}
{
// "txt"
WildCardCyFileFilter filter = new WildCardCyFileFilter(new String[] { "csv", "tsv", "txt", "" }, new String[] { "text/csv", "text/tab-separated-values", "text/plain", "" }, "Comma or Tab Separated Value", NETWORK, streamUtil);
filter.setBlacklist("xml", "xgmml", "rdf", "owl", "zip", "rar", "jar", "doc", "docx", "ppt", "pptx", "pdf", "jpg", "jpeg", "gif", "png", "svg", "tiff", "ttf", "mp3", "mp4", "mpg", "mpeg", "exe", "dmg", "iso", "cys");
ImportNetworkTableReaderFactory factory = new ImportNetworkTableReaderFactory(filter, serviceRegistrar);
Properties props = new Properties();
props.setProperty("readerDescription", "Network Table file reader");
props.setProperty("readerId", "networkTableReader_txt");
registerService(bc, factory, InputStreamTaskFactory.class, props);
}
{
// ".xls"
WildCardCyFileFilter filter = new WildCardCyFileFilter(new String[] { "xls", "xlsx" }, new String[] { "application/excel" }, "Excel", NETWORK, streamUtil);
ImportNetworkTableReaderFactory factory = new ImportNetworkTableReaderFactory(filter, serviceRegistrar);
Properties props = new Properties();
props.setProperty("readerDescription", "Network Table file reader");
props.setProperty("readerId", "networkTableReader_xls");
registerService(bc, factory, InputStreamTaskFactory.class, props);
}
{
AttributeMappingParametersHandlerFactory factory = new AttributeMappingParametersHandlerFactory(ImportType.TABLE_IMPORT, serviceRegistrar);
registerService(bc, factory, GUITunableHandlerFactory.class);
}
{
NetworkTableMappingParametersHandlerFactory factory = new NetworkTableMappingParametersHandlerFactory(ImportType.NETWORK_IMPORT, serviceRegistrar);
registerService(bc, factory, GUITunableHandlerFactory.class);
}
{
TaskFactory factory = new ImportNoGuiTableReaderFactory(false, serviceRegistrar);
Properties props = new Properties();
props.setProperty(COMMAND, "import file");
props.setProperty(COMMAND_NAMESPACE, "table");
props.setProperty(COMMAND_DESCRIPTION, "Import a table from a file");
props.setProperty(COMMAND_LONG_DESCRIPTION, "This uses a long list of input parameters to specify the attributes of the table, the mapping keys, and the destination table for the input.");
props.setProperty(COMMAND_SUPPORTS_JSON, "true");
props.setProperty(COMMAND_EXAMPLE_JSON, "{\"mappedTables\":[101,102]}");
// Register the service as a TaskFactory for commands
registerService(bc, factory, TaskFactory.class, props);
}
{
TaskFactory importURLTableFactory = new ImportNoGuiTableReaderFactory(true, serviceRegistrar);
Properties props = new Properties();
props.setProperty(COMMAND, "import url");
props.setProperty(COMMAND_NAMESPACE, "table");
props.setProperty(COMMAND_DESCRIPTION, "Import a table from a URL");
props.setProperty(COMMAND_LONG_DESCRIPTION, "Similar to Import Table this uses a long list of input parameters to specify the attributes of the table, the mapping keys, and the destination table for the input.");
props.setProperty(COMMAND_SUPPORTS_JSON, "true");
props.setProperty(COMMAND_EXAMPLE_JSON, "{\"mappedTables\":[101,102]}");
// Register the service as a TaskFactory for commands
registerService(bc, importURLTableFactory, TaskFactory.class, props);
}
// {
// TaskFactory mapColumnTaskFactory = new ImportNoGuiTableReaderFactory(true, serviceRegistrar);
// Properties props = new Properties();
// props.setProperty(COMMAND, "map column");
// props.setProperty(COMMAND_NAMESPACE, "table");
// props.setProperty(COMMAND_DESCRIPTION, "Map column content from one namespace to another");
// props.setProperty(COMMAND_LONG_DESCRIPTION, "Uses the BridgeDB service to look up analogous identifiers from a wide selection of other databases");
// props.setProperty(COMMAND_SUPPORTS_JSON, "true");
// // Register the service as a TaskFactory for commands
// registerService(bc, mapColumnTaskFactory, MapColumnTaskFactory.class, props);
// }
{
TaskFactory factory = new ImportNoGuiNetworkReaderFactory(false, serviceRegistrar);
Properties props = new Properties();
props.setProperty(COMMAND, "import file");
props.setProperty(COMMAND_NAMESPACE, "network");
props.setProperty(COMMAND_DESCRIPTION, "Import a network from a file");
props.setProperty(COMMAND_LONG_DESCRIPTION, "Import a new network from a tabular formatted file type " + "(e.g. ``csv``, ``tsv``, ``Excel``, etc.). Use ``network load file`` " + "to load network formatted files. This command will create a " + "new network collection if no current network collection is selected, otherwise " + "it will add the network to the current collection. The SUIDs of the new networks " + "and views are returned.");
props.setProperty(COMMAND_SUPPORTS_JSON, "true");
props.setProperty(COMMAND_EXAMPLE_JSON, ImportNoGuiNetworkReaderFactory.JSON_EXAMPLE);
// Register the service as a TaskFactory for commands
registerService(bc, factory, TaskFactory.class, props);
}
{
TaskFactory factory = new ImportNoGuiNetworkReaderFactory(true, serviceRegistrar);
Properties props = new Properties();
props.setProperty(COMMAND, "import url");
props.setProperty(COMMAND_NAMESPACE, "network");
props.setProperty(COMMAND_DESCRIPTION, "Import a network from a URL");
props.setProperty(COMMAND_LONG_DESCRIPTION, "Import a new network from a URL that points to a tabular formatted file type " + "(e.g. ``csv``, ``tsv``, ``Excel``, etc.). Use ``network load url`` " + "to load network formatted files. This command will create a " + "new network collection if no current network collection is selected, otherwise " + "it will add the network to the current collection. The SUIDs of the new networks " + "and views are returned.");
props.setProperty(COMMAND_SUPPORTS_JSON, "true");
props.setProperty(COMMAND_EXAMPLE_JSON, ImportNoGuiNetworkReaderFactory.JSON_EXAMPLE);
// Register the service as a TaskFactory for commands
registerService(bc, factory, TaskFactory.class, props);
}
}
use of org.cytoscape.service.util.CyServiceRegistrar in project cytoscape-impl by cytoscape.
the class CyActivator method start.
@Override
public void start(BundleContext bc) {
final CyServiceRegistrar serviceRegistrar = getService(bc, CyServiceRegistrar.class);
final OpenBrowserImpl openBrowser = new OpenBrowserImpl();
registerService(bc, openBrowser, OpenBrowser.class, new Properties());
final FileUtilImpl fileUtil = new FileUtilImpl(serviceRegistrar);
registerService(bc, fileUtil, FileUtil.class, new Properties());
final IconManagerImpl iconManager = new IconManagerImpl();
registerService(bc, iconManager, IconManager.class, new Properties());
}
use of org.cytoscape.service.util.CyServiceRegistrar in project cytoscape-impl by cytoscape.
the class CloneNetworkTaskFactoryTest method testObserver.
@Test
public void testObserver() throws Exception {
NetworkViewTestSupport viewSupport = new NetworkViewTestSupport();
NetworkTestSupport networkSupport = new NetworkTestSupport();
CyNetworkManager networkMgr = Mockito.mock(CyNetworkManager.class);
CyNetworkViewManager networkViewMgr = Mockito.mock(CyNetworkViewManager.class);
VisualMappingManager vmm = Mockito.mock(VisualMappingManager.class);
CyNetworkFactory netFactory = networkSupport.getNetworkFactory();
CyNetworkViewFactory netViewFactory = viewSupport.getNetworkViewFactory();
CyNetworkNaming naming = Mockito.mock(CyNetworkNaming.class);
CyApplicationManager appMgr = Mockito.mock(CyApplicationManager.class);
CyNetworkTableManager netTableMgr = Mockito.mock(CyNetworkTableManager.class);
CyRootNetworkManager rootNetMgr = new CyRootNetworkManagerImpl();
CyGroupManager groupMgr = Mockito.mock(CyGroupManager.class);
CyGroupFactory groupFactory = Mockito.mock(CyGroupFactory.class);
RenderingEngineManager renderingEngineMgr = Mockito.mock(RenderingEngineManager.class);
CyNetworkViewFactory nullNetworkViewFactory = new NullCyNetworkViewFactory();
CyServiceRegistrar serviceRegistrar = Mockito.mock(CyServiceRegistrar.class);
CloneNetworkTaskFactoryImpl factory = new CloneNetworkTaskFactoryImpl(networkMgr, networkViewMgr, vmm, netFactory, netViewFactory, naming, appMgr, netTableMgr, rootNetMgr, groupMgr, groupFactory, renderingEngineMgr, nullNetworkViewFactory, serviceRegistrar);
CyNetwork network = netFactory.createNetwork();
TaskObserver observer = Mockito.mock(TaskObserver.class);
TaskIterator iterator = factory.createTaskIterator(network);
TaskMonitor taskMonitor = Mockito.mock(TaskMonitor.class);
while (iterator.hasNext()) {
Task t = iterator.next();
t.run(taskMonitor);
if (t instanceof ObservableTask)
observer.taskFinished((ObservableTask) t);
}
Mockito.verify(observer, Mockito.times(1)).taskFinished(Mockito.any(ObservableTask.class));
}
Aggregations