Package eu.planets_project.pp.plato.model

Examples of eu.planets_project.pp.plato.model.Values


            for (Plan p : projectList) {
                log.info("deleting plan "+p.getPlanProperties().getName());
                log.debug("removing value scale linkage...");
                for (Leaf l: p.getTree().getRoot().getAllLeaves()) {
                    for (Alternative a: p.getAlternativesDefinition().getAlternatives()) {
                        Values values = l.getValues(a.getName());
                        if (values != null) {
                            for (Value v : values.getList()) {
                                if (v!= null) {
                                    v.setScale(null);
                                }
                            }
                        }
View Full Code Here


     * @see #getResult(Alternative)
     * @param a the {@link Alternative} for which evaluation values shall be returned
     * @return {@link TargetValues}
     */
    public TargetValues transformValues(Alternative a) {
        Values v = valueMap.get(a.getName());
        if (transformer == null) {
            PlatoLogger.getLogger(getClass()).fatal("transformer is null!");
        }
        return transformer.transformValues(v);
    }
View Full Code Here

            valueMap.clear();
            return;
        }
        // Get the Values for each Alternative
        for (Alternative a : list) {
            Values values = valueMap.get(a.getName());
            if (values == null) {
                Logger.getLogger(this.getClass()).debug("values is null for alternative "+ a.getName()+ " in Leaf "+name);
                continue;
            }
            // Check value of each sample object for conformance with Scale -
            // if we find a changed scale, we reset everything.
            // It might be faster not to check ALL values, but this is safer.
            for (Value value : values.getList()) {
                // If the scale has changed, we reset all evaluation values of this Alternative:
                // this may look strange, but it is OK that the scale of a value is null.
                // If there have been values before, you change the scale and then save - the linkage is lost               
                // if (value.getScale() == null) {
                //      Logger.getLogger(Leaf.class).error("WHAT THE...?? no scale for value"+getName());
                // } else {
                    if ((value.getScale() == null) ||
                        (!value.getScale().getClass().equals(scale.getClass())) ) {
                        if (!a.isDiscarded()) { // for discarded alternatives, that's ok.
                            Logger.getLogger(Leaf.class).debug(
                                    "Leaf "+this.getName()+" Class: " + value.getClass() + " not like "
                                            + scale.getClass()+". RESETTING the valuemap now!");
                            valueMap.clear(); // reset all values
                            return;
                        }
                    }
                // }
                // PLEASE NOTE- WRT ORDINAL RESTRICTIONS:
                // we do NOT reset values when the restriction has changed, such as
                // the ordinal values or the boundaries.
                // Instead, those values that are still valid remain, the others will be checked
                // and need to be corrected anyway in the evaluate step.
                // Should be nicer for the user. If we find out this leads to validation problems
                // (which shouldnt be the case because the data types are valid as long as the scale
                // doesnt change) then we will reset the values even if just the restriction changes.
            }
            /*
             * maybe this leaf was set to single, reset all values
             */
            if (isSingle() && values.size() > 1) {
                valueMap.clear();
                return;
            }
        }
    }
View Full Code Here

     * @param list list of Alternatives for which values shall be removed
     * @param record index of the record for which  values shall be removed
     */
    public void removeValues(List<Alternative> list, int record) {
        for (Alternative a : list) {
            Values v = getValues(a.getName());
            // maybe this alternative has no values at all - e.g. because it was just created
            if ((v != null// there is a Values object
                && (v.getList().size() > record) // there can be a value for this sample record
                && (v.getList().get(record) != null)) { // there is a value
                PlatoLogger.getLogger(this.getClass()).debug("removing values:: "+getName()+" ,"+record+", "+a.getName());
                v.getList().remove(record);
            }
        }
    }
View Full Code Here

        if (scale == null)
            return;
        for (Alternative a : list) {
            // for every Alternative we get the container of the values of each sample object
            // from the map
            Values v = valueMap.get(a.getName());

            // If it doesnt exist, we create it and link it in the map
            if (v == null) {
                v = new Values();
                valueMap.put(a.getName(), v);
                // it the valueMap has just been created and the leaf is single,
                // we need to add one value.
                if (isSingle()) {
                    v.add(scale.createValue());
                }
            }

            // 20090217, hotfix CB: if a Leaf is set to SINGLE *after* initValues has been called,
            // the Value object at position 0 of the ValueS object might not be properly initialised.
            // Check and initialise if needed:
            if (isSingle()) {
                if (v.size() == 0) {
                    PlatoLogger.getLogger(this.getClass()).warn("adding value to a SINGLE LEAF WITH A VALUES OBJECT WITHOUT A PROPER VALUE:" + getName());
                    v.getList().add(scale.createValue());
                } else {
                    if (v.getValue(0) == null) {
                        PlatoLogger.getLogger(this.getClass()).warn("adding value to a SINGLE LEAF WITH A VALUES OBJECT WITHOUT A PROPER VALUE:" + getName());
                        v.setValue(0,scale.createValue());
                    }
                }
            }
            // end hotfix 20090217
           
            // So we can be sure now that we have a value container and
            // that it is linked and that for Action criteria, i.e. single
            // values, we have the one value.
            // For Object criteria we have to be sure that the number of values
            // corresponds to the number of sample objects, so we fill the list up
            if (!isSingle()) {
                // this is to add MISSING values for records.
                // it doesnt make a difference for this condition
                // whether we just created a new valuemap or are
                // refilling an existing one

                // Note that the index here starts at the size of the values array
                // and runs to the total number of records.
                // so if we have enough - nothing happens; if some are missing, they are
                // added at the end
                for (int i = v.size(); i < records; i++) {
                    v.add(scale.createValue());
                }
            }
        }
        if (addLinkage) {
            initScaleValueLinkage(list, records);
View Full Code Here

     * @param list List of Alternatives over which to iterate
     * @param records denotes the number of records for the iteration
     */
    public void initScaleValueLinkage(List<Alternative> list, int records) {
        for (Alternative a : list) {
            Values v = valueMap.get(a.getName());
            if (v == null) {
                throw new IllegalStateException("initScaleLinkage called,"
                        + " but the valueMap is still empty - that's a bug."
                        + " Leaf:" + getName());
            }
            if (isSingle()) {
                v.getValue(0).setScale(scale);
            } else {
                for (int i = 0; i < records; i++) {
                    v.getValue(i).setScale(scale);
                }
            }
        }
    }
View Full Code Here

    public boolean isCompletelyEvaluated(List<String> errorMessages,
            List<TreeNode> nodes, List<Alternative> alternatives) {
        boolean validates = true;
        PlatoLogger.getLogger(this.getClass()).debug("checking complete evaluation for leaf " +getName());
        for (Alternative a : alternatives) {
            Values values = valueMap.get(a.getName());
            PlatoLogger.getLogger(this.getClass()).debug("checking values for "+a.getName());
            if (this.isSingle()) {
                if (values.size() < 1) {
                    Logger.getLogger(Leaf.class).warn(
                            "Not Enough Value Objects in Values");
                    validates = false;
                } else {
                    if (!scale.isEvaluated(values.getValue(0))) {
                        validates = false;
                    }
                }
            } else {
                int i = 0;
                for (Value value : values.getList()) {
                    PlatoLogger.getLogger(this.getClass()).debug("checking value for "+(i));
                    if (!scale.isEvaluated(value)) {
                        validates = false;
                        break;
                    }
View Full Code Here

                PlatoLogger.getLogger(this.getClass()).warn("removing Values for "+altName+" at leaf "
                        +getName());
                namesToRemove.add(altName);
                number++;
            } else {
                Values v = valueMap.get(altName);
                int removed  = v.removeLooseValues(isSingle() ? 1 : records);
                PlatoLogger.getLogger(this.getClass()).warn("removed "+removed+" Value objects " +
                                "for "+altName+" at leaf "+getName());
                number += removed;
            }
        }
View Full Code Here

                        if (leaf.isSingle()) {

                            // if (leaf.getScale().getType() == ScaleType.ordinal) {

                                Values vs = leaf.getValueMap().get(alter.getName());

                                assert vs != null;

                                assert vs.getList().get(0) != null;
                            // } else {

                            // }
                        } else {

                            int i = 0;
                            for (SampleObject record : p.getSampleRecordsDefinition().getRecords()) {

                                Values vs = leaf.getValueMap().get(alter.getName());

                                assert vs.getList().get(i++) != null;
                            }
                        }
                    }

                }
View Full Code Here

        // If we removed samples, persist all the Values objects of all leaves in the tree
        // - that leads to the orphan VALUE objects to be deleted from the database.
        if (recordsToRemove.size() > 0) {
            for (Leaf l: selectedPlan.getTree().getRoot().getAllLeaves()) {
                for (Alternative a: selectedPlan.getAlternativesDefinition().getConsideredAlternatives()) {
                    Values v = l.getValues(a.getName());
                    if (v != null) {
                        em.persist(em.merge(v));
                    } else {
                        log.error("values is NULL: "+l.getName()+", "+a.getName());
                    }
View Full Code Here

TOP

Related Classes of eu.planets_project.pp.plato.model.Values

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.