Examples of PrimitiveElement


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

            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) + "'.");
                }
                //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
                        createFieldMapping(pe, col.column.name,
                                col.column.sqlType, rcm.getMainRdbTable(),
View Full Code Here

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

            NameDef tnd,
            SpeedoClass tclass) throws PException, SpeedoException {
        RdbTable table = rcm.getRdbTable();
        //Map the name def of the reference over new local columns
        if (nd.isFieldName()) {
            PrimitiveElement pe = (PrimitiveElement) jclass
                    .getTypedElement(nd.getFieldName());
            RdbPrimitiveElementMapping pem = (RdbPrimitiveElementMapping) table
                    .getPrimitiveElementMappingByCol(sf.columns[0].name);
            if (pem == null) {
                // create it
                table.createPrimitiveElementMapping(pe,
                        sf.columns[0].name, sf.columns[0].sqlType,
                        false);
            } else {
                //it already exists
                //remove the old hidden field
                ((Class) pe.getParent()).removeTypedElement(pe
                        .getName());
                //Use the existing one in the name def
                pe = (PrimitiveElement) pem.getLinkedMO();
                nd.setFieldName(pe.getName());
                if (pem.getType() == null) {
                    pem.setType(sf.columns[0].sqlType);
                }
            }
        } else {
            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 class used in by this name def
                PrimitiveElement pe = (PrimitiveElement) jclass
                        .getTypedElement((String) me.getValue());
                //find the pk column
                RdbPrimitiveElementMapping tpem = getPEMOfField(tclass,
                        (Mapping) rcm.getParent(),
                        (String) tndproj.get(me.getKey()));
                //find the fk column name
                SpeedoColumn fkCol = sf.getFKColumn(tpem.getName());
                //check if the fk column name is already used
                RdbPrimitiveElementMapping pem = (RdbPrimitiveElementMapping) table
                        .getPrimitiveElementMappingByCol(fkCol.name);
                if (pem == null) {
                    // create it
                    table.createPrimitiveElementMapping(pe, fkCol.name,
                            fkCol.sqlType, false);
                } else {
                    //it already exists
                    //remove the old hidden field
                    ((Class) pe.getParent()).removeTypedElement(pe.getName());
                    //Use the existing one in the name def
                    pe = (PrimitiveElement) pem.getLinkedMO();
                    me.setValue(pe.getName());
                    if (pem.getType() == null) {
                        pem.setType(sf.columns[0].sqlType);
                    }
                }
            }
View Full Code Here

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

        }
        // map the name def over pk field of the referenced class
        if (tnd.isFieldName()) {
            RdbPrimitiveElementMapping pem = (RdbPrimitiveElementMapping) trcm
                    .getPrimitiveElementMapping(tnd.getFieldName(), true);
            PrimitiveElement pe = (PrimitiveElement) jclass
                    .getTypedElement(nd.getFieldName());
            exttable.createPrimitiveElementMapping(pe, pem.getName(),
                    null, false, j);
        } else {
            Map tclassndproj = tnd.getNameRef().getProjection();
            Iterator it = nd.getNameRef().getProjection().entrySet()
                    .iterator();
            while (it.hasNext()) {
                Map.Entry me = (Map.Entry) it.next();
                PrimitiveElement pe = (PrimitiveElement) jclass
                        .getTypedElement((String) me.getValue());
                RdbPrimitiveElementMapping pem = (RdbPrimitiveElementMapping)
                  trcm.getPrimitiveElementMapping(
                          (String) tclassndproj.get(me.getKey()), true);
                exttable.createPrimitiveElementMapping(pe, pem.getName(), null, false, j);
View Full Code Here

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

            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

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

            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

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

                logger.log(BasicLevel.ERROR, "The specified scale for the field '"
                    + sp.name + "' of the class '" + sc.getFQName()
                    + "' cannot be parsed: " + se.value, e);
            }
        }
        PrimitiveElement pe = clazz.createPrimitiveElement(sp.name, ptype, size, scale);
        if (cm != null && mb != null) {
            mb.createFieldMapping(pe, sp, cm);
        }
    }
View Full Code Here

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

                            "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

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

                if (se instanceof SpeedoNoFieldColumn) {
                    if (sc.getSuper() == null) {
                        // The discriminator is a column not mapped to a
                        // persistent field. then we have to create a constant
                        // hidden field.
                        PrimitiveElement pe = sc.jormclass.createHiddenField(
                            HIDDEN_FIELD_CLASS_NAME, PTypeSpace.STRING, PType.NOSIZE, PType.NOSIZE);
                        pe.setStatus(PrimitiveElement.CONSTANT_PERSISTENT);
                        mb.createFieldMapping(pe, (SpeedoNoFieldColumn) se, cm);
                    }
                    if (sc.inheritance.discriminator.strategy ==
                                SpeedoDiscriminator.STRATEGY_CLASS_NAME
                                && sc.inheritance.discriminatorValues != null) {
View Full Code Here

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

            MIBuilderHelper mibh,
            JormMIMappingBuilder mb,
            Collection createdMOs)
            throws SpeedoException, PException {
    SpeedoField pkField = fetchUniqueLongPKField(sc);
    PrimitiveElement lid;
    String lidname;
    if (pkField == null) {
        if (sc.identity.columns == null) {
            logger.log(BasicLevel.WARN,
                    "No mapping information for the identifier of the class '"
                    + sc.getFQName() +"'.");
          lidname = getHiddenLidFieldName();
        } else {
            lidname = sc.identity.columns[0].column.name;
        }
        // create an hidden identifier field
      lid = mibh.createNameDefField(sc.jormclass, lidname, getFieldType());
    } else {
        //The identifier is mapped over a persistent field
        lidname = pkField.name;
      lid = mibh.getPrimitiveField(sc.jormclass, lidname);
      if (lid == null) {
        throw new SpeedoException(
          mibh.getErrorMessage(sc, sc.jormclass, null)
          + " Impossible to get the field '" + lidname + "'");
      }
    }
        Manager manager = mibh.getManager(jc);
        CompositeName cn = getLongIdCompositeName(manager);
    NameRef nr = nd.createNameRef(cn);
    nr.addProjection(getLongIdLid(), lid.getName());
    if (sc.jormclass.getSuperClasses().isEmpty()) {
      // define the inheritance filter permiting to determine the class
      // since an identifier (some bits are reserved for class
      // identification)
      Expression expr = new Round(new DivideBy(
View Full Code Here

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

    private void defineNameDef(NameDef nd,
            MetaObject owner,
            MIBuilderHelper mibh,
            String prefix) throws SpeedoException, PException{
        PrimitiveElement oid = mibh.createNameDefField(owner, prefix + OID, PTypeSpace.LONG);
        PrimitiveElement cid = mibh.createNameDefField(owner, prefix + CID, PTypeSpace.LONG);
        Manager manager = mibh.getManager(owner);
        CompositeName speedoidcn = getPolymorphIdCN(manager);
        NameRef nr = nd.createNameRef(speedoidcn);
        nr.addProjection(POLYMORH_ID_OID, oid.getName());
        nr.addProjection(POLYMORH_ID_CID, cid.getName());
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.