Package eu.scape_project.planning.model

Examples of eu.scape_project.planning.model.TargetValueObject


public class OrdinalTransformerTest {

  @Test
  public void testTransform() {
    OrdinalTransformer ord = new OrdinalTransformer();
    TargetValueObject t1 = new TargetValueObject();
    t1.setValue(1.4);
    TargetValueObject t2 = new TargetValueObject();
    t2.setValue(2.4);
    TargetValueObject t3 = new TargetValueObject();
    t3.setValue(3.2);
    Map<String,TargetValueObject> map = new HashMap<String,TargetValueObject>();
    map.put("GOOD", t1);
    map.put("BAD", t2);
    map.put("HORRIBLE", t3);
    ord.setMapping(map);
View Full Code Here


        VPlanLeaf leaf = new VPlanLeaf();

        // create simple transformer
        OrdinalTransformer ordinalTrans = new OrdinalTransformer();
        Map<String, TargetValueObject> mapping = new HashMap<String, TargetValueObject>();
        TargetValueObject tv0 = new TargetValueObject();
        TargetValueObject tv1 = new TargetValueObject();
        tv0.setValue(5);
        tv1.setValue(1);
        mapping.put("Y", tv0);
        mapping.put("N", tv1);
        ordinalTrans.setMapping(mapping);
        leaf.setTransformer(ordinalTrans);
View Full Code Here

     *            the ordinal value to be transformed
     * @return {@link TargetValue} transformed value.
     */
    public TargetValue transform(IOrdinalValue v) {
        TargetValue t = new TargetValue();
        TargetValueObject o = mapping.get(v.getValue());
        t.setValue(o.getValue());
        return t;
    }
View Full Code Here

     * checks in because it can't hurt.
     */
    public boolean isTransformable(List<ValidationError> errors) {
        boolean result = true;
        for (String key : mapping.keySet()) {
            TargetValueObject value = mapping.get(key);
            // Target values are initialised and set to 0.0, so we can assume it
            // is not null:
            if ((value.getValue() < 0.0) || (value.getValue() > 5.0)) {
                result = false;
                errors.add(new ValidationError("Transformation of '" + key + "' to " + value.getValue()
                    + ": For ordinal values only target values between 0.0 and 5.0 are allowed.", this));
            }
        }
        return result;
    }
View Full Code Here

    @Override
    public Transformer clone() {
        OrdinalTransformer t = new OrdinalTransformer();
        t.setId(0);
        for (String s : mapping.keySet()) {
            TargetValueObject tvo = mapping.get(s);
            t.getMapping().put(s, tvo.clone());
        }
        return t;
    }
View Full Code Here

            this.setTransformer(t);
            if (!(scale instanceof FreeStringScale)) {
                Map<String, TargetValueObject> map = t.getMapping();
                OrdinalScale o = (OrdinalScale) scale;
                for (String s : o.getList()) {
                    map.put(s, new TargetValueObject());
                }
            }
        } else {
            NumericTransformer t = new NumericTransformer();
            this.setTransformer(t);
View Full Code Here

            // We add all values that occur, but are not in the map yet:
            for (String s : allValues) {
                if (!map.containsKey(s)) {
                    if (defaultTarget == null) {
                        map.put(s, new TargetValueObject());
                    } else {
                        map.put(s, new TargetValueObject(defaultTarget.doubleValue()));
                    }
                }
            }

            // We also have to publish the known values
View Full Code Here

public class OrdinalTransformerMappingFactory extends AbstractObjectCreationFactory<TargetValueObject> {

    @Override
    public TargetValueObject createObject(Attributes arg0) throws Exception {
        TargetValueObject o = new TargetValueObject();
        o.setValue(Double.parseDouble(arg0.getValue("target")));
        return  o;
    }
View Full Code Here

TOP

Related Classes of eu.scape_project.planning.model.TargetValueObject

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.