Package org.apache.ojb.broker.metadata

Examples of org.apache.ojb.broker.metadata.DescriptorRepository


        MetadataManager metaManager = MetadataManager.getInstance();
        RepositoryPersistor persistor = new RepositoryPersistor();
        URL descriptorUrl = getClass().getClassLoader().getResource(repositoryPath);

        logger.info("Merging OJB respository "+descriptorUrl+" for DAO class "+getClass().getName());
        DescriptorRepository repo = persistor.readDescriptorRepository(descriptorUrl.openStream());
        metaManager.mergeDescriptorRepository(repo);
    }
View Full Code Here


        MetadataManager metaManager = MetadataManager.getInstance();
        RepositoryPersistor persistor = new RepositoryPersistor();
        URL descriptorUrl = getClass().getClassLoader().getResource(repositoryPath);

        logger.info("Merging OJB respository "+descriptorUrl+" for DAO class "+getClass().getName());
        DescriptorRepository repo = persistor.readDescriptorRepository(descriptorUrl.openStream());
        metaManager.mergeDescriptorRepository(repo);
    }
View Full Code Here

        if (_fkInfo != null)
        {
            return;
        }

        DescriptorRepository repos = broker.getDescriptorRepository();
        _fkInfo = new HashMap();
        for (Iterator it = repos.iterator(); it.hasNext();)
        {
            ClassDescriptor desc = (ClassDescriptor) it.next();
            List ordList = desc.getObjectReferenceDescriptors();
            if (!ordList.isEmpty())
            {
                HashSet fkTables = getFKTablesFor(desc.getFullTableName());
                for (Iterator it2 = ordList.iterator(); it2.hasNext();)
                {
                    ObjectReferenceDescriptor ord = (ObjectReferenceDescriptor) it2.next();
                    ClassDescriptor oneDesc = repos.getDescriptorFor(ord.getItemClass());
                    fkTables.addAll(getFullTableNames(oneDesc, repos));
                }
            }

            List codList = desc.getCollectionDescriptors();
            for (Iterator it2 = codList.iterator(); it2.hasNext();)
            {
                CollectionDescriptor cod = (CollectionDescriptor) it2.next();
                ClassDescriptor manyDesc = repos.getDescriptorFor(cod.getItemClass());
                if (cod.isMtoNRelation())
                {
                    HashSet fkTables = getFKTablesFor(cod.getIndirectionTable());
                    fkTables.addAll(getFullTableNames(desc, repos));
                    fkTables.addAll(getFullTableNames(manyDesc, repos));
View Full Code Here

       
        try
        {
            MetadataManager      manager  = initOJB();
            Database             dbModel  = readModel();
            DescriptorRepository objModel = manager.getGlobalRepository();

            if (dbModel == null)
            {
                throw new BuildException("No database model specified");
            }
View Full Code Here

            public void run()
            {
                try
                {
                    // RepositoryPersistor persistor = new RepositoryPersistor ();
                    DescriptorRepository repository = new DescriptorRepository();
                    JIFrmOJBRepository frm = new JIFrmOJBRepository(repository);
                    containingFrame.getContentPane().add(frm);
                    frm.setVisible(true);
                }
                catch (Throwable t)
View Full Code Here

     */
    private void insertOrDeleteMtoNImplementor(MtoNImplementor m2nImpl, boolean insert)
            throws PersistenceBrokerException
    {
        //look for a collection descriptor on left  such as left.element-class-ref='right'
        DescriptorRepository dr = pb.getDescriptorRepository();

        Object leftObject = m2nImpl.getLeftObject();
        Class leftClass = m2nImpl.getLeftClass();
        Object rightObject = m2nImpl.getRightObject();
        Class rightClass = m2nImpl.getRightClass();

        //are written per class, maybe referencing abstract classes or interfaces
        //so let's look for collection descriptors on the left class and try to
        // handle extents on teh right class
        ClassDescriptor leftCld = dr.getDescriptorFor(leftClass);
        ClassDescriptor rightCld = dr.getDescriptorFor(rightClass);
        //Vector leftColds = leftCld.getCollectionDescriptors();
        CollectionDescriptor wanted = m2nImpl.getLeftDescriptor();

        if(leftObject == null || rightObject == null)
        {
View Full Code Here

     * Get MultiJoined ClassDescriptors
     * @param cld
     */
    private ClassDescriptor[] getMultiJoinedClassDescriptors(ClassDescriptor cld)
    {
        DescriptorRepository repository = cld.getRepository();
        Class[] multiJoinedClasses = repository.getSubClassesMultipleJoinedTables(cld, true);
        ClassDescriptor[] result = new ClassDescriptor[multiJoinedClasses.length];

        for (int i = 0 ; i < multiJoinedClasses.length; i++)
        {
            result[i] = repository.getDescriptorFor(multiJoinedClasses[i]);
         }

        return result;
    }
View Full Code Here

     * @param cld the ClassDescriptor
     * @return the Fields to be selected
     */
    protected FieldDescriptor[] buildFieldsForSelect(ClassDescriptor cld)
    {
        DescriptorRepository repository = cld.getRepository();
        Set fields = new ListOrderedSet();   // keep the order of the fields
       
        // add Standard Fields
        // MBAIRD: if the object being queried on has multiple classes mapped to the table,
        // then we will get all the fields that are a unique set across all those classes so if we need to
        // we can materialize an extent
        FieldDescriptor fds[] = repository.getFieldDescriptorsForMultiMappedTable(cld);
        for (int i = 0; i < fds.length; i++)
        {
            fields.add(fds[i]);
        }

        // add inherited Fields. This is important when querying for a class having a super-reference
        fds = cld.getFieldDescriptor(true);
        for (int i = 0; i < fds.length; i++)
        {
            fields.add(fds[i]);
        }

        // add Fields of joined subclasses
        Class[] multiJoinedClasses = repository.getSubClassesMultipleJoinedTables(cld, true);
        for (int c = 0; c < multiJoinedClasses.length; c++)
        {
            ClassDescriptor subCld = repository.getDescriptorFor(multiJoinedClasses[c]);
            fds = subCld.getFieldDescriptions();
            for (int i = 0; i < fds.length; i++)
            {
                fields.add(fds[i]);
            }
View Full Code Here

                public void run()
                {
                    try
                    {
                        RepositoryPersistor persistor = new RepositoryPersistor ();
                        DescriptorRepository repository = persistor.readDescriptorRepository(selectedFile.getCanonicalPath());
                        JIFrmOJBRepository frm = new JIFrmOJBRepository(repository);
                        containingFrame.getContentPane().add(frm);
                        frm.setVisible(true);
                    }
                    catch (Throwable t)
View Full Code Here

     * check optional hint. The returned Class is to highest superclass contained in the hint list.
   * TODO: add super ClassDescriptor
   */
    private ClassDescriptor getItemClassDescriptor(ObjectReferenceDescriptor ord, List hintClasses)
    {  
        DescriptorRepository repo = ord.getClassDescriptor().getRepository();

        if (hintClasses == null || hintClasses.isEmpty())
        {
            return repo.getDescriptorFor(ord.getItemClass());
        }
       
        Class resultClass = (Class) hintClasses.get(0);
       
        for (Iterator iter = hintClasses.iterator(); iter.hasNext();)
        {
            Class clazz = (Class) iter.next();
            Class superClazz = clazz.getSuperclass();

            if (superClazz != null && resultClass.equals(superClazz.getSuperclass()))
            {
                continue; // skip if we already have a super superclass
            }
          
            if (hintClasses.contains(superClazz))
            {
                resultClass = superClazz;   // use superclass if it's in the hints
            }
        }

        return repo.getDescriptorFor(resultClass);
    }
View Full Code Here

TOP

Related Classes of org.apache.ojb.broker.metadata.DescriptorRepository

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.