本文整理匯總了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();
}