Package org.apache.ojb.broker.metadata

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


        linkOrUnlink(false, obj, false);
    }

    private void linkOrUnlink(boolean doLink, Object obj, boolean insert)
    {
        ClassDescriptor cld = m_broker.getDescriptorRepository().getDescriptorFor(obj.getClass());

        if (cld.getObjectReferenceDescriptors().size() > 0)
        {
            // never returns null, thus we can direct call iterator
            Iterator descriptors = cld.getObjectReferenceDescriptors().iterator();
            while (descriptors.hasNext())
            {
                ObjectReferenceDescriptor ord = (ObjectReferenceDescriptor) descriptors.next();
                linkOrUnlinkOneToOne(doLink, obj, ord, insert);
            }
        }
        if (cld.getCollectionDescriptors().size() > 0)
        {
            // never returns null, thus we can direct call iterator
            Iterator descriptors = cld.getCollectionDescriptors().iterator();
            while (descriptors.hasNext())
            {
                CollectionDescriptor cod = (CollectionDescriptor) descriptors.next();
                linkOrUnlinkXToMany(doLink, obj, cod, insert);
            }
View Full Code Here


     * @param insert flag signals insert operation
     * @return true if the specified reference was found and linking was successful
     */
    public boolean link(Object obj, String attributeName, Object reference, boolean insert)
    {
        ClassDescriptor cld = m_broker.getDescriptorRepository().getDescriptorFor(ProxyHelper.getRealClass(obj));
        ObjectReferenceDescriptor ord;
        boolean match = false;
        // first look for reference then for collection
        ord = cld.getObjectReferenceDescriptorByName(attributeName);
        if (ord != null)
        {
            linkOrUnlinkOneToOne(true, obj, ord, insert);
            match = true;
        }
        else
        {
            CollectionDescriptor cod = cld.getCollectionDescriptorByName(attributeName);
            if (cod != null)
            {
                linkOrUnlinkXToMany(true, obj, cod, insert);
                match = true;
            }
View Full Code Here

    }

    private boolean linkOrUnlink(boolean doLink, Object obj, String attributeName, boolean insert)
    {
        boolean match = false;
        ClassDescriptor cld = m_broker.getDescriptorRepository().getDescriptorFor(ProxyHelper.getRealClass(obj));
        ObjectReferenceDescriptor ord;

        // first look for reference then for collection
        ord = cld.getObjectReferenceDescriptorByName(attributeName);
        if (ord != null)
        {
            linkOrUnlinkOneToOne(doLink, obj, ord, insert);
            match = true;
        }
        else
        {
            CollectionDescriptor cod = cld.getCollectionDescriptorByName(attributeName);
            if (cod != null)
            {
                linkOrUnlinkXToMany(doLink, obj, cod, insert);
                match = true;
            }
View Full Code Here

        arminw: we need the class-descriptor where the reference is declared, thus we ask the
        reference-descriptor for this, instead of using the class-descriptor of the specified
        object. If the reference was declared within an interface (should never happen) we
        only can use the descriptor of the real class.
        */
        ClassDescriptor cld = ord.getClassDescriptor();
        if(cld.isInterface())
        {
            cld = m_broker.getDescriptorRepository().getDescriptorFor(ProxyHelper.getRealClass(obj));
        }

        if (doLink)
View Full Code Here

        {
            m_broker.deleteMtoNImplementor(new MtoNImplementor(cds, source, referenceToUnlink));
        }
        else
        {
            ClassDescriptor cld = m_broker.getClassDescriptor(referenceToUnlink.getClass());
            m_broker.unlinkFK(referenceToUnlink, cld, cds);
        }
    }
View Full Code Here

        {
            m_broker.addMtoNImplementor(new MtoNImplementor(cds, source, referenceToLink));
        }
        else
        {
            ClassDescriptor cld = m_broker.getClassDescriptor(referenceToLink.getClass());
            m_broker.link(referenceToLink, cld, cds, source, false);
        }
    }
View Full Code Here

    {
        Connection conn = getConnection();

        // Use the OJB SqlGenerator to generate SQL Statements. All details about
        // Table and column names are read from the repository.xml file.
        ClassDescriptor cld = broker.getClassDescriptor(PerformanceArticle.class);
        String sql = broker.serviceSqlGenerator().getPreparedUpdateStatement(cld).getStatement();
        logger.debug("update stmt: " + sql);

        // update all objects
        for(int i = 0; i < articleCount; i++)
View Full Code Here

    {
        TreeMap result = new TreeMap();

        for (Iterator it = model.getDescriptorTable().values().iterator(); it.hasNext();)
        {
            ClassDescriptor classDesc = (ClassDescriptor)it.next();

            if (classDesc.getFullTableName() == null)
            {
                // not mapped to a database table
                continue;
            }

            String elementName        = getElementName(classDesc);
            Table  mappedTable        = getTableFor(elementName);
            Map    columnsMap         = getColumnsFor(elementName);
            Map    requiredAttributes = getRequiredAttributes(elementName);
            List   classDescs         = getClassDescriptorsMappingTo(elementName);

            if (mappedTable == null)
            {
                mappedTable = _schema.findTable(classDesc.getFullTableName());
                if (mappedTable == null)
                {
                    continue;
                }
                columnsMap         = new TreeMap();
View Full Code Here

        HashMap indirectionTables = new HashMap();

        // first we gather all participants for each m:n relationship
        for (Iterator classDescIt = model.getDescriptorTable().values().iterator(); classDescIt.hasNext();)
        {
            ClassDescriptor classDesc = (ClassDescriptor)classDescIt.next();

            for (Iterator collDescIt = classDesc.getCollectionDescriptors().iterator(); collDescIt.hasNext();)
            {
                CollectionDescriptor collDesc   = (CollectionDescriptor)collDescIt.next();
                String               indirTable = collDesc.getIndirectionTable();

                if ((indirTable != null) && (indirTable.length() > 0))
                {
                    Set columns = (Set)indirectionTables.get(indirTable);

                    if (columns == null)
                    {
                        columns = new HashSet();
                        indirectionTables.put(indirTable, columns);
                    }
                    columns.addAll(Arrays.asList(collDesc.getFksToThisClass()));
                    columns.addAll(Arrays.asList(collDesc.getFksToItemClass()));
                }
            }
        }
        if (indirectionTables.isEmpty())
        {
            // nothing to do
            return;
        }

        for (Iterator it = indirectionTables.keySet().iterator(); it.hasNext();)
        {
            String tableName   = (String)it.next();
            Set    columns     = (Set)indirectionTables.get(tableName);
            String elementName = tableName;

            for (Iterator classDescIt = model.getDescriptorTable().values().iterator(); classDescIt.hasNext();)
            {
                ClassDescriptor classDesc = (ClassDescriptor)classDescIt.next();

                if (tableName.equals(classDesc.getFullTableName()))
                {
                    elementName = getElementName(classDesc);

                    FieldDescriptor[] fieldDescs = classDesc.getFieldDescriptions();

                    if (fieldDescs != null)
                    {
                        for (int idx = 0; idx < fieldDescs.length; idx++)
                        {
View Full Code Here

    public void testSerializedObjectsRefreshWithProxy()
    {
        String prefix = "testSerializedObjectsRefreshWithProxy_" + System.currentTimeMillis() + "_";

        ClassDescriptor cld = broker.getClassDescriptor(ObjectRepository.Component.class);
        ObjectReferenceDescriptor ord = cld.getObjectReferenceDescriptorByName("parentComponent");
        boolean oldState = ord.isLazy();
        try
        {
            ord.setLazy(true);
            ObjectRepository.ComponentIF parent = new ObjectRepository.Component();
View Full Code Here

TOP

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

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.