All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.sap.cds.impl.parser.DeleteParser Maven / Gradle / Ivy

There is a newer version: 3.6.1
Show newest version
/*******************************************************************
 * © 2019 SAP SE or an SAP affiliate company. All rights reserved. *
 *******************************************************************/
package com.sap.cds.impl.parser;

import com.fasterxml.jackson.databind.JsonNode;
import com.jayway.jsonpath.DocumentContext;
import com.sap.cds.ql.Delete;
import com.sap.cds.ql.StructuredType;
import com.sap.cds.ql.cqn.CqnPredicate;
import com.sap.cds.ql.cqn.CqnStructuredTypeRef;
import com.sap.cds.ql.impl.DeleteBuilder;

public class DeleteParser extends CqnParser {

	private DeleteParser(DocumentContext cqn) {
		super(cqn);
	}

	public static DeleteParser of(String cqn) {
		return new DeleteParser(getDocumentContext(cqn));
	}

	public static Delete> parse(String cqn) {
		return of(cqn).parse();
	}

	public Delete> parse() {
		CqnStructuredTypeRef ref = TokenParser.ref(cqn.read("$.DELETE.from"));
		return DeleteBuilder.from(ref).where(where());
	}

	private CqnPredicate where() {
		JsonNode where = cqn.read("$.DELETE.where");
		return ExpressionParser.parsePredicate(where);
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy