Changeset 2402

Show
Ignore:
Timestamp:
08/12/08 14:05:09 (3 months ago)
Author:
kelleyt
Message:

added progresstrackable to the extract x-type network algorithms. Need to create real .properties files for the extract author-paper network algorithm

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/plugins/analysis/edu.iu.nwb.analysis.extractcoauthorship/src/edu/iu/nwb/analysis/extractcoauthorship/algorithms/ExtractAlgorithm.java

    r2246 r2402  
    1010import org.cishell.framework.algorithm.Algorithm; 
    1111import org.cishell.framework.algorithm.AlgorithmExecutionException; 
     12import org.cishell.framework.algorithm.ProgressMonitor; 
     13import org.cishell.framework.algorithm.ProgressTrackable; 
    1214import org.cishell.framework.data.BasicData; 
    1315import org.cishell.framework.data.Data; 
     
    1618 
    1719import edu.iu.nwb.analysis.extractcoauthorship.metadata.SupportedFileTypes; 
    18 import edu.iu.nwb.analysis.extractcoauthorship.metadata.SupportedFileTypes.CitationFormat; 
    1920import edu.iu.nwb.analysis.extractnetfromtable.components.ExtractNetworkFromTable; 
    2021import edu.iu.nwb.analysis.extractnetfromtable.components.GraphContainer; 
    2122import edu.iu.nwb.analysis.extractnetfromtable.components.InvalidColumnNameException; 
    2223 
    23 public class ExtractAlgorithm implements Algorithm, SupportedFileTypes
     24public class ExtractAlgorithm implements Algorithm, SupportedFileTypes,ProgressTrackable
    2425        Data[] data; 
    2526        Dictionary parameters; 
    2627        CIShellContext ciContext; 
    2728        LogService logger; 
     29        ProgressMonitor progressMonitor; 
     30 
     31        public ProgressMonitor getProgressMonitor() { 
     32                // TODO Auto-generated method stub 
     33                return this.progressMonitor; 
     34        } 
     35 
     36        public void setProgressMonitor(ProgressMonitor monitor) { 
     37                this.progressMonitor = monitor; 
     38                 
     39        } 
    2840 
    2941        public ExtractAlgorithm(Data[] dm, Dictionary parameters, 
     
    5769                try{ 
    5870                        String authorColumn = CitationFormat.getAuthorColumnByName(fileFormat); 
    59                         GraphContainer gc = GraphContainer.initializeGraph(dataTable, authorColumn, authorColumn, false, metaData, this.logger); 
     71                        GraphContainer gc = GraphContainer.initializeGraph(dataTable, authorColumn, authorColumn, false, metaData, this.logger,this.progressMonitor); 
    6072                        final prefuse.data.Graph outputGraph = gc.buildGraph(authorColumn, authorColumn, "|", this.logger); 
    6173                        final Data outputData1 = new BasicData(outputGraph, 
  • trunk/plugins/analysis/edu.iu.nwb.analysis.extractcoauthorship/src/edu/iu/nwb/analysis/extractcoauthorship/algorithms/ExtractAlgorithmFactory.java

    r2207 r2402  
    3636 
    3737                String[] supportedFormats = SupportedFileTypes.supportedFormats; 
    38                  
    39                 for(int i = 0; i < supportedFormats.length; i++){ 
    40                         System.out.println(supportedFormats[i]); 
    41                 } 
    4238 
    4339                definition.addAttributeDefinition(ObjectClassDefinition.REQUIRED, 
  • trunk/plugins/analysis/edu.iu.nwb.analysis.extractcoauthorship/src/edu/iu/nwb/analysis/extractcoauthorship/metadata/SupportedFileTypes.java

    r2207 r2402  
    1212         
    1313        public class CitationFormat{ 
    14                 String name; 
    15                 String authorColumn; 
    1614                private static HashMap nameToColumn = new HashMap(); 
    1715                 
    1816                public CitationFormat(String name, String authorColumn){ 
    19                         this.name = name; 
    20                         this.authorColumn = authorColumn; 
    21                         CitationFormat.nameToColumn.put(this.name, this.authorColumn); 
     17                        CitationFormat.nameToColumn.put(name, authorColumn); 
    2218                } 
    2319 
    24                 public String getName(){ 
    25                         return this.name; 
    26                 } 
    27                  
    28                 public String getAuthorColumn(){ 
    29                         return this.authorColumn; 
    30                 } 
    31                  
    3220                public static String getAuthorColumnByName(String name){ 
    3321                        return CitationFormat.nameToColumn.get(name).toString(); 
  • trunk/plugins/analysis/edu.iu.nwb.analysis.extractdirectednetfromtable/src/edu/iu/nwb/analysis/extractdirectednetfromtable/algorithms/ExtractDirectedNetworkAlgorithm.java

    r2245 r2402  
    77import org.cishell.framework.algorithm.Algorithm; 
    88import org.cishell.framework.algorithm.AlgorithmExecutionException; 
     9import org.cishell.framework.algorithm.ProgressMonitor; 
     10import org.cishell.framework.algorithm.ProgressTrackable; 
    911import org.cishell.framework.data.BasicData; 
    1012import org.cishell.framework.data.Data; 
     
    1719import edu.iu.nwb.analysis.extractnetfromtable.components.PropertyHandler; 
    1820 
    19 public class ExtractDirectedNetworkAlgorithm implements Algorithm
     21public class ExtractDirectedNetworkAlgorithm implements Algorithm, ProgressTrackable
    2022    Data[] data; 
    2123    Dictionary parameters; 
    2224    CIShellContext context; 
    2325    LogService logger; 
     26    ProgressMonitor progressMonitor; 
    2427     
    25     public ExtractDirectedNetworkAlgorithm(Data[] data, Dictionary parameters, CIShellContext context) { 
     28     
     29     
     30    public ProgressMonitor getProgressMonitor() { 
     31                // TODO Auto-generated method stub 
     32                return this.progressMonitor; 
     33        } 
     34 
     35        public void setProgressMonitor(ProgressMonitor monitor) { 
     36                this.progressMonitor = monitor; 
     37        } 
     38 
     39        public ExtractDirectedNetworkAlgorithm(Data[] data, Dictionary parameters, CIShellContext context) { 
    2640        this.data = data; 
    2741        this.parameters = parameters; 
     
    4963         
    5064        try{ 
    51         GraphContainer gc = GraphContainer.initializeGraph(dataTable, sourceColumn, targetColumn, true,functions, this.logger); 
     65        GraphContainer gc = GraphContainer.initializeGraph(dataTable, sourceColumn, targetColumn, true,functions, this.logger,this.progressMonitor); 
    5266        Graph directedNetwork = gc.buildGraph(sourceColumn, targetColumn, split, this.logger); 
    5367         
  • trunk/plugins/analysis/edu.iu.nwb.analysis.extractnetfromtable/src/edu/iu/nwb/analysis/extractnetfromtable/components/GraphContainer.java

    r2251 r2402  
    88import java.util.regex.Pattern; 
    99 
     10import org.cishell.framework.algorithm.ProgressMonitor; 
    1011import org.osgi.service.log.LogService; 
    1112 
     
    2223        private AggregateFunctionMappings nodeMap; 
    2324        private AggregateFunctionMappings edgeMap; 
     25        private ProgressMonitor progMonitor = null; 
    2426 
    2527        public GraphContainer(Graph g, Table t, AggregateFunctionMappings nodeFunctionMap, AggregateFunctionMappings edgeFunctionMap){ 
     
    3032        } 
    3133 
     34        public GraphContainer(Graph g, Table t, AggregateFunctionMappings nodeFunctionMap, AggregateFunctionMappings edgeFunctionMap, ProgressMonitor pm){ 
     35                this.graph = g; 
     36                this.table = t; 
     37                this.nodeMap = nodeFunctionMap; 
     38                this.edgeMap = edgeFunctionMap; 
     39                this.progMonitor = pm; 
     40        } 
     41 
    3242        public Graph buildGraph(String sourceColumnName, String targetColumnName, String splitString, LogService log){ 
    3343                if(this.graph.isDirected()){ 
     
    3747                } 
    3848        } 
    39          
     49 
    4050        private Graph buildUndirectedGraph(String sourceColumnName, String targetColumnName, String splitString, LogService log){ 
    4151                boolean dupValues = false; 
    4252                final HashMap dupValuesErrorMessages = new HashMap(); 
    43                  
    44                  
    45                  
     53                int rows = this.table.getRowCount(); 
     54                int count = 0; 
     55 
     56                if(this.progMonitor != null){ 
     57                        this.progMonitor.start(ProgressMonitor.WORK_TRACKABLE, rows); 
     58                } 
     59 
    4660                for (Iterator it = this.table.rows(); it.hasNext();){ 
    4761                        Node node1 = null; 
     
    6579                                                        if(seenObject.add(objects[j])){ //no duplicate nodes. 
    6680                                                                node2 = NodeContainer.mutateNode(objects[j], this.graph, this.table, row, this.nodeMap, AggregateFunctionMappings.SOURCEANDTARGET); 
    67                                                                  
     81 
    6882                                                        } 
    6983                                                        //create or modify an edge as necessary 
     
    87101                                //ExtractNetworkFromTable.printNoValueToExtractError(title, columnName, this.log); 
    88102                        } 
     103                        count = count+1; 
     104                        if(this.progMonitor != null) 
     105                                this.progMonitor.worked(count); 
     106 
    89107                } 
    90108                for(Iterator dupIter = dupValuesErrorMessages.keySet().iterator(); dupIter.hasNext();){ 
    91109                        log.log(LogService.LOG_WARNING, (String)dupValuesErrorMessages.get(dupIter.next())); 
    92110                } 
    93                  
     111 
    94112                return this.graph; 
    95113        } 
    96          
     114 
    97115        private Graph buildDirectedGraph(String sourceColumnName, String targetColumnName, String splitString, LogService log){ 
    98116                final Pattern p = Pattern.compile("\\Q" + splitString + "\\E"); 
     
    102120                Node node1; 
    103121                Node node2; 
     122 
     123                int rows = this.table.getRowCount(); 
     124                int count = 0; 
     125 
     126                if(this.progMonitor != null){ 
     127                        this.progMonitor.start(ProgressMonitor.WORK_TRACKABLE, rows); 
     128                } 
     129 
    104130                for (Iterator it = this.table.rows(); it.hasNext();){ 
    105131 
     
    119145                                        if(seenSource.add(sources[i])){  
    120146                                                node1 = NodeContainer.mutateNode(sources[i],this.graph,this.table,row,this.nodeMap,AggregateFunctionMappings.SOURCE); 
    121                                                        seenTarget = new HashSet(); 
    122                                                  
     147                                                seenTarget = new HashSet(); 
     148 
    123149                                                for (int j = 0; j < targets.length; j++) { 
    124                                                                if(seenTarget.add(targets[j])){ 
    125                                                                        node2 = NodeContainer.mutateNode(targets[j],this.graph,this.table,row,this.nodeMap,AggregateFunctionMappings.TARGET); 
    126                                                                  
    127                                                                        EdgeContainer.mutateEdge(node1,node2,this.graph,this.table,row,this.edgeMap); 
     150                                                        if(seenTarget.add(targets[j])){ 
     151                                                                node2 = NodeContainer.mutateNode(targets[j],this.graph,this.table,row,this.nodeMap,AggregateFunctionMappings.TARGET); 
     152 
     153                                                                EdgeContainer.mutateEdge(node1,node2,this.graph,this.table,row,this.edgeMap); 
    128154                                                        } 
    129155                                                } 
    130156                                        } 
    131157                                } 
    132                
    133                 else{ 
     158                       
     159                       else{ 
    134160                                //String title = (String)pdt.get(row,pdt.getColumnNumber("TI")); 
    135161                                String title = "unknown"; 
    136162                                //ExtractNetworkFromTable.printNoValueToExtractError(title, sourceColumnName, log); 
    137163                        } 
     164                        count = count+1; 
     165                        if(this.progMonitor != null) 
     166                                this.progMonitor.worked(count); 
    138167                } 
    139168                for(Iterator dupIter = dupValuesErrorMessages.keySet().iterator(); dupIter.hasNext();){ 
     
    144173                return this.graph; 
    145174        } 
    146          
     175 
    147176        public static GraphContainer initializeGraph(Table pdt,String sourceColumnName, String targetColumnName, boolean isDirected,Properties p, LogService log) throws InvalidColumnNameException{ 
    148177 
     
    151180                if(inputSchema.getColumnIndex(sourceColumnName) < 0) 
    152181                        throw new InvalidColumnNameException(sourceColumnName + " was not a column in this table.\n"); 
    153                  
     182 
    154183                if(inputSchema.getColumnIndex(targetColumnName) < 0) 
    155184                        throw new InvalidColumnNameException(targetColumnName + " was not a column in this table.\n"); 
     
    157186                Schema nodeSchema = createNodeSchema(); 
    158187                Schema edgeSchema = createEdgeSchema(); 
    159                  
     188 
    160189                AggregateFunctionMappings nodeAggregateFunctionMap = new AggregateFunctionMappings(); 
    161190                AggregateFunctionMappings edgeAggregateFunctionMap = new AggregateFunctionMappings(); 
    162                  
     191 
    163192                AggregateFunctionMappings.parseProperties(inputSchema, nodeSchema, edgeSchema, p,  
    164193                                nodeAggregateFunctionMap, edgeAggregateFunctionMap, log);        
     
    166195                Graph outputGraph = new Graph(nodeSchema.instantiate(), 
    167196                                edgeSchema.instantiate(), isDirected); 
    168                  
    169                  
     197 
     198 
    170199 
    171200                return new GraphContainer(outputGraph,pdt,nodeAggregateFunctionMap,edgeAggregateFunctionMap); 
     201 
     202        } 
     203         
     204        public static GraphContainer initializeGraph(Table pdt,String sourceColumnName, String targetColumnName, boolean isDirected,Properties p, LogService log, ProgressMonitor pm) throws InvalidColumnNameException{ 
     205 
     206                final Schema inputSchema = pdt.getSchema(); 
     207 
     208                if(inputSchema.getColumnIndex(sourceColumnName) < 0) 
     209                        throw new InvalidColumnNameException(sourceColumnName + " was not a column in this table.\n"); 
     210 
     211                if(inputSchema.getColumnIndex(targetColumnName) < 0) 
     212                        throw new InvalidColumnNameException(targetColumnName + " was not a column in this table.\n"); 
     213 
     214                Schema nodeSchema = createNodeSchema(); 
     215                Schema edgeSchema = createEdgeSchema(); 
     216 
     217                AggregateFunctionMappings nodeAggregateFunctionMap = new AggregateFunctionMappings(); 
     218                AggregateFunctionMappings edgeAggregateFunctionMap = new AggregateFunctionMappings(); 
     219 
     220                AggregateFunctionMappings.parseProperties(inputSchema, nodeSchema, edgeSchema, p,  
     221                                nodeAggregateFunctionMap, edgeAggregateFunctionMap, log);        
     222 
     223                Graph outputGraph = new Graph(nodeSchema.instantiate(), 
     224                                edgeSchema.instantiate(), isDirected); 
     225 
     226 
     227 
     228                return new GraphContainer(outputGraph,pdt,nodeAggregateFunctionMap,edgeAggregateFunctionMap,pm); 
    172229 
    173230        }