Package org.objectweb.jorm.metainfo.api

Examples of org.objectweb.jorm.metainfo.api.Class


    public void createClassIdentifierNameDefMapping(
            ClassMapping cm,
            NameDef nd,
            SpeedoClass sc,
            MIBuilderHelper mibh) throws PException, SpeedoException {
        Class clazz = (Class) nd.getParent();
        RdbClassMapping rcm = (RdbClassMapping) cm;
        if (nd.isFieldName()) {
            //The identifier of the class is based on a single field
            PrimitiveElement pe = (PrimitiveElement) clazz.getTypedElement(nd
                    .getFieldName());
            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) + "'.");
View Full Code Here


        }
        RdbClassMultiMapping trcm = (RdbClassMultiMapping) tclass.jormclass
                .getClassProject(cm.getProjectName()).getMapping(
                        cm.getMapperName()).getClassMapping();
        NameDef tnd = (NameDef) trcm.getIdentifierMapping().getLinkedMO();
        Class jclass = sf.moClass.jormclass;
        if (sf.join == null) {
            createLocalClassRefNameDefMapping(rcm, jclass, sf, nd, tnd, tclass);
        } else {
            createExternalClassRefNameDefMapping(rcm, jclass, sf, nd, trcm, tnd, tclass);
        }
View Full Code Here

            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:
                //Create the join table for the Generic class
                t = rgcm.createRdbTable(sf.join.extTable.name);
                if (reverseField.mappedByReversefield
View Full Code Here

        debug = logger.isLoggable(BasicLevel.DEBUG);
        if (debug) {
            logger.log(BasicLevel.DEBUG,
                    "Verify the definition of the class " + clas.getFQName());
        }
        Class classJorm = manager.getClass(clas.getFQName());
        if (classJorm == null) {
            throw new SpeedoException("Jorm description of the class '"
                    + clas.getFQName() + "' is not availlable");
        }
        NameDef pName = null;
        SpeedoClass sc = clas;
        while(sc.getSuperClassName() != null) {
            SpeedoClass scl = sc;
            sc = sc.moPackage.xmlDescriptor.smi.getSpeedoClass(sc.getSuperClassName(), sc.moPackage);
            if (sc == null) {
                throw new SpeedoException("Class " + scl.getFQName()
                        + " not defined in the jorm meta information");
            }
        }
        Class pclassJorm = manager.getClass(sc.getFQName());
        pName = getClassNameDef(pclassJorm);

        if (classJorm == null) {
            throw new SpeedoXMLError("Class '" + clas.name + "' not defined in JORM metadata");
        }
View Full Code Here

                            String projectName,
                            String mapperName,
                            JormMIMappingBuilder mb,
                            Collection createdMOs)
            throws SpeedoException, PException {
        Class clazz = manager.getClass(sc.getFQName());
        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

  private void createPrimitiveFields(SpeedoClass sc,
                                    String projectName,
                                    String mapperName,
                          JormMIMappingBuilder mb)
          throws SpeedoException, PException {
    Class clazz = sc.jormclass;
    ClassMapping cm = clazz.getClassProject(projectName)
        .getMapping(mapperName).getClassMapping();
        logger.log(BasicLevel.DEBUG, "Generate the Jorm MI for the class "
                + clazz.getFQName());
        for (Iterator fieldsIt = sc.fields.values().iterator();fieldsIt.hasNext();) {
            SpeedoField sp = (SpeedoField) fieldsIt.next();
            createPrimitiveField(sc, clazz, sp, cm, mb);
        }
    }
View Full Code Here

                                 String projectName,
                                 String mapperName,
                                 JormMIMappingBuilder mb,
                                 Collection createdMOs)
            throws SpeedoException, PException {
        Class clazz = manager.getClass(sc.getFQName());
        logger.log(BasicLevel.DEBUG, "Generate the Jorm MI for the references of class "
                + clazz.getFQName());
        Mapping mapping = null;
        ClassMapping cm = null;
        if (projectName != null && mapperName != null) {
            mapping = clazz.getClassProject(projectName)
                .getMapping(mapperName);
            cm = mapping.getClassMapping();
        }
        Iterator fieldsIt = sc.fields.values().iterator();
        //System.out.println("Manage reference of the class " + sc.getFQName());
        while (fieldsIt.hasNext()) {
            SpeedoField sp = (SpeedoField) fieldsIt.next();
          if (clazz.getTypedElement(sp.name) != null) {
                //the primitive element is already managed before(createJormClass)
                continue;
            }
          Type t = Type.getType(sp.type);
            String javatype = t.getClassName();
            if (!isGenClassRef(javatype)) {
                //                     reference to a class                   //
                //============================================================//
              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 '"
View Full Code Here

    protected PNameField extent(String classname, String alias) throws SpeedoException, MedorException {
        if (classname == null) {
            throw new NullPointerException("class name not defined");
        }
        Class theClass = jmiManager.getClass(classname);
        if (theClass == null) {
            throw new SpeedoException
                ("Class '" + classname +
                 "' has not been declared in the jorm meta information");
        }
View Full Code Here

    private GenClassMapping getGenClassMapping(GenClassRef gcr, Class clazz)
            throws SpeedoException {
        String gcid = gcr.getGenClassId();
        GenClassMapping gcm = getMapping(clazz).getGenClassMapping(gcid);
        if (gcm == null) {
            Class klass = clazz;
            Collection superclasses = klass.getSuperClasses();
            while (gcm == null && !superclasses.isEmpty()) {
                klass = (Class) superclasses.iterator().next();
                gcm = getMapping(klass).getGenClassMapping(gcid);
                superclasses = klass.getSuperClasses();
            }
        }
        if (gcm == null) {
            throw new SpeedoException("No GenClassMapping found for the field "
                    + gcid);
View Full Code Here

            throws SpeedoException {
        String rid = cr.getName();
        ReferenceMapping rm = getMapping(clazz).getClassMapping()
                .getReferenceMapping(rid);
        if (rm == null) {
            Class klass = clazz;
            Collection superclasses = klass.getSuperClasses();
            while (rm == null && !superclasses.isEmpty()) {
                klass = (Class) superclasses.iterator().next();
                rm = getMapping(klass).getClassMapping().getReferenceMapping(
                        rid);
                superclasses = klass.getSuperClasses();
            }
        }
        if (rm == null) {
            throw new SpeedoException(
                    "No ReferenceMapping found for the field " + rid);
View Full Code Here

TOP

Related Classes of org.objectweb.jorm.metainfo.api.Class

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.