Package org.objectweb.speedo.metadata

Examples of org.objectweb.speedo.metadata.SpeedoField


      //try to find the column name(s)
      if (si.columnNames.isEmpty()) {
        for (Iterator it = si.fieldNames.iterator(); it.hasNext(); ) {
          String fieldName = (String) it.next();
          //try to add the column name(s) to the index
              SpeedoField sf = (SpeedoField) si.speedoClass.fields.get(fieldName);
              if( sf.columns != null  && sf.columns.length != 0) {
                for(int i = 0; i < sf.columns.length; i++) {
                  si.columnNames.add(sf.columns[i].name);
                }
              } else {
View Full Code Here


     * java.lang.Long instead of a long. In this case the strategy is
     * SpeedoIdentity.DATASTORE_OLONG.
     */
    private final void treatDataStoreLong(final SpeedoClass sc) throws SpeedoException {
        if (sc.identity.strategy == SpeedoIdentity.DATASTORE_NATIVE) {
            SpeedoField sf = sc.getUniquePKField();
            if (sf != null && "Ljava/lang/Long;".equals(sf.type)) {
                sc.identity.strategy = SpeedoIdentity.DATASTORE_OLONG;
            }
        }
    }
View Full Code Here

    private void checkColumn(SpeedoClass sc, SpeedoDiscriminator sd) throws SpeedoException {
        for (int i = 0; i < sd.elements.size(); i++) {
            SpeedoElement se = (SpeedoElement) sd.elements.get(i);
            if (se instanceof SpeedoNoFieldColumn) {
                SpeedoColumn col = ((SpeedoNoFieldColumn) se).column;
                SpeedoField sf = sc.getFieldFromColumn(col.name);
                if (sf != null) {
                    // the specified column correspond to a primitive persistent
                    // field. Then the SpeedoNoFieldColumn is replaced by the
                    // the found field.
                    sd.elements.set(i, sf);
View Full Code Here

            if (pe == null) {
                throw new SpeedoException(
                        "impossible to map the fields of the namedef of the metaobject '"
                                + JormPathHelper.getPath(clazz) + "'.");
            }
            SpeedoField sf = sc.getField(pe.getName());
            if (sf == null) {
                // The single field used as identifier is not a visible
                // persistent field
                if (sc.identity.columns != null
                        && sc.identity.columns.length == 1
                        && sc.identity.columns[0] != null
                        && sc.identity.columns[0].column != null
                        && sc.identity.columns[0].column.name != null) {
                    // the column name of the hidden identity field has been
                    // specified
                    createFieldMapping(pe,
                            sc.identity.columns[0].column.name,
                            sc.identity.columns[0].column.sqlType,
                            rcm.getMainRdbTable(),
                            null);
                } else {
                    // No column name specified
                    createFieldMapping(pe, (SpeedoCommonField) null, cm);
                }
            }
        } else {
            // The identifier of the persistent class is based on several
            // persistent field.
            Collection c = nd.getNameRef().getProjection().values();
            int i = 0;
            for (Iterator it = c.iterator(); it.hasNext();) {
                PrimitiveElement pe = (PrimitiveElement) clazz
                        .getTypedElement((String) it.next());
                if (pe == null) {
                    throw new SpeedoException(
                            "impossible to map the fields of the namedef of the metaobject '"
                                    + JormPathHelper.getPath(clazz) + "'.");
                }
                //find the corresponding Speedo meta object.
                SpeedoField sf = sc.getField(pe.getName());
                if (sf == null) {
                    SpeedoNoFieldColumn col = getIdentityColumn(sc.identity, pe
                            .getName());
                    if (col != null) {
                        //column name is specified for the field
View Full Code Here

                String compositeFieldName = (String) me.getValue();
                //get the primitive element corresponding in the Generic class
                PrimitiveElement peInGC =
                        gcr.getHiddenField(compositeFieldName);
                String classIdFieldName = (String) classNdProj.get(me.getKey());
                SpeedoField pkfield = (SpeedoField) sf.moClass.getField(classIdFieldName);
                SpeedoColumn col = sf.getJoinColumn(pkfield);
                createPEMInGC(peInGC, col, table, nd, (String) me.getKey());
            }
        }
    }
View Full Code Here

                        + sf.join.extTable.name);
            }
            //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) {
View Full Code Here

      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
    SpeedoField keyfield = sf.getFieldOfTheReferencedClass(se.value);
    if (keyfield == null) {
      throw new SpeedoException("No key field '" + se.value
                    + "' found for the" + sf.getSourceDesc());
    }
    SpeedoMap sm = (SpeedoMap) sf.jdoTuple;
    if (sm.keyType != null && ((String) sm.keyType).length() > 0) {
      //check the key field type and the
      if (keyfield.type().equalsIgnoreCase((String) sm.keyType)) {
                throw new SpeedoException("Bad type for the key field '" + se.value
                        + "' found for the" + sf.getSourceDesc());
      }
    } else {
      //specify the map key type from the keyField type
      sm.keyType = keyfield.type();
    }

    // Add the SQL_NAME extension for the index field if it is specified
    // for the key field
    SpeedoExtension _se = keyfield.getExtensionByKey(SQL_NAME);
    if (_se != null) {
      _se = new SpeedoExtension(_se.vendorName, INDEX, _se.value, sf);
      sf.addExtension(_se);
    }

    // Add the SQL_TYPE extension for the index field if it is specified
    // for the key field
    _se = keyfield.getExtensionByKey(SQL_TYPE);
    if (_se != null) {
      _se = new SpeedoExtension(_se.vendorName, INDEX_TYPE, _se.value, sf);
      sf.addExtension(_se);
    }
    super.visitExtension(se);
View Full Code Here

                    sc.inheritance.discriminatorValues.put(sd.expression, se.value);
                }
            }
           
        } else if (se.owner instanceof SpeedoField) {
            SpeedoField sf = (SpeedoField) se.owner;
            if (SQL_NAME.equals(se.key)) {
              if (sf.getReferencedClass() == null) {
                  initColumnField(sf);
                  try {
                      sf.columns[0].name = se.value;
                  } catch (RuntimeException e) {
                      logger.log(BasicLevel.WARN, sf.getSourceDesc() + ", cols=" + sf.columns[0], e);
                      logger.log(BasicLevel.WARN, "se.value" + se.value);
                      throw e;
                  }
                  deprecate(SQL_NAME,"use the 'column' attribut of the tag 'field'.");
                } else {
                    logger.log(BasicLevel.WARN,
                            "Extension 'sql-name' cannot be specified for a non primitive field: " + sf.getSourceDesc());
                }
               
            } else if (SQL_TYPE.equals(se.key)) {
                if (sf.getReferencedClass() == null) {
                  initColumnField(sf);
                  sf.columns[0].sqlType = se.value;
                  deprecate(SQL_TYPE,"use the 'sql-type' attribut of the tag 'field'.");
                } else {
                    logger.log(BasicLevel.WARN,
                            "Extension 'sql-type' cannot be specified for a non primitive field: " + sf.getSourceDesc());
                }

            } else if (SIZE.equals(se.key)) {
                if (sf.getReferencedClass() == null) {
                  initColumnField(sf);
                  sf.columns[0].length = Integer.parseInt(se.value);
                  deprecate(SIZE,"use the 'size' attribut of the tag 'field'.");
                } else {
                    logger.log(BasicLevel.WARN,
                            "Extension 'size' cannot be specified for a non primitive field: " + sf.getSourceDesc());
                }

            } else if (SCALE.equals(se.key)) {
                if (sf.getReferencedClass() == null) {
                  initColumnField(sf);
                  sf.columns[0].scale = Integer.parseInt(se.value);
                  deprecate(SCALE,"use the 'scale' attribut of the tag 'field'.");
                } else {
                    logger.log(BasicLevel.WARN,
                            "Extension 'scale' cannot be specified for a non primitive field: " + sf.getSourceDesc());
                }
               
            } else if (REVERSE_FIELD.equals(se.key)) {
                //@see org.objectweb.speedo.generation.mivisitor.ReverseFieldAdder
            } else if (ELEMENT.equals(se.key)) {
                if (sf.jdoTuple != null && sf.getReferencedClass() == null) {
                  initColumnField(sf);
                  sf.columns[0].name = se.value;
                  deprecate(ELEMENT,"use the 'column' attribut of the tag 'field'.");
                } else {
                    logger.log(BasicLevel.WARN,
                            "Extension 'element-sql-name' cannot be specified for a field which is not a collection of primitive element: " + sf.getSourceDesc());
                }
               
            } else if (ELEMENT_TYPE.equals(se.key)) {
                if (sf.jdoTuple != null && sf.getReferencedClass() == null) {
                  initColumnField(sf);
                  sf.columns[0].sqlType = se.value;
                  deprecate(ELEMENT_TYPE,"use the 'column' attribut of the tag 'field'.");
                } else {
                    logger.log(BasicLevel.WARN,
                            "Extension 'element-sql-type' cannot be specified for a field which is not a collection of primitive element: " + sf.getSourceDesc());
                }
            } else if (INDEX.equals(se.key)) {
                if (sf.jdoTuple instanceof SpeedoCollection) {
                    initCollectionIndexColumn(
                            (SpeedoCollection) sf.jdoTuple).name = se.value;
                } else if (sf.jdoTuple instanceof SpeedoMap) {
                    initMapKeyColumn((SpeedoMap) sf.jdoTuple).name = se.value;
                } else {
                    logger.log(BasicLevel.WARN,
                            "Extension 'index-sql-name' cannot be specified for a field which is not a collection or a map: " + sf.getSourceDesc());
                }
            } else if (INDEX_TYPE.equals(se.key)) {
                if (sf.jdoTuple instanceof SpeedoCollection) {
                    initCollectionIndexColumn(
                            (SpeedoCollection) sf.jdoTuple).sqlType = se.value;
                } else if (sf.jdoTuple instanceof SpeedoMap) {
                    initMapKeyColumn((SpeedoMap) sf.jdoTuple).sqlType = se.value;
                } else {
                    logger.log(BasicLevel.WARN,
                            "Extension 'index-sql-type' cannot be specified for a field which is not a collection or a map: " + sf.getSourceDesc());
                }
            }
           

        }
View Full Code Here

        if (sc.inheritance.discriminator == null) {
            sc.inheritance.discriminator = new SpeedoDiscriminator();
        }
        SpeedoDiscriminator sd = sc.inheritance.discriminator;
        sd.strategy = SpeedoDiscriminator.STRATEGY_MAP_VALUE;
        SpeedoField sf = sc.getField(value);
        if (sf == null) {
            sd.expression = value;
        } else if (!sd.elements.contains(sf)) {
            sd.elements.add(sf);
        }
View Full Code Here

    public void visitClass(SpeedoClass sc) throws SpeedoException {
        logger.log(BasicLevel.DEBUG, "Visit Class " + sc.name);
        super.visitClass(sc);
        visitExtension(sc);
        for(Iterator fieldIt = sc.fields.values().iterator(); fieldIt.hasNext();) {
            SpeedoField sf = (SpeedoField) fieldIt.next();
            visitField(sf);
        }
        for(Iterator it = sc.getTableIndexes().iterator(); it.hasNext(); ) {
          SpeedoIndex si = (SpeedoIndex) it.next();
          visitIndex(si, sc.moPackage);
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.