Package xdoclet.modules.ojb.model

Examples of xdoclet.modules.ojb.model.ClassDescriptorDef


     * @return The collection that uses the field or <code>null</code> if the field is not
     *         used in this way
     */
    private CollectionDescriptorDef usedByCollection(ModelDef modelDef, FieldDescriptorDef fieldDef, boolean elementClassSuffices)
    {
        ClassDescriptorDef      ownerClass = (ClassDescriptorDef)fieldDef.getOwner();
        String                  name       = fieldDef.getName();
        ClassDescriptorDef      classDef;
        CollectionDescriptorDef collDef;

        for (Iterator classIt = modelDef.getClasses(); classIt.hasNext();)
        {
            classDef = (ClassDescriptorDef)classIt.next();
            for (Iterator collIt = classDef.getCollections(); collIt.hasNext();)
            {
                collDef = (CollectionDescriptorDef)collIt.next();
                // if the owner class of the field is the element class of a normal collection
                // and the field is a foreignkey of this collection
                if (ownerClass.getName().equals(collDef.getProperty(PropertyHelper.OJB_PROPERTY_ELEMENT_CLASS_REF)))
View Full Code Here


     * @return The reference that uses the field or <code>null</code> if the field is not used in this way
     */
    private ReferenceDescriptorDef usedByReference(ModelDef modelDef, FieldDescriptorDef fieldDef)
    {
        String                 ownerClassName = fieldDef.getOwner().getName();
        ClassDescriptorDef     classDef;
        ReferenceDescriptorDef refDef;

        // only relevant for primarykey fields
        if (PropertyHelper.toBoolean(fieldDef.getProperty(PropertyHelper.OJB_PROPERTY_PRIMARYKEY), false))
        {
            for (Iterator classIt = modelDef.getClasses(); classIt.hasNext();)
            {
                classDef = (ClassDescriptorDef)classIt.next();
                for (Iterator refIt = classDef.getReferences(); refIt.hasNext();)
                {
                    refDef = (ReferenceDescriptorDef)refIt.next();
                    if (ownerClassName.equals(refDef.getProperty(PropertyHelper.OJB_PROPERTY_CLASS_REF)))
                    {
                        // the field is a primary key of the class referenced by this reference descriptor
View Full Code Here

                throw new ConstraintException("Reference "+refDef.getName()+" in class "+refDef.getOwner().getName()+" does not reference any class");
            }
        }

        // now checking the type
        ClassDescriptorDef ownerClassDef   = (ClassDescriptorDef)refDef.getOwner();
        ModelDef           model           = (ModelDef)ownerClassDef.getOwner();
        String             targetClassName = refDef.getProperty(PropertyHelper.OJB_PROPERTY_CLASS_REF);
        ClassDescriptorDef targetClassDef  = model.getClass(targetClassName);
       
        if (targetClassDef == null)
        {
            throw new ConstraintException("The class "+targetClassName+" referenced by "+refDef.getName()+" in class "+ownerClassDef.getName()+" is unknown or not persistent");
        }
        if (!targetClassDef.getBooleanProperty(PropertyHelper.OJB_PROPERTY_OJB_PERSISTENT, false))
        {
            throw new ConstraintException("The class "+targetClassName+" referenced by "+refDef.getName()+" in class "+ownerClassDef.getName()+" is not persistent");
        }
       
        if (CHECKLEVEL_STRICT.equals(checkLevel))
        {
            try
            {
                InheritanceHelper helper = new InheritanceHelper();

                if (refDef.isAnonymous())
                {
                    // anonymous reference: class must be a baseclass of the owner class
                    if (!helper.isSameOrSubTypeOf(ownerClassDef, targetClassDef.getName(), true))
                    {
                        throw new ConstraintException("The class "+targetClassName+" referenced by the anonymous reference "+refDef.getName()+" in class "+ownerClassDef.getName()+" is not a basetype of the class");
                    }
                }
                else
View Full Code Here

TOP

Related Classes of xdoclet.modules.ojb.model.ClassDescriptorDef

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.