dhis2 / dhis2-android-trackercapture

DHIS 2 Tracker Capture application for Android
Other
14 stars 28 forks source link

Error while adding the Data Eement to existing porfile #62

Closed i-sourabh closed 9 years ago

i-sourabh commented 9 years ago

*Hi, I am facing a new issue while running the app. Following is the screenshot for same: fin

When user clicks on the Org Unit here Financial Security: Andheri then app unfortunately stops and following error comes:* Same is the error while updating the profile of person:

Process: org.hisp.dhis.android.trackercapture, PID: 18718 org.apache.commons.jexl2.JexlException$Parsing: org.hisp.dhis.android.sdk.utils.support.ExpressionUtils.evaluate@1:12 parsing error near '... ents} == f ...' at org.apache.commons.jexl2.JexlEngine.parse(JexlEngine.java:1260) at org.apache.commons.jexl2.JexlEngine.createExpression(JexlEngine.java:435) at org.apache.commons.jexl2.JexlEngine.createExpression(JexlEngine.java:419) at org.hisp.dhis.android.sdk.utils.support.ExpressionUtils.evaluate(ExpressionUtils.java:69) at org.hisp.dhis.android.sdk.utils.support.ExpressionUtils.isTrue(ExpressionUtils.java:105) at org.hisp.dhis.android.sdk.utils.services.ProgramRuleService.evaluate(ProgramRuleService.java:96) at org.hisp.dhis.android.sdk.ui.fragments.dataentry.DataEntryFragment$6.run(DataEntryFragment.java:514) Caused by: org.apache.commons.jexl2.parser.ParseException: parse error at org.apache.commons.jexl2.parser.Parser.generateParseException(Parser.java:3935) at org.apache.commons.jexl2.parser.Parser.jj_consume_token(Parser.java:3817) at org.apache.commons.jexl2.parser.Parser.MapEntry(Parser.java:1835) at org.apache.commons.jexl2.parser.Parser.MapLiteral(Parser.java:1781) at org.apache.commons.jexl2.parser.Parser.Reference(Parser.java:2324) at org.apache.commons.jexl2.parser.Parser.PrimaryExpression(Parser.java:2184) at org.apache.commons.jexl2.parser.Parser.UnaryExpression(Parser.java:1481) at org.apache.commons.jexl2.parser.Parser.MultiplicativeExpression(Parser.java:1269) at org.apache.commons.jexl2.parser.Parser.AdditiveExpression(Parser.java:1196) at org.apache.commons.jexl2.parser.Parser.RelationalExpression(Parser.java:991) at org.apache.commons.jexl2.parser.Parser.EqualityExpression(Parser.java:915) at org.apache.commons.jexl2.parser.Parser.AndExpression(Parser.java:873) at org.apache.commons.jexl2.parser.Parser.ExclusiveOrExpression(Parser.java:831) at org.apache.commons.jexl2.parser.Parser.InclusiveOrExpression(Parser.java:789) at org.apache.commons.jexl2.parser.Parser.ConditionalAndExpression(Parser.java:747) at org.apache.commons.jexl2.parser.Parser.ConditionalOrExpression(Parser.java:705) at org.apache.commons.jexl2.parser.Parser.ConditionalExpression(Parser.java:627) at org.apache.commons.jexl2.parser.Parser.Expression(Parser.java:450) at org.apache.commons.jexl2.parser.Parser.ExpressionStatement(Parser.java:256) at org.apache.commons.jexl2.parser.Parser.Statement(Parser.java:140) at org.apache.commons.jexl2.parser.Parser.JexlScript(Parser.java:72) at org.apache.commons.jexl2.parser.Parser.parse(Parser.java:24) at org.apache.commons.jexl2.JexlEngine.parse(JexlEngine.java:1248)             at org.apache.commons.jexl2.JexlEngine.createExpression(JexlEngine.java:435)             at org.apache.commons.jexl2.JexlEngine.createExpression(JexlEngine.java:419)             at org.hisp.dhis.android.sdk.utils.support.ExpressionUtils.evaluate(ExpressionUtils.java:69)             at org.hisp.dhis.android.sdk.utils.support.ExpressionUtils.isTrue(ExpressionUtils.java:105)             at org.hisp.dhis.android.sdk.utils.services.ProgramRuleService.evaluate(ProgramRuleService.java:96)             at org.hisp.dhis.android.sdk.ui.fragments.dataentry.DataEntryFragment$6.run(DataEntryFragment.java:514)

erlingfjelstad commented 9 years ago

Hi, Andy. Please check that your program rules for Financial Security in the DHIS 2 web interface is valid

i-sourabh commented 9 years ago

Thanks @erlingfjelstad for the reply, but there are no program rules for Financial Security and same thing is happening in case user clicks on Update Profile option, following error comes: fin

