Search in sources :

Example 1 with ValueTypeRenderingObject

use of org.hisp.dhis.render.type.ValueTypeRenderingObject in project dhis2-core by dhis2.

the class ProgramTrackedEntityAttributeObjectBundleHook method renderTypeConformsToConstrains.

private void renderTypeConformsToConstrains(ProgramTrackedEntityAttribute ptea, Consumer<ErrorReport> addReports) {
    DeviceRenderTypeMap<ValueTypeRenderingObject> map = ptea.getRenderType();
    TrackedEntityAttribute attr = ptea.getAttribute();
    if (map == null) {
        return;
    }
    for (ValueTypeRenderingObject renderingObject : map.values()) {
        if (renderingObject.getType() == null) {
            addReports.accept(new ErrorReport(ProgramTrackedEntityAttribute.class, ErrorCode.E4011, "renderType.type"));
        }
        if (!ValidationUtils.validateRenderingType(ProgramTrackedEntityAttribute.class, attr.getValueType(), attr.hasOptionSet(), renderingObject.getType())) {
            addReports.accept(new ErrorReport(ProgramTrackedEntityAttribute.class, ErrorCode.E4020, renderingObject.getType(), attr.getValueType()));
        }
    }
}
Also used : ErrorReport(org.hisp.dhis.feedback.ErrorReport) ProgramTrackedEntityAttribute(org.hisp.dhis.program.ProgramTrackedEntityAttribute) TrackedEntityAttribute(org.hisp.dhis.trackedentity.TrackedEntityAttribute) ProgramTrackedEntityAttribute(org.hisp.dhis.program.ProgramTrackedEntityAttribute) ValueTypeRenderingObject(org.hisp.dhis.render.type.ValueTypeRenderingObject)

Example 2 with ValueTypeRenderingObject

use of org.hisp.dhis.render.type.ValueTypeRenderingObject in project dhis2-core by dhis2.

the class ProgramStageDataElementObjectBundleHook method validate.

/**
 * Validate that the RenderType (if any) conforms to the constraints of
 * ValueType or OptionSet.
 */
@Override
public void validate(ProgramStageDataElement psda, ObjectBundle bundle, Consumer<ErrorReport> addReports) {
    DeviceRenderTypeMap<ValueTypeRenderingObject> map = psda.getRenderType();
    if (map == null) {
        return;
    }
    DataElement de = psda.getDataElement();
    for (ValueTypeRenderingObject renderingObject : map.values()) {
        if (renderingObject.getType() == null) {
            addReports.accept(new ErrorReport(ProgramStageDataElement.class, ErrorCode.E4011, "renderType.type"));
        }
        if (!ValidationUtils.validateRenderingType(ProgramStageDataElement.class, de.getValueType(), de.hasOptionSet(), renderingObject.getType())) {
            addReports.accept(new ErrorReport(ProgramStageDataElement.class, ErrorCode.E4017, renderingObject.getType(), de.getValueType()));
        }
    }
}
Also used : ErrorReport(org.hisp.dhis.feedback.ErrorReport) ProgramStageDataElement(org.hisp.dhis.program.ProgramStageDataElement) DataElement(org.hisp.dhis.dataelement.DataElement) ProgramStageDataElement(org.hisp.dhis.program.ProgramStageDataElement) ValueTypeRenderingObject(org.hisp.dhis.render.type.ValueTypeRenderingObject)

Example 3 with ValueTypeRenderingObject

use of org.hisp.dhis.render.type.ValueTypeRenderingObject in project dhis2-core by dhis2.

the class JsonBinaryTypeTest method getValueTypeRenderingObject.

private ValueTypeRenderingObject getValueTypeRenderingObject() {
    ValueTypeRenderingObject valueTypeRenderingObject = new ValueTypeRenderingObject();
    valueTypeRenderingObject.setType(BAR_CODE);
    return valueTypeRenderingObject;
}
Also used : ValueTypeRenderingObject(org.hisp.dhis.render.type.ValueTypeRenderingObject)

Aggregations

ValueTypeRenderingObject (org.hisp.dhis.render.type.ValueTypeRenderingObject)3 ErrorReport (org.hisp.dhis.feedback.ErrorReport)2 DataElement (org.hisp.dhis.dataelement.DataElement)1 ProgramStageDataElement (org.hisp.dhis.program.ProgramStageDataElement)1 ProgramTrackedEntityAttribute (org.hisp.dhis.program.ProgramTrackedEntityAttribute)1 TrackedEntityAttribute (org.hisp.dhis.trackedentity.TrackedEntityAttribute)1