diff --git a/src/fr/inrialpes/exmo/align/service/msg/AlignmentId.java b/src/fr/inrialpes/exmo/align/service/msg/AlignmentId.java index a86bd1efa7089a7cb71512366990e633488a4e00..d7be9ddf4004de1fe01874baaca0577749c6fc5c 100644 --- a/src/fr/inrialpes/exmo/align/service/msg/AlignmentId.java +++ b/src/fr/inrialpes/exmo/align/service/msg/AlignmentId.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) INRIA, 2006-2009, 2011, 2013 + * Copyright (C) INRIA, 2006-2009, 2011, 2013-2014 * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License @@ -54,5 +54,8 @@ public class AlignmentId extends Success { public String RESTString(){ return "<alid>"+getContent()+"</alid>"; } + public String JSONString(){ + return "{ \"type\" : \"AlignmentId\",\n \"content\" : \""+content+"\"\n}"; + } } diff --git a/src/fr/inrialpes/exmo/align/service/msg/AlignmentIds.java b/src/fr/inrialpes/exmo/align/service/msg/AlignmentIds.java index cdde5684b0282a0af19109cb64810215866f3df7..3b751e99a9b1ae74dd3ae93438a500f2e1d309f2 100644 --- a/src/fr/inrialpes/exmo/align/service/msg/AlignmentIds.java +++ b/src/fr/inrialpes/exmo/align/service/msg/AlignmentIds.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) INRIA, 2006-2009, 2011, 2013 + * Copyright (C) INRIA, 2006-2009, 2011, 2013-2014 * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License @@ -100,4 +100,17 @@ public class AlignmentIds extends Success { msg += " </alignmentList>"; return msg; } + + public String JSONString(){ + String msg = "{ \"type\" : \"AlignmentIds\",\n"; + msg += " \"alignmentIds\" : ["; + String id[] = content.split(" "); + for ( int i = id.length-1; i >= 0; i-- ){ + if ( id[i].trim() != "" ) { + msg += " \""+id[i].trim()+"\",\n"; + } + } + msg += " ]\n}\n"; + return msg; + } } diff --git a/src/fr/inrialpes/exmo/align/service/msg/AlignmentMetadata.java b/src/fr/inrialpes/exmo/align/service/msg/AlignmentMetadata.java index ffe9aae158367da39352ebfb5f6e2b2f11737a44..2f2441101c0c57278af3eb2cac68ea4969edc064 100644 --- a/src/fr/inrialpes/exmo/align/service/msg/AlignmentMetadata.java +++ b/src/fr/inrialpes/exmo/align/service/msg/AlignmentMetadata.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) INRIA, 2006-2009, 2011 + * Copyright (C) INRIA, 2006-2009, 2011, 2014 * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License @@ -41,4 +41,7 @@ public class AlignmentMetadata extends Success { public String SOAPString(){ return "<id>"+surrogate+"</id>"+"<in-reply-to>"+inReplyTo+"</in-reply-to><metadata>"+content+"</metadata>"; } + public String JSONString(){ + return "{ \"type\" : \"AlignmentMetadata\",\n \"id\" : \"+surrogate+\",\n \"in-reply-to\" : \"+inReplyTo+\",\n \"content\" : \""+content+"\"\n}"; + } } diff --git a/src/fr/inrialpes/exmo/align/service/msg/CannotRenderAlignment.java b/src/fr/inrialpes/exmo/align/service/msg/CannotRenderAlignment.java index 51783e035b0805a2f4354bec7cca3e7ac3782e24..68439c08593535b9b675da4f370405ae8affb1d7 100644 --- a/src/fr/inrialpes/exmo/align/service/msg/CannotRenderAlignment.java +++ b/src/fr/inrialpes/exmo/align/service/msg/CannotRenderAlignment.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) INRIA, 2006-2009, 2011 + * Copyright (C) INRIA, 2006-2009, 2011, 2014 * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License @@ -36,4 +36,7 @@ public class CannotRenderAlignment extends ErrorMsg { public String RESTString(){ return "<CannotRenderAlignment>"+content+"</CannotRenderAlignment>"; } + public String JSONString(){ + return "{ \"type\" : \"CannotRenderAlignment\",\n \"content\" : \""+getContent()+"\"\n}"; + } } diff --git a/src/fr/inrialpes/exmo/align/service/msg/EntityList.java b/src/fr/inrialpes/exmo/align/service/msg/EntityList.java index cc349b7d232b1c2c7467d25b81cb4504006543af..bf334567bfb7cf1cd7d50a55a2d5eb647b22a1e2 100644 --- a/src/fr/inrialpes/exmo/align/service/msg/EntityList.java +++ b/src/fr/inrialpes/exmo/align/service/msg/EntityList.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) INRIA, 2012 + * Copyright (C) INRIA, 2012, 2014 * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License @@ -63,4 +63,15 @@ public class EntityList extends Success { msg += " </entityList>"; return msg; } + public String JSONString(){ + String msg = "{ \"type\" : \"EntityList\",\n \"entities\" : \" [\n"; + String id[] = content.split(" "); + for ( int i = id.length-1; i >= 0; i-- ){ + if ( id[i].trim() != "" ) { + msg += " \""+id[i].trim()+"\",\n"; + } + } + msg += "]\n}"; + return msg; + } } diff --git a/src/fr/inrialpes/exmo/align/service/msg/ErrorMsg.java b/src/fr/inrialpes/exmo/align/service/msg/ErrorMsg.java index a7f35bde2820a99ffa80da5fb8de81148defdda4..cf9e5299471c3c03b86a15be970484cb43ada23b 100644 --- a/src/fr/inrialpes/exmo/align/service/msg/ErrorMsg.java +++ b/src/fr/inrialpes/exmo/align/service/msg/ErrorMsg.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) INRIA, 2006-2011 + * Copyright (C) INRIA, 2006-2011, 2014 * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License @@ -56,4 +56,7 @@ public class ErrorMsg extends Message { res += " "+RESTString()+"\n"+" </ErrorMsg>\n"; return res; } + public String JSONString(){ + return "{ \"type\" : \"ErrorMsg\",\n \"content\" : \""+content+"\"\n}"; + } } diff --git a/src/fr/inrialpes/exmo/align/service/msg/EvalResult.java b/src/fr/inrialpes/exmo/align/service/msg/EvalResult.java index bd4a16f5d966d223519217d1d2cd2dcbe4e772bf..88e87324c1a2d960f9b1b454fd37185012551d76 100644 --- a/src/fr/inrialpes/exmo/align/service/msg/EvalResult.java +++ b/src/fr/inrialpes/exmo/align/service/msg/EvalResult.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) INRIA, 2006-2011 + * Copyright (C) INRIA, 2006-2011, 2014 * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License @@ -52,5 +52,13 @@ public class EvalResult extends Success { results += "</EvaluationResults>"; return results; } + public String JSONString(){ + String results = "{ \"type\" : \"EvaluationResult\""; + for ( String key : getParameters().stringPropertyNames() ) { + results += ",\n \""+key+"\" : \""+getParameters().getProperty( key )+"\""; + } + results += "\n}"; + return results; + } } diff --git a/src/fr/inrialpes/exmo/align/service/msg/EvaluationId.java b/src/fr/inrialpes/exmo/align/service/msg/EvaluationId.java index f98ac6a9c57de6ba1b7ece2d77c25102e91a04a7..b867ce2c506a7feaebdaac141c8390f73f9a4bd6 100644 --- a/src/fr/inrialpes/exmo/align/service/msg/EvaluationId.java +++ b/src/fr/inrialpes/exmo/align/service/msg/EvaluationId.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) INRIA, 2008, 2011 + * Copyright (C) INRIA, 2008, 2011, 2014 * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License @@ -23,7 +23,7 @@ package fr.inrialpes.exmo.align.service.msg; import java.util.Properties; /** - * Contains the messages that should be sent according to the protocol + * The id of the result of an evaluation */ public class EvaluationId extends Success { @@ -45,5 +45,8 @@ public class EvaluationId extends Success { public String RESTString(){ return "<alid>"+content+"</alid>"; } + public String JSONString(){ + return "{ \"type\" : \"EvaluationId\",\n \"id\" : \""+content+"\"}"; + } } diff --git a/src/fr/inrialpes/exmo/align/service/msg/Message.java b/src/fr/inrialpes/exmo/align/service/msg/Message.java index 48ad2153ddc5d6920d2db6b5eae2e8c22f2ad931..ff3f8eac865111dcc005f82e6f5594eaeb7192da 100644 --- a/src/fr/inrialpes/exmo/align/service/msg/Message.java +++ b/src/fr/inrialpes/exmo/align/service/msg/Message.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) INRIA, 2006-2007, 2009, 2011 + * Copyright (C) INRIA, 2006-2007, 2009, 2011-2014 * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License @@ -52,6 +52,9 @@ public class Message { return "<ErrorMsg/>"; } + /** + * For HTML interface calling the REST interface + */ public String HTMLRESTString(){ return "<ErrorMsg/>"; } @@ -60,6 +63,10 @@ public class Message { return "<id>"+surrogate+"</id>"+"<sender>"+sender+"</sender>" + "<receiver>"+receiver+"</receiver>" + "<in-reply-to>" + inReplyTo+ "</in-reply-to>" + "<content>" + content + "</content>"; } + public String JSONString(){ + return "{ \"id\" : \""+surrogate+"\",\n \"sender\" : \""+sender+"\",\n \"receiver\" : \""+receiver+"\",\n \"in-reply-to\" : \"" + inReplyTo+ "\",\n \"content\" : \"" + content + "\"\n}"; + } + public int getId () { return surrogate; } diff --git a/src/fr/inrialpes/exmo/align/service/msg/NonConformParameters.java b/src/fr/inrialpes/exmo/align/service/msg/NonConformParameters.java index e0cf966555b77d5fa8fc7e3c826d098840a3f838..a2acc2b65f06b6d61cbb82e3bc2aa61223c11e44 100644 --- a/src/fr/inrialpes/exmo/align/service/msg/NonConformParameters.java +++ b/src/fr/inrialpes/exmo/align/service/msg/NonConformParameters.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) INRIA, 2006-2009, 2011 + * Copyright (C) INRIA, 2006-2009, 2011, 2014 * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License @@ -38,5 +38,8 @@ public class NonConformParameters extends ErrorMsg { public String RESTString(){ return "<NonConformParameters>" + content + "</NonConformParameters>"; } + public String JSONString(){ + return "{ \"type\" : \"NonConformParameters\",\n \"content\" : \""+content+"\"\n}"; + } } diff --git a/src/fr/inrialpes/exmo/align/service/msg/OntologyURI.java b/src/fr/inrialpes/exmo/align/service/msg/OntologyURI.java index 5b9f5e9b5b037657564e35f54021a373865d9f4b..24ddd0309682d51c5913f385127e587a8bb6a311 100644 --- a/src/fr/inrialpes/exmo/align/service/msg/OntologyURI.java +++ b/src/fr/inrialpes/exmo/align/service/msg/OntologyURI.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) INRIA, 2006-2009, 2011 + * Copyright (C) INRIA, 2006-2009, 2011, 2014 * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License @@ -37,5 +37,9 @@ public class OntologyURI extends Success { public String RESTString(){ return "<uri>"+content+"</uri>"; } - + public String JSONString(){ + String res = "{ \"type\" : \"OntologyURI\",\n"; + res += " \"uri\" : \""+content+"\"\n}\n"; + return res; + } } diff --git a/src/fr/inrialpes/exmo/align/service/msg/RenderedAlignment.java b/src/fr/inrialpes/exmo/align/service/msg/RenderedAlignment.java index 1a3ec99374a4732f0b203cf42e9b92c83cb936aa..3325ddab3185e2459699e2f20adda492b4d4d345 100644 --- a/src/fr/inrialpes/exmo/align/service/msg/RenderedAlignment.java +++ b/src/fr/inrialpes/exmo/align/service/msg/RenderedAlignment.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) INRIA, 2006, 2008-2009, 2011 + * Copyright (C) INRIA, 2006, 2008-2009, 2011, 2014 * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License @@ -31,7 +31,12 @@ public class RenderedAlignment extends Success { public RenderedAlignment ( int surr, Message rep, String from, String to, String cont, Properties param ) { super( surr, rep, from, to, cont, param ); } + // THIS CONTENT SHOULD BE ESCAPED: XMLSTRINGENCODDE? public String RESTString(){ return "<alignment>"+content+"</alignment>"; } + // THIS CONTENT SHOULD BE ESCAPED: STRINGENCODDE? + public String JSONString(){ + return "{ \"type\" : \"RenderedAlignment\",\n \"content\" : \""+content+"\"\n}"; + } } diff --git a/src/fr/inrialpes/exmo/align/service/msg/RunTimeError.java b/src/fr/inrialpes/exmo/align/service/msg/RunTimeError.java index 8c8a9ab0bbdc070a528b1f2e97ccab96ac03a51d..99203688c50130b500964cacc135f82169bb57dd 100644 --- a/src/fr/inrialpes/exmo/align/service/msg/RunTimeError.java +++ b/src/fr/inrialpes/exmo/align/service/msg/RunTimeError.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) INRIA, 2006-2009, 2011 + * Copyright (C) INRIA, 2006-2009, 2011, 2014 * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License @@ -36,4 +36,7 @@ public class RunTimeError extends ErrorMsg { public String HTMLString(){ return "Cannot process: "+content; } + public String JSONString(){ + return "{ \"type\" : \"RunTimeError\",\n \"content\" : \""+content+"\"\n}"; + } } diff --git a/src/fr/inrialpes/exmo/align/service/msg/Success.java b/src/fr/inrialpes/exmo/align/service/msg/Success.java index 16c468dbe97e3013835c7405638cfbf2182b9e87..620374f4ab8fbebe204b8f227e9cabc68a7c808b 100644 --- a/src/fr/inrialpes/exmo/align/service/msg/Success.java +++ b/src/fr/inrialpes/exmo/align/service/msg/Success.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) INRIA, 2006, 2008-2009, 2011 + * Copyright (C) INRIA, 2006, 2008-2009, 2011, 2014 * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License @@ -41,4 +41,11 @@ public class Success extends Message { res += " "+RESTString()+"\n"; return res; } + public String JSONString(){ + String res = "{ \"type\" : \"Success\",\n"; + res += " \"id\" : \""+surrogate+"\",\n"; + if ( inReplyTo != null ) res += " \"in-reply-to\" : \""+inReplyTo+"\",\n"; + res += " \"content\" : \""+content+"\"\n}\n"; + return res; + } } diff --git a/src/fr/inrialpes/exmo/align/service/msg/TranslatedMessage.java b/src/fr/inrialpes/exmo/align/service/msg/TranslatedMessage.java index 4a3db2cceb2c486c80862e291a1bbb59455af181..2404cb785647b3378239c3dcfe5804abbc0b1622 100644 --- a/src/fr/inrialpes/exmo/align/service/msg/TranslatedMessage.java +++ b/src/fr/inrialpes/exmo/align/service/msg/TranslatedMessage.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) INRIA, 2006-2009, 2011 + * Copyright (C) INRIA, 2006-2009, 2011, 2014 * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License @@ -37,4 +37,7 @@ public class TranslatedMessage extends Success { public String RESTString(){ return "<message>"+content+"</message>"; } + public String JSONString(){ + return "{ \"type\" : \"TranslatedMessage\",\n \"content\" : \""+content+"\"\n}"; + } } diff --git a/src/fr/inrialpes/exmo/align/service/msg/UnknownAlignment.java b/src/fr/inrialpes/exmo/align/service/msg/UnknownAlignment.java index 908db20315676328e993971696711d791052e135..4323ff24c2f31648ca6bd5b4191c60878c85ddfc 100644 --- a/src/fr/inrialpes/exmo/align/service/msg/UnknownAlignment.java +++ b/src/fr/inrialpes/exmo/align/service/msg/UnknownAlignment.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) INRIA, 2006-2009, 2011 + * Copyright (C) INRIA, 2006-2009, 2011, 2014 * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License @@ -36,4 +36,7 @@ public class UnknownAlignment extends ErrorMsg { public String HTMLString(){ return "Unknown alignment: "+content; } + public String JSONString(){ + return "{ \"type\" : \"UnknownAlignment\",\n \"content\" : \""+content+"\"\n}"; + } } diff --git a/src/fr/inrialpes/exmo/align/service/msg/UnknownMethod.java b/src/fr/inrialpes/exmo/align/service/msg/UnknownMethod.java index 431431dc37c75951d21a4405c650aee0f65fa551..823d1575d0d6a8fe02875f91279a07d4fc41bedf 100644 --- a/src/fr/inrialpes/exmo/align/service/msg/UnknownMethod.java +++ b/src/fr/inrialpes/exmo/align/service/msg/UnknownMethod.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) INRIA, 2006-2009, 2011 + * Copyright (C) INRIA, 2006-2009, 2011, 2014 * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License @@ -36,4 +36,7 @@ public class UnknownMethod extends ErrorMsg { public String RESTString() { return "<UnknownMethod>"+content+"</UnknownMethod>"; } + public String JSONString(){ + return "{ \"type\" : \"UnknownMethod\",\n \"content\" : \""+getContent()+"\"\n}"; + } } diff --git a/src/fr/inrialpes/exmo/align/service/msg/UnreachableAlignment.java b/src/fr/inrialpes/exmo/align/service/msg/UnreachableAlignment.java index d43cdb529feefd7f043c899accbde1dee0993f5d..8080950eaaf99b115493c90b2753db23b6ab59cb 100644 --- a/src/fr/inrialpes/exmo/align/service/msg/UnreachableAlignment.java +++ b/src/fr/inrialpes/exmo/align/service/msg/UnreachableAlignment.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) INRIA, 2006-2009, 2011 + * Copyright (C) INRIA, 2006-2009, 2011, 2014 * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License @@ -36,4 +36,7 @@ public class UnreachableAlignment extends ErrorMsg { public String HTMLString() { return "Unreachable alignment: "+content; } + public String JSONString(){ + return "{ \"type\" : \"UnreachableAlignment\",\n \"content\" : \""+content+"\"\n}"; + } } diff --git a/src/fr/inrialpes/exmo/align/service/msg/UnreachableOntology.java b/src/fr/inrialpes/exmo/align/service/msg/UnreachableOntology.java index bbf1b7505186e8500938a7a1c0491b88cf9db94b..2230ebba746c185d2f23185c246db37cd56fe2c5 100644 --- a/src/fr/inrialpes/exmo/align/service/msg/UnreachableOntology.java +++ b/src/fr/inrialpes/exmo/align/service/msg/UnreachableOntology.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) INRIA, 2006-2009, 2011 + * Copyright (C) INRIA, 2006-2009, 2011, 2014 * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License @@ -36,4 +36,7 @@ public class UnreachableOntology extends ErrorMsg { public String HTMLString() { return "Unreachable ontology: "+content; } + public String JSONString(){ + return "{ \"type\" : \"UnreachableOntology\",\n \"content\" : \""+content+"\"\n}"; + } }