當前位置: 首頁>>代碼示例>>Java>>正文


Java EdgeCollectionQuery類代碼示例

本文整理匯總了Java中org.ndexbio.model.network.query.EdgeCollectionQuery的典型用法代碼示例。如果您正苦於以下問題:Java EdgeCollectionQuery類的具體用法?Java EdgeCollectionQuery怎麽用?Java EdgeCollectionQuery使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


EdgeCollectionQuery類屬於org.ndexbio.model.network.query包,在下文中一共展示了EdgeCollectionQuery類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createODBExecutor

import org.ndexbio.model.network.query.EdgeCollectionQuery; //導入依賴的package包/類
public static NetworkFilterQueryExecutor createODBExecutor(String networkIdStr, EdgeCollectionQuery query) throws NdexException {
	
	// check if the query is valid
	if ( query.getEdgeFilter() == null || query.getEdgeFilter().getPropertySpecifications().size() == 0) {
		if ( query.getNodeFilter() == null || query.getNodeFilter().getPropertySpecifications().size() == 0 )  {  //error
			throw new NdexException ("Invalid query object received. Both filters are empty.");
		}
	} 
	
	//TODO: optimize the case that when filter compiled to an empty list. Should just return empty collection without iteration.
	
	EdgeCollectionQueryODB edgeQuery = new EdgeCollectionQueryODB();
	edgeQuery.setQueryName(query.getQueryName());
	edgeQuery.setEdgeLimit(query.getEdgeLimit());
	
	try ( NetworkDocDAO networkDao = new NetworkDocDAO()) {
	
		ODocument networkDoc = networkDao.getNetworkDocByUUIDString(networkIdStr);
		
		EdgeByEdgePropertyFilterODB edgeFilter = preprocessEdgeByEdgePropertyFilter(
				   query.getEdgeFilter(), networkDoc)	;
		
		EdgeByNodePropertyFilterODB nodeFilter = preprocessEdgeByNodePropertyFilter(
				query.getNodeFilter(), networkDoc);
		
		edgeQuery.setEdgeFilter(edgeFilter);
		edgeQuery.setNodeFilter(nodeFilter);
	  NetworkFilterQueryExecutor executor = new NetworkFilterQueryExecutor(networkIdStr, edgeQuery);
	
	  return executor;
	}
}
 
開發者ID:ndexbio,項目名稱:ndex-common,代碼行數:33,代碼來源:NetworkFilterQueryExecutorFactory.java

示例2: test0150queryNetworkByEdgeFilter

import org.ndexbio.model.network.query.EdgeCollectionQuery; //導入依賴的package包/類
/** 
    * Upload network specified in the properties file to the server, 
    * and query it by ( Edge Property Name = value ) 
    * Delete this network from the server.
    * 
    * APIs tested: public void uploadNetwork(UploadedFile uploadedNetwork)
    *              public Network queryNetworkByEdgeFilter(String networkId, EdgeCollectionQuery query)
    *              public void deleteNetwork(String id)
    * 
    * @param   void
    * @return  void
    */
   //@Test
   public void test0150queryNetworkByEdgeFilter()  {
   	// network to be uploaded to the Server
   	TreeMap<String, String> testNetworkToUpload = 
   				PropertyFileUtils.parsePropertyFile(networksAServicePropertyFile);
	
   	// absolute path name of the file containing network in JSON format; defined in properties file: "uploadNetworkForQueryNetworkByEdgeFilter = ..."
   //	String networkUUID = uploadNetworkFile(testNetworkToUpload.get("uploadNetworkForQueryNetworkByEdgeFilter"));
   	
	// restart server without removing the database; we need this to make
	// sure there is only one user task on the server that we can track
//   	String responseFromServer = JettyServerUtils.sendCommand("restartServerWithoutCleaningDatabase");
  // 	assertEquals("unable to restart Jetty Server: ",  "done", responseFromServer);
	 
   	
   	// build the queryNetworkByEdgeFilter query
   	EdgeCollectionQuery query = new EdgeCollectionQuery();
   	query.setEdgeLimit(-1);
   	EdgeByEdgePropertyFilter edgeByNodeFilter = new EdgeByEdgePropertyFilter();
   	ArrayList<PropertySpecification> properties = new ArrayList<PropertySpecification>();
   	PropertySpecification property = new PropertySpecification();
   	property.setName("Disease");
   	property.setValue("Atherosclerosis");
   	properties.add(property);
   	edgeByNodeFilter.setPropertySpecifications(properties);
   	query.setEdgeFilter(edgeByNodeFilter);
   	
   /*	
   	// issue the queryNetworkByEdgeFilter query
   	Network network = NetworkUtils.queryNetworkByEdgeFilter(ndex, networkUUID, query);
   	assertNotNull("no network retrieved", network);
   	assertEquals("wrong number of nodes", 4, network.getNodeCount());
   	assertEquals("wrong number of edges", 3, network.getEdgeCount());
   	
   	
   	// re-issue the same query with lower edge limit
   	query.setEdgeLimit(2);
   	network = NetworkUtils.queryNetworkByEdgeFilter(ndex, networkUUID, query);
   	assertNotNull("no network retrieved", network);
   	assertEquals("wrong number of nodes", 3, network.getNodeCount());
   	assertEquals("wrong number of edges", 2, network.getEdgeCount());

   	
   	// query by predicate with no edge limit
   	property.setName("ndex:predicate");
   	property.setValue("increases");
   	query.setEdgeLimit(-1);
   	network = NetworkUtils.queryNetworkByEdgeFilter(ndex, networkUUID, query);
   	assertNotNull("no network retrieved", network);
   	assertEquals("wrong number of nodes", 21, network.getNodeCount());
   	assertEquals("wrong number of edges", 22, network.getEdgeCount());
   	
   	
   	// delete network from the test account
   	NetworkUtils.deleteNetwork(ndex, networkUUID.toString()); */	 
   }
 
