Package org.objectweb.speedo.metadata.jdo

Source Code of org.objectweb.speedo.metadata.jdo.JDODefaults

/**
* Copyright (C) 2001-2005 France Telecom R&D
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

package org.objectweb.speedo.metadata.jdo;

import java.util.ArrayList;
import java.util.HashMap;

import org.objectweb.speedo.api.SpeedoRuntimeException;
import org.objectweb.speedo.lib.Personality;
import org.objectweb.speedo.metadata.SpeedoCallback;
import org.objectweb.speedo.metadata.SpeedoClass;
import org.objectweb.speedo.metadata.SpeedoCollection;
import org.objectweb.speedo.metadata.SpeedoColumn;
import org.objectweb.speedo.metadata.SpeedoDefaults;
import org.objectweb.speedo.metadata.SpeedoDiscriminator;
import org.objectweb.speedo.metadata.SpeedoElement;
import org.objectweb.speedo.metadata.SpeedoField;
import org.objectweb.speedo.metadata.SpeedoIdentity;
import org.objectweb.speedo.metadata.SpeedoInheritance;
import org.objectweb.speedo.metadata.SpeedoInheritedField;
import org.objectweb.speedo.metadata.SpeedoJoin;
import org.objectweb.speedo.metadata.SpeedoJoinColumn;
import org.objectweb.speedo.metadata.SpeedoMap;
import org.objectweb.speedo.metadata.SpeedoNoFieldColumn;
import org.objectweb.speedo.metadata.SpeedoNullValue;
import org.objectweb.speedo.metadata.SpeedoPackage;
import org.objectweb.speedo.metadata.SpeedoTable;

/**
* This class is in charge of the initialization of Speedo Meta Objects with
* the default value corresponding to the JDO personality.
*
* @author S.Chassande-Barrioz, P. Dechamboux
*/
public class JDODefaults extends SpeedoDefaults {

