static public RProject createProject(String name, String descr, ProjectCreationOptions options, RClient client, String uri)
        {
            StringBuilder data = new StringBuilder();

            //create the input String
            data.Append(Constants.FORMAT_JSON);
            data.Append("&projectname=" + HttpUtility.UrlEncode(name));
            data.Append("&projectdescr=" + HttpUtility.UrlEncode(descr));

            if (!(options == null))
            {
                data.Append("&blackbox=" + options.blackbox.ToString());

                if (!(options.rinputs == null))
                {
                    if (options.rinputs.Count > 0)
                    {
                        data.Append("&inputs=");
                        String sJSON = JSONSerialize.createJSONfromRData(options.rinputs);
                        data.Append(HttpUtility.UrlEncode(sJSON));
                        if (HTTPUtilities.DEBUGMODE == true)
                        {
                            Console.Write(sJSON);
                        }
                    }
                }

                if (!(options.preloadDirectory == null))
                {
                    data.Append("&preloadfilename=" + HttpUtility.UrlEncode(options.preloadDirectory.filename));
                    data.Append("&preloadfiledirectory=" + HttpUtility.UrlEncode(options.preloadDirectory.directory));
                    data.Append("&preloadfileauthor=" + HttpUtility.UrlEncode(options.preloadDirectory.author));
                    data.Append("&preloadfileversion=" + HttpUtility.UrlEncode(options.preloadDirectory.version));
                }

                if (!(options.preloadWorkspace == null))
                {
                    data.Append("&preloadobjectname=" + HttpUtility.UrlEncode(options.preloadWorkspace.filename));
                    data.Append("&preloadobjectdirectory=" + HttpUtility.UrlEncode(options.preloadWorkspace.directory));
                    data.Append("&preloadobjectauthor=" + HttpUtility.UrlEncode(options.preloadWorkspace.author));
                    data.Append("&preloadobjectversion=" + HttpUtility.UrlEncode(options.preloadWorkspace.version));
                }

                if (!(options.adoptionOptions == null))
                {
                    data.Append("&adoptworkspace=" + HttpUtility.UrlEncode(options.adoptionOptions.adoptWorkspace));
                    data.Append("&adoptdirectory=" + HttpUtility.UrlEncode(options.adoptionOptions.adoptDirectory));
                    data.Append("&adoptpackages=" + HttpUtility.UrlEncode(options.adoptionOptions.adoptPackages));
                }

                data.Append("&cluster=" + HttpUtility.UrlEncode(options.gridCluster));
            }

            //call the server
            JSONResponse jresponse = HTTPUtilities.callRESTPost(uri, data.ToString(), ref client);

            RProject returnValue = new RProject(jresponse, client);

            return(returnValue);
        }
