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


Java ClassDescriptor.getFieldDescriptions方法代码示例

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


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

示例1: getPrimaryKeyDescriptors

import org.apache.ojb.broker.metadata.ClassDescriptor; //导入方法依赖的package包/类
private Collection<FieldDescriptor> getPrimaryKeyDescriptors(String clazz) {
    final Collection<FieldDescriptor> pks = new ArrayList<FieldDescriptor>();

    final ClassDescriptor cd = OjbUtil.findClassDescriptor(clazz, descriptorRepositories);
    if (cd != null) {
        //This causes a stackoverflow and appears to not work correctly
        //return cd.getPkFields().length > 1;
        int i = 0;
        FieldDescriptor[] fds = cd.getFieldDescriptions();
        if (fds != null) {
            for (FieldDescriptor fd : fds) {
                if (fd.isPrimaryKey()) {
                    pks.add(fd);
                }
            }
        }
    }
    return pks;
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:20,代码来源:IdClassResolver.java

示例2: refreshInstance

import org.apache.ojb.broker.metadata.ClassDescriptor; //导入方法依赖的package包/类
/**
 * refresh all primitive typed attributes of a cached instance
 * with the current values from the database.
 * refreshing of reference and collection attributes is not done
 * here.
 * @param cachedInstance the cached instance to be refreshed
 * @param oid the Identity of the cached instance
 * @param cld the ClassDescriptor of cachedInstance
 */
private void refreshInstance(Object cachedInstance, Identity oid, ClassDescriptor cld)
{
    // read in fresh copy from the db, but do not cache it
    Object freshInstance = getPlainDBObject(cld, oid);

    // update all primitive typed attributes
    FieldDescriptor[] fields = cld.getFieldDescriptions();
    FieldDescriptor fmd;
    PersistentField fld;
    for (int i = 0; i < fields.length; i++)
    {
        fmd = fields[i];
        fld = fmd.getPersistentField();
        fld.set(cachedInstance, fld.get(freshInstance));
    }
}
 
开发者ID:KualiCo,项目名称:ojb,代码行数:26,代码来源:PersistenceBrokerImpl.java

示例3: testGenerateStandardTables

import org.apache.ojb.broker.metadata.ClassDescriptor; //导入方法依赖的package包/类
public void testGenerateStandardTables() {
    StringBuffer buffer = new StringBuffer();
    TableDescriptor tableDescriptor = new TableDescriptor();
    this.torqueTableGenerator.generateStandardTable(tableDescriptor, buffer, "JUnit indx");
    assertEquals(EMPTY_STANDARD_TABLE, buffer.toString());

    buffer = new StringBuffer();
    tableDescriptor.setName("PERSON_PROJECT");
    ClassDescriptor classDescriptor = this.repository.getDescriptorFor(org.apache.ojb.odmg.shared.ProductGroup.class);
    FieldDescriptor fieldDescriptors[] = classDescriptor.getFieldDescriptions();
    for (int i = 0; i < fieldDescriptors.length; i++) {
        tableDescriptor.addColumn(fieldDescriptors[i]);
    }
    tableDescriptor.setIndices(classDescriptor.getIndexes());
    tableDescriptor.getReferences().addAll(classDescriptor.getObjectReferenceDescriptors());

    this.torqueTableGenerator.generateStandardTable(tableDescriptor, buffer, "JUnit indx");
    assertEquals(PERSON_PROJECT_TABLE, buffer.toString());
}
 
开发者ID:KualiCo,项目名称:ojb,代码行数:20,代码来源:TorqueTableGeneratorTest.java

示例4: listFieldNames

import org.apache.ojb.broker.metadata.ClassDescriptor; //导入方法依赖的package包/类
/**
 * @see org.kuali.rice.krad.service.PersistenceMetadataExplorerService#listFieldNames(java.lang.Class)
 */

@Override
public List listFieldNames(Class clazz) {
	List fieldNames = new ArrayList();
	ClassDescriptor classDescriptor = getClassDescriptor(clazz);
	FieldDescriptor fieldDescriptors[] = classDescriptor.getFieldDescriptions();
	for (int i = 0; i < fieldDescriptors.length; ++i) {
		FieldDescriptor fieldDescriptor = fieldDescriptors[i];
		fieldNames.add(fieldDescriptor.getAttributeName());
	}
	return fieldNames;
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:16,代码来源:PersistenceStructureServiceOjbImpl.java

示例5: convertDBColumnNameToJavaName

import org.apache.ojb.broker.metadata.ClassDescriptor; //导入方法依赖的package包/类
/**
 * Returns the java attribute name corresponding to the column name
 * 
 * @param classDescriptor the origin entry class
 * @param columnName the DB column name
 * @param caseInsensitive whether to do case insensitive matching
 * @return the java attribute name
 */
protected String convertDBColumnNameToJavaName(ClassDescriptor classDescriptor, String columnName, boolean caseInsensitive) {
    FieldDescriptor[] fields = classDescriptor.getFieldDescriptions();
    for (FieldDescriptor field : fields) {
        if (caseInsensitive && field.getColumnName().equalsIgnoreCase(columnName)) {
            return field.getAttributeName();
        }
        if (!caseInsensitive && field.getColumnName().equals(columnName)) {
            return field.getAttributeName();
        }
    }
    return null;
}
 
开发者ID:VU-libtech,项目名称:OLE-INST,代码行数:21,代码来源:ReconciliationDaoOjb.java

示例6: extractAttributes

import org.apache.ojb.broker.metadata.ClassDescriptor; //导入方法依赖的package包/类
private void extractAttributes(ClassDescriptor classDesc, Table mappedTable, Map columnsMap, Map requiredColumnsMap)
{
    FieldDescriptor[] fieldDescs = classDesc.getFieldDescriptions();

    if (fieldDescs != null)
    {
        for (int idx = 0; idx < fieldDescs.length; idx++)
        {
            Column column = mappedTable.findColumn(fieldDescs[idx].getColumnName());

            if (column != null)
            {
                // we'll check whether another field (of not necessarily the same name)
                // already maps to this column; if this is the case, we're ignoring
                // this field
                boolean alreadyMapped = false;

                for (Iterator mappedColumnsIt = columnsMap.values().iterator(); mappedColumnsIt.hasNext();)
                {
                    if (column.equals(mappedColumnsIt.next()))
                    {
                        alreadyMapped = true;
                        break;
                    }
                }
                if (!alreadyMapped)
                {
                    String shortAttrName = getShortAttributeName(fieldDescs[idx].getAttributeName());
    
                    columnsMap.put(shortAttrName, column);
                    requiredColumnsMap.put(shortAttrName,
                                           fieldDescs[idx].isPrimaryKey() ? Boolean.TRUE : Boolean.FALSE);
                }
            }
        }
    }
}
 
开发者ID:KualiCo,项目名称:ojb,代码行数:38,代码来源:PreparedModel.java

示例7: buildCriteria

import org.apache.ojb.broker.metadata.ClassDescriptor; //导入方法依赖的package包/类
/**
 * Build Criteria based on example object<br>
 * all non null values are used as EqualToCriteria
 */
private static Criteria buildCriteria(Object anExample)
{
    Criteria criteria = new Criteria();
    ClassDescriptor cld = MetadataManager.getInstance().getRepository().getDescriptorFor(anExample.getClass());
    FieldDescriptor[] fds = cld.getFieldDescriptions();
    PersistentField f;
    Object value;

    for (int i = 0; i < fds.length; i++)
    {
        try
        {
            f = fds[i].getPersistentField();
            value = f.get(anExample);
            if (value != null)
            {
                criteria.addEqualTo(f.getName(), value);
            }
        }
        catch (Throwable ex)
        {
            LoggerFactory.getDefaultLogger().error(ex);
        }
    }

    return criteria;
}
 
开发者ID:KualiCo,项目名称:ojb,代码行数:32,代码来源:QueryByCriteria.java

示例8: buildFieldsForSelect

import org.apache.ojb.broker.metadata.ClassDescriptor; //导入方法依赖的package包/类
/**
 * Return the Fields to be selected.
 *
 * @param cld the ClassDescriptor
 * @return the Fields to be selected
 */
protected FieldDescriptor[] buildFieldsForSelect(ClassDescriptor cld)
{
    DescriptorRepository repository = cld.getRepository();
    Set fields = new ListOrderedSet();   // keep the order of the fields
    
    // add Standard Fields
    // MBAIRD: if the object being queried on has multiple classes mapped to the table,
    // then we will get all the fields that are a unique set across all those classes so if we need to
    // we can materialize an extent
    FieldDescriptor fds[] = repository.getFieldDescriptorsForMultiMappedTable(cld);
    for (int i = 0; i < fds.length; i++)
    {
        fields.add(fds[i]);
    }

    // add inherited Fields. This is important when querying for a class having a super-reference
    fds = cld.getFieldDescriptor(true);
    for (int i = 0; i < fds.length; i++)
    {
        fields.add(fds[i]);
    }

    // add Fields of joined subclasses
    Class[] multiJoinedClasses = repository.getSubClassesMultipleJoinedTables(cld, true);
    for (int c = 0; c < multiJoinedClasses.length; c++)
    {
        ClassDescriptor subCld = repository.getDescriptorFor(multiJoinedClasses[c]);
        fds = subCld.getFieldDescriptions();
        for (int i = 0; i < fds.length; i++)
        {
            fields.add(fds[i]);
        }
    }

    FieldDescriptor[] result = new FieldDescriptor[fields.size()];
    fields.toArray(result);
    return result;
}
 
开发者ID:KualiCo,项目名称:ojb,代码行数:45,代码来源:SqlSelectStatement.java

示例9: appendSuperClassColumns

import org.apache.ojb.broker.metadata.ClassDescriptor; //导入方法依赖的package包/类
private void appendSuperClassColumns(ClassDescriptor cldSuper, StringBuffer buf)
{
    FieldDescriptor[] fields = cldSuper.getFieldDescriptions();
    for (int i = 0; i < fields.length; i++)
    {
        FieldDescriptor field = fields[i];
        if (i > 0)
        {
            buf.append(",");
        }
        buf.append(cldSuper.getFullTableName());
        buf.append(".");
        buf.append(field.getColumnName());
    }
}
 
开发者ID:KualiCo,项目名称:ojb,代码行数:16,代码来源:SqlSelectStatement.java

示例10: getDBFieldNamesForClass

import org.apache.ojb.broker.metadata.ClassDescriptor; //导入方法依赖的package包/类
/**
 * 
 * fetch the DB column names for the fields in the class for the query
 * @param ojbClass = class of the query
 * @return hash set of DB column names keyed by OJB attribute name, 
 */
protected HashMap<String,String> getDBFieldNamesForClass(Class ojbClass)
{
    ClassDescriptor ojbClassDescriptor = MetadataManager.getInstance().getRepository().getDescriptorFor(ojbClass);
    FieldDescriptor[] fieldDescriptorArray = ojbClassDescriptor.getFieldDescriptions();
    HashMap<String,String> returnSet = new HashMap<String,String>(((Double)(1.34*fieldDescriptorArray.length)).intValue());
    for (FieldDescriptor fieldInDB: fieldDescriptorArray)
    {
        returnSet.put(fieldInDB.getAttributeName(),fieldInDB.getColumnName());
    }
    return returnSet;   
}
 
开发者ID:kuali,项目名称:kfs,代码行数:18,代码来源:BudgetConstructionBatchHelperDaoOjb.java

示例11: handleDependentReferences

import org.apache.ojb.broker.metadata.ClassDescriptor; //导入方法依赖的package包/类
/**
 * Mark for creation all newly introduced dependent references.
 * Mark for deletion all nullified dependent references.
 * @return the list of created objects
 */
private ArrayList handleDependentReferences(Identity oid, Object userObject,
        Object[] origFields, Object[] newFields, Object[] newRefs)
        throws LockingException
{
    ClassDescriptor mif = _pb.getClassDescriptor(userObject.getClass());
    FieldDescriptor[] fieldDescs = mif.getFieldDescriptions();
    Collection refDescs = mif.getObjectReferenceDescriptors();
    int count = 1 + fieldDescs.length;
    ArrayList newObjects = new ArrayList();
    int countRefs = 0;

    for (Iterator it = refDescs.iterator(); it.hasNext(); count++, countRefs++)
    {
        ObjectReferenceDescriptor rds = (ObjectReferenceDescriptor) it.next();
        Identity origOid = (origFields == null ? null : (Identity) origFields[count]);
        Identity newOid = (Identity) newFields[count];

        if (rds.getOtmDependent())
        {
            if ((origOid == null) && (newOid != null))
            {
                ContextEntry entry = (ContextEntry) _objects.get(newOid);

                if (entry == null)
                {
                    Object relObj = newRefs[countRefs];
                    insertInternal(newOid, relObj, LockType.WRITE_LOCK,
                                   true, oid, new Stack());
                    newObjects.add(newOid);
                }
            }
            else if ((origOid != null) &&
                     ((newOid == null) || !newOid.equals(origOid)))
            {
                markDelete(origOid, oid, false);
            }
        }
    }

    return newObjects;
}
 
开发者ID:KualiCo,项目名称:ojb,代码行数:47,代码来源:ConcreteEditingContext.java


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