dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #39589
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 20042: Introduced an ExpressionController with a method for validation and getting textual description o...
------------------------------------------------------------
revno: 20042
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2015-09-08 17:56:00 +0200
message:
Introduced an ExpressionController with a method for validation and getting textual description of expressions. Using the api resource in data dictionary/indicator and validation rule modules.
removed:
dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetExpressionTextAction.java
dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/javascript/expression.js
added:
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/ExpressionController.java
modified:
dhis-2/dhis-services/dhis-service-core/src/main/resources/i18n_global.properties
dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-web/dhis-web-commons/src/main/resources/dhis-web-commons.xml
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/expressionBuilder.js
dhis-2/dhis-web/dhis-web-validationrule/src/main/resources/struts.xml
dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/javascript/expressionBuilder.js
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/i18n_global.properties'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/i18n_global.properties 2015-09-08 15:03:31 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/i18n_global.properties 2015-09-08 15:56:00 +0000
@@ -755,6 +755,7 @@
org_unit_group_does_not_exist=Organisation unit group does not exist
id_not_numeric=Identifier is not numeric
expression_not_well_formed=Expression is not well-formed
+valid=Valid
#-- Validation Rule -----------------------------------------------------------#
=== added file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/ExpressionController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/ExpressionController.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/ExpressionController.java 2015-09-08 15:56:00 +0000
@@ -0,0 +1,83 @@
+package org.hisp.dhis.webapi.controller;
+
+/*
+ * Copyright (c) 2004-2015, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import java.io.IOException;
+
+import javax.servlet.http.HttpServletResponse;
+
+import org.hisp.dhis.dxf2.webmessage.DescriptiveWebMessage;
+import org.hisp.dhis.dxf2.webmessage.WebMessageStatus;
+import org.hisp.dhis.expression.ExpressionService;
+import org.hisp.dhis.i18n.I18n;
+import org.hisp.dhis.i18n.I18nManager;
+import org.hisp.dhis.webapi.service.WebMessageService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.MediaType;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+
+/**
+ * @author Lars Helge Overland
+ */
+@Controller
+@RequestMapping( value = "/expressions" )
+public class ExpressionController
+{
+ @Autowired
+ protected WebMessageService webMessageService;
+
+ @Autowired
+ private ExpressionService expressionService;
+
+ @Autowired
+ private I18nManager i18nManager;
+
+ @RequestMapping( value = "/description", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE )
+ public void getExpressionDescription( @RequestParam String expression, HttpServletResponse response )
+ throws IOException
+ {
+ I18n i18n = i18nManager.getI18n();
+
+ String result = expressionService.expressionIsValid( expression );
+
+ DescriptiveWebMessage message = new DescriptiveWebMessage();
+ message.setStatus( ExpressionService.VALID.equals( result ) ? WebMessageStatus.OK : WebMessageStatus.ERROR );
+ message.setMessage( i18n.getString( result ) );
+
+ if ( result.equals( ExpressionService.VALID ) )
+ {
+ message.setDescription( expressionService.getExpressionDescription( expression ) );
+ }
+
+ webMessageService.sendJson( message, response );
+ }
+}
=== removed file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetExpressionTextAction.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetExpressionTextAction.java 2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetExpressionTextAction.java 1970-01-01 00:00:00 +0000
@@ -1,103 +0,0 @@
-package org.hisp.dhis.commons.action;
-
-/*
- * Copyright (c) 2004-2015, University of Oslo
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * Neither the name of the HISP project nor the names of its contributors may
- * be used to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-import org.hisp.dhis.expression.ExpressionService;
-import org.hisp.dhis.i18n.I18n;
-
-import com.opensymphony.xwork2.Action;
-
-public class GetExpressionTextAction
- implements Action
-{
- // -------------------------------------------------------------------------
- // Dependencies
- // -------------------------------------------------------------------------
-
- private ExpressionService expressionService;
-
- public void setExpressionService( ExpressionService expressionService )
- {
- this.expressionService = expressionService;
- }
-
- private I18n i18n;
-
- public void setI18n( I18n i18n )
- {
- this.i18n = i18n;
- }
-
- // -------------------------------------------------------------------------
- // Input
- // -------------------------------------------------------------------------
-
- private String expression;
-
- public void setExpression( String expression )
- {
- this.expression = expression;
- }
-
- // -------------------------------------------------------------------------
- // Output
- // -------------------------------------------------------------------------
-
- private String message;
-
- public String getMessage()
- {
- return message;
- }
-
- // -------------------------------------------------------------------------
- // Action implementation
- // -------------------------------------------------------------------------
-
- @Override
- public String execute()
- throws Exception
- {
- String result = expressionService.expressionIsValid( expression );
-
- if ( result.equals( ExpressionService.VALID ) )
- {
- message = expressionService.getExpressionDescription( expression );
-
- return SUCCESS;
- }
- else
- {
- message = i18n.getString( result );
-
- return ERROR;
- }
-
- }
-}
=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml 2015-06-21 04:35:23 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml 2015-09-08 15:56:00 +0000
@@ -412,11 +412,6 @@
<property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService" />
</bean>
- <bean id="org.hisp.dhis.commons.action.GetExpressionTextAction" class="org.hisp.dhis.commons.action.GetExpressionTextAction"
- scope="prototype">
- <property name="expressionService" ref="org.hisp.dhis.expression.ExpressionService" />
- </bean>
-
<bean id="org.hisp.dhis.commons.action.GetIndicatorAction" class="org.hisp.dhis.commons.action.GetIndicatorAction"
scope="prototype">
<property name="indicatorService" ref="org.hisp.dhis.indicator.IndicatorService" />
=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/resources/dhis-web-commons.xml'
--- dhis-2/dhis-web/dhis-web-commons/src/main/resources/dhis-web-commons.xml 2015-05-05 04:23:07 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/resources/dhis-web-commons.xml 2015-09-08 15:56:00 +0000
@@ -853,16 +853,6 @@
<param name="onExceptionReturn">plainTextError</param>
</action>
- <action name="getExpressionText" class="org.hisp.dhis.commons.action.GetExpressionTextAction">
- <result name="success" type="velocity-json">
- /dhis-web-commons/ajax/jsonResponseSuccess.vm
- </result>
- <result name="error" type="velocity-json">
- /dhis-web-commons/ajax/jsonResponseError.vm
- </result>
- <param name="onExceptionReturn">plainTextError</param>
- </action>
-
</package>
<!-- Stream -->
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/expressionBuilder.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/expressionBuilder.js 2014-07-25 06:49:27 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/expressionBuilder.js 2015-09-08 15:56:00 +0000
@@ -79,18 +79,21 @@
function getExpressionText()
{
if ( hasText('expression') ){
- jQuery.postJSON( '../dhis-web-commons-ajax-json/getExpressionText.action', {
- expression: getFieldValue('expression')
- }, function( json ) {
- if( json.response == 'success' || json.response == 'error' )
- {
- jQuery( "#formulaText").html( json.message );
- }
- else {
- jQuery( "#formulaText").html( '' );
+ jQuery.ajax({
+ url: '../api/expressions/description',
+ data: {
+ expression: getFieldValue('expression')
+ },
+ success: function( json, status, xhr ) {
+ if ( 'OK' == json.status ) {
+ jQuery( "#formulaText").html( json.description );
+ }
+ else {
+ jQuery( "#formulaText").html( json.message );
+ }
}
});
- }
+ }
else {
jQuery( "#formulaText").html( '' );
}
@@ -118,16 +121,21 @@
var expression = getFieldValue( 'indicator-expression-container textarea[id=expression]' );
var description = getFieldValue( 'indicator-expression-container input[id=description]' );
- jQuery.postJSON( '../dhis-web-commons-ajax-json/getExpressionText.action',
- {expression: expression},
- function( json ) {
- if ( json.response == 'error') markInvalid( 'indicator-expression-container textarea[id=expression]', json.message );
+ jQuery.ajax({
+ url: '../api/expressions/description',
+ data: {
+ expression: getFieldValue('expression')
+ },
+ success: function( json, status, xhr ) {
+ if ( json.status == 'ERROR') {
+ markInvalid( 'indicator-expression-container textarea[id=expression]', json.message );
+ }
else {
if ( numerator ){
setFieldValue( 'numerator', expression );
setFieldValue( 'numeratorDescription', description );
}
- else{
+ else {
setFieldValue( 'denominator', expression );
setFieldValue( 'denominatorDescription', description );
}
@@ -135,5 +143,5 @@
closeExpressionBuilder();
}
}
- );
-}
\ No newline at end of file
+ });
+}
=== modified file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-validationrule/src/main/resources/struts.xml 2014-10-13 16:03:06 +0000
+++ dhis-2/dhis-web/dhis-web-validationrule/src/main/resources/struts.xml 2015-09-08 15:56:00 +0000
@@ -32,9 +32,8 @@
<result name="success" type="velocity">/main.vm</result>
<param name="page">/dhis-web-validationrule/addValidationRuleForm.vm</param>
<param name="menu">/dhis-web-validationrule/menu.vm</param>
- <param name="javascripts">javascript/general.js,javascript/expression.js,
- javascript/expressionBuilder.js,javascript/validationRule.js,javascript/addValidationRuleForm.js
- </param>
+ <param name="javascripts">javascript/general.js,javascript/expressionBuilder.js,
+ javascript/validationRule.js,javascript/addValidationRuleForm.js</param>
<param name="requiredAuthorities">F_VALIDATIONRULE_ADD</param>
</action>
@@ -63,9 +62,8 @@
<action name="showUpdateValidationRuleForm" class="org.hisp.dhis.validationrule.action.ShowUpdateValidationRuleFormAction">
<result name="success" type="velocity">/main.vm</result>
<param name="page">/dhis-web-validationrule/updateValidationRuleForm.vm</param>
- <param name="javascripts">javascript/general.js,javascript/expression.js,
- javascript/expressionBuilder.js,javascript/validationRule.js,javascript/updateValidationRuleForm.js
- </param>
+ <param name="javascripts">javascript/general.js,javascript/expressionBuilder.js,
+ javascript/validationRule.js,javascript/updateValidationRuleForm.js</param>
<param name="requiredAuthorities">F_VALIDATIONRULE_ADD</param>
</action>
=== removed file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/javascript/expression.js'
--- dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/javascript/expression.js 2014-08-28 12:01:44 +0000
+++ dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/javascript/expression.js 1970-01-01 00:00:00 +0000
@@ -1,164 +0,0 @@
-function showEditLeftSideExpressionForm()
-{
- var description = $( "#leftSideDescription" ).val();
- var expression = $( "#leftSideExpression" ).val();
- var textualExpression = $( "#leftSideTextualExpression" ).val();
- var periodTypeName = $( "#periodTypeName" ).val();
-
- showExpressionForm( "left", description, expression, textualExpression, periodTypeName );
-}
-
-function showEditRightSideExpressionForm()
-{
- var description = $( "#rightSideDescription" ).val();
- var expression = $( "#rightSideExpression" ).val();
- var textualExpression = $( "#rightSideTextualExpression" ).val();
- var periodTypeName = $( "#periodTypeName" ).val();
-
- showExpressionForm( "right", description, expression, textualExpression, periodTypeName );
-}
-
-function showExpressionForm( side, description, expression, textualExpression, periodTypeName )
-{
- $.post( "showEditExpressionForm.action", {
- side : side,
- description : description,
- expression : expression,
- textualExpression : textualExpression,
- periodTypeName : periodTypeName
- }, function( data )
- {
- $( "#dynamicContent" ).html( data );
- showPopupWindowById( 'dynamicContent', 755, 450 );
- }, 'html' );
-}
-
-function insertText( inputAreaName, inputText )
-{
- insertTextCommon( inputAreaName, inputText );
-
- updateTextualExpression( inputAreaName );
-}
-
-function filterDataElements( dataSetName, filterName )
-{
- var dataSet = $( "#" + dataSetName ).val();
- var dataSetId = dataSet.options[dataSet.selectedIndex].value;
- var filter = $( "#" + filterName ).val();
- var periodTypeName = getFieldValue( 'periodTypeName' );
-
- var url = "getFilteredDataElements.action";
-
- $.getJSON( url, {
- "dataSetId" : dataSetId,
- "periodTypeName" : periodTypeName,
- "filter" : filter
- }, function( json )
- {
- clearListById( "dataElementId" );
-
- var objects = json.operands;
-
- for ( var i = 0; i < objects.length; i++ )
- {
- addOptionById( "dataElementId", "[" + objects[i].operandId + "]", objects[i].operandName );
- }
- } );
-}
-
-function updateTextualExpression( expressionFieldName )
-{
- var expression = $( "#" + expressionFieldName ).val();
-
- jQuery.postJSON( '../dhis-web-commons-ajax-json/getExpressionText.action', {
- expression : expression
- }, function( json )
- {
- $( "#textualExpression" ).html( json.message );
- } );
-}
-
-function checkNotEmpty( field, message )
-{
- if ( field.value.length == 0 )
- {
- setInnerHTML( field.name + "Info", message );
- $( '#' + field.name ).css( "background-color", "#ffc5c5" );
- return false;
- } else
- {
- setInnerHTML( field.name + "Info", '' );
- $( '#' + field.name ).css( "background-color", "#ffffff" );
- }
-
- return true;
-}
-
-function validateExpression()
-{
- var description = byId( "expDescription" ).value;
- var expression = byId( "expression" ).value;
-
- if ( checkNotEmpty( byId( "expDescription" ), i18n_description_not_null ) == false )
- return;
- if ( checkNotEmpty( byId( "expression" ), i18n_expression_not_null ) == false )
- return;
-
- jQuery.postJSON( '../dhis-web-commons-ajax-json/getExpressionText.action', {
- expression : expression
- }, function( json )
- {
- byId( "textualExpression" ).innerHTML = json.message;
- if ( json.response == 'error' )
- {
- $( '#expression' ).css( "background-color", "#ffc5c5" );
- return;
- }
- var description = byId( "expDescription" ).value;
- var expression = byId( "expression" ).value;
- var textualDescription = byId( "textualExpression" ).innerHTML;
- var side = byId( "side" ).value;
- saveExpression( side, description, expression, textualDescription );
- disable( 'periodTypeName' );
- return true;
- } );
-}
-
-function saveExpression( side, description, expression, textualDescription )
-{
- if ( side == "left" )
- {
- $( "#leftSideDescription" ).val( description );
- $( "#leftSideExpression" ).val( expression );
- $( "#leftSideTextualExpression" ).val( textualDescription );
- }
- else if ( side == "right" )
- {
- $( "#rightSideDescription" ).val( description );
- $( "#rightSideExpression" ).val( expression );
- $( "#rightSideTextualExpression" ).val( textualDescription );
- }
-
- hideById( 'dynamicContent' );
- unLockScreen();
-}
-
-// -----------------------------------------------------------------------------
-// Set Null Expression
-// -----------------------------------------------------------------------------
-
-function clearRuleExpression()
-{
- var description = $( "#leftSideDescription" ).val();
- $( "#leftSideExpression" ).val( "" );
- $( "#leftSideTextualExpression" ).val( "" );
- saveExpression( "left", description, "", "" );
-
- description = $( "#rightSideDescription" ).val();
- $( "#rightSideExpression" ).val( "" );
- $( "#rightSideTextualExpression" ).val( "" );
- saveExpression( "right", description, "", "" );
-
- enable( "ruleType" );
- enable( "periodTypeName" );
-}
=== modified file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/javascript/expressionBuilder.js'
--- dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/javascript/expressionBuilder.js 2014-08-28 12:01:44 +0000
+++ dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/javascript/expressionBuilder.js 2015-09-08 15:56:00 +0000
@@ -88,25 +88,23 @@
function getExpressionText()
{
- if( hasText('expression') )
- {
- jQuery.postJSON( '../dhis-web-commons-ajax-json/getExpressionText.action',
- {
- expression: $( '#expression' ).val()
- },
- function( json )
- {
- if( json.response == 'success' || json.response == 'error' )
- {
- jQuery( "#formulaText").html( json.message );
- }
- else {
- jQuery( "#formulaText").html( '' );
+ if ( hasText('expression') ){
+ jQuery.ajax({
+ url: '../api/expressions/description',
+ data: {
+ expression: $( '#expression' ).val()
+ },
+ success: function( json, status, xhr ) {
+ if ( 'OK' == json.status ) {
+ jQuery( "#formulaText").html( json.description );
+ }
+ else {
+ jQuery( "#formulaText").html( json.message );
+ }
}
});
}
- else
- {
+ else {
jQuery( "#formulaText").html( '' );
}
}
@@ -125,34 +123,35 @@
formulaText = $( '#formulaText' ).text(),
missingValueStrategy = $( 'input[name="missingValueStrategy"]:checked' ).val();
- jQuery.postJSON( '../dhis-web-commons-ajax-json/getExpressionText.action',
- {
- expression: expression
- },
- function( json )
- {
- if ( json.response == 'error' )
- {
- markInvalid( 'expression-container textarea[id=expression]', json.message );
- }
- else
- {
- if ( left )
- {
- $( '#leftSideExpression' ).val( expression );
- $( '#leftSideDescription' ).val( description );
- $( '#leftSideTextualExpression' ).val( formulaText );
- $( '#leftSideMissingValueStrategy' ).val( missingValueStrategy );
- }
- else
- {
- $( '#rightSideExpression' ).val( expression );
- $( '#rightSideDescription' ).val( description );
- $( '#rightSideTextualExpression' ).val( formulaText );
- $( '#rightSideMissingValueStrategy' ).val( missingValueStrategy );
- }
-
- dialog.dialog( "close" );
+ jQuery.ajax({
+ url: '../api/expressions/description',
+ data: {
+ expression: expression
+ },
+ success: function( json, status, xhr ) {
+ if ( json.status == 'ERROR' )
+ {
+ markInvalid( 'expression-container textarea[id=expression]', json.message );
+ }
+ else
+ {
+ if ( left )
+ {
+ $( '#leftSideExpression' ).val( expression );
+ $( '#leftSideDescription' ).val( description );
+ $( '#leftSideTextualExpression' ).val( formulaText );
+ $( '#leftSideMissingValueStrategy' ).val( missingValueStrategy );
+ }
+ else
+ {
+ $( '#rightSideExpression' ).val( expression );
+ $( '#rightSideDescription' ).val( description );
+ $( '#rightSideTextualExpression' ).val( formulaText );
+ $( '#rightSideMissingValueStrategy' ).val( missingValueStrategy );
+ }
+
+ dialog.dialog( "close" );
+ }
}
});
}