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


Java ObjectNode.deepCopy方法代码示例

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


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

示例1: updateMetricData

import com.fasterxml.jackson.databind.node.ObjectNode; //导入方法依赖的package包/类
private ObjectNode updateMetricData(long nowMs, String hostName, ObjectNode testData) {
	ObjectNode data;
	data = testData.deepCopy(); // copy test data, modify it

	ObjectNode attNode = (ObjectNode) data.path( "attributes" );
	attNode.put( "hostName", hostName );
	attNode.put( "currentTimeMillis", nowMs );

	ArrayNode timeStamps = (ArrayNode) data.path( "data" ).path( "timeStamp" );
	for (int i = 0; i < timeStamps.size(); i++) {
		long offset = i * 30000; // timeStamps in reverse order LIFO. latest
									// time is first
		timeStamps.set( i, LongNode.valueOf( nowMs - offset ) );
	}
	return data;
}
 
开发者ID:csap-platform,项目名称:csap-core,代码行数:17,代码来源:Agent_Capacity_Tests.java

示例2: updateOrValidateSettings

import com.fasterxml.jackson.databind.node.ObjectNode; //导入方法依赖的package包/类
@RequestMapping ( value = "/settings" , produces = MediaType.APPLICATION_JSON_VALUE , method = RequestMethod.POST )
public ObjectNode updateOrValidateSettings (
												@RequestParam ( "lifeToEdit" ) String lifeToEdit,
												@RequestParam ( "definition" ) String definitionText,
												@RequestParam ( value = "isUpdate" , required = false ) String isUpdate ) {

	if ( lifeToEdit == null ) {
		lifeToEdit = Application.getCurrentLifeCycle();
	}

	logger.info( "lifeToEdit: {} , isUpdate: {}", lifeToEdit, isUpdate );
	logger.debug( "definitionText: \n{}", definitionText );

	ObjectNode updateResultNode = jacksonMapper.createObjectNode();

	try {
		ObjectNode updatedSettingsDefinition = (ObjectNode) jacksonMapper.readTree( definitionText );
		updatedSettingsDefinition.put( "lastModifiedBy", CsapUser.currentUsersID() );

		ObjectNode modelNode = (ObjectNode) csapApp.getRootModel().getJsonModelDefinition();

		ObjectNode testPackageModel = modelNode.deepCopy();

		JsonNode currentLifeNode = testPackageModel.at( DefinitionParser.buildLifePtr( lifeToEdit ) );

		((ObjectNode) currentLifeNode).set( DefinitionParser.PARSER_SETTINGS, updatedSettingsDefinition );

		updateResultNode.put( "lifeToEdit", lifeToEdit );
		logger.debug( "updateNode: \n{}", updatedSettingsDefinition.toString() );

		ObjectNode validationResults = csapApp.checkDefinitionForParsingIssues(
			testPackageModel.toString(),
			csapApp.getRootModel().getReleasePackageName(),
			"settingsUpdate" );

		updateResultNode.set( "validationResults", validationResults );

		boolean validatePassed = ((ArrayNode) validationResults.get( Application.VALIDATION_ERRORS )).size() == 0;

		if ( validatePassed ) {
			validateTrendingAndRealTimeDefinition( lifeToEdit, updatedSettingsDefinition, validationResults );
		}

		if ( isUpdate != null && validatePassed ) {
			updateResultNode.put( "updatedHost", Application.getHOST_NAME() );
			csapApp.getRootModel().setJsonModelDefinition( testPackageModel );
		}

	} catch (Throwable ex) {
		logger.error( "Failed to parse", ex );
		return buildEditingErrorResponse( ex, updateResultNode );
	}

	return updateResultNode;
}
 
开发者ID:csap-platform,项目名称:csap-core,代码行数:56,代码来源:DefinitionRequests.java


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