Package xdoclet.modules.ojb

Examples of xdoclet.modules.ojb.CommaListIterator


        String             token;
        String             fieldName;
        String             ordering;
        int                pos;

        for (CommaListIterator it = new CommaListIterator(orderbySpec); it.hasNext();)
        {
            token = it.getNext();
            pos   = token.indexOf('=');
            if (pos == -1)
            {
                fieldName = token;
                ordering  = null;
View Full Code Here


                        if (elementClassSuffices)
                        {
                            return collDef;
                        }
                    }
                    else if (new CommaListIterator(collDef.getProperty(PropertyHelper.OJB_PROPERTY_FOREIGNKEY)).contains(name))
                    {
                        // if the field is a foreignkey of this normal 1:n collection
                        return collDef;
                    }
                }
View Full Code Here

        ClassDescriptorDef elementClassDef  = ((ModelDef)ownerClassDef.getOwner()).getClass(collDef.getProperty(PropertyHelper.OJB_PROPERTY_ELEMENT_CLASS_REF));
        ArrayList          localPrimFields  = ownerClassDef.getPrimaryKeys();
        ArrayList          remotePrimFields = elementClassDef.getPrimaryKeys();
        String             ownerTable       = ownerClassDef.getProperty(PropertyHelper.OJB_PROPERTY_TABLE);
        String             elementTable     = elementClassDef.getProperty(PropertyHelper.OJB_PROPERTY_TABLE);
        CommaListIterator  localKeys        = new CommaListIterator(collDef.getProperty(PropertyHelper.OJB_PROPERTY_FOREIGNKEY));
        CommaListIterator  remoteKeys       = new CommaListIterator(collDef.getProperty(PropertyHelper.OJB_PROPERTY_REMOTE_FOREIGNKEY));
        FieldDescriptorDef fieldDef;
        ForeignkeyDef      foreignkey       = null;
        ColumnDef          columnDef;
        String             relationName;
        String             name;
        int                idx;

        relationName = collDef.getProperty(PropertyHelper.TORQUE_PROPERTY_RELATION_NAME);
        if (relationName != null)
        {   
            foreignkey   = tableDef.getForeignkey(relationName, ownerTable);
            if (foreignkey == null)
            {
                foreignkey = new ForeignkeyDef(relationName, ownerTable);
                tableDef.addForeignkey(foreignkey);
            }
        }
        for (idx = 0; localKeys.hasNext(); idx++)
        {
            fieldDef  = (FieldDescriptorDef)localPrimFields.get(idx);
            name      = localKeys.getNext();

            columnDef = tableDef.getColumn(name);
            if (columnDef == null)
            {
                columnDef = new ColumnDef(name);
                tableDef.addColumn(columnDef);
            }
            columnDef.setProperty(PropertyHelper.TORQUE_PROPERTY_TYPE, fieldDef.getProperty(PropertyHelper.OJB_PROPERTY_JDBC_TYPE));
            columnDef.setProperty(PropertyHelper.TORQUE_PROPERTY_SIZE, fieldDef.getSizeConstraint());

            if (foreignkey != null)
            {   
                foreignkey.addColumnPair(name, fieldDef.getProperty(PropertyHelper.OJB_PROPERTY_COLUMN));
            }
        }

        relationName = collDef.getProperty(PropertyHelper.TORQUE_PROPERTY_INV_RELATION_NAME);
        if (relationName != null)
        {   
            foreignkey   = tableDef.getForeignkey(relationName, elementTable);
            if (foreignkey == null)
            {
                foreignkey = new ForeignkeyDef(relationName, elementTable);
                tableDef.addForeignkey(foreignkey);
            }
        }
        for (idx = 0; remoteKeys.hasNext(); idx++)
        {
            fieldDef  = (FieldDescriptorDef)remotePrimFields.get(idx);
            name      = remoteKeys.getNext();

            columnDef = tableDef.getColumn(name);
            if (columnDef == null)
            {
                columnDef = new ColumnDef(name);
View Full Code Here

                if (classDef.getField(fieldName) == null)
                {
                    throw new ConstraintException("The "+type+"-procedure "+name+" in class "+classDef.getName()+" references an unknown or non-persistent return field "+fieldName);
                }
            }
            for (CommaListIterator argIt = new CommaListIterator(procDef.getProperty(PropertyHelper.OJB_PROPERTY_ARGUMENTS)); argIt.hasNext();)
            {
                argName = argIt.getNext();
                if (classDef.getProcedureArgument(argName) == null)
                {
                    throw new ConstraintException("The "+type+"-procedure "+name+" in class "+classDef.getName()+" references an unknown argument "+argName);
                }
            }
View Full Code Here

            copyRefDef.setNested();

            // we have to modify the foreignkey setting as it specifies a field of the same (nested) class
            newForeignkey = new StringBuffer();

            for (CommaListIterator it = new CommaListIterator(copyRefDef.getProperty(PropertyHelper.OJB_PROPERTY_FOREIGNKEY)); it.hasNext();)
            {
                if (newForeignkey.length() > 0)
                {
                    newForeignkey.append(",");
                }
                newForeignkey.append(prefix);
                newForeignkey.append(it.next());
            }
            copyRefDef.setProperty(PropertyHelper.OJB_PROPERTY_FOREIGNKEY, newForeignkey.toString());
            newReferences.add(copyRefDef);
        }
        for (Iterator collIt = nestedClassDef.getCollections(); collIt.hasNext();)
