示例#1
0
	def getActionAndTemplateAndParameterValues(self, ruleConsequent):
		checkData(locals())

		actions = Actions()
		actionList = actions.getAllActions()

		for action in actionList:
			
			# A action.ruleConsequent is represented as set of templates models:
			# Example "template1 | template2 | template2"

			models = action.ruleConsequent.split('|')

			for model in models:
				parameterNumber = model.count("@val")
				originalModel = model.strip()
				model = model.replace("@val","(.+)").strip()

				matchObj = re.match( model, ruleConsequent, re.M|re.I)

				if matchObj:
					parameterValues = {}

					for i in range(0,parameterNumber):
						parameterValues[str(i)] = matchObj.group(i + 1)

					return (action, originalModel, parameterValues)

		raise NotWellFormedRuleError("Impossible to find any action corresponding to the following rule consequent > " + ruleConsequent)
示例#2
0
	def getActions(self, buildingName = None, groupId = None):
		checkData(locals())

		from app.backend.model.actions import Actions
		actions = Actions()

		actionList = []
		for action in actions.getAllActions():
			actionList.append(action.getDict())

		return {"actions" : actionList}
示例#3
0
	def getActionCategories(self):
		checkData(locals())

		
		actions = Actions()
		actionList = actions.getAllActions()

		categories = []
		for action in actionList:
			if action.category not in categories:
				categories.append(action.category)

		return categories