本文整理汇总了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;
}
}
示例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()); */
}
示例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();
}