Package eu.planets_project.services.characterise

Examples of eu.planets_project.services.characterise.CharacteriseResult


    @Test
    public void simple() {
        /* A simple CharacteriseResult consists of a list of properties and a service report: */
        ArrayList<Property> props = someProps();
        ServiceReport report = someReport();
        CharacteriseResult result = new CharacteriseResult(props, report);
        Assert.assertEquals(props, result.getProperties());
        Assert.assertEquals(report, result.getReport());
    }
View Full Code Here


        ArrayList<Property> props = someProps();
        ServiceReport report = someReport();
        /* Embedded property lists: */
        ArrayList<Property> embeddedProps1 = someProps();
        ArrayList<Property> embeddedProps2 = someProps();
        List<CharacteriseResult> embeddedResults = Arrays.asList(new CharacteriseResult(embeddedProps1, someReport()),
                new CharacteriseResult(embeddedProps2, someReport()));
        /* Create the top-level result with the embedded results: */
        CharacteriseResult result = new CharacteriseResult(props, report, embeddedResults);
        /* Retrieve top-level properties: */
        Assert.assertEquals(props, result.getProperties());
        Assert.assertEquals(report, result.getReport());
        /* Retrieve the embedded results: */
        List<CharacteriseResult> embedded = result.getResults();
        Assert.assertEquals(embeddedResults, embedded);
        Assert.assertEquals(embeddedProps1, embedded.get(0).getProperties());
        Assert.assertEquals(embeddedProps2, embedded.get(1).getProperties());
    }
View Full Code Here

        Assert.assertEquals(embeddedProps2, embedded.get(1).getProperties());
    }

    @Test(expected = UnsupportedOperationException.class)
    public void immutableProperties() {
        new CharacteriseResult(someProps(), someReport()).getProperties().add(null);
    }
View Full Code Here

        new CharacteriseResult(someProps(), someReport()).getProperties().add(null);
    }

    @Test(expected = UnsupportedOperationException.class)
    public void immutableResults() {
        new CharacteriseResult(someProps(), someReport()).getResults().add(null);
    }
View Full Code Here

        ServiceReport sr = new ServiceReport(Type.INFO, Status.SUCCESS, "Nothing checked");
       
        // Attempt to measure size:
        measured.add( new Property( makePropertyURI(MIME_PROP_URI), MIME_PROP_URI, ""+DigitalObjectUtils.getContentSize( digitalObject ) ));

        return new CharacteriseResult(measured, sr);
    }
View Full Code Here

    private List<Property> runCharacterization(DigitalObject digitalObject) {
        WorkflowResultItem wfResultItem = new WorkflowResultItem(
            WorkflowResultItem.SERVICE_ACTION_CHARACTERISATION,
            System.currentTimeMillis());
      wfResultItem.addLogInfo("STEP 1: Characterisation");
        CharacteriseResult characteriseResult = characterise.characterise(
                digitalObject, null);
       wfResultItem.addLogInfo("Characterise name: " + characterise.NAME + ", qname: " + characterise.QNAME);
        List<Property> properties = characteriseResult.getProperties();
        wfResultItem.addLogInfo("Characterised as: " + properties);
        wfResultItem.addLogInfo("Characterise endpoint: " + characterise.describe().getEndpoint());
        return properties;
    }
View Full Code Here

    /* (non-Javadoc)
     * @see eu.planets_project.services.characterise.DetermineProperties#measure(eu.planets_project.services.datatypes.DigitalObject, eu.planets_project.services.datatypes.Properties, eu.planets_project.services.datatypes.Parameters)
     */
    public CharacteriseResult characterise(DigitalObject dob, List<Parameter> params) {
        /* Result properties are available here: */
        CharacteriseResult characteriseResult = extractorCharacterise.characterise(dob, params);
        List<Property> properties = characteriseResult.getProperties();
        System.out.println(properties);
        /* But the code below wants the XCDL as a DigitalObject, so we use Migrate: */
        MigrateResult migrateResult = extractorMigrate.migrate(dob, null, null, params);
       
        // FIXME Use the properties interface / generally update the invoker as this code is not needed now...
        /*
        for( Property p : characteriseResult.getProperties() ) {
            log.info("Got p = "+p);
        }
        */

        List<MeasurementImpl> list;
        try {
            list = XCDLParser.parseXCDL(migrateResult.getDigitalObject().getContent().getInputStream());
        } catch (Exception e) {
            e.printStackTrace();
            list = null;
        }
        List<Property> mprops = new Vector<Property>();
        if( list != null ) {
            for( MeasurementImpl m : list ) {
                Property p;
                try {
                    p = new Property( new URI( m.getIdentifier()), m.getIdentifier(), m.getValue() );
                    mprops.add(p);
                } catch (URISyntaxException e) {
                    e.printStackTrace();
                }
            }
        }
       
        // FIXME Interface is a problem!  We really want to return simpler entities than full property descriptions.

        ServiceReport report = new ServiceReport(Type.INFO, Status.SUCCESS, "OK");
       
        return new CharacteriseResult(mprops, report);
    }
View Full Code Here

                    ExperimentInspector.persistExperiment();
                }
               
            } else if(sd.getType().equals(Characterise.class.getCanonicalName())) {
                Characterise chr = new CharacteriseWrapper( surl );
                CharacteriseResult cr1 = chr.characterise( this.getDob1().getDob(), null);
                this.compareServiceReport = cr1.getReport();
                CharacteriseResult cr2 = chr.characterise( this.getDob2().getDob(), null);
                this.compareServiceReport = cr2.getReport();
               
                me = this.createMeasurementEvent();
                if( me != null ) {
                    me.setAgent(new MeasurementAgent(chr.describe()));
                    me.setDate(Calendar.getInstance());
                    this.recordPropertyComparison(me, cr1.getProperties(), this.getDobUri1(), cr2.getProperties(), this.getDobUri2() );
                   
                    ExperimentInspector.persistExperiment();
                }
               
            } else {
View Full Code Here

                SimpleCharacterisationService.MIME_PROP_URI,
                null
                ) );
       
        /* Now pass this to the service */
        CharacteriseResult ir = ids.characterise( object, null);
        System.out.println("Got report: "+ir.getReport());
        System.out.println("Got properties: "+ir.getProperties());
        System.out.println("Got properties.size(): "+ir.getProperties().size());
       
        /* Check the result */
        long mSize = -1;
        for( Property p : ir.getProperties() ) {
            if( p.getName().equals(SimpleCharacterisationService.MIME_PROP_URI)) {
                mSize = Long.parseLong( p.getValue() );
            }
        }
        System.out.println("Recieved measured size: " + mSize );
        assertEquals("The returned size did not match the expected size;", size, mSize);
       
        System.out.println("Recieved service report: " + ir.getReport() );
    }
View Full Code Here

     */
    public CharacteriseResult characterise(final DigitalObject digitalObject,
            final List<Parameter> parameters) {
        String resultString = basicCharacteriseOneBinary(digitalObject);
        List<Property> props = readProperties(resultString);
        return new CharacteriseResult(props, new ServiceReport(Type.INFO, Status.SUCCESS, "OK"));
    }
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.