本文整理汇总了Java中org.apache.ojb.broker.metadata.ClassDescriptor.getCollectionDescriptors方法的典型用法代码示例。如果您正苦于以下问题:Java ClassDescriptor.getCollectionDescriptors方法的具体用法?Java ClassDescriptor.getCollectionDescriptors怎么用?Java ClassDescriptor.getCollectionDescriptors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.ojb.broker.metadata.ClassDescriptor
的用法示例。
在下文中一共展示了ClassDescriptor.getCollectionDescriptors方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: 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);
}
}
示例3: cascadeDeleteFor
import org.apache.ojb.broker.metadata.ClassDescriptor; //导入方法依赖的package包/类
/**
* Walk through the object graph of the specified delete object. Was used for
* recursive object graph walk.
*/
private void cascadeDeleteFor(ObjectEnvelope mod, List alreadyPrepared)
{
// avoid endless recursion
if(alreadyPrepared.contains(mod.getIdentity())) return;
alreadyPrepared.add(mod.getIdentity());
ClassDescriptor cld = getTransaction().getBroker().getClassDescriptor(mod.getObject().getClass());
List refs = cld.getObjectReferenceDescriptors(true);
cascadeDeleteSingleReferences(mod, refs, alreadyPrepared);
List colls = cld.getCollectionDescriptors(true);
cascadeDeleteCollectionReferences(mod, colls, alreadyPrepared);
}
示例4: getCustomizedFields
import org.apache.ojb.broker.metadata.ClassDescriptor; //导入方法依赖的package包/类
private Collection<String> getCustomizedFields(String clazz) {
final ClassDescriptor cd = OjbUtil.findClassDescriptor(clazz, descriptorRepositories);
if (cd != null) {
Collection<String> customizedFields = new ArrayList<String>();
for (CollectionDescriptor cld : (Collection<CollectionDescriptor>) cd.getCollectionDescriptors()) {
if (cld.getQueryCustomizer() != null) {
customizedFields.add(cld.getAttributeName());
}
}
return customizedFields;
}
return Collections.emptySet();
}
示例5: isBidirectional
import org.apache.ojb.broker.metadata.ClassDescriptor; //导入方法依赖的package包/类
private boolean isBidirectional(String thisClass, String itemClass) {
final ClassDescriptor cd = OjbUtil.findClassDescriptor(itemClass, descriptorRepositories);
Collection<CollectionDescriptor> clds = cd.getCollectionDescriptors();
if (clds != null) {
for (CollectionDescriptor cld : clds) {
if (cld.getItemClassName().equals(thisClass)) {
return true;
}
}
}
return false;
}
示例6: getMappedBy
import org.apache.ojb.broker.metadata.ClassDescriptor; //导入方法依赖的package包/类
private String getMappedBy(String thisClass, String itemClass) {
final ClassDescriptor cd = OjbUtil.findClassDescriptor(itemClass, descriptorRepositories);
Collection<CollectionDescriptor> clds = cd.getCollectionDescriptors();
if (clds != null) {
for (CollectionDescriptor cld : clds) {
if (cld.getItemClassName().equals(thisClass)) {
return cld.getAttributeName();
}
}
}
return null;
}
示例7: cascadeInsertFor
import org.apache.ojb.broker.metadata.ClassDescriptor; //导入方法依赖的package包/类
/**
* Walk through the object graph of the specified insert object. Was used for
* recursive object graph walk.
*/
private void cascadeInsertFor(ObjectEnvelope mod, List alreadyPrepared)
{
// avoid endless recursion, so use List for registration
if(alreadyPrepared.contains(mod.getIdentity())) return;
alreadyPrepared.add(mod.getIdentity());
ClassDescriptor cld = getTransaction().getBroker().getClassDescriptor(mod.getObject().getClass());
List refs = cld.getObjectReferenceDescriptors(true);
cascadeInsertSingleReferences(mod, refs, alreadyPrepared);
List colls = cld.getCollectionDescriptors(true);
cascadeInsertCollectionReferences(mod, colls, alreadyPrepared);
}
示例8: buildConstraints
import org.apache.ojb.broker.metadata.ClassDescriptor; //导入方法依赖的package包/类
private void buildConstraints(ClassDescriptor cd) {
Vector collectionDescriptors = cd.getCollectionDescriptors();
for (int i = 0; i < collectionDescriptors.size(); i++) {
CollectionDescriptor collectionDescriptor = (CollectionDescriptor) collectionDescriptors.get(i);
if (collectionDescriptor.isMtoNRelation()) {
buildManyToManyConstraints(cd, collectionDescriptor);
} else {
buildOneToManyReferences(cd, collectionDescriptor);
}
}
}
示例9: storeCollections
import org.apache.ojb.broker.metadata.ClassDescriptor; //导入方法依赖的package包/类
/**
* Store/Link collections of objects poiting to <b>obj</b>.
* More info please see comments in source.
*
* @param obj real object which we will store collections for
* @throws PersistenceBrokerException if some goes wrong - please see the error message for details
*/
private void storeCollections(Object obj, ClassDescriptor cld, boolean insert) throws PersistenceBrokerException
{
// get all members of obj that are collections and store all their elements
Collection listCods = cld.getCollectionDescriptors();
// return if nothing to do
if (listCods.size() == 0)
{
return;
}
Iterator i = listCods.iterator();
while (i.hasNext())
{
CollectionDescriptor cod = (CollectionDescriptor) i.next();
// if CASCADE_NONE was set, do nothing with referenced objects
if (cod.getCascadingStore() != ObjectReferenceDescriptor.CASCADE_NONE)
{
Object referencedObjects = cod.getPersistentField().get(obj);
if (cod.isMtoNRelation())
{
storeAndLinkMtoN(false, obj, cod, referencedObjects, insert);
}
else
{
storeAndLinkOneToMany(false, obj, cod, referencedObjects, insert);
}
// BRJ: only when auto-update = object (CASCADE_OBJECT)
//
if ((cod.getCascadingStore() == ObjectReferenceDescriptor.CASCADE_OBJECT)
&& (referencedObjects instanceof ManageableCollection))
{
((ManageableCollection) referencedObjects).afterStore(this);
}
}
}
}
示例10: handleDependentCollections
import org.apache.ojb.broker.metadata.ClassDescriptor; //导入方法依赖的package包/类
/**
* Mark for creation all objects that were included into dependent collections.
* Mark for deletion all objects that were excluded from dependent collections.
*/
private ArrayList handleDependentCollections(Identity oid, Object obj,
Object[] origCollections, Object[] newCollections,
Object[] newCollectionsOfObjects)
throws LockingException
{
ClassDescriptor mif = _pb.getClassDescriptor(obj.getClass());
Collection colDescs = mif.getCollectionDescriptors();
ArrayList newObjects = new ArrayList();
int count = 0;
for (Iterator it = colDescs.iterator(); it.hasNext(); count++)
{
CollectionDescriptor cds = (CollectionDescriptor) it.next();
if (cds.getOtmDependent())
{
ArrayList origList = (origCollections == null ? null
: (ArrayList) origCollections[count]);
ArrayList newList = (ArrayList) newCollections[count];
if (origList != null)
{
for (Iterator it2 = origList.iterator(); it2.hasNext(); )
{
Identity origOid = (Identity) it2.next();
if ((newList == null) || !newList.contains(origOid))
{
markDelete(origOid, oid, true);
}
}
}
if (newList != null)
{
int countElem = 0;
for (Iterator it2 = newList.iterator(); it2.hasNext(); countElem++)
{
Identity newOid = (Identity) it2.next();
if ((origList == null) || !origList.contains(newOid))
{
ContextEntry entry = (ContextEntry) _objects.get(newOid);
if (entry == null)
{
ArrayList relCol = (ArrayList)
newCollectionsOfObjects[count];
Object relObj = relCol.get(countElem);
insertInternal(newOid, relObj, LockType.WRITE_LOCK,
true, null, new Stack());
newObjects.add(newOid);
}
}
}
}
}
}
return newObjects;
}