Package eu.scape_project.planning.model.tree

Examples of eu.scape_project.planning.model.tree.Leaf


        for (Alternative alt : plan.getAlternativesDefinition().getConsideredAlternatives()) {
            consideredAltNames.add(alt.getName());
        }
        List<ValidationError> errors = new ArrayList<ValidationError>();
        for (Iterator<Leaf> iter = leaves.iterator(); iter.hasNext();) {
            Leaf l = iter.next();
            if (l.isMapped()) {
                numMappedLeaves++;
            }
            int numMeasuresNeeded = 0;
            if (l.isSingle()) {
                numMeasuresNeeded += numConsideredAlternatives;
            } else {
                numMeasuresNeeded += (numConsideredAlternatives * numSamples);
            }
            numMeasuresNeededTotal += numMeasuresNeeded;

            for (Iterator<String> alts = consideredAltNames.iterator(); alts.hasNext();) {
                String alt = alts.next();
                Values values = l.getValues(alt);
                if (values != null) {
                    for (Iterator<Value> valueiter = values.getList().iterator(); valueiter.hasNext();) {
                        Value value = valueiter.next();
                        if ((value != null) && (value.getScale() != null) && value.isEvaluated()) {
                            numEvaluated++;
                        }
                    }
                }
            }

            if (l.getTransformer() != null) {
                if (l.isCompletelyTransformed(errors)) {
                    percentageDefinedTransformers += 1;
                }
            }
        }
        percentageDefinedTransformers = percentageDefinedTransformers / numLeaves;
