Package eu.planets_project.services.characterise

Examples of eu.planets_project.services.characterise.CharacteriseResult


        if (file.length() == 0) {
            throw new IllegalStateException("Empty file: " + file);
        }
        DigitalObject digitalObject = new DigitalObject.Builder(Content
                .byValue(file)).build();
        CharacteriseResult characteriseResult = characterizer.characterise(
                digitalObject, null);
        List<Property> properties = characteriseResult.getProperties();
        System.out.println("Characterised " + file.getAbsolutePath() + " as: "
                + properties);
        Assert.assertTrue("Result does not contain the correct mime type: "
                + type.mime + " in result: " + properties, properties
                .contains(new Property(MetadataExtractor.makePropertyURI("TYPE"), "TYPE", type.mime)));
View Full Code Here


        // Now prepare the result:
        List<MeasurementImpl> stage_m = stage.getMeasurements();
       
        // Invoke the service, timing it along the way:
        boolean success = true;
        CharacteriseResult result = null;
        long msBefore = 0, msAfter = 0;
        msBefore = System.currentTimeMillis();
        try {
            log.info("Characterising "+dob);
            //FIXME this is a hack for disabling norm data for XCDL characterisation services
            // as parameters are currently not definable for this expType
            List<Parameter> parameterList = new ArrayList<Parameter>();
            parameterList.add(new Parameter("disableNormDataInXCDL","-n"));
            result = dp.characterise(dob, parameterList);
            wr.logReport(result.getReport());
        } catch( Exception e ) {
            log.error("Characterisation failed with exception: "+e);
            e.printStackTrace();
            success = false;
        }
        msAfter = System.currentTimeMillis();
        if( success ) {
            log.info("Characterisation succeeded: "+result);
            if( result != null ) {
                // URGENT Formalise and refactor this logic.
                log.info("Service Report: "+result.getReport().getMessage());
                log.info("Service Report: "+result.getReport().getStatus());
                log.info("Service Report: "+result.getReport().getType());
                if( result.getReport().getStatus() == Status.INSTALLATION_ERROR
                        || result.getReport().getStatus() == Status.TOOL_ERROR ) {
                    success = false;
                }
            }
        }
       
        // Compute the run time.
        stage_m.add(new MeasurementImpl(TecRegMockup.PROP_SERVICE_TIME, ""+((msAfter-msBefore)/1000.0)) );
        // Add the object size:
        stage_m.add( new MeasurementImpl(TecRegMockup.PROP_DO_SIZE, ""+IdentifyWorkflow.getContentSize(dob) ) );

        // Record results:
        if( success ) {
            stage_m.add( new MeasurementImpl( TecRegMockup.PROP_SERVICE_EXECUTION_SUCEEDED, "true"));
            if( result != null && result.getProperties() != null ) {
                log.info("Got "+result.getProperties().size()+" properties");
                for( Property p : result.getProperties() ) {
                    log.info("Recording measurement: "+p.getUri()+":"+p.getName()+" = "+p.getValue());
                    stage_m.add(new MeasurementImpl( p.getUri(), p.getValue() ));
                }
            }
            return;
View Full Code Here

        // Run the service:
        try {
            Characterise chr = new CharacteriseWrapper(new URL(this.getCharacteriseService()));
            DigitalObject dob = this.getDob().getDob();
            log.info("Got digital object: "+dob);
            CharacteriseResult cr = chr.characterise( dob, null);
            return cr;
        } catch( Exception e ) {
            log.error("FAILED! "+e);
            e.printStackTrace();
            return null;
View Full Code Here

    /**
     * @return
     */
    public List<Property> getCharacteriseProperties() {
      List<Property> ret = new ArrayList<Property>();
        CharacteriseResult cr = this.runCharacteriseService();
        if( cr == null ) return null;
        if( cr.getProperties() != null ) {
            log.info("Got properties: "+cr.getProperties().size());
        }else{
          return ret;
        }
        //iterate over the properties and truncate when more than 500 chars
        for(Property p : cr.getProperties()){
          if(p.getValue().length()>500){
            //add a truncated value String
            ret.add(new Property(p.getUri(),p.getName(),p.getValue().substring(0, 500)+"[..]"));
          }else{
            //add the original result
View Full Code Here

   
    /**
     * @return
     */
    public String getCharacteriseServiceReport() {
        CharacteriseResult cr = this.runCharacteriseService();
        if( cr == null ) return null;
        return ""+cr.getReport();
    }
View Full Code Here

TOP

Related Classes of eu.planets_project.services.characterise.CharacteriseResult

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.