From: <bea...@us...> - 2006-10-16 15:04:32
|
Revision: 280 http://svn.sourceforge.net/cishell/?rev=280&view=rev Author: bearsfan Date: 2006-10-16 08:04:20 -0700 (Mon, 16 Oct 2006) Log Message: ----------- Changed the title in the SaveDataChooser, added NullConverter, and a check for a converter path to itself Modified Paths: -------------- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/Save.java trunk/core/org.cishell.reference/src/org/cishell/reference/service/conversion/DataConversionServiceImpl.java Added Paths: ----------- trunk/core/org.cishell.reference/src/org/cishell/reference/service/conversion/NullConverter.java Modified: trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/Save.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/Save.java 2006-10-14 15:53:43 UTC (rev 279) +++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/Save.java 2006-10-16 15:04:20 UTC (rev 280) @@ -67,7 +67,7 @@ public void run() { SaveDataChooser sdc = new SaveDataChooser(data[0], parentShell, converters, - "title", + "Save", context); sdc.createContent(parentShell); sdc.open(); Modified: trunk/core/org.cishell.reference/src/org/cishell/reference/service/conversion/DataConversionServiceImpl.java =================================================================== --- trunk/core/org.cishell.reference/src/org/cishell/reference/service/conversion/DataConversionServiceImpl.java 2006-10-14 15:53:43 UTC (rev 279) +++ trunk/core/org.cishell.reference/src/org/cishell/reference/service/conversion/DataConversionServiceImpl.java 2006-10-16 15:04:20 UTC (rev 280) @@ -24,6 +24,7 @@ import java.util.List; import java.util.Map; import java.util.Set; +import java.util.regex.Pattern; import org.cishell.framework.CIShellContext; import org.cishell.framework.algorithm.AlgorithmFactory; @@ -191,6 +192,13 @@ //in=file:text/graphml out=file:* If so, need to add a null converter //(w/ 0 sized servicereference array) to the converterList + if (outFormat.indexOf('*') != -1) { + String outFormatCopy = outFormat.replaceAll("[*]", ".*"); + if (Pattern.matches(outFormatCopy, inFormat)) { + converterList.add(new NullConverter(inFormat)); + } + } + try { ServiceReference[] inRefs = bContext.getServiceReferences( AlgorithmFactory.class.getName(), inFilter); @@ -230,10 +238,6 @@ Vertex srcVertex = (Vertex)dataTypeToVertex.get(inType); Vertex tgtVertex = (Vertex)dataTypeToVertex.get(outType); - if (srcVertex.equals(tgtVertex)) { - return new ConverterImpl(bContext, ciContext, new ServiceReference[0]); - } - if (srcVertex != null && tgtVertex != null) { DijkstraShortestPath shortestPathAlg = new DijkstraShortestPath(graph); List edgeList = shortestPathAlg.getPath(srcVertex, tgtVertex); Added: trunk/core/org.cishell.reference/src/org/cishell/reference/service/conversion/NullConverter.java =================================================================== --- trunk/core/org.cishell.reference/src/org/cishell/reference/service/conversion/NullConverter.java (rev 0) +++ trunk/core/org.cishell.reference/src/org/cishell/reference/service/conversion/NullConverter.java 2006-10-16 15:04:20 UTC (rev 280) @@ -0,0 +1,121 @@ +/* **************************************************************************** + * CIShell: Cyberinfrastructure Shell, An Algorithm Integration Framework. + * + * All rights reserved. This program and the accompanying materials are made + * available under the terms of the Apache License v2.0 which accompanies + * this distribution, and is available at: + * http://www.apache.org/licenses/LICENSE-2.0.html + * + * Created on Jul 20, 2006 at Indiana University. + * + * Contributors: + * Indiana University - + * ***************************************************************************/ +package org.cishell.reference.service.conversion; + +import java.util.Dictionary; +import java.util.Hashtable; + +import org.cishell.framework.CIShellContext; +import org.cishell.framework.algorithm.Algorithm; +import org.cishell.framework.algorithm.AlgorithmFactory; +import org.cishell.framework.algorithm.AlgorithmProperty; +import org.cishell.framework.data.Data; +import org.cishell.service.conversion.Converter; +import org.osgi.framework.ServiceReference; +import org.osgi.service.metatype.MetaTypeProvider; + +/** + * + * @author Bruce Herr (bh...@bh...) + */ +public class NullConverter implements Converter, AlgorithmFactory, AlgorithmProperty, Comparable { + private Dictionary props; + + + public NullConverter(String inData) { + props = new Hashtable(); + + props.put(IN_DATA, inData); + props.put(OUT_DATA, inData); + props.put(LABEL, props.get(IN_DATA) + " -> " + props.get(OUT_DATA)); + + String lossiness = LOSSLESS; + + //TODO: Do the same thing for complexity + props.put(CONVERSION, lossiness); + } + + /** + * @see org.cishell.service.conversion.Converter#convert(org.cishell.framework.data.Data) + */ + public Data convert(Data inDM) { + return inDM; + } + + + /** + * @see org.cishell.service.conversion.Converter#getAlgorithmFactory() + */ + public AlgorithmFactory getAlgorithmFactory() { + return this; + } + + /** + * @see org.cishell.service.conversion.Converter#getConverterChain() + */ + public ServiceReference[] getConverterChain() { + return new ServiceReference[0]; + } + + /** + * @see org.cishell.service.conversion.Converter#getProperties() + */ + public Dictionary getProperties() { + return props; + } + + public Algorithm createAlgorithm(Data[] dm, Dictionary parameters, CIShellContext context) { + return new ConverterAlgorithm(dm, parameters, context); + } + + public MetaTypeProvider createParameters(Data[] dm) { + return null; + } + + public boolean equals(Object o) { + boolean equals = false; + if (o instanceof Converter) { + ServiceReference[] otherServiceReference = ((Converter)o).getConverterChain(); + if (otherServiceReference.length == 0) { + Dictionary otherDictionary = ((Converter)o).getProperties(); + if (otherDictionary.get(IN_DATA).equals(props.get(IN_DATA)) && + otherDictionary.get(OUT_DATA).equals(props.get(OUT_DATA))) { + equals = true; + } + } + } + + return equals; + } + + private class ConverterAlgorithm implements Algorithm { + Data[] inDM; + CIShellContext context; + Dictionary parameters; + + public ConverterAlgorithm(Data[] dm, Dictionary parameters, CIShellContext context) { + this.inDM = dm; + this.parameters = parameters; + this.context = context; + } + + public Data[] execute() { + return inDM; + } + } + + public int compareTo(Object o) { + return equals(o) ? 0 : 1; + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |