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


Java ObjectNode.remove方法代码示例

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


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

示例1: getTaskFromJson

import com.fasterxml.jackson.databind.node.ObjectNode; //导入方法依赖的package包/类
private Task getTaskFromJson(JsonNode node) throws JsonProcessingException {
	if (node.isObject()) {
		ObjectNode onode = (ObjectNode) node;
		final JsonNode type = onode.remove("type");
		final JsonNode attributes = onode.remove("attributes");
		final JsonNode relationships = onode.remove("relationships");
		final JsonNode links = onode.remove("links");
		Iterator<Map.Entry<String, JsonNode>> fields = attributes.fields();
		while (fields.hasNext()) {
			Map.Entry<String, JsonNode> f = fields.next();
			onode.put(f.getKey(), f.getValue().textValue());
		}
		return mapper.treeToValue(onode, Task.class);
	}
	else {
		throw new JsonMappingException("Not an object: " + node);
	}
}
 
开发者ID:crnk-project,项目名称:crnk-framework,代码行数:19,代码来源:JerseyApplicationTest.java

示例2: testBasicEdit

import com.fasterxml.jackson.databind.node.ObjectNode; //导入方法依赖的package包/类
@Test
public void testBasicEdit()
{
	ObjectNode client = normalRequests.create(createJsonForEdit(context.getFullName("Editing")));
	extraEdits(client);
	client.put("name", "changed");
	client.put("description", "changed");
	client.remove("nameStrings");
	client.remove("descriptionStrings");
	// Cannot edit owner without import=true
	// client.with("owner").put("id", RestTestConstants.USERID_MODERATOR1);

	String uuid = normalRequests.editId(client);
	ObjectNode edited = normalRequests.get(uuid);
	assertExtraEdits(edited);
	// Assert.assertEquals(edited.with("owner").get("id").asText(),
	// RestTestConstants.USERID_MODERATOR1);
	Assert.assertEquals(edited.get("name").asText(), "changed");
	Assert.assertEquals(edited.get("description").asText(), "changed");
}
 
开发者ID:equella,项目名称:Equella,代码行数:21,代码来源:AbstractEntityApiEditTest.java

示例3: createTest

import com.fasterxml.jackson.databind.node.ObjectNode; //导入方法依赖的package包/类
@Test
public void createTest()
{
	ObjectNode wrong = institutions.jsonAppendBaseUrl(INST_NAME, null, INST_NAME, INST_NAME, true);
	assertValidationError(wrong, "Password must not be left blank");
	wrong.put("password", context.getTestConfig().getAdminPassword());
	wrong.remove("name");
	assertValidationError(wrong, "Institution name must not be left blank");
	wrong.put("name", "AutoTest");
	assertValidationError(wrong, "Institution name 'AutoTest' is already in use by another institution");
	wrong.put("name", INST_NAME);
	wrong.put("filestoreId", "autotest");
	assertValidationError(wrong, "Filestore ID 'autotest' is already in use by another institution");
	wrong.put("filestoreId", INST_NAME);

	institutionsNoAuth.createFail(institutionsNoAuth.accessDeniedRequest(), wrong);
	ObjectNode inst = institutions.create(wrong);
	instId = institutions.getId(inst);
}
 
开发者ID:equella,项目名称:Equella,代码行数:20,代码来源:InstitutionApiTest.java

示例4: process

import com.fasterxml.jackson.databind.node.ObjectNode; //导入方法依赖的package包/类
@Override
public void process(final Exchange exchange) throws Exception {
    // parse input json and extract Id field
    final Message in = exchange.getIn();
    final String body = in.getBody(String.class);

    if (body == null) {
        return;
    }

    final ObjectNode node = (ObjectNode) MAPPER.readTree(body);

    final String idPropertyName = determineIdProperty(exchange);

    final JsonNode idProperty = node.remove(idPropertyName);
    if (idProperty == null) {
        exchange.setException(
            new SalesforceException("Missing option value for Id or " + SalesforceEndpointConfig.SOBJECT_EXT_ID_NAME, 404));

        return;
    }

    final String idValue = idProperty.textValue();
    if ("Id".equals(idPropertyName)) {
        in.setHeader(SalesforceEndpointConfig.SOBJECT_ID, idValue);
    } else {
        in.setHeader(SalesforceEndpointConfig.SOBJECT_EXT_ID_VALUE, idValue);
    }

    // base fields are not allowed to be updated
    clearBaseFields(node);

    // update input json
    in.setBody(MAPPER.writeValueAsString(node));
}
 
