Package eu.scape_project.planning.model.scales

Examples of eu.scape_project.planning.model.scales.Scale


     *
     * @param className
     *            canonical class name of the new scale
     */
    public void setScaleByClassName(String className) {
        Scale scaleType = null;
        try {
            if (className != null && !"".equals(className)) {
                scaleType = (Scale) Class.forName(className).newInstance();
            }
        } catch (InstantiationException e) {
View Full Code Here


        }
        params.put("PUID", puid);

        for (String measureId : measureUris) {

            Scale scale = null;
            Value value = null;

            if (MeasureConstants.BATCHPROCESSING_SUPPORTED.equals(measureId)) {
                scale = new BooleanScale();
                value = scale.createValue();
                if (!alternative.getAction().isEmulated() && alternative.getAction().isExecutable()) {
                    // this alternative is wrapped as service and therefore
                    // provides batch support
                    value.parse("Yes");
                    value.setComment("this alternative is wrapped as service and therefore provides batch support");
                }
            }

            String statement = statements.get(measureId);
            if (statement == null) {
                // this leaf cannot be evaluated by MiniREEF - skip it
                continue;
            }

            String result = null;

            // add additional params if necessary
            // ...
            ResultSet resultSet = MiniREEFResolver.getInstance().resolve(statement, params);
            listener.updateStatus("MiniREEF is attempting to evaluate " + measureId);

            if (resultSet == null) {
                // this should not happen, if MiniREEF is properly configured
                listener.updateStatus("querying MiniREEF/P2 knowledge base failed for statement: " + statement);
                // skip this leaf
                continue;
            }

            // evaluation was successful!
            if (measureId.startsWith(MeasureConstants.NUMBER_OF_TOOLS)) {
                scale = new PositiveIntegerScale();
                value = scale.createValue();

                // _measure_ is the number of tools found
                result = "" + resultSet.size();
                value.parse(result);
                // add names of tools as comment
                value.setComment(toCommaSeparated(resultSet.getColResults("swname"))
                    + "; - according to miniREEF/P2 knowledge base");
                listener.updateStatus("MiniREEF evaluated " + measureId);
            } else if (MeasureConstants.FORMAT_IPR_PROTECTION.equals(measureId)) {
                scale = new OrdinalScale();

                if (resultSet.size() > 0) {
                    // e.g. open = false, comment: "Format is encumbered by IPR"
                    String comment = "";
                    String valueStr = "";
                    for (int i = 0; i < resultSet.size(); i++) {
                        List<String> vals = resultSet.getRow(i);
                        comment = comment + vals.get(0) + "\n";
                        String type = vals.get(1);
                        if (P2_RESOURCE_FORMAT_LICENSE_RIGHTS_IPR_PROTECTED.equals(type)) {
                            valueStr = "ipr_protected";
                            comment = comment + valueStr;
                        } else if (P2_RESOURCE_FORMAT_LICENSE_RIGHTS_PROPRIETARY.equals(type)) {
                            valueStr = "proprietary";
                            comment = comment + valueStr;
                        } else if (P2_RESOURCE_FORMAT_LICENSE_RIGHTS_OPEN.equals(type)) {
                            valueStr = "open";
                            comment = comment + valueStr;
                        }
                    }
                    if (resultSet.size() > 1) {
                        comment = comment
                            + ": more than one right category applies to this format, check for reason of this conflict.\n";
                    }
                    value = scale.createValue();
                    value.parse(valueStr);
                    value.setComment(comment + ": according to MiniREEF/P2 knowledge base");
                    listener.updateStatus("MiniREEF evaluated " + measureId);
                }
                listener.updateStatus("P2 does not contain enough information to evaluate " + measureId
                    + " for this format.");
            } else if ((MeasureConstants.FORMAT_COMPLEXITY.equals(measureId))) {
                // || (MeasureConstants.FORMAT_DISCLOSURE.equals(measureId))
                // FIXME: the results from p2 have to be matched to the defined
                // measures
                // || (MeasureConstants.FORMAT_UBIQUITY.equals(measureId))
                // ||
                // (MeasureConstants.FORMAT_DOCUMENTATION_QUALITY.equals(measureId))
                // || (MeasureConstants.FORMAT_STABILITY.equals(measureId))
                // || (MeasureConstants.FORMAT_LICENSE.equals(measureId))) {

                scale = new OrdinalScale();

                if (resultSet.size() > 0) {
                    String text = resultSet.getRow(0).get(0);
                    if (text.trim().length() > 0) {
                        value = scale.createValue();
                        value.parse(text);
                        value.setComment("according to miniREEF/P2 knowledge base");
                    }
                    listener.updateStatus("MiniREEF evaluated " + measureId);
                } else {
View Full Code Here

            // NOTE: imageEvaluator is called once per criterion as the used
            // minimee evaluator will do separate calls anyway
            ImageCompareEvaluator imageEvaluator = new ImageCompareEvaluator();

            for (String measureUri : measureUris) {
                Scale scale = null;
                String mode = null;
                if (MeasureConstants.IMAGE_CONTENT_IS_EQUAL.equals(measureUri)) {
                    mode = "equal";
                    scale = new BooleanScale();
                } else if (MeasureConstants.ABSOLUTE_ERROR_AE.equals(measureUri)) {
                    mode = "ae";
                    scale = new PositiveFloatScale();
                } else if (MeasureConstants.PEAK_ABSOLUTE_ERROR_PAE.equals(measureUri)) {
                    mode = "pae";
                    scale = new PositiveFloatScale();
                } else if (MeasureConstants.PEAK_SIGNAL_TO_NOISE_RATIO.equals(measureUri)) {
                    mode = "psnr";
                    scale = new PositiveFloatScale();
                } else if (MeasureConstants.MEAN_ABSOLUTE_ERROR.equals(measureUri)) {
                    mode = "mae";
                    scale = new PositiveFloatScale();
                } else if (MeasureConstants.MEAN_SQUARED_ERROR.equals(measureUri)) {
                    mode = "mse";
                    scale = new PositiveFloatScale();
                } else if (MeasureConstants.IMAGE_DISTANCE_RMSE.equals(measureUri)) {
                    mode = "rmse";
                    scale = new PositiveFloatScale();
                }

                if (mode != null) {
                    if (mode.equals("equal")) {
                        Double d = imageEvaluator.evaluate(tempDir.getAbsolutePath(), tempFiles.get(sample),
                            tempFiles.get(result), "AE");
                        if (d != null && d.compareTo(Scale.MAX_VALUE) != 0) {
                            Value v = scale.createValue();
                            ((BooleanValue) v).bool(d.compareTo(0.0) == 0);
                            v.setComment("ImageMagick compare returned " + Double.toString(d) + " different pixels");
                            results.put(measureUri, v);
                        }
                    } else {
                        Double d = imageEvaluator.evaluate(tempDir.getAbsolutePath(), tempFiles.get(sample),
                            tempFiles.get(result), mode);
                        if (d != null && d.compareTo(Scale.MAX_VALUE) != 0) {
                            Value v = scale.createValue();
                            if (v instanceof FloatValue) {
                                ((FloatValue) v).setValue(d);
                                v.setComment("computed by ImageMagick compare");
                            } else if (v instanceof PositiveFloatValue) {
                                ((PositiveFloatValue) v).setValue(d);
View Full Code Here

            // we can only use the scales of leaves, as
            // - nodes can be changed when weighting is changed
            // - leaves are "changed" when evaluated, aggregation mode is
            // changed
            if (treeNode instanceof Leaf) {
                Scale scale = ((Leaf) treeNode).getScale();
                if (scale != null) {
                    ChangeLog scaleCL = scale.getChangeLog();
                    if (maxCL < scaleCL.getChanged()) {
                        maxCL = scaleCL.getChanged();
                    }
                }
            }
View Full Code Here

    @Test
    public void testMeasureWithPositiveNumberScale() {
        Measure m = criteriaManager.getMeasure("http://purl.org/DP/quality/measures#3");
        Assert.assertNotNull(m);

        Scale s = m.getScale();
        Assert.assertNotNull("Measure '" + m.getName() + "' has no scale!", s);

        Assert.assertTrue(s instanceof PositiveFloatScale);
    }
View Full Code Here

    @Test
    public void testMeasureWithPositiveIntegerScale() {
        Measure m = criteriaManager.getMeasure("http://purl.org/DP/quality/measures#96");
        Assert.assertNotNull(m);

        Scale s = m.getScale();
        Assert.assertNotNull("Measure '" + m.getName() + "' has no scale!", s);

        Assert.assertTrue(s instanceof PositiveIntegerScale);
    }
View Full Code Here

    @Test
    public void testMeasureWithOrdinalScale() {
        Measure m = criteriaManager.getMeasure("http://purl.org/DP/quality/measures#38");
        Assert.assertNotNull(m);

        Scale s = m.getScale();
        Assert.assertNotNull("Measure '" + m.getName() + "' has no scale!", s);

        Assert.assertTrue(s instanceof OrdinalScale);
        Assert.assertTrue("Measure '" + m.getName() + "' scale " + s.getDisplayName() + " has no restriction defined.",
            StringUtils.isNotEmpty(((OrdinalScale) s).getRestriction()));
    }
View Full Code Here

        Assert.assertTrue("Measure '" + m.getName() + "' category has no uri!",
            StringUtils.isNotEmpty(category.getUri()));
        Assert.assertNotNull("Measure '" + m.getName() + "' category " + category.getUri() + " has no scope",
            category.getScope());

        Scale s = m.getScale();
        Assert.assertNotNull("Measure '" + m.getName() + "' has no scale!", s);
        Assert.assertNotNull("Measure '" + m.getName() + "' scale " + s.getDisplayName() + " has no type", s.getType());
    }
View Full Code Here

            Assert.assertTrue(StringUtils.isNotEmpty(a.getName()));

            CriterionCategory category = a.getCategory();
            Assert.assertNotNull("Measure '" + m.getName() + " has no category defined", category);

            Scale s = m.getScale();
            Assert.assertNotNull("Measure '" + m.getName() + "' has no scale!", s);
            Assert.assertNotNull("Measure '" + m.getName() + "' scale " + s.getDisplayName() + " has no type",
                s.getType());

            if (s instanceof RestrictedScale) {
                Assert.assertTrue("Measure '" + m.getName() + "' restricted scale " + s.getDisplayName()
                    + " with undefined restriction.", StringUtils.isNotEmpty(((RestrictedScale) s).getRestriction()));
            }
        }
    }
View Full Code Here

            m.setUri(qs.getResource("m").toString());
            m.setName(qs.getLiteral("mn").getString());
            m.setDescription(qs.getLiteral("md").getString());

            Scale s = createScale(qs.getResource("s").getLocalName());
            m.setScale(s);

            if ((s instanceof RestrictedScale) && (qs.contains("r"))) {
                String restriction = qs.getLiteral("r").getString();
                ((RestrictedScale) s).setRestriction(restriction);
View Full Code Here

TOP

Related Classes of eu.scape_project.planning.model.scales.Scale

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.