Added params functionalities to multipleXml, bugfix
This commit is contained in:
@@ -68,7 +68,7 @@ public class MultipleXMLController implements RestController {
|
|||||||
private XMLResponseBody processData(MultipleXmlJob xmlJob) throws Exception {
|
private XMLResponseBody processData(MultipleXmlJob xmlJob) throws Exception {
|
||||||
XmlEngine engine = xmlJob.getEngine();
|
XmlEngine engine = xmlJob.getEngine();
|
||||||
XMLMultipleFilesBody requestBody = xmlJob.getRequestBody();
|
XMLMultipleFilesBody requestBody = xmlJob.getRequestBody();
|
||||||
String result = engine.processXSLT(requestBody.getData(), requestBody.getProcessorData());
|
String result = engine.processXSLT(requestBody.getParams(), requestBody.getData(), requestBody.getProcessorData());
|
||||||
return new XMLResponseBody(result, "OK", requestBody.getVersion());
|
return new XMLResponseBody(result, "OK", requestBody.getVersion());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package com.r11.tools.model;
|
||||||
|
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
|
||||||
|
|
||||||
|
public class Param {
|
||||||
|
@SerializedName("key")
|
||||||
|
private String key;
|
||||||
|
@SerializedName("value")
|
||||||
|
private String value;
|
||||||
|
|
||||||
|
public String getKey() {
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -2,6 +2,8 @@ package com.r11.tools.model;
|
|||||||
|
|
||||||
import com.google.gson.annotations.SerializedName;
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class XMLMultipleFilesBody {
|
public class XMLMultipleFilesBody {
|
||||||
|
|
||||||
@SerializedName("data")
|
@SerializedName("data")
|
||||||
@@ -12,6 +14,8 @@ public class XMLMultipleFilesBody {
|
|||||||
private String processor;
|
private String processor;
|
||||||
@SerializedName("version")
|
@SerializedName("version")
|
||||||
private String version;
|
private String version;
|
||||||
|
@SerializedName("params")
|
||||||
|
private List<Param> params;
|
||||||
|
|
||||||
|
|
||||||
public String getProcessorData() {
|
public String getProcessorData() {
|
||||||
@@ -29,4 +33,9 @@ public class XMLMultipleFilesBody {
|
|||||||
public XMLMultipleFilesData[] getData() {
|
public XMLMultipleFilesData[] getData() {
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Param> getParams() {
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.r11.tools.xml;
|
package com.r11.tools.xml;
|
||||||
|
|
||||||
|
import com.r11.tools.model.Param;
|
||||||
import com.r11.tools.model.XMLMultipleFilesData;
|
import com.r11.tools.model.XMLMultipleFilesData;
|
||||||
import com.r11.tools.model.XMLRequestBody;
|
import com.r11.tools.model.XMLRequestBody;
|
||||||
import com.r11.tools.model.XPathQueryResult;
|
import com.r11.tools.model.XPathQueryResult;
|
||||||
@@ -30,11 +31,11 @@ public class Saxon implements XmlEngine{
|
|||||||
* @throws IOException thrown when file does not exist, or cannot be read.
|
* @throws IOException thrown when file does not exist, or cannot be read.
|
||||||
*/
|
*/
|
||||||
XmlTools tools = new XmlTools();
|
XmlTools tools = new XmlTools();
|
||||||
public String processXSLT(XMLMultipleFilesData[] data, String transform) throws SaxonApiException, IOException{
|
public String processXSLT(List<Param> params, XMLMultipleFilesData[] data, String transform) throws SaxonApiException, IOException{
|
||||||
Processor processor = new Processor(false);
|
Processor processor = new Processor(false);
|
||||||
XsltCompiler compiler = processor.newXsltCompiler();
|
XsltCompiler compiler = processor.newXsltCompiler();
|
||||||
|
|
||||||
// transform = tools.addParams(params,transform);
|
transform = tools.addParams(params,transform);
|
||||||
|
|
||||||
String filesPath = "/tmp/"+UUID.randomUUID()+"/";
|
String filesPath = "/tmp/"+UUID.randomUUID()+"/";
|
||||||
try{
|
try{
|
||||||
@@ -91,7 +92,7 @@ public class Saxon implements XmlEngine{
|
|||||||
* @return transformed xml
|
* @return transformed xml
|
||||||
* @throws SaxonApiException thrown on stylesheet or transformation errors
|
* @throws SaxonApiException thrown on stylesheet or transformation errors
|
||||||
*/
|
*/
|
||||||
public String processXSLT(List<XMLRequestBody.Param> params, String data, String transform) throws SaxonApiException {
|
public String processXSLT(List<Param> params, String data, String transform) throws SaxonApiException {
|
||||||
Processor processor = new Processor(false);
|
Processor processor = new Processor(false);
|
||||||
XsltCompiler compiler = processor.newXsltCompiler();
|
XsltCompiler compiler = processor.newXsltCompiler();
|
||||||
transform = tools.addParams(params,transform);
|
transform = tools.addParams(params,transform);
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.r11.tools.xml;
|
package com.r11.tools.xml;
|
||||||
|
|
||||||
|
import com.r11.tools.model.Param;
|
||||||
import com.r11.tools.model.XMLMultipleFilesData;
|
import com.r11.tools.model.XMLMultipleFilesData;
|
||||||
import com.r11.tools.model.XMLRequestBody;
|
import com.r11.tools.model.XMLRequestBody;
|
||||||
import com.r11.tools.model.XPathQueryResult;
|
import com.r11.tools.model.XPathQueryResult;
|
||||||
@@ -41,7 +42,7 @@ public class Xalan implements XmlEngine{
|
|||||||
* @return transformed xml
|
* @return transformed xml
|
||||||
* @throws Exception thrown on stylesheet or transformation errors
|
* @throws Exception thrown on stylesheet or transformation errors
|
||||||
*/
|
*/
|
||||||
public String processXSLT(List<XMLRequestBody.Param> params, String data, String transform) throws Exception {
|
public String processXSLT(List<Param> params, String data, String transform) throws Exception {
|
||||||
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||||
DocumentBuilder builder = factory.newDocumentBuilder();
|
DocumentBuilder builder = factory.newDocumentBuilder();
|
||||||
Document document = builder.parse(new InputSource(new StringReader(data)));
|
Document document = builder.parse(new InputSource(new StringReader(data)));
|
||||||
@@ -69,7 +70,7 @@ public class Xalan implements XmlEngine{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String processXSLT(XMLMultipleFilesData[] data, String transform) throws Exception {
|
public String processXSLT(List<Param> params, XMLMultipleFilesData[] data, String transform) throws Exception {
|
||||||
throw new UnsupportedOperationException("Xalan does not support multiple files XSLT processing");
|
throw new UnsupportedOperationException("Xalan does not support multiple files XSLT processing");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
package com.r11.tools.xml;
|
package com.r11.tools.xml;
|
||||||
|
|
||||||
|
import com.r11.tools.model.Param;
|
||||||
import com.r11.tools.model.XMLMultipleFilesData;
|
import com.r11.tools.model.XMLMultipleFilesData;
|
||||||
import com.r11.tools.model.XMLRequestBody;
|
|
||||||
import com.r11.tools.model.XPathQueryResult;
|
import com.r11.tools.model.XPathQueryResult;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public interface XmlEngine {
|
public interface XmlEngine {
|
||||||
|
|
||||||
String processXSLT(XMLMultipleFilesData[] data, String transform) throws Exception;
|
String processXSLT(List<Param> params, XMLMultipleFilesData[] data, String transform) throws Exception;
|
||||||
XPathQueryResult processXPath(String data, String query, String version) throws Exception;
|
XPathQueryResult processXPath(String data, String query, String version) throws Exception;
|
||||||
String processXSLT(List<XMLRequestBody.Param> params, String data, String transform) throws Exception;
|
String processXSLT(List<Param> params, String data, String transform) throws Exception;
|
||||||
String validate(String data, String xsd) throws Exception;
|
String validate(String data, String xsd) throws Exception;
|
||||||
String executeXQuery(String data, String xquery, String version) throws Exception;
|
String executeXQuery(String data, String xquery, String version) throws Exception;
|
||||||
public String getVersion();
|
public String getVersion();
|
||||||
|
|||||||
@@ -23,7 +23,11 @@ const selectedOption = ref(options.value[0].name)
|
|||||||
|
|
||||||
const selectedFunction = () => {
|
const selectedFunction = () => {
|
||||||
if (selectOption(selectedOption.value) === 'Add Param') {
|
if (selectOption(selectedOption.value) === 'Add Param') {
|
||||||
options.value.push({name: nameInput.value + " = " + valueInput.value});
|
if(!valueInput.value.length == 0 && !nameInput.value.length == 0){
|
||||||
|
options.value.push({name: nameInput.value + " = " + valueInput.value});
|
||||||
|
valueInput.value = "";
|
||||||
|
nameInput.value = "";
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if (selectOption(selectedOption.value) === 'Remove Param') {
|
if (selectOption(selectedOption.value) === 'Remove Param') {
|
||||||
@@ -106,6 +110,22 @@ function selectOption(option: string): string {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
<input
|
||||||
|
v-if="selectedOption==='Add Param'"
|
||||||
|
id="NameTextInput"
|
||||||
|
v-model="nameInput"
|
||||||
|
class="text-input h-full px-3 rounded-full border border-slate-400 bg-white dark:text-slate-100 dark:bg-gray-600 w-48"
|
||||||
|
type="text"
|
||||||
|
placeholder="Name"
|
||||||
|
/>
|
||||||
|
<input
|
||||||
|
v-if="selectedOption==='Add Param'"
|
||||||
|
id="ValueTextInput"
|
||||||
|
v-model="valueInput"
|
||||||
|
class="text-input h-full px-3 rounded-full border border-slate-400 bg-white dark:text-slate-100 dark:bg-gray-600 w-48"
|
||||||
|
type="text"
|
||||||
|
placeholder="Value"
|
||||||
|
/>
|
||||||
<select
|
<select
|
||||||
v-model="selectedOption"
|
v-model="selectedOption"
|
||||||
class="flex h-full px-3 rounded-full border border-slate-400 bg-white dark:text-slate-100 dark:bg-gray-600 w-48"
|
class="flex h-full px-3 rounded-full border border-slate-400 bg-white dark:text-slate-100 dark:bg-gray-600 w-48"
|
||||||
@@ -114,22 +134,7 @@ function selectOption(option: string): string {
|
|||||||
{{ option.name }}
|
{{ option.name }}
|
||||||
</option>
|
</option>
|
||||||
</select>
|
</select>
|
||||||
<input
|
<button class="tool-button w-24" @click="selectedFunction">{{ selectOption(selectedOption) }}</button>
|
||||||
v-if="selectedOption==='Add Param'"
|
|
||||||
id="NameTextInput"
|
|
||||||
v-model="nameInput"
|
|
||||||
class="text-input h-full px-3 rounded-full border border-slate-400 bg-white dark:text-slate-100 dark:bg-gray-600 w-1/3"
|
|
||||||
type="text"
|
|
||||||
placeholder="Name"
|
|
||||||
/>
|
|
||||||
<input
|
|
||||||
v-if="selectedOption==='Add Param'"
|
|
||||||
id="ValueTextInput"
|
|
||||||
v-model="valueInput"
|
|
||||||
class="text-input h-full px-3 rounded-full border border-slate-400 bg-white dark:text-slate-100 dark:bg-gray-600 w-1/3"
|
|
||||||
type="text"
|
|
||||||
placeholder="Value"
|
|
||||||
/>
|
|
||||||
<button class="tool-button" @click="selectedFunction">{{ selectOption(selectedOption) }}</button>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|||||||
@@ -149,12 +149,15 @@ function prepareRequestBodySingleXml(data: string):string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function prepareRequestBodyMultiXml():string {
|
function prepareRequestBodyMultiXml():string {
|
||||||
if (!Array.isArray(props.xml))
|
const formattedParams = formatParams();
|
||||||
|
|
||||||
|
if (!Array.isArray(props.xml))
|
||||||
return "";
|
return "";
|
||||||
|
|
||||||
let xmlFilesArray = convertDataArray(props.xml);
|
let xmlFilesArray = convertDataArray(props.xml);
|
||||||
|
|
||||||
let requestBody = JSON.stringify({
|
let requestBody = JSON.stringify({
|
||||||
|
"params": formattedParams,
|
||||||
"data": xmlFilesArray,
|
"data": xmlFilesArray,
|
||||||
"processorData": props.query,
|
"processorData": props.query,
|
||||||
"processor": engine.value,
|
"processor": engine.value,
|
||||||
|
|||||||
Reference in New Issue
Block a user