Package eu.planets_project.pp.plato.model.values

Examples of eu.planets_project.pp.plato.model.values.Value


    /**
     * @see eu.planets_project.pp.plato.model.scales.Scale#createValue()
     */
    @Override
    public Value createValue() {
        Value v = new FloatValue();
        v.setScale(this);
        return v;
    }
View Full Code Here


    /**
     * @see eu.planets_project.pp.plato.model.scales.Scale#createValue()
     */
    @Override
    public Value createValue() {
        Value v = new IntegerValue();
        v.setScale(this);
        return v;
    }
View Full Code Here

            SampleObject sample, DigitalObject result, List<MeasurementInfoUri> measurementInfoUris,
            IStatusListener listener) throws EvaluatorException {
       
        HashMap<MeasurementInfoUri, Value> results = new HashMap<MeasurementInfoUri, Value>();
        for(MeasurementInfoUri m : measurementInfoUris) {
            Value v = evaluate(alternative, sample, result, m);
            if (v != null) {
                results.put(m, v);
            }
        }
        return results;
View Full Code Here

                v.setComment("extracted from experiments details");
                return v;
            }
            return null;
        } else if (OBJECT_ACTION_RUNTIME_PERFORMANCE_THROUGHPUT.equals(propertyURI)) {
            Value extracted = extractMeasuredValue(alternative, sample, OBJECT_ACTION_RUNTIME_PERFORMANCE_TIME_PERSAMPLE);
            if (extracted instanceof PositiveFloatValue){
                PositiveFloatValue value = new PositiveFloatValue();
                double floatVal =  ((PositiveFloatValue)extracted).getValue();
                if (Double.compare(floatVal, 0.0) !=  0) {
                    // calculate msec/MB
                    floatVal = floatVal / sampleSize;
                    // throughput is defined in MB per second, time/perMB is msec/MB
                    value.setValue((1.0/(floatVal/1000.0)));
                }
                value.setComment("extracted from experiment details");
                return value;
            }
        } else if (OBJECT_ACTION_RUNTIME_PERFORMANCE_TIME_PERMB.equals(propertyURI)) {
            Value extracted = extractMeasuredValue(alternative, sample, OBJECT_ACTION_RUNTIME_PERFORMANCE_TIME_PERSAMPLE);
            if (extracted instanceof PositiveFloatValue){
                PositiveFloatValue value = new PositiveFloatValue();
                double floatVal =  ((PositiveFloatValue)extracted).getValue();
                if (Double.compare(floatVal, 0.0) !=  0) {
                    // calculate msec/MB
                    floatVal = floatVal / sampleSize;
                    value.setValue(floatVal);
                }
                value.setComment("extracted from experiment details");
                return value;
            }
        } else if(OBJECT_ACTION_RUNTIME_PERFORMANCE_MEMORY_PERMB.equals(propertyURI)) {
            Value extracted = extractMeasuredValue(alternative, sample, OBJECT_ACTION_RUNTIME_PERFORMANCE_MEMORY_PERSAMPLE);
            if (extracted instanceof PositiveFloatValue) {
                PositiveFloatValue value = new PositiveFloatValue();
                double floatVal = ((PositiveFloatValue)extracted).getValue();
               
                value.setValue(floatVal / sampleSize);
                value.setComment("extracted from experiment details");
                return value;
            }
        }
        Value extracted = extractMeasuredValue(alternative, sample, propertyURI);
        if (extracted != null) {
            extracted.setComment("extracted from experiment details");
        }
        return extracted;
    }
