def createUnverifiedPropertyValue(self, session, propertyTypeName, tag, value, units, description, enteredByUserId): enteredOnDateTime = datetime.datetime.now() dbPropertyType = self.propertyTypeHandler.getPropertyTypeByName(session, propertyTypeName) self.propertyTypeHandler.checkPropertyValueIsAllowed(value, dbPropertyType.allowedPropertyValueList) dbPropertyValue = PropertyValue(tag=tag, value=value, units=units, description=description, entered_by_user_id=enteredByUserId, entered_on_date_time=enteredOnDateTime) dbPropertyValue.propertyType = dbPropertyType return dbPropertyValue
def createPropertyValue(self, session, propertyTypeName, tag, value, units, description, enteredByUserId, isUserWriteable=None, isDynamic=None, displayValue=None, targetValue=None, enteredOnDateTime=None): enteredByDbUserInfo = self.userInfoHandler.getUserInfoById( session, enteredByUserId) if enteredOnDateTime is None: enteredOnDateTime = datetime.datetime.now() dbPropertyType = self.propertyTypeHandler.getPropertyTypeByName( session, propertyTypeName) self.propertyTypeHandler.checkPropertyValueIsAllowed( value, dbPropertyType.allowedPropertyValueList) dbPropertyValue = PropertyValue(tag=tag, value=value, units=units, description=description, entered_on_date_time=enteredOnDateTime) dbPropertyValue.enteredByUserInfo = enteredByDbUserInfo dbPropertyValue.propertyType = dbPropertyType return dbPropertyValue
def createPropertyValueByTypeId(self, session, propertyTypeId, tag, value, units, description, enteredByUserId, isDynamic, isUserWriteable): enteredByDbUserInfo = self.userInfoHandler.getUserInfoById(session, enteredByUserId) enteredOnDateTime = datetime.datetime.now() dbPropertyType = self.propertyTypeHandler.getPropertyTypeById(session, propertyTypeId) self.propertyTypeHandler.checkPropertyValueIsAllowed(value, dbPropertyType.allowedPropertyValueList) dbPropertyValue = PropertyValue(property_type_id=propertyTypeId, tag=tag, value=value, units=units, description=description, entered_by_user_id=enteredByUserId, entered_on_date_time=enteredOnDateTime, is_dynamic=isDynamic, is_user_writeable=isUserWriteable) return dbPropertyValue
def createPropertyValue(self, session, propertyTypeName, tag, value, units, description, enteredByUserId, isUserWriteable=None, isDynamic=None, displayValue=None, targetValue=None, enteredOnDateTime=None, allowInternal=False): enteredByDbUserInfo = self.userInfoHandler.getUserInfoById( session, enteredByUserId) if enteredOnDateTime is None: enteredOnDateTime = datetime.datetime.now() dbPropertyType = self.propertyTypeHandler.getPropertyTypeByName( session, propertyTypeName) if (allowInternal == False and dbPropertyType.is_internal): raise CommandFailed( "%s is an internal property. Can only be added and updated using specialized functionality." % propertyTypeName) else: allowedPropertyValueList = self.propertyTypeHandler.getAllowedPropertyTypeValuesById( session, dbPropertyType.id) self.propertyTypeHandler.checkPropertyValueIsAllowed( value, allowedPropertyValueList) dbPropertyValue = PropertyValue( tag=tag, value=value, display_value=displayValue, units=units, description=description, entered_on_date_time=enteredOnDateTime) dbPropertyValue.enteredByUserInfo = enteredByDbUserInfo dbPropertyValue.propertyType = dbPropertyType return dbPropertyValue