Exemple #2
0
        static public RProject saveAs(RProjectDetails details, ProjectDropOptions options, RClient client, String uri)
        {
            StringBuilder data = new StringBuilder();

            //create the input String
            data.Append(Constants.FORMAT_JSON);
            data.Append("&project=" + HttpUtility.UrlEncode(details.id));
            data.Append("&name=" + HttpUtility.UrlEncode(details.name));
            data.Append("&descr=" + HttpUtility.UrlEncode(details.descr));
            data.Append("&longdescr=" + HttpUtility.UrlEncode(details.longdescr));
            data.Append("&projectcookie=" + HttpUtility.UrlEncode(details.cookie));
            data.Append("&shared=" + details.sharedUsers.ToString());

            if (!(options == null))
            {
                data.Append("&dropworkspace=" + options.dropWorkspace.ToString());
                data.Append("&dropdirectory=" + options.dropDirectory.ToString());
                data.Append("&drophistory=" + options.dropHistory.ToString());
            }

            //call the server
            JSONResponse jresponse = HTTPUtilities.callRESTPost(uri, data.ToString(), ref client);

            RProject returnValue = default(RProject);

            returnValue = new RProject(jresponse, client);
            return(returnValue);
        }
 /// <summary>
 /// Constructor for specifying a Pooled Instance of RBrokerWorker
 /// </summary>
 /// <param name="task">DiscreteTask reference</param>
 /// <param name="executorTaskRef">Reserved for future use</param>
 /// <param name="isPriorityTask">Boolean indicating this is a high priority task</param>
 /// <param name="resourceToken">integer referencing the token from the reosurce pool</param>
 /// <param name="rBroker">RBroker reference</param>
 /// <remarks></remarks>
 public PooledTaskWorker(PooledTask task,
                         long executorTaskRef,
                         Boolean isPriorityTask,
                         RProject resourceToken,
                         RBroker rBroker)
 {
     m_task = task;
     m_executorTaskRef = executorTaskRef;
     m_isPriorityTask = isPriorityTask;
     m_rProject = resourceToken;
     m_rBroker = (PooledTaskBroker) rBroker;
 }
        static public RProject getProject(String name, RClient client, String uri)
        {
            StringBuilder data = new StringBuilder();

            //create the input String
            data.Append(Constants.FORMAT_JSON);
            data.Append("&project=" + HttpUtility.UrlEncode(name));
            //call the server
            JSONResponse jresponse = HTTPUtilities.callRESTPost(uri, data.ToString(), ref client);

            RProject returnValue = new RProject(jresponse, client);

            return(returnValue);
        }
        static public RProject importProject(String file, String descr, RClient client, String uri)
        {
            StringBuilder data = new StringBuilder();
            Dictionary <String, String> parameters = new Dictionary <String, String>();

            //create the input String
            parameters.Add("format", "json");
            parameters.Add("name", HttpUtility.UrlEncode(Path.GetFileName(file)));
            parameters.Add("descr", HttpUtility.UrlEncode(descr));
            //call the server
            JSONResponse jresponse = HTTPUtilities.callRESTFileUploadPost(uri, parameters, file, ref client);

            RProject returnValue = new RProject(jresponse, client);

            return(returnValue);
        }
        public static RProject saveAs(RProjectDetails details, ProjectDropOptions options, RClient client, String uri)
        {
            StringBuilder data = new StringBuilder();

            //create the input String
            data.Append(Constants.FORMAT_JSON);
            data.Append("&project=" + HttpUtility.UrlEncode(details.id));
            data.Append("&name=" + HttpUtility.UrlEncode(details.name));
            data.Append("&descr=" + HttpUtility.UrlEncode(details.descr));
            data.Append("&longdescr=" + HttpUtility.UrlEncode(details.longdescr));
            data.Append("&projectcookie=" + HttpUtility.UrlEncode(details.cookie));
            data.Append("&shared=" + details.sharedUsers.ToString());

            if (!(options == null))
            {
                data.Append("&dropworkspace=" + options.dropWorkspace.ToString());
                data.Append("&dropdirectory=" + options.dropDirectory.ToString());
                data.Append("&drophistory=" + options.dropHistory.ToString());
            }

            //call the server
            JSONResponse jresponse = HTTPUtilities.callRESTPost(uri, data.ToString(), ref client);

            RProject returnValue = default(RProject);
            returnValue = new RProject(jresponse, client);
            return returnValue;
        }
        /// <summary>
        /// Import project from a file
        /// </summary>
        /// <param name="file">Full path to File to upload and import</param>
        /// <param name="descr">Description of project</param>
        /// <returns>RProject object</returns>
        /// <remarks></remarks>
        public RProject importProject(String file, String descr)
        {
            RProject returnValue = RUserProjectImpl.importProject(file, descr, m_client, Constants.RPROJECTIMPORT);

            return(returnValue);
        }
        /// <summary>
        /// Retrieve project reference
        /// </summary>
        /// <param name="name">Name of project</param>
        /// <returns>RProject object</returns>
        /// <remarks></remarks>
        public RProject getProject(String name)
        {
            RProject returnValue = RUserProjectImpl.getProject(name, m_client, Constants.RPROJECTABOUT);

            return(returnValue);
        }
        /// <summary>
        /// Create a named persistent project with options
        /// </summary>
        /// <param name="name">Name of project</param>
        /// <param name="descr">Description of project</param>
        /// <param name="options">ProjectCreationOptions that specifies what options the projects should be created with</param>
        /// <returns>RProject object</returns>
        /// <remarks></remarks>
        public RProject createProject(String name, String descr, ProjectCreationOptions options)
        {
            RProject returnValue = RUserProjectImpl.createProject(name, descr, options, m_client, Constants.RPROJECTCREATE);

            return(returnValue);
        }
        /// <summary>
        /// Create a named persistent project
        /// </summary>
        /// <param name="name">Name of project</param>
        /// <param name="descr">Description of project</param>
        /// <returns>RProject object</returns>
        /// <remarks></remarks>
        public RProject createProject(String name, String descr)
        {
            RProject returnValue = RUserProjectImpl.createProject(name, descr, null, m_client, Constants.RPROJECTCREATE);

            return(returnValue);
        }
        /// <summary>
        /// Create a temporary project with options
        /// </summary>
        /// <param name="options">ProjectCreationOptions that specifies what options the projects should be created with</param>
        /// <returns>RProject object</returns>
        /// <remarks></remarks>
        public RProject createProject(ProjectCreationOptions options)
        {
            RProject returnValue = RUserProjectImpl.createProject("", "", options, m_client, Constants.RPROJECTCREATE);

            return(returnValue);
        }
        /// <summary>
        /// Create a temporary project
        /// </summary>
        /// <returns>RProject object</returns>
        /// <remarks></remarks>
        public RProject createProject()
        {
            RProject returnValue = RUserProjectImpl.createProject("", "", null, m_client, Constants.RPROJECTCREATE);

            return(returnValue);
        }
        public static RProject createProject(String name, String descr, ProjectCreationOptions options, RClient client, String uri)
        {
            StringBuilder data = new StringBuilder();

            //create the input String
            data.Append(Constants.FORMAT_JSON);
            data.Append("&projectname=" + HttpUtility.UrlEncode(name));
            data.Append("&projectdescr=" + HttpUtility.UrlEncode(descr));

            if (!(options == null))
            {

                data.Append("&blackbox=" + options.blackbox.ToString());

                if (!(options.rinputs == null))
                {
                    if (options.rinputs.Count > 0)
                    {
                        data.Append("&inputs=");
                        String sJSON = JSONSerialize.createJSONfromRData(options.rinputs);
                        data.Append(HttpUtility.UrlEncode(sJSON));
                        if (HTTPUtilities.DEBUGMODE == true)
                        {
                            Console.Write(sJSON);
                        }
                    }
                }

                if (!(options.preloadDirectory == null))
                {
                    data.Append("&preloadfilename=" + HttpUtility.UrlEncode(options.preloadDirectory.filename));
                    data.Append("&preloadfiledirectory=" + HttpUtility.UrlEncode(options.preloadDirectory.directory));
                    data.Append("&preloadfileauthor=" + HttpUtility.UrlEncode(options.preloadDirectory.author));
                    data.Append("&preloadfileversion=" + HttpUtility.UrlEncode(options.preloadDirectory.version));
                }

                if (!(options.preloadWorkspace == null))
                {
                    data.Append("&preloadobjectname=" + HttpUtility.UrlEncode(options.preloadWorkspace.filename));
                    data.Append("&preloadobjectdirectory=" + HttpUtility.UrlEncode(options.preloadWorkspace.directory));
                    data.Append("&preloadobjectauthor=" + HttpUtility.UrlEncode(options.preloadWorkspace.author));
                    data.Append("&preloadobjectversion=" + HttpUtility.UrlEncode(options.preloadWorkspace.version));
                }

                if (!(options.adoptionOptions == null))
                {
                    data.Append("&adoptworkspace=" + HttpUtility.UrlEncode(options.adoptionOptions.adoptWorkspace));
                    data.Append("&adoptdirectory=" + HttpUtility.UrlEncode(options.adoptionOptions.adoptDirectory));
                    data.Append("&adoptpackages=" + HttpUtility.UrlEncode(options.adoptionOptions.adoptPackages));
                }

                data.Append("&cluster=" + HttpUtility.UrlEncode(options.gridCluster));
            }

            //call the server
            JSONResponse jresponse = HTTPUtilities.callRESTPost(uri, data.ToString(), ref client);

            RProject returnValue = new RProject(jresponse, client);

            return returnValue;
        }
        public static RProject importProject(String file, String descr, RClient client, String uri)
        {
            StringBuilder data = new StringBuilder();
            Dictionary<String, String> parameters = new Dictionary<String, String>();

            //create the input String
            parameters.Add("format", "json");
            parameters.Add("name", HttpUtility.UrlEncode(Path.GetFileName(file)));
            parameters.Add("descr", HttpUtility.UrlEncode(descr));
            //call the server
            JSONResponse jresponse = HTTPUtilities.callRESTFileUploadPost(uri, parameters, file, ref client);

            RProject returnValue = new RProject(jresponse, client);

            return returnValue;
        }
        public static RProject getProject(String name, RClient client, String uri)
        {
            StringBuilder data = new StringBuilder();

            //create the input String
            data.Append(Constants.FORMAT_JSON);
            data.Append("&project=" + HttpUtility.UrlEncode(name));
            //call the server
            JSONResponse jresponse = HTTPUtilities.callRESTPost(uri, data.ToString(), ref client);

            RProject returnValue = new RProject(jresponse, client);

            return returnValue;
        }
        /// <summary>
        /// Saves a copy the project
        /// </summary>
        /// <param name="details">RProjectDetails object describing the project</param>
        /// <param name="dropOptions">ProjectDropOptions object describing what to drop from the project</param>
        /// <returns>RProject object</returns>
        /// <remarks></remarks>
        public RProject saveAs(RProjectDetails details, ProjectDropOptions dropOptions)
        {
            RProject returnValue = RProjectBaseImpl.saveAs(details, dropOptions, m_client, Constants.RPROJECTSAVEAS);

            return(returnValue);
        }