Package org.objectweb.jorm.metainfo.api

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


            NameDef nd,
            SpeedoField sf) throws PException, SpeedoException {
        RdbGenClassMapping rgcm = (RdbGenClassMapping) gcm;
        //Find the table (JORM Meta object)
        RdbTable table = rgcm.getRdbTable();
        GenClassRef gcr = (GenClassRef) gcm.getLinkedMO();
        if (nd.isFieldName()) {
            createPEMInGC(gcr.getHiddenField(nd.getFieldName()),
                    sf.columns[0], table, nd, null);
        } else {
            SpeedoClass tclass = sf.getReferencedClass();
            RdbClassMultiMapping trcm = getClassMapping(
                    (Mapping) gcm.getParent(), tclass.jormclass);
            NameDef tnd = (NameDef) trcm.getIdentifierMapping().getLinkedMO();
            Map tndproj = tnd.getNameRef().getProjection();
            Iterator it = nd.getNameRef().getProjection().entrySet()
                    .iterator();
            while (it.hasNext()) {
                Map.Entry me = (Map.Entry) it.next();
                //find the field in the genclass used in by this name def
                PrimitiveElement pe = gcr.getHiddenField((String) me.getValue());
                //find the pk column
                RdbPrimitiveElementMapping tpem = getPEMOfField(tclass,
                        (Mapping) gcm.getParent(),
                        (String) tndproj.get(me.getKey()));
                //find the fk column name
View Full Code Here


     * referencing a generic class.
     */
    public void createGenClassIdentifierNameDefMapping(GenClassMapping gcm,
            NameDef nd, SpeedoField sf, MIBuilderHelper mibh)
            throws PException, SpeedoException {
        GenClassRef gcr = (GenClassRef) nd.getParent();
        RdbGenClassMapping rgcm = (RdbGenClassMapping) gcm;
        RdbTable table = rgcm.getRdbTable();
        if (nd.isFieldName()) {
            PrimitiveElement pe = gcr.getHiddenField(nd.getFieldName());
            SpeedoJoinColumn col = (SpeedoJoinColumn) sf.join.columns.get(0);
            createPEMInGC(pe, col.column, table, nd, null);
        } else {
            //get the ClassMapping of class owning the generic class
            RdbClassMultiMapping rcmOwner = (RdbClassMultiMapping) sf.moClass.jormclass
                    .getClassProject(rgcm.getProjectName()).getMapping(
                            rgcm.getMapperName()).getClassMapping();
            //get the namedef identifier of the generic class owner
            NameDef ndIdOwner = (NameDef) rcmOwner.getIdentifierMapping()
                    .getLinkedMO();
            //:compute the prefix for genclass field(s) used as identifier
            String prefix = mibh.getNameDefFieldPrefix(gcr, true, true, sf);
            Map classNdProj = ndIdOwner.getNameRef().getProjection();
            Iterator it = nd.getNameRef().getProjection().entrySet().iterator();
            while (it.hasNext()) {
                Map.Entry me = (Map.Entry) it.next();
                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

          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 '"
                            + sc.moPackage.xmlDescriptor.xmlFile
                                + "' has not been found among the persitent classes : "
                            + manager.getClasses());
                    }
                    cr = gcr.createClassRef(tclass);
                } else {
                    throw new SpeedoException(
                            "unmanaged the inner-element of the field '"
                            + sp.name + "' of the class '" + sc.getFQName()
                            + "' : " + innerType);
                }
                //Map the element of the generic class
                if (mapping != null) {
                    gcm = mb.createGenClassMapping(gcr, sp, mapping);
                    if (gcr.isPrimitive()) {
                        mb.createGenClassElementMapping(gcr.getPrimitiveElement(), sp, gcm);
                    } else {
                        NameDef elemNd = cr.createRefNameDef();
                        nmf.getNamingManager(tsc).defineClassReferenceNameDef(elemNd, cr, sp, sc, gcm, this, mb);
                        //fillNameDef(elemNd, tsc, sc, gcr, gcr, gcm, mb, false, true, true, createdMOs);
                        gcm.createReferenceMapping(sp.name, elemNd);
                        cm.addDependency(tsc.getFQName());
                    }
                }

                // reference to a generic class from the class
                NameDef refNd = gcr.createRefNameDef();
                nmf.getNamingManager(sc).defineGenClassReferenceNameDef(refNd, gcr, sp, sc, cm, this, mb);
                //fillNameDef(refNd, sc, sc, clazz, gcr, cm, mb, false, false, false, createdMOs);
                if (cm != null) {
                    cm.createReferenceMapping(sp.name, refNd);
                }

                //identifier of the gen class
                NameDef gcidNd = gcr.createIdNameDef();
                nmf.getNamingManager(sc).defineGenClassIdentifierNameDef(
                        gcidNd, gcr, sp, sc, gcm, this, mb);
                //fillNameDef(gcidNd, sc, sc, gcr, gcr, gcm, mb, true, true, true, createdMOs);
                if (gcm != null) {
                    gcm.createIdentifierMapping(gcidNd);
                }

                //index of the gen class
                java.lang.Class gcClass;
                try {
                    gcClass = java.lang.Class.forName(javatype);
                } catch (ClassNotFoundException e) {
                    throw new SpeedoException(
                            "The multivalued field '" + sp.name
                            + "' of the class '" + sc.getFQName()
                            + "' is not a well known class " + javatype, e);
                }
                if (isSubType(gcClass, java.util.List.class)) {
                    PrimitiveElement pe = gcr.createHiddenField(
                            LIST_INDEX, PTypeSpace.INT, PType.NOSIZE, PType.NOSIZE);
                    if (gcm != null) {
                        mb.createGenClassIndexMapping(pe, sp, gcm);
                    }
                    gcr.addIndexField(LIST_INDEX);
                } else if (isSubType(gcClass, java.util.Map.class)) {
          String keyfield = sp.getExtensionValueByKey(SpeedoProperties.KEY_FIELD);
          if (keyfield == null) {
            keyfield = MAP_INDEX;
          }
                    PrimitiveElement pe = gcr.createHiddenField(
                            keyfield, getMapKeyPType(sp), PType.NOSIZE, PType.NOSIZE);
                    if (gcm != null) {
                        mb.createGenClassIndexMapping(pe, sp, gcm);
                    }
                    gcr.addIndexField(pe.getName());
                }
            }
        }

    }
