Package org.objectweb.speedo.metadata

Examples of org.objectweb.speedo.metadata.SpeedoClass


    private void orderMOsByInheritance(List scs) {
        List newscs = new ArrayList(scs.size());
        if (debug) {
            logger.log(BasicLevel.DEBUG, "before ordering scs.size()=" + scs.size());
        }
        SpeedoClass sc;
        for(int i = 0; i<scs.size();) {
            sc = (SpeedoClass) scs.get(i);
            if (sc.getSuperClassName() == null) {
                //Add classes without parent
                scs.remove(i);
                newscs.add(sc);
                if (debug) {
                    logger.log(BasicLevel.DEBUG, "Class '" + sc.getFQName()
                        + "' has no parent");
                }
            } else {
                i++;
            }
        }
        int idx = 0;
        while (!scs.isEmpty() && idx < newscs.size()) {
            //Take an element in the new list
            sc = (SpeedoClass) newscs.get(idx);
            if (debug) {
                logger.log(BasicLevel.DEBUG, "Find children of the class '" + sc.getFQName() + "'.");
            }
            //Search its children in the old list
            for(int i = 0; i<scs.size();) {
                SpeedoClass child = (SpeedoClass) scs.get(i);
                if (child.getSuper() == sc) {
                    //It is a child
                    scs.remove(i);
                    newscs.add(child);
                    if (debug) {
                        logger.log(BasicLevel.DEBUG, "Class '"
                            + child.getFQName() + "' is a child of the class '"
                            + sc.getFQName() + "'.");
                    }
                } else {
                    i++;
                }
View Full Code Here


        if (clazz == null) {
            clazz = manager.createClass(sc.getFQName());
            createdMOs.add(clazz);
        }
    if (sc.getSuperClassName() != null) {
      SpeedoClass parent = sc.getSpeedoClassFromContext(sc.getSuperClassName());
      if (parent == null) {
        throw new SpeedoException("No super class '"
            + sc.getSuperClassName() + "'found in the .jdo file: "
            + sc.getXMLFileName());
      }
      Class parentClazz = manager.getClass(parent.getFQName());
      if (parentClazz == null) {
        throw new SpeedoException("Internal algorythm problem: parent class must be treated before sub classes");
      }
      clazz.addSuperClass(parentClazz);
    }
View Full Code Here

                  classNd, sc.jormclass, sc, cm, this, mb, createdMOs);
      if (cm != null) {
        cm.createIdentifierMapping(classNd);
      }
    } else {
      SpeedoClass parent = sc.getSpeedoClassFromContext(sc.getSuperClassName());
      im = parent.jormclass
          .getClassProject(projectName).getMapping(mapperName)
          .getClassMapping().getIdentifierMapping();
      if (im != null) {
        classNd = (NameDef) im.getLinkedMO();
View Full Code Here

              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();
View Full Code Here

    }

    if (sc.getSuperClassName() == null) {
      return;
    }
    SpeedoClass parent = sc.getSpeedoClassFromContext(sc.getSuperClassName());
    String im = sc.getExtensionValueByKey(SpeedoProperties.INHERITANCE_MAPPING);

    // Map the inherited field if required
    if (sc.inheritance.isHorizontalMapping()) {
        for (Iterator it = sc.inheritance.remappedInheritedFields.values().iterator(); it.hasNext();) {
View Full Code Here

    sb.append(HINTS_SEP);
    int ct = getCodingType(nd.getFieldName(), sourceMO);
    sb.append(ct);
    sb.append(HINTS_SEP);
    String className = targetClass.getFQName();
    SpeedoClass ancestor = targetClass.getAncestor();
    if (sourceMO instanceof GenClassRef //For a Genclass ref or identifier
      || (ancestor == null //No inheritance
        && targetClass.jormclass.getSubClasses().isEmpty())) {
      sb.append(ct);
    } else {
      if (ancestor == null) {
        ancestor = targetClass;
      }
      try {
        if (targetClass.jormclass.getSubClasses().isEmpty()) {
          sb.append(ct);
        } else   if (targetClass.jormclass.detectFilterElementNotInPK(targetClass.jormclass.getInheritanceFilter(nd), nd)) {
          //if has child(ren)
          //and one of the fields of the filter is not in the primary key,
          //use a PolymorphicPNC
          sb.append(POLYMORPHIC_PNC);
        } else {
          //use a kfpnc
          sb.append(NamingRules.kfpncName(ancestor.getFQName()));
        }
      } catch (Exception e) {
        logger.log(BasicLevel.ERROR, "Error while retrieving the inheritance filter of the namedef:" + nd.toString());
        throw new SpeedoException("Error while retrieving the inheritance filter of the namedef:" + nd.toString(), e);
      }
      className = ancestor.getFQName();
    }
    sb.append(HINTS_SEP);
    sb.append(className);
    result.setProperty(key, sb.toString());
    }
View Full Code Here

            SpeedoClass sc,
            ClassMapping cm,
            MIBuilderHelper mibh,
            JormMIMappingBuilder mb,
            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

    private void defineClassReferenceNamedDef(NameDef nd,
            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

    sb.append(SEQUENCE_ID);

    sb.append(HINTS_SEP);
    sb.append(SPEEDO_BINDER_CLASS_NAME);

    SpeedoClass ancestor = targetClass.getAncestor();
    String ancestorClassName;
    String pncClassName;
    if (!(sourceMO instanceof GenClassRef) //For a Genclass ref or identifier
      && (ancestor != null // has supper class
        || !targetClass.jormclass.getSubClasses().isEmpty()) // has sub class
      ) {
      if (ancestor == null) {
        ancestor = targetClass;
      }
      ancestorClassName = ancestor.getFQName();
      try {
        if (targetClass.jormclass.getSubClasses().isEmpty()) {
          pncClassName = SPEEDO_BINDER_CLASS_NAME;
        } else   if (targetClass.jormclass.detectFilterElementNotInPK(targetClass.jormclass.getInheritanceFilter(nd), nd)) {
          //if has child(ren)
          //and one of the fields of the filter is not in the primary key,
          //use a PolymorphicPNC
          pncClassName = POLYMORPHIC_PNC;
        } else {
          //use a kfpnc
          pncClassName = NamingRules.kfpncName(ancestor.getFQName());
        }
      } catch (Exception e) {
        logger.log(BasicLevel.ERROR, "Error while retrieving the inheritance filter of the namedef:" + nd.toString());
        throw new SpeedoException("Error while retrieving the inheritance filter of the namedef:" + nd.toString(), e);
      }
View Full Code Here

    private void defineClassReferenceNameDef(NameDef nd,
            ClassRef cr,
            SpeedoField sf,
            MIBuilderHelper mibh,
            String prefix) throws SpeedoException, PException {
        SpeedoClass referencedClass = sf.moClass.getSpeedoClassFromContext(
                cr.getMOClass().getFQName());
        SpeedoField pkField = (SpeedoField) referencedClass.getUniquePKField();
        String fieldName = null;
        PType fieldType;
    if (pkField == null) {
            fieldName = ID_FIELD;
            fieldType = PTypeSpace.OBJLONG;
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.