/** * Indicates whether the value type of this attribute is numeric. */ public boolean isNumericType() { return valueType.isNumeric(); }
/** * Indicates whether the value type of this data element is a file (externally stored resource) */ public boolean isFileType() { return getValueType().isFile(); }
private RuleValueType toMappedValueType( ProgramRuleVariable programRuleVariable ) { ValueType valueType = VALUE_TYPE_MAPPER.getOrDefault( programRuleVariable.getSourceType(), prv -> ValueType.TEXT ).apply( programRuleVariable ); if ( valueType.isBoolean() ) { return RuleValueType.BOOLEAN; } if ( valueType.isText() ) { return RuleValueType.TEXT; } if ( valueType.isNumeric() ) { return RuleValueType.NUMERIC; } return RuleValueType.TEXT; }
/** * Returns a string useful for substitution. * * @param valueType the value type. * @return the string. */ public static String getSubstitutionValue( ValueType valueType ) { if ( valueType.isNumeric() || valueType.isBoolean() ) { return "1"; } else if ( valueType.isDate() ) { return "'2000-01-01'"; } else { return "'A'"; } }
if ( valueType.isText() || valueType.isNumeric() || ValueType.USERNAME == valueType ) inputHTML = inputHTML.replace( "$PROGRAMSTAGENAME", programStageName ); inputHTML = inputHTML.replace( "$DATAELEMENTNAME", dataElement.getName() ); inputHTML = inputHTML.replace( "$DATAELEMENTTYPE", dataElement.getValueType().toString() ); inputHTML = inputHTML.replace( "$DISABLED", disabled ); inputHTML = inputHTML.replace( "$COMPULSORY", compulsory );
private String getTrackedEntityAttributeValue( TrackedEntityAttributeValue attributeValue ) { ValueType valueType = attributeValue.getAttribute().getValueType(); if ( valueType.isBoolean() ) { return attributeValue.getValue() != null ? attributeValue.getValue() : "false"; } if ( valueType.isNumeric() ) { return attributeValue.getValue() != null ? attributeValue.getValue() : "0"; } return attributeValue.getValue() != null ? attributeValue.getValue() : ""; }
/** * Creates a mapping between data type and data element for the given data * elements. * * @param dataElements list of data elements. */ public static ListMap<DataType, DimensionalItemObject> getDataTypeDataElementMap( List<DimensionalItemObject> dataElements ) { ListMap<DataType, DimensionalItemObject> map = new ListMap<>(); for ( DimensionalItemObject element : dataElements ) { DataElement dataElement = (DataElement) element; ValueType valueType = dataElement.getValueType(); // Both text and date types are recognized as DataType.TEXT DataType dataType = ( valueType.isText() || valueType.isDate() ) ? DataType.TEXT : DataType.NUMERIC; map.putValue( dataType, dataElement ); } return map; }
public boolean isText() { return valueType.isText(); }
/** * Indicates whether the value type of this attribute is date. */ public boolean isDateType() { return valueType.isDate(); }
public String getTrackedEntityInstanceRecipient( TrackedEntityInstance tei, ValueType type ) { Set<TrackedEntityAttributeValue> attributeValues = tei.getTrackedEntityAttributeValues(); for ( TrackedEntityAttributeValue value : attributeValues ) { if ( value != null && value.getAttribute().getValueType().equals( type ) && value.getPlainValue() != null && !value.getPlainValue().trim().isEmpty() ) { return value.getPlainValue(); } } throw new IllegalQueryException( "Tracked entity does not have any attribute of value type: " + type.toString() ); }
public static boolean validateValueType( TextPattern textPattern, ValueType valueType ) { if ( ValueType.TEXT.equals( valueType ) ) { return true; } else if ( ValueType.NUMBER.equals( valueType ) ) { boolean isAllNumbers = true; for ( TextPatternSegment segment : textPattern.getSegments() ) { isAllNumbers = isAllNumbers && isNumericOnly( segment ); } return isAllNumbers; } else { return false; } }
else if ( valueType.isText() || valueType.isNumeric() || ValueType.USERNAME == valueType ) inputHTML = inputHTML.replace( "$PROGRAMSTAGENAME", programStageName ); inputHTML = inputHTML.replace( "$DATAELEMENTNAME", dataElement.getFormNameFallback() ); inputHTML = inputHTML.replace( "$DATAELEMENTTYPE", dataElement.getValueType().toString() ); inputHTML = inputHTML.replace( "$DISABLED", disabled ); inputHTML = inputHTML.replace( "$COMPULSORY", compulsory );
private String getTrackedEntityDataValue( TrackedEntityDataValue dataValue ) { ValueType valueType = dataValue.getDataElement().getValueType(); if ( valueType.isBoolean() ) { return dataValue.getValue() != null ? dataValue.getValue() : "false"; } if ( valueType.isNumeric() ) { return dataValue.getValue() != null ? dataValue.getValue() : "0"; } return dataValue.getValue() != null ? dataValue.getValue() : ""; } }
/** * Indicates whether the given time field is valid, i.e. whether * it is either a fixed time field or matches the identifier of an * attribute or data element of date value type part of the query program. */ public boolean timeFieldIsValid() { if ( timeField == null ) { return true; } if ( TimeField.fieldIsValid( timeField ) ) { return true; } if ( program.getTrackedEntityAttributes().stream() .anyMatch( at -> at.getValueType().isDate() && timeField.equals( at.getUid() ) ) ) { return true; } if ( program.getDataElements().stream() .anyMatch( de -> de.getValueType().isDate() && timeField.equals( de.getUid() ) ) ) { return true; } return false; }
else if ( dv.getDataElement().getValueType().isInteger() )
@Override public boolean equals( Object o ) { if ( this == o ) return true; if ( o == null || getClass() != o.getClass() ) return false; Attribute attribute1 = (Attribute) o; if ( attribute != null ? !attribute.equals( attribute1.attribute ) : attribute1.attribute != null ) { return false; } if ( displayName != null ? !displayName.equals( attribute1.displayName ) : attribute1.displayName != null ) { return false; } if ( valueType != null ? !valueType.equals( attribute1.valueType ) : attribute1.valueType != null ) { return false; } if ( code != null ? !code.equals( attribute1.code ) : attribute1.code != null ) { return false; } if ( value != null ? !value.equals( attribute1.value ) : attribute1.value != null ) { return false; } return true; }
public boolean isNumeric() { return valueType.isNumeric(); }