sparqlGraphLibrary/src/main/java/com/ge/research/semtk/edc/JobTracker.java
public void createJob(String jobId) throws Exception {	
		// Note: createJob can be called by two different threads colliding on the same JobId without bad consequences.
	    
		// Testing only
		String userName = ThreadAuthenticator.getThreadUserName();
		LocalLogger.logToStdOut("creating job " + jobId + " principal.user_name=" + userName);
		
		// get the current date and time...
		DateFormat xsdFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
		Calendar cal = Calendar.getInstance();

		Date initialDate = cal.getTime();
		
		String jobUri = this.getJobUri(jobId);
		
		// delete in case job already exists (save the job and id, they are solid)
	    String query = String.format("  \n" +
	        "prefix job:<http://research.ge.com/semtk/services/job#> \n" +
	        "prefix XMLSchema:<http://www.w3.org/2001/XMLSchema#> \n" +
	        " \n" +
	        "WITH <" + this.sei.getGraph() + "> " +
	        "DELETE { " +
            "?job job:creationTime ?x. \n" +
	        "?job job:percentComplete ?y. \n" +
	        "?job job:status ?w. \n" +
	        "} \n" +
	        "INSERT { " +
	        "?job a job:Job. \n" + 
	        "?job job:id '%s' . \n" +
            "?job job:creationTime '%s'^^XMLSchema:dateTime . \n" +
	        "?job job:percentComplete 0 . \n" +
	        "?job job:userName '%s' . \n" +
	        "?job job:status job:InProgress. \n" +
	        "}\n" +
	        "WHERE {\n" +
	        "BIND (<%s> AS ?job)\n" +
	        "}\n",
	        
	        SparqlToXUtils.safeSparqlString(jobId), 
	        xsdFormat.format(initialDate), 
	        userName,
	        jobUri);
	    // LocalLogger.logToStdErr(query);
	    try {
	    	this.createSuperuserEndpoint().executeQuery(query, SparqlResultTypes.CONFIRM);
	    } catch (Exception e) {
	    	throw new Exception(e.getMessage());
	    }
	}
/**
	 * Create a Job with given jobId.  
	 * @param jobId
	 * @throws Exception
	 */
Create a Job with given jobId.
@param jobId
@throws Exception
Create a Job with given jobId . @param jobId @throws Exception
public void createJob(String jobId) throws Exception {	
		String userName = ThreadAuthenticator.getThreadUserName();
		LocalLogger.logToStdOut("creating job " + jobId + " principal.user_name=" + userName);
		DateFormat xsdFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
		Calendar cal = Calendar.getInstance();
		Date initialDate = cal.getTime();
		String jobUri = this.getJobUri(jobId);
	    String query = String.format("  \n" +
	        "prefix job:<http://research.ge.com/semtk/services/job#> \n" +
	        "prefix XMLSchema:<http://www.w3.org/2001/XMLSchema#> \n" +
	        " \n" +
	        "WITH <" + this.sei.getGraph() + "> " +
	        "DELETE { " +
            "?job job:creationTime ?x. \n" +
	        "?job job:percentComplete ?y. \n" +
	        "?job job:status ?w. \n" +
	        "} \n" +
	        "INSERT { " +
	        "?job a job:Job. \n" + 
	        "?job job:id '%s' . \n" +
            "?job job:creationTime '%s'^^XMLSchema:dateTime . \n" +
	        "?job job:percentComplete 0 . \n" +
	        "?job job:userName '%s' . \n" +
	        "?job job:status job:InProgress. \n" +
	        "}\n" +
	        "WHERE {\n" +
	        "BIND (<%s> AS ?job)\n" +
	        "}\n",
	        SparqlToXUtils.safeSparqlString(jobId), 
	        xsdFormat.format(initialDate), 
	        userName,
	        jobUri);
	    try {
	    	this.createSuperuserEndpoint().executeQuery(query, SparqlResultTypes.CONFIRM);
	    } catch (Exception e) {
	    	throw new Exception(e.getMessage());
	    }
	}
public void createJob ( String jobId ) throws Exception { String userName = ThreadAuthenticator . getThreadUserName ( ) ; LocalLogger . logToStdOut ( "creating job " + jobId + " principal.user_name=" + userName ) ; DateFormat xsdFormat = new SimpleDateFormat ( "yyyy-MM-dd'T'HH:mm:ss" ) ; Calendar cal = Calendar . getInstance ( ) ; Date initialDate = cal . getTime ( ) ; String jobUri = this . getJobUri ( jobId ) ; String query = String . format ( "  \n" + "prefix job:<http://research.ge.com/semtk/services/job#> \n" + "prefix XMLSchema:<http://www.w3.org/2001/XMLSchema#> \n" + " \n" + "WITH <" + this . sei . getGraph ( ) + "> " + "DELETE { " + "?job job:creationTime ?x. \n" + "?job job:percentComplete ?y. \n" + "?job job:status ?w. \n" + "} \n" + "INSERT { " + "?job a job:Job. \n" + "?job job:id '%s' . \n" + "?job job:creationTime '%s'^^XMLSchema:dateTime . \n" + "?job job:percentComplete 0 . \n" + "?job job:userName '%s' . \n" + "?job job:status job:InProgress. \n" + "}\n" + "WHERE {\n" + "BIND (<%s> AS ?job)\n" + "}\n" , SparqlToXUtils . safeSparqlString ( jobId ) , xsdFormat . format ( initialDate ) , userName , jobUri ) ; try { this . createSuperuserEndpoint ( ) . executeQuery ( query , SparqlResultTypes . CONFIRM ) ; } catch ( Exception e ) { throw new Exception ( e . getMessage ( ) ) ; } }
Create a Job with given jobId.
Create a Job with given jobId .
// Note: createJob can be called by two different threads colliding on the same JobId without bad consequences. // Testing only // get the current date and time... // delete in case job already exists (save the job and id, they are solid) // LocalLogger.logToStdErr(query);