本文整理汇总了Java中org.apache.ojb.broker.metadata.FieldDescriptor类的典型用法代码示例。如果您正苦于以下问题:Java FieldDescriptor类的具体用法?Java FieldDescriptor怎么用?Java FieldDescriptor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FieldDescriptor类属于org.apache.ojb.broker.metadata包,在下文中一共展示了FieldDescriptor类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getReferenceFKValue
import org.apache.ojb.broker.metadata.FieldDescriptor; //导入依赖的package包/类
private Object getReferenceFKValue(Object persistableObject, ObjectReferenceDescriptor chkRefCld, String fkName) {
ClassDescriptor classDescriptor = getClassDescriptor(persistableObject.getClass());
Object referenceObject = ObjectUtils.getPropertyValue(persistableObject, chkRefCld.getAttributeName());
if (referenceObject == null) {
return null;
}
FieldDescriptor[] refFkNames = chkRefCld.getForeignKeyFieldDescriptors(classDescriptor);
ClassDescriptor refCld = getClassDescriptor(chkRefCld.getItemClass());
FieldDescriptor[] refPkNames = refCld.getPkFields();
Object fkValue = null;
for (int i = 0; i < refFkNames.length; i++) {
FieldDescriptor fkField = refFkNames[i];
if (fkField.getAttributeName().equals(fkName)) {
fkValue = ObjectUtils.getPropertyValue(referenceObject, refPkNames[i].getAttributeName());
break;
}
}
return fkValue;
}
开发者ID:kuali,项目名称:kc-rice,代码行数:26,代码来源:PersistenceServiceOjbImpl.java
示例2: getForeignKeyFieldName
import org.apache.ojb.broker.metadata.FieldDescriptor; //导入依赖的package包/类
/**
* @see org.kuali.rice.krad.service.PersistenceService#getForeignKeyFieldName(java.lang.Object,
* java.lang.String, java.lang.String)
*/
@Override
public String getForeignKeyFieldName(Class persistableObjectClass, String attributeName, String pkName) {
String fkName = "";
ClassDescriptor classDescriptor = getClassDescriptor(persistableObjectClass);
ObjectReferenceDescriptor objectReferenceDescriptor = classDescriptor.getObjectReferenceDescriptorByName(attributeName);
if (objectReferenceDescriptor == null) {
throw new RuntimeException("Attribute name " + attributeName + " is not a valid reference to class " + persistableObjectClass.getName());
}
ClassDescriptor referenceDescriptor = this.getClassDescriptor(objectReferenceDescriptor.getItemClass());
FieldDescriptor[] fkFields = objectReferenceDescriptor.getForeignKeyFieldDescriptors(classDescriptor);
FieldDescriptor[] pkFields = referenceDescriptor.getPkFields();
for (int i = 0; i < pkFields.length; i++) {
FieldDescriptor pkField = pkFields[i];
if (pkField.getAttributeName().equals(pkName)) {
fkName = fkFields[i].getAttributeName();
}
}
return fkName;
}
开发者ID:kuali,项目名称:kc-rice,代码行数:26,代码来源:PersistenceStructureServiceOjbImpl.java
示例3: getReferencesForForeignKey
import org.apache.ojb.broker.metadata.FieldDescriptor; //导入依赖的package包/类
/**
* @see org.kuali.rice.krad.service.PersistenceService#getReferencesForForeignKey(java.lang.Class,
* java.lang.String)
*/
@Override
public Map getReferencesForForeignKey(Class persistableObjectClass, String attributeName) {
Map referenceClasses = new HashMap();
if (PersistableBusinessObject.class.isAssignableFrom(persistableObjectClass)) {
ClassDescriptor classDescriptor = getClassDescriptor(persistableObjectClass);
Vector objectReferences = classDescriptor.getObjectReferenceDescriptors();
for (Iterator iter = objectReferences.iterator(); iter.hasNext();) {
ObjectReferenceDescriptor referenceDescriptor = (ObjectReferenceDescriptor) iter.next();
/*
* iterate through the fk keys for the reference object and if
* matches the attributeName add the class as a reference
*/
FieldDescriptor[] refFkNames = referenceDescriptor.getForeignKeyFieldDescriptors(classDescriptor);
for (int i = 0; i < refFkNames.length; i++) {
FieldDescriptor fkField = refFkNames[i];
if (fkField.getAttributeName().equals(attributeName)) {
referenceClasses.put(referenceDescriptor.getAttributeName(), referenceDescriptor.getItemClass());
}
}
}
}
return referenceClasses;
}
开发者ID:kuali,项目名称:kc-rice,代码行数:30,代码来源:PersistenceStructureServiceOjbImpl.java
示例4: getNestedForeignKeyMap
import org.apache.ojb.broker.metadata.FieldDescriptor; //导入依赖的package包/类
/**
* @see org.kuali.rice.krad.service.PersistenceService#getNestedForeignKeyMap(java.lang.Class)
*/
@Override
public Map getNestedForeignKeyMap(Class persistableObjectClass) {
Map fkMap = new HashMap();
ClassDescriptor classDescriptor = getClassDescriptor(persistableObjectClass);
Vector objectReferences = classDescriptor.getObjectReferenceDescriptors();
for (Iterator iter = objectReferences.iterator(); iter.hasNext();) {
ObjectReferenceDescriptor objectReferenceDescriptor = (ObjectReferenceDescriptor) iter.next();
ClassDescriptor referenceDescriptor = this.getClassDescriptor(objectReferenceDescriptor.getItemClass());
FieldDescriptor[] fkFields = objectReferenceDescriptor.getForeignKeyFieldDescriptors(classDescriptor);
FieldDescriptor[] pkFields = referenceDescriptor.getPkFields();
for (int i = 0; i < pkFields.length; i++) {
FieldDescriptor pkField = pkFields[i];
fkMap.put(objectReferenceDescriptor.getAttributeName() + "." + pkField.getAttributeName(), fkFields[i].getAttributeName());
}
}
return fkMap;
}
开发者ID:kuali,项目名称:kc-rice,代码行数:24,代码来源:PersistenceStructureServiceOjbImpl.java
示例5: getAnnotationNodes
import org.apache.ojb.broker.metadata.FieldDescriptor; //导入依赖的package包/类
@Override
protected NodeData getAnnotationNodes(String enclosingClass, String fieldName, String mappedClass) {
final FieldDescriptor fd = OjbUtil.findFieldDescriptor(mappedClass, fieldName, descriptorRepositories);
if (fd != null) {
final Class<?> fc = ResolverUtil.getType(enclosingClass, fieldName);
final String columnType = fd.getColumnType();
if (isLob(columnType)) {
if (isValidFieldType(fc)) {
return new NodeData(new MarkerAnnotationExpr(new NameExpr(SIMPLE_NAME)),
new ImportDeclaration(new QualifiedNameExpr(new NameExpr(PACKAGE), SIMPLE_NAME), false, false));
} else {
LOG.error(ResolverUtil.logMsgForField(enclosingClass, fieldName, mappedClass) + " is not a valid field type for the @Lob annotation, must be one of " + VALID_TYPES_STR);
}
}
return null;
}
return null;
}
开发者ID:kuali,项目名称:kc-rice,代码行数:21,代码来源:LobResolver.java
示例6: getAnnotationNodes
import org.apache.ojb.broker.metadata.FieldDescriptor; //导入依赖的package包/类
@Override
protected NodeData getAnnotationNodes(String enclosingClass, String fieldName, String mappedClass) {
final FieldDescriptor fd = OjbUtil.findFieldDescriptor(mappedClass, fieldName, descriptorRepositories);
if (fd != null) {
final Class<?> fc = ResolverUtil.getType(enclosingClass, fieldName);
if (isEnum(fc)) {
final Comment fixme = new BlockComment("\nFIXME:\n" +
"Enums must be annotated with the @Enumerated annotation.\n " +
"The @Enumerated annotation should set the EnumType.\n" +
"If the EnumType is not set, then the Enumerated annotation is defaulted to EnumType.ORDINAL.\n" +
"This conversion program cannot tell whether EnumType.ORDINAL is the appropriate EnumType.");
AnnotationExpr enumerated = new NormalAnnotationExpr(new NameExpr(SIMPLE_NAME), Collections.singletonList(new MemberValuePair("value", new NameExpr("EnumType."))));
enumerated.setComment(fixme);
return new NodeData(enumerated, new ImportDeclaration(new QualifiedNameExpr(new NameExpr(PACKAGE), SIMPLE_NAME), false, false),
Collections.singletonList(new ImportDeclaration(new QualifiedNameExpr(new NameExpr(PACKAGE), "TemporalType"), false, false)));
}
}
return null;
}
开发者ID:kuali,项目名称:kc-rice,代码行数:22,代码来源:EnumeratedResolver.java
示例7: resolve
import org.apache.ojb.broker.metadata.FieldDescriptor; //导入依赖的package包/类
@Override
public NodeData resolve(Node node, String mappedClass) {
if (!(node instanceof ClassOrInterfaceDeclaration)) {
throw new IllegalArgumentException("this annotation belongs only on ClassOrInterfaceDeclaration");
}
final TypeDeclaration dclr = (TypeDeclaration) node;
if (!(dclr.getParentNode() instanceof CompilationUnit)) {
//handling nested classes
return null;
}
final String name = dclr.getName();
final Collection<FieldDescriptor> primaryKeyDescriptors = getPrimaryKeyDescriptors(mappedClass);
if (primaryKeyDescriptors != null && primaryKeyDescriptors.size() > 1 && nodeContainsPkFields(dclr,
primaryKeyDescriptors)) {
final NodeAndImports<ClassOrInterfaceDeclaration> primaryKeyClass = createPrimaryKeyClass(name, primaryKeyDescriptors);
final String pkClassName = primaryKeyClass.node.getName();
return new NodeData(new SingleMemberAnnotationExpr(new NameExpr(SIMPLE_NAME), new NameExpr(name + "." + pkClassName + ".class")),
new ImportDeclaration(new QualifiedNameExpr(new NameExpr(PACKAGE), SIMPLE_NAME), false, false), primaryKeyClass.imprts, primaryKeyClass.node);
}
return null;
}
开发者ID:kuali,项目名称:kc-rice,代码行数:26,代码来源:IdClassResolver.java
示例8: nodeContainsPkFields
import org.apache.ojb.broker.metadata.FieldDescriptor; //导入依赖的package包/类
private boolean nodeContainsPkFields(TypeDeclaration dclr, Collection<FieldDescriptor> pks) {
for (FieldDescriptor pk : pks) {
boolean contains = false;
for (FieldDeclaration field : ParserUtil.getFieldMembers(dclr.getMembers())) {
if (field.getVariables().get(0).getId().getName().equals(pk.getAttributeName())) {
contains = true;
break;
}
}
if (!contains) {
return false;
}
}
return true;
}
开发者ID:kuali,项目名称:kc-rice,代码行数:18,代码来源:IdClassResolver.java
示例9: getPrimaryKeyDescriptors
import org.apache.ojb.broker.metadata.FieldDescriptor; //导入依赖的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
示例10: getAnnotationNodes
import org.apache.ojb.broker.metadata.FieldDescriptor; //导入依赖的package包/类
@Override
protected NodeData getAnnotationNodes(String enclosingClass, String fieldName, String mappedClass) {
final FieldDescriptor fd = OjbUtil.findFieldDescriptor(mappedClass, fieldName, descriptorRepositories);
if (fd != null) {
final boolean autoInc = fd.isAutoIncrement();
final String seqName = fd.getSequenceName();
if (autoInc && StringUtils.isBlank(seqName)) {
LOG.error(ResolverUtil.logMsgForField(enclosingClass, fieldName, mappedClass) + " field has autoincrement set to true but sequenceName is blank.");
}
if (!autoInc && StringUtils.isNotBlank(seqName)) {
LOG.error(ResolverUtil.logMsgForField(enclosingClass, fieldName, mappedClass) + " field has autoincrement set to false but sequenceName is " + seqName + ".");
}
if (autoInc || StringUtils.isNotBlank(seqName)) {
return new NodeData(new NormalAnnotationExpr(new NameExpr(SIMPLE_NAME), Collections.singletonList(new MemberValuePair("name", new StringLiteralExpr(upperCaseTableName ? seqName.toUpperCase() : seqName)))),
new ImportDeclaration(new QualifiedNameExpr(new NameExpr(PACKAGE), SIMPLE_NAME), false, false));
}
}
return null;
}
开发者ID:kuali,项目名称:kc-rice,代码行数:22,代码来源:PortableSequenceGeneratorResolver.java
示例11: createJoinColumn
import org.apache.ojb.broker.metadata.FieldDescriptor; //导入依赖的package包/类
private AnnotationExpr createJoinColumn(FieldDescriptor thisField, FieldDescriptor itemField) {
final List<MemberValuePair> pairs = new ArrayList<MemberValuePair>();
pairs.add(new MemberValuePair("name", new StringLiteralExpr(thisField.getColumnName())));
pairs.add(new MemberValuePair("referencedColumnName", new StringLiteralExpr(itemField.getColumnName())));
if (!isAnonymousFk(thisField)) {
pairs.add(new MemberValuePair("insertable", new BooleanLiteralExpr(false)));
pairs.add(new MemberValuePair("updatable", new BooleanLiteralExpr(false)));
}
// Per this page: https://forums.oracle.com/message/3923913
// the nullable attribute is a hint to the DDL generation, especially on fields like this.
// Commenting this flag out for now as it's just "noise" in the annotation definitions
// if (!isNullableFk(thisField)) {
// pairs.add(new MemberValuePair("nullable", new BooleanLiteralExpr(false)));
// }
return new NormalAnnotationExpr(new NameExpr("JoinColumn"), pairs);
}
开发者ID:kuali,项目名称:kc-rice,代码行数:19,代码来源:AbstractJoinColumnResolver.java
示例12: getAnnotationNodes
import org.apache.ojb.broker.metadata.FieldDescriptor; //导入依赖的package包/类
@Override
protected NodeData getAnnotationNodes(String enclosingClass, String fieldName, String mappedClass) {
final FieldDescriptor fd = OjbUtil.findFieldDescriptor(mappedClass, fieldName, descriptorRepositories);
if (fd != null) {
final boolean autoInc = fd.isAutoIncrement();
final String seqName = fd.getSequenceName();
if (autoInc && StringUtils.isBlank(seqName)) {
LOG.error(ResolverUtil.logMsgForField(enclosingClass, fieldName, mappedClass) + " field has autoincrement set to true but sequenceName is blank.");
}
if (!autoInc && StringUtils.isNotBlank(seqName)) {
LOG.error(ResolverUtil.logMsgForField(enclosingClass, fieldName, mappedClass) + " field has autoincrement set to false but sequenceName is " + seqName + ".");
}
if (autoInc || StringUtils.isNotBlank(seqName)) {
return new NodeData(new NormalAnnotationExpr(new NameExpr(SIMPLE_NAME), Collections.singletonList(new MemberValuePair("generator", new StringLiteralExpr(upperCaseTableName ? seqName.toUpperCase() : seqName)))),
new ImportDeclaration(new QualifiedNameExpr(new NameExpr(PACKAGE), SIMPLE_NAME), false, false));
}
}
return null;
}
开发者ID:kuali,项目名称:kc-rice,代码行数:22,代码来源:GeneratedValueResolver.java
示例13: buildPrefetchQuery
import org.apache.ojb.broker.metadata.FieldDescriptor; //导入依赖的package包/类
/**
* Build the prefetch query for a M-N relationship, The query looks like the following sample :
* <br>
* <pre>
* crit = new Criteria();
* crit.addIn("PERSON_PROJECT.PROJECT_ID", ids);
* crit.addEqualToField("id","PERSON_PROJECT.PERSON_ID");
* qry = new QueryByMtoNCriteria(Person.class, "PERSON_PROJECT", crit, true);
* </pre>
*
* @param ids Collection containing all identities of objects of the M side
* @return the prefetch Query
*/
protected Query buildPrefetchQuery(Collection ids)
{
CollectionDescriptor cds = getCollectionDescriptor();
String[] indFkCols = getFksToThisClass();
String[] indItemFkCols = getFksToItemClass();
FieldDescriptor[] itemPkFields = getItemClassDescriptor().getPkFields();
Criteria crit = buildPrefetchCriteria(ids, indFkCols, indItemFkCols, itemPkFields);
// BRJ: do not use distinct:
//
// ORA-22901 cannot compare nested table or VARRAY or LOB attributes of an object type
// Cause: Comparison of nested table or VARRAY or LOB attributes of an
// object type was attempted in the absence of a MAP or ORDER method.
// Action: Define a MAP or ORDER method for the object type.
//
// Without the distinct the resultset may contain duplicate rows
return new QueryByMtoNCriteria(cds.getItemClass(), cds.getIndirectionTable(), crit, false);
}
开发者ID:KualiCo,项目名称:ojb,代码行数:34,代码来源:MtoNCollectionPrefetcher.java
示例14: testAddColumn
import org.apache.ojb.broker.metadata.FieldDescriptor; //导入依赖的package包/类
public void testAddColumn() {
FieldDescriptor fieldDescriptor = new FieldDescriptor(null, 1);
fieldDescriptor.setColumnName("JUnit 1");
this.tableDescriptor.addColumn(fieldDescriptor);
Vector columns = this.tableDescriptor.getColumns();
assertNotNull("The vector of columns is strangely null", columns);
assertEquals("There was strangely not 1 element in the vector", 1, columns.size());
this.tableDescriptor.addColumn(fieldDescriptor);
columns = this.tableDescriptor.getColumns();
assertEquals("There was strangely not 1 element in the vector", 1, columns.size());
FieldDescriptor newFieldDescriptor = new FieldDescriptor(null, 2);
newFieldDescriptor.setColumnName("JUnit 2");
this.tableDescriptor.addColumn(newFieldDescriptor);
columns = this.tableDescriptor.getColumns();
assertEquals("There was strangely not 1 element in the vector", 2, columns.size());
}
开发者ID:KualiCo,项目名称:ojb,代码行数:17,代码来源:TableDescriptorTest.java
示例15: getIdentityFromResultSet
import org.apache.ojb.broker.metadata.FieldDescriptor; //导入依赖的package包/类
/**
* returns an Identity object representing the current resultset row
*/
protected Identity getIdentityFromResultSet() throws PersistenceBrokerException
{
// fill primary key values from Resultset
FieldDescriptor fld;
FieldDescriptor[] pkFields = getQueryObject().getClassDescriptor().getPkFields();
Object[] pkValues = new Object[pkFields.length];
for (int i = 0; i < pkFields.length; i++)
{
fld = pkFields[i];
pkValues[i] = getRow().get(fld.getColumnName());
}
// return identity object build up from primary keys
return getBroker().serviceIdentity().buildIdentity(
getQueryObject().getClassDescriptor().getClassOfObject(), getTopLevelClass(), pkValues);
}
开发者ID:KualiCo,项目名称:ojb,代码行数:21,代码来源:RsIterator.java
示例16: bindDelete
import org.apache.ojb.broker.metadata.FieldDescriptor; //导入依赖的package包/类
/**
* binds the Identities Primary key values to the statement
*/
public void bindDelete(PreparedStatement stmt, Identity oid, ClassDescriptor cld) throws SQLException
{
Object[] pkValues = oid.getPrimaryKeyValues();
FieldDescriptor[] pkFields = cld.getPkFields();
int i = 0;
try
{
for (; i < pkValues.length; i++)
{
setObjectForStatement(stmt, i + 1, pkValues[i], pkFields[i].getJdbcType().getType());
}
}
catch (SQLException e)
{
m_log.error("bindDelete failed for: " + oid.toString() + ", while set value '" +
pkValues[i] + "' for column " + pkFields[i].getColumnName());
throw e;
}
}
开发者ID:KualiCo,项目名称:ojb,代码行数:23,代码来源:StatementManager.java
示例17: appendListOfColumnsForSelect
import org.apache.ojb.broker.metadata.FieldDescriptor; //导入依赖的package包/类
/**
* Appends to the statement a comma separated list of column names.
*
* DO NOT use this if order of columns is important. The row readers build reflectively and look up
* column names to find values, so this is safe. In the case of update, you CANNOT use this as the
* order of columns is important.
*
* @return list of column names for the set of all unique columns for multiple classes mapped to the
* same table.
*/
protected List appendListOfColumnsForSelect(StringBuffer buf)
{
FieldDescriptor[] fieldDescriptors = getFieldsForSelect();
ArrayList columnList = new ArrayList();
TableAlias searchAlias = getSearchTable();
for (int i = 0; i < fieldDescriptors.length; i++)
{
FieldDescriptor field = fieldDescriptors[i];
TableAlias alias = getTableAliasForClassDescriptor(field.getClassDescriptor());
if (alias == null)
{
alias = searchAlias;
}
if (i > 0)
{
buf.append(",");
}
appendColumn(alias, field, buf);
columnList.add(field.getAttributeName());
}
appendClazzColumnForSelect(buf);
return columnList;
}
开发者ID:KualiCo,项目名称:ojb,代码行数:36,代码来源:SqlSelectStatement.java
示例18: appendSuperClassJoin
import org.apache.ojb.broker.metadata.FieldDescriptor; //导入依赖的package包/类
private void appendSuperClassJoin(ClassDescriptor cld, ClassDescriptor cldSuper, StringBuffer stmt, StringBuffer where)
{
stmt.append(",");
appendTable(cldSuper, stmt);
if (where != null)
{
if (where.length() > 0)
{
where.append(" AND ");
}
// get reference field in super class
// TODO: do not use the superclassfield anymore, just assume that the id is the same in both tables - @see PBroker.storeToDb
int superFieldRef = cld.getSuperClassFieldRef();
FieldDescriptor refField = cld.getFieldDescriptorByIndex(superFieldRef);
appendTable(cldSuper, where);
where.append(".");
appendField(cldSuper.getAutoIncrementFields()[0], where);
where.append(" = ");
appendTable(cld, where);
where.append(".");
appendField(refField, where);
}
}
开发者ID:KualiCo,项目名称:ojb,代码行数:27,代码来源:SqlSelectStatement.java
示例19: getColumnIndex
import org.apache.ojb.broker.metadata.FieldDescriptor; //导入依赖的package包/类
public int getColumnIndex(FieldDescriptor fld)
{
int index = JdbcType.MIN_INT;
FieldDescriptor[] fields = getFieldsForSelect();
if (fields != null)
{
for (int i = 0; i < fields.length; i++)
{
if (fields[i].equals(fld))
{
index = i + 1; // starts at 1
break;
}
}
}
return index;
}
开发者ID:KualiCo,项目名称:ojb,代码行数:18,代码来源:SqlSelectStatement.java
示例20: getFieldDescriptor
import org.apache.ojb.broker.metadata.FieldDescriptor; //导入依赖的package包/类
/**
* Get the FieldDescriptor for the PathInfo
*
* @param aTableAlias
* @param aPathInfo
* @return FieldDescriptor
*/
protected FieldDescriptor getFieldDescriptor(TableAlias aTableAlias, PathInfo aPathInfo)
{
FieldDescriptor fld = null;
String colName = aPathInfo.column;
if (aTableAlias != null)
{
fld = aTableAlias.cld.getFieldDescriptorByName(colName);
if (fld == null)
{
ObjectReferenceDescriptor ord = aTableAlias.cld.getObjectReferenceDescriptorByName(colName);
if (ord != null)
{
fld = getFldFromReference(aTableAlias, ord);
}
else
{
fld = getFldFromJoin(aTableAlias, colName);
}
}
}
return fld;
}
开发者ID:KualiCo,项目名称:ojb,代码行数:32,代码来源:SqlQueryStatement.java
注:本文中的org.apache.ojb.broker.metadata.FieldDescriptor类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论