Search in sources :

Example 1 with TextTableReader

use of org.cytoscape.tableimport.internal.reader.TextTableReader in project cytoscape-impl by cytoscape.

the class LoadTableReaderTask method loadAnnotation.

private void loadAnnotation(TaskMonitor tm) {
    tm.setProgress(0.0);
    TextTableReader reader = this.reader;
    AttributeMappingParameters readerAMP = (AttributeMappingParameters) reader.getMappingParameter();
    String primaryKey = readerAMP.getAttributeNames()[readerAMP.getKeyIndex()];
    tm.setProgress(0.1);
    final CyTableFactory tableFactory = serviceRegistrar.getService(CyTableFactory.class);
    final CyTable table = tableFactory.createTable("AttrTable " + inputName.substring(inputName.lastIndexOf('/') + 1) + " " + Integer.toString(numImports++), primaryKey, String.class, true, true);
    cyTables = new CyTable[] { table };
    tm.setProgress(0.3);
    try {
        this.reader.readTable(table);
    } catch (IOException e) {
        e.printStackTrace();
    }
    tm.setProgress(1.0);
}
Also used : CyTableFactory(org.cytoscape.model.CyTableFactory) CyTable(org.cytoscape.model.CyTable) IOException(java.io.IOException) TextTableReader(org.cytoscape.tableimport.internal.reader.TextTableReader) AttributeMappingParameters(org.cytoscape.tableimport.internal.reader.AttributeMappingParameters)

Example 2 with TextTableReader

use of org.cytoscape.tableimport.internal.reader.TextTableReader in project cytoscape-impl by cytoscape.

the class ImportAttributeTableReaderTask method loadAnnotation.

private void loadAnnotation(TaskMonitor tm) {
    tm.setProgress(0.0);
    final TextTableReader reader = this.reader;
    final AttributeMappingParameters readerAMP = (AttributeMappingParameters) reader.getMappingParameter();
    final String primaryKey = readerAMP.getAttributeNames()[readerAMP.getKeyIndex()];
    final AttributeDataType dataType = readerAMP.getDataTypes()[readerAMP.getKeyIndex()];
    final Class<?> keyType;
    switch(dataType) {
        case TYPE_INTEGER:
            keyType = Integer.class;
            break;
        case TYPE_LONG:
            keyType = Long.class;
            break;
        default:
            keyType = String.class;
    }
    tm.setProgress(0.1);
    final CyTable table = serviceRegistrar.getService(CyTableFactory.class).createTable("AttrTable " + inputName.substring(inputName.lastIndexOf('/') + 1) + " " + Integer.toString(numImports++), primaryKey, keyType, true, true);
    cyTables = new CyTable[] { table };
    tm.setProgress(0.3);
    try {
        this.reader.readTable(table);
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    tm.setProgress(1.0);
}
Also used : CyTableFactory(org.cytoscape.model.CyTableFactory) CyTable(org.cytoscape.model.CyTable) AttributeDataType(org.cytoscape.tableimport.internal.util.AttributeDataType) IOException(java.io.IOException) TextTableReader(org.cytoscape.tableimport.internal.reader.TextTableReader) AttributeMappingParameters(org.cytoscape.tableimport.internal.reader.AttributeMappingParameters)

Aggregations

IOException (java.io.IOException)2 CyTable (org.cytoscape.model.CyTable)2 CyTableFactory (org.cytoscape.model.CyTableFactory)2 AttributeMappingParameters (org.cytoscape.tableimport.internal.reader.AttributeMappingParameters)2 TextTableReader (org.cytoscape.tableimport.internal.reader.TextTableReader)2 AttributeDataType (org.cytoscape.tableimport.internal.util.AttributeDataType)1