當前位置: 首頁>>代碼示例>>Java>>正文


Java XStream.aliasPackage方法代碼示例

本文整理匯總了Java中com.thoughtworks.xstream.XStream.aliasPackage方法的典型用法代碼示例。如果您正苦於以下問題:Java XStream.aliasPackage方法的具體用法?Java XStream.aliasPackage怎麽用?Java XStream.aliasPackage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.thoughtworks.xstream.XStream的用法示例。


在下文中一共展示了XStream.aliasPackage方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: executeDataMigration

import com.thoughtworks.xstream.XStream; //導入方法依賴的package包/類
@Override
@SuppressWarnings({"unchecked", "nls"})
protected void executeDataMigration(HibernateMigrationHelper helper, MigrationResult result, Session session)
{
	ClassLoader classLoader = getClass().getClassLoader();
	XStream xstream = xmlService.createDefault(classLoader);
	xstream.aliasPackage("com.tle.beans.entity.workflow", "com.tle.common.old.workflow");

	MigrateWorkflow migrator = new MigrateWorkflow();
	Map<Long, Map<String, WorkflowNode>> workflowMap = new HashMap<Long, Map<String, WorkflowNode>>();
	Query allWorkflows = session.createQuery("from Workflow");
	List<Workflow> workflows = allWorkflows.list();
	for( Workflow workflow : workflows )
	{

		List<WorkflowNode> newNodes = migrator.convertNodes((WorkflowTreeNode) xstream.fromXML(workflow.root));
		for( WorkflowNode newNode : newNodes )
		{
			newNode.setWorkflow(workflow);
			session.save(newNode);
			session.flush();
		}
		result.incrementStatus();
		workflowMap.put(workflow.id, workflow.getAllTasksAsMap());
	}
	session.clear();

	int badModStatus = 0;
	Query allStatuses = session.createQuery("from WorkflowNodeStatus");
	List<WorkflowNodeStatus> statuses = allStatuses.list();
	for( WorkflowNodeStatus status : statuses )
	{
		String nodeId = status.nodeId;
		Query statusQuery = session.createQuery("select s from ModerationStatus s join s.statuses st where st = ?");
		statusQuery.setParameter(0, status);
		ModerationStatus modStatus = (ModerationStatus) statusQuery.uniqueResult();
		if( modStatus != null )
		{
			FakeItem item = modStatus.item;
			if( item != null )
			{
				Map<String, WorkflowNode> map = workflowMap.get(item.itemDefinition.workflowId);
				WorkflowNode linkedNode = map != null ? map.get(nodeId) : null;
				if( linkedNode != null )
				{
					status.setNode(linkedNode);
					status.setModStatus(modStatus);
					if( status instanceof WorkflowItemStatus)
					{
						WorkflowItemStatus itemStatus = (WorkflowItemStatus) status;
						itemStatus.setAcceptedUsers((Set<String>) xstream.fromXML(itemStatus.oldAccepted));
					}
					session.save(status);
				}
				else
				{
					modStatus.statuses.remove(status);
					session.save(modStatus);
				}
			}
			else
			{
				badModStatus++;
				session.delete(modStatus);
			}
		}
		result.incrementStatus();
		session.flush();
	}
	session.clear();
	int numDeleted = session.createQuery("delete from WorkflowNodeStatus where node is null").executeUpdate();
	if( numDeleted > 0 )
	{
		LOGGER.warn("Found " + numDeleted + " orphaned WorkflowNodeStatus objects");
	}
	if( badModStatus > 0 )
	{
		LOGGER.warn("Found " + badModStatus + " orphaned ModerationStatus objects");
	}
	session.createQuery("update ModerationStatus set needsReset = false").executeUpdate();
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:82,代碼來源:CreateWorkflowTables.java


注:本文中的com.thoughtworks.xstream.XStream.aliasPackage方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。