Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [geclipse-dev] JSDL job description creation

Deer Romain. First of all check if the file is actually created in the local disk and in which folder. Another think is instead of trying to create a new JSDL file from the file instance
try getting it like this
IFolder tempFolder = createTemporaryJSDLFolder();
    IFile tempJSDLFile = createTemporaryJSDLFile(tempFolder);
    IGridElement element = GridModel.getRoot().findElement( tempJSDLFile );
    JSDLJobDescription basicJSDL = null;
    if( element instanceof JSDLJobDescription ) {
      basicJSDL = initializeJSDLJobDescription(( JSDLJobDescription )element);
      basicJSDL.save( tempJSDLFile );
    }

Also I suggest that you take a look at the code of GBDL Benchmark Description. At least I have tested it and it works so you would have a known path to achiece your goal. I'm not also sure on the call on creating a new project. Isn't there a way to use the current project?

Thaks Neophytos

On Wed, May 7, 2008 at 4:53 PM, reuillon <reuillon@xxxxxxxx> wrote:
Thank you for you answer but using your code I obtains the same exception.

I think the problem is that the file is not being looked for at the right place:
java.io.FileNotFoundException: /myproject/jsdl/myjsld.jsdl  (No such file or directory)

When I create the IFile the getFullPath method gives me:
/myproject/jsdl/myjsld.jsdl

The getJSDLString method of the JSDLJobDescription class contains the following code:

  File jsdlFile = this.getPath().toFile();
  FileInputStream jsdlStream = null;
  jsdlStream = new FileInputStream( jsdlFile );

this.getPath call getFullPath on the IFile. The creation of the input stream is done on the absolute path: /myproject/jsdl/myjsld.jsdl, that does'nt exist.

Is my IFile is not created correctly or is it a bug?

Cheers, Romain.

Neophytos Theodorou a écrit :
Had a simillar problem. it seems that you have to open an output stream to the file to actually create it. This what I have done

private IFile createTemporaryJSDLFile(final IFolder jsdlFolder){
   IFile newJSDL = jsdlFolder.getFile( "." + this.benchmark.getName()
.toLowerCase() + (fileCount++) + ".jsdl" ); //$NON-NLS-1$//$NON-NLS-2$
   if(!newJSDL.exists()){

     try {
       FileOutputStream tempOutStream= new FileOutputStream(newJSDL.getRawLocation().toOSString());
       tempOutStream.close();

       FileInputStream tempInStream = new FileInputStream(newJSDL.getRawLocation().toOSString());
       newJSDL.create( tempInStream, true, null );
       tempInStream.close();


     } catch( FileNotFoundException e ) {
       // TODO Auto-generated catch block
       e.printStackTrace();
     } catch( CoreException e1 ) {
       // TODO Auto-generated catch block
       e1.printStackTrace();
     } catch( IOException e ) {
       // TODO Auto-generated catch block
       e.printStackTrace();
     }
   }
   return newJSDL;
 }

Although It may seem reduntant it actually worked. You can find the rest of the code in eu.geclipse.benchmarking.model.GBDLBenchmarkDescription

Neophytos Theodororou
University of Cyprus


On Tue, May 6, 2008 at 5:03 PM, reuillon <reuillon@xxxxxxxx <mailto:reuillon@xxxxxxxx>> wrote:

   Hi All,

   I am trying to create a simple jsdl job description with the
   following code:

            IWorkspace ws = ResourcesPlugin.getWorkspace();
            System.out.println(ws.getRoot().getLocationURI().toString());
            IWorkspaceRoot swRoot = ws.getRoot();
            IProject project = swRoot.getProject( "myproject" );

            if ( ! project.exists() ) {
                project.create( null );
            }

            project.open( null );

            IFile file = project.getFile( "myjsld.jsdl" );

            if(!file.exists()) {                  file.create(new
   InputStream(){

                    @Override
                    public int read() throws IOException {
                        return -1;
                    }
                                   }, IResource.REPLACE, null );
            }

            JSDLJobDescription jsdl = new JSDLJobDescription( file );
            jsdl.create(new JSDLJobDescriptionCreator());
            jsdl.createRoot();
            jsdl.addJobDescription();
            jsdl.addApplication();
            jsdl.setApplicationName("/bin/date");
            jsdl.save(file);

            System.out.println(jsdl.getJSDLString());

   But I get the following exception:

   java.io.FileNotFoundException: /myproject/myjsld.jsdl (No such
   file or directory)
    at java.io.FileInputStream.open(Native Method)
    at java.io.FileInputStream.<init>(FileInputStream.java:106)
    at
   eu.geclipse.jsdl.JSDLJobDescription.getJSDLString(JSDLJobDescription.java:250)

    at
   fr.cemagref.simexplorer.ide.osgi.processors.JobLauncherProcessor.process(JobLauncherProcessor.java:209)

    at
   fr.cemagref.simexplorer.ide.core.processors.modular.ProcessorsList.process(ProcessorsList.java:54)

    at
   fr.cemagref.simexplorer.ide.core.IDEModularApplication.run(IDEModularApplication.java:41)

    at
   fr.cemagref.simexplorer.service.loader.EFSSimulationLoaderImpl.run(EFSSimulationLoaderImpl.java:26)

    at
   fr.cemagref.simexplorer.service.application.SimExplorer.start(SimExplorer.java:49)

    at
   org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:169)

    at
   org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:106)

    at
   org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:76)

    at
   org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:363)

    at
   org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:176)

    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at
   sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

    at
   sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:508)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:447)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1173)
    at org.eclipse.equinox.launcher.Main.main(Main.java:1148)

   At the end of the process the jsdl file has been written:

   <?xml version="1.0" encoding="UTF-8"?>
   <jsdl:JobDefinition
   xmlns:jsdl="http://schemas.ggf.org/jsdl/2005/11/jsdl">
   <jsdl:JobDescription>
    <jsdl:Application>
      <jsdl:ApplicationName>/bin/date</jsdl:ApplicationName>
    </jsdl:Application>
   </jsdl:JobDescription>
   </jsdl:JobDefinition>


   Did I miss something?


   Romain

   _______________________________________________
   geclipse-dev mailing list
   geclipse-dev@xxxxxxxxxxx <mailto:geclipse-dev@xxxxxxxxxxx> ------------------------------------------------------------------------


_______________________________________________
geclipse-dev mailing list
geclipse-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/geclipse-dev
 

_______________________________________________
geclipse-dev mailing list
geclipse-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/geclipse-dev


Back to the top