Package eu.planets_project.pp.plato.model.scales

Examples of eu.planets_project.pp.plato.model.scales.FreeStringScale


    }
   
    public Measurement(String propertyName, String value) {
        MeasurableProperty p = new MeasurableProperty();
        p.setName(propertyName);
        p.setScale(new FreeStringScale());
        FreeStringValue s = (FreeStringValue) p.getScale().createValue();
        s.setValue(value);
        this.setProperty(p);
        this.setValue(s);
    }
View Full Code Here


     * then for each newly added mapping, the default target is set as provided.
     */
    public void initTransformer(Double defaultTarget) {

        if (scale instanceof FreeStringScale) {
            FreeStringScale freeScale = (FreeStringScale) scale;
            // We collect all distinct actually EXISTING values
            OrdinalTransformer t = (OrdinalTransformer) transformer;
            Map<String, TargetValueObject> map = t.getMapping();

            HashSet<String> allValues = new HashSet<String>();
            for (Values values: valueMap.values()) {
                for (Value v : values.getList()) {
                    FreeStringValue text = (FreeStringValue) v;
                    if (!text.toString().equals("")) {
                        for (String s: map.keySet()) {
                            // if the value is NOT the same, but IS the same with other case,
                            // we replace the value with the cases predefined by the mapping
                            if (text.getValue().equalsIgnoreCase(s) && !text.getValue().equals(s)) {
                                text.setValue(s);
                            }
                        }
                        allValues.add(text.getValue());
                    }
                }
            }
           
            // We remove all values from the transformer that do not actually occur (anymore)
            // I am disabling this for now - why would we want to remove known mappings?
            // They don't do harm because for the lookup, we use the actually encountered values
            // (see below)
//            HashSet<String> keysToRemove = new HashSet<String>();
//           for (String s: map.keySet()) {
//               if (!allValues.contains(s)) {
//                   keysToRemove.add(s);
//               }
//           }
//           for (String s: keysToRemove) {
//               map.remove(s);
//           }
          
            // We add all values that occur, but dont 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
            // to the SCALE because it provides the reference lookup
            // for iterating and defining the transformation
            freeScale.setPossibleValues(allValues);
        }
    }
View Full Code Here

        Measurement success = new Measurement();
        success.setProperty(new MeasurableProperty(new BooleanScale(), MigrationResult.MIGRES_SUCCESS));
        success.setValue(success.getProperty().getScale().createValue());
       
        Measurement report = new Measurement();
        report.setProperty(new MeasurableProperty(new FreeStringScale(), MigrationResult.MIGRES_REPORT));
        report.setValue(report.getProperty().getScale().createValue());
       
        try {
            MigrationResult result = service.migrate(e.getAction(), r);
            if (result.isSuccessful()) {
View Full Code Here

            if ("?".equals(TEXT)) {
                return null;
            }
           
            if ("FREE TEXT".equals(TEXT.toUpperCase())) {
                return new FreeStringScale();
            }

            if (TEXT.indexOf(Scale.SEPARATOR) != -1 ) {
                RestrictedScale v = null;
//              try {
View Full Code Here

TOP

Related Classes of eu.planets_project.pp.plato.model.scales.FreeStringScale

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.