Java Code Examples for net.sf.jsqlparser.statement.select.SetOperationList

The following examples show how to use net.sf.jsqlparser.statement.select.SetOperationList. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: DataPermissionHelper   Source File: SelectVisitorImpl.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void visit(SetOperationList setOpList) {
    for (SelectBody plainSelect : setOpList.getSelects()) {
        plainSelect.accept(new SelectVisitorImpl());
    }
}
 
Example 2
Source Project: dynamic-add-date   Source File: AddDateInterceptor.java    License: MIT License 4 votes vote down vote up
@Override
public void visit(SetOperationList setOperationList) {
    throw new UnsupportedOperationException("Not supported yet.");
}
 
Example 3
Source Project: quetzal   Source File: CTEToNestedQueryConverter.java    License: Eclipse Public License 2.0 4 votes vote down vote up
public SetOperationListNoParenthesisWrapper(SetOperationList setOp) {
	super();
	this.setOp = setOp;
}
 
Example 4
Source Project: quetzal   Source File: CTEToNestedQueryConverter.java    License: Eclipse Public License 2.0 4 votes vote down vote up
@Override
public void visit(SetOperationList setOpList) {
	if (transformEXCEPT && setOpList.getOperations().size()>0 && setOpList.getOperations().get(0).toString().equals(SetOperationList.SetOperationType.EXCEPT.name())) {
		assert setOpList.getPlainSelects().size() == 2 : setOpList;
		PlainSelect left = setOpList.getPlainSelects().get(0);
		PlainSelect right = setOpList.getPlainSelects().get(1);
		Join join = new Join();
		join.setLeft(true);
		join.setOuter(true);
		FromItem rightFrom = right.getFromItem();
		assert rightFrom instanceof Table;
		Table  rightTable = (Table) rightFrom;
		join.setRightItem(rightTable);
		FromItem leftFrom = left.getFromItem();
		assert leftFrom instanceof Table;
		Table leftTable = (Table) leftFrom;
		Expression onExp = null;
		Expression whereExp = null;
		for (int i=0;i<Math.min(left.getSelectItems().size(), right.getSelectItems().size());i++) {
			Expression rightExp = getExpression(right.getSelectItems().get(i), rightTable);
			Expression leftExp = getExpression(left.getSelectItems().get(i), leftTable);
			if (!leftExp.toString().equals(rightExp.toString())) {
				EqualsTo leftEqRight = new EqualsTo();
				leftEqRight.setLeftExpression(leftExp);
				leftEqRight.setRightExpression(rightExp);
				if (onExp ==  null) {
					onExp = leftEqRight;
				} else {
					onExp = new AndExpression(onExp, leftEqRight);
				}
			}
			if (!rightExp.toString().equals(new NullValue().toString())) {
				IsNullExpression rightEqNull = new IsNullExpression();
				rightEqNull.setLeftExpression(rightExp);
				rightEqNull.setNot(false);
				if (whereExp == null) {
					whereExp = rightEqNull;
				} else {
					whereExp = new AndExpression(whereExp,rightEqNull);
				}
			}
		}
		join.setOnExpression(onExp);
		if (whereExp!=null) {
			if (left.getWhere()!=null) {
				whereExp = new AndExpression(left.getWhere(), whereExp);
			}
			left.setWhere(whereExp);
		}
		if (left.getJoins() ==null) {
			List<Join> js = new LinkedList<Join>();
			js.add(join);
			left.setJoins(js);
		} else {
			left.getJoins().add(join);
		}
		setOpList.getPlainSelects().remove(1);
		setOpList.getOperations().clear();
		setOpList.accept(this);
		
	} else {
		if (setOpList.getPlainSelects()!=null) {
			for (PlainSelect plainSelect : setOpList.getPlainSelects()) {
				plainSelect.accept(this);
			}
		}
	}
}