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

The following examples show how to use net.sf.jsqlparser.statement.select.FromItem. 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
private void addToSQLHolderMap(FromItem from) throws com.github.vincentrussell.query.mongodb.sql.converter.ParseException, ParseException {
	if (from instanceof Table) {
		Table table = (Table)from;
		fromToSQLHolder.put(table, new SQLTableInfoHolder(table.getName()));
   	}
   	else if(from instanceof SubSelect){
   		SubSelect subselect = (SubSelect) from; 
   		fromToSQLHolder.put(from, SQLCommandInfoHolder.Builder
                   .create(defaultFieldType, fieldNameToFieldTypeMapping)
                   .setPlainSelect((PlainSelect)subselect.getSelectBody())
                   .build());
   	}
   	else {//Not happen SubJoin, not supported previously
   		return;
   	}
}
 
Example 2
private void addBaseFrom(FromItem from, String alias) throws com.github.vincentrussell.query.mongodb.sql.converter.ParseException, ParseException {
	addBaseFrom(from);
	if(alias != null) {
		baseAlias = alias;
		aliasToTable.put(alias, from);
	}
	tableToAlias.put(from, alias);
}
 
Example 3
public void addFrom(FromItem from) throws com.github.vincentrussell.query.mongodb.sql.converter.ParseException, ParseException {
	if(baseFrom != null) {
		tableToAlias.put(from, null);
		addToSQLHolderMap(from);
	}
	else {
		addBaseFrom(from);
	}
}
 
Example 4
public void addFrom(FromItem from, String alias) throws com.github.vincentrussell.query.mongodb.sql.converter.ParseException, ParseException {
	if(baseFrom != null) {
		if(alias != null) {
			aliasToTable.put(alias, from);
		}
		tableToAlias.put(from, alias);
		addToSQLHolderMap(from);
	}
	else {
		addBaseFrom(from, alias);
	}
}
 
Example 5
Source Project: quetzal   Source File: CTEToNestedQueryConverter.java    License: Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void visit(SubJoin subjoin) {
	if (subjoin.getLeft()!=null) {
		subjoin.getLeft().accept(this);
		subjoin.setLeft(result);
	}
	if (subjoin.getJoin().getRightItem()!=null) {
		FromItem right = subjoin.getJoin().getRightItem();
		right.accept(this);
		subjoin.getJoin().setRightItem(result);
	}
	result = subjoin;
	
}
 
Example 6
Source Project: DataPermissionHelper   Source File: SelectVisitorImpl.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void visit(PlainSelect plainSelect) {

    // 访问 select
    if (plainSelect.getSelectItems() != null) {
        for (SelectItem item : plainSelect.getSelectItems()) {
            item.accept(new SelectItemVisitorImpl());
        }
    }

    // 访问from
    FromItem fromItem = plainSelect.getFromItem();
    FromItemVisitorImpl fromItemVisitorImpl = new FromItemVisitorImpl();
    fromItem.accept(fromItemVisitorImpl);

    if (fromItemVisitorImpl.getSubSelect() != null) {
        plainSelect.setFromItem(fromItemVisitorImpl.getSubSelect());
        if (!DPHelper.getChangeTable()) {
            DPHelper.setChangeTable(true);
        }
    }

    // 访问where
    if (plainSelect.getWhere() != null) {
        plainSelect.getWhere().accept(new ExpressionVisitorImpl());
    }

    // 访问join
    if (plainSelect.getJoins() != null) {
        for (Join join : plainSelect.getJoins()) {
            FromItemVisitorImpl fromItemVisitorImplTemp = new FromItemVisitorImpl();
            join.getRightItem().accept(fromItemVisitorImplTemp);
            if (fromItemVisitorImplTemp.getSubSelect() != null) {
                join.setRightItem(fromItemVisitorImplTemp.getSubSelect());
                if (!DPHelper.getChangeTable()) {
                    DPHelper.setChangeTable(true);
                }
            }
        }
    }

    // 访问 order by
    if (plainSelect.getOrderByElements() != null) {
        for (OrderByElement orderByElement : plainSelect
                .getOrderByElements()) {
            orderByElement.getExpression().accept(
                    new ExpressionVisitorImpl());
        }
    }

    // 访问group by having
    if (plainSelect.getHaving() != null) {
        plainSelect.getHaving().accept(new ExpressionVisitorImpl());
    }

}
 
Example 7
private void addBaseFrom(FromItem from) throws com.github.vincentrussell.query.mongodb.sql.converter.ParseException, ParseException {
	baseFrom = from;
	addToSQLHolderMap(from);
}
 
Example 8
public FromItem getBaseFrom() throws ParseException {
	return baseFrom;
}
 
Example 9
public SQLInfoHolder getSQLHolder(FromItem fitem) throws ParseException {
	return fromToSQLHolder.get(fitem);
}
 
Example 10
Source Project: quetzal   Source File: CTEToNestedQueryConverter.java    License: Eclipse Public License 2.0 4 votes vote down vote up
public FromItem getResult() {
	return result;
}