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

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


            if (mappingMetric != null){
                mappingInfo.setMetric(mappingMetric.clone());
            } else {
                mappingInfo.setMetric(null);
            }
            Scale mappingScale =  mappingInfo.getScale();
               
            if (mappingScale != null) {
                // We have to set the scale first, as the measurement info will be reseted, if the scale changes
                mpmSelectedLeaf.changeScale(mappingScale);
                mpmSelectedLeaf.getMeasurementInfo().setProperty(mappingInfo.getProperty());
View Full Code Here


            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
View Full Code Here

        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
               
               
               
               
                if (scale instanceof FreeStringScale) {
                    restriction = "free text";
                } else if ((scale.getType() == ScaleType.ordinal || scale.getType() == ScaleType.restricted)
                        && !"".equals(((RestrictedScale)scale).getRestriction()))
                {
                    restriction = ((RestrictedScale)scale).getRestriction();
                } else {
                    restriction = scale.getUnit();
                }
                scaleElement.addAttribute("TEXT",restriction);
            }
           
        } else {
View Full Code Here

        }
        params.put("PUID", puid);
       
       
        for (MeasurementInfoUri info: measurementInfoUris) {
            Scale scale = descriptor.getMeasurementScale(info);
            if (scale == null)  {
                // This means that I am not entitled to evaluate this measurementInfo and therefore supposed to skip it:
                continue;
            }
           
            Value value = scale.createValue();
            String propertyURI = info.getAsURI();
           
            if (ACTION_BATCH_SUPPORT.equals(propertyURI)) {
                if (alternative.getAction() instanceof IMigrationAction) {
                    // 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(propertyURI);
            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 "+propertyURI);

            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 (propertyURI.startsWith(FORMAT_NUMBEROFTOOLS)){
                // _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 "+propertyURI);
            } else if ((FORMAT_LICENSE_OPEN.equals(propertyURI))||
                       (FORMAT_LICENSE_IPR_PROTECTED.equals(propertyURI))||
                       (FORMAT_LICENSE_PROPRIETARY.equals(propertyURI))) {
                if (resultSet.size() > 0) {
                    // we query for rights information in general, this way we can clarify the deduced result
                    // e.g. open = false, comment: "Format is encumbered by IPR"
                    boolean open = false;
                    boolean ipr = false;
                    boolean proprietary = false;
                    String comment = "";
                    for (int i=0; i < resultSet.size(); i++) {
                        // collect all results, even though there should be only one, the user can take care of it
                        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)) {
                            ipr = true;
                        } else if (P2_RESOURCE_FORMAT_LICENSE_RIGHTS_PROPRIETARY.equals(type)) {
                            proprietary = true;
                        }else if (P2_RESOURCE_FORMAT_LICENSE_RIGHTS_OPEN.equals(type)) {
                            open = true;
                        }
                    }
                    if (resultSet.size() > 1) {
                        comment = comment + "more than one right category applies to this format, check for reason of this conflict.\n";
                    }
                    boolean boolResult = false;
                    if (FORMAT_LICENSE_OPEN.equals(propertyURI)) {
                        boolResult = open;
                    } else if (FORMAT_LICENSE_IPR_PROTECTED.equals(propertyURI)) {
                        boolResult = ipr;
                    } else if (FORMAT_LICENSE_PROPRIETARY.equals(propertyURI)) {
                        boolResult = proprietary;
                    }
                    value = scale.createValue();
                    ((BooleanValue)value).bool(boolResult);
                    value.setComment(comment + "according to MiniREEF/P2 knowledge base");
                    listener.updateStatus("MiniREEF evaluated "+propertyURI);
                }
                listener.updateStatus("P2 does not contain enough information to evaluate "+propertyURI+" for this format.");
            } else if ((FORMAT_COMPLEXITY.equals(propertyURI)) ||
                       (FORMAT_DISCLOSURE.equals(propertyURI)) ||
                       (FORMAT_UBIQUITY.equals(propertyURI))   ||
                       (FORMAT_DOCUMENTATION_QUALITY.equals(propertyURI))||
                       (FORMAT_STABILITY.equals(propertyURI))||
                       (FORMAT_LICENSE.equals(propertyURI)))  {
                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 "+propertyURI);
                } else {
View Full Code Here

            ImageCompareEvaluator imageEvaluator = new ImageCompareEvaluator();
           
            for(MeasurementInfoUri measurementInfoUri: measurementInfoUris) {
                String propertyURI = measurementInfoUri.getAsURI();
                String fragment = measurementInfoUri.getFragment();
                Scale scale = descriptor.getMeasurementScale(measurementInfoUri);
                if (scale == null)  {
                    // This means that I am not entitled to evaluate this measurementInfo and therefore supposed to skip it:
                    continue;
                }
                if ((propertyURI != null) && propertyURI.startsWith(OBJECT_IMAGE_SIMILARITY +"#")) {
                    Value v = null;
                    if (fragment.equals("equal")) {
                        Double d= imageEvaluator.evaluate(tempDir.getAbsolutePath(),
                                tempFiles.get(sample),
                                tempFiles.get(result),
                                "AE");
                       
                        if (d.compareTo(Scale.MAX_VALUE) == 0) {
                            // No: only evaluation results are returned, no error messages
                            // v.setComment("ImageMagick compare failed or could not be called");
                        } else {
                            v = scale.createValue();
                            ((BooleanValue)v).bool(d.compareTo(0.0) == 0);
                            v.setComment("ImageMagick compare returned "+Double.toString(d)+" different pixels");
                        }
        //                log.debug("difference" + Double.toString(Scale.MAX_VALUE-d));
                    } else {
                        Double d= imageEvaluator.evaluate(tempDir.getAbsolutePath(),
                                         tempFiles.get(sample),
                                         tempFiles.get(result),
                                         fragment);
                        if (d == null) {
                            // No: only evaluation results are returned, no error messages
                            // v = leaf.getScale().createValue();
                            // v.setComment("ImageMagick comparison failed");
                        } else {
                            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

        return results;
    }
   
    public Value evaluate(Alternative alternative, SampleObject sample, DigitalObject result, MeasurementInfoUri measurementInfoUri) {
        String propertyURI = measurementInfoUri.getAsURI();
        Scale scale = descriptor.getMeasurementScale(measurementInfoUri) ;
        if (scale == null)  {
            // This means that I am not entitled to evaluate this measurementInfo and therefore supposed to skip it:
            return null;
        }
        double sampleSize = sample.getData().getSize()*(1024*1024);
       
        if (OBJECT_ACTION_ACTIVITYLOGGING_AMOUNT.equals(propertyURI)) {
            Map<SampleObject, DetailedExperimentInfo> detailedInfo = alternative.getExperiment().getDetailedInfo();
            DetailedExperimentInfo detailedExperimentInfo = detailedInfo.get(sample);
            if ((detailedExperimentInfo != null) && (detailedExperimentInfo.getProgramOutput() != null)) {
                PositiveIntegerValue v = (PositiveIntegerValue) scale.createValue();
                v.setValue(detailedExperimentInfo.getProgramOutput().length());
                v.setComment("extracted from experiment details");
                return v;
            }
            return null;
        } else if (OBJECT_ACTION_ACTIVITYLOGGING_FORMAT.equals(propertyURI)) {
            Map<SampleObject, DetailedExperimentInfo> detailedInfo = alternative.getExperiment().getDetailedInfo();
            DetailedExperimentInfo detailedExperimentInfo = detailedInfo.get(sample);
            if ((detailedExperimentInfo != null) && (detailedExperimentInfo.getProgramOutput() != null)) {
                FreeStringValue v = (FreeStringValue) scale.createValue();
                v.setValue(evaluateLogging(detailedExperimentInfo.getProgramOutput()));
                v.setComment("extracted from experiments details");
                return v;
            }
            return null;
View Full Code Here

                               compResult.get(0).getProperties().get(keyParts[1]);
                            if (cprP != null) {
                                String id = MetricToScaleMapping.getMetricId(keyParts[2]);
                                if (id != null) {
                                    Value v = null;                                   
                                    Scale s = MetricToScaleMapping.getScale(id);
                                    if (s == null) {
                                        // There is a new XCLMetric we have not registered in MetricToScaleMapping yet...
                                        log.debug("CPR: unkown metricId: " +  id);
                                    } else {
                                        // scale found, so we can create a value object
                                        v =  s.createValue();
                                        v.setScale(null);
                                       
                                        CprMetricResult mResult = cprP.getResultMetrics().get(id);
                                        if (mResult != null) {
                                            if ("ok".equals(mResult.getState())) {
View Full Code Here

                        // 1. there are only derived measurements in XCL
                        // 2. the fragment of an xcl - measurable property always corresponds to a xcl metric
                        String metricId = info.getFragment();
                       
                        Value v = null;
                        Scale s = descriptor.getMeasurementScale(info);
                        if (s != null) {
                            v = s.createValue();
                            v.setScale(null);
                        }
                        if ((metricId != null)&&(v != null)) {
                            CprMetricResult mResult = resultProperty.getResultMetrics().get(metricId);
                            if (mResult != null) {
View Full Code Here

    public Value getEvaluationValue(String propertyName, String metricName) {
       if (pservProperties != null) {
           try {
               String strValue = getEvaluationResult(propertyName, metricName);
               if (strValue != null) {
                   Scale s = MetricToScaleMapping.getScale(MetricToScaleMapping.getMetricId(metricName));
                   Value result = s.createValue();
                   result.setScale(null);
                   MetricToScaleMapping.setValueFromCprString(strValue, result);
                   return result;
               }
           }catch (Exception e) {
View Full Code Here

         * Plato's Scales are more precise than the result types of XCL metrics:
         * There are not only int, float and boolean values, but a distinction is drawn between
         * positive and negative numbers.
         * Therefore we have to choose the scale according to the metric itself. 
         */
        Scale scale = MetricToScaleMapping.getScale(metric.getMetricId().trim());
        return scale;
       
    }
View Full Code Here

TOP

Related Classes of eu.planets_project.pp.plato.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.