View Full Code Here

    {
        ArrayList          result    = new ArrayList();
        FieldDescriptorDef fieldDef;
        String             name;

        for (CommaListIterator it = new CommaListIterator(fieldNames); it.hasNext();)
        {
            name = it.getNext();
            fieldDef = getField(name);
            if (fieldDef == null)
            {
                throw new NoSuchFieldException(name);
            }
View Full Code Here

        String             token;
        String             fieldName;
        String             ordering;
        int                pos;

        for (CommaListIterator it = new CommaListIterator(orderbySpec); it.hasNext();)
        {
            token = it.getNext();
            pos   = token.indexOf('=');
            if (pos == -1)
            {
                fieldName = token;
                ordering  = null;
View Full Code Here

        ArrayList          remotePrimFields = elementClassDef.getPrimaryKeys();
        String             localKeyList     = collDef.getProperty(PropertyHelper.OJB_PROPERTY_FOREIGNKEY);
        String             remoteKeyList    = collDef.getProperty(PropertyHelper.OJB_PROPERTY_REMOTE_FOREIGNKEY);
        String             ownerTable       = getTargetTable(ownerClassDef, tableName, localKeyList);
        String             elementTable     = getTargetTable(elementClassDef, tableName, remoteKeyList);
        CommaListIterator  localKeys        = new CommaListIterator(localKeyList);
        CommaListIterator  localKeyDocs     = new CommaListIterator(collDef.getProperty(PropertyHelper.OJB_PROPERTY_FOREIGNKEY_DOCUMENTATION));
        CommaListIterator  remoteKeys       = new CommaListIterator(remoteKeyList);
        CommaListIterator  remoteKeyDocs    = new CommaListIterator(collDef.getProperty(PropertyHelper.OJB_PROPERTY_REMOTE_FOREIGNKEY_DOCUMENTATION));
        ArrayList          localColumns     = new ArrayList();
        ArrayList          remoteColumns    = new ArrayList();
        boolean            asPrimarykeys    = collDef.getBooleanProperty(PropertyHelper.OJB_PROPERTY_INDIRECTION_TABLE_PRIMARYKEYS, false);
        FieldDescriptorDef fieldDef;
        ColumnDef          columnDef;
        String             relationName;
        String             name;
        int                idx;

        for (idx = 0; localKeys.hasNext(); idx++)
        {
            fieldDef  = (FieldDescriptorDef)localPrimFields.get(idx);
            name      = localKeys.getNext();
            columnDef = tableDef.getColumn(name);
            if (columnDef == null)
            {
                columnDef = new ColumnDef(name);
                tableDef.addColumn(columnDef);
            }
            columnDef.setProperty(PropertyHelper.TORQUE_PROPERTY_TYPE, fieldDef.getProperty(PropertyHelper.OJB_PROPERTY_JDBC_TYPE));
            columnDef.setProperty(PropertyHelper.TORQUE_PROPERTY_SIZE, fieldDef.getSizeConstraint());
            if (asPrimarykeys)
            {
                columnDef.setProperty(PropertyHelper.TORQUE_PROPERTY_PRIMARYKEY, "true");
            }
            if (localKeyDocs.hasNext())
            {
                columnDef.setProperty(PropertyHelper.OJB_PROPERTY_COLUMN_DOCUMENTATION, localKeyDocs.getNext());
            }
            localColumns.add(name);
            remoteColumns.add(fieldDef.getProperty(PropertyHelper.OJB_PROPERTY_COLUMN));
        }
        if (collDef.getBooleanProperty(PropertyHelper.OJB_PROPERTY_DATABASE_FOREIGNKEY, true))
        {
            relationName = collDef.getProperty(PropertyHelper.TORQUE_PROPERTY_RELATION_NAME);
            if ((relationName != null) && (ownerTable != null))
            {
                tableDef.addForeignkey(relationName, ownerTable, localColumns, remoteColumns);
            }
        }
        localColumns.clear();
        remoteColumns.clear();

        for (idx = 0; remoteKeys.hasNext(); idx++)
        {
            fieldDef  = (FieldDescriptorDef)remotePrimFields.get(idx);
            name      = remoteKeys.getNext();

            columnDef = tableDef.getColumn(name);
            if (columnDef == null)
            {
                columnDef = new ColumnDef(name);
                tableDef.addColumn(columnDef);
            }
            columnDef.setProperty(PropertyHelper.TORQUE_PROPERTY_TYPE, fieldDef.getProperty(PropertyHelper.OJB_PROPERTY_JDBC_TYPE));
            columnDef.setProperty(PropertyHelper.TORQUE_PROPERTY_SIZE, fieldDef.getSizeConstraint());
            if (asPrimarykeys)
            {
                columnDef.setProperty(PropertyHelper.TORQUE_PROPERTY_PRIMARYKEY, "true");
            }
            if (remoteKeyDocs.hasNext())
            {
                columnDef.setProperty(PropertyHelper.OJB_PROPERTY_COLUMN_DOCUMENTATION, remoteKeyDocs.getNext());
            }
            localColumns.add(name);
            remoteColumns.add(fieldDef.getProperty(PropertyHelper.OJB_PROPERTY_COLUMN));
        }
View Full Code Here

                if (classDef.getField(fieldName) == null)
                {
                    throw new ConstraintException("The "+type+"-procedure "+name+" in class "+classDef.getName()+" references an unknown or non-persistent return field "+fieldName);
                }
            }
            for (CommaListIterator argIt = new CommaListIterator(procDef.getProperty(PropertyHelper.OJB_PROPERTY_ARGUMENTS)); argIt.hasNext();)
            {
                argName = argIt.getNext();
                if (classDef.getProcedureArgument(argName) == null)
                {
                    throw new ConstraintException("The "+type+"-procedure "+name+" in class "+classDef.getName()+" references an unknown argument "+argName);
                }
            }
View Full Code Here

        String             fkFieldNames     = collDef.getProperty(PropertyHelper.OJB_PROPERTY_FOREIGNKEY);
        ArrayList          missingFields    = new ArrayList();
        SequencedHashMap   fkFields         = new SequencedHashMap();

        // first we gather all field names
        for (CommaListIterator it = new CommaListIterator(fkFieldNames); it.hasNext();)
        {
            String             fieldName = (String)it.next();
            FieldDescriptorDef fieldDef  = elementClassDef.getField(fieldName);

            if (fieldDef == null)
            {
                missingFields.add(fieldName);
            }
            fkFields.put(fieldName, fieldDef);
        }

        // next we traverse all sub types and gather fields as we go
        for (Iterator it = elementClassDef.getAllExtentClasses(); it.hasNext() && !missingFields.isEmpty();)
        {
            ClassDescriptorDef subTypeDef = (ClassDescriptorDef)it.next();

            for (int idx = 0; idx < missingFields.size();)
            {
                FieldDescriptorDef fieldDef = subTypeDef.getField((String)missingFields.get(idx));
View Full Code Here

TOP

Related Classes of xdoclet.modules.ojb.CommaListIterator

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.