本文整理汇总了Java中org.ndexbio.model.object.Task.setFormat方法的典型用法代码示例。如果您正苦于以下问题:Java Task.setFormat方法的具体用法?Java Task.setFormat怎么用?Java Task.setFormat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.ndexbio.model.object.Task
的用法示例。
在下文中一共展示了Task.setFormat方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTaskFromDocument
import org.ndexbio.model.object.Task; //导入方法依赖的package包/类
protected static Task getTaskFromDocument(ODocument doc) {
Task result = new Task();
Helper.populateExternalObjectFromDoc(result, doc);
result.setDescription((String)doc.field(NdexClasses.Task_P_description));
result.setPriority(Priority.valueOf((String)doc.field(NdexClasses.Task_P_priority)));
result.setProgress((int)doc.field(NdexClasses.Task_P_progress));
result.setResource((String)doc.field(NdexClasses.Task_P_resource));
result.setStatus(Status.valueOf((String)doc.field(NdexClasses.Task_P_status)));
result.setTaskType(TaskType.valueOf((String)doc.field(NdexClasses.Task_P_taskType)));
Object o = doc.field(NdexClasses.Task_P_attributes);
if ( o != null) {
Map<String, Object> attr = (Map<String,Object>) o;
result.setAttributes(attr);
}
Date d = doc.field(NdexClasses.Task_P_startTime);
if (d !=null)
result.setStartTime(new Timestamp(d.getTime()));
d = doc.field(NdexClasses.Task_P_endTime);
if ( d!=null)
result.setFinishTime(new Timestamp(d.getTime()));
result.setMessage((String)doc.field(NdexClasses.Task_P_message));
ODocument ownerDoc = doc.field("out_"+ NdexClasses.Task_E_owner);
result.setTaskOwnerId(UUID.fromString((String)ownerDoc.field(NdexClasses.ExternalObj_ID)));
String str = doc.field(NdexClasses.Task_P_fileFormat);
if ( str != null) result.setFormat(FileFormat.valueOf(str));
return result;
}
示例2: exportNetworks
import org.ndexbio.model.object.Task; //导入方法依赖的package包/类
@POST
@Path("/export")
@Produces("application/json")
@ApiDoc("Set the system flag specified by ‘parameter’ to ‘value’ for the network with id ‘networkId’. As of " +
"NDEx v1.2, the only supported parameter is readOnly={true|false}. In 2.0, we added visibility={PUBLIC|PRIVATE}")
public Map<UUID,UUID> exportNetworks(NetworkExportRequest exportRequest)
throws IllegalArgumentException, NdexException, SQLException, SolrServerException, IOException {
logger.info("exporting networks");
if ( !exportRequest.getNetworkFormat().toLowerCase().equals("cx"))
throw new NdexException("Networks can only be exported in cx fromat in this server.");
Map<UUID,UUID> result = new TreeMap<>();
try (NetworkDAO networkDao = new NetworkDAO()) {
try (TaskDAO taskdao = new TaskDAO()) {
for ( UUID networkID : exportRequest.getNetworkIds()) {
Task t = new Task();
Timestamp currentTime = new Timestamp(Calendar.getInstance().getTimeInMillis());
t.setCreationTime(currentTime);
t.setModificationTime(currentTime);
t.setStartTime(currentTime);
t.setFinishTime(currentTime);
t.setDescription("network export");
t.setTaskType(TaskType.EXPORT_NETWORK_TO_FILE);
t.setFormat(FileFormat.CX);
t.setTaskOwnerId(getLoggedInUserId());
t.setResource(networkID.toString());
if (! networkDao.isReadable(networkID, getLoggedInUserId())) {
t.setStatus(Status.FAILED);
t.setMessage("Network " + networkID + " is not found for user.");
//throw new NdexException ("Network " + networkID + " is not found.");
} else {
t.setStatus(Status.QUEUED);
NetworkSummary s = networkDao.getNetworkSummaryById(networkID);
t.setAttribute("downloadFileName", s.getName());
t.setAttribute("downloadFileExtension", "CX");
}
UUID taskId = taskdao.createTask(t);
taskdao.commit();
result.put(networkID, taskId);
if ( t.getStatus() == Status.QUEUED)
NdexServerQueue.INSTANCE.addUserTask(new NetworkExportTask(t));
}
}
}
return result;
}