本文整理汇总了Java中org.ndexbio.model.object.Task.getTaskType方法的典型用法代码示例。如果您正苦于以下问题:Java Task.getTaskType方法的具体用法?Java Task.getTaskType怎么用?Java Task.getTaskType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.ndexbio.model.object.Task
的用法示例。
在下文中一共展示了Task.getTaskType方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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());
}
}
示例2: getNdexTaskByTaskType
import org.ndexbio.model.object.Task; //导入方法依赖的package包/类
private NdexTask getNdexTaskByTaskType(Task task) throws NdexException{
try {
if( task.getTaskType() == TaskType.PROCESS_UPLOADED_NETWORK) {
return new FileUploadTask(task, db);
}
if( task.getTaskType() == TaskType.EXPORT_NETWORK_TO_FILE) {
if ( task.getFormat() == FileFormat.XBEL)
return new XbelExporterTask(task);
else if ( task.getFormat() == FileFormat.XGMML) {
return new XGMMLExporterTask(task);
} if ( task.getFormat() == FileFormat.BIOPAX) {
return new BioPAXExporterTask(task);
} if ( task.getFormat() == FileFormat.CX) {
return new CXExporterTask(task);
}
throw new NdexException ("Only XBEL, XGMML, CX and BIOPAX exporters are implemented.");
}
throw new NdexException("Task type: " +task.getTaskType() +" is not supported");
} catch (IllegalArgumentException | SecurityException | NdexException e) {
e.printStackTrace();
throw new NdexException ("Error occurred when creating task. " + e.getMessage());
}
}
示例3: createUserTask
import org.ndexbio.model.object.Task; //导入方法依赖的package包/类
public static NdexTask createUserTask(Task t) throws NdexException {
switch (t.getTaskType()) {
case EXPORT_NETWORK_TO_FILE:
return new NetworkExportTask(t);
default:
throw new NdexException ("Unknow user task: " + t.getExternalId() + " - " + t.getTaskType());
}
}
示例4: getNdexTask
import org.ndexbio.model.object.Task; //导入方法依赖的package包/类
private static NdexTask getNdexTask(Task task) throws NdexException{
try {
switch ( task.getTaskType()) {
case PROCESS_UPLOADED_NETWORK:
return new FileUploadTask(task, NdexDatabase.getInstance());
case DOWNLOAD_NAMESPACE_FILES:
return new AttachNamespacefilesTask(task);
case EXPORT_NETWORK_TO_FILE:
if ( task.getFormat() == FileFormat.XBEL)
return new XbelExporterTask(task);
else if ( task.getFormat() == FileFormat.XGMML) {
return new XGMMLExporterTask(task);
} if ( task.getFormat() == FileFormat.BIOPAX) {
return new BioPAXExporterTask(task);
} if ( task.getFormat() == FileFormat.SIF) {
return new SIFExporterTask(task);
} if ( task.getFormat() == FileFormat.CX) {
return new CXExporterTask(task);
}
throw new NdexException ("Only XBEL, XGMML, SIF, CX, and BIOPAX exporters are implemented.");
case CREATE_NETWORK_CACHE:
return new AddNetworkToCacheTask(task);
case DELETE_NETWORK_CACHE:
return new RemoveNetworkFromCacheTask(task);
default:
throw new NdexException("Task type: " +task.getTaskType() +" is not supported");
}
} catch (IllegalArgumentException | SecurityException | NdexException e) {
e.printStackTrace();
throw new NdexException ("Error occurred when creating task. " + e.getMessage());
}
}
示例5: deleteTask
import org.ndexbio.model.object.Task; //导入方法依赖的package包/类
/**************************************************************************
* Deletes a task.
*
* @param taskId
* The task ID.
* @throws SQLException
* @throws IOException
* @throws JsonMappingException
* @throws JsonParseException
**************************************************************************/
/*
* refactored for non-transactional database operations
*/
@DELETE
@Path("/{taskid}")
@Produces("application/json")
@ApiDoc("Delete the task specified by taskId. Errors if no task found or if authenticated user does not own task.")
public void deleteTask(@PathParam("taskid")final String taskUUID) throws IllegalArgumentException, ObjectNotFoundException, UnauthorizedOperationException, NdexException, SQLException, JsonParseException, JsonMappingException, IOException
{
UUID taskId = UUID.fromString(taskUUID);
try (TaskDAO tdao= new TaskDAO()) {
final Task taskToDelete = tdao.getTaskByUUID(taskId);
if (taskToDelete == null) {
throw new ObjectNotFoundException("Task with ID: " + taskUUID + " doesn't exist.");
}
else if (!taskToDelete.getTaskOwnerId().equals(this.getLoggedInUser().getExternalId())) {
throw new UnauthorizedOperationException("You cannot delete a task you don't own.");
}
if ( taskToDelete.getIsDeleted()) {
logger.info("[end: Task {} is already deleted by user {}]",
taskUUID,this.getLoggedInUser().getUserName());
} else {
tdao.deleteTask(taskToDelete.getExternalId());
tdao.commit();
if (taskToDelete.getTaskType() == TaskType.EXPORT_NETWORK_TO_FILE) { //delete the exported file assume all exported files started with the taskId
Files.list(Paths.get(Configuration.getInstance().getNdexRoot() + "/workspace/" +taskToDelete.getTaskOwnerId()))
.filter(p -> p.toString().contains("/" + taskToDelete.getExternalId().toString() + ".")).forEach((p) -> {
try {
Files.deleteIfExists(p);
} catch (Exception e) {
e.printStackTrace();
}
});
}
}
}
}
示例6: downloadExportedFile
import org.ndexbio.model.object.Task; //导入方法依赖的package包/类
@PermitAll
@GET
@Path("/{taskid}/file")
//download the file generated by this export task. If this task is not an export task, a 500 error will be return.
public Response downloadExportedFile( @PathParam("taskid") final String taskIdStr,
@QueryParam("download") boolean isDownload,
@QueryParam("id_token") String id_token)
throws NdexException, SQLException, JsonParseException, JsonMappingException, IOException, IllegalArgumentException, GeneralSecurityException {
String title = null;
UUID taskId = UUID.fromString(taskIdStr);
String extension = null;
UUID userId = getLoggedInUserId();
if ( userId == null && id_token !=null) {
if ( getGoogleAuthenticator() == null)
throw new UnauthorizedOperationException("Google OAuth is not enabled on this server.");
userId = getGoogleAuthenticator().getUserUUIDByIdToken(id_token);
}
try (TaskDAO dao = new TaskDAO()) {
Task t = dao.getTaskByUUID(taskId);
if (t == null)
throw new ObjectNotFoundException("Task " + taskIdStr + " is not found in this server.");
if(t.getTaskOwnerId() == null || !t.getTaskOwnerId().equals(userId) )
throw new UnauthorizedOperationException("This task is not owned by this user.");
if ( t.getTaskType() != TaskType.EXPORT_NETWORK_TO_FILE)
throw new ObjectNotFoundException("File not found. This task is not a network export task.");
if ( t.getStatus() != Status.COMPLETED)
throw new ObjectNotFoundException("File not found. This task is not completed yet.");
title = (String)t.getAttribute("downloadFileName");
extension = (String)t.getAttribute("downloadFileExtension");
}
if ( title == null || title.length() < 1) {
title = taskIdStr;
}
title.replace('"', '_');
String cxFilePath = Configuration.getInstance().getNdexRoot() + "/workspace/" +userId +
"/"+ taskId + (extension != null ? "." + extension : "");
try {
FileInputStream in = new FileInputStream(cxFilePath) ;
// setZipFlag();
// logger.info("[end: Return network {}]", networkId);
ResponseBuilder r = Response.ok();
if ( isDownload) {
r.header("Content-Disposition", "attachment; filename=\"" + title + (extension != null ? "." + extension : "") +"\"");
r.header("Access-Control-Expose-Headers", "Content-Disposition");
}
return r.type(MediaType.APPLICATION_OCTET_STREAM_TYPE).entity(in).build();
} catch (IOException e) {
logger.error("[end: Ndex server can't find file: {}]", e.getMessage());
throw new NdexException ("Ndex server can't find file: " + e.getMessage());
}
}