当前位置: 首页>>代码示例>>Java>>正文


Java DynaBean.set方法代码示例

本文整理汇总了Java中org.apache.commons.beanutils.DynaBean.set方法的典型用法代码示例。如果您正苦于以下问题:Java DynaBean.set方法的具体用法?Java DynaBean.set怎么用?Java DynaBean.set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.beanutils.DynaBean的用法示例。


在下文中一共展示了DynaBean.set方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addRole

import org.apache.commons.beanutils.DynaBean; //导入方法依赖的package包/类
public ActionForward addRole(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
	DynaBean lazyForm = (DynaBean) form;

	Site site = (Site) lazyForm.get("site");

    String roleId = request.getParameter("roleId");
    String roleType = request.getParameter("roleType");
    
    SuperSiteUtil superSiteUtil = (SuperSiteUtil) SpringUtils.getBean("superSiteUtil");
    SiteRoleMpgDao siteRoleMpgDao = SpringUtils.getBean(SiteRoleMpgDao.class);
    
    if(roleType!=null)
    {
    	if(roleType.equalsIgnoreCase("access"))
    		siteRoleMpgDao.addAccessRoleToSite(site.getId(), Integer.parseInt(roleId));
    	else if(roleType.equalsIgnoreCase("admit_discharge"))
    		siteRoleMpgDao.addAdmitDischargeRoleToSite(site.getId(), Integer.parseInt(roleId));
    }
    
    request.setAttribute("siteId", site.getId()+"");
    lazyForm.set("site", site);
    return mapping.findForward("details");
}
 
开发者ID:williamgrosset,项目名称:OSCAR-ConCert,代码行数:24,代码来源:SitesManageAction.java

示例2: deleteRole

import org.apache.commons.beanutils.DynaBean; //导入方法依赖的package包/类
public ActionForward deleteRole(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
	DynaBean lazyForm = (DynaBean) form;

	Site site = (Site) lazyForm.get("site");

    String roleId = request.getParameter("roleId");
    String roleType = request.getParameter("roleType");
    
    SuperSiteUtil superSiteUtil = (SuperSiteUtil) SpringUtils.getBean("superSiteUtil");
    SiteRoleMpgDao siteRoleMpgDao = SpringUtils.getBean(SiteRoleMpgDao.class);
    
    if(roleType!=null)
    {
    	if(roleType.equalsIgnoreCase("access"))
    		siteRoleMpgDao.deleteAccessRoleFromSite(site.getId(), Integer.parseInt(roleId));
    	else if(roleType.equalsIgnoreCase("admit_discharge"))
    		siteRoleMpgDao.deleteAdmitDischargeRoleToSite(site.getId(), Integer.parseInt(roleId));
    }
    
    request.setAttribute("siteId", site.getId()+"");
    lazyForm.set("site", site);
    return mapping.findForward("details");
}
 
开发者ID:williamgrosset,项目名称:OSCAR-ConCert,代码行数:24,代码来源:SitesManageAction.java

示例3: testToColumnValues

import org.apache.commons.beanutils.DynaBean; //导入方法依赖的package包/类
/**
 * Test the toColumnValues method.
 */
