Package org.objectweb.speedo.metadata

Examples of org.objectweb.speedo.metadata.SpeedoField


            }
          //visit primitive Fields first because it can contain the pk fields used
          // for classRef or genClassRef
          //visit primitive fields (including pk fields)
          for (Iterator fieldIt = vr.primitiveFields.iterator(); fieldIt.hasNext();) {
              SpeedoField sf = (SpeedoField) fieldIt.next();
                visitPrimitiveField(sf);
          }
            if (sc.joinToExtTables != null) {
                for (int i = 0; i < sc.joinToExtTables.length; i++) {
                    visitJoinOfSecondaryTable(sc.joinToExtTables[i], sc);
                }
            }
          vr.baseVisited();
        }
        if (vr.visitReferences(toVisit)) {
            logger.log(BasicLevel.DEBUG, "\tvisit reference fields:");
         
          //visit references fields
          for (Iterator fieldIt = vr.references.iterator(); fieldIt.hasNext();) {
              SpeedoField sf = (SpeedoField) fieldIt.next();
              if (vr.visitReferenceField(sf, toVisit)) {
                  if (sf.jdoTuple == null) {
                      visitClassRefField(sf);
                  } else {
                    visitGenClassRefField(sf);
View Full Code Here


                                    + "' secondary table have not targetColumn defined in the "
                                    + sc.getSourceDesc());
                        }
                    } else {
                        //find the column of the target field
                        SpeedoField sf = sc.getField(jc.targetField);
                        if (sf == null) {
                            throw new SpeedoException("Targeted field '" + jc.targetField + "' in the " + sc.getSourceDesc() + ". It is defined in the join to the secondary table '" + join.extTable.name +"'.");
                        }
                        if (sf.columns == null || sf.columns.length != 1) {
                            throw new SpeedoException("In join column, target field must be a primitive field: " + sf.getSourceDesc() + ". It is defined in the join to the secondary table '" + join.extTable.name +"'.");
                        }
                        jc.targetColumn = sf.columns[0].name;
                    }
                }
            }
