|
From: <tea...@us...> - 2007-07-25 20:51:02
|
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.
|