開發者ID:ndexbio,項目名稱:ndex-java-client,代碼行數:69,代碼來源:testNetworkAService.java

示例3: advancedQuery

import org.ndexbio.model.network.query.EdgeCollectionQuery; //導入依賴的package包/類
@PermitAll
@POST
@Path("/network/{networkId}/advancedquery")
@Produces("application/json")
   @ApiDoc("Retrieves a subnetwork of the network specified by ‘networkId’. The query finds " +
           "the subnetwork by a filtering the network on conditions defined in filter query object. " +
           "specified in a POSTed JSON query object. " )
public Response advancedQuery(
		@PathParam("networkId") final String networkIdStr,
		@QueryParam("accesskey") String accessKey,			
		final EdgeCollectionQuery queryParameters
		) throws NdexException, SQLException   {
	
/*	if ( networkIdStr.equals("0000"))
		return Response.ok().build();*/
	ObjectMapper mapper = new ObjectMapper();
	try {
		accLogger.info("[data]\t[query:" + mapper.writeValueAsString(queryParameters)+ "]" );
	} catch (JsonProcessingException ee) {
		logger.info("Failed to generate json string for logging in function SearchServiceV2.advancedQuery:" + ee.getMessage());
	}

	UUID networkId = UUID.fromString(networkIdStr);

	try (NetworkDAO dao = new NetworkDAO())  {
		UUID userId = getLoggedInUserId();
		if ( !dao.isReadable(networkId, userId) && !dao.accessKeyIsValid(networkId, accessKey)) {
			throw new UnauthorizedOperationException ("Unauthorized access to network " + networkId);
		}
		checkIfQueryIsAllowed(networkId, dao);
	}   
	
	Client client = ClientBuilder.newBuilder().build();
	
	/*Map<String, Object> queryEntity = new TreeMap<>();
	queryEntity.put("terms", queryParameters.getSearchString());
	queryEntity.put("depth", queryParameters.getSearchDepth());
	queryEntity.put("edgeLimit", queryParameters.getEdgeLimit()); */
	String prefix = Configuration.getInstance().getProperty("AdvancedQueryURL");
       WebTarget target = client.target(prefix + networkId + "/advancedquery");
       Response response = target.request().post(Entity.entity(queryParameters, "application/json"));
       
       if ( response.getStatus()!=200) {
       	Object obj = response.readEntity(Object.class);
       	throw new NdexException(obj.toString());
       }
       
     //     String value = response.readEntity(String.class);
      //    response.close();  
       InputStream in = response.readEntity(InputStream.class);

       return Response.ok().entity(in).build();
	
}
 
開發者ID:ndexbio,項目名稱:ndex-rest,代碼行數:55,代碼來源:SearchServiceV2.java


注:本文中的org.ndexbio.model.network.query.EdgeCollectionQuery類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。