nodeGroupStoreService/src/main/java/com/ge/research/semtk/services/nodegroupStore/service/NodeGroupStoreRestController.java
@CrossOrigin
	@RequestMapping(value="/storeNodeGroup", method=RequestMethod.POST)
	public JSONObject storeNodeGroup(@RequestBody StoreNodeGroupRequest requestBody, @RequestHeader HttpHeaders headers) {
		HeadersManager.setHeaders(headers);
		try {
			final String SVC_ENDPOINT_NAME = SERVICE_NAME + "/storeNodeGroup";
			SimpleResultSet retval = null;
	
			try{
	
				// throw a meaningful exception if needed info is not present in the request
				requestBody.validate();	
	
				// check that the ID does not already exist. if it does, fail.
				NgStore store = new NgStore(this.getStoreDataSei());
				Table instanceTable = store.getNodegroupTable(requestBody.getName(), true);
				
				if(instanceTable.getNumRows() > 0){
					throw new Exception("Unable to store node group:  ID (" + requestBody.getName() + ") already exists");
				}
	
				// get the nodeGroup and the connection info:
				JSONObject sgJsonJson = requestBody.getJsonNodeGroup();			// changed to allow for more dynamic nodegroup actions. 
				SparqlGraphJson sgJson = new SparqlGraphJson(sgJsonJson);
				JSONObject connJson = sgJson.getSparqlConnJson();
				if(connJson == null){
					throw new Exception("storeNodeGroup :: sparqlgraph json serialization passed to store node group did not contain a valid connection block. it is possible that only the node group itself was passed. please check that complete input is sent.");
				}
	
				store.insertNodeGroup(sgJsonJson, connJson, requestBody.getName(), requestBody.getComments(), requestBody.getCreator(), true);
				
				retval = new SimpleResultSet(true);
	
			}
			catch(Exception e){
				retval = new SimpleResultSet(false);
				retval.addRationaleMessage(SVC_ENDPOINT_NAME, e);
				LocalLogger.printStackTrace(e);
			} 	
			return retval.toJson();
		    
		} finally {
	    	HeadersManager.clearHeaders();
	    }
	}
/**
	 * Store a new nodegroup to the nodegroup store.
	 * @param requestBody
	 * @return
	 */
Store a new nodegroup to the nodegroup store.
@param requestBody
@return
Store a new nodegroup to the nodegroup store . @param requestBody @return
@CrossOrigin
	@RequestMapping(value="/storeNodeGroup", method=RequestMethod.POST)
	public JSONObject storeNodeGroup(@RequestBody StoreNodeGroupRequest requestBody, @RequestHeader HttpHeaders headers) {
		HeadersManager.setHeaders(headers);
		try {
			final String SVC_ENDPOINT_NAME = SERVICE_NAME + "/storeNodeGroup";
			SimpleResultSet retval = null;
			try{
				requestBody.validate();	
				NgStore store = new NgStore(this.getStoreDataSei());
				Table instanceTable = store.getNodegroupTable(requestBody.getName(), true);
				if(instanceTable.getNumRows() > 0){
					throw new Exception("Unable to store node group:  ID (" + requestBody.getName() + ") already exists");
				}
				JSONObject sgJsonJson = requestBody.getJsonNodeGroup();			
				SparqlGraphJson sgJson = new SparqlGraphJson(sgJsonJson);
				JSONObject connJson = sgJson.getSparqlConnJson();
				if(connJson == null){
					throw new Exception("storeNodeGroup :: sparqlgraph json serialization passed to store node group did not contain a valid connection block. it is possible that only the node group itself was passed. please check that complete input is sent.");
				}
				store.insertNodeGroup(sgJsonJson, connJson, requestBody.getName(), requestBody.getComments(), requestBody.getCreator(), true);
				retval = new SimpleResultSet(true);
			}
			catch(Exception e){
				retval = new SimpleResultSet(false);
				retval.addRationaleMessage(SVC_ENDPOINT_NAME, e);
				LocalLogger.printStackTrace(e);
			} 	
			return retval.toJson();
		} finally {
	    	HeadersManager.clearHeaders();
	    }
	}
@ CrossOrigin @ RequestMapping ( value = "/storeNodeGroup" , method = RequestMethod . POST ) public JSONObject storeNodeGroup ( @ RequestBody StoreNodeGroupRequest requestBody , @ RequestHeader HttpHeaders headers ) { HeadersManager . setHeaders ( headers ) ; try { final String SVC_ENDPOINT_NAME = SERVICE_NAME + "/storeNodeGroup" ; SimpleResultSet retval = null ; try { requestBody . validate ( ) ; NgStore store = new NgStore ( this . getStoreDataSei ( ) ) ; Table instanceTable = store . getNodegroupTable ( requestBody . getName ( ) , true ) ; if ( instanceTable . getNumRows ( ) > 0 ) { throw new Exception ( "Unable to store node group:  ID (" + requestBody . getName ( ) + ") already exists" ) ; } JSONObject sgJsonJson = requestBody . getJsonNodeGroup ( ) ; SparqlGraphJson sgJson = new SparqlGraphJson ( sgJsonJson ) ; JSONObject connJson = sgJson . getSparqlConnJson ( ) ; if ( connJson == null ) { throw new Exception ( "storeNodeGroup :: sparqlgraph json serialization passed to store node group did not contain a valid connection block. it is possible that only the node group itself was passed. please check that complete input is sent." ) ; } store . insertNodeGroup ( sgJsonJson , connJson , requestBody . getName ( ) , requestBody . getComments ( ) , requestBody . getCreator ( ) , true ) ; retval = new SimpleResultSet ( true ) ; } catch ( Exception e ) { retval = new SimpleResultSet ( false ) ; retval . addRationaleMessage ( SVC_ENDPOINT_NAME , e ) ; LocalLogger . printStackTrace ( e ) ; } return retval . toJson ( ) ; } finally { HeadersManager . clearHeaders ( ) ; } }
Store a new nodegroup to the nodegroup store.
Store a new nodegroup to the nodegroup store .
// throw a meaningful exception if needed info is not present in the request // check that the ID does not already exist. if it does, fail. // get the nodeGroup and the connection info: // changed to allow for more dynamic nodegroup actions. 