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


Java Task.setResource方法代码示例

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


在下文中一共展示了Task.setResource方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createTask

import org.ndexbio.model.object.Task; //导入方法依赖的package包/类
@Override
public Task createTask() {
	Task t = super.createTask();
	t.setResource(networkId.toString());
	t.getAttributes().put(AttrScope, this.idxScope);
	t.getAttributes().put(AttrCreateOnly, Boolean.valueOf(this.createOnly));
	t.setAttribute("fields", indexedFields);
	t.setAttribute("indexLevel", this.indexLevel);
	return t;
}
 
开发者ID:ndexbio,项目名称:ndex-rest,代码行数:11,代码来源:SolrTaskRebuildNetworkIdx.java

示例2: createTask

import org.ndexbio.model.object.Task; //导入方法依赖的package包/类
@Override
public Task createTask() {
	Task task = super.createTask();
    task.setResource(networkId.toString());
	task.setAttribute("visibility", visibility);
	task.setAttribute("nodeIndexes", this.nodeAttributeIndexList);
	task.setAttribute("owner", ownerUserName);
	task.setAttribute("isUpdate", Boolean.valueOf(isUpdate));
    return task;	

}
 
开发者ID:ndexbio,项目名称:ndex-rest,代码行数:12,代码来源:CXNetworkLoadingTask.java

示例3: createTask

import org.ndexbio.model.object.Task; //导入方法依赖的package包/类
@Override
public Task createTask() {
	Task t = super.createTask();
	t.setResource(networkId.toString());
	t.setAttribute(globalIdxAttr, Boolean.valueOf(globalIdxOnly));
	return t;
}
 
开发者ID:ndexbio,项目名称:ndex-rest,代码行数:8,代码来源:SolrTaskDeleteNetwork.java

示例4: abortTransaction

import org.ndexbio.model.object.Task; //导入方法依赖的package包/类
public void abortTransaction() throws ObjectNotFoundException, NdexException {
	System.out.println(this.getClass().getName()
			+ ".abortTransaction has been invoked.");

	logger.info("Deleting partial network "+ network.getExternalId().toString() + " in order to rollback in response to error");
	this.networkDAO.logicalDeleteNetwork(network.getExternalId().toString());
	graph.commit();
	Task task = new Task();
	task.setTaskType(TaskType.SYSTEM_DELETE_NETWORK);
	task.setResource(network.getExternalId().toString());
	NdexServerQueue.INSTANCE.addSystemTask(task);
	logger.info("Partial network "+ network.getExternalId().toString() + " is deleted.");
}
 
开发者ID:ndexbio,项目名称:ndex-common,代码行数:14,代码来源:NdexPersistenceService.java

示例5: abortTransaction

import org.ndexbio.model.object.Task; //导入方法依赖的package包/类
private void abortTransaction() throws ObjectNotFoundException, NdexException {
	logger.warn("AbortTransaction has been invoked from CX loader.");

	logger.info("Deleting partial network "+ uuid + " in order to rollback in response to error");
	networkDoc.field(NdexClasses.ExternalObj_isDeleted, true).save();
	graph.commit();
	
	Task task = new Task();
	task.setTaskType(TaskType.SYSTEM_DELETE_NETWORK);
	task.setResource(uuid.toString());
	NdexServerQueue.INSTANCE.addSystemTask(task);
	logger.info("Partial network "+ uuid + " is deleted.");
}
 
开发者ID:ndexbio,项目名称:ndex-common,代码行数:14,代码来源:CXNetworkLoader.java

示例6: abortTransaction

import org.ndexbio.model.object.Task; //导入方法依赖的package包/类
private void abortTransaction() throws ObjectNotFoundException, NdexException {
	logger.warn("AbortTransaction has been invoked from network clone service.");

	logger.info("Deleting partial network "+ this.network.getExternalId().toString() + " in order to rollback in response to error");
	networkDoc.field(NdexClasses.ExternalObj_isDeleted, true).save();
	graph.commit();
	
	Task task = new Task();
	task.setTaskType(TaskType.SYSTEM_DELETE_NETWORK);
	task.setResource(this.network.getExternalId().toString());
	NdexServerQueue.INSTANCE.addSystemTask(task);
	logger.info("Partial network "+ this.network.getExternalId().toString() + " is deleted.");
}
 
开发者ID:ndexbio,项目名称:ndex-common,代码行数:14,代码来源:NdexNetworkCloneService.java

示例7: 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

示例8: generateTask

import org.ndexbio.model.object.Task; //导入方法依赖的package包/类
private Task generateTask(String networkId) {
		Task task = new Task();
		task.setResource(networkId);
//		task.setCreatedDate(new Date());
		task.setStatus(Status.QUEUED);
		
		return task;
	}
 
开发者ID:ndexbio,项目名称:ndex-common,代码行数:9,代码来源:TestXbelExportTask.java

示例9: 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

示例10: 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

示例11: updateNetwork

