Search in sources :

Example 21 with STOREDBY

use of org.hisp.dhis.dxf2.events.trackedentity.store.query.EventQuery.COLUMNS.STOREDBY in project dhis2-core by dhis2.

the class EventDataValueRowCallbackHandler method getDataValue.

private List<DataValue> getDataValue(ResultSet rs) throws SQLException {
    // TODO not sure this is the most efficient way to handle JSONB -> java
    List<DataValue> dataValues = new ArrayList<>();
    PGobject values = (PGobject) rs.getObject("eventdatavalues");
    Map<String, ?> eventDataValuesJson = gson.fromJson(values.getValue(), Map.class);
    for (String dataElementUid : eventDataValuesJson.keySet()) {
        Map jsonValues = (Map) eventDataValuesJson.get(dataElementUid);
        DataValue value = new DataValue(dataElementUid, (String) jsonValues.get("value"));
        value.setCreated((String) jsonValues.get("created"));
        value.setLastUpdated((String) jsonValues.get("lastUpdated"));
        value.setStoredBy((String) jsonValues.get("storedBy"));
        value.setProvidedElsewhere((Boolean) jsonValues.get("providedElsewhere"));
        dataValues.add(value);
    }
    return dataValues;
}
Also used : DataValue(org.hisp.dhis.dxf2.events.event.DataValue) ArrayList(java.util.ArrayList) Map(java.util.Map) HashMap(java.util.HashMap) PGobject(org.postgresql.util.PGobject)

Example 22 with STOREDBY

use of org.hisp.dhis.dxf2.events.trackedentity.store.query.EventQuery.COLUMNS.STOREDBY in project dhis2-core by dhis2.

the class TrackedEntityAttributeRowCallbackHandler method getAttribute.

private Attribute getAttribute(ResultSet rs) throws SQLException {
    Attribute attribute = new Attribute();
    attribute.setCreated(DateUtils.getIso8601NoTz(rs.getTimestamp(getColumnName(CREATED))));
    attribute.setLastUpdated(DateUtils.getIso8601NoTz(rs.getTimestamp(getColumnName(UPDATED))));
    attribute.setDisplayName(rs.getString(getColumnName(ATTR_NAME)));
    attribute.setAttribute(rs.getString(getColumnName(ATTR_UID)));
    attribute.setValueType(ValueType.fromString(rs.getString(getColumnName(ATTR_VALUE_TYPE))));
    attribute.setCode(rs.getString(getColumnName(ATTR_CODE)));
    attribute.setValue(rs.getString(getColumnName(VALUE)));
    attribute.setStoredBy(rs.getString(getColumnName(STOREDBY)));
    attribute.setSkipSynchronization(rs.getBoolean(getColumnName(ATTR_SKIP_SYNC)));
    return attribute;
}
Also used : Attribute(org.hisp.dhis.dxf2.events.trackedentity.Attribute)

Aggregations

Date (java.util.Date)9 OrganisationUnit (org.hisp.dhis.organisationunit.OrganisationUnit)8 DataElement (org.hisp.dhis.dataelement.DataElement)6 DataElementCategoryOptionCombo (org.hisp.dhis.dataelement.DataElementCategoryOptionCombo)6 ImportSummary (org.hisp.dhis.dxf2.importsummary.ImportSummary)6 Period (org.hisp.dhis.period.Period)6 DataValue (org.hisp.dhis.dxf2.events.event.DataValue)5 DataSet (org.hisp.dhis.dataset.DataSet)4 DataValue (org.hisp.dhis.datavalue.DataValue)4 WebMessageException (org.hisp.dhis.dxf2.webmessage.WebMessageException)4 ArrayList (java.util.ArrayList)3 HashSet (java.util.HashSet)3 IdScheme (org.hisp.dhis.common.IdScheme)3 Event (org.hisp.dhis.dxf2.events.event.Event)3 ImportConflict (org.hisp.dhis.dxf2.importsummary.ImportConflict)3 HashMap (java.util.HashMap)2 Map (java.util.Map)2 CategoryOptionCombo (org.hisp.dhis.category.CategoryOptionCombo)2 DhisApiVersion (org.hisp.dhis.common.DhisApiVersion)2 CompleteDataSetRegistration (org.hisp.dhis.dataset.CompleteDataSetRegistration)2