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

The following examples show how to use net.sf.jsqlparser.statement.select.SetOperationList. 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 File: SelectVisitorImpl.java    From DataPermissionHelper with 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 File: AddDateInterceptor.java    From dynamic-add-date with MIT License 4 votes vote down vote up
@Override
public void visit(SetOperationList setOperationList) {
    throw new UnsupportedOperationException("Not supported yet.");
}
 
Example #3
Source File: CTEToNestedQueryConverter.java    From quetzal with Eclipse Public License 2.0 4 votes vote down vote up
public SetOperationListNoParenthesisWrapper(SetOperationList setOp) {
	super();
	this.setOp = setOp;
}
 
Example #4
Source File: CTEToNestedQueryConverter.java    From quetzal with 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);
			}
		}
	}
}