Skip to content
This repository has been archived by the owner on Oct 11, 2024. It is now read-only.

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
* dev:
  updated version to 0.1.1
  fix form parser for only one input
  • Loading branch information
autermann committed Jul 2, 2014
2 parents af07d00 + c0d4b10 commit ba3f919
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 27 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<name>52North WPS JavaScript Client</name>

<!-- http://semver.org/ -->
<version>0.1.0</version>
<version>0.1.1</version>

<url>https://wiki.52north.org/bin/view/Processing/Wps-js/</url>
<inceptionYear>2013</inceptionYear>
Expand Down
54 changes: 28 additions & 26 deletions src/main/webapp/js/wps-js/form/FormParser.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@

var FormParser = Class.extend({

init : function(settings) {
this.settings = settings;
},

parseInputs : function(formValues) {
var inputs = [];
var inputNameToPosition = {};

for (var i = 0; i < formValues.length; i++) {
var prop = formValues[i];
if (stringStartsWith(prop.name, "input_")) {
Expand All @@ -22,19 +22,19 @@ var FormParser = Class.extend({
}
}
}

/*
* look for each input's type
*/
for (var i = 0; i < formValues.length; i++) {
var prop = formValues[i];
if (stringStartsWith(prop.name, "type_input")) {
var originalInputName = prop.name.substring(5, prop.name.length);

// check if input is set before setting the type
if(inputNameToPosition[originalInputName] != null) {
inputs[inputNameToPosition[originalInputName]].type = prop.value;

if (stringStartsWith(prop.value, "complex")) {
inputs[inputNameToPosition[originalInputName]].complexPayload = inputs[inputNameToPosition[originalInputName]].value;
}
Expand All @@ -44,7 +44,7 @@ var FormParser = Class.extend({
}
}
}

/*
* check asReference flag
*/
Expand All @@ -58,22 +58,24 @@ var FormParser = Class.extend({
inputs[inputNameToPosition[originalInputName]].asReference = true;
}
}

/*
* look for each input's format
*/
for (var i = 0; i < formValues.length; i++) {
var prop = formValues[i];
if (stringStartsWith(prop.name, "format_input")) {
var originalInputName = prop.name.substring(7, prop.name.length);
var formatObject = JSON.parse(prop.value);
this.parseFormatObject(formatObject, inputs[inputNameToPosition[originalInputName]]);
if (inputNameToPosition[originalInputName] != null) {
var formatObject = JSON.parse(prop.value);
this.parseFormatObject(formatObject, inputs[inputNameToPosition[originalInputName]]);
}
}
}

return inputs;
},

parseBboxValue : function(bboxString, targetObject) {
var array = bboxString.split(",");

Expand All @@ -86,15 +88,15 @@ var FormParser = Class.extend({
array[i] = "0.0";
}
}

targetObject.lowerCorner = jQuery.trim(array[0]) + " " + jQuery.trim(array[1]);
targetObject.upperCorner = jQuery.trim(array[2]) + " " + jQuery.trim(array[3]);
},

parseOutputs : function(formValues) {
var outputs = [];
var outputNameToPosition = {};

for (var i = 0; i < formValues.length; i++) {
var prop = formValues[i];
if (stringStartsWith(prop.name, "output_")) {
Expand All @@ -107,27 +109,27 @@ var FormParser = Class.extend({
outputNameToPosition[prop.name] = j;
}
}

/*
* look for each outputs type
*/
for (var i = 0; i < formValues.length; i++) {
var prop = formValues[i];
if (stringStartsWith(prop.name, "type_output")) {
var originalName = prop.name.substring(5, prop.name.length);

// only set output properties for selected outputs
if(outputNameToPosition[originalName] != null) {
outputs[outputNameToPosition[originalName]].type = prop.value;

//TODO: set via form
if (stringStartsWith(prop.value, "complex")) {
outputs[outputNameToPosition[originalName]].asReference = true;
}
}
}
}

/*
* look for each outputs format
*/
Expand All @@ -136,30 +138,30 @@ var FormParser = Class.extend({
if (stringStartsWith(prop.name, "format_output")) {
var originalName = prop.name.substring(7, prop.name.length);
var formatObject = JSON.parse(prop.value);

if(outputNameToPosition[originalName] != null) {
this.parseFormatObject(formatObject, outputs[outputNameToPosition[originalName]]);
}
}
}

return outputs;
},

parseFormatObject : function(formatObject, targetObject) {
if (formatObject.mimeType) {
targetObject.mimeType = formatObject.mimeType;
}

if (formatObject.schema) {
targetObject.schema = formatObject.schema;
}

if (formatObject.encoding) {
targetObject.encoding = formatObject.encoding;
}
},

parseProcessIdentifier : function(formValues) {
for (var i = 0; i < formValues.length; i++) {
var prop = formValues[i];
Expand All @@ -169,7 +171,7 @@ var FormParser = Class.extend({
}
return "";
},

parseOutputStyle : function(formValues) {
return {
storeExecuteResponse: true,
Expand Down

0 comments on commit ba3f919

Please sign in to comment.