Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
cpedrinaci committed Jun 2, 2015
2 parents b622c85 + 553646d commit 25b62d3
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014. Knowledge Media Institute - The Open University
* Copyright (c) 2015. Knowledge Media Institute - The Open University
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -211,7 +211,7 @@ private void obtainGrounding(Individual individual, AnnotableResource resource)
}

//Swagger grounding
rdfGrounding = individual.getPropertyValue(MSM_WSDL.isGroundedIn);
rdfGrounding = individual.getPropertyValue(MSM_SWAGGER.isGroundedIn);
if (rdfGrounding != null) {
if (rdfGrounding.isLiteral()) {
if (rdfGrounding.asLiteral().getDatatypeURI() != null) {
Expand Down Expand Up @@ -281,7 +281,12 @@ private List<Operation> obtainOperations(NodeIterator hasOpValues) throws URISyn

// Method
if (individual.hasProperty(HRESTS.hasMethod)) {
operation.setMethod(new URI(individual.getProperty(HRESTS.hasMethod).getString()));
RDFNode method = individual.getPropertyValue(HRESTS.hasMethod);
if (method.isLiteral()) {
operation.setMethod(method.asLiteral().getString());
} else {
operation.setMethod(new URI(method.asResource().getURI()));
}
}

// ProducesContentTypes
Expand Down
5 changes: 3 additions & 2 deletions msm4j-io/src/test/resources/twitter.n3
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@
@prefix sioc: <http://rdfs.org/sioc/ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix msm-wsdl: <http://iserve.kmi.open.ac.uk/ns/msm-wsdl#> .
@prefix cc: <http://creativecommons.org/ns#> .

<http://twitter> a msm:Service ;
rdfs:comment "The Twitter micro-blogging service includes two RESTful APIs. The Twitter REST API methods allow developers to access core Twitter data. This includes update timelines, status data, and user information. The Search API methods give developers methods to interact with Twitter Search and trends data. The API presently supports the following data formats: XML, JSON, and the RSS and Atom syndication formats, with some methods only accepting a subset of these formats." ;
rdfs:seeAlso <http://www.programmableweb.com/api/twitter> ;
dcterms:created "2014-07-04"^^<http://www.w3.org/2001/XMLSchema#date> ;
sawsdl:modelReference schema:UpdateAction , schema:InformAction , schema:WriteAction , schema:FollowAction , schema:ReadAction , schema:ReactAction , schema:BefriendAction .
sawsdl:modelReference schema:UpdateAction , schema:InformAction , schema:WriteAction , schema:FollowAction , schema:ReadAction , schema:ReactAction , schema:BefriendAction ;
<http://iserve.kmi.open.ac.uk/ns/msm-swagger#isGroundedIn>
"$[?(@.resourcePath == '/13995621040863b7ca393ebef47d5b026166bde6da559/streams/service_info')].apis.operations.[?(@.nickname == 'clearService_info')]"^^<http://iserve.kmi.open.ac.uk/ns/msm-swagger#JSONPath> ;
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014. Knowledge Media Institute - The Open University
* Copyright (c) 2015. Knowledge Media Institute - The Open University
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -25,10 +25,14 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import uk.ac.open.kmi.msm4j.Service;
import uk.ac.open.kmi.msm4j.io.ServiceReader;
import uk.ac.open.kmi.msm4j.io.ServiceWriter;
import uk.ac.open.kmi.msm4j.io.Syntax;
import uk.ac.open.kmi.msm4j.io.TransformationException;
import uk.ac.open.kmi.msm4j.io.impl.ServiceTransformationEngine;
import uk.ac.open.kmi.msm4j.io.impl.TransformerModule;

import java.io.*;
import java.util.Collection;
import java.util.List;

Expand Down Expand Up @@ -68,6 +72,40 @@ public void testTransformRemoteDescription() {
Assert.assertTrue("There should be one service", 1 == services.size());
}

@Test
public void testTransformReadAndWrite(ServiceReader reader, ServiceWriter writer) {
Collection<Service> services = null;
try {
services = importer.transform(null, API_DOCS_URL + "/iserve/");
} catch (TransformationException e) {
e.printStackTrace();
}

Assert.assertNotNull("Service collection should not be null", services);
Assert.assertTrue("There should be one service", 1 == services.size());

try {
for (Service service : services) {
File ontoFile = new File("temp.n3");
FileOutputStream fos = new FileOutputStream(ontoFile);
writer.serialise(service, fos, Syntax.N3);
fos.flush();
fos.close();

List<Service> parsedServices = reader.parse(new FileInputStream(ontoFile), "http://test", Syntax.N3);
Assert.assertNotNull(parsedServices.get(0));

ontoFile.delete();
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}


}

@Test
public void testPluginBasedTransformation(ServiceTransformationEngine serviceTransformationEngine) {
try {
Expand Down

0 comments on commit 25b62d3

Please sign in to comment.