Package org.cishell.service.conversion

Examples of org.cishell.service.conversion.DataConversionService


        && inData[0].equalsIgnoreCase(AlgorithmProperty.NULL_DATA)) {
      this.inputData = new Data[0];
    } else if (selectedData == null) {
      this.inputData = null;
    } else {
      DataConversionService converter = (DataConversionService) Activator
          .getCiShellContext().getService(
              DataConversionService.class.getName());

      List<Data> dataSet = new ArrayList<Data>(
          Arrays.asList(selectedData));
      this.inputData = new Data[inData.length];
      this.converters = new Converter[inData.length][];
      for (int ii = 0; ii < inData.length; ii++) {
        for (int jj = 0; jj < dataSet.size(); jj++) {
          Data datum = (Data) dataSet.get(jj);
          if (datum != null) {
            if (isAssignableFrom(inData[ii], datum)) {
              dataSet.remove(jj);
              this.inputData[ii] = datum;
              this.converters[ii] = null;
            } else {
              Converter[] conversion = converter.findConverters(
                  datum, inData[ii]);

              if (conversion.length > 0) {
                dataSet.remove(jj);
                this.inputData[ii] = datum;
View Full Code Here


   * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
   */
  public void start(BundleContext bundleContext) throws Exception {
        CIShellContext ciShellContext = new LocalCIShellContext(bundleContext);
       
        DataConversionService conversionService =
          new DataConversionServiceImpl(bundleContext, ciShellContext);
        this.conversionRegistration = bundleContext.registerService(
          DataConversionService.class.getName(),
          conversionService,
          new Hashtable<String, Object>());
View Full Code Here

   
    /**
     * @see org.cishell.remoting.service.conversion.RemoteDataConversionService#convert(java.lang.String, java.lang.String)
     */
    public String convert(String dataModelID, String outFormat) {
        DataConversionService converter = getConverter();
        String id = "-1";
       
        DataModelRegistry dmRegistry = (DataModelRegistry) dmReg.getService();
       
        Data dm = dmRegistry.getDataModel(dataModelID);
        if (dm != null) {
            try {
        dm = converter.convert(dm, outFormat);
      } catch (ConversionException e) {
        dm = null;
      }
           
            if (dm != null) {
View Full Code Here

    /**
     * @see org.cishell.remoting.service.conversion.RemoteDataConversionService#findConverter(java.util.Vector, java.util.Vector)
     */
    public Vector findConverter(Vector inFormats, Vector outFormats) {
        DataConversionService converter = getConverter();
       
        for (Iterator i=inFormats.iterator(); i.hasNext(); ) {
            String inFormat = (String) i.next();
           
            for (Iterator j=outFormats.iterator(); j.hasNext(); ) {
                String outFormat = (String) j.next();
               
                Converter[] c = converter.findConverters(inFormat, outFormat);
                if (c.length > 0) {
                    Vector v = new Vector();
                    v.add(inFormat);
                    v.add(outFormat);
                   
View Full Code Here

            //find file-friendly format to convert to
            String format = dm.getFormat();
            String finalOutFormat = null;
           
            if (format == null || !format.startsWith("file:")) {
                DataConversionService converter = (DataConversionService)
                    ciContext.getService(DataConversionService.class.getName());
               
                Converter[] converters = converter.findConverters(dm, "file:*");
               
                if (converters.length > 0) {
                    //see if the server has a converter to convert from a file back
                    //to the data model's original format
                   
                    Set inFormats = new HashSet();
                    Set outFormats = new HashSet();
                   
                    for (int i=0; i < converters.length; i++) {
                        inFormats.add(converters[i].getProperties().get(AlgorithmProperty.IN_DATA));
                        outFormats.add(converters[i].getProperties().get(AlgorithmProperty.OUT_DATA));
                    }
                   
                    Vector inF = new Vector(inFormats);
                    Vector outF = new Vector(outFormats);
                   
                    //give them the format that will come in (the out format on the client)
                    //and what it will need to convert back to on the other side (the in
                    //format on the client)
                    Vector conversion = remoteConverter.findConverter(outF, inF);
                   
                    if (conversion != null && conversion.size() > 0) {
                        format = (String)conversion.get(0);
                        finalOutFormat = (String)conversion.get(1);
                       
                        try {
              dm = converter.convert(dm, format);
            } catch (ConversionException e) {
              dm = null;
            }
                    }
                } else {
View Full Code Here

    /**
     * @see org.cishell.remoting.service.framework.DataModelRegistry#getData(String, String)
     */
    public byte[] getData(String dataModelID, String format) {
        DataConversionService converter = (DataConversionService)
            ciContext.getService(DataConversionService.class.getName());
       
        Data dm = getDataModel(dataModelID);
        try {
      dm = converter.convert(dm, format);
    } catch (ConversionException e1) {
      dm = null;
    }
        byte[] data = null;
       
View Full Code Here

        public Object getData() {
            String format = getFormat();
           
            if (!gotData && format != null) {               
                DataConversionService converter = (DataConversionService)
                    ciContext.getService(DataConversionService.class.getName());
               
                Converter[] convert = new Converter[0];
               
                Vector conversions = remoteConverter.getConversions(dmID, "file:*");
                for (int i=0; i < conversions.size(); i++) {
                    String outFormat = (String) conversions.get(i);
                   
                    convert = converter.findConverters(outFormat, format);
                    if (convert.length > 0) {
                        break;
                    }
                }
               
View Full Code Here


public class FileViewFactory implements AlgorithmFactory {
  public Algorithm createAlgorithm(
      Data[] data, Dictionary<String, Object> parameters, CIShellContext ciShellContext) {
    DataConversionService conversionManager =
      (DataConversionService) ciShellContext.getService(
        DataConversionService.class.getName());
    LogService logger = (LogService) ciShellContext.getService(LogService.class.getName());

        return new FileView(data, ciShellContext, conversionManager, logger);
View Full Code Here

        if ((inData.length == 1) && inData[0].equalsIgnoreCase(NULL_DATA)) {
            this.data = new Data[0];
        } else if (selectedData == null) {
            this.data = null;
        } else {
            DataConversionService converter =
              (DataConversionService) this.ciShellContext.getService(
                DataConversionService.class.getName());
           
            List<Data> dataSet = new ArrayList<Data>(Arrays.asList(selectedData));
            this.data = new Data[inData.length];
            this.converters = new Converter[inData.length][];
           
            for (int ii = 0; ii < inData.length; ii++) {
                for (int jj = 0; jj < dataSet.size(); jj++) {
                    Data datum = (Data) dataSet.get(jj);
                   
                    if (datum != null) {
                        if (isAssignableFrom(inData[ii], datum)) {
                            dataSet.remove(jj);
                            this.data[ii] = datum;
                            this.converters[ii] = null;
                        } else {
                            Converter[] conversion = converter.findConverters(datum, inData[ii]);
                           
                            if (conversion.length > 0) {
                                dataSet.remove(jj);
                                this.data[ii] = datum;
                                this.converters[ii] = conversion;
View Full Code Here

TOP

Related Classes of org.cishell.service.conversion.DataConversionService

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.