当前位置: 首页>>代码示例>>Java>>正文


Java Task.setMessage方法代码示例

本文整理汇总了Java中org.ndexbio.model.object.Task.setMessage方法的典型用法代码示例。如果您正苦于以下问题:Java Task.setMessage方法的具体用法?Java Task.setMessage怎么用?Java Task.setMessage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.ndexbio.model.object.Task的用法示例。


在下文中一共展示了Task.setMessage方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
 
开发者ID:ndexbio,项目名称:ndex-common,代码行数:37,代码来源:TaskDocDAO.java

示例2: cleanupDeletedNetwork

import org.ndexbio.model.object.Task; //导入方法依赖的package包/类
private void cleanupDeletedNetwork (Task task) throws NdexException  {
	logger.info( "Cleanup deleted network " + task.getResource());

	task.setStartTime(new Timestamp(Calendar.getInstance().getTimeInMillis()));
	try (NetworkDAO networkDao = new NetworkDAO(NdexDatabase.getInstance().getAConnection()); ) {
		int cnt = networkDao.cleanupDeleteNetwork(task.getResource());
		networkDao.commit();
		task.setFinishTime(new Timestamp(Calendar.getInstance().getTimeInMillis()));
		task.setStatus(Status.COMPLETED);
		if ( cnt >=0 ) {
			logger.info("Network " + task.getResource() + " cleanup finished.");
			task.setMessage(cnt + " vertices deleted.");
		} else {  // only partially deleted.
			String message ="cleanup stoppped after " +( -1 * cnt )+ " vertices deleted.";
			logger.info("Network " + task.getResource() + message);
			task.setMessage(message);
		}
		try (TaskDAO taskdao = new TaskDAO (NdexDatabase.getInstance().getAConnection())) {
			taskdao.createTask(null, task);
			taskdao.commit();
		}
		if ( cnt < 0 ) {
			task.setExternalId(NdexUUIDFactory.INSTANCE.createNewNDExUUID());
			NdexServerQueue.INSTANCE.addSystemTask(task); // add the task back to the queue.
		}
	}	
}
 
开发者ID:ndexbio,项目名称:ndex-common,代码行数:28,代码来源:SystemTaskProcessor.java

示例3: exportNetworks

import org.ndexbio.model.object.Task; //导入方法依赖的package包/类
@POST
@Path("/network/export")
@Produces("application/json")
   @ApiDoc("")
public Map<UUID,UUID> exportNetworks(NetworkExportRequestV2 exportRequest)

		throws IllegalArgumentException, NdexException, SQLException, IOException {
	
	    
   			String rr = (new ObjectMapper()).writeValueAsString(exportRequest.getNetworkIds());
		accLogger.info("[data]\t[format:" +exportRequest.getExportFormat() + "][NetworkIds:"+ rr+ "]" );

	    ImporterExporterEntry entry = Configuration.getInstance().getImpExpEntry(exportRequest.getExportFormat());
	    if ( entry == null || entry.getExporterCmd() == null || 
	    		entry.getExporterCmd().isEmpty())
	    	throw new NdexException("No exporter was registered in this server for network format " + exportRequest.getExportFormat());
	    
	    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("User doesn't have read access to network " + networkID + ".");
						//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("name", entry.getName());
						t.setAttribute("downloadFileExtension", entry.getFileExtension());
					}
					UUID taskId = taskdao.createTask(t);
					taskdao.commit();
					
					result.put(networkID, taskId);
					
					if ( t.getStatus() == Status.QUEUED)
					NdexServerQueue.INSTANCE.addUserTask(new NetworkExportTask(t));

				}
			}
		}
		
		return result;
	    
}
 
开发者ID:ndexbio,项目名称:ndex-rest,代码行数:61,代码来源:BatchServiceV2.java

示例4: 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;
	    
}
 
开发者ID:ndexbio,项目名称:ndex-rest,代码行数:58,代码来源:NetworkService.java

示例5: backupDatabase

import org.ndexbio.model.object.Task; //导入方法依赖的package包/类
private void backupDatabase (Task task) throws NdexException {

		task.setStartTime(new Timestamp(Calendar.getInstance().getTimeInMillis()));
   		 String ndexRoot = Configuration.getInstance().getNdexRoot();
   		 SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
   		 String strDate = sdf.format(Calendar.getInstance().getTime());

   		 try (ODatabaseDocumentTx db = NdexDatabase.getInstance().getAConnection()){
		
       		 String exportFile = ndexRoot + "/dbbackups/db_"+ strDate + ".export";

       		 logger.info("Backing up database to " + exportFile);
       		 
       		 try{
       			  OCommandOutputListener listener = new OCommandOutputListener() {
       			    @Override
       			    public void onMessage(String iText) {
       			      logger.info(iText);
       			    }
       			  };

       			  ODatabaseExport export = new ODatabaseExport(db, exportFile, listener);
       			  export.setIncludeIndexDefinitions(false);
       			  export.exportDatabase();
       			  export.close();
       			  task.setFinishTime(new Timestamp(Calendar.getInstance().getTimeInMillis()));
       			  task.setStatus(Status.COMPLETED);
       			  task.setMessage("Db exported to " + exportFile);
           		 logger.info("Database back up fininished succefully.");
       			} catch (Exception e) {
       				task.setMessage(e.getMessage());
       				task.setStatus(Status.FAILED);
					logger.severe("IO exception when backing up database. " + e.getMessage());
					e.printStackTrace();
				} 

 			try (TaskDAO taskdao = new TaskDAO (NdexDatabase.getInstance().getAConnection())) {
 				taskdao.createTask(null, task);
 				taskdao.commit();
 				taskdao.close();
 			}

       	 } 	
	}
 
开发者ID:ndexbio,项目名称:ndex-common,代码行数:45,代码来源:SystemTaskProcessor.java


注:本文中的org.ndexbio.model.object.Task.setMessage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。