private boolean isEmailValid( String email ) { return ValidationUtils.emailIsValid( email ); }
public boolean isValid() { return ValidationUtils.coordinateIsValid( getCoordinateString() ); }
/** * Validates whether a date string is valid for the default Locale. * * @param date the date string. * @return true if the date string is valid, false otherwise. */ public static boolean dateIsValid( String date ) { return dateIsValid( date, null ); }
ValidationUtils.normalizeBoolean( dataValue.getValue(), dataElement.getValueType() ) ); String valueValid = ValidationUtils.dataValueIsValid( dataValue.getValue(), dataElement ); String commentValid = ValidationUtils.commentIsValid( dataValue.getComment() ); boolean zeroInsignificant = ValidationUtils.dataValueIsZeroAndInsignificant( dataValue.getValue(), dataElement ); String storedByValid = ValidationUtils.storedByIsValid( dataValue.getStoredBy() );
@Override @Transactional public void updateDataValue( DataValue dataValue ) { if ( dataValue.isNullValue() || dataValueIsZeroAndInsignificant( dataValue.getValue(), dataValue.getDataElement() ) ) { deleteDataValue( dataValue ); } else if ( dataValueIsValid( dataValue.getValue(), dataValue.getDataElement() ) == null ) { dataValue.setLastUpdated( new Date() ); DataValueAudit dataValueAudit = new DataValueAudit( dataValue, dataValue.getAuditValue(), dataValue.getStoredBy(), AuditType.UPDATE ); dataValueAuditService.addDataValueAudit( dataValueAudit ); dataValueStore.updateDataValue( dataValue ); } }
return dataValueIsValid( value, dataElement.getValueType() );
boolean zeroInsignificant = dataValueIsZeroAndInsignificant( newValue.getValue(), newValue.getDataElement() );
/** * Get all the Organisation Units within the distance of a coordinate. */ @Override public List<OrganisationUnit> getOrganisationUnitWithinDistance( double longitude, double latitude, double distance ) { List<OrganisationUnit> objects = organisationUnitStore.getWithinCoordinateArea( GeoUtils.getBoxShape( longitude, latitude, distance ) ); // Go through the list and remove the ones located outside radius if ( objects != null && objects.size() > 0 ) { Iterator<OrganisationUnit> iter = objects.iterator(); Point2D centerPoint = new Point2D.Double( longitude, latitude ); while ( iter.hasNext() ) { OrganisationUnit orgunit = iter.next(); double distancebetween = GeoUtils.getDistanceBetweenTwoPoints( centerPoint, ValidationUtils.getCoordinatePoint2D( orgunit.getCoordinates() ) ); if ( distancebetween > distance ) { iter.remove(); } } } return objects; }
String sample = ValidationUtils.getSubstitutionValue( dataElement.getValueType() ); String sample = ValidationUtils.getSubstitutionValue( attribute.getValueType() );
if ( params.hasBbox() && !ValidationUtils.bboxIsValid( params.getBbox() ) )
String result = dataValueIsValid( dataValue.getValue(), dataValue.getDataElement() ); boolean zeroInsignificant = dataValueIsZeroAndInsignificant( dataValue.getValue(), dataValue.getDataElement() );
dv.setStoredBy( storedBy ); if ( ValidationUtils.dataValueIsValid( value, dv.getDataElement() ) != null )
!dataValueIsZeroAndInsignificant( Double.toString( value ), outputDataElement ) )
private boolean validateDataValue( ProgramStageInstance programStageInstance, User user, DataElement dataElement, String value, EventStatus eventStatus, Set<String> mandatoryDataElements, boolean validateMandatoryAttributes, ImportSummary importSummary ) String status = ValidationUtils.dataValueIsValid( value, dataElement );
@Override public boolean systemNotificationEmailValid() { String address = (String) getSystemSetting( SettingKey.SYSTEM_NOTIFICATIONS_EMAIL ); return address != null && ValidationUtils.emailIsValid( address ); }
@Override public void saveTrackedEntityDataValue( TrackedEntityDataValue trackedEntityDataValue ) { trackedEntityDataValue.setAutoFields(); if ( !StringUtils.isEmpty( trackedEntityDataValue.getValue() ) ) { if ( StringUtils.isEmpty( trackedEntityDataValue.getStoredBy() ) ) { trackedEntityDataValue.setStoredBy( currentUserService.getCurrentUsername() ); } if ( trackedEntityDataValue.getDataElement() == null || trackedEntityDataValue.getDataElement().getValueType() == null ) { throw new IllegalQueryException( "Data element or type is null or empty" ); } String result = dataValueIsValid( trackedEntityDataValue.getValue(), trackedEntityDataValue.getDataElement().getValueType() ); if ( result != null ) { throw new IllegalQueryException( "Value is not valid: " + result ); } if ( trackedEntityDataValue.getDataElement().isFileType() ) { handleFileDataValueSave( trackedEntityDataValue ); } dataValueStore.saveVoid( trackedEntityDataValue ); } }
@Override public String validateRestore( UserCredentials credentials ) { if ( !emailMessageSender.isConfigured() ) { log.warn( "Could not send restore/invite message as email is not configured" ); return "email_not_configured_for_system"; } if ( credentials == null || credentials.getUserInfo() == null ) { log.warn( "Could not send restore/invite message as user is null: " + credentials ); return "no_user_credentials"; } if ( credentials.getUserInfo().getEmail() == null || !ValidationUtils.emailIsValid( credentials.getUserInfo().getEmail() ) ) { log.warn( "Could not send restore/invite message as user has no email or email is invalid" ); return "user_does_not_have_valid_email"; } return null; }
@Override public void updateTrackedEntityDataValue( TrackedEntityDataValue trackedEntityDataValue ) { trackedEntityDataValue.setAutoFields(); if ( StringUtils.isEmpty( trackedEntityDataValue.getValue() ) ) { deleteTrackedEntityDataValue( trackedEntityDataValue ); } else { if ( StringUtils.isEmpty( trackedEntityDataValue.getStoredBy() ) ) { trackedEntityDataValue.setStoredBy( currentUserService.getCurrentUsername() ); } if ( trackedEntityDataValue.getDataElement() == null || trackedEntityDataValue.getDataElement().getValueType() == null ) { throw new IllegalQueryException( "Data element or type is null or empty" ); } String result = dataValueIsValid( trackedEntityDataValue.getValue(), trackedEntityDataValue.getDataElement().getValueType() ); if ( result != null ) { throw new IllegalQueryException( "Value is not valid: " + result ); } createAndAddAudit( trackedEntityDataValue, trackedEntityDataValue.getStoredBy(), AuditType.UPDATE ); handleFileDataValueUpdate( trackedEntityDataValue ); dataValueStore.update( trackedEntityDataValue ); } }
@Override public OutboundMessageResponse sendSystemEmail( Email email ) { OutboundMessageResponse response = new OutboundMessageResponse(); String recipient = (String) systemSettingManager.getSystemSetting( SettingKey.SYSTEM_NOTIFICATIONS_EMAIL ); String appTitle = (String) systemSettingManager.getSystemSetting( SettingKey.APPLICATION_TITLE ); if ( recipient == null || !ValidationUtils.emailIsValid( recipient ) ) { response.setOk( false ); response.setDescription( "No recipient found" ); return response; } User user = new User(); UserCredentials credentials = new UserCredentials(); credentials.setUsername( recipient ); user.setEmail( recipient ); User sender = new User(); sender.setFirstName( StringUtils.trimToEmpty( appTitle ) ); sender.setSurname( recipient ); return emailMessageSender.sendMessage( email.getSubject(), email.getText(), null, sender, Sets.newHashSet( user ), true ); } }
String result = dataValueIsValid( attributeValue.getValue(), attributeValue.getAttribute().getValueType() );