iot.jcypher.query.factories.clause.ON_MATCH Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jcypher Show documentation
Show all versions of jcypher Show documentation
Provides seamlessly integrated Java access to graph databases (Neo4J)
at different levels of abstraction.
/************************************************************************
* Copyright (c) 2015 IoT-Solutions e.U.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
************************************************************************/
package iot.jcypher.query.factories.clause;
import iot.jcypher.query.api.APIObjectAccess;
import iot.jcypher.query.api.modify.CopyProperties;
import iot.jcypher.query.api.modify.ModifyFactory;
import iot.jcypher.query.api.modify.ModifyTerminal;
import iot.jcypher.query.api.modify.Set;
import iot.jcypher.query.ast.ASTNode;
import iot.jcypher.query.ast.ClauseType;
import iot.jcypher.query.values.JcElement;
import iot.jcypher.query.values.JcLabel;
import iot.jcypher.query.values.JcNode;
import iot.jcypher.query.values.JcProperty;
/**
* JCYPHER CLAUSE
*/
public class ON_MATCH {
/**
* JCYPHER
* set a property of a node or relation in an ON_MATCH clause
* e.g. ...SET(n.property("age")).to(20)...
*
*/
public static Set SET(JcProperty property) {
Set ret = ModifyFactory.setPropertyInDO(property);
ASTNode an = APIObjectAccess.getAstNode(ret);
an.setClauseType(ClauseType.ON_MATCH_SET);
return ret;
}
/**
* JCYPHER
* set a label of a node in an ON_MATCH clause
* e.g. ...SET(n.label("Person"))
*
*/
public static ModifyTerminal SET(JcLabel label) {
ModifyTerminal ret = ModifyFactory.setLabel(label);
ASTNode an = APIObjectAccess.getAstNode(ret);
an.setClauseType(ClauseType.ON_MATCH_SET);
return ret;
}
/**
* JCYPHER
* select a node or relation to be the source for copying all properties
* e.g. ...copyPropertiesFrom(n).to(m)
*
*/
public static CopyProperties copyPropertiesFrom(JcElement source) {
CopyProperties ret = ModifyFactory.copyPropertiesFromInDO(source);
ASTNode an = APIObjectAccess.getAstNode(ret);
an.setClauseType(ClauseType.ON_MATCH_SET);
return ret;
}
/**
* JCYPHER
* delete a graph element in an ON_MATCH clause
* e.g. ...DELETE(n)
*
*/
public static ModifyTerminal DELETE(JcElement element) {
ModifyTerminal ret = ModifyFactory.deleteElement(element);
ASTNode an = APIObjectAccess.getAstNode(ret);
an.setClauseType(ClauseType.ON_MATCH_DELETE);
return ret;
}
/**
* JCYPHER
* detach all relations and then delete a node in an ON_MATCH clause
* e.g. ...DETACH_DELETE(n)
*
*/
public static ModifyTerminal DETACH_DELETE(JcNode node) {
ModifyTerminal ret = ModifyFactory.deleteElement(node);
ASTNode an = APIObjectAccess.getAstNode(ret);
an.setClauseType(ClauseType.ON_MATCH_DETACH_DELETE);
return ret;
}
/**
* JCYPHER
* remove a property from a node or relation in an ON_MATCH clause
* e.g. ...REMOVE(n.property("age"))
*
*/
public static ModifyTerminal REMOVE(JcProperty property) {
ModifyTerminal ret = ModifyFactory.removeProperty(property);
ASTNode an = APIObjectAccess.getAstNode(ret);
an.setClauseType(ClauseType.ON_MATCH_REMOVE);
return ret;
}
/**
* JCYPHER
* remove a label from a node in an ON_MATCH clause
* e.g. ...REMOVE(n.label("Person"))
*
*/
public static ModifyTerminal REMOVE(JcLabel label) {
ModifyTerminal ret = ModifyFactory.removeLabel(label);
ASTNode an = APIObjectAccess.getAstNode(ret);
an.setClauseType(ClauseType.ON_MATCH_REMOVE);
return ret;
}
}