Caused by: java.lang.NullPointerException: println needs a message at android.util.Log.println_native(Native Method) at android.util.Log.d(Log.java:139) at org.hisp.dhis.android.trackercapture.fragments.trackedentityinstanceprofile.TrackedEntityInstanceProfileFragmentQuery.query(TrackedEntityInstanceProfileFragmentQuery.java:71) at org.hisp.dhis.android.trackercapture.fragments.trackedentityinstanceprofile.TrackedEntityInstanceProfileFragmentQuery.query(TrackedEntityInstanceProfileFragmentQuery.java:30) at org.hisp.dhis.android.sdk.persistence.loaders.DbLoader.loadInBackground(DbLoader.java:89) at android.support.v4.content.AsyncTaskLoader.onLoadInBackground(AsyncTaskLoader.java:242) at android.support.v4.content.AsyncTaskLoader$LoadTask.doInBackground(AsyncTaskLoader.java:51) at android.support.v4.content.AsyncTaskLoader$LoadTask.doInBackground(AsyncTaskLoader.java:40) at android.support.v4.content.ModernAsyncTask$2.call(ModernAsyncTask.java:123) at java.util.concurrent.FutureTask.run(FutureTask.java:237)             at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)             at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)             at java.lang.Thread.run(Thread.java:818)

erlingfjelstad commented 9 years ago

Have you done some modification of the source code? It seems that it is a logger in the TrackedEntityInstanceProfileFragmentQuery class that is crashing. I don't have any logger in that class in my code.

i-sourabh commented 9 years ago

No I am using the same source code available at Git hub and log's are predefined in that code.

erlingfjelstad commented 9 years ago

Can you please try to update the source code to latest version?

i-sourabh commented 9 years ago

Actually I am already using the latest one available at Git Hub

russnes commented 9 years ago

andy please post the code where the program is crashing. 10 lines before and after line 71 in TrackedEntityInstanceProfileFragmentQuery.java

i-sourabh commented 9 years ago

Here is the code after line no: 71 Log.d(attributes.get(i).getTrackedEntityAttribute().getName(), values.get(i).getValue()); } mForm.setTrackedEntityAttributeValues(values); mForm.setDataEntryRows(dataEntryRows); return mForm; }

public TrackedEntityAttributeValue getTrackedEntityDataValue(String trackedEntityAttribute, List<TrackedEntityAttributeValue> trackedEntityAttributeValues) {
    for (TrackedEntityAttributeValue trackedEntityAttributeValue : trackedEntityAttributeValues) {
        if (trackedEntityAttributeValue.getTrackedEntityAttributeId().equals(trackedEntityAttribute))
            return trackedEntityAttributeValue;
    }

    //the datavalue didnt exist for some reason. Create a new one.
    TrackedEntityAttributeValue trackedEntityAttributeValue = new TrackedEntityAttributeValue();
    trackedEntityAttributeValue.setTrackedEntityAttributeId(trackedEntityAttribute);
    trackedEntityAttributeValue.setTrackedEntityInstanceId(currentTrackedEntityInstance.getTrackedEntityInstance());
    trackedEntityAttributeValue.setLocalTrackedEntityInstanceId(currentTrackedEntityInstance.getLocalId());
    trackedEntityAttributeValue.setValue("");
    trackedEntityAttributeValues.add(trackedEntityAttributeValue);
    return trackedEntityAttributeValue;
}

public DataEntryRow createDataEntryView(TrackedEntityAttribute trackedEntityAttribute, TrackedEntityAttributeValue dataValue) {
    DataEntryRow row;
    String trackedEntityAttributeName = trackedEntityAttribute.getName();
    if (trackedEntityAttribute.getOptionSet() != null) {
        OptionSet optionSet = MetaDataController.getOptionSet(trackedEntityAttribute.getOptionSet());
        if (optionSet == null) {
            row = new EditTextRow(trackedEntityAttributeName, dataValue, DataEntryRowTypes.TEXT);
        } else {
            row = new AutoCompleteRow(trackedEntityAttributeName, dataValue, optionSet);
        }
    } else if (trackedEntityAttribute.getValueType().equalsIgnoreCase(DataElement.VALUE_TYPE_TEXT)) {
        row = new EditTextRow(trackedEntityAttributeName, dataValue, DataEntryRowTypes.TEXT);
    } else if (trackedEntityAttribute.getValueType().equalsIgnoreCase(DataElement.VALUE_TYPE_LONG_TEXT)) {
        row = new EditTextRow(trackedEntityAttributeName, dataValue, DataEntryRowTypes.LONG_TEXT);
    } else if (trackedEntityAttribute.getValueType().equalsIgnoreCase(DataElement.VALUE_TYPE_NUMBER)) {
        row = new EditTextRow(trackedEntityAttributeName, dataValue, DataEntryRowTypes.NUMBER);
    } else if (trackedEntityAttribute.getValueType().equalsIgnoreCase(DataElement.VALUE_TYPE_INT)) {
        row = new EditTextRow(trackedEntityAttributeName, dataValue, DataEntryRowTypes.INTEGER);
    } else if (trackedEntityAttribute.getValueType().equalsIgnoreCase(DataElement.VALUE_TYPE_ZERO_OR_POSITIVE_INT)) {
        row = new EditTextRow(trackedEntityAttributeName, dataValue, DataEntryRowTypes.INTEGER_ZERO_OR_POSITIVE);
    } else if (trackedEntityAttribute.getValueType().equalsIgnoreCase(DataElement.VALUE_TYPE_POSITIVE_INT)) {
        row = new EditTextRow(trackedEntityAttributeName, dataValue, DataEntryRowTypes.INTEGER_POSITIVE);
    } else if (trackedEntityAttribute.getValueType().equalsIgnoreCase(DataElement.VALUE_TYPE_NEGATIVE_INT)) {
        row = new EditTextRow(trackedEntityAttributeName, dataValue, DataEntryRowTypes.INTEGER_NEGATIVE);
    } else if (trackedEntityAttribute.getValueType().equalsIgnoreCase(DataElement.VALUE_TYPE_BOOL)) {
        row = new RadioButtonsRow(trackedEntityAttributeName, dataValue, DataEntryRowTypes.BOOLEAN);
    } else if (trackedEntityAttribute.getValueType().equalsIgnoreCase(DataElement.VALUE_TYPE_TRUE_ONLY)) {
        row = new CheckBoxRow(trackedEntityAttributeName, dataValue);
    } else if (trackedEntityAttribute.getValueType().equalsIgnoreCase(DataElement.VALUE_TYPE_DATE)) {
        row = new DatePickerRow(trackedEntityAttributeName, dataValue);
    } else if (trackedEntityAttribute.getValueType().equalsIgnoreCase(DataElement.VALUE_TYPE_STRING)) {
        row = new EditTextRow(trackedEntityAttributeName, dataValue, DataEntryRowTypes.LONG_TEXT);
    } else {
        row = new EditTextRow(trackedEntityAttributeName, dataValue, DataEntryRowTypes.LONG_TEXT);
    }
    return row;
}

}

