Package org.objectweb.speedo.metadata

Examples of org.objectweb.speedo.metadata.SpeedoClass


            }
            //Create the RdbTable for the Generic class
            rgcm.createRdbTable(sf.join.extTable.name);
        } else if (gcr.isClassRef()) {
            SpeedoField reverseField = sf.getReverseField();
            SpeedoClass tclass = sf.moClass.getSpeedoClassFromContext(
                    gcr.getClassRef().getMOClass().getFQName());
            Class targetClassJMO = tclass.jormclass;
            mapping.getClassMapping().addDependency(targetClassJMO.getFQName());
            switch (sf.relationType) {
            case SpeedoField.MANY_MANY_BI_RELATION:
View Full Code Here


     */
    private RdbPrimitiveElementMapping getPEMOfField(
            SpeedoClass sc,
            Mapping map,
            String fieldName) throws PException {
        SpeedoClass current = sc;
        RdbPrimitiveElementMapping pem = null;
        while(pem == null) {
          RdbClassMultiMapping trcm = getClassMapping(map, current.jormclass);
          pem = (RdbPrimitiveElementMapping)
            trcm.getPrimitiveElementMapping(fieldName, true);
View Full Code Here

            return;
        }

    //check that the extension KEY_FIELD is specified for a SpeedoField
    if (!(se.owner instanceof SpeedoField)) {
      SpeedoClass sc = getSpeedoClass(se.owner);
      logger.log(BasicLevel.ERROR, "You have specified the key field ('"
          + se.value + "') in other thing than a field tag ('"
          + se.owner.toString() + "')" +
          (sc == null
          ? ""
          : " in class '" + sc.getFQName() + "' of the descriptor '"
          + sc.moPackage.xmlDescriptor.xmlFile));
      super.visitExtension(se);
      return;
    }

    //check that the SpeedoField is like a map
    SpeedoField sf = (SpeedoField) se.owner;
    if (!(sf.jdoTuple instanceof SpeedoMap)) {
      SpeedoClass sc = getSpeedoClass(se.owner);
      logger.log(BasicLevel.ERROR, "You have specified the key field ('"
          + se.value + "') for the field '" + sf.name
          + "' which is not Map" +
          (sc == null
          ? ""
          : ", in class '" + sc.getFQName() + "' of the descriptor '"
          + sc.moPackage.xmlDescriptor.xmlFile));
      super.visitExtension(se);
      return;
    }
    //Search the key field
View Full Code Here

    }

    public void visitExtension(SpeedoExtension se) throws SpeedoException {
        logger.log(BasicLevel.DEBUG, "Extension '" + se.key + "=" + se.value);
        if (se.owner instanceof SpeedoClass) {
            SpeedoClass sc = (SpeedoClass) se.owner;
            //Main table name
            if (SQL_NAME.equals(se.key)) {
                sc.mainTable = new SpeedoTable();
                sc.mainTable.name = se.value;
                sc.mainTable.catalog = null;
                sc.mainTable.schema = null;
            } else if (INHERITANCE_FILTER.equals(se.key)) {
                setDiscriminatorElement(sc, se.value);
            } else if (INHERITANCE_KEY.equals(se.key)) {
                if (sc.inheritance == null) {
                    sc.inheritance = new SpeedoInheritance(sc);
                }
                if (sc.inheritance.discriminatorValues == null) {
                    sc.inheritance.discriminatorValues = new HashMap();
                }
                SpeedoDiscriminator sd = sc.inheritance.discriminator;
                if (sd == null || !sd.hasDiscriminator()) {
                    //find the discriminator
                    SpeedoClass current = sc;
                    while (current != null && sd == null) {
                        if (current.inheritance != null
                                && current.inheritance.discriminator != null
                                && current.inheritance.discriminator.hasDiscriminator()) {
                            sd = current.inheritance.discriminator;
                        } else {
                            String f = current.getExtensionValueByKey(INHERITANCE_FILTER);
                            if (f != null) {
                                sd = setDiscriminatorElement(current, f);
                            }
                        }
                        if (sd == null) {
                            current = current.getSuper();
                        }
                    }
                    if (sd == null || !sd.hasDiscriminator()) {
                        throw new SpeedoException("Extension '"
                                + INHERITANCE_KEY
View Full Code Here

      // The real type of relation will be calculated later (@see ReverseFieldAdder).
      sf.relationType = SpeedoField.NO_BI_RELATION;
    }
    // Verify that there is an identifier definition
    if (sc.getPKFields().size() == 0) {
      SpeedoClass sch = sc.getSuper();
      while (sch != null) {
        if (sch.getPKFields().size() != 0) {
          break;
        }
        sch = sch.getSuper();
      }
      if (sch == null) {
        nbErrors++;
        logger.log(BasicLevel.ERROR, sc.getSourceDescShort()
            + ": no identity defined for the class.");
View Full Code Here

    public void visitPackage(SpeedoPackage sp) throws SpeedoException {
        logger.log(BasicLevel.DEBUG, "Visit package " + sp.name);
        super.visitPackage(sp);
        visitExtension(sp);
        for(Iterator classIt = sp.classes.values().iterator();classIt.hasNext();) {
            SpeedoClass clazz = (SpeedoClass) classIt.next();
            visitClass(clazz);
        }
        for (Iterator it = sp.sequences.values().iterator(); it.hasNext();) {
            SpeedoSequence sequence = (SpeedoSequence) it.next();
            visitSequence(sequence, sp);
View Full Code Here

        logger.log(BasicLevel.WARN, sc.getSourceDescShort()
            + ": no discriminator column definition required for TABLE_PER_CLASS inheritance strategy - ignored!");
        sc.inheritance.discriminator = null;
      }
      // Define attribute mapping for attributes of the superclasses
      SpeedoClass inhsc = sc.getSuper();
      while (inhsc != null) {
        for (Object inhsf : inhsc.fields.values()) {
          if (inhsf instanceof SpeedoInheritedField) {
            continue;
          }
                    SpeedoInheritedField sif =
                        sc.inheritance.newSpeedoInheritedField((SpeedoField)inhsf);
                    for (SpeedoColumn scol : sif.inheritedField.columns) {
            SpeedoColumn nscol = (SpeedoColumn) scol.clone();
            nscol.table = sc.mainTable;
            sif.addColumn(nscol);
          }
        }
        inhsc = inhsc.getSuper();
      }
      break;
    case JOINED: // vertical inheritance mapping
      sc.inheritance.strategy = SpeedoInheritance.STRATEGY_NEW_TABLE;
      if (sc.getAncestor() == null) {
View Full Code Here

      logger.log(BasicLevel.WARN, sc.getSourceDescShort()
          + ": unknown type for element of collection for field ("
          + sf.name + ").");
      return;
    }
    SpeedoClass scf = scp.smi.getSpeedoClass(t.getName());
    if (scf != null) {
      // This is en Entity class.
      sf.relationType = SpeedoField.ONE_REFERENCE;
      if (sf.type != null) { // defined at association definition time
        if (! sf.type.equals(t.getName())) {
          logger.log(BasicLevel.WARN, sc.getSourceDescShort()
              + ": type for field ("
              + sf.name + ") is different from the one defined in association - association type ignored.");
        }
      }
      sf.type = Type.getDescriptor(t);
      return;
    }
    if (isValidType(Type.getDescriptor(t), FIELDTYPES) || t.isEnum()) {
      // This a basic valid type or an enum type. Nothing to do.
      sf.type = Type.getDescriptor(t);
      return;
    }
    // Verifies if it is a Collection or a Serializable type.
    if (Set.class.isAssignableFrom(t)
        || List.class.isAssignableFrom(t)
        || Collection.class.isAssignableFrom(t)) {
      // This is a valid type: a Set, List or Collection of Entity class.
      sf.jdoTuple = new SpeedoCollection();
      sf.jdoTuple.moField = sf;
      if (t == gt) {
        // No generic type defined.
        if (sf.type == null) {
          nbErrors++;
          logger.log(BasicLevel.ERROR, sc.getSourceDescShort()
              + ": unknown type for element of Set/List/Collection for field ("
              + sf.name + ").");
          return;
        }
        ((SpeedoCollection) sf.jdoTuple).elementType = sf.type;
        sf.type = Type.getDescriptor(t);
        return;
      }
      // The Java generic type is completely defined.
      sf.relationType = SpeedoField.MANY_REFERENCE;
      SpeedoClass escf = scp.smi.getSpeedoClass(((Class)((ParameterizedType) gt).getActualTypeArguments()[0]).getName());
      if (escf == null) {
        nbErrors++;
        logger.log(BasicLevel.ERROR, sc.getSourceDescShort()
            + ": element of collection should belong to an Entity class (found "
            + Type.getDescriptor((Class)((ParameterizedType) gt).getActualTypeArguments()[0])
            + ") for field (" + sf.name + ").");
        return;
      }
      if (! sf.type.equals(escf.name)) {
        logger.log(BasicLevel.WARN, sc.getSourceDescShort()
            + ": type for element of collection field ("
            + sf.name + ") is different from the one defined in association - association type ignored.");
      }
      ((SpeedoCollection) sf.jdoTuple).elementType = ((Class)((ParameterizedType) gt).getActualTypeArguments()[0]).getName();
      sf.type = Type.getDescriptor(t);
      return;
    }
    if (Map.class.isAssignableFrom(t)) {
      // This is a Map valid type.
      sf.jdoTuple = new SpeedoMap();
      sf.jdoTuple.moField = sf;
      if (t == gt) {
        logger.log(BasicLevel.WARN, sc.getSourceDescShort()
            + ": unknown type for element of Map for field ("
            + sf.name + ").");
        return;
      }
      // The Java generic type is completely defined.
      sf.relationType = SpeedoField.MANY_REFERENCE;
      SpeedoClass escf = scp.smi.getSpeedoClass(((Class)((ParameterizedType) gt).getActualTypeArguments()[1]).getName());
      if (escf == null) {
        nbErrors++;
        logger.log(BasicLevel.ERROR, sc.getSourceDescShort()
            + ": element of Map should belong to an Entity class (found "
            + Type.getDescriptor((Class)((ParameterizedType) gt).getActualTypeArguments()[1])
View Full Code Here

        for (Iterator xmlIt = scp.smi.xmlDescriptors.values().iterator(); xmlIt.hasNext();) {
            SpeedoXMLDescriptor xml = (SpeedoXMLDescriptor) xmlIt.next();
            for (Iterator packIt = xml.packages.values().iterator(); packIt.hasNext();) {
                SpeedoPackage sp = (SpeedoPackage) packIt.next();
                for (Iterator classIt = sp.classes.values().iterator(); classIt.hasNext();) {
                    SpeedoClass sc = (SpeedoClass) classIt.next();
                    visitSpeedoClass(sc, VisitRequired.ALL);
                }
            }
        }
        visitedClasses.clear();
View Full Code Here

     */
    private void visitClassParent(SpeedoClass sc, VisitRequired toVisit) throws SpeedoException {

        //find all not visited parents
        List parents = new ArrayList();
        SpeedoClass parent = sc.getSuper();
        while (parent != null) {
            VisitRemember vr = (VisitRemember) visitedClasses.get(parent);
            if (vr == null || vr.hasUnvisitedPart(toVisit)) {
                //Add in first
                parents.add(0, parent);
                parent = parent.getSuper();
            } else {
                //if a parent is visited all super parents are visited too
                parent = null;
            }
        }
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.