Package org.objectweb.speedo.metadata

Examples of org.objectweb.speedo.metadata.SpeedoClass


                //The table is one of the parent
                sc.mainTable = getRootTable(sc.getSuper());
            } else if (sc.inheritance.isHorizontalMapping()) {
                sc.mainTable = new SpeedoTable();
            } else if (sc.inheritance.isVerticalMapping()) {
                SpeedoClass parent = sc.getSuper();
                if (sc.inheritance.join == null) {
                    sc.inheritance.join = new SpeedoJoin();
                }
                SpeedoJoin join = sc.inheritance.join;
                if (join.mainTable == null) {
View Full Code Here


        if (sc.inheritance == null || sc.inheritance.superClassName == null) {
            return;
        }
        if (sc.inheritance.isFilteredMapping()) {
            if (scp.nmf.getNamingManager(sc).needInheritanceDiscriminator(sc)) {
                SpeedoClass ancestor = sc.getAncestor();
                if (ancestor.inheritance == null || ancestor.inheritance.discriminator == null) {
                    throw new SpeedoException("Filtered inheritance requires discriminator defined at root level: " + ancestor.getSourceDesc());
                }
                if (sc.inheritance.discriminatorValues == null) {
                    throw new SpeedoException("Filtered inheritance requires discriminator values defined for each sub class: " + sc.getSourceDesc());
                }
            }
        } else if (sc.inheritance.isHorizontalMapping()) {
            //maps all field of all parents
            List parents = sc.getParents();
            for (Iterator parentIt = parents.iterator(); parentIt.hasNext();) {
                SpeedoClass parent = (SpeedoClass) parentIt.next();
                for (Iterator fieldIt = parent.fields.values().iterator(); fieldIt.hasNext();) {
                    mapHorizontalInheritedField((SpeedoField) fieldIt.next(), sc);
                }
            }
        } else if (sc.inheritance.isVerticalMapping()) {
View Full Code Here

     */
    private void visitClassRefField(SpeedoField sf) throws SpeedoException {
        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) {
              table = sf.moClass.mainTable;
          } else {
              table = sf.join.extTable;
          }
          if (sf.columns == null) {
              logger.log(BasicLevel.DEBUG, "\t\tfield '" + sf.name
                      + "' requires pk fields of the class "
                      + rclass.getFQName());
            visitSpeedoClass(rclass, VisitRequired.BASE);
              sf.columns = getFKColumn(rclass, sf.name + "_", table);
          } else {
              for (int i = 0; i < sf.columns.length; i++) {
                  sf.columns[i].table = table;
View Full Code Here

     * Visit gen class element. The element can be a primitive element
     * or a reference to a persistent class.
     * @param sf is the SpeedoField meta object representing the genclass
     */
    private void visitGenClassElement(SpeedoField sf) throws SpeedoException {
        SpeedoClass rclass = sf.getReferencedClass();
        if (sf.columns == null) {
          if (rclass == null) {
              //primitive element
              sf.addColumn(new SpeedoColumn("element", sf.join.extTable));
          } else {
              logger.log(BasicLevel.DEBUG, "\t\tfield '" + sf.name
                      + "' requires pk fields of the class "
                      + rclass.getFQName());
                visitSpeedoClass(rclass, VisitRequired.BASE);
              //persistent class ==> classRef
                String prefix = "";
                if (sf.join.extTable != rclass.mainTable) {
                    prefix = "elem_";
View Full Code Here

        sc.inheritance.remappedInheritedFields.get(sf.getFQFieldName());
        if (sif == null) {
            sif = sc.inheritance.newSpeedoInheritedField(sf);
        }
        if (sf.jdoTuple == null) {
            SpeedoClass rclass = sf.getReferencedClass();
            //primitive field or simple reference to a persistent class
            if (rclass != null && sf.join != null
                    && sf.relationType == SpeedoField.ONE_ONE_BI_RELATION
                    && sf.mappedByReversefield) {
                // the classref belongs a bidirectionnal relationship
View Full Code Here

     * @param sf a persistent field referencing a persistent class.
     * @see SpeedoProperties#SOURCE_FK
     * @see SpeedoProperties#TARGET_FK
     */
    public void visitClassRefFieldExtension(SpeedoField sf) throws SpeedoException {
        SpeedoClass rclass = sf.getReferencedClass();
        String sfk = sf.getExtensionValueByKey(SpeedoProperties.SOURCE_FK);
        String tfk = sf.getExtensionValueByKey(SpeedoProperties.TARGET_FK);
        if (sfk == null && tfk == null) {
            return;
        }
        if (sfk != null && sf.relationType == SpeedoField.ONE_ONE_BI_RELATION) {
            //The relation is mapped by the field having the foreign key
            return;
        }
        if (tfk != null) {
            SpeedoColumn[] cols = getFKColumn(tfk, sf.moClass.mainTable, sf.getReferencedClass());
            if (sf.columns != null && cols.length == sf.columns.length) {
                for (int i = 0; i < cols.length; i++) {
                    sf.columns[i].merge(cols[i]);
                }
            } else {
                sf.columns = cols;
            }
        } else if (sfk != null) { //backward reference
            sf.join = new SpeedoJoin();
            sf.join.mainTable = sf.moClass.mainTable;
            sf.join.extTable = rclass.mainTable;
            //compute the sf.column from the pk column of the referenced class
            Collection pkFields = rclass.getPKFields();
            if (pkFields.isEmpty()) {
                sf.columns = new SpeedoColumn[rclass.identity.columns.length];
                for(int i=0; i<rclass.identity.columns.length; i++) {
                    sf.columns[i] = rclass.identity.columns[i].column;
                }
View Full Code Here

        // Calculate the list of the Jorm Meta Object which must be serialized
        //Set mos = new HashSet(desc.jdoPackage.size());
        for (Iterator itPack = desc.packages.values().iterator(); itPack.hasNext();) {
            SpeedoPackage sp = (SpeedoPackage) itPack.next();
            for (Iterator itclass = sp.classes.values().iterator(); itclass.hasNext();) {
                SpeedoClass jdoClass = (SpeedoClass) itclass.next();
                if (jdoClass.jormclass == null)
                    throw new SpeedoException(
                            "The Jorm meta information of the jdo descriptor "
                            + desc.xmlFile + " is not complete: class "
                            + jdoClass.name + " has not been found");
View Full Code Here

        for (Iterator itDesc = scp.getXmldescriptor().values().iterator(); itDesc
                .hasNext();) {
            SpeedoXMLDescriptor desc = (SpeedoXMLDescriptor) itDesc.next();
            List scs = desc.getSpeedoClasses();
            for (int i = 0; i < scs.size(); i++) {
                SpeedoClass sc = (SpeedoClass) scs.get(i);
                String fn = sc.getJormFileName();
                logger.log(BasicLevel.DEBUG, "looking for the file: " + fn);
                if (!pdfiles.contains(fn)) {
                    // No .pd file is availlable, add the SpeedoClass into the
                    // list
                    notFoundMOs.add(sc);
View Full Code Here

        if (classJorm == null) {
            throw new SpeedoException("Jorm description of the class '"
                    + clas.getFQName() + "' is not availlable");
        }
        NameDef pName = null;
        SpeedoClass sc = clas;
        while(sc.getSuperClassName() != null) {
            SpeedoClass scl = sc;
            sc = sc.moPackage.xmlDescriptor.smi.getSpeedoClass(sc.getSuperClassName(), sc.moPackage);
            if (sc == null) {
                throw new SpeedoException("Class " + scl.getFQName()
                        + " not defined in the jorm meta information");
            }
        }
        Class pclassJorm = manager.getClass(sc.getFQName());
        pName = getClassNameDef(pclassJorm);

        if (classJorm == null) {
            throw new SpeedoXMLError("Class '" + clas.name + "' not defined in JORM metadata");
        }

        // Comparison from JDO
        clas.jormclass = classJorm;
        for (Iterator efield = clas.fields.values().iterator(); efield.hasNext();) {
            SpeedoField field = (SpeedoField) efield.next();
            String fieldName = field.name;

            // Fields with this persistent modifier shouldn't stay in JDO Metadata
            if (field.persistenceStatus == SpeedoField.NONE)
                continue;

            TypedElement tElem = classJorm.getTypedElement(fieldName);
            if (tElem == null) {
                throw new SpeedoXMLError("Field '" + fieldName
                    + "' not defined in JORM metadata of the class '"
                    + clas.getFQName() + "'");
            }

            // for application identity key fields have to be compared
            if (field.primaryKey) {
                boolean found = false;
                for (Iterator it = pName.iterateField(); it.hasNext() && !found;) {
                    found = fieldName.equals(it.next());
                }
                if (!found) {
                    throw new SpeedoXMLError("Field '" + fieldName
                        + "' not defined in Class NameDef's Fields of the class '"
                        + clas.getFQName() + "'");
                }
            }

            if (tElem instanceof GenClassRef && field.jdoTuple == null)
                throw new SpeedoXMLError("field '" + fieldName + "' should be a tuple in JDO metadata of the class '" + clas.getFQName() + "'");
        }

        // Comparison from JORM
        for (Iterator jormfield = classJorm.getFields().iterator(); jormfield.hasNext();) {
            TypedElement te = (TypedElement) jormfield.next();
            String fieldName = te.getName();
            if (!clas.fields.containsKey(fieldName)
                    && !isContainerIdField(classJorm, te, clas))
                throw new SpeedoXMLError("Field '" + fieldName + "' of the class '"
                            + clas.getFQName() + "' is not defined in the '"
                            + clas.moPackage.xmlDescriptor.xmlFile
                            + "' file (found: " + clas.fields.keySet() + ").");
        }

        // for application identity key fields have to be compared
        if (clas.getIdentityType() == SpeedoIdentity.USER_ID) {
            SpeedoClass classWithId = clas;
            while(classWithId.getSuperClassName() != null) {
                classWithId = classWithId.getSpeedoClassFromContext(classWithId.getSuperClassName());
            }
            boolean found = false;
            for (Iterator it = pName.iterateField(); it.hasNext() && !found;) {
                String fn = (String) it.next();
                SpeedoField sf = (SpeedoField) classWithId.fields.get(fn);
View Full Code Here

                    "the Jorm meta information manager must be assigned");
        }
      int size = scs.size();
      debug = logger.isLoggable(BasicLevel.DEBUG);
        ArrayList createdMOs = new ArrayList(size * 2);
        SpeedoClass sc;
        String mn;
        if (mapperName != null) {
            // take the mapper name without the sub mapper name
            int idx = mapperName.indexOf(".");
            mn = (idx != -1 ? mapperName.substring(0, idx) : mapperName);
View Full Code Here

TOP

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

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.