Package org.apache.empire.db.expr.compare

Examples of org.apache.empire.db.expr.compare.DBCompareExpr


            if (record.isNew()==false)
            {   // add restriction
                if (keyColumns.length>1)
                {   // Multiple key columns
                    Object value = record.getValue(keyColumns[0]);
                    DBCompareExpr notExpr = keyColumns[0].is(value);
                    for (int i=1; i<keyColumns.length; i++)
                    {   // Check if column has changed
                        cmd.where(keyColumns[i].is(value));
                    }
                    cmd.where(notExpr.not());
                }
                else
                {   // Single key column
                    Object value = record.getValue(keyColumns[0]);
                    cmd.where(keyColumns[0].isNot(value));
View Full Code Here


                        throw new ItemNotFoundException(right.getFullName());
            }
            // Evaluate Existing restrictions
            for (i = 0; cmd.where != null && i < cmd.where.size(); i++)
            {
                DBCompareExpr cmp = cmd.where.get(i);
                if (cmp instanceof DBCompareColExpr)
                {   // Check whether constraint belongs to update table
                    DBCompareColExpr cmpExpr = (DBCompareColExpr) cmp;
                    DBColumn col = cmpExpr.getColumnExpr().getUpdateColumn();
                    if (col!=null && col.getRowSet() == table)
                    {  // add the constraint
                      if (cmpExpr.getValue() instanceof DBCmdParam)
                      {  // Create a new command param
                        DBColumnExpr colExpr = cmpExpr.getColumnExpr();
                        DBCmdParam param =(DBCmdParam)cmpExpr.getValue();
                        DBCmdParam value = upd.addParam(colExpr, param.getValue());
                        cmp = new DBCompareColExpr(colExpr, cmpExpr.getCmpop(), value);
                      }
                        upd.where(cmp);
                    }   
                }
                else
                // other constraints are not supported
                    throw new NotSupportedException(this, "updateRecord with "+cmp.getClass().getName());
                }
            }
            // Add Restrictions
            for (i = 0; i < keyColumns.length; i++)
            {
View Full Code Here

     */
    protected void setConstraint(List<DBCompareExpr> list, DBCompareExpr expr)
    { // adds a comparison to the where or having list
        for (int i = 0; i < list.size(); i++)
        { // check expression
          DBCompareExpr other = list.get(i);
            if (expr.isMutuallyExclusive(other)==false)
                continue;
            // Check if we replace a DBCommandParam
            if (other instanceof DBCompareColExpr)
              removeCommandParam((DBCompareColExpr)other);
View Full Code Here

    public List<Employee> searchEmmployee(Integer id, String firstName, String lastName, Integer department)
    {
        DBCommand cmd = db.createCommand();
        cmd.select(T_EMP.getColumns());

        DBCompareExpr comp;

        if (id != null)
            comp = T_EMP.EMPLOYEE_ID.is(id);
        else
            comp = T_EMP.EMPLOYEE_ID.isNot(null);

        if (firstName != null && !firstName.equals(""))
        {
            comp = comp.and(T_EMP.FIRSTNAME.like(firstName));
        }

        if (lastName != null && !lastName.equals(""))
        {
            comp = comp.and(T_EMP.LASTNAME.like(lastName));
        }

        if (department != null)
        {
            comp = comp.and(T_EMP.DEPARTMENT_ID.is(department));
        }

        cmd.where(comp);

        DBReader reader = new DBReader();
View Full Code Here

            if (record.isNew()==false)
            {   // add restriction
                if (keyColumns.length>1)
                {   // Multiple key columns
                    Object value = record.getValue(keyColumns[0]);
                    DBCompareExpr notExpr = keyColumns[0].is(value);
                    for (int i=1; i<keyColumns.length; i++)
                    {   // Check if column has changed
                        cmd.where(keyColumns[i].is(value));
                    }
                    cmd.where(notExpr.not());
                }
                else
                {   // Single key column
                    Object value = record.getValue(keyColumns[0]);
                    cmd.where(keyColumns[0].isNot(value));
View Full Code Here

     */
    protected void setConstraint(List<DBCompareExpr> list, DBCompareExpr expr)
    { // adds a comparison to the where or having list
        for (int i = 0; i < list.size(); i++)
        { // check expression
          DBCompareExpr other = list.get(i);
            if (expr.isMutuallyExclusive(other)==false)
                continue;
            // columns match
            list.set(i, expr);
            return;
View Full Code Here

                        return error(Errors.ItemNotFound, right.getFullName());
            }
            // Evaluate Existing restrictions
            for (i = 0; cmd.where != null && i < cmd.where.size(); i++)
            {
                DBCompareExpr cmp = cmd.where.get(i);
                if (cmp instanceof DBCompareColExpr)
                { // Check whether
                    DBCompareColExpr cmpExpr = (DBCompareColExpr) cmp;
                    DBColumn col = cmpExpr.getColumnExpr().getUpdateColumn();
                    if (col!=null && col.getRowSet() == table)
View Full Code Here

                        throw new ItemNotFoundException(right.getFullName());
            }
            // Evaluate Existing restrictions
            for (i = 0; cmd.where != null && i < cmd.where.size(); i++)
            {
                DBCompareExpr cmp = cmd.where.get(i);
                if (cmp instanceof DBCompareColExpr)
                {   // Check whether constraint belongs to update table
                    DBCompareColExpr cmpExpr = (DBCompareColExpr) cmp;
                    DBColumn col = cmpExpr.getColumnExpr().getUpdateColumn();
                    if (col!=null && col.getRowSet() == table)
                    {  // add the constraint
                      if (cmpExpr.getValue() instanceof DBCmdParam)
                      {  // Create a new command param
                        DBColumnExpr colExpr = cmpExpr.getColumnExpr();
                        DBCmdParam param =(DBCmdParam)cmpExpr.getValue();
                        DBCmdParam value = upd.addParam(colExpr, param.getValue());
                        cmp = new DBCompareColExpr(colExpr, cmpExpr.getCmpop(), value);
                      }
                        upd.where(cmp);
                    }   
                }
                else
                // other constraints are not supported
                    throw new NotSupportedException(this, "updateRecord with "+cmp.getClass().getName());
                }
            }
            // Add Restrictions
            for (i = 0; i < keyColumns.length; i++)
            {
View Full Code Here

                        return error(Errors.ItemNotFound, right.getFullName());
            }
            // Evaluate Existing restrictions
            for (i = 0; cmd.where != null && i < cmd.where.size(); i++)
            {
                DBCompareExpr cmp = cmd.where.get(i);
                if (cmp instanceof DBCompareColExpr)
                {   // Check whether constraint belongs to update table
                    DBCompareColExpr cmpExpr = (DBCompareColExpr) cmp;
                    DBColumn col = cmpExpr.getColumnExpr().getUpdateColumn();
                    if (col!=null && col.getRowSet() == table)
View Full Code Here

            if (record.isNew()==false)
            {   // add restriction
                if (keyColumns.length>1)
                {   // Multiple key columns
                    Object value = record.getValue(keyColumns[0]);
                    DBCompareExpr notExpr = keyColumns[0].is(value);
                    for (int i=1; i<keyColumns.length; i++)
                    {   // Check if column has changed
                        cmd.where(keyColumns[i].is(value));
                    }
                    cmd.where(notExpr.not());
                }
                else
                {   // Single key column
                    Object value = record.getValue(keyColumns[0]);
                    cmd.where(keyColumns[0].isNot(value));
View Full Code Here

TOP

Related Classes of org.apache.empire.db.expr.compare.DBCompareExpr

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.