← Back to team overview

dhis2-devs team mailing list archive

Re: calling datavalueservice

 

Hi Ime,

You should look at dhis-api module for definition of datavalue service at that is dhis-api/src/main/java/org/hisp/dhis/datavalue and and hibernate mapping and service implementation in dhis-service-core/src/main/java/org/hisp/dhis/datavalue and dhis-service-core/src/main/resources/org/hisp/dhis/datavalue/hibernate. 
These two define full cycle of datavalue access API. 
External access example could be seen in dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/multidimentional/:

Injected service (see bean definition at dhis-web-dataentry/src/main/resources/META-INF/dhis/beans.xml):
...
    private DataValueService dataValueService;

    public void setDataValueService( DataValueService dataValueService )
    {
        this.dataValueService = dataValueService;
    }
...

Usage:

        // ---------------------------------------------------------------------
        // Get the DataValues and create a map
        // ---------------------------------------------------------------------

        Collection<DataValue> dataValues = dataValueService.getDataValues( organisationUnit, period, dataElements,
            orderdCategoryOptionCombos );

and 
...
        // ---------------------------------------------------------------------
        // Add/Update datavalue
        // ---------------------------------------------------------------------

        DataValue dataValue = dataValueService.getDataValue( organisationUnit, dataElement, period,optionCombo  );        

        if ( dataValue == null )
        {
            if ( value != null )
            {
                LOG.debug( "Adding DataValue, value added" );

                dataValue = new DataValue( dataElement, period, organisationUnit, value, storedBy, new Date(), null, optionCombo );
                dataValueService.addDataValue( dataValue );
            }
        }
        else
        {
            LOG.debug( "Updating DataValue, value added/changed" );

            dataValue.setValue( value );
            dataValue.setTimestamp( new Date() );
            dataValue.setStoredBy( storedBy );
                        
            dataValueService.updateDataValue( dataValue );
        }
...

Hope this helps. This is general structure to call any service in dhis2. For hibernate and spring mapping please refer to respective manuals from their sites. 

regards,
murod




----- Original Message ----
From: Ime Asangansi <asangansi@xxxxxxxxx>
To: Dhis2 <dhis2-devs@xxxxxxxxxxxxxxxxxxx>
Sent: Tuesday, June 16, 2009 7:12:02 PM
Subject: [Dhis2-devs] calling datavalueservice


Hi guys,

Please can someone kindly show me code that calls the datavalueservice?
(Link in launchpad).
Particularly interested in any available code (in an external module) that handles the import of datavalues into the database (e.g. from import).

Also, any possiblities with adding datavalues through a webservice???

TIA!

Cheers,
Ime

_______________________________________________
Mailing list: https://launchpad.net/~dhis2-devs
Post to     : dhis2-devs@xxxxxxxxxxxxxxxxxxx
Unsubscribe : https://launchpad.net/~dhis2-devs
More help   : https://help.launchpad.net/ListHelp



      



References