View Full Code Here

                id = JormPathHelper.getPath(((ClassRef) o));
                SpeedoClass tsc = xml.getSpeedoClass(((ClassRef) o)
                        .getMOClass().getFQName(), true);
                jormConfigs(nd, tsc, sc.jormclass, id, classProperties);
            } else if (o instanceof GenClassRef) {
                GenClassRef gcr = (GenClassRef) o;
                nd = getRefNameDef(gcr, sc.jormclass);
                id = JormPathHelper.getPath((GenClassRef) o, false);
                jormConfigs(nd, sc, gcr, id, classProperties);
                while (gcr.isGenClassRef()) {
                    gcr = gcr.getGenClassRef();
                    nd = getElemNameDef(gcr, sc.jormclass);
                    id = JormPathHelper.getPath(gcr, false);
                    jormConfigs(nd, sc, gcr, id, classProperties);
                }
                if (gcr.isClassRef()) {
                    ClassRef cr = gcr.getClassRef();
                    nd = getElemNameDef(gcr, sc.jormclass);
                    id = JormPathHelper.getPath(cr);
                    SpeedoClass tsc = xml.getSpeedoClass(cr.getMOClass()
                            .getFQName(), true);
                    jormConfigs(nd, tsc, cr, id, classProperties);
View Full Code Here

      String[] s = getCollectionClass(asmType, scp.personality);
      f.memoryType = s[0];
      f.gcproxy = s[1];
      f.gcJDKImpl = s[2];
      GenClassRef gcr = (GenClassRef) te;
      if (gcr.isClassRef()) {
        f.accessorClassName = NamingRules.fieldsName(gcr.getClassRef().getMOClass().getFQName());
      }
    } else {
      f.jormcast = te.getType().getJormName();

      f.memoryType = te.getType().getJormName();
View Full Code Here

TOP

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

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.