Package org.objectweb.speedo.metadata

Examples of org.objectweb.speedo.metadata.SpeedoClass


        for (Iterator itDesc = xmls.iterator(); itDesc.hasNext();) {
            SpeedoXMLDescriptor desc = (SpeedoXMLDescriptor) itDesc.next();
            for (Iterator itPack = desc.packages.values().iterator(); itPack.hasNext();) {
                SpeedoPackage sp = (SpeedoPackage) itPack.next();
                for (Iterator itclass = sp.classes.values().iterator(); itclass.hasNext();) {
                    SpeedoClass sc = (SpeedoClass) itclass.next();
                    String name = sp.name + '.' + sc.name;
                    String accessorName = NamingRules.accessorName(name);
                    String mappingName = sp.name + '.' + scp.mapperName + '.' + NamingRules.mappingName(sc.name);
                    String iteratorName = sp.name + '.' + scp.mapperName + '.' + sc.name + "ResultIterator";
                    String fieldsName = NamingRules.fieldsName(name);
View Full Code Here


                + " the interface " + pngcn);
        logger.log(BasicLevel.DEBUG, "Add to the class " + className
                + " the interface " + sncn);
        super.visit(version, access, className, superName, itfs, sourceFile);

    SpeedoClass pkFieldClassHolder = speedoClass;
    if (speedoClass.getSuperClassName() != null) {
      pkFieldClassHolder = speedoClass.getAncestor();
    }

        for(Iterator it = pkFieldClassHolder.fields.values().iterator(); it.hasNext();) {
View Full Code Here

            SpeedoXMLDescriptor desc = (SpeedoXMLDescriptor) itDesc.next();
            for (Iterator itPack = desc.packages.values().iterator(); itPack.hasNext();) {
                SpeedoPackage sp = (SpeedoPackage) itPack.next();

                for (Iterator itclass = sp.classes.values().iterator(); itclass.hasNext();) {
                    SpeedoClass sc = (SpeedoClass) itclass.next();
                    String className = sc.getFQName();

                    String c;

                    c = toJavaFileName(NamingRules.fieldsName(className));
                    compiler.createInclude().setName(c);
                    logger.log(BasicLevel.DEBUG, c);

                    c = toJavaFileName(NamingRules.homeName(className));
                    compiler.createInclude().setName(c);
                    logger.log(BasicLevel.DEBUG, c);
/*
                    c = toJavaFileName(NamingRules.fpncName(className));
                    compiler.createInclude().setName(c);
                    logger.log(BasicLevel.DEBUG, c);
*/
                    c = toJavaFileName(NamingRules.kfpncName(className));
                    compiler.createInclude().setName(c);
                    logger.log(BasicLevel.DEBUG, c);

                    c = toJavaFileName(NamingRules.fqMappingName(className));
                    compiler.createInclude().setName(c);
                    logger.log(BasicLevel.DEBUG, c);

                    toCompil +=  2; //field + mapping
                    if (sc.jormclass.getSubClasses().isEmpty()) {
                        toCompil += 1; // [ + (fpnc | kfpnc)]
                    }

                    if (sc.getIdentityType() == SpeedoIdentity.USER_ID
                            && sc.generateObjectId()) {
                        c = NamingRules.generatedObjectIdName(sc.getFQName())
                        .replace('.', '/') + ".java";
                        compiler.createInclude().setName(c);
                        logger.log(BasicLevel.DEBUG, c);
                        toCompil +=  1;
                    }
View Full Code Here

 
  public void fillFieldInfo(Field f,
                SpeedoField sp,
                int nbField,
                Map ctx) throws SpeedoException {
    SpeedoClass moClass = sp.moClass;
    f.name = sp.name;
    TypedElement te = moClass.jormclass.getTypedElement(f.name);
    f.type = sp.type();
        f.jvmType = sp.type;
    f.nameUpperFirst = Character.toUpperCase(f.name.charAt(0))
      + f.name.substring(1);
    f.number = sp.number;
    f.getter = NamingRules.getterName(sp.moClass, sp.name);
    f.setter = NamingRules.setterName(sp.moClass, sp.name);
    f.isClassical = isClassicalType(sp.type());
    f.modifier = sp.modifier();
    f.isKey = sp.primaryKey;
    f.jormmeth = jormTools.upperFL(te.getName());
    f.jormfield = te.getName();
    f.isNotauthorizedToBeNull = (sp.nullValue == SpeedoNullValue.EXCEPTION);
    f.declaration = sp.publicSignature();
    f.defaultFetchGroup = sp.defaultFetchGroup;
    String cacheName = sp.getExtensionValueByKey(SpeedoProperties.USER_CACHE);
    if (cacheName != null) {
        f.userCacheNames = Collections.singleton(cacheName);
    } else {
        f.userCacheNames = Collections.EMPTY_SET;
    }

    // looks for identity type of the field and tests if it is an array
    Type fieldType = Type.getReturnType(sp.type);
    if (!f.isClassical && fieldType.getSort() == Type.OBJECT) {
      SpeedoClass jdoclass = scp.smi.getSpeedoClass(
        fieldType.getClassName(),
        sp.moClass.moPackage.xmlDescriptor);
      if (jdoclass != null) {
        f.isContainerId = jdoclass.identity.isDataStore();
      } else {
View Full Code Here

                 Map ctx,
                 Type asmType) throws SpeedoException {
    if (sp.relationType == SpeedoField.NO_BI_RELATION) {
      return;
    }
    SpeedoClass jdoClass = sp.moClass;
    f.reverse = sp.reverseField;
    f.reverseGetter = NamingRules.getterName(null, sp.reverseField);
    f.reverseSetter = NamingRules.setterName(null, sp.reverseField);
    f.coherentSetter = NamingRules.coherentSetterName(sp.moClass, sp.name);
        SpeedoClass otherClass = null;
    switch (sp.relationType) {
    case SpeedoField.ONE_ONE_BI_RELATION:
      f.is11Relation = true;
            otherClass = jdoClass.moPackage.xmlDescriptor.getSpeedoClass(sp.type(), true);
      break;

    case SpeedoField.ONE_MANY_BI_RELATION:
      f.is1MRelation = true;
      if (sp.jdoTuple instanceof SpeedoCollection) {
        f.elemType = (String) ((SpeedoCollection) sp.jdoTuple).elementType;
      } else if (sp.jdoTuple instanceof SpeedoMap) {
        f.elemType = (String) ((SpeedoMap) sp.jdoTuple).valueType;
        f.keyField = NamingRules.getterName(null,
          sp.getExtensionValueByKey(SpeedoProperties.KEY_FIELD))
          + "()";
      } else {
        throw new SpeedoException(
          "Unmanaged relation with this multivalued field: "
          + sp.jdoTuple);
      }
      if (f.elemType.indexOf('.') == -1) {
        f.elemType = jdoClass.moPackage.name + '.' + f.elemType;
      }
            otherClass = jdoClass.moPackage.xmlDescriptor.getSpeedoClass(f.elemType, true);
      ctx.put("needSpeedoGenClassListener", new Boolean(true));
      break;

    case SpeedoField.MANY_ONE_BI_RELATION:
      f.isM1Relation = true;
      // speedoClass corresponding to sp.type()
      otherClass = jdoClass.moPackage.xmlDescriptor.getSpeedoClass(sp.type(), true);
            f.reverseField = otherClass.getField(f.reverse);
            // number of the reverse field
      f.reverseNumber = f.reverseField.number;
      if (f.reverseField.jdoTuple instanceof SpeedoMap) {
        f.reverseIsMap = true;
                String reverseKeyFieldName = f.reverseField.getExtensionValueByKey(SpeedoProperties.KEY_FIELD);
                f.reverseKField = jdoClass.getField(reverseKeyFieldName);
                f.reverseKeyField = NamingRules.getterName(null,reverseKeyFieldName) + "()";
      }
      break;

    case SpeedoField.MANY_MANY_BI_RELATION:
      f.isMMRelation = true;
            f.reverseIsMap = sp.jdoTuple instanceof SpeedoMap;
      f.elemType = (String) ((SpeedoCollection) sp.jdoTuple).elementType;
      if (f.elemType.indexOf('.') == -1) {
        f.elemType = jdoClass.moPackage.name + '.' + f.elemType;
      }
      // speedoClass corresponding to f.elemType
            otherClass = jdoClass.moPackage.xmlDescriptor.getSpeedoClass(f.elemType, true);
      // number of the reverse field
      ctx.put("needSpeedoGenClassListener", new Boolean(true));
      break;
    }
        f.reverseField = otherClass.getField(f.reverse);
        f.reverseNumber = f.reverseField.number;
  }
View Full Code Here

    for (Iterator itDesc = scp.getXmldescriptor().values().iterator(); itDesc.hasNext();) {   
          SpeedoXMLDescriptor desc = (SpeedoXMLDescriptor) itDesc.next();   
          for (Iterator itPack = desc.packages.values().iterator(); itPack.hasNext();) {   
              SpeedoPackage sp = (SpeedoPackage) itPack.next();   
              for (Iterator itclass = sp.classes.values().iterator(); itclass.hasNext();) {   
                  SpeedoClass clazz = (SpeedoClass) itclass.next();   
                  clazz.computeFieldNumbers();   
              }   
          }   
      }
  }
View Full Code Here

        n = classNode.getAttributes().getNamedItem("name");
        if (n == null) {
            logger.log(BasicLevel.ERROR, "Attribute 'name' for tag class required.");
            return;
        }
        SpeedoClass c = new SpeedoClass();
        c.name = n.getNodeValue();
        p.addClass(c, true, logger);

        //attribute identity-type
        n = classNode.getAttributes().getNamedItem("identity-type");
        if (n != null)
            c.setIdentityType(SpeedoIdentity.getStrategy(n.getNodeValue()));
         
        //attribute object-id
        n = classNode.getAttributes().getNamedItem("objectid-class");
        if (n != null) {
            c.identity.objectidClass = n.getNodeValue();
            c.setIdentityType(SpeedoIdentity.USER_ID);
        }

        //attribute requires-extent is not taken into account

        //attribute detachable
        n = classNode.getAttributes().getNamedItem("detachable");
        if (n != null)
            c.isDetachable = Boolean.valueOf(n.getNodeValue()).booleanValue();
             
        //attribute persistence-capable-superclass
        n = classNode.getAttributes().getNamedItem("persistence-capable-superclass");
        if (n != null) {
            if (c.inheritance == null) {
                c.inheritance = new SpeedoInheritance(c);
            }
            c.inheritance.superClassName = n.getNodeValue();
        }
        //attribute table
        n = classNode.getAttributes().getNamedItem("table");
        if (n != null) {
            c.mainTable = new SpeedoTable();
            c.mainTable.name = n.getNodeValue();
        }
        if (c.mainTable == null) {
            if (c.inheritance == null
                    || c.inheritance.strategy == SpeedoInheritance.STRATEGY_NEW_TABLE) {
                c.mainTable = new SpeedoTable();
                c.mainTable.name = c.name.toUpperCase();
            }
        }

        logger.log(BasicLevel.DEBUG, "New class: "
                + "name=" + c.name
                + "  / id = " + c.getIdentityType()
                + "  / idClass = " + c.identity.objectidClass
                + "  / detachable = " + c.isDetachable
        );
       
        Map classChildren = groupChildrenByName(classNode);
        //extension*, implements*, datastore-identity?, inheritance?, version?,
        // join*, foreign-key*, index*, unique*, field*, query*, fetch-group*, extension*
        treatExtensions((List) classChildren.get("extension"), c);
        List l = (List) classChildren.get("datastore-identity");
        if (l != null) {
            treatDataStoreId((Node) l.get(0), c);
        }
        l = (List) classChildren.get("inheritance");
        if (l != null) {
            treatInheritance((Node) l.get(0), c);
        }
        l = (List) classChildren.get("version");
        if (l != null) {
            treatVersion((Node) l.get(0), c);
        }
        l = (List) classChildren.get("join");
        if (l != null) {
            for (int j = 0; j < l.size(); j++) {
                Object[] os = getJoin((Node) l.get(j), null);
                SpeedoJoin join = (SpeedoJoin) os[0];
                String tableName = (String) os[1];
                //define an external/secondary table
                c.addJoin(join);
                if (c.mainTable != null) {
                    join.mainTable = c.mainTable;
                }
                if (tableName != null) {
                    join.extTable = new SpeedoTable();
View Full Code Here

            for (Iterator itPack = desc.packages.values().iterator(); itPack.hasNext();) {
                SpeedoPackage sp = (SpeedoPackage) itPack.next();
                //base directory for new files
                String baseDir = scp.output + fs + sp.name.replace('.', fs) + fs;
                for (Iterator itclass = sp.classes.values().iterator(); itclass.hasNext();) {
                    SpeedoClass sClass = (SpeedoClass) itclass.next();

                    //asm has not failed on this class
                    if (sClass.enhancementFailed())
                        continue;
                    String[] filenames = {
                        baseDir + NamingRules.fieldsName(sClass.name) + ".java",
                        baseDir + NamingRules.homeName(sClass.name) + ".class",
                        baseDir + sClass.identity.objectidClass + ".java"};
                    try {
                        //fields
                        vl.setLog(loggers[0]);
                        vgs[0].generate(sClass, filenames[0]);
                        generatedFiles ++;
                        //home
                        vl.setLog(loggers[1]);
                        vgs[1].generate(sClass, filenames[1]);
                        generatedFiles ++;
                        //oid
                        if (sClass.identity.oidClassAutoCalculated) {
                            vl.setLog(loggers[2]);
                            vgs[2].generate(sClass, filenames[2]);
                            generatedFiles ++;
                            logger.log(BasicLevel.WARN,
                                    "No object id class defined for the class '"
                                    + sClass.getFQName()
                                    + "': use the generated class: '"
                                    + NamingRules.generatedObjectIdName(sClass.getFQName()) + "'");
                        }
                        logger.log(BasicLevel.INFO, "Classes generated for "
                                + sClass.getFQName());
                    } catch (SpeedoException e) {
                        logger.log(BasicLevel.ERROR,
                                "ERROR during the speedo generation of files "
                                + filenames[0] + ", " + filenames[1] + " or "
                                + filenames[2], e);
View Full Code Here

  }

  public boolean isParentField(SpeedoClass sc, String fn) {
    if (sc.getSuperClassName() == null)
      return false;
    SpeedoClass psc = sc.moPackage.xmlDescriptor.getSpeedoClass(
      sc.getSuperClassName(), true);
    return psc != null && psc.fields.get(fn) != 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.