Examples of DynaBean


Examples of org.apache.commons.beanutils.DynaBean

                                                                                          "SELECT Id1, Avalue FROM TestTable1, TestTable2 WHERE Id2 = Id",
                                                                                          new Table[] { getModel().getTable(0), getModel().getTable(1) });

        assertTrue(it.hasNext());

        DynaBean bean = (DynaBean)it.next();

        assertEquals(new Integer(2),
                     getPropertyValue(bean, "Id1"));
        assertEquals("Text 3",
                     getPropertyValue(bean, "Avalue"));
View Full Code Here

Examples of org.apache.commons.beanutils.DynaBean

    {
        Database         database = parseDatabaseFromString(TESTED_MODEL);
        PlatformImplBase platform = new TestPlatform();
        Table            table    = database.getTable(0);
        SqlDynaClass     clz      = SqlDynaClass.newInstance(table);
        DynaBean         db       = new SqlDynaBean(SqlDynaClass.newInstance(table));

        db.set("name", "name");

        Map map = platform.toColumnValues(clz.getSqlDynaProperties(), db);

        assertEquals("name",
                     map.get("name"));
View Full Code Here

Examples of org.apache.commons.beanutils.DynaBean

     */
    public void write(Iterator beans) throws DataWriterException
    {
        while (beans.hasNext())
        {
            DynaBean bean = (DynaBean)beans.next();

            if (bean instanceof SqlDynaBean)
            {
                write((SqlDynaBean)bean);
            }
            else
            {
                _log.warn("Cannot write normal dyna beans (type: "+bean.getDynaClass().getName()+")");
            }
        }
    }
View Full Code Here

Examples of org.apache.commons.beanutils.DynaBean

                        finishedObjs.add(waitingObj.getObject());
                    }
                }
                for (Iterator finishedObjIt = finishedObjs.iterator(); finishedObjIt.hasNext();)
                {
                    DynaBean finishedObj = (DynaBean)finishedObjIt.next();
                    Table    tableForObj = _model.getDynaClassFor(finishedObj).getTable();
                    Identity objIdentity = buildIdentityFromPKs(tableForObj, finishedObj);

                    insertBeanIntoDatabase(tableForObj, finishedObj);
                   
View Full Code Here

Examples of org.apache.commons.beanutils.DynaBean

     * @return A new dyna bean bound to the given table and containing all the properties from
     *         the source object
     */
    public DynaBean copy(Table table, Object source) throws SqlDynaException
    {
        DynaBean answer = createNewInstance(table);

        try
        {
            // copy all the properties from the source
            BeanUtils.copyProperties(answer, source);
View Full Code Here

Examples of org.apache.commons.beanutils.DynaBean

        }
        else
        {
            try
            {
                DynaBean bean  = _dynaClass.newInstance();
                Table    table = null;

                if (bean instanceof SqlDynaBean)
                {
                    SqlDynaClass dynaClass = (SqlDynaClass)((SqlDynaBean)bean).getDynaClass();

                    table = dynaClass.getTable();
                }

                for (Iterator it = _columnsToProperties.entrySet().iterator(); it.hasNext();)
                {
                    Map.Entry entry      = (Map.Entry)it.next();
                    String    columnName = (String)entry.getKey();
                    String    propName   = (String)entry.getValue();
                    Table     curTable   = table;

                    if (curTable == null)
                    {
                        curTable = (Table)_preparedQueryHints.get(_caseSensitive ? columnName : columnName.toLowerCase());
                    }

                    Object value = _platform.getObjectFromResultSet(_resultSet, columnName, curTable);

                    bean.set(propName, value);
                }
                _needsAdvancing = true;
                return bean;
            }
            catch (Exception ex)
View Full Code Here

Examples of org.apache.commons.beanutils.DynaBean

    /**
     * {@inheritDoc}
     */
    public void end(String namespace, String name) throws Exception
    {
        DynaBean top = (DynaBean)digester.pop();

        if (digester.getLogger().isDebugEnabled())
        {
            digester.getLogger().debug("[DynaSqlCreateRule]{" + digester.getMatch() + "} Pop " + top.getDynaClass().getName());
        }
        _receiver.addBean(top);
    }
View Full Code Here

Examples of org.apache.commons.beanutils.DynaBean

            Table    table  = model.getTable(idx);
            Column[] pkCols = table.getPrimaryKeyColumns();

            for (Iterator it = origDbPlatform.query(model, buildQueryString(origDbPlatform, table, null, null), new Table[] { table }); it.hasNext();)
            {
                DynaBean   obj    = (DynaBean)it.next();
                Collection result = testedDbPlatform.fetch(model, buildQueryString(origDbPlatform, table, pkCols, obj), new Table[] { table });

                if (result.isEmpty())
                {
                    if (_log.isDebugEnabled())
                    {
                        hasError = true;
                        _log.debug("Row "+obj.toString()+" is not present in second database");
                    }
                    else
                    {
                        throw new AssertionFailedError(failureMsg);
                    }
                }
                else if (result.size() > 1)
                {
                    if (_log.isDebugEnabled())
                    {
                        hasError = true;

                        StringBuffer debugMsg = new StringBuffer();

                        debugMsg.append("Row ");
                        debugMsg.append(obj.toString());
                        debugMsg.append(" is present more than once in the second database:\n");
                        for (Iterator resultIt = result.iterator(); resultIt.hasNext();)
                        {
                            debugMsg.append("  ");
                            debugMsg.append(resultIt.next().toString());
                        }
                        _log.debug(debugMsg.toString());
                    }
                    else
                    {
                        throw new AssertionFailedError(failureMsg);
                    }
                }
                else
                {
                    DynaBean otherObj = (DynaBean)result.iterator().next();

                    if (!obj.equals(otherObj))
                    {
                        if (_log.isDebugEnabled())
                        {
                            hasError = true;
   
                            _log.debug("Row "+obj.toString()+" is different in the second database: "+otherObj.toString());
                        }
                        else
                        {
                            throw new AssertionFailedError(failureMsg);
                        }
View Full Code Here

Examples of org.apache.commons.beanutils.DynaBean

        int               addedStmts             = 0;
        boolean           identityWarningPrinted = false;

        for (Iterator it = dynaBeans.iterator(); it.hasNext();)
        {
            DynaBean     dynaBean     = (DynaBean)it.next();
            SqlDynaClass curDynaClass = model.getDynaClassFor(dynaBean);

            if (curDynaClass != dynaClass)
            {
                if (dynaClass != null)
View Full Code Here

Examples of org.apache.commons.beanutils.DynaBean

        assertEquals(getAdjustedModel(),
                     readModelFromDatabase("roundtriptest"));

        List     beans = getRows("roundtrip");
        DynaBean bean  = (DynaBean)beans.get(0);

        // Some databases (e.g. DB2) pad the string for some reason, so we manually trim it
        if (bean.get("avalue") instanceof String)
        {
            bean.set("avalue", ((String)bean.get("avalue")).trim());
        }
        assertEquals((Object)"2", beans.get(0), "avalue");
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.