Package org.objectweb.speedo.metadata

Examples of org.objectweb.speedo.metadata.SpeedoField


         * the list of persistent fields.
         */
        public VisitRemember(SpeedoClass c) {
            sc = c;
            for (Iterator fieldIt = sc.fields.values().iterator(); fieldIt.hasNext();) {
                SpeedoField sf = (SpeedoField) fieldIt.next();
                if (sf.jdoTuple != null) {
                    references.add(sf);
                } else {
                    SpeedoClass rclass = sf.getReferencedClass();
                    if (rclass == null) {
                        primitiveFields.add(sf);
                    } else {
                        references.add(sf);
                    }
View Full Code Here


                    return "BASE";
                } else {
                    StringBuffer sb = new StringBuffer();
                    sb.append("BASE");
                    for (Iterator it = visitedReferencesFields.iterator(); it.hasNext();) {
                        SpeedoField sf = (SpeedoField) it.next();
                        sb.append(", ").append(sf.name);
                    }
                    return sb.toString();
                }
            } else {
View Full Code Here

    // (getters/setters)
    for (Method m : c.getMethods()) {
      if (!isRelevantAttribute(m, c)) {
        continue;
      }
      SpeedoField sf = new SpeedoField();
      sf.name = getter2attribute(m.getName());
      // sf.visibility;
      sf.moClass = sc;
      sc.fields.put(sf.name, sf);
      logger.log(BasicLevel.DEBUG, "New SpeedoField for EJB property: "
          + sf.name + ", TYPE: " + sf.type);
      parseManyToOne(m.getAnnotation(ManyToOne.class), sc, sf);
      parseOneToOne(m.getAnnotation(OneToOne.class), sc, sf);
      parseOneToMany(m.getAnnotation(OneToMany.class), sc, sf);
      parseManyToMany(m.getAnnotation(ManyToMany.class), sc, sf);
      parseType((Class) m.getReturnType(), m.getGenericReturnType(), sc,
          sf);
      if (sf.relationType == SpeedoField.NO_BI_RELATION) {
        excludeAnnotation(new Object[] {
            m.getAnnotation(JoinColumns.class),
            m.getAnnotation(JoinColumn.class),
            m.getAnnotation(JoinTable.class) }, sc, sf.name,
            "property");
        parseVersion(m.getAnnotation(Version.class), sc, sf);
        parseColumn(m.getAnnotation(Column.class), sc, sf);
        parseBasic(m.getAnnotation(Basic.class), sc, sf, true);
        parseLob(m.getAnnotation(Lob.class), sc, sf, true);
        if (m.getAnnotation(Embedded.class) != null) {
          parseEmbeddedOverriding(
              (AttributeOverride) m.getAnnotation(AttributeOverride.class),
              (AttributeOverrides) m.getAnnotation(AttributeOverrides.class),
              sc, sf);
        }
      } else {
        excludeAnnotation(new Object[] {
            m.getAnnotation(Version.class),
            m.getAnnotation(Column.class),
            m.getAnnotation(Basic.class),
            m.getAnnotation(Lob.class) }, sc, sf.name,
            "association property");
        if (m.getAnnotation(JoinColumns.class) != null) {
          if (m.getAnnotation(JoinColumn.class) != null) {
            nbErrors++;
            logger.log(BasicLevel.ERROR, sc.getSourceDescShort()
                + ": cannot define both 'JoinColumns' and'JoinColumn' annotation for property ("
                + sf.name + ").");
          } else {
            parseJoinColumns(
                m.getAnnotation(JoinColumns.class).value(),
                sc, sf);
          }
        } else {
          if (m.getAnnotation(JoinColumn.class) != null) {
            parseJoinColumns(
                new JoinColumn[] { m.getAnnotation(JoinColumn.class) },
                sc, sf);
          }
        }
      }
      parseEmbeddedId(m.getAnnotation(EmbeddedId.class), sc, sf);
      if (parseId(m.getAnnotation(Id.class), sc, sf)) {
        // ---------------------------------------------------------------------
        // In case of Long identifier, try parsing Id generator
        parseGeneratedValue((GeneratedValue) m.getAnnotation(GeneratedValue.class), sc);
      } else {
        if (m.getAnnotation(GeneratedValue.class) != null) {
          logger.log(BasicLevel.WARN, sc.getSourceDescShort()
              + ": can only associate an identifier generator to a Long ID - ignored!");
        }
      }
    }
    // look for persistent attributes represented by variables
    for (Field f : c.getDeclaredFields()) {
      if (!isRelevantAttribute(f, c)) {
        continue;
      }
      SpeedoField sf = new SpeedoField();
      sf.name = f.getName();
      // sf.visibility;
      sf.moClass = sc;
      sc.fields.put(sf.name, sf);
      logger.log(BasicLevel.DEBUG, "New SpeedoField for EJB field: "
View Full Code Here

                + ": try to define a secondary table ("
                + st.name()
                + ") without defining names of referenced columns in main table.");
            continue;
          }
          SpeedoField sf;
          try {
            sf = sc.getUniquePKField();
          } catch (SpeedoException e) {
            nbErrors++;
            logger.log(BasicLevel.ERROR, sc.getSourceDescShort()
View Full Code Here

    }

    public void visitExtension(SpeedoExtension se) throws SpeedoException {
        debug = logger.isLoggable(BasicLevel.DEBUG);
    if (se.owner instanceof SpeedoTuple) {
      SpeedoField sf = ((SpeedoTuple) se.owner).moField;
      SpeedoExtension oldse = sf.getExtensionByKey(se.key);
      if (oldse != null) {
        //The extension already exist on the SpeedoField
        if ((se.value == null && oldse.value!= null)
          || se.value != null && !se.value.equals(oldse.value)) {
          //different value ==> exception
View Full Code Here

    }
    // target is completed; perform analysis
    for (AttributeOverride a : target) {
      // TODO:
      // Look for the field in inherited classes
      SpeedoField inhsf = sc.getInheritedField(a.name());
      if (inhsf == null) {
        nbErrors++;
        logger.log(BasicLevel.ERROR, sc.getSourceDescShort()
            + ": overriden attribute does not exist in inherited class - overriding ignored");
        continue;
View Full Code Here

   */
  private SpeedoColumn searchColumn(SpeedoClass sc, String cn, SpeedoTable t) {
    SpeedoColumn c = null;
    Iterator itf = sc.fields.values().iterator();
    while (itf.hasNext()) {
      SpeedoField ft = (SpeedoField) itf.next();
      for (int k = 0; k < ft.columns.length; k++) {
        if (ft.columns[k].table != t) {
          continue;
        }
        if (ft.columns[k].name.equals(cn)) {
View Full Code Here

            sf.isCoherentReverseField = true;
        }
        if (sf.reverseField == null) {
            return;
        }
        SpeedoField reverse = sf.getReverseField();
        if (reverse == null) {
            throw new SpeedoException("No reverse field '" + sf.reverseField
                    + "' found for the " + sf.getSourceDesc());
        }
        if (reverse.reverseField == null) {
            //fill the info about the current field on its reverse
            reverse.reverseField = sf.name;
            reverse.isCoherentReverseField = sf.isCoherentReverseField;
        } else if (!reverse.reverseField.equals(sf.name)) {
            throw new SpeedoException("Incoherent reverse field between the "
                    + sf.getSourceDesc() + " and the "
                    + reverse.getSourceDesc());
        }

        // compute relationType
        if (sf.jdoTuple != null) {
            if (reverse.jdoTuple != null) {
View Full Code Here

                    + sc.moPackage.xmlDescriptor.xmlFile));
            super.visitExtension(se);
            return;
        }

        SpeedoField sf = (SpeedoField) se.owner;
        sf.reverseField = se.value;
        sf.isCoherentReverseField = true;
        SpeedoField reverse = sf.getReverseField();
        if (reverse == null) {
            throw new SpeedoException("No reverse field '" + sf.reverseField
                    + "' found for the " + sf.getSourceDesc());
        }
        checkExtension(sf, reverse,
View Full Code Here

            logger.log(BasicLevel.DEBUG, "Class " + sc.getFQName() + ": version: " + SpeedoVersion.toString(sc.version.strategy));
      }
      //if a version strategy has been defined
      if (sc.version.strategy != SpeedoVersion.NO_VERSION) {
        //create a speedofield
        SpeedoField sf = new SpeedoField();
        sf.visibility = Constants.ACC_PUBLIC;
        sf.name = "speedo" + SpeedoVersion.toString(sc.version.strategy);
        //  equivalent for long in ASM
        sf.type = "J";
        //create a speedo extension for the sql name
        SpeedoExtension se = new SpeedoExtension("speedo","sql-name", sf.name.toUpperCase(), sf);
        sf.addExtension(se);
        sc.add(sf, true, logger);
      }
    }
    super.visitClass(sc);
  }
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.