Package org.objectweb.jorm.mapper.rdb.metainfo

Examples of org.objectweb.jorm.mapper.rdb.metainfo.RdbGenClassMapping


     * referencing a generic class.
     */
    public void createClassRefNameDefMapping(GenClassMapping gcm,
            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 {
View Full Code Here


     */
    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);
View Full Code Here

     */
    public GenClassMapping createGenClassMapping(
            GenClassRef gcr,
            SpeedoField sf,
            Mapping mapping) throws PException, SpeedoException {
        RdbGenClassMapping rgcm = new RdbGenClassMapping("to-table", gcr,
                mapping);
        mapping.addGenClassMapping(gcr.getGenClassId(), rgcm);
        RdbTable t = null;
        if (gcr.isPrimitive()) {
            if (logger.isLoggable(BasicLevel.DEBUG)) {
                logger.log(BasicLevel.DEBUG, "The GCR field " + gcr.getName()
                        + " is mappeded over a dedicated table: "
                        + 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) {
            case SpeedoField.MANY_MANY_BI_RELATION:
                //Create the join table for the Generic class
                t = rgcm.createRdbTable(sf.join.extTable.name);
                if (reverseField.mappedByReversefield
                        || (reverseField.join != null
                                && reverseField.join.extTable != null
                                && t.getName().equalsIgnoreCase(reverseField.join.extTable.name))) {
                    //The MANY-MANY relation is mapped over the same join table
                  if (sf.name.compareToIgnoreCase(reverseField.name) < 0) {
                      // master side is not randomly choosen 
                      t.setColocatedMaster(true);
                  } else {
                      //write are done only on master side. The slave side
                      // reads only the generic class
                      t.setReadOnly(true);
                      t.setColocated(true);
                  }
                }
                if (logger.isLoggable(BasicLevel.DEBUG)) {
                    logger.log(BasicLevel.DEBUG, "Many-Many relation,"
                            + " join table: " + t.getName()
                            + (t.isColocated()?", colocated":"")
                            + (t.isColocatedMaster()?", master":"")
                            + (t.isReadOnly()?", readonly":"")
                            );
                }
                break;
            case SpeedoField.ONE_MANY_BI_RELATION:
                reverseField = sf.getReverseField();
              RdbClassMultiMapping trcm = (RdbClassMultiMapping) getClassMapping(
                    mapping, targetClassJMO);
              if (sf.mappedByReversefield) {
                  RdbTable tTable;
                  SpeedoTable table;
                  if (reverseField.join != null) {
                      table = reverseField.join.extTable;
                      tTable = trcm.getRdbExternalTable(table.name);
                  } else {
                      table = reverseField.moClass.mainTable;
                      tTable = trcm.getRdbTable();
                  }
                  t = rgcm.createRdbTable(table.name);
                  tTable.setColocated(true);
                    t.setColocated(true);
                  tTable.setColocatedMaster(true);
                    t.setColocatedMaster(false);
                  trcm.addDependency(sf.moClass.getFQName());
                  if (sf.isCoherentReverseField) {
                      //optimisation: the reverse field assumes the coherence.
                      // Then there is no need to write the generic class.
                      t.setReadOnly(true);
                  }
              } else if (sf.join != null) {
                  t = rgcm.createRdbTable(sf.join.extTable.name);
              }
                if (t != null && logger.isLoggable(BasicLevel.DEBUG)) {
                    logger.log(BasicLevel.DEBUG, "One-Many relation,"
                            + " join table: " + t.getName()
                            + (t.isColocated()?", colocated":"")
                            + (t.isColocatedMaster()?", master":"")
                            + (t.isReadOnly()?", readonly":"")
                            );
                }
                break;
            default:
                //Create the RdbTable for the Generic class
                rgcm.createRdbTable(sf.join.extTable.name);
              //add the dependency
              trcm = (RdbClassMultiMapping) getClassMapping(mapping, targetClassJMO);
              trcm.addDependency(sf.moClass.getFQName());
              if (t != null && logger.isLoggable(BasicLevel.DEBUG)) {
                  logger.log(BasicLevel.DEBUG, "GCR field,"
View Full Code Here

TOP

Related Classes of org.objectweb.jorm.mapper.rdb.metainfo.RdbGenClassMapping

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.