本文整理汇总了Java中org.apache.ojb.broker.metadata.ClassDescriptor类的典型用法代码示例。如果您正苦于以下问题:Java ClassDescriptor类的具体用法?Java ClassDescriptor怎么用?Java ClassDescriptor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ClassDescriptor类属于org.apache.ojb.broker.metadata包,在下文中一共展示了ClassDescriptor类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: refreshAllNonUpdatingReferences
import org.apache.ojb.broker.metadata.ClassDescriptor; //导入依赖的package包/类
/**
*
* @see org.kuali.rice.krad.service.PersistenceService#refreshAllNonUpdatingReferences(org.kuali.rice.krad.bo.BusinessObject)
*/
@Override
public void refreshAllNonUpdatingReferences(PersistableBusinessObject bo) {
// get the OJB class-descriptor for the bo class
ClassDescriptor classDescriptor = getClassDescriptor(bo.getClass());
// get a list of all reference-descriptors for that class
Vector references = classDescriptor.getObjectReferenceDescriptors();
// walk through all of the reference-descriptors
for (Iterator iter = references.iterator(); iter.hasNext();) {
ObjectReferenceDescriptor reference = (ObjectReferenceDescriptor) iter.next();
// if its NOT an updateable reference, then lets refresh it
if (reference.getCascadingStore() == ObjectReferenceDescriptor.CASCADE_NONE) {
PersistentField persistentField = reference.getPersistentField();
String referenceName = persistentField.getName();
retrieveReferenceObject(bo, referenceName);
}
}
}
开发者ID:kuali,项目名称:kc-rice,代码行数:26,代码来源:PersistenceServiceOjbImpl.java
示例2: getReferenceFKValue
import org.apache.ojb.broker.metadata.ClassDescriptor; //导入依赖的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
示例3: getClassDescriptor
import org.apache.ojb.broker.metadata.ClassDescriptor; //导入依赖的package包/类
/**
* @param persistableClass
* @return ClassDescriptor for the given Class
* @throws IllegalArgumentException
* if the given Class is null
* @throws ClassNotPersistableException
* if the given Class is unknown to OJB
*/
// Legacy OJB - no need for JPA equivalent
protected ClassDescriptor getClassDescriptor(Class persistableClass) {
if (persistableClass == null) {
throw new IllegalArgumentException("invalid (null) object");
}
ClassDescriptor classDescriptor = null;
DescriptorRepository globalRepository = getDescriptorRepository();
try {
classDescriptor = globalRepository.getDescriptorFor(persistableClass);
} catch (ClassNotPersistenceCapableException e) {
throw new ClassNotPersistableException("class '" + persistableClass.getName() + "' is not persistable", e);
}
return classDescriptor;
}
开发者ID:kuali,项目名称:kc-rice,代码行数:25,代码来源:PersistenceServiceStructureImplBase.java
示例4: listPersistableSubclasses
import org.apache.ojb.broker.metadata.ClassDescriptor; //导入依赖的package包/类
/**
* @see org.kuali.rice.krad.service.PersistenceMetadataExplorerService#listPersistableSubclasses(java.lang.Class)
*/
// Unit tests only
@Override
public List listPersistableSubclasses(Class superclazz) {
if (superclazz == null) {
throw new IllegalArgumentException("invalid (null) uberclass");
}
Map allDescriptors = getDescriptorRepository().getDescriptorTable();
List persistableSubclasses = new ArrayList();
for (Iterator i = allDescriptors.entrySet().iterator(); i.hasNext();) {
Map.Entry e = (Map.Entry) i.next();
Class persistableClass = ((ClassDescriptor) e.getValue()).getClassOfObject();
if (!superclazz.equals(persistableClass) && superclazz.isAssignableFrom(persistableClass)) {
persistableSubclasses.add(persistableClass);
}
}
return persistableSubclasses;
}
开发者ID:kuali,项目名称:kc-rice,代码行数:24,代码来源:PersistenceStructureServiceOjbImpl.java
示例5: getForeignKeyFieldName
import org.apache.ojb.broker.metadata.ClassDescriptor; //导入依赖的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
示例6: getReferencesForForeignKey
import org.apache.ojb.broker.metadata.ClassDescriptor; //导入依赖的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
示例7: getNestedForeignKeyMap
import org.apache.ojb.broker.metadata.ClassDescriptor; //导入依赖的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
示例8: listReferenceObjectFields
import org.apache.ojb.broker.metadata.ClassDescriptor; //导入依赖的package包/类
/**
* @see org.kuali.rice.krad.service.PersistenceStructureService#listReferenceObjectFieldNames(java.lang.Class)
*/
@Override
public Map<String, Class> listReferenceObjectFields(Class boClass) {
// validate parameter
if (boClass == null) {
throw new IllegalArgumentException("Class specified in the parameter was null.");
}
Map<String, Class> references = new HashMap<String, Class>();
ClassDescriptor classDescriptor = getClassDescriptor(boClass);
Collection<ObjectReferenceDescriptor> referenceDescriptors = classDescriptor.getObjectReferenceDescriptors(true);
for (ObjectReferenceDescriptor referenceDescriptor : referenceDescriptors) {
/*
* Below check is performed for OJB specific inheritance implementation. For more information see the OJB
* documentation: http://db.apache.org/ojb/docu/guides/advanced-technique.html#table-per-subclass
*/
String superReferenceDescriptor = referenceDescriptor.getAttributeName();
if (!SuperReferenceDescriptor.SUPER_FIELD_INTERNAL_NAME.equals(superReferenceDescriptor)) {
references.put(superReferenceDescriptor, referenceDescriptor.getItemClass());
}
}
return references;
}
开发者ID:kuali,项目名称:kc-rice,代码行数:29,代码来源:PersistenceStructureServiceOjbImpl.java
示例9: listCollectionObjectTypes
import org.apache.ojb.broker.metadata.ClassDescriptor; //导入依赖的package包/类
@Override
public Map<String, Class> listCollectionObjectTypes(Class boClass) {
if (boClass == null) {
throw new IllegalArgumentException("Class specified in the parameter was null.");
}
Map<String, Class> references = new HashMap<String, Class>();
ClassDescriptor classDescriptor = null;
try {
classDescriptor = getClassDescriptor(boClass);
} catch (ClassNotPersistableException cnpe) {
return references;
}
Collection<CollectionDescriptor> collectionDescriptors = classDescriptor.getCollectionDescriptors(true);
for (CollectionDescriptor collectionDescriptor : collectionDescriptors) {
references.put(collectionDescriptor.getAttributeName(), collectionDescriptor.getItemClass());
}
return references;
}
开发者ID:kuali,项目名称:kc-rice,代码行数:22,代码来源:PersistenceStructureServiceOjbImpl.java
示例10: 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
示例11: resolve
import org.apache.ojb.broker.metadata.ClassDescriptor; //导入依赖的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 String pckg = ((CompilationUnit) dclr.getParentNode()).getPackage().getName().toString();
final String enclosingClass = pckg + "." + name;
final ClassDescriptor cd = OjbUtil.findClassDescriptor(enclosingClass, descriptorRepositories);
if (cd != null) {
return new NodeData(new MarkerAnnotationExpr(new NameExpr(SIMPLE_NAME)),
new ImportDeclaration(new QualifiedNameExpr(new NameExpr(PACKAGE), SIMPLE_NAME), false, false));
}
return null;
}
开发者ID:kuali,项目名称:kc-rice,代码行数:25,代码来源:EntityResolver.java
示例12: getMappedTree
import org.apache.ojb.broker.metadata.ClassDescriptor; //导入依赖的package包/类
private static void getMappedTree(String rootClass, Collection<DescriptorRepository> descriptorRepositories, Set<String> processed) {
if (processed.contains(rootClass)) {
return;
}
processed.add(rootClass);
final ClassDescriptor cd = findClassDescriptor(rootClass, descriptorRepositories);
if (cd != null) {
final Collection<ObjectReferenceDescriptor> ords = cd.getObjectReferenceDescriptors();
if (ords != null) {
for (ObjectReferenceDescriptor ord : ords) {
getMappedTree(ord.getItemClassName(), descriptorRepositories, processed);
}
}
final Collection<CollectionDescriptor> clds = cd.getCollectionDescriptors();
if (clds != null) {
for (ObjectReferenceDescriptor cld : clds) {
getMappedTree(cld.getItemClassName(), descriptorRepositories, processed);
}
}
} else {
LOG.warn("ClassDescriptor not found for " + rootClass);
}
}
开发者ID:kuali,项目名称:kc-rice,代码行数:27,代码来源:OjbUtil.java
示例13: getPreparedExistsStatement
import org.apache.ojb.broker.metadata.ClassDescriptor; //导入依赖的package包/类
public SqlStatement getPreparedExistsStatement(ClassDescriptor cld)
{
SqlStatement sql;
SqlForClass sfc = getSqlForClass(cld);
sql = sfc.getSelectExists();
if(sql == null)
{
// TODO: Should we support a procedure call for this too??
sql = new SqlExistStatement(cld, logger);
// set the sql string
sfc.setSelectExists(sql);
if(logger.isDebugEnabled())
{
logger.debug("SQL:" + sql.getStatement());
}
}
return sql;
}
开发者ID:KualiCo,项目名称:ojb,代码行数:19,代码来源:SqlGeneratorDefaultImpl.java
示例14: asSQLClause
import org.apache.ojb.broker.metadata.ClassDescriptor; //导入依赖的package包/类
/**
* Answer the SQL-Clause for a SelectionCriteria
*
* @param c SelectionCriteria
* @param cld ClassDescriptor
*/
protected String asSQLClause(SelectionCriteria c, ClassDescriptor cld)
{
if (c instanceof FieldCriteria)
return toSQLClause((FieldCriteria) c, cld);
if (c instanceof NullCriteria)
return toSQLClause((NullCriteria) c);
if (c instanceof BetweenCriteria)
return toSQLClause((BetweenCriteria) c, cld);
if (c instanceof InCriteria)
return toSQLClause((InCriteria) c);
if (c instanceof SqlCriteria)
return toSQLClause((SqlCriteria) c);
if (c instanceof ExistsCriteria)
return toSQLClause((ExistsCriteria) c, cld);
return toSQLClause(c, cld);
}
开发者ID:KualiCo,项目名称:ojb,代码行数:29,代码来源:SqlGeneratorDefaultImpl.java
示例15: buildNextSequence
import org.apache.ojb.broker.metadata.ClassDescriptor; //导入依赖的package包/类
/**
* Calls the stored procedure stored procedure throws an
* error if it doesn't exist.
* @param broker
* @param cld
* @param sequenceName
* @return
* @throws LookupException
* @throws SQLException
*/
protected long buildNextSequence(PersistenceBroker broker, ClassDescriptor cld, String sequenceName)
throws LookupException, SQLException, PlatformException
{
CallableStatement cs = null;
try
{
Connection con = broker.serviceConnectionManager().getConnection();
cs = getPlatform().prepareNextValProcedureStatement(con, PROCEDURE_NAME, sequenceName);
cs.executeUpdate();
return cs.getLong(1);
}
finally
{
try
{
if (cs != null)
cs.close();
}
catch (SQLException ignore)
{
// ignore it
}
}
}
开发者ID:KualiCo,项目名称:ojb,代码行数:35,代码来源:SequenceManagerStoredProcedureImpl.java
示例16: afterLoading
import org.apache.ojb.broker.metadata.ClassDescriptor; //导入依赖的package包/类
/**
* Remove colProxy from list of pending collections and
* register its contents with the transaction.
*/
public void afterLoading(CollectionProxyDefaultImpl colProxy)
{
if (log.isDebugEnabled()) log.debug("loading a proxied collection a collection: " + colProxy);
Collection data = colProxy.getData();
for (Iterator iterator = data.iterator(); iterator.hasNext();)
{
Object o = iterator.next();
if(!isOpen())
{
log.error("Collection proxy materialization outside of a running tx, obj=" + o);
try{throw new Exception("Collection proxy materialization outside of a running tx, obj=" + o);}
catch(Exception e)
{e.printStackTrace();}
}
else
{
Identity oid = getBroker().serviceIdentity().buildIdentity(o);
ClassDescriptor cld = getBroker().getClassDescriptor(ProxyHelper.getRealClass(o));
RuntimeObject rt = new RuntimeObject(o, oid, cld, false, ProxyHelper.isProxy(o));
lockAndRegister(rt, Transaction.READ, isImplicitLocking(), getRegistrationList());
}
}
unregisterFromCollectionProxy(colProxy);
}
开发者ID:KualiCo,项目名称:ojb,代码行数:29,代码来源:TransactionImpl.java
示例17: buildObjectImage
import org.apache.ojb.broker.metadata.ClassDescriptor; //导入依赖的package包/类
/**
* buildObjectImage() will return the image of the Object.
*/
private Map buildObjectImage(PersistenceBroker broker) throws PersistenceBrokerException
{
Map imageMap = new HashMap();
ClassDescriptor cld = broker.getClassDescriptor(getObject().getClass());
//System.out.println("++++ build image: " + getObject());
// register 1:1 references in image
buildImageForSingleReferences(imageMap, cld);
// put object values to image map
buildImageForFields(imageMap, cld);
// register 1:n and m:n references in image
buildImageForCollectionReferences(imageMap, cld);
return imageMap;
}
开发者ID:KualiCo,项目名称:ojb,代码行数:17,代码来源:ObjectEnvelope.java
示例18: link
import org.apache.ojb.broker.metadata.ClassDescriptor; //导入依赖的package包/类
/**
* Assign FK value to target object by reading PK values of referenced object.
*
* @param targetObject real (non-proxy) target object
* @param cld {@link ClassDescriptor} of the real target object
* @param rds An {@link ObjectReferenceDescriptor} or {@link CollectionDescriptor}
* associated with the real object.
* @param referencedObject referenced object or proxy
* @param insert Show if "linking" is done while insert or update.
*/
public void link(Object targetObject, ClassDescriptor cld, ObjectReferenceDescriptor rds, Object referencedObject, boolean insert)
{
// MBAIRD: we have 'disassociated' this object from the referenced object,
// the object represented by the reference descriptor is now null, so set
// the fk in the target object to null.
// arminw: if an insert was done and ref object was null, we should allow
// to pass FK fields of main object (maybe only the FK fields are set)
if (referencedObject == null)
{
/*
arminw:
if update we set FK fields to 'null', because reference was disassociated
We do nothing on insert, maybe only the FK fields of main object (without
materialization of the reference object) are set by the user
*/
if(!insert)
{
unlinkFK(targetObject, cld, rds);
}
}
else
{
setFKField(targetObject, cld, rds, referencedObject);
}
}
开发者ID:KualiCo,项目名称:ojb,代码行数:36,代码来源:PersistenceBrokerImpl.java
示例19: getClassDescriptor
import org.apache.ojb.broker.metadata.ClassDescriptor; //导入依赖的package包/类
/**
* Returns the OJB class descriptor
*
* @param <E> an origin entry class
* @param persistableClass the class
* @return the class descriptor
*/
protected <E extends OriginEntryFull> ClassDescriptor getClassDescriptor(Class<E> persistableClass) {
if (persistableClass == null) {
throw new IllegalArgumentException("invalid (null) object");
}
ClassDescriptor classDescriptor = null;
DescriptorRepository globalRepository = getDescriptorRepository();
try {
classDescriptor = globalRepository.getDescriptorFor(persistableClass);
}
catch (ClassNotPersistenceCapableException e) {
throw new ClassNotPersistableException("class '" + persistableClass.getName() + "' is not persistable", e);
}
return classDescriptor;
}
开发者ID:kuali,项目名称:kfs,代码行数:24,代码来源:ReconciliationDaoOjb.java
示例20: getIsolationLevel
import org.apache.ojb.broker.metadata.ClassDescriptor; //导入依赖的package包/类
/**
* determines the isolationlevel of class c by evaluating
* the ClassDescriptor of obj.getClass().
*
* @return int the isolationlevel
*/
public static int getIsolationLevel(Object obj)
{
Class c = ProxyHelper.getRealClass(obj);
int isolationLevel = IsolationLevels.IL_READ_UNCOMMITTED;
try
{
ClassDescriptor cld = TxManagerFactory.instance().getCurrentTransaction().getBroker().getClassDescriptor(c);
isolationLevel = cld.getIsolationLevel();
}
catch (PersistenceBrokerException e)
{
LoggerFactory.getDefaultLogger().error("[LockStrategyFactory] Can't detect locking isolation level", e);
}
return isolationLevel;
}
开发者ID:KualiCo,项目名称:ojb,代码行数:23,代码来源:LockStrategyFactory.java
注:本文中的org.apache.ojb.broker.metadata.ClassDescriptor类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论