import org.ndexbio.model.object.Task; //导入方法依赖的package包/类
public UUID updateNetwork(String networkUUID) throws NdexException, ExecutionException, SolrServerException, IOException {

		// get the old network head node
		ODocument srcNetworkDoc = this.getRecordByUUIDStr(networkUUID);
		if (srcNetworkDoc == null)
				throw new NdexException("Network with UUID " + networkUUID + " is not found in this server");

		srcNetworkDoc.field(NdexClasses.Network_P_isComplete, false).save();
		graph.commit();
		try {


			// create new network and set the isComplete flag to false 
			uuid = NdexUUIDFactory.INSTANCE.createNewNDExUUID();

			persistNetworkData();
			
			// copy the permission from source to target.
			copyNetworkPermissions(srcNetworkDoc, networkVertex);
			
			graph.commit();
		} catch ( Exception e) {
			e.printStackTrace();
			this.abortTransaction();
			srcNetworkDoc.field(NdexClasses.Network_P_isComplete, true).save();
			graph.commit();
			throw new NdexException("Error occurred when updating network using CX. " + e.getMessage());
		}
			
		
		graph.begin();

		UUID newUUID = NdexUUIDFactory.INSTANCE.createNewNDExUUID();

		srcNetworkDoc.fields(NdexClasses.ExternalObj_ID, newUUID.toString(),
					  NdexClasses.ExternalObj_isDeleted,true).save();
			
		this.networkDoc.reload();
		// copy the creationTime and visibility
		networkDoc.fields( NdexClasses.ExternalObj_ID, networkUUID,
					NdexClasses.ExternalObj_cTime, srcNetworkDoc.field(NdexClasses.ExternalObj_cTime),
					NdexClasses.Network_P_visibility, srcNetworkDoc.field(NdexClasses.Network_P_visibility),
					NdexClasses.Network_P_isLocked,false,
					NdexClasses.ExternalObj_mTime, new Date() ,
					          NdexClasses.Network_P_isComplete,true)
			.save();
		graph.commit();
		
		
		// remove the old solr Index and add the new one.
		SingleNetworkSolrIdxManager idxManager = new SingleNetworkSolrIdxManager(networkUUID);
		NetworkGlobalIndexManager globalIdx = new NetworkGlobalIndexManager();
		try {
			idxManager.dropIndex();
			globalIdx.deleteNetwork(networkUUID);
		} catch (SolrServerException | HttpSolrClient.RemoteSolrException | IOException se ) {
			logger.warn("Failed to delete Solr Index for network " + networkUUID + ". Please clean it up manually from solr. Error message: " + se.getMessage());
		}
		
		createSolrIndex(networkDoc);
			
		// added a delete old network task.
		Task task = new Task();
		task.setTaskType(TaskType.SYSTEM_DELETE_NETWORK);
		task.setResource(newUUID.toString());
		NdexServerQueue.INSTANCE.addSystemTask(task);
			
		return UUID.fromString(networkUUID);
		 	
	}
 
开发者ID:ndexbio,项目名称:ndex-common,代码行数:71,代码来源:CXNetworkLoader.java

示例12: updateNetwork

import org.ndexbio.model.object.Task; //导入方法依赖的package包/类
/**
 * 
 * @return
 * @throws NdexException
 * @throws ExecutionException
 * @throws IOException 
 * @throws SolrServerException 
 */
public NetworkSummary updateNetwork() throws NdexException, ExecutionException, SolrServerException, IOException {
	try {
		
		// create new network and set the isComplete flag to false 
		cloneNetworkCore();
		
		this.network.setExternalId(this.srcNetwork.getExternalId());
		
		// get the old network head node
		ODocument srcNetworkDoc = networkDAO.getNetworkDocByUUID(this.srcNetwork.getExternalId());
		if (srcNetworkDoc == null)
			throw new NdexException("Network with UUID " + this.srcNetwork.getExternalId()
					+ " is not found in this server");
		
		// copy the permission from source to target.
		copyNetworkPermissions(srcNetworkDoc, networkVertex);
		
		this.localConnection.commit();
		
		//move the UUID from old network to new network, set new one's isComplete and set the old one to isDeleted.
		
		localConnection.begin();
		UUID newUUID = NdexUUIDFactory.INSTANCE.createNewNDExUUID();

		srcNetworkDoc.fields(NdexClasses.ExternalObj_ID, newUUID.toString(),
				  NdexClasses.ExternalObj_isDeleted,true).save();
		
		this.networkDoc.reload();
		// copy the creationTime and visibility
		networkDoc.fields(NdexClasses.ExternalObj_ID, this.srcNetwork.getExternalId(),
				NdexClasses.ExternalObj_cTime, srcNetworkDoc.field(NdexClasses.ExternalObj_cTime),
				NdexClasses.Network_P_visibility, srcNetworkDoc.field(NdexClasses.Network_P_visibility),
				NdexClasses.Network_P_isLocked,false,
				NdexClasses.ExternalObj_mTime, new Date() ,
				          NdexClasses.Network_P_isComplete,true)
		.save();
		localConnection.commit();
		
		// remove the old solr Index and add the new one.
		String networkUUID = this.srcNetwork.getExternalId().toString();
		SingleNetworkSolrIdxManager idxManager = new SingleNetworkSolrIdxManager(networkUUID);
		NetworkGlobalIndexManager globalIdx = new NetworkGlobalIndexManager();
		try {
			idxManager.dropIndex();
			globalIdx.deleteNetwork(networkUUID);
		} catch (SolrServerException | HttpSolrClient.RemoteSolrException | IOException se ) {
			logger.warn("Failed to delete Solr Index for network " + networkUUID + ". Please clean it up manually from solr. Error message: " + se.getMessage());
		}
		createSolrIndex(networkDoc);
					
		
		// added a delete old network task.
		Task task = new Task();
		task.setTaskType(TaskType.SYSTEM_DELETE_NETWORK);
		task.setResource(newUUID.toString());
		NdexServerQueue.INSTANCE.addSystemTask(task);
		
		this.network.setIsLocked(false);
		
		return this.network;
	} finally {
		this.localConnection.commit();

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


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