Here is the Logcat: [ 09-15 14:22:09.116 7127: 7127 D/org.hisp.dhis.android.trackercapture.fragments.trackedentityinstanceprofile.TrackedEntityInsonCreateOptionsMenu 09-15 14:22:09.210 7127-7317/org.hisp.dhis.android.trackercapture D/First name﹕ q 09-15 14:22:09.212 7127-7317/org.hisp.dhis.android.trackercapture D/Last name﹕ q 09-15 14:22:09.213 7127-7317/org.hisp.dhis.android.trackercapture D/Nick name﹕ q 09-15 14:22:09.229 7127-7317/org.hisp.dhis.android.trackercapture D/Date of Birth﹕ 33 09-15 14:22:09.232 7127-7317/org.hisp.dhis.android.trackercapture D/Age﹕ Male 09-15 14:22:09.298 7127-7317/org.hisp.dhis.android.trackercapture D/Gender﹕ MSM 09-15 14:22:09.300 7127-7317/org.hisp.dhis.android.trackercapture D/Typology﹕ false 09-15 14:22:09.303 7127-7317/org.hisp.dhis.android.trackercapture D/Education status﹕ --------- beginning of crash 09-15 14:22:09.322 7127-7317/org.hisp.dhis.android.trackercapture E/AndroidRuntime﹕ FATAL EXCEPTION: ModernAsyncTask #5 Process: org.hisp.dhis.android.trackercapture, PID: 7127 java.lang.RuntimeException: An error occured while executing doInBackground() at android.support.v4.content.ModernAsyncTask$3.done(ModernAsyncTask.java:137) at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355) at java.util.concurrent.FutureTask.setException(FutureTask.java:222) at java.util.concurrent.FutureTask.run(FutureTask.java:242) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) at java.lang.Thread.run(Thread.java:818) Caused by: java.lang.NullPointerException: println needs a message at android.util.Log.println_native(Native Method) at android.util.Log.d(Log.java:139) at org.hisp.dhis.android.trackercapture.fragments.trackedentityinstanceprofile.TrackedEntityInstanceProfileFragmentQuery.query(TrackedEntityInstanceProfileFragmentQuery.java:71) at org.hisp.dhis.android.trackercapture.fragments.trackedentityinstanceprofile.TrackedEntityInstanceProfileFragmentQuery.query(TrackedEntityInstanceProfileFragmentQuery.java:30) at org.hisp.dhis.android.sdk.persistence.loaders.DbLoader.loadInBackground(DbLoader.java:89) at android.support.v4.content.AsyncTaskLoader.onLoadInBackground(AsyncTaskLoader.java:242) at android.support.v4.content.AsyncTaskLoader$LoadTask.doInBackground(AsyncTaskLoader.java:51) at android.support.v4.content.AsyncTaskLoader$LoadTask.doInBackground(AsyncTaskLoader.java:40) at android.support.v4.content.ModernAsyncTask$2.call(ModernAsyncTask.java:123) at java.util.concurrent.FutureTask.run(FutureTask.java:237)             at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)             at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)             at java.lang.Thread.run(Thread.java:818) --------- beginning of system

russnes commented 9 years ago

the value might be null in some cases, so if you try to print it then it will cause a nullpointerexception. If you want to print the null then add print for example ("" + value).

@andy003 please note that this issue tracker is about issues related to the code in this project, so if you need help with basic programming you should perhaps consult stack overflow or some other resource

i-sourabh commented 9 years ago

Thanks @simens