开发者ID:syndesisio,项目名称:syndesis,代码行数:36,代码来源:AdaptObjectForUpdateProcessor.java

示例5: clearBaseFields

import com.fasterxml.jackson.databind.node.ObjectNode; //导入方法依赖的package包/类
private static void clearBaseFields(final ObjectNode node) {
    node.remove("attributes");
    node.remove("Id");
    node.remove("IsDeleted");
    node.remove("CreatedDate");
    node.remove("CreatedById");
    node.remove("LastModifiedDate");
    node.remove("LastModifiedById");
    node.remove("SystemModstamp");
    node.remove("LastActivityDate");
}
 
开发者ID:syndesisio,项目名称:syndesis,代码行数:12,代码来源:AdaptObjectForUpdateProcessor.java

示例6: setLinks

import com.fasterxml.jackson.databind.node.ObjectNode; //导入方法依赖的package包/类
public void setLinks(LinksContainer container, LinksInformation linksInformation, QueryAdapter queryAdapter) {
	if (linksInformation != null) {
		container.setLinks((ObjectNode) objectMapper.valueToTree(linksInformation));
	}
	if (queryAdapter != null && queryAdapter.getCompactMode()) {
		ObjectNode links = container.getLinks();
		if (links != null) {
			links.remove("self");
			if (!links.fieldNames().hasNext()) {
				container.setLinks(null);
			}
		}

	}
}
 
开发者ID:crnk-project,项目名称:crnk-framework,代码行数:16,代码来源:DocumentMapperUtil.java

示例7: testChangeCollection

import com.fasterxml.jackson.databind.node.ObjectNode; //导入方法依赖的package包/类
@Test
public void testChangeCollection()
{
	ObjectNode workflow = Workflows.json("Change1 workflow");
	ObjectNode workflow2 = Workflows.json("Change2 workflow");
	ObjectNode task1 = Workflows.task(STEP1, "Step 1", false, RestTestConstants.USERID_MODERATOR1);
	ObjectNode task2 = Workflows.task(STEP2, "Step 2", false, RestTestConstants.USERID_MODERATOR2);
	Workflows.rootChild(workflow, task1);
	Workflows.rootChild(workflow2, task2);

	String workflowId = workflows.createId(workflow);
	String workflowId2 = workflows.createId(workflow2);

	ObjectNode collection = CollectionJson.json(context.getFullName("Change collection"), RestTestConstants.SCHEMA_BASIC,
		workflowId);
	collection = collections.create(collection);
	String collUuid = collections.getId(collection);

	String itemName = context.getFullName("Change item");
	ObjectNode item = items.create(Items.json(collUuid, "item/name", itemName), true);
	ItemId itemId = items.getId(item);

	collection.with("workflow").put("uuid", workflowId2);
	collections.editId(collection);

	ObjectNode moderation = items.moderation(itemId);
	Assert.assertNotNull(ItemStatusAssertions.findStatus(moderation, STEP2));

	mod2tasks.findTaskToModerate(itemId, context.getNamePrefix(), STEP2);
	collection.remove("workflow");
	collections.editId(collection);
	items.untilModeration(itemId, ItemStatusAssertions.statusIs("live"));
}
 
开发者ID:equella,项目名称:Equella,代码行数:34,代码来源:WorkflowApiEditTest.java

示例8: unsupportedVersionTest

import com.fasterxml.jackson.databind.node.ObjectNode; //导入方法依赖的package包/类
@Test(expected = java.lang.RuntimeException.class)
public void unsupportedVersionTest() throws Exception {
    final ObjectNode jsonObject = (ObjectNode) JsonUtil.keyShardSetToJson(keyShardSet);
    jsonObject.remove(JsonUtil.VERSION_NAME);
    jsonObject.put(JsonUtil.VERSION_NAME, "0");
    JsonUtil.jsonToKeyShardSet(jsonObject);
}
 
