Package realcix20.guis.relationships

Examples of realcix20.guis.relationships.RelationManager$Relation


        } catch (Exception e) {
            e.printStackTrace();
        }
        Iterator pkColumnIter = object.getPkColumns().iterator();
        while (pkColumnIter.hasNext()) {
            Column pkColumn = (Column)pkColumnIter.next();
            if (pkColumn.getTableName().equals(mainTableName)) {
                Cell childPkOldCell = ObjectUtil.findOldCell(newRow, childTableName, pkColumn.getColumnName());

                //found
                if (childPkOldCell != null) {
                    Cell childPkNewCell = ObjectUtil.findNewCell(newRow, childTableName, pkColumn.getColumnName());
                    Cell mainPkNewCell = ObjectUtil.findNewCell(newRow, mainTableName, pkColumn.getColumnName());
                    childPkOldCell.setColumnValue(mainPkNewCell.getColumnValue());
                    childPkNewCell.setColumnValue(mainPkNewCell.getColumnValue());
                }
            }
        }
View Full Code Here


        return oldCell;
    }
       
    //���object,tableName,columnName����column��
    public static Column findColumn(BaseClass object, String tableName, String columnName) {
        Column rColumn = null;
        Iterator columnIter = object.getColumns().iterator();
        while (columnIter.hasNext()) {
            Column column = (Column)columnIter.next();
            if ( (column.getTableName().equals(tableName)) && (column.getColumnName().equals(columnName)) ) {
                rColumn = column;
                break;
            }
        }
        return rColumn;
View Full Code Here

       
        Iterator componentExtIter = componentExts.iterator();
        while (componentExtIter.hasNext()) {
           
            ComponentExt componentExt = (ComponentExt)componentExtIter.next();
            Column column = componentExt.getColumn();
            JComponent component = componentExt.getComponent();
           
            switch (column.getInputType()) {
               
                case 1:
                case 2:
                   
                    if ( (column.getPControls() == null) || (column.getPControls().equals("")) ) {
                       
                        DAO dao = DAO.getInstance();
                        dao.query(column.getInputPar());
                        ResultSet rs = dao.executeQuery();
                        try {

                            ResultSetMetaData rsmd = rs.getMetaData();
                            if (rsmd.getColumnCount() == 1) {
View Full Code Here

       
    }
   
    protected Column findColumn(String tableName, String columnName, Vector componentExts) {
       
        Column column = null;
       
        Iterator componentExtIter = componentExts.iterator();
        while (componentExtIter.hasNext()) {
            ComponentExt componentExt = (ComponentExt)componentExtIter.next();
            Column tempColumn = componentExt.getColumn();
            if ( (tempColumn.getTableName().equals(tableName)) && (tempColumn.getColumnName().equals(columnName)) ) {
                column = tempColumn;
                break;
            }
        }
       
View Full Code Here

        Row row = null;
       
        Iterator componentExtIter = componentExts.iterator();
        while (componentExtIter.hasNext()) {
            ComponentExt componentExt = (ComponentExt)componentExtIter.next();
            Column column = componentExt.getColumn();
            if ( (column.getTableName().equals(tableName)) && (column.getColumnName().equals(columnName)) ) {
                row = componentExt.getRow();
                break;
            }
        }
       
View Full Code Here

        JComponent component = null;
       
        Iterator componentExtIter = componentExts.iterator();
        while (componentExtIter.hasNext()) {
            ComponentExt componentExt = (ComponentExt)componentExtIter.next();
            Column column = componentExt.getColumn();
            if ( (column.getTableName().equals(tableName)) && (column.getColumnName().equals(columnName)) ) {
                component = componentExt.getComponent();
                break;
            }
        }
       
View Full Code Here

        JComponent childComponent = super.findComponent("BUD", "PAMOUNT", componentExts);
        super.contactRelationship1_11(component, childComponent);
       
        //initial BUD.CREATEDBY & BUD.LASTCHANGEDBY relationship
        JComponent component1 = super.findComponent("BUD", "CREATEDBY", componentExts);
        Column column1 = super.findColumn("BUD", "CREATEDBY", componentExts);
        JComponent component2 = super.findComponent("BUD", "LASTCHANGEDBY", componentExts);
        Column column2 = super.findColumn("BUD", "LASTCHANGEDBY", componentExts);
        super.initialComponent7Value(component1, column1.getColumnName(), column1.getInputPar(), null);
        super.initialComponent7Value(component2, column2.getColumnName(), column2.getInputPar(), null);
        super.contactRelationship7_7(component1, component2);
        super.contactRelationship7_7(component2, component1);
                   
    }
View Full Code Here

    private void initialItemRelationship() {
       
        //initial BUDM.LCURR & BUD.PLCURR relationship
        JComponent component = super.findComponent("BUD", "PLCURR", componentExts);
        JComponent childComponent = super.findComponent("BUDM", "LCURR", componentExts);
        Column column = super.findColumn("BUDM", "LCURR", componentExts);       
        String sql = column.getInputPar();
        String str = "[BUD.PLCURR]";
        if (sql.indexOf(str) != -1) {
            StringBuffer sb = new StringBuffer(sql);
            sb.replace(sql.indexOf(str), sql.indexOf(str) + str.length(), "?");
            sql = sb.toString();
View Full Code Here

       
        sb.append("SELECT ");
       
        for (int i = 0; i < cdModel.getRowCount(); i++) {
           
            Column column = (Column)cdModel.getValueAt(i, 0);
            if ( (cdModel.getValueAt(i, 1) == null) && (cdModel.getValueAt(i, 2) == null) ) {
                sb.append(column.getTableName() + "." + column.getColumnName() + ",");
            } else if (cdModel.getValueAt(i, 1) != null) {
                Boolean isCount = (Boolean)cdModel.getValueAt(i, 1);
                if (isCount)
                    sb.append("COUNT(" + column.getTableName() + "." + column.getColumnName() + ") AS COUNT_" +
                            column.getTableName() + "_" + column.getColumnName() + ",");
                else {
                    sb.append(column.getTableName() + "." + column.getColumnName() + ",");
                }
            } else if (cdModel.getValueAt(i, 2) != null) {
                Boolean isSum = (Boolean)cdModel.getValueAt(i, 2);
                if (isSum)
                    sb.append("SUM(" + column.getTableName() + "." + column.getColumnName() + ") AS SUM_" +
                            column.getTableName() + "_" + column.getColumnName() + ",");
                else {
                    sb.append(column.getTableName() + "." + column.getColumnName() + ",");
                }
            }
           
        }
        sb.replace(sb.length() - 1, sb.length(), " ");
       
        BaseClass object = container.getObject();
        String basicSQL = object.getBasicSQL();       
        if (basicSQL.indexOf("WHERE") == -1)
            basicSQL = basicSQL.substring(basicSQL.indexOf("FROM"));
        else {
            basicSQL = basicSQL.substring(basicSQL.indexOf("FROM"), basicSQL.indexOf("WHERE"));
        }
        sb.append(basicSQL + " ");
       
        boolean hasWhere = false;
        basicSQL = object.getBasicSQL();
        if (basicSQL.indexOf("WHERE") == -1)
            sb.append("WHERE ");
        else {
            hasWhere = true;
            basicSQL = basicSQL.substring(basicSQL.indexOf("WHERE"));
            sb.append(basicSQL + " AND ");
        }
       
        Vector filters = new Vector();
        Vector andors = new Vector();
        for (int i = 0; i < caModel.getRowCount(); i++) {
           
            if ( (caModel.getValueAt(i, 2) != null) && (!caModel.getValueAt(i, 2).toString().trim().equals("")) ) {
                hasWhere = true;
                String andorString = (String)caModel.getValueAt(i, 0);
                boolean andor = (andorString.equals("AND"));
                andors.add(andor);
                Column column = (Column)caModel.getValueAt(i, 1);
                String filterString = (String)caModel.getValueAt(i, 2);
                filterString = filterString.replaceAll("~", column.getTableName() + "." + column.getColumnName());
                filters.add(filterString);
            }
           
        }
       
        if (hasWhere) {
            //first, add and wheres
            for (int i = 0; i < filters.size(); i++) {
                Boolean andor = (Boolean)andors.get(i);
                if (andor) {
                    String filterString = (String)filters.get(i);
                    sb.append(filterString + " AND ");
                }
            }
            //next, add or wheres
            for (int i = 0; i < filters.size(); i++) {
                Boolean andor = (Boolean)andors.get(i);
                if (!andor) {
                    String filterString = (String)filters.get(i);
                    sb.append(filterString + " OR  ");
                }
            }
        }       
        if (!hasWhere)
            sb.replace(sb.lastIndexOf("WHERE"), sb.lastIndexOf("WHERE") + 5, "");
        else
            sb.replace(sb.length() - 4, sb.length() - 1, "");               
       
        boolean hasGroup = true;
        boolean hasCountOrSum = false;
        for (int i = 0; i < cdModel.getRowCount(); i++) {
           
            if ( (cdModel.getValueAt(i, 1) == null) && (cdModel.getValueAt(i, 2) == null) ) {
            } else if (cdModel.getValueAt(i, 1) != null) {               
                Boolean isCount = (Boolean)cdModel.getValueAt(i, 1);
                if (isCount)
                    hasCountOrSum = true;
            } else if (cdModel.getValueAt(i, 2) != null) {               
                Boolean isSum = (Boolean)cdModel.getValueAt(i, 2);
                if (isSum)
                    hasCountOrSum = true;
            }
           
        }
       
        if (!hasCountOrSum)
            hasGroup = false;
       
        if (hasGroup) {
           
            sb.append("GROUP BY ");
           
            for (int i = 0 ; i < cdModel.getRowCount(); i++) {
               
                Column column = (Column)cdModel.getValueAt(i, 0);
               
                if ( (cdModel.getValueAt(i, 1) == null) && (cdModel.getValueAt(i, 2) == null) ) {
                    sb.append(column.getTableName() + "." + column.getColumnName() + ",");
                } else if (cdModel.getValueAt(i, 1) != null) {
                    Boolean isCount = (Boolean)cdModel.getValueAt(i, 1);
                    if (!isCount)
                        sb.append(column.getTableName() + "." + column.getColumnName() + ",");
                } else if (cdModel.getValueAt(i, 2) != null) {
                    Boolean isSum = (Boolean)cdModel.getValueAt(i, 2);
                    if (!isSum)
                        sb.append(column.getTableName() + "." + column.getColumnName() + ",");
                }
               
            }
           
            sb.replace(sb.length() - 1, sb.length(), " ");
           
        }
       
        boolean hasOrder = false;
        if (coModel.getRowCount() > 0)
            hasOrder = true;
       
        if (hasOrder) {
           
            sb.append("ORDER BY ");
           
            for (int i = 0; i < coModel.getRowCount(); i++) {
               
                Column column = (Column)coModel.getValueAt(i, 0);
                Boolean order = false;
                if (coModel.getValueAt(i, 1) != null)
                    order = (Boolean)coModel.getValueAt(i, 1);
               
                String orderString = "DESC";
                if (order)
                    orderString = "ASC";
               
                int tempRow = findRow(column, container.getColumnDisplayTable());
               
                if ( (cdModel.getValueAt(tempRow, 1) == null) && (cdModel.getValueAt(tempRow, 2) == null) ) {
                    sb.append(column.getTableName() + "." + column.getColumnName() + " " + orderString + ",");
                } else if (cdModel.getValueAt(tempRow, 1) != null) {
                    Boolean isCount = (Boolean)cdModel.getValueAt(tempRow, 1);
                    if (isCount)
                        sb.append("COUNT(" + column.getTableName() + "." + column.getColumnName() + ") " + orderString + ",");
                    else {
                        sb.append(column.getTableName() + "." + column.getColumnName() + " " + orderString + ",");
                        hasGroup = true;
                    }
                } else if (cdModel.getValueAt(tempRow, 2) != null) {
                    Boolean isSum = (Boolean)cdModel.getValueAt(tempRow, 2);
                    if (isSum)
                        sb.append("SUM(" + column.getTableName() + "." + column.getColumnName() + ") " + orderString + ",");
                    else {
                        sb.append(column.getTableName() + "." + column.getColumnName() + " " + orderString + ",");
                        hasGroup = true;
                    }
                }
               
            }
View Full Code Here

            dao.executeUpdate();
           
            //addDisplayColumns
            for (int i = 0; i < cdModel.getRowCount(); i++) {
               
                Column column = (Column)cdModel.getValueAt(i, 0);
               
                dao.update(Resources.INSERT_CLFIELDS_SQL);
                dao.setInt(1, clsId);
                dao.setInt(2, layout);
                dao.setString(3, column.getTableName());
                dao.setString(4, column.getColumnName());
                dao.setInt(5, i + 1);
                dao.setObject(6, cdModel.getValueAt(i, 2));
                dao.setObject(7, cdModel.getValueAt(i, 1));
               
                int tempRow = findRow(column, container.getColumnAllTable());
                String andorString = (String)caModel.getValueAt(tempRow, 0);
                if (andorString.equals("AND"))
                    dao.setObject(8, true);
                else
                    dao.setObject(8,false);
                dao.setObject(9, caModel.getValueAt(tempRow, 2));
               
                tempRow = findRow(column, container.getColumnOrderTable());
                if (tempRow == -1)
                    dao.setObject(10, null);
                else
                    dao.setInt(10, tempRow + 1);
               
                if (tempRow == -1)
                    dao.setObject(11, null);
                else
                    dao.setObject(11, coModel.getValueAt(tempRow, 1));
               
                flag = dao.executeUpdate();
               
                if (!flag) {
                    dao.rollback();
                    dao.setAutoCommit(true);
                    return false;
                }
               
            }
            //addFilterColumns
            for (int i = 0; i < caModel.getRowCount(); i++) {
                Column column = (Column)caModel.getValueAt(i, 1);
                String filterString = (String)caModel.getValueAt(i, 2);
                if ( (filterString != null) && (filterString.trim().length() > 0) ) {                
                    dao.query(Resources.SELECT_CLFIELDS_BY_CLSID_AND_LAYOUT_AND_TABLENAME_AND_COLUMNNAME);
                    dao.setObject(1, clsId);
                    dao.setObject(2, layout);
                    dao.setObject(3, column.getTableName());
                    dao.setObject(4, column.getColumnName());
                    ResultSet rs = dao.executeQuery();
                    boolean displayed = false;
                    try {
                        if (rs.next()) {
                            displayed = true;
                        }
                        rs.close();
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                    if (!displayed) {
                        dao.update(Resources.INSERT_CLFIELDS_SQL);
                        dao.setInt(1, clsId);
                        dao.setInt(2, layout);
                        dao.setString(3, column.getTableName());
                        dao.setString(4, column.getColumnName());
                        dao.setInt(5, 0);
                        dao.setObject(6, null);
                        dao.setObject(7, null);
                        int tempRow = findRow(column, container.getColumnAllTable());
                        String andorString = (String)caModel.getValueAt(tempRow, 0);
View Full Code Here

TOP

Related Classes of realcix20.guis.relationships.RelationManager$Relation

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.