View Full Code Here


        if (minCL <= createdAt) {
            minCL = Long.MAX_VALUE;
        }
        for (TreeNode treeNode : nodes) {
            if (treeNode instanceof Leaf) {
                Leaf leaf = (Leaf) treeNode;
                // ValueMap-Values
                for (Values values : leaf.getValueMap().values()) {
                    for (Value value : values.getList()) {
                        ChangeLog valueCL = value.getChangeLog();
                        if (maxCL < valueCL.getChanged()) {
                            maxCL = valueCL.getChanged();
                        }
                    }
                }
                // values are created in a previous step, therefore the min
                // values cannot be set regarding the created timestamp
            }
        }
        minChangeLogs[9] = minCL;
        maxChangeLogs[9] = maxCL;

        // 10. Transform measured values - TRANSFORMATION_DEFINED(10,
        // "Transformations Defined")
        // - leaf.transformer
        // - Transformation
        // - leaf (!! - leaf.aggregationMode )
        minCL = plan.getTransformation().getChangeLog().getChanged();
        maxCL = minCL;
        if (minCL <= createdAt) {
            minCL = Long.MAX_VALUE;
        }
        for (TreeNode treeNode : nodes) {
            if (treeNode instanceof Leaf) {
                Leaf leaf = (Leaf) treeNode;
                if (leaf.getTransformer() != null) {
                    ChangeLog tCL = leaf.getTransformer().getChangeLog();
                    if (maxCL < tCL.getChanged()) {
                        maxCL = tCL.getChanged();
                    }
                    if (minCL > tCL.getChanged()) {
                        minCL = tCL.getChanged();
View Full Code Here

        if (hasLeaves && isLeaf()) {
            // i am a leaf, so create a Leaf.
            // this is called only if hasUnits == false, see below.
            // So we don't need to check that again.
            Leaf leaf = new Leaf();
            setNameAndWeight(leaf);
            setDescription(leaf);
            setMIU(leaf);
            return leaf;
        } else {
            // We start with assuming that I'm a Node
            TreeNode node =  new eu.scape_project.planning.model.tree.Node();

            setNameAndWeight(node);
            setDescription(node);
            for (Node n : children) {
                if (hasLeaves && n.isLeaf()) {
                    // Case 1: we don't have units in the tree, so n is in fact a LEAF
                    // and I am a NODE as assumed above
                    if (!hasUnits) {
                        Leaf leaf = new Leaf();
                        n.setNameAndWeight(leaf);
                        n.setDescription(leaf);
                        n.setMIU(leaf);
                        ((eu.scape_project.planning.model.tree.Node)node).addChild(leaf);
                    } else {
                        // Case 2: we have units, so n is the SCALE of myself
                        // - but this means that I AM a LEAF
                        // and that we can finish recursion
                        node = new Leaf();
                        setNameAndWeight(node);
                        setDescription(node);
                        Leaf leaf = (Leaf) node;
                        leaf.changeScale(n.createScale());
                        setMIU(leaf);
                       
                        return leaf; // == node
                    }
                } else {
View Full Code Here

     */
    private void addSubTree(TreeNode data, Element xmlRoot) {
        if (data.isLeaf()) {
            Element leaf = xmlRoot.addElement("leaf");
            addNodeAttributes(data, leaf);
            Leaf l = (Leaf) data;
            leaf.addElement("aggregationMode").addAttribute("value", l.getAggregationMode().name());

            String typename = null;
            /*
             * Scale: A special element is created, depending on the type of the
             * scale
             */
            Scale s = l.getScale();

            if (s != null) {
                typename = deriveElementname(s.getClass());

                addScale(s, leaf);

                // Transformer
                if (l.getTransformer() != null) {
                    Element transformer = leaf.addElement(deriveElementname(l.getTransformer().getClass()));

                    if (l.getTransformer() instanceof OrdinalTransformer) {

                        Map<String, TargetValueObject> mapping = ((OrdinalTransformer) l.getTransformer()).getMapping();
                        Element mappings = transformer.addElement("mappings");
                        for (String ordinal : mapping.keySet()) {
                            mappings
                                .addElement("mapping")
                                .addAttribute("ordinal", ordinal)
                                .addAttribute("target",
                                    floatFormatter.formatFloatPrecisly(mapping.get(ordinal).getValue()));
                        }
                    }
                    if (l.getTransformer() instanceof NumericTransformer) {
                        NumericTransformer nt = (NumericTransformer) l.getTransformer();
                        transformer.addElement("mode").addAttribute("value", nt.getMode().name());
                        Element thresholds = transformer.addElement("thresholds");
                        thresholds.addElement("threshold1").setText(
                            floatFormatter.formatFloatPrecisly(nt.getThreshold1()));
                        thresholds.addElement("threshold2").setText(
                            floatFormatter.formatFloatPrecisly(nt.getThreshold2()));
                        thresholds.addElement("threshold3").setText(
                            floatFormatter.formatFloatPrecisly(nt.getThreshold3()));
                        thresholds.addElement("threshold4").setText(
                            floatFormatter.formatFloatPrecisly(nt.getThreshold4()));
                        thresholds.addElement("threshold5").setText(
                            floatFormatter.formatFloatPrecisly(nt.getThreshold5()));

                    }
                    addChangeLog(l.getTransformer().getChangeLog(), transformer);
                }

                if (l.isMapped()) {
                    addMeasure(l.getMeasure(), leaf);
                }

                Element eval = leaf.addElement("evaluation");
                typename = typename.substring(0, typename.lastIndexOf("Scale"));
                /*
                 * keep in mind: there are only values of the considered
                 * alternatives in the map
                 */
                for (String a : l.getValueMap().keySet()) {
                    Element alt = eval.addElement("alternative");
                    alt.addAttribute("key", a);
                    addStringElement(alt, "comment", l.getValueMap().get(a).getComment());
                    for (Value v : l.getValueMap().get(a).getList()) {
                        /*
                         * A special element is created, depending on the type
                         * of the scale
                         */
                        Element valElement = alt.addElement(typename + "Result");
View Full Code Here

        Element element = xmlElement.addElement("node");
        addFreemindAttributes(node, element);

        if (node.isLeaf()) {
            // add scale
            Leaf leaf = (Leaf) node;
            Scale scale = leaf.getScale();
            if (scale != null) {
                Element scaleElement = element.addElement("node");
                String restriction = "?";

                // restrictions: restrictedscale, ordinals -freestring
View Full Code Here

        // TODO export weights? units? single? >> future.

        String mInfoUri = null;

        if (node.isLeaf()) {
            Leaf leaf = (Leaf) node;
            if (leaf.isMapped()) {
                mInfoUri = leaf.getMeasure().getUri();
            }
        }
        // add DESCRIPTION if existent
        if (((mInfoUri != null) && (!"".equals(mInfoUri)))
            || (node.getDescription() != null && !"".equals(node.getDescription()))) {
View Full Code Here

     */
    private void initializeNodeRec(TreeNode node) {

        Hibernate.initialize(node);
        if (node.isLeaf()) {
            Leaf leaf = (Leaf) node;
            Transformer t = leaf.getTransformer();
            Hibernate.initialize(t);
            if (t instanceof OrdinalTransformer) {
                OrdinalTransformer nt = (OrdinalTransformer) t;
                Hibernate.initialize(nt.getMapping());
            }
            // log.debug("hibernate initialising Transformer: " +
            // leaf.getTransformer());
            for (Values value : leaf.getValueMap().values()) {
                Hibernate.initialize(value);
            }
        } else if (node instanceof Node) {
            Node recnode = (Node) node;
            Hibernate.initialize(node.getChildren());
View Full Code Here

            stateChangeLogs.add(new StateChangeLog(planId, 9, createdAt, changelog.getChanged(), changelog.getChangedBy()));
        }

        for (TreeNode treeNode : nodes) {
            if (treeNode instanceof Leaf) {
                Leaf leaf = (Leaf) treeNode;
                // ValueMap-Values
                for (Values values : leaf.getValueMap().values()) {
                    for (Value value : values.getList()) {
                        ChangeLog valueCL = value.getChangeLog();
                        stateChangeLogs
                            .add(new StateChangeLog(planId, 9, createdAt, valueCL.getChanged(), valueCL.getChangedBy()));
                    }
                }
            }
        }

        // 10. Transform measured values - TRANSFORMATION_DEFINED(10,
        // "Transformations Defined")
        // - leaf.transformer
        // - Transformation
        // - leaf (!! - leaf.aggregationMode )
        changelog = plan.getTransformation().getChangeLog();
        if (changelog.getChanged() > createdAt) {
            stateChangeLogs.add(new StateChangeLog(planId, 10, createdAt, changelog.getChanged(), changelog.getChangedBy()));
        }

        for (TreeNode treeNode : nodes) {
            if (treeNode instanceof Leaf) {
                Leaf leaf = (Leaf) treeNode;
                if (leaf.getTransformer() != null) {
                    ChangeLog tCL = leaf.getTransformer().getChangeLog();
                    stateChangeLogs.add(new StateChangeLog(planId, 10, createdAt, tCL.getChanged(), tCL.getChangedBy()));
                }
            }
        }
View Full Code Here

TOP

Related Classes of eu.scape_project.planning.model.tree.Leaf

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.