001    // GraphLab Project: http://graphlab.sharif.edu
002    // Copyright (C) 2008 Mathematical Science Department of Sharif University of Technology
003    // Distributed under the terms of the GNU General Public License (GPL): http://www.gnu.org/licenses/
004    
005    package graphlab.plugins.connector;
006    
007    
008    
009    import graphlab.platform.attribute.AttributeSet;
010    import graphlab.platform.attribute.AttributeSetImpl;
011    import graphlab.platform.core.BlackBoard;
012    import graphlab.platform.parameter.Parameter;
013    import graphlab.platform.parameter.Parametrizable;
014    import graphlab.plugins.commandline.Shell;
015    import graphlab.plugins.main.GraphData;
016    import graphlab.plugins.reports.extension.GraphReportExtension;
017    
018    import java.io.File;
019    
020    /**
021     * @author Mohammad Ali Rostami
022     * @email ma.rostami@yahoo.com
023     */
024    
025    public class ConnectorReportExtension implements GraphReportExtension, Parametrizable {
026        File matlabFile;
027        private BlackBoard blackboard;
028        private ConnectorDS connectorDs;
029    
030    
031        @Parameter
032        public AttributeSet atrs = new AttributeSetImpl();
033    
034    
035        public ConnectorReportExtension(File matlabFile, BlackBoard blackboard, ConnectorDS connectorDs) {
036            this.matlabFile = matlabFile;
037            this.blackboard = blackboard;
038            this.connectorDs = connectorDs;
039            this.atrs = connectorDs.atrs;
040        }
041    
042        public String getName() {
043            return connectorDs.commandName;
044        }
045    
046        public String getDescription() {
047            return connectorDs.description;
048        }
049    
050        public Object calculate(GraphData gd) {
051            Shell currentShell = Shell.getCurrentShell(blackboard);
052            String args = connectorDs.getArgs(); //this works becase atrs in this class points to atrs in connectorDS (they are the same!)
053            return currentShell.evaluate(connectorDs.commandName + "(" + args + ")");
054        }
055    
056        public String checkParameters() {
057            return null;
058        }
059    }