当前位置: 首页>>代码示例>>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;未经允许,请勿转载。