Search in sources :

Example 1 with AttributeMappingParametersHandlerFactory

use of org.cytoscape.tableimport.internal.tunable.AttributeMappingParametersHandlerFactory 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);
    }
}
Also used : NetworkTableMappingParametersHandlerFactory(org.cytoscape.tableimport.internal.tunable.NetworkTableMappingParametersHandlerFactory) AttributeMappingParametersHandlerFactory(org.cytoscape.tableimport.internal.tunable.AttributeMappingParametersHandlerFactory) GUITunableHandlerFactory(org.cytoscape.work.swing.GUITunableHandlerFactory) Properties(java.util.Properties) ImportNoGuiTableReaderFactory(org.cytoscape.tableimport.internal.task.ImportNoGuiTableReaderFactory) WildCardCyFileFilter(org.cytoscape.tableimport.internal.io.WildCardCyFileFilter) CyServiceRegistrar(org.cytoscape.service.util.CyServiceRegistrar) ImportNoGuiNetworkReaderFactory(org.cytoscape.tableimport.internal.task.ImportNoGuiNetworkReaderFactory) InputStreamTaskFactory(org.cytoscape.io.read.InputStreamTaskFactory) ImportAttributeTableReaderFactory(org.cytoscape.tableimport.internal.task.ImportAttributeTableReaderFactory) ImportNetworkTableReaderFactory(org.cytoscape.tableimport.internal.task.ImportNetworkTableReaderFactory) TaskFactory(org.cytoscape.work.TaskFactory) InputStreamTaskFactory(org.cytoscape.io.read.InputStreamTaskFactory) StreamUtil(org.cytoscape.io.util.StreamUtil)

Aggregations

Properties (java.util.Properties)1 InputStreamTaskFactory (org.cytoscape.io.read.InputStreamTaskFactory)1 StreamUtil (org.cytoscape.io.util.StreamUtil)1 CyServiceRegistrar (org.cytoscape.service.util.CyServiceRegistrar)1 WildCardCyFileFilter (org.cytoscape.tableimport.internal.io.WildCardCyFileFilter)1 ImportAttributeTableReaderFactory (org.cytoscape.tableimport.internal.task.ImportAttributeTableReaderFactory)1 ImportNetworkTableReaderFactory (org.cytoscape.tableimport.internal.task.ImportNetworkTableReaderFactory)1 ImportNoGuiNetworkReaderFactory (org.cytoscape.tableimport.internal.task.ImportNoGuiNetworkReaderFactory)1 ImportNoGuiTableReaderFactory (org.cytoscape.tableimport.internal.task.ImportNoGuiTableReaderFactory)1 AttributeMappingParametersHandlerFactory (org.cytoscape.tableimport.internal.tunable.AttributeMappingParametersHandlerFactory)1 NetworkTableMappingParametersHandlerFactory (org.cytoscape.tableimport.internal.tunable.NetworkTableMappingParametersHandlerFactory)1 TaskFactory (org.cytoscape.work.TaskFactory)1 GUITunableHandlerFactory (org.cytoscape.work.swing.GUITunableHandlerFactory)1