View Full Code Here

     */
    private void visitFieldMappedBy(SpeedoField sf) throws SpeedoException {
        if (sf.relationType == SpeedoField.NO_BI_RELATION) {
            logger.log(BasicLevel.DEBUG, "\t\t\tNo bidirectional relation.");
        } else {
            SpeedoField rf = sf.getReverseField();
            boolean sfHasMapping = sf.columns != null || (sf.join != null && !sf.join.columns.isEmpty());
            boolean rfHasMapping = rf.columns != null || (rf.join != null && !rf.join.columns.isEmpty());
            if (sfHasMapping) {
                if (rfHasMapping) {
                    logger.log(BasicLevel.DEBUG, "\t\t\tOR Mapping already defined both side.");
View Full Code Here

        logger.log(BasicLevel.DEBUG, "\t\tvisit field class reference '" + sf.name + "'.");
        visitClassRefFieldExtension(sf);
        visitFieldMappedBy(sf);
        SpeedoClass rclass = sf.getReferencedClass();
        if (sf.mappedByReversefield) {
            SpeedoField rf = sf.getReverseField();
            logger.log(BasicLevel.DEBUG, "\t\tfield '" + sf.name
                    + "' is mapped by reverse field: "
                    + rf.getFQFieldName());;
            visitSpeedoClass(rclass, new VisitRequired(rf));
            computeFieldFromReverse(sf);
        } else {
          SpeedoTable table;
          if (sf.join == null) {
View Full Code Here

    }
    /**
     * Computes field mapping from its reverse field.
     */
    private void computeFieldFromReverse(SpeedoField sf)throws SpeedoException {
        SpeedoField rField = sf.getReverseField();
        sf.join = new SpeedoJoin();
        sf.join.mainTable = sf.moClass.mainTable;
        if (rField.join == null) {
            //compute the sf.column from the pk column of the referenced class
            sf.join.extTable = rField.moClass.mainTable;
View Full Code Here

        } else {
            //identifier is based on hidden field(s) (ex: data store id)
            int i = 0;
            columns = new SpeedoColumn[pkFields.size()];
            for (Iterator it = pkFields.iterator(); it.hasNext();) {
                SpeedoField pkField = (SpeedoField) it.next();
                columns[i] = pkField.columns[0];
                i++;
            }
        }
        return columns;
View Full Code Here

    private void visitGenClassRefField(SpeedoField sf) throws SpeedoException {
        logger.log(BasicLevel.DEBUG, "\t\tvisit field generic class reference '" + sf.name + "'.");
        visitGenClassRefFieldExtension(sf);
        visitFieldMappedBy(sf);
        if (sf.mappedByReversefield) {
            SpeedoField rf = sf.getReverseField();
            logger.log(BasicLevel.DEBUG, "\t\tfield '" + sf.name
                    + "' is mapped by reverse field: "
                    + rf.getFQFieldName());
            visitSpeedoClass(sf.getReferencedClass(), new VisitRequired(rf));
            computeFieldFromReverse(sf);
            // do not forget index in case of map indexed by field of the
            // referenced class
            visitGenClassIndex(sf);
            return;
        }
        boolean joinCreated = sf.join == null;
        if (joinCreated) {
            //create the join between mainTable and the genClass table
            sf.join = new SpeedoJoin();
            //sf.moClass.addJoin(sf.join);
            if (logger.isLoggable(BasicLevel.DEBUG)) {
                logger.log(BasicLevel.DEBUG, "\t\t\tCreate SpeedoJoin");
            }
        }
        if (sf.join.mainTable == null) {
            sf.join.mainTable = sf.moClass.mainTable;
            if (logger.isLoggable(BasicLevel.DEBUG)) {
                logger.log(BasicLevel.DEBUG, "\t\t\tDefine the main table on join: " + sf.join.mainTable.name);
            }
        }
        if (sf.join.extTable == null) {
            //compute the table of the genclass with regards to the relation type
            switch (sf.relationType) {
            case SpeedoField.MANY_MANY_BI_RELATION:
                SpeedoField rfield = sf.getReverseField();
                if (rfield.join != null && rfield.join.extTable != null) {
                    sf.join.extTable = rfield.join.extTable;
                    if (logger.isLoggable(BasicLevel.DEBUG)) {
                        logger.log(BasicLevel.DEBUG, "\t\t\tUse table of reverse field: " + sf.join.extTable.name);
                    }
View Full Code Here

        if (sf.columns[colIdx].targetField == null) {
            //both are null
            if (sf.columns.length == 1) {
                //compute the target column from the unique pk field
                try {
                    SpeedoField pkField = rclass.getUniquePKField();
                    sf.columns[colIdx].targetColumn = pkField.columns[0].name;
                } catch (SpeedoException e) {
                    throw new SpeedoException("Bad number of column specified for the " + sf.getSourceDesc(), e);
                }
            } else {
                SpeedoException se = new SpeedoException("Target column is required for the reference " + sf.getSourceDesc());
                logger.log(BasicLevel.ERROR, se.getMessage(), se);
                throw se;
            }
        } else {
            //compute the target column from the target field
            SpeedoField pkField = rclass.getField(sf.columns[colIdx].targetField);
            sf.columns[colIdx].targetColumn = pkField.columns[0].name;
        }
    }
View Full Code Here

        int nbcol = sf.join.columns.size();
        if (jc.targetField == null) {
            //both are null
            if (nbcol == 1) {
                //compute the target column from the unique pk field
                SpeedoField pkField = sf.moClass.getUniquePKField();
                jc.targetColumn = pkField.columns[0].name;
            } else {
                SpeedoException se = new SpeedoException("Target column is required for join column of the reference " + sf.getSourceDesc());
                logger.log(BasicLevel.ERROR, se.getMessage(), se);
                throw se;
            }
        } else {
            //compute the target column from the target field
            SpeedoField pkField = sf.moClass.getField(jc.targetField);
            jc.targetColumn = pkField.columns[0].name;
        }
    }
View Full Code Here

            setJoinNColsFromParent(sif);
            //TODO: support index/key
        }
    }
    private void setJoinNColsFromParent(SpeedoInheritedField sif) {
        SpeedoField sf = sif.inheritedField;
        if (sif.columns == null) {
            //Use the same column for the genclass value
            sif.columns = sf.columns;
        }
        if (sif.join == null) {
            sif.join = new SpeedoJoin();
            sif.join.extTable = sf.join.extTable;
            sif.join.mainTable = sf.moClass.mainTable;
            // Use the same join column name but with the targeted column
            // of the current table. We suppose than the id has the same
            // structure
            sif.join.columns = getFKJoinColumn(sf.moClass, "", sif.join.extTable);
            if (sif.join.columns.size() == 1) {
                ((SpeedoJoinColumn) sif.join.columns.get(0)).column.name =
                    ((SpeedoJoinColumn) sf.join.columns.get(0)).column.name;
            } else {
                for (Iterator it = sf.moClass.getPKFields().iterator(); it.hasNext();) {
                    SpeedoField pkField = (SpeedoField) it.next();
                    SpeedoJoinColumn parentjc = sf.getFKJoinColumn(pkField.columns[0].name);
                    SpeedoJoinColumn newjc = sif.getFKJoinColumn(pkField.columns[0].name);
                    newjc.column.name = parentjc.column.name;
                }
            }
View Full Code Here

TOP

Related Classes of org.objectweb.speedo.metadata.SpeedoField

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.