|
From: Bruce H. <bh...@bh...> - 2007-07-26 19:50:19
|
Please don't use Java 1.5 features. Everything in CIShell must stay 1.4 to maximize the number of environments it can run in. Bruce On 7/25/07, tea...@us... <tea...@us...> wrote: > Revision: 439 > http://cishell.svn.sourceforge.net/cishell/?rev=439&view=rev > Author: teakettle22 > Date: 2007-07-25 13:50:58 -0700 (Wed, 25 Jul 2007) > > Log Message: > ----------- > first implementation of the converter graph. Warning!!! Many errors; unusable, committing to store it so that I don't rely on local storage. > > Added Paths: > ----------- > trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/converter/graph/ > trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/converter/graph/ConverterGraph.java > trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/converter/graph/ConverterNode.java > trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/converter/graph/ConverterPath.java > > Added: trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/converter/graph/ConverterGraph.java > =================================================================== > --- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/converter/graph/ConverterGraph.java (rev 0) > +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/converter/graph/ConverterGraph.java 2007-07-25 20:50:58 UTC (rev 439) > @@ -0,0 +1,124 @@ > +package org.cishell.testing.convertertester.core.converter.graph; > + > +import java.util.ArrayList; > +import java.util.HashMap; > +import java.util.Map; > + > +import org.osgi.framework.ServiceReference; > + > +public class ConverterGraph { > + prefuse.data.Graph converterGraph; > + Map<String, ArrayList<ServiceReference>> inDataToAlgorithm; > + Map<String, ArrayList<ConverterPath>> fileExtensionTestConverters; > + Map<String, ConverterPath> fileExtensionCompareConverters; > + ServiceReference[] converters; > + private static final String testOutData = "prefuse.data.Graph"; > + > + public ConverterGraph(ServiceReference[] converters){ > + this.converters = converters; > + inDataToAlgorithm = new HashMap<String, ArrayList<ServiceReference>>(); > + fileExtensionTestConverters = new HashMap<String, ArrayList<ConverterPath>>(); > + fileExtensionCompareConverters = new HashMap<String, ConverterPath>(); > + > + associateAlgorithms(this.converters, this.inDataToAlgorithm); > + createConverterPaths(this.inDataToAlgorithm, this.fileExtensionTestConverters, this.fileExtensionCompareConverters); > + } > + > + private void associateAlgorithms(ServiceReference[] sr, Map<String, ArrayList<ServiceReference>> hm){ > + for(ServiceReference srv : sr){ > + String s = srv.getProperty("in_data").toString(); > + if(hm.get(s) == null){ > + ArrayList<ServiceReference> al = new ArrayList<ServiceReference>(); > + al.add(srv); > + hm.put(s, al); > + } > + else{ > + hm.get(s).add(srv); > + } > + } > + } > + > + private void createConverterPaths(Map<String, ArrayList<ServiceReference>> algorithms, Map<String, ArrayList<ConverterPath>> testPaths, > + Map<String, ConverterPath> comparePaths){ > + > + for(String s : algorithms.keySet()){ > + if(s.startsWith("file-ext")){ > + > + > + ConverterPath test = new ConverterPath(); > + //ConverterPath > + test.setInData(s); > + createPaths(algorithms, testPaths, comparePaths, test, s); > + } > + } > + } > + > + private void createPaths(Map<String,ArrayList<ServiceReference>> algorithms, Map<String, ArrayList<ConverterPath>> testPaths, > + Map<String, ConverterPath> comparePaths, ConverterPath path, String dataType){ > + /* > + if(path.getInData().equals(path.getOutData())){ > + if(testPaths.get(path.getInData()) == null){ > + ArrayList<ConverterPath> paths = new ArrayList<ConverterPath>(); > + paths.add(new ConverterPath(path)); > + testPaths.put(path.getInData(), paths); > + System.out.println(path); > + } > + else{ > + testPaths.get(path.getInData()).add(new ConverterPath(path)); > + System.out.println(path); > + } > + }*/ > + try{ > + ArrayList<ServiceReference> algs = new ArrayList<ServiceReference>(algorithms.get(dataType)); > + > + algs.removeAll(path.getPath()); > + for(ServiceReference sr : algs){ > + //for(ServiceReference sr: algs){ > + System.out.println(sr.getProperty("service.pid")); > + //} > + ConverterPath p = new ConverterPath(path); > + System.out.println(); > + if(p.addAlgoritm(sr)){ > + algs.remove(sr); > + createPaths(algorithms, testPaths,comparePaths,p,p.getOutData()); > + } > + > + else{ > + if(testPaths.get(path.getInData()) == null){ > + ArrayList<ConverterPath> paths = new ArrayList<ConverterPath>(); > + paths.add(p); > + testPaths.put(path.getInData(), paths); > + System.out.println(p); > + } > + else{ > + testPaths.get(path.getInData()).add(p); > + System.out.println(p); > + } > + algs.remove(sr); > + } > + } > + }catch(NullPointerException npe){ > + npe.printStackTrace(); > + } > + } > + > + > + > + public String toString(){ > + String str = ""; > + for(String s : this.inDataToAlgorithm.keySet()){ > + str += s + "\n"; > + for(ServiceReference sr : this.inDataToAlgorithm.get(s)){ > + str += "\t" + sr.getProperty("service.pid") + "\n"; > + } > + } > + > + for(String s : this.fileExtensionTestConverters.keySet()){ > + for(ConverterPath cp : this.fileExtensionTestConverters.get(s)){ > + str += cp.toString(); > + } > + } > + > + return str; > + } > +} > \ No newline at end of file > > Added: trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/converter/graph/ConverterNode.java > =================================================================== > --- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/converter/graph/ConverterNode.java (rev 0) > +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/converter/graph/ConverterNode.java 2007-07-25 20:50:58 UTC (rev 439) > @@ -0,0 +1,32 @@ > +package org.cishell.testing.convertertester.core.converter.graph; > + > +public class ConverterNode { > + String name; > + int id; > + > + public ConverterNode(String s, int i){ > + name = s; > + id = i; > + } > + > + public String getName(){ > + return name; > + } > + > + public int getID(){ > + return id; > + } > + > + public void setName(String s){ > + name = s; > + } > + > + public void setID(int i){ > + id = i; > + } > + > + public String toString(){ > + return name + " " + id; > + } > + > +} > > Added: trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/converter/graph/ConverterPath.java > =================================================================== > --- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/converter/graph/ConverterPath.java (rev 0) > +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/converter/graph/ConverterPath.java 2007-07-25 20:50:58 UTC (rev 439) > @@ -0,0 +1,69 @@ > +package org.cishell.testing.convertertester.core.converter.graph; > + > +import java.util.ArrayList; > +import java.util.List; > + > +import org.osgi.framework.ServiceReference; > + > +public class ConverterPath { > + String in_data; > + String out_data = null; > + ArrayList<ServiceReference> path; > + > + public ConverterPath(){ > + path = new ArrayList<ServiceReference>(); > + } > + > + public ConverterPath(ConverterPath p){ > + in_data = p.getInData(); > + out_data = p.getOutData(); > + > + this.path = new ArrayList<ServiceReference>(p.getPath()); > + > + } > + > + public void setInData(String s){ > + this.in_data = s; > + } > + > + public void setOutData(String s){ > + this.out_data = s; > + } > + > + public boolean addAlgoritm(ServiceReference sr){ > + boolean val = true; > + //System.out.println(this.in_data + " " + this.out_data); > + if(path.contains(sr)){ > + System.out.println("Path already contains " + sr.getProperty("service.pid")); > + //this.setOutData(sr.getProperty("out_data").toString()); > + return false; > + } > + //System.out.println("Adding: " + sr.getProperty("service.pid")); > + path.add(sr); > + this.setOutData(sr.getProperty("out_data").toString()); > + return val; > + } > + > + public String getInData(){ > + return this.in_data; > + } > + > + public String getOutData(){ > + return this.out_data; > + } > + > + public List<ServiceReference> getPath(){ > + return this.path; > + } > + > + public String toString(){ > + String val = this.in_data +" -->\n"; > + > + for(ServiceReference sr : this.path){ > + val += "\t" + sr.getProperty("service.pid") + "\n"; > + } > + val += "--> " + this.out_data + "\n"; > + return val; > + } > + > +} > > > This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Splunk Inc. > Still grepping through log files to find problems? Stop. > Now Search log events and configuration files using AJAX and a browser. > Download your FREE copy of Splunk now >> http://get.splunk.com/ > _______________________________________________ > Cishell-svn mailing list > Cis...@li... > https://lists.sourceforge.net/lists/listinfo/cishell-svn > -- Bruce Herr Senior Software Developer Cyberinfrastructure for Network Science Center School of Library and Information Science Indiana University 10th Street & Jordan Avenue Phone: (812) 856-7034 Fax: -6166 Main Library 022 E-mail: bh...@bh... Bloomington, IN 47405, USA |
|
From: Bruce H. <bh...@bh...> - 2007-07-30 18:05:51
|
Last time I made a commit with a "blah" in it, it was with Professor
Rawlins on Fluency. Yeah, he had a cow. I'm not gonna have a cow, but
please don't commit 'blahs' :-P
> + System.out.println("Blah!");
Bruce
On 7/30/07, tea...@us...
<tea...@us...> wrote:
> Revision: 445
> http://cishell.svn.sourceforge.net/cishell/?rev=445&view=rev
> Author: teakettle22
> Date: 2007-07-30 10:54:45 -0700 (Mon, 30 Jul 2007)
>
> Log Message:
> -----------
> fixed some errors, return cast arrays rather than ArrayLists.
>
> Modified Paths:
> --------------
> trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/converter/ConverterLoaderImpl.java
> trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/converter/graph/ConverterGraph.java
>
> Modified: trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/converter/ConverterLoaderImpl.java
> ===================================================================
> --- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/converter/ConverterLoaderImpl.java 2007-07-30 17:28:26 UTC (rev 444)
> +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/converter/ConverterLoaderImpl.java 2007-07-30 17:54:45 UTC (rev 445)
> @@ -60,6 +60,7 @@
> ServiceReference[] refs = bContext.getServiceReferences(
> AlgorithmFactory.class.getName(), filter);
> ConverterGraph g = new ConverterGraph(refs);
> + System.out.println("Blah!");
> System.out.println(g);
> if (refs != null) {
> for (int i = 0; i < refs.length; ++i) {
>
> Modified: trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/converter/graph/ConverterGraph.java
> ===================================================================
> --- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/converter/graph/ConverterGraph.java 2007-07-30 17:28:26 UTC (rev 444)
> +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/converter/graph/ConverterGraph.java 2007-07-30 17:54:45 UTC (rev 445)
> @@ -43,7 +43,8 @@
>
> private void createConverterPaths(Map algorithms, Map testPaths,
> Map comparePaths){
> - String[] keySet = (String[])algorithms.keySet().toArray();
> + String[] keySet = new String[algorithms.keySet().size()];
> + keySet = (String[])algorithms.keySet().toArray(keySet);
> for(int i = 0; i < keySet.length; i++){
> String s = keySet[i];
> if(s.startsWith("file-ext")){
> @@ -155,7 +156,8 @@
>
> public String printTestConverterPaths(){
> StringBuffer sb = new StringBuffer();
> - String[] keySet = (String[])this.fileExtensionTestConverters.keySet().toArray();
> + String[] keySet = new String[this.fileExtensionTestConverters.keySet().size()];
> + keySet = (String[])this.fileExtensionTestConverters.keySet().toArray(keySet);
> for(int i = 0; i < keySet.length; i++){
> String s = keySet[i];
> sb.append(printTestConverterPath(s));
> @@ -183,7 +185,8 @@
>
> public String toString(){
> StringBuffer str = new StringBuffer();
> - String[] keySet = (String[])this.inDataToAlgorithm.keySet().toArray();
> + String[] keySet = new String[this.inDataToAlgorithm.keySet().size()];
> + keySet = (String[])this.inDataToAlgorithm.keySet().toArray(keySet);
> for(int i = 0; i < keySet.length; i++){
> String s = keySet[i];
> str.append(s + "\n");
> @@ -201,29 +204,29 @@
> return str.toString();
> }
>
> - public ArrayList getTestPath(String s){
> - return (ArrayList)this.fileExtensionTestConverters.get(s);
> + public ServiceReference[] getTestPath(String s){
> + return (ServiceReference[])((ArrayList)this.fileExtensionTestConverters.get(s)).toArray();
> }
>
> - public ArrayList getTestPaths(){
> + public ServiceReference[][] getTestPaths(){
> String[] fileExtensions = (String[])this.fileExtensionTestConverters.keySet().toArray();
> ArrayList graphs = new ArrayList();
> for(int i = 0; i < fileExtensions.length; i++){
> graphs.add(getTestPath(fileExtensions[i]));
> }
> - return graphs;
> + return (ServiceReference[][])graphs.toArray();
> }
>
> public ConverterPath getComparePath(String s){
> return (ConverterPath)this.fileExtensionCompareConverters.get(s);
> }
>
> - public ArrayList getComparePaths(){
> + public ServiceReference[] getComparePaths(){
> String[] fileExtensions = (String[])this.fileExtensionCompareConverters.keySet().toArray();
> ArrayList graphs = new ArrayList();
> for(int i = 0; i < fileExtensions.length; i++){
> graphs.add(getComparePath(fileExtensions[i]));
> }
> - return graphs;
> + return (ServiceReference[])graphs.toArray();
> }
> }
> \ No newline at end of file
>
>
> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc.
> Still grepping through log files to find problems? Stop.
> Now Search log events and configuration files using AJAX and a browser.
> Download your FREE copy of Splunk now >> http://get.splunk.com/
> _______________________________________________
> Cishell-svn mailing list
> Cis...@li...
> https://lists.sourceforge.net/lists/listinfo/cishell-svn
>
--
Bruce Herr
Senior Software Developer
Cyberinfrastructure for Network Science Center
School of Library and Information Science
Indiana University
10th Street & Jordan Avenue Phone: (812) 856-7034 Fax: -6166
Main Library 022 E-mail: bh...@bh...
Bloomington, IN 47405, USA
|
|
From: Bruce H. <bh...@bh...> - 2007-08-01 18:57:16
|
Ok, I wasn't kidding... get rid of the System.out.println("Blah!");
Also, is it really necessary to be committing these commented out
debug System.out messages?
Also also, does anyone here actually read what I'm typing. I've yet to
get a reply to any post i've made.
Bruce
On 8/1/07, tea...@us...
<tea...@us...> wrote:
> Revision: 450
> http://cishell.svn.sourceforge.net/cishell/?rev=450&view=rev
> Author: teakettle22
> Date: 2007-08-01 09:47:06 -0700 (Wed, 01 Aug 2007)
>
> Log Message:
> -----------
> added an asNWB function
>
> Modified Paths:
> --------------
> trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/converter/ConverterLoaderImpl.java
> trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/converter/graph/ConverterGraph.java
>
> Modified: trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/converter/ConverterLoaderImpl.java
> ===================================================================
> --- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/converter/ConverterLoaderImpl.java 2007-08-01 16:44:53 UTC (rev 449)
> +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/converter/ConverterLoaderImpl.java 2007-08-01 16:47:06 UTC (rev 450)
> @@ -59,7 +59,8 @@
>
> ServiceReference[] refs = bContext.getServiceReferences(
> AlgorithmFactory.class.getName(), filter);
> - // ConverterGraph g = new ConverterGraph(refs);
> + ConverterGraph g = new ConverterGraph(refs);
> + g.asNWB();
> // System.out.println("Blah!");
> // System.out.println(g);
> if (refs != null) {
>
> Modified: trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/converter/graph/ConverterGraph.java
> ===================================================================
> --- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/converter/graph/ConverterGraph.java 2007-08-01 16:44:53 UTC (rev 449)
> +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/converter/graph/ConverterGraph.java 2007-08-01 16:47:06 UTC (rev 450)
> @@ -245,7 +245,7 @@
> BufferedWriter bw = new BufferedWriter(out);
>
> writeNodes(bw,nodes);
> -
> + writeEdges(bw,output);
> }
> catch(IOException ex){
> System.out.println("Blurt!");
> @@ -255,26 +255,25 @@
>
> private void writeNodeHeader(BufferedWriter bw, int numNodes) throws IOException{
> bw.flush();
> - bw.write("*Nodes " + numNodes);
> + bw.write("*Nodes " + numNodes + "\nid*int label*string\n");
>
> }
>
> private void writeNodes(BufferedWriter bw, Map nodes) throws IOException{
> - System.out.println("*Nodes " + nodes.size());
> + System.out.println("*Nodes " + nodes.size() + "\n");
> writeNodeHeader(bw, nodes.size());
> String[] keySet = new String[nodes.keySet().size()];
> keySet = (String[])nodes.keySet().toArray(keySet);
> -
> for(int i = 0; i < keySet.length; i++){
> bw.flush();
> - bw.write(nodes.get(keySet[i]) + " " + keySet[i]);
> + bw.write(nodes.get(keySet[i]) + " \"" + keySet[i]+"\"\n");
> }
>
> }
>
> private void writeEdgeHeader(BufferedWriter bw, int numEdges) throws IOException{
> bw.flush();
> - bw.write("*DirectedEdges " + numEdges);
> + bw.write("*DirectedEdges " + numEdges + "\nsource*int target*int\n");
> }
>
>
> @@ -288,7 +287,7 @@
> for(int i = 0; i < edgeArray.length; i++){
> System.out.println(edgeArray[i]);
> bw.flush();
> - bw.write(edgeArray[i]);
> + bw.write(edgeArray[i]+"\n");
> }
> }
>
> @@ -307,8 +306,9 @@
> ServiceReference[] references = new ServiceReference[paths.size()];
> references = (ServiceReference[])paths.toArray(references);
>
> - for(int j = 0; j < references.length; j++){
> - nodeNames.add(s);
> + for(int j = 0; j < references.length; j++){
> + ServiceReference r = references[j];
> + nodeNames.add(r.getProperty("service.pid").toString());
> }
> }
>
> @@ -316,6 +316,7 @@
> names = (String[])nodeNames.toArray(names);
>
> for(int i = 0; i < names.length; i++){
> + System.out.println(names[i] + " " + (i+1));
> nodesToInt.put(names[i], new Integer(i+1));
> }
>
> @@ -328,16 +329,23 @@
> keySet = (String[])m.keySet().toArray(keySet);
> for(int i = 0; i < keySet.length; i++){
> String s = keySet[i];
> -
> + System.out.println(keySet[i]);
> ArrayList paths = (ArrayList)this.inDataToAlgorithm.get(s);
> + if(paths != null){
> ServiceReference[] references = new ServiceReference[paths.size()];
> references = (ServiceReference[])paths.toArray(references);
>
> for(int j = 0; j < references.length; j++){
> - String output = m.get(s).toString() + " ";
> - output += m.get(references[j].getProperty("service.pid")).toString();
> - edges.add(output);
> + String output1 = m.get(s).toString() + " ";
> + String output2 = references[j].getProperty("service.pid").toString();
> + output1 += m.get(output2).toString();
> + output2 = m.get(output2).toString() + " " + m.get(references[j].getProperty("out_data")).toString();
> + System.out.println(output1);
> + System.out.println(output2);
> + edges.add(output1);
> + edges.add(output2);
> }
> + }
>
> }
> return edges;
>
>
> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc.
> Still grepping through log files to find problems? Stop.
> Now Search log events and configuration files using AJAX and a browser.
> Download your FREE copy of Splunk now >> http://get.splunk.com/
> _______________________________________________
> Cishell-svn mailing list
> Cis...@li...
> https://lists.sourceforge.net/lists/listinfo/cishell-svn
>
--
Bruce Herr
Senior Software Developer
Cyberinfrastructure for Network Science Center
School of Library and Information Science
Indiana University
10th Street & Jordan Avenue Phone: (812) 856-7034 Fax: -6166
Main Library 022 E-mail: bh...@bh...
Bloomington, IN 47405, USA
|