Package org.objectweb.speedo.metadata

Examples of org.objectweb.speedo.metadata.SpeedoField


                }
            } else {
                int i = 0;
                sf.columns = new SpeedoColumn[pkFields.size()];
                for (Iterator it = pkFields.iterator(); it.hasNext();) {
                    SpeedoField pkField = (SpeedoField) it.next();
                    sf.columns[i] = pkField.columns[0];
                    i++;
                }
            }
            //compute the join columns
View Full Code Here


        }
        if (sc.getSuperClassName() != null) {
      //do nothing, the primary key field are inherited from the ancestor
    } else if (pkfields.isEmpty()) {
            for(int i=0; i<uica.fieldNames.size(); i++) {
                SpeedoField sf = (SpeedoField) sc.fields.get(uica.fieldNames.get(i));
                if (sf == null) {
                    logger.log(BasicLevel.WARN, "The public field '"
                            + uica.fieldNames.get(i) + "' of the identifier class "
                            + className + "' does not match to any field in the persistent class '"
                            + sc.getFQName() +"'.");
View Full Code Here

            logger.log(BasicLevel.DEBUG, "fields ["
                    + moClass.fields.values().size() + "]: "
                    + moClass.fields.values());
        }
        for(Iterator it = moClass.fields.values().iterator(); it.hasNext();) {
            SpeedoField current = (SpeedoField) it.next();
            if (debug) {
                logger.log(BasicLevel.DEBUG, "treat  field " + current.name);
            }
            if (!finder.fillInfo(current)) {
                throw new SpeedoRuntimeException(
View Full Code Here

        // Adds in the object model fields whose type is known as
        // Persistence Capable
        if ((access & Constants.ACC_STATIC) == 0
              && (access & Constants.ACC_FINAL) == 0
              && (access & Constants.ACC_SYNTHETIC) == 0) {
          SpeedoField jdoField = (SpeedoField) moClass.fields.get(name);
          if (jdoField == null
                  && Util.isAutomaticPersistentType(desc, xmlDescriptors)) {
        jdoField = new SpeedoField();
        jdoField.persistenceStatus = SpeedoField.PERSISTENT;
        jdoField.name = name;
        jdoField.visibility = access;
        jdoField.type = desc;
        moClass.add(jdoField);
View Full Code Here

    public void visitEnd() {
        // Removes from the object model all fields that are not defined as
        // persistent
        for (Iterator it = moClass.fields.entrySet().iterator();it.hasNext();) {
            Map.Entry entry = (Map.Entry) it.next();
            SpeedoField field = (SpeedoField) entry.getValue();
            if (field.persistenceStatus != SpeedoField.PERSISTENT) {
                it.remove();
            }
        }
    }
View Full Code Here

        }

        // 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);
                if (sf == null) {
                    logger.log(BasicLevel.WARN, "Field " + fn + " defined in the identifier of "
                            + classWithId.name
                            + ".pd file but not availlable in the class (or .pd file).");
                } else if (!sf.primaryKey) {
View Full Code Here

    ClassMapping cm = clazz.getClassProject(projectName)
        .getMapping(mapperName).getClassMapping();
        logger.log(BasicLevel.DEBUG, "Generate the Jorm MI for the class "
                + clazz.getFQName());
        for (Iterator fieldsIt = sc.fields.values().iterator();fieldsIt.hasNext();) {
            SpeedoField sp = (SpeedoField) fieldsIt.next();
            createPrimitiveField(sc, clazz, sp, cm, mb);
        }
    }
View Full Code Here

            cm = mapping.getClassMapping();
        }
        Iterator fieldsIt = sc.fields.values().iterator();
        //System.out.println("Manage reference of the class " + sc.getFQName());
        while (fieldsIt.hasNext()) {
            SpeedoField sp = (SpeedoField) fieldsIt.next();
          if (clazz.getTypedElement(sp.name) != null) {
                //the primitive element is already managed before(createJormClass)
                continue;
            }
          Type t = Type.getType(sp.type);
            String javatype = t.getClassName();
            if (!isGenClassRef(javatype)) {
                //                     reference to a class                   //
                //============================================================//
              if (debug) {
                    logger.log(BasicLevel.DEBUG, "Class reference field: "
                        + sp.name + " / javatype: " + javatype);
              }
                // reference to a class
                SpeedoClass tsc = sc.moPackage.xmlDescriptor
                        .getSpeedoClass(javatype, true);
                if (tsc == null) {
                    throw new SpeedoException("No persistent class '"
                            + javatype + "' found in the file: "
                            + sc.moPackage.xmlDescriptor.xmlFile);
                }
                Class tclass = manager.getClass(tsc.getFQName());
                if (tclass == null) {
                    manager.createClass(tsc.getFQName());
                }
                ClassRef cr = clazz.createClassRef(sp.name, tclass);
                NameDef refNd = cr.createRefNameDef();
                nmf.getNamingManager(tsc)
                  .defineClassReferenceNameDef(refNd, cr, sp, sc, cm, this, mb);
                if ( cm != null) {
                    cm.createReferenceMapping(sp.name, refNd);
                    cm.addDependency(tsc.getFQName());
                }

            } else {
                //                reference to a generic class                //
                //============================================================//
                String innerType = getInnerType(sp);
                if (innerType == null) {
                    throw new SpeedoException("The inner element type is " +
                            "required for the multivalued field '" + sp.name
                            + "' of the class '" + sc.getFQName()
                            + "' in the .jdo file '"
                            + sc.moPackage.xmlDescriptor.xmlFile + "'");
                }
                PType type = getPrimitivePType(innerType);
              if (type == null && !isPersistentClass(innerType, sc.moPackage.name, manager)) {
                logger.log(BasicLevel.INFO, "The field '" + sc.getFQName()
                        + "." + sp.name + " is managed as a Serialized field.");
                type = PTypeSpace.SERIALIZED;
              }
              if (debug) {
          logger.log(BasicLevel.DEBUG, "GenClass reference field: "
              + sp.name + " / javatype: " + javatype
              + " / innerType: " + innerType
            + " / ptype=" + (type == null ? null : type.getJavaName()));
              }
                GenClassRef gcr = clazz.createGenClassRef(sp.name, javatype);
                GenClassMapping gcm = null;
                ClassRef cr = null;
                SpeedoClass tsc = null;

                //element of the gen class
                if (type != null) {
                    // gen class of primitive type
                    gcr.createPrimitiveElement(type, PType.NOSIZE, PType.NOSIZE);
                } else if (!isGenClassRef(innerType)) {
                    // gen class of classref
                    tsc = sc.moPackage.xmlDescriptor.smi
                            .getSpeedoClass(innerType, sc.moPackage);
                    if (tsc == null) {
                        throw new SpeedoException("The persistent class '"
                                + sc.getFQName()
                                + "' tries to reference (througth the field '"
                                + sp.name
                                + "') the class '" + innerType
                                + "' not defined in the .jdo file '"
                                + sc.moPackage.xmlDescriptor.xmlFile + "'");
                    }
                    Class tclass = manager.getClass(tsc.getFQName());
                    if (tclass == null) {
                        throw new SpeedoException("The inner element class '"
                            + tsc.getFQName() + "' of the multivalued field '"
                            + sp.name + "' of the class '" + sc.getFQName()
                            + "' in the .jdo file '"
                            + sc.moPackage.xmlDescriptor.xmlFile
                                + "' has not been found among the persitent classes : "
                            + manager.getClasses());
                    }
                    cr = gcr.createClassRef(tclass);
                } else {
                    throw new SpeedoException(
                            "unmanaged the inner-element of the field '"
                            + sp.name + "' of the class '" + sc.getFQName()
                            + "' : " + innerType);
                }
                //Map the element of the generic class
                if (mapping != null) {
                    gcm = mb.createGenClassMapping(gcr, sp, mapping);
                    if (gcr.isPrimitive()) {
                        mb.createGenClassElementMapping(gcr.getPrimitiveElement(), sp, gcm);
                    } else {
                        NameDef elemNd = cr.createRefNameDef();
                        nmf.getNamingManager(tsc).defineClassReferenceNameDef(elemNd, cr, sp, sc, gcm, this, mb);
                        //fillNameDef(elemNd, tsc, sc, gcr, gcr, gcm, mb, false, true, true, createdMOs);
                        gcm.createReferenceMapping(sp.name, elemNd);
                        cm.addDependency(tsc.getFQName());
                    }
                }

                // reference to a generic class from the class
                NameDef refNd = gcr.createRefNameDef();
                nmf.getNamingManager(sc).defineGenClassReferenceNameDef(refNd, gcr, sp, sc, cm, this, mb);
                //fillNameDef(refNd, sc, sc, clazz, gcr, cm, mb, false, false, false, createdMOs);
                if (cm != null) {
                    cm.createReferenceMapping(sp.name, refNd);
                }

                //identifier of the gen class
                NameDef gcidNd = gcr.createIdNameDef();
                nmf.getNamingManager(sc).defineGenClassIdentifierNameDef(
                        gcidNd, gcr, sp, sc, gcm, this, mb);
                //fillNameDef(gcidNd, sc, sc, gcr, gcr, gcm, mb, true, true, true, createdMOs);
                if (gcm != null) {
                    gcm.createIdentifierMapping(gcidNd);
                }

                //index of the gen class
                java.lang.Class gcClass;
                try {
                    gcClass = java.lang.Class.forName(javatype);
                } catch (ClassNotFoundException e) {
                    throw new SpeedoException(
                            "The multivalued field '" + sp.name
                            + "' of the class '" + sc.getFQName()
                            + "' is not a well known class " + javatype, e);
                }
                if (isSubType(gcClass, java.util.List.class)) {
                    PrimitiveElement pe = gcr.createHiddenField(
                            LIST_INDEX, PTypeSpace.INT, PType.NOSIZE, PType.NOSIZE);
                    if (gcm != null) {
                        mb.createGenClassIndexMapping(pe, sp, gcm);
                    }
                    gcr.addIndexField(LIST_INDEX);
                } else if (isSubType(gcClass, java.util.Map.class)) {
          String keyfield = sp.getExtensionValueByKey(SpeedoProperties.KEY_FIELD);
          if (keyfield == null) {
            keyfield = MAP_INDEX;
          }
                    PrimitiveElement pe = gcr.createHiddenField(
                            keyfield, getMapKeyPType(sp), PType.NOSIZE, PType.NOSIZE);
View Full Code Here

            Collection createdMOs) throws SpeedoException, PException {
        SpeedoClass clazz = sc.getAncestor();
        if (clazz == null) {
            clazz = sc;
        }
        SpeedoField pkField = clazz.getUniquePKField();
        nd.setFieldName(pkField.name);
    }
View Full Code Here

            SpeedoField sf,
            ClassRef cr,
            MIBuilderHelper mibh,
            String prefix) throws SpeedoException, PException {
        SpeedoClass referencedClass = sf.moClass.getSpeedoClassFromContext(cr.getMOClass().getFQName());
        SpeedoField pkField = (SpeedoField) referencedClass.getUniquePKField();

        String fn =  prefix + pkField.name;
        int size = PType.NOSIZE;
        int scale = PType.NOSIZE;
        if (pkField.columns != null && pkField.columns.length == 1) {
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.