开发者ID:mgrand,项目名称:crypto-shuffle,代码行数:8,代码来源:JsonUtilTest.java

示例9: nullVersionTest

import com.fasterxml.jackson.databind.node.ObjectNode; //导入方法依赖的package包/类
@Test(expected = java.lang.RuntimeException.class)
public void nullVersionTest() throws Exception {
    final ObjectNode jsonObject = (ObjectNode) JsonUtil.keyShardSetToJson(keyShardSet);
    jsonObject.remove(JsonUtil.VERSION_NAME);
    jsonObject.replace(JsonUtil.VERSION_NAME, objectMapper.getNodeFactory().nullNode());
    JsonUtil.jsonToKeyShardSet(jsonObject);
}
 
开发者ID:mgrand,项目名称:crypto-shuffle,代码行数:8,代码来源:JsonUtilTest.java

示例10: apply

import com.fasterxml.jackson.databind.node.ObjectNode; //导入方法依赖的package包/类
/**
 * Applies this schema rule to take the required code generation steps.
 * <p>
 * A Java {@link Enum} is created, with constants for each of the enum
 * values present in the schema. The enum name is derived from the nodeName,
 * and the enum type itself is created as an inner class of the owning type.
 * In the rare case that no owning type exists (the enum is the root of the
 * schema), then the enum becomes a public class in its own right.
 * <p>
 * The actual JSON value for each enum constant is held in a property called
 * "value" in the generated type. A static factory method
 * <code>fromValue(String)</code> is added to the generated enum, and the
 * methods are annotated to allow Jackson to marshal/unmarshal values
 * correctly.
 *
 * @param nodeName
 *            the name of the property which is an "enum"
 * @param node
 *            the enum node
 * @param container
 *            the class container (class or package) to which this enum
 *            should be added
 * @return the newly generated Java type that was created to represent the
 *         given enum
 */