public void testToColumnValues()
{
    final String schema =
        "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
        "<database xmlns='" + DatabaseIO.DDLUTILS_NAMESPACE + "' name='ddlutils'>\n"+
        "  <table name='TestTable'>\n"+
        "    <column name='id' autoIncrement='true' type='INTEGER' primaryKey='true'/>\n"+
        "    <column name='name' type='VARCHAR' size='15'/>\n"+
        "  </table>\n"+
        "</database>";

    Database         database = parseDatabaseFromString(schema);
    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"));
    assertTrue(map.containsKey("id"));
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:29,代码来源:TestPlatformImplBase.java

示例4: add

import org.apache.commons.beanutils.DynaBean; //导入方法依赖的package包/类
public ActionForward add(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) {
	DynaBean lazyForm = (DynaBean) form;

	Site s = new Site();
	lazyForm.set("site", s);

    return mapping.findForward("details");
}
 
开发者ID:williamgrosset,项目名称:OSCAR-ConCert,代码行数:9,代码来源:SitesManageAction.java

示例5: update

import org.apache.commons.beanutils.DynaBean; //导入方法依赖的package包/类
public ActionForward update(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
	DynaBean lazyForm = (DynaBean) form;

	String siteId = request.getParameter("siteId");
    Site s = siteDao.getById(new Integer(siteId));

    if(s.getSiteLogoId()!=null) {
		s.setSiteLogoDesc(docDao.getDocument(String.valueOf(s.getSiteLogoId())).getDocdesc());
	}
    
    lazyForm.set("site", s);
    return mapping.findForward("details");
}
 
开发者ID:williamgrosset,项目名称:OSCAR-ConCert,代码行数:14,代码来源:SitesManageAction.java

示例6: updateFKColumns

import org.apache.commons.beanutils.DynaBean; //导入方法依赖的package包/类
/**
 * Updates the values of the columns constituting the indicated foreign key with the values
 * of the given identity.
 * 
 * @param bean     The bean whose columns shall be updated
 * @param fkName   The name of the foreign key
 * @param identity The target identity
 */
private void updateFKColumns(DynaBean bean, String fkName, Identity identity)
{
    Table      sourceTable = ((SqlDynaClass)bean.getDynaClass()).getTable();
    Table      targetTable = identity.getTable();
    ForeignKey fk          = null;

    for (int idx = 0; idx < sourceTable.getForeignKeyCount(); idx++)
    {
        ForeignKey curFk = sourceTable.getForeignKey(idx);

        if (curFk.getForeignTableName().equalsIgnoreCase(targetTable.getQualifiedName()))
        {
            if (fkName.equals(getFKName(sourceTable, curFk)))
            {
                fk = curFk;
                break;
            }
        }
    }
    if (fk != null)
    {
        for (int idx = 0; idx < fk.getReferenceCount(); idx++)
        {
            Reference curRef       = fk.getReference(idx);
            Column    sourceColumn = curRef.getLocalColumn();
            Column    targetColumn = curRef.getForeignColumn();

            bean.set(sourceColumn.getName(), identity.getColumnValue(targetColumn.getName()));
        }
    }
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:40,代码来源:DataToDatabaseSink.java

示例7: testExists

import org.apache.commons.beanutils.DynaBean; //导入方法依赖的package包/类
/**
 * Tests the exists method.
 */
public void testExists() throws Exception
{
    createDatabase(
        "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
        "<database xmlns='" + DatabaseIO.DDLUTILS_NAMESPACE + "' name='ddlutils'>\n"+
        "  <table name='TestTable'>\n"+
        "    <column name='TheId' type='INTEGER' primaryKey='true' required='true'/>\n"+
        "    <column name='TheText' type='VARCHAR' size='15'/>\n"+
        "  </table>\n"+
        "</database>");

    insertData(
        "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
        "<data>\n"+
        "  <TestTable TheId='1' TheText='Text 1'/>\n"+
        "  <TestTable TheId='3' TheText='Text 3'/>\n"+
        "</data>");

    SqlDynaClass dynaClass = SqlDynaClass.newInstance(getModel().getTable(0));
    DynaBean     dynaBean1 = new SqlDynaBean(dynaClass);
    DynaBean     dynaBean2 = new SqlDynaBean(dynaClass);
    DynaBean     dynaBean3 = new SqlDynaBean(dynaClass);

    dynaBean1.set("TheId", new Integer(1));
    dynaBean1.set("TheText", "Text 1"); 
    dynaBean2.set("TheId", new Integer(2));
    dynaBean2.set("TheText", "Text 2"); 
    dynaBean3.set("TheId", new Integer(3));
    dynaBean3.set("TheText", "Text 30"); 

    assertTrue(getPlatform().exists(getModel(), dynaBean1));
    assertFalse(getPlatform().exists(getModel(), dynaBean2));
    assertTrue(getPlatform().exists(getModel(), dynaBean3));
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:38,代码来源:TestDynaSqlQueries.java

示例8: sendMailVelocity

import org.apache.commons.beanutils.DynaBean; //导入方法依赖的package包/类
/**
 * Velocity 模板发送邮件 html 格式
 *
 * @param to
 * @param subject
 * @throws javax.mail.MessagingException
 */
public void sendMailVelocity(String from ,String[] to, String subject) throws MessagingException {

    //如果不是 html 格式,修改为  SimpleMailMessage
    MimeMessage message = mailSender.createMimeMessage();
    MimeMessageHelper helper = new MimeMessageHelper(message, true, StandardCharsets.UTF_8.toString());

    /**
     *邮件内容
     */
    helper.setFrom(from);
    helper.setTo(to);
    helper.setSubject(subject);

    //模板内容
    Map<String, Object> model = new HashMap<String, Object>();
    model.put("firstName", "Yashwant");
    model.put("lastName", "Chavan");
    model.put("location", "china");
    //创建动态 bean
    DynaBean dynaBean = new LazyDynaBean();
    dynaBean.set("name", "It is name"); //simple
    dynaBean.set("gender", new Integer(1));  //simple
    //设置 bean 属性

    // Velocity 工具类,实例可以直接放入 map ,在模板文件中直接使用
    // 如日期格式化 $dateTool.format("yyyy-MM-dd",$info.issueTime)
    DateTool dateTool = new DateTool();//日期工具
    NumberTool numberTool = new NumberTool();//数字工具
    model.put("dateTool",dateTool);
    model.put("numberTool",numberTool);

    model.put("bean", dynaBean);
    String text = VelocityEngineUtils.mergeTemplateIntoString(velocityEngine, "./templates/velocity_template_email-newsletter.vm", StandardCharsets.UTF_8.toString(), model);
    helper.setText(text, true);

    mailSender.send(message);
}
 
开发者ID:h819,项目名称:spring-boot,代码行数:45,代码来源:SpringMailService.java

示例9: testStoreExisting

import org.apache.commons.beanutils.DynaBean; //导入方法依赖的package包/类
/**
 * Tests the store method.
 */
public void testStoreExisting() throws Exception
{
    createDatabase(
        "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
        "<database xmlns='" + DatabaseIO.DDLUTILS_NAMESPACE + "' name='ddlutils'>\n"+
        "  <table name='TestTable'>\n"+
        "    <column name='TheId' type='INTEGER' primaryKey='true' required='true'/>\n"+
        "    <column name='TheText' type='VARCHAR' size='15'/>\n"+
        "  </table>\n"+
        "</database>");

    insertData(
        "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
        "<data>\n"+
        "  <TestTable TheId='1' TheText='Text 1'/>\n"+
        "</data>");

    SqlDynaClass dynaClass = SqlDynaClass.newInstance(getModel().getTable(0));
    DynaBean     dynaBean  = new SqlDynaBean(dynaClass);

    dynaBean.set("TheId", new Integer(1));
    dynaBean.set("TheText", "Text 10"); 

    getPlatform().store(getModel(), dynaBean);

    List beans = getPlatform().fetch(getModel(),
                                     "SELECT * FROM " + asIdentifier("TestTable"),
                                     new Table[] { getModel().getTable(0) });

    assertEquals(1,
                 beans.size());

    DynaBean bean = (DynaBean)beans.get(0);

    assertEquals(new Integer(1),
                 getPropertyValue(bean, "TheId"));
    assertEquals("Text 10",
                 getPropertyValue(bean, "TheText"));
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:43,代码来源:TestDynaSqlQueries.java

示例10: insertRow

import org.apache.commons.beanutils.DynaBean; //导入方法依赖的package包/类
/**
 * Inserts a row into the designated table.
 * 
 * @param tableName    The name of the table (case insensitive)
 * @param columnValues The values for the columns in order of definition
 * @return The dyna bean for the row
 */
protected DynaBean insertRow(String tableName, Object[] columnValues)
{
    Table    table = getModel().findTable(tableName);
    DynaBean bean  = getModel().createDynaBeanFor(table);

    for (int idx = 0; (idx < table.getColumnCount()) && (idx < columnValues.length); idx++)
    {
        Column column = table.getColumn(idx);

        bean.set(column.getName(), columnValues[idx]);
    }
    getPlatform().insert(getModel(), bean);
    return bean;
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:22,代码来源:TestAgainstLiveDatabaseBase.java

示例11: updateRow

import org.apache.commons.beanutils.DynaBean; //导入方法依赖的package包/类
/**
 * Updates the row in the designated table.
 * 
 * @param tableName    The name of the table (case insensitive)
 * @param oldBean      The bean representing the current row
 * @param columnValues The values for the columns in order of definition
 * @return The dyna bean for the new row
 */
protected DynaBean updateRow(String tableName, DynaBean oldBean, Object[] columnValues)
{
    Table    table = getModel().findTable(tableName);
    DynaBean bean  = getModel().createDynaBeanFor(table);

    for (int idx = 0; (idx < table.getColumnCount()) && (idx < columnValues.length); idx++)
    {
        Column column = table.getColumn(idx);

        bean.set(column.getName(), columnValues[idx]);
    }
    getPlatform().update(getModel(), oldBean, bean);
    return bean;
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:23,代码来源:TestAgainstLiveDatabaseBase.java

示例12: deleteRow

import org.apache.commons.beanutils.DynaBean; //导入方法依赖的package包/类
/**
 * Deletes the specified row from the table.
 * 
 * @param tableName      The name of the table (case insensitive)
 * @param pkColumnValues The values for the pk columns in order of definition
 */
protected void deleteRow(String tableName, Object[] pkColumnValues)
{
    Table    table     = getModel().findTable(tableName);
    DynaBean bean      = getModel().createDynaBeanFor(table);
    Column[] pkColumns = table.getPrimaryKeyColumns();

    for (int idx = 0; (idx < pkColumns.length) && (idx < pkColumnValues.length); idx++)
    {
        bean.set(pkColumns[idx].getName(), pkColumnValues[idx]);
    }
    getPlatform().delete(getModel(), bean);
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:19,代码来源:TestAgainstLiveDatabaseBase.java

示例13: testColumnTypeSmallintToVarchar

import org.apache.commons.beanutils.DynaBean; //导入方法依赖的package包/类
/**
 * Tests the alteration of a column datatype change from smallint to varchar.
 */
public void testColumnTypeSmallintToVarchar()
{
    final String model1Xml = 
        "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
        "<database xmlns='" + DatabaseIO.DDLUTILS_NAMESPACE + "' name='roundtriptest'>\n"+
        "  <table name='roundtrip'>\n"+
        "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
        "    <column name='avalue' type='SMALLINT'/>\n"+
        "  </table>\n"+
        "</database>";
    final String model2Xml = 
        "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
        "<database xmlns='" + DatabaseIO.DDLUTILS_NAMESPACE + "' name='roundtriptest'>\n"+
        "  <table name='roundtrip'>\n"+
        "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
        "    <column name='avalue' type='VARCHAR' size='20'/>\n"+
        "  </table>\n"+
        "</database>";

    createDatabase(model1Xml);

    insertRow("roundtrip", new Object[] { new Integer(1), new Short((short)2) });

	alterDatabase(model2Xml);

    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(new Integer(1), beans.get(0), "pk");
    assertEquals((Object)"2",    beans.get(0), "avalue");
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:43,代码来源:TestChangeColumn.java

示例14: insertSingleBeanIntoDatabase

import org.apache.commons.beanutils.DynaBean; //导入方法依赖的package包/类
/**
 * Directly inserts the given bean into the database.
 * 
 * @param table The table of the bean
 * @param bean  The bean
 */
private void insertSingleBeanIntoDatabase(Table table, DynaBean bean) throws DataSinkException
{
    try
    {
        boolean    needTwoStepInsert = false;
        ForeignKey selfRefFk         = null;

        if (!_platform.isIdentityOverrideOn() &&
            _tablesWithSelfIdentityReference.contains(table))
        {
            selfRefFk = table.getSelfReferencingForeignKey();

            // in case of a self-reference (fk points to the very row that we're inserting)
            // and (at least) one of the pk columns is an identity column, we first need
            // to insert the row with the fk columns set to null
            Identity pkIdentity = buildIdentityFromPKs(table, bean);
            Identity fkIdentity = buildIdentityFromFK(table, selfRefFk, bean);

            if (pkIdentity.equals(fkIdentity))
            {
                if (_tablesWithRequiredSelfReference.contains(table))
                {
                    throw new DataSinkException("Can only insert rows with fk pointing to themselves when all fk columns can be NULL (row pk is " + pkIdentity + ")");
                }
                else
                {
                    needTwoStepInsert = true;
                }
            }
        }

        if (needTwoStepInsert)
        {
            // we first insert the bean without the fk, then in the second step we update the bean
            // with the row with the identity pk values
            ArrayList fkValues = new ArrayList();

            for (int idx = 0; idx < selfRefFk.getReferenceCount(); idx++)
            {
                String columnName = selfRefFk.getReference(idx).getLocalColumnName();

                fkValues.add(bean.get(columnName));
                bean.set(columnName, null);
            }
            _platform.insert(_connection, _model, bean);
            for (int idx = 0; idx < selfRefFk.getReferenceCount(); idx++)
            {
                bean.set(selfRefFk.getReference(idx).getLocalColumnName(), fkValues.get(idx));
            }
            _platform.update(_connection, _model, bean);
        }
        else
        {
            _platform.insert(_connection, _model, bean);
        }
        if (!_connection.getAutoCommit())
        {
            _connection.commit();
        }
    }
    catch (Exception ex)
    {
        if (_haltOnErrors)
        {
            _platform.returnConnection(_connection);
            throw new DataSinkException(ex);
        }
        else
        {
            _log.warn("Exception while inserting a row into the database", ex);
        }
    }
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:80,代码来源:DataToDatabaseSink.java

示例15: testUniqueIndexColumnTypeSmallintToVarchar

import org.apache.commons.beanutils.DynaBean; //导入方法依赖的package包/类
/**
 * Tests the alteration of an indexed column datatype change from smallint to varchar.
 */
public void testUniqueIndexColumnTypeSmallintToVarchar()
{
    if (!getPlatformInfo().isIndicesSupported())
    {
        return;
    }

    final String model1Xml = 
        "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
        "<database xmlns='" + DatabaseIO.DDLUTILS_NAMESPACE + "' name='roundtriptest'>\n"+
        "  <table name='roundtrip'>\n"+
        "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
        "    <column name='avalue1' type='SMALLINT'/>\n"+
        "    <column name='avalue2' type='DOUBLE'/>\n"+
        "    <unique name='testindex'>\n"+
        "      <unique-column name='avalue1'/>\n"+
        "      <unique-column name='avalue2'/>\n"+
        "    </unique>\n"+
        "  </table>\n"+
        "</database>";
    final String model2Xml = 
        "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
        "<database xmlns='" + DatabaseIO.DDLUTILS_NAMESPACE + "' name='roundtriptest'>\n"+
        "  <table name='roundtrip'>\n"+
        "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
        "    <column name='avalue1' type='VARCHAR' size='20'/>\n"+
        "    <column name='avalue2' type='DOUBLE'/>\n"+
        "    <unique name='testindex'>\n"+
        "      <unique-column name='avalue1'/>\n"+
        "      <unique-column name='avalue2'/>\n"+
        "    </unique>\n"+
        "  </table>\n"+
        "</database>";

    createDatabase(model1Xml);

    insertRow("roundtrip", new Object[] { new Integer(1), new Short((short)2), new Double(3.0) });

    alterDatabase(model2Xml);

    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("avalue1") instanceof String)
    {
        bean.set("avalue1", ((String)bean.get("avalue1")).trim());
    }
    assertEquals(new Integer(1),  beans.get(0), "pk");
    assertEquals((Object)"2",     beans.get(0), "avalue1");
    assertEquals(new Double(3.0), beans.get(0), "avalue2");
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:59,代码来源:TestChangeColumn.java


注:本文中的org.apache.commons.beanutils.DynaBean.set方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。