  public void assignDefaults(Object se) throws SpeedoRuntimeException {
    ((SpeedoElement) se).personality = Personality.JDO;
        if (se instanceof SpeedoPackage) {
      SpeedoPackage sp = (SpeedoPackage) se;
      //sp.classes = ?;
      //sp.jdoExtension = ?;
      //sp.name = ?;
      //sp.sequences = ?;
      //sp.xmlDescriptor = ?;
    } else if (se instanceof SpeedoClass) {
      SpeedoClass sc = (SpeedoClass) se;
      //sc.enhancementStatus = ?;
      sc.fetchGroups = new HashMap();
      sc.fields = new HashMap();
      sc.identity = new SpeedoIdentity();
      sc.versionField = null;
      sc.inheritance = null;
      sc.isAbstract = false;
      sc.isDetachable = false;
      sc.isInstanceCallbacks = false;
      sc.isSerializable = false;
      //sc.jdoExtension = ?;
      //sc.joinToExtTables = ?;
      //sc.jormclass = ?;
      sc.callBacks = null;
      //sc.mainTable = ?;
      //sc.moPackage = ?;
      //sc.name = ?;
      sc.name2query = new HashMap();
      //sc.noArgConstructorStatus = ?;
      //sc.version = ?;
    } else if (se instanceof SpeedoField) {
      SpeedoField sf = (SpeedoField) se;
      sf.name = null;
      //sf.visibility = ?;
      sf.propagate = SpeedoField.PROPAG_ALL;
      sf.type = null;
      sf.number = -1;
      sf.persistenceStatus = SpeedoField.UNKNOWN;
      sf.primaryKey = false;
      sf.nullValue = SpeedoNullValue.NONE;
      sf.defaultFetchGroup = true;
      sf.depth = 0;
      //sf.fetchGroup = ?;
      sf.embedded = true;
      //sf.valueStrategy = ?;
      //sf.sequence = ?;
      sf.relationType = SpeedoField.NO_BI_RELATION;
      sf.reverseField = null;
      sf.isCoherentReverseField = false;
      sf.jdoTuple = null;
      sf.moClass = null;
      if (sf.columns != null) {
          System.out.println("forget existing columns");
          throw new RuntimeException("forget existing columns");
      }
      sf.columns = null;
      sf.join = null;
      sf.mappedByReversefield = false;
    } else if (se instanceof SpeedoTable) {
      SpeedoTable st = (SpeedoTable) se;
      st.catalog = null;
      st.name = null;
      st.schema = null;
      st.join = null;
    } else if (se instanceof SpeedoJoin) {
      SpeedoJoin sj = (SpeedoJoin) se;
      sj.extTable = null;
      sj.mainTable = null;
      sj.columns = new ArrayList();
      sj.deleteAction = SpeedoJoin.ACTION_NONE;
    } else if (se instanceof SpeedoColumn) {
      SpeedoColumn sc = (SpeedoColumn) se;
      sc.allowNull = true;
      sc.defaultValue = null;
      sc.jdbcType = null;
      sc.length = -1;
      sc.name = null;
      sc.targetColumn = null;
      sc.targetField = null;
      sc.scale = -1;
      sc.sqlType = null;
      sc.table = null;
      sc.insertable = true;
      sc.updatable = true;
    } else if (se instanceof SpeedoIdentity) {
      SpeedoIdentity si = (SpeedoIdentity) se;
      si.objectidClass = null;
      si.objectidJClass = null;
      si.sequenceName = null;
      si.strategy = SpeedoIdentity.DATASTORE_LONG;
      si.columns = null;
    } else if (se instanceof SpeedoJoinColumn) {
      SpeedoJoinColumn sjc = (SpeedoJoinColumn) se;
      sjc.column = null;
      sjc.targetColumn = null;
      sjc.targetField = null;
    } else if (se instanceof SpeedoInheritance) {
      SpeedoInheritance si = (SpeedoInheritance) se;
      si.clazz = null;
      si.discriminator = null;
      si.discriminatorValues = null;
      si.join = null;
      si.remappedInheritedFields = null;
      si.strategy = SpeedoInheritance.STRATEGY_UNKOWN;
      si.superClassName = null;
    } else if (se instanceof SpeedoDiscriminator) {
      SpeedoDiscriminator sd = (SpeedoDiscriminator) se;
      sd.elements = new ArrayList();
      sd.strategy  = SpeedoDiscriminator.STRATEGY_NONE;
    } else if (se instanceof SpeedoNoFieldColumn) {
      SpeedoNoFieldColumn sc = (SpeedoNoFieldColumn) se;
      // In EJB3, type may be one of {"Ljava.lang.String;", "", ""}.
      //sc.type = ;
      //sc.column = ;
    } else if (se instanceof SpeedoInheritedField) {
      SpeedoInheritedField shf = (SpeedoInheritedField) se;
      shf.name = null;
      shf.columns = null;
      shf.inheritedField = null;
      shf.join = null;
      shf.moClass = null;
    } else if (se instanceof SpeedoCollection) {
      SpeedoCollection sc = (SpeedoCollection) se;
      sc.elementType = null;
      sc.embeddedElement = false;
      sc.indexColumns = null;
      sc.moField = null;
    } else if (se instanceof SpeedoMap) {
      SpeedoMap sm = (SpeedoMap) se;
      sm.embeddedKey = false;
      sm.embeddedValue = false;
      sm.keyColumns = null;
      sm.keyType = null;
      sm.moField = null;
    } else if (se instanceof SpeedoCallback) {
      SpeedoCallback sc = (SpeedoCallback) se;
      sc.listenerClassName = null;
      sc.callbackName = null;
      sc.methodByteCodeSignature = null;
      sc.callbackType = -1;
    } else {
      /*throw new SpeedoException("Unknown element to initialize: " +
          se.getClass().getName());*/
    }
  }
TOP

Related Classes of org.objectweb.speedo.metadata.jdo.JDODefaults

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.