Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/**********************************************************************
Copyright (c) 2009 Stefan Seelmann and others. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Contributors :
...
***********************************************************************/
package org.datanucleus.store.ldap.fieldmanager;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import javax.naming.directory.Attributes;
import javax.naming.ldap.LdapName;
import org.datanucleus.ClassLoaderResolver;
import org.datanucleus.exceptions.NucleusException;
import org.datanucleus.metadata.AbstractClassMetaData;
import org.datanucleus.metadata.AbstractMemberMetaData;
import org.datanucleus.metadata.MetaDataManager;
import org.datanucleus.metadata.RelationType;
import org.datanucleus.state.ObjectProvider;
import org.datanucleus.store.ldap.LDAPUtils;
import org.datanucleus.store.ldap.LDAPUtils.LocationInfo;
import org.datanucleus.store.types.SCOUtils;
import org.datanucleus.util.ClassUtils;
import org.datanucleus.store.StoreManager;
/**
* Mapping strategy for hierarchical mapping of relationships.
*/
public class RelationByHierarchyStrategy extends AbstractMappingStrategy
{
protected int fieldNumber;
protected StoreManager storeMgr;
protected ClassLoaderResolver clr;
protected AbstractClassMetaData effectiveClassMetaData;
protected boolean isFieldHierarchicalMapped;
protected boolean isFieldParentOfHierarchicalMapping;
protected RelationByHierarchyStrategy(StoreManager storeMgr, ObjectProvider op, AbstractMemberMetaData mmd, Attributes attributes)
{
super(op, mmd, attributes);
this.fieldNumber = mmd.getAbsoluteFieldNumber();
this.storeMgr = storeMgr;
this.clr = ec.getClassLoaderResolver();
this.effectiveClassMetaData = LDAPUtils.getEffectiveClassMetaData(mmd, ec.getMetaDataManager());
this.isFieldHierarchicalMapped = isChildOfHierarchicalMapping(mmd, ec.getMetaDataManager());
this.isFieldParentOfHierarchicalMapping = isParentOfHierarchicalMapping(mmd, ec.getMetaDataManager());
}
public Object fetch()
{
if (isFieldHierarchicalMapped)
{
RelationType relType = mmd.getRelationType(clr);
if (RelationType.isRelationSingleValued(relType))
{
// hierarchical mapped one-one relationships are always dependent!
mmd.setDependent(true);
return getHierarchicalMappedChild(mmd, op);
}
else if (relType == RelationType.ONE_TO_MANY_UNI || relType == RelationType.ONE_TO_MANY_BI)
{
if (mmd.hasCollection())
{
Collection