# Enhancing Sustainable IoT Systems Through a Goal-Oriented Requirements Analysis Framework
## 4 Goal-Oriented Requirements Analysis Approach for IoT Software Systems
### Application Example: IoT System for Monitoring Air Quality
#### 4.2.5 QVT for Model-to-Model Transformations
In the Initialization Phase, the source iStar model, containing resource elements, is loaded, and the target UML model is initialized. In addition, transformation traceability links are established to maintain consistency between the source and target artifacts. Upon defining the QVT (Query/View/Transformation) rules, their execution generates a UML class diagram that structurally mirrors the iStar model. Specifically, actors are transformed into UML classes, goals into attributes, tasks or services into operations, and resources into specialized sensor classes. During the Matching Phase, the transformation engine identifies all resource elements within the iStar model. For each resource possessing a resourceName attribute, a corresponding match is generated. Subsequently, in the Execution Phase, every matched resource is processed by instantiating a UML Class in the target model, where the Class's name attribute is assigned the value of the resource's resourceName. Traceability information is recorded to ensure bidirectional model synchronization. Finally, the Completion Phase performs essential post-processing tasks: the target UML model is finalized, transformation trace metadata persist, and model validation is conducted to verify structural and semantic correctness. The model transformation process has been refined to ensure alignment between the conceptual elements of the i* framework and the automated code generation pipeline proposed in our methodology. Specifically, the QVT transformation rules were updated to accurately map the core elements of the i* model to an intermediate Python model, establishing a clear correspondence as follows: Goals are represented by monitoring activities such as \"Monitor Air Quality\"; Tasks correspond to actuator logic, such as \"Activate Purifier\"; and SoftGoals are associated with sustainability-related metrics, which are exemplified by \"Minimize Energy Consumption\". These mappings allow the intermediate model to retain the semantic intent of the requirements analysis. Subsequently, the Acceleo template was adjusted to interpret the intermediate Python model and to generate the corresponding Python source code. This alignment enhances the fidelity of the model-driven approach and ensures that the generated code accurately reflects the stakeholder intentions and sustainability objectives captured during the early requirements engineering phase. The implementation details of the QVT Operational Engine within the Eclipse Framework, providing insights into its execution mechanics and integration, is presented next in Listing 6. ```
//Using EclipseQVTOperationalengine QVTOperationalEngine engine = newQVTOperationalEngine(); **QVT Rules (GORA.iStar2 PythonModel.qvto)**  modeltype iStar uses \"[[http://gora.org/istar](http://gora.org/istar)]([http://gora.org/istar](http://gora.org/istar))\";  modeltype PythonModel uses \"[[http://gora.org/pythonmodel](http://gora.org/pythonmodel)]([http://gora.org/pythonmodel](http://gora.org/pythonmodel))\";transformation GORA2 PythonModel(in inModel : iStar, out out outModel : PythonModel);

main() {  inModel.rootObjects()[GoalModel]->map toPythonSystem  ();  }

mapping GoalModel::toPythonSystem() : PythonSystem {  name := 'GORA_System';  nodes := self.elements->select(e | e.oclIsTypeOf(Goal  ))->map toPythonNode()  ->union(self.elements->select(e | e.oclIsTypeOf(Task)  )->map toPythonTask())  ->union(self.elements->select(e | e.oclIsTypeOf(  ) SoftGoal))->map toLoggerNode());  }

mapping Goal::toPythonNode() : PythonNode when { self.name =  'Monitor Air Quality' } {  nodeType :='sensor';  topic :='sensors/air';  handler :='read_air_sensor';  }

mapping Task::toPythonTask() : PythonNode when { self.name =  'Active Purifier' } {  nodeType := 'actuator';  topic := 'actuators/purifier';  handler := 'trigger_purifier';  log_response_time := true;  }

mapping SoftGoal::toLoggerNode() : PythonNode when { self.