public void setAttributePropertiesInDB ( final String attributeName , final Map < String , String [ ] > properties ) throws DevFailed { xlogger . entry ( properties ) ; final Map < String , String > currentValues = getAttributePropertiesFromDBSingle ( attributeName ) ; final Map < String , String [ ] > propInsert = new HashMap < String , String [ ] > ( ) ; for ( final Entry < String , String [ ] > entry : properties . entrySet ( ) ) { final String propertyName = entry . getKey ( ) ; final String [ ] valueArray = entry . getValue ( ) ; // insert value in db only if input value is different and not a // default value if ( valueArray . length == 1 ) { final String value = valueArray [ 0 ] ; final String presentValue = currentValues . get ( propertyName ) ; boolean isADefaultValue = false ; if ( presentValue != null ) { isADefaultValue = presentValue . isEmpty ( ) && ( value . equalsIgnoreCase ( Constants . NOT_SPECIFIED ) || value . equalsIgnoreCase ( Constants . NO_DIPLAY_UNIT ) || value . equalsIgnoreCase ( Constants . NO_UNIT ) || value . equalsIgnoreCase ( Constants . NO_STD_UNIT ) ) ; } if ( ! isADefaultValue ) { if ( presentValue == null ) { propInsert . put ( propertyName , valueArray ) ; } else if ( ! presentValue . equals ( value ) && ! value . isEmpty ( ) && ! value . equals ( "NaN" ) ) { propInsert . put ( propertyName , valueArray ) ; } } } else { // do not check if not a single value propInsert . put ( propertyName , valueArray ) ; } } logger . debug ( "update attribute {} properties {} in DB " , attributeName , properties . keySet ( ) ) ; DatabaseFactory . getDatabase ( ) . setAttributeProperties ( deviceName , attributeName , propInsert ) ; xlogger . exit ( ) ; }
Set attribute properties in tango db