本文整理汇总了Java中org.ndexbio.model.object.Task类的典型用法代码示例。如果您正苦于以下问题:Java Task类的具体用法?Java Task怎么用?Java Task使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Task类属于org.ndexbio.model.object包,在下文中一共展示了Task类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTask
import org.ndexbio.model.object.Task; //导入依赖的package包/类
/**
* Removes the member specified by userId from the group specified by groupId.
* @param groupId Group id of
* @param userId
* @throws JsonProcessingException
* @throws IOException
* @throws NdexException
*/
/* public void removeGroupMember(UUID groupId, UUID userId) throws JsonProcessingException, IOException, NdexException{
ndexRestClient.delete("/group/" + groupId + "/membership?userid=" + userId);
} */
/*-----------------------------------------
*
* Task
*
* -----------------------------------------
*/
// Get a task by id
// task GET /task/{taskUUID} Task
public Task getTask(UUID taskId) throws IOException, NdexException {
return (Task) ndexRestClient.getNdexObject("/task/"+ taskId, "", Task.class);
}
示例2: test0020uploadNetwork
import org.ndexbio.model.object.Task; //导入依赖的package包/类
/**
* Upload network specified in the properties file to the server,
* and then delete this network from the server.
*
* APIs tested: public void uploadNetwork(UploadedFile uploadedNetwork)
* public void deleteNetwork(String id)
*
* @param void
* @return void
*/
//@Test
public void test0020uploadNetwork() {
// network to be uploaded to the Server
TreeMap<String, String> testNetworkToUpload =
PropertyFileUtils.parsePropertyFile(networksAServicePropertyFile);
// absolute path name of the network; defined in properties file: "uploadNetwork = ..."
String absoluteNetworkPath = testNetworkToUpload.get("uploadNetwork");
assertNotNull("network path is null; check properties file", absoluteNetworkPath);
File fileToUpload = new File(absoluteNetworkPath);
// NetworkUtils.startNetworkUpload(ndex, fileToUpload);
// wait for the network upload task to finish
Task task = NetworkUtils.waitForTaskToFinish(ndex, testAccount);
Object networkUUID = task.getAttribute("networkUUID");
assertNotNull("network UUID of uploaded network is null", networkUUID);
// delete network from the test account
// NetworkUtils.deleteNetwork(ndex, networkUUID.toString());
}
示例3: loadNetwork
import org.ndexbio.model.object.Task; //导入依赖的package包/类
/**
* This methods runs before every test case.
* It restarts the server with clean database (removes the database), and uploads test network to the server.
*
* @param void
* @return void
*/
@Before public void loadNetwork() {
// stop Jetty server if it is running, remove database from file system, start Jetty server
// (i.e., (re)start server with clean database)
// String responseFromServer = JettyServerUtils.sendCommand("restartServerWithCleanDatabase");
// assertEquals("unable to restart Jetty Server: ", responseFromServer, "done");
// create test account
// testAccount = UserUtils.createUserAccount(ndex, testUser);
// start uploading network to the test account
// NetworkUtils.startNetworkUpload(ndex, fileToUpload);
// wait till network is uploaded
Task task = NetworkUtils.waitForTaskToFinish(ndex, testAccount);
// get UUID of the network we just uploaded
testNetworkUUID = task.getAttribute("networkUUID").toString();
}
示例4: getTasks
import org.ndexbio.model.object.Task; //导入依赖的package包/类
@GET
@Path("/task/{status}/{skipBlocks}/{blockSize}")
@Produces("application/json")
@ApiDoc("Returns an array of Task objects with the specified status")
public List<Task> getTasks(
@PathParam("status") final String status,
@PathParam("skipBlocks") int skipBlocks,
@PathParam("blockSize") int blockSize) throws SQLException, JsonParseException, JsonMappingException, IOException {
logger.info("[start: Getting tasks for user {}]", getLoggedInUser().getUserName());
try (TaskDAO dao = new TaskDAO ()){
Status taskStatus = Status.valueOf(status);
List<Task> tasks= dao.getTasksByUserId(this.getLoggedInUser().getExternalId(),taskStatus, skipBlocks, blockSize);
logger.info("[end: Returned {} tasks under user {}]", tasks.size(), getLoggedInUser().getUserName());
return tasks;
}
}
示例5: getTasks
import org.ndexbio.model.object.Task; //导入依赖的package包/类
@GET
@Produces("application/json")
@ApiDoc("Returns an array of Task objects with the specified status")
public List<Task> getTasks(
@QueryParam("status") String status,
@DefaultValue("0") @QueryParam("start") int skipBlocks,
@DefaultValue("100") @QueryParam("size") int blockSize)
throws SQLException, JsonParseException, JsonMappingException, IOException {
logger.info("[start: Getting tasks for user {}]", getLoggedInUser().getUserName());
Status taskStatus = Status.ALL;
if ( status != null)
taskStatus = Status.valueOf(status);
try (TaskDAO dao = new TaskDAO ()){
List<Task> tasks= dao.getTasksByUserId(this.getLoggedInUser().getExternalId(),taskStatus, skipBlocks, blockSize);
logger.info("[end: Returned {} tasks under user {}]", tasks.size(), getLoggedInUser().getUserName());
return tasks;
}
}
示例6: getTasks
import org.ndexbio.model.object.Task; //导入依赖的package包/类
@GET
@Path("/task/{status}/{start}/{size}")
@Produces("application/json")
@ApiDoc("Returns an array of Task objects with the specified status")
public List<Task> getTasks(
@PathParam("status") final String status,
@PathParam("start") int skipBlocks,
@PathParam("size") int blockSize) throws SQLException, JsonParseException, JsonMappingException, IOException {
logger.info("[start: Getting tasks for user {}]", getLoggedInUser().getUserName());
try (TaskDAO dao = new TaskDAO ()){
Status taskStatus = Status.valueOf(status);
List<Task> tasks= dao.getTasksByUserId(this.getLoggedInUser().getExternalId(),taskStatus, skipBlocks, blockSize);
logger.info("[end: Returned {} tasks under user {}]", tasks.size(), getLoggedInUser().getUserName());
return tasks;
}
}
示例7: populateQueuedTasksFromDB
import org.ndexbio.model.object.Task; //导入依赖的package包/类
private static void populateQueuedTasksFromDB() throws NdexException, SQLException, JsonParseException, JsonMappingException, IOException {
try ( TaskDAO taskDAO = new TaskDAO()) {
List<Task> list =taskDAO.getQueuedTasks();
for ( Task t : list) {
if ( t.getTaskOwnerId()!=null)
NdexServerQueue.INSTANCE.addUserTask(NdexTask.createUserTask(t));
else {
NdexSystemTask sysTask = NdexSystemTask.createSystemTask(t);
if (sysTask !=null) {
sysTask.setTaskId(t.getExternalId());
NdexServerQueue.INSTANCE.addSystemTaskToQueue(sysTask);
}
}
}
logger.info (list.size() + " previously queued tasks were added to the queue.");
}
}
示例8: getTaskByUUID
import org.ndexbio.model.object.Task; //导入依赖的package包/类
public Task getTaskByUUID(UUID taskId) throws ObjectNotFoundException, NdexException, SQLException, JsonParseException, JsonMappingException, IOException {
String sqlStr = "SELECT * FROM " + NdexClasses.Task + " where \"UUID\" = ? and not is_deleted ";
try (PreparedStatement st = db.prepareStatement(sqlStr)) {
st.setObject(1, taskId);
try (ResultSet rs = st.executeQuery() ) {
if (rs.next()) {
// populate the user object;
Task result = new Task();
populateTaskFromResultSet(result, rs);
return result;
}
throw new ObjectNotFoundException("Task with UUID: " + taskId.toString() + " doesn't exist.");
}
}
}
示例9: saveTaskAttributes
import org.ndexbio.model.object.Task; //导入依赖的package包/类
public void saveTaskAttributes(UUID taskID, Map<String, Object> attributes ) throws ObjectNotFoundException, NdexException, JsonProcessingException, SQLException {
String updateStr = "update " + NdexClasses.Task + " set other_attributes= ? ::jsonb where \"UUID\" = ? and is_deleted = false";
ObjectMapper mapper = new ObjectMapper();
String s = mapper.writeValueAsString( attributes);
try (PreparedStatement st = db.prepareStatement(updateStr) ) {
st.setString(1, s);
st.setObject(2, taskID);
int rowsInserted = st.executeUpdate();
if ( rowsInserted != 1)
throw new NdexException ( "Failed to delete task " + taskID + " in database.");
}
}
示例10: getQueuedTasks
import org.ndexbio.model.object.Task; //导入依赖的package包/类
public List<Task> getQueuedTasks() throws SQLException, JsonParseException, JsonMappingException, IOException {
List <Task> result = new ArrayList<>(20);
String queryStr = "select * from task where is_deleted = false and status ='QUEUED' order by creation_time desc ";
try (PreparedStatement st = db.prepareStatement(queryStr)) {
try (ResultSet rs = st.executeQuery() ) {
while (rs.next()) {
Task t = new Task();
populateTaskFromResultSet(t,rs);
result.add(t);
}
}
}
return result;
}
示例11: createSystemTask
import org.ndexbio.model.object.Task; //导入依赖的package包/类
public static NdexSystemTask createSystemTask(Task t) throws NdexException {
switch (t.getTaskType()) {
case SYS_SOLR_DELETE_NETWORK:
return new SolrTaskDeleteNetwork(UUID.fromString(t.getResource()),
(Boolean)t.getAttribute(SolrTaskDeleteNetwork.globalIdxAttr));
case SYS_SOLR_REBUILD_NETWORK_INDEX:
return new SolrTaskRebuildNetworkIdx(UUID.fromString(t.getResource()), SolrIndexScope.valueOf((String)t.getAttribute(SolrTaskRebuildNetworkIdx.AttrScope)),
((Boolean)t.getAttribute(SolrTaskRebuildNetworkIdx.AttrCreateOnly)).booleanValue(),
(Set<String>)t.getAttribute("fields"),
NetworkIndexLevel.valueOf((String)t.getAttribute("indexLevel")));
case SYS_LOAD_NETWORK:
return new CXNetworkLoadingTask (UUID.fromString(t.getResource()),(String)t.getAttribute("owner"),
(Boolean)t.getAttribute("isUpdate"),
(t.getAttribute("visibility") != null ? VisibilityType.valueOf((String)t.getAttribute("visibility")): null),
(Set<String>)t.getAttribute("nodeIndexes"));
default:
throw new NdexException("Unknow system task: " + t.getExternalId() + " - " + t.getTaskType());
}
}
示例12: stageQueuedTasks
import org.ndexbio.model.object.Task; //导入依赖的package包/类
public List<Task> stageQueuedTasks() throws NdexException
{
try {
this.ndexService.setupDatabase();
TaskDAO dao = new TaskDAO(this.ndexService._ndexDatabase);
List<Task> taskList = dao.stageQueuedTasks();
this.ndexService._ndexDatabase.commit();
return taskList;
} catch (Exception e) {
logger.error("Failed to search tasks", e);
throw new NdexException("Failed to search tasks.");
}finally {
this.ndexService.teardownDatabase();
}
}
示例13: getActiveTasks
import org.ndexbio.model.object.Task; //导入依赖的package包/类
public List<Task> getActiveTasks() throws NdexException
{
try {
this.ndexService.setupDatabase();
TaskDAO dao = new TaskDAO(this.ndexService._ndexDatabase);
List<Task> taskList = dao.getActiveTasks();
return taskList;
} catch (Exception e) {
logger.error("Failed to search tasks", e);
throw new NdexException("Failed to search tasks.");
}finally {
this.ndexService.teardownDatabase();
}
}
示例14: updateTaskStatus
import org.ndexbio.model.object.Task; //导入依赖的package包/类
public Task updateTaskStatus(Status status, Task task) throws NdexException {
try {
this.ndexService.setupDatabase();
TaskDocDAO dao = new TaskDocDAO(this.ndexService._ndexDatabase);
logger.info("Updating status of tasks " + task.getExternalId() + " from " +
task.getStatus() + " to " + status);
dao.updateTaskStatus(status, task);
this.ndexService._ndexDatabase.commit();
return task;
} catch (Exception e) {
logger.error("Failed to update task satus : " + e.getMessage(), e);
throw new NdexException("Failed to update status of task: " + task.getExternalId() + " to " + status);
}finally {
this.ndexService.teardownDatabase();
}
}
示例15: addTaskAttribute
import org.ndexbio.model.object.Task; //导入依赖的package包/类
public void addTaskAttribute(String uuidStr, String name, Object value) throws NdexException {
try {
this.ndexService.setupDatabase();
TaskDocDAO dao = new TaskDocDAO(this.ndexService._ndexDatabase);
Task t = dao.getTaskByUUID(uuidStr);
t.getAttributes().put(name,value);
dao.saveTaskAttributes(uuidStr,t.getAttributes());
this.ndexService._ndexDatabase.commit();
return;
} finally {
this.ndexService.teardownDatabase();
}
}