View Full Code Here

                        // This means that I am not entitled to evaluate this measurementInfo and therefore supposed to skip it:
                        continue;
                    }
                    if (ACTION_RETAIN_FILENAME.equals(propertyURI)) {
                        // for all wrapped minimee migrators the output filename can be determined by -o <filename> or something similar 
                        Value v = scale.createValue();
                        v.setComment("obtained from PCDL descriptor");
                        v.parse("Yes");
                        results.put(measurementInfoUri, v);
                    }
                   
                    String extractionPath = extractionPaths.get(propertyURI);
                    if (extractionPath != null) {
                        Value v = new XmlExtractor().extractValue(doc, scale, extractionPath, null);
                        if (v != null) {
                            v.setComment("obtained from PCDL descriptor");
                            results.put(measurementInfoUri, v);                       
                        } else {
                            // No: only successfully evaluated values are returned 
                            // v = leaf.getScale().createValue();
                            // v.setComment("failed to obtain value from PCDL descriptor");
View Full Code Here

                
                 String sampleImageCompressionScheme = extractor.extractText(fitsDocSample, "//fits:compressionScheme/text()");
                 String resultImageCompressionScheme = extractor.extractText(fitsDocResult, "//fits:compressionScheme/text()");
                
                 for (MeasurementInfoUri measurementInfoUri : measurementInfoUris) {
                     Value v = null;
                     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:
                         continue;
                     }
                     if(OBJECT_FORMAT_CORRECT_WELLFORMED.equals(propertyURI)) {
                         v = extractor.extractValue(fitsDocResult, scale,
                             "//fits:well-formed[@status='SINGLE_RESULT']/text()",
                             "//fits:filestatus/fits:message/text()");
                     } else if(OBJECT_FORMAT_CORRECT_VALID.equals(propertyURI)) {
                         v = extractor.extractValue(fitsDocResult, scale,
                                 "//fits:filestatus/fits:valid[@status='SINGLE_RESULT']/text()",
                                 "//fits:filestatus/fits:message/text()");
                     } if(OBJECT_COMPRESSION_SCHEME.equals(propertyURI)) {
                         v = extractor.extractValue(fitsDocResult, scale,
                                 "//fits:compressionScheme/text()",
                                 null);
                     }
                    
                     if ((v!= null) && (v.getComment() == null || "".equals(v.getComment()))) {
                         v.setComment(SOURCE);
                         results.put(measurementInfoUri, v);
                         listener.updateStatus(String.format("%s: measurement: %s = %s", NAME, measurementInfoUri.getAsURI(), v.toString()));
                         // this leaf has been processed
                         continue;
                     }                             

                     if(OBJECT_FORMAT_CORRECT_CONFORMS.equals(propertyURI)) {
                         if (alternative.getAction() != null) {
                             String puid = "UNDEFINED";
                             FormatInfo info = alternative.getAction().getTargetFormatInfo();
                             if (info != null) {
                                 puid = info.getPuid();
                             }
                             String fitsText = extractor.extractText(fitsDocResult,"//fits:externalIdentifier[@type='puid']/text()");
                             v = identicalValues(puid, fitsText, scale);
                         }
                     }  else if((OBJECT_IMAGE_DIMENSION_WIDTH + "#equal").equals(propertyURI)) {
                         String sampleValue = extractor.extractText(fitsDocSample, "//fits:imageWidth/text()");
                         String resultValue = extractor.extractText(fitsDocResult,"//fits:imageWidth/text()");
                         v = identicalValues(sampleValue, resultValue, scale);
                     else if((OBJECT_IMAGE_DIMENSION_HEIGHT + "#equal").equals(propertyURI)) {
                         String sampleValue = extractor.extractText(fitsDocSample,"//fits:imageHeight/text()");
                         String resultValue = extractor.extractText(fitsDocResult,"//fits:imageHeight/text()");
                         v = identicalValues(sampleValue, resultValue, scale);
                     else if((OBJECT_IMAGE_DIMENSION_ASPECTRATIO + "#equal").equals(propertyURI)) {
                         try {
                            int sampleHeight = Integer.parseInt(extractor.extractText(fitsDocSample,"//fits:imageHeight/text()"));
                            int resultHeight =  Integer.parseInt(extractor.extractText(fitsDocResult,"//fits:imageHeight/text()"));
                            int sampleWidth = Integer.parseInt(extractor.extractText(fitsDocSample,"//fits:imageWidth/text()"));
                            int resultWidth =  Integer.parseInt(extractor.extractText(fitsDocResult,"//fits:imageWidth/text()"));
                           
                            double sampleRatio = ((double)sampleWidth) / sampleHeight;
                            double resultRatio = ((double)resultWidth) / resultHeight;
                            v = scale.createValue();
                            ((BooleanValue)v).bool(0 == Double.compare(sampleRatio, resultRatio));
                            v.setComment(String.format("Reference value: %s\nActual value: %s",
                                    formatter.formatFloat(sampleRatio),formatter.formatFloat(resultRatio)));
                        } catch (NumberFormatException e) {
                            // not all values are available - aspectRatio cannot be calculated
                            v = scale.createValue();
                            v.setComment("Image width and/or height are not available - aspectRatio cannot be calculated");
                        }
                     }  else if((OBJECT_COMPRESSION_SCHEME + "#equal").equals(propertyURI)) {
                         v = identicalValues(sampleImageCompressionScheme, resultImageCompressionScheme, scale);
                     else if(OBJECT_COMPRESSION_LOSSLESS.equals(propertyURI)) {
                         // At the moment we only handle compression schemes of images
                         if ((resultImageCompressionScheme != null) && (!"".equals(resultImageCompressionScheme))) {
                             v = scale.createValue();
                             ((BooleanValue)v).bool(FITS_COMPRESSIONSCHEME_UNCOMPRESSED.equals(resultImageCompressionScheme));
                         }
                     }  else if(OBJECT_COMPRESSION_LOSSY.equals(propertyURI)) {
                         // At the moment we only handle compression schemes of images
                         if ((resultImageCompressionScheme != null) && (!"".equals(resultImageCompressionScheme))) {
                             v = scale.createValue();
                             ((BooleanValue)v).bool(! FITS_COMPRESSIONSCHEME_UNCOMPRESSED.equals(resultImageCompressionScheme));
                         }
                     }  else if((OBJECT_IMAGE_COLORENCODING_BITSPERSAMPLE + "#equal").equals(propertyURI)) {
                         String sampleValue = extractor.extractText(fitsDocSample,"//fits:bitsPerSample/text()");
                         String resultValue = extractor.extractText(fitsDocResult,"//fits:bitsPerSample/text()");
                         v = identicalValues(sampleValue, resultValue, scale);
                     else if((OBJECT_IMAGE_COLORENCODING_SAMPLESPERPIXEL + "#equal").equals(propertyURI)) {
                         String sampleValue = extractor.extractText(fitsDocSample,"//fits:samplesPerPixel/text()");
                         String resultValue = extractor.extractText(fitsDocResult,"//fits:samplesPerPixel/text()");
                         v = identicalValues(sampleValue, resultValue, scale);
                     else if((OBJECT_IMAGE_PHOTOMETRICINTERPRETATION_COLORSPACE + "#equal").equals(propertyURI)) {
                         String sampleValue = extractor.extractText(fitsDocSample,"//fits:colorSpace/text()");
                         String resultValue = extractor.extractText(fitsDocResult,"//fits:colorSpace/text()");
                         v = identicalValues(sampleValue, resultValue, scale);
                     } else if ((OBJECT_IMAGE_PHOTOMETRICINTERPRETATION_COLORPROFILE_ICCPROFILE+ "#equal").equals(propertyURI)) {
                         String sampleValue = extractor.extractText(fitsDocSample,"//fits:iccProfileName/text()");
                         String resultValue = extractor.extractText(fitsDocResult,"//fits:iccProfileName/text()");
                         v = identicalValues(sampleValue, resultValue, scale);
                     } else if ((OBJECT_IMAGE_SPATIALMETRICS_SAMPLINGFREQUENCYUNIT+ "#equal").equals(propertyURI)) {
                         String sampleValue = extractor.extractText(fitsDocSample,"//fits:samplingFrequencyUnit/text()");
                         String resultValue = extractor.extractText(fitsDocResult,"//fits:samplingFrequencyUnit/text()");
                         v = identicalValues(sampleValue, resultValue, scale);
                     } else if ((OBJECT_IMAGE_SPATIALMETRICS_XSAMPLINGFREQUENCY+ "#equal").equals(propertyURI)) {
                         String sampleValue = extractor.extractText(fitsDocSample,"//fits:xSamplingFrequency/text()");
                         String resultValue = extractor.extractText(fitsDocResult,"//fits:xSamplingFrequency/text()");
                         v = identicalValues(sampleValue, resultValue, scale);
                     } else if ((OBJECT_IMAGE_SPATIALMETRICS_YSAMPLINGFREQUENCY+ "#equal").equals(propertyURI)) {
                         String sampleValue = extractor.extractText(fitsDocSample,"//fits:ySamplingFrequency/text()");
                         String resultValue = extractor.extractText(fitsDocResult,"//fits:ySamplingFrequency/text()");
                         v = identicalValues(sampleValue, resultValue, scale);
                        
                     } else if ((OBJECT_IMAGE_METADATA+ "#equal").equals(propertyURI)) {
                         // we use the equal metric. reserve PRESERVED metric for later and get it right.
                         HashMap<String, String> sampleMetadata = extractor.extractValues(fitsDocSample, "//fits:exiftool/*[local-name() != 'rawdata']");
                         HashMap<String, String> resultMetadata = extractor.extractValues(fitsDocResult, "//fits:exiftool/*[local-name() != 'rawdata']");
                         v = preservedValues(sampleMetadata, resultMetadata, scale);
                     } else if ((OBJECT_IMAGE_METADATA_PRODUCER+ "#equal").equals(propertyURI)) {
                         String sampleValue = extractor.extractText(fitsDocSample,"//fits:ImageCreation/ImageProducer/text()");
                         String resultValue = extractor.extractText(fitsDocResult,"//fits:ImageCreation/ImageProducer/text()");
                         v = identicalValues(sampleValue, resultValue, scale);
                     } else if ((OBJECT_IMAGE_METADATA_SOFTWARE+ "#equal").equals(propertyURI)) {
                         String sampleValue = extractor.extractText(fitsDocSample,"//fits:creatingApplicationName/text()");
                         String resultValue = extractor.extractText(fitsDocResult,"//fits:creatingApplicationName/text()");
                         v = identicalValues(sampleValue, resultValue, scale);
                     } else if ((OBJECT_IMAGE_METADATA_CREATIONDATE+ "#equal").equals(propertyURI)) {
                         String sampleValue = extractor.extractText(fitsDocSample,"//fits:ImageCreation/DateTimeCreated/text()");
                         String resultValue = extractor.extractText(fitsDocResult,"//fits:ImageCreation/DateTimeCreated/text()");
                         v = identicalValues(sampleValue, resultValue, scale);
                     } else if ((OBJECT_IMAGE_METADATA_LASTMODIFIED+ "#equal").equals(propertyURI)) {
                         String sampleValue = extractor.extractText(fitsDocSample,"//fits:fileinfo/lastmodified/text()");
                         String resultValue = extractor.extractText(fitsDocResult,"//fits:fileinfo/lastmodified/text()");
                         v = identicalValues(sampleValue, resultValue, scale);
                     } else if ((OBJECT_IMAGE_METADATA_DESCRIPTION+ "#equal").equals(propertyURI)) {
                         String sampleValue = extractor.extractText(fitsDocSample,"//fits:exiftool/ImageDescription/text()");
                         String resultValue = extractor.extractText(fitsDocResult,"//fits:exiftool/ImageDescription/text()");
                         v = identicalValues(sampleValue, resultValue, scale);
                     } else if ((OBJECT_IMAGE_METADATA_ORIENTATION+ "#equal").equals(propertyURI)) {
                         String sampleValue = extractor.extractText(fitsDocSample,"//fits:exiftool/Orientation/text()");
                         String resultValue = extractor.extractText(fitsDocResult,"//fits:exiftool/Orientation/text()");
                         v = identicalValues(sampleValue, resultValue, scale);
                     }
                   

                     if (v!= null) {
                         v.setComment(v.getComment() + SOURCE);
                         results.put(measurementInfoUri, v);
                         listener.updateStatus(String.format("%s: evaluated measurement: %s = %s", NAME, measurementInfoUri.getAsURI(), v.toString()));                            
                     } else {
                         listener.updateStatus(String.format("%s: no evaluator found for measurement: %s", NAME, measurementInfoUri.getAsURI()));                            
                     }
                 }
            } catch (IOException e) {
View Full Code Here

            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 {
                    listener.updateStatus("P2 does not contain enough information to evaluate "+propertyURI+" for this format.");
                }
View Full Code Here

                return results;
            }
           
            // add comments to results
            for (MeasurementInfoUri info : compResult.keySet()) {
                Value v = compResult.get(info);
                if (v != null) {
                    v.setComment(v.getComment() + "\n - evaluated with XCL tools");
                    results.put(info, v);
                }
            }
            return results;
        } catch (Exception e) {
View Full Code Here

    public Value extractValue(Document xml, Scale scale, String xpath, String commentXPath) {
        try {
            Document pcdlDoc = xml;
            String text = extractTextInternal(pcdlDoc,xpath);
            Value v = scale.createValue();
            v.parse(text);
            if (commentXPath != null) {
                String comment = extractTextInternal(pcdlDoc,commentXPath);
                v.setComment(comment);
            }
            return v;
           
        } catch (Exception e) {
            PlatoLogger.getLogger(this.getClass()).error(
View Full Code Here

                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);
                                v.setComment("computed by ImageMagick compare");                           
                            } else {
                                v.setComment("ImageMagick comparison failed - wrong Scale defined.");
                            }
                        }
                    }
                    if (v != null) {
                        // add the value to the result set
View Full Code Here

TOP

Related Classes of eu.planets_project.pp.plato.model.values.Value

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.