@Override
public JType apply(String nodeName, JsonNode node, JClassContainer container, Schema schema) {

    JDefinedClass _enum;
    try {
        _enum = createEnum(node, nodeName, container);
    } catch (ClassAlreadyExistsException e) {
        return e.getExistingClass();
    }

    schema.setJavaTypeIfEmpty(_enum);

    if (node.has("javaInterfaces")) {
        addInterfaces(_enum, node.get("javaInterfaces"));
    }

    // copy our node; remove the javaType as it will throw off the TypeRule for our case
    ObjectNode typeNode = (ObjectNode)node.deepCopy();
    typeNode.remove("javaType");

    // If type is specified on the enum, get a type rule for it.  Otherwise, we're a string.
    // (This is different from the default of Object, which is why we don't do this for every case.)
    JType backingType = node.has("type") ?
            ruleFactory.getTypeRule().apply(nodeName, typeNode, container, schema) :
                container.owner().ref(String.class);

            JFieldVar valueField = addValueField(_enum, backingType);

            // override toString only if we have a sensible string to return
            if(isString(backingType)){
                addToString(_enum, valueField);
            }

            addValueMethod(_enum, valueField);

            addEnumConstants(node.path("enum"), _enum, node.path("javaEnumNames"), backingType);
            addFactoryMethod(_enum, backingType);

            return _enum;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:66,代码来源:EnumRule.java

示例11: getService

import com.fasterxml.jackson.databind.node.ObjectNode; //导入方法依赖的package包/类
@RequestMapping ( value = "/service" , produces = MediaType.APPLICATION_JSON_VALUE , method = RequestMethod.GET )
public ObjectNode getService (
								@RequestParam ( "serviceName" ) String serviceName,
								@RequestParam ( "hostName" ) String hostName,
								@RequestParam ( value = "releasePackage" , required = false ) String releasePackage )
		throws IOException {

	logger.info( "serviceName: {}, hostName: {} ", serviceName, hostName );

	if ( serviceName.contains( "_" ) ) {
		serviceName = serviceName.split( "_" )[0];
	}

	csapApp.updateCache( true );

	ReleasePackage serviceModel = null;

	if ( releasePackage == null ) {
		serviceModel = csapApp.getModel( hostName, serviceName );
	} else {
		serviceModel = csapApp.getModel( releasePackage );
	}

	logger.info( "Found model: {}", serviceModel.getReleasePackageName() );

	// clone the root object because it is updated with property files for
	// UI
	ObjectNode serviceNode = (ObjectNode) jacksonMapper.readTree(
		serviceModel.getServiceDefinition( serviceName ).toString() );

	if ( serviceNode.has( ServiceAttributes.eolParameters.value ) ) {
		// rename to new naming conventins
		String parameters = serviceNode.get( ServiceAttributes.eolParameters.value ).asText();
		serviceNode.remove( ServiceAttributes.eolParameters.value );
		serviceNode.put( ServiceAttributes.parameters.value, parameters );
	}

	if ( serviceNode.has( ServiceAttributes.eolEnv.value ) ) {
		// rename to new naming conventins
		ObjectNode vars = (ObjectNode) serviceNode.get( ServiceAttributes.eolEnv.value );
		serviceNode.remove( ServiceAttributes.eolEnv.value );
		serviceNode.set( ServiceAttributes.environmentVariables.value, vars );
	}

	if ( !serviceNode.has( ServiceAttributes.description.value ) ) {

		serviceNode.put( ServiceAttributes.description.value,
			CsapUser.currentUsersID() + " added, and needs to update this description" );
	}

	addServicePropertyFiles( serviceNode, serviceName );

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

示例12: propertyNodeForComparisson

import com.fasterxml.jackson.databind.node.ObjectNode; //导入方法依赖的package包/类
private static ObjectNode propertyNodeForComparisson(final JsonNode propertyDefinition) {
    final ObjectNode propertyDefinitionForComparisson = propertyDefinition.deepCopy();
    propertyDefinitionForComparisson.remove(Arrays.asList("tags", "componentProperty"));
    return propertyDefinitionForComparisson;
}
 
开发者ID:syndesisio,项目名称:syndesis,代码行数:6,代码来源:DeploymentDescriptorIT.java

示例13: missingVersionTest

import com.fasterxml.jackson.databind.node.ObjectNode; //导入方法依赖的package包/类
@Test(expected = java.lang.RuntimeException.class)
public void missingVersionTest() throws Exception {
    final ObjectNode jsonObject = (ObjectNode) JsonUtil.keyShardSetToJson(keyShardSet);
    jsonObject.remove(JsonUtil.VERSION_NAME);
    JsonUtil.jsonToKeyShardSet(jsonObject);
}
 
开发者ID:mgrand,项目名称:crypto-shuffle,代码行数:7,代码来源:JsonUtilTest.java

示例14: missingAssymentricEncryptionAlgorithmTest

import com.fasterxml.jackson.databind.node.ObjectNode; //导入方法依赖的package包/类
@Test(expected = java.lang.RuntimeException.class)
public void missingAssymentricEncryptionAlgorithmTest() throws Exception {
    final ObjectNode jsonObject = (ObjectNode) JsonUtil.keyShardSetToJson(keyShardSet);
    jsonObject.remove(JsonUtil.ENCRYPTION_ALGORITHM_NAME);
    JsonUtil.jsonToKeyShardSet(jsonObject);
}
 
开发者ID:mgrand,项目名称:crypto-shuffle,代码行数:7,代码来源:JsonUtilTest.java

示例15: missingShardCountTest

import com.fasterxml.jackson.databind.node.ObjectNode; //导入方法依赖的package包/类
@Test(expected = java.lang.RuntimeException.class)
public void missingShardCountTest() throws Exception {
    final ObjectNode jsonObject = (ObjectNode) JsonUtil.keyShardSetToJson(keyShardSet);
    jsonObject.remove(JsonUtil.SHARD_COUNT_NAME);
    JsonUtil.jsonToKeyShardSet(jsonObject);
}
 
开发者ID:mgrand,项目名称:crypto-shuffle,代码行数:7,代码来源:JsonUtilTest.java


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