Package org.objectweb.speedo.metadata

Examples of org.objectweb.speedo.metadata.SpeedoDiscriminator


    if (sc.inheritance == null) {
      // This is a root class in an inheritance hierarchy
      sc.inheritance = new SpeedoInheritance();
      sc.inheritance.clazz = sc;
      sc.inheritance.superClassName = null;
      sc.inheritance.discriminator = new SpeedoDiscriminator();
      String cn = a.name();
      if (cn.equals("")) {
        cn = "TYPE"; // Default name of the discriminator column
      }
      SpeedoNoFieldColumn snofc = new SpeedoNoFieldColumn();
View Full Code Here


   
    private SpeedoDiscriminator getDiscriminatorFromParent(SpeedoClass sc) throws SpeedoException {
        if (sc.inheritance == null) {
            return null;
        }
        SpeedoDiscriminator sd = sc.inheritance.discriminator;
        SpeedoClass parent = sc.getSuper();
        if (parent == null) {
            // sc is the root of the tree
            if (sd != null) {
                checkColumn(sc, sd);
                if (sd.strategy == SpeedoDiscriminator.STRATEGY_CLASS_NAME) {
                    SpeedoElement se = (SpeedoElement) sd.elements.get(0);
                    if (se instanceof SpeedoNoFieldColumn) {
                        ((SpeedoNoFieldColumn) se).type = Type.getDescriptor(String.class);
                    }
                }
            }
        } else {
            sd = getDiscriminatorFromParent(parent);
            // use the discriminator of parent
            if (sd != null) {
                SpeedoDiscriminator oldsd = sc.inheritance.discriminator;
                if (oldsd != sd) {
                    sc.inheritance.discriminator = sd;
                    if (sc.inheritance.discriminatorValues != null) {
                        //Replace old keys in discriminator map values
                        replaceOldKeys(sd, oldsd, sc.inheritance.discriminatorValues);
View Full Code Here

                    sc.inheritance = new SpeedoInheritance(sc);
                }
                if (sc.inheritance.discriminatorValues == null) {
                    sc.inheritance.discriminatorValues = new HashMap();
                }
                SpeedoDiscriminator sd = sc.inheritance.discriminator;
                if (sd == null || !sd.hasDiscriminator()) {
                    //find the discriminator
                    SpeedoClass current = sc;
                    while (current != null && sd == null) {
                        if (current.inheritance != null
                                && current.inheritance.discriminator != null
                                && current.inheritance.discriminator.hasDiscriminator()) {
                            sd = current.inheritance.discriminator;
                        } else {
                            String f = current.getExtensionValueByKey(INHERITANCE_FILTER);
                            if (f != null) {
                                sd = setDiscriminatorElement(current, f);
                            }
                        }
                        if (sd == null) {
                            current = current.getSuper();
                        }
                    }
                    if (sd == null || !sd.hasDiscriminator()) {
                        throw new SpeedoException("Extension '"
                                + INHERITANCE_KEY
                                + "' specified without filter definition in the "
                                + sc.getSourceDesc());
                    }
View Full Code Here

    private SpeedoDiscriminator setDiscriminatorElement(SpeedoClass sc, String value) {
        if (sc.inheritance == null) {
            sc.inheritance = new SpeedoInheritance();
        }
        if (sc.inheritance.discriminator == null) {
            sc.inheritance.discriminator = new SpeedoDiscriminator();
        }
        SpeedoDiscriminator sd = sc.inheritance.discriminator;
        sd.strategy = SpeedoDiscriminator.STRATEGY_MAP_VALUE;
        SpeedoField sf = sc.getField(value);
        if (sf == null) {
            sd.expression = value;
        } else if (!sd.elements.contains(sf)) {
View Full Code Here

    ClassMapping cm = sc.jormclass.getClassProject(projectName)
        .getMapping(mapperName).getClassMapping();
    NameDef nd = (NameDef) cm.getIdentifierMapping().getLinkedMO();

    if (sc.inheritance != null && sc.inheritance.discriminator != null) {
        SpeedoDiscriminator sd = sc.inheritance.discriminator;
        String filter = null;
        if (sd.expression != null) {
        filter = sd.expression;
        } else if (sd.elements.size() == 1) {
                SpeedoElement se = (SpeedoElement) sd.elements.get(0);
View Full Code Here

      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;", "", ""}.
View Full Code Here

      si.join = null;
      si.remappedInheritedFields = null;
      si.strategy = SpeedoInheritance.STRATEGY_UNKOWN;
      si.superClassName = "";//TODO: null should be better
    } 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;", "", ""}.
View Full Code Here

        }
        return sc.inheritance;
    }
    private Object treatDiscriminator(Node node, Object mo) throws SpeedoException {
        SpeedoInheritance si = (SpeedoInheritance) mo;
        si.discriminator = new SpeedoDiscriminator();
        Node n = node.getAttributes().getNamedItem("strategy");
        if (n == null) {
            si.discriminator.strategy =
                SpeedoDiscriminator.parseStrategy(n.getNodeValue());
        }
View Full Code Here

            treatDiscriminator((Node) l.get(0), moClass.inheritance);
        }
    }
    private void treatDiscriminator(Node discNode, SpeedoInheritance inh)throws SpeedoException {
        if (inh.discriminator == null) {
            inh.discriminator = new SpeedoDiscriminator();
        }
        //<!ATTLIST discriminator strategy CDATA #IMPLIED>
        Node n = discNode.getAttributes().getNamedItem("strategy");
        if (n != null) {
            inh.discriminator.strategy =
View Full Code Here

TOP

Related Classes of org.objectweb.speedo.metadata.SpeedoDiscriminator

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.