# SCM-IoT: An Approach for Internet of Things Services Integration and Coordination
## 3 Methodology
### Platform Dependent Computacional Model
#### 3.3.1 Storage Medium
To attend to the editing services, the procedure followed by the editor consists of repeatedly performing two activities sequentially: first, receiving service requests, then making changes to the content of the notebook according to the requests received. Listing 4 shows a fragment of this procedure that shows in detail. The attention to the update request has a very similar structure. The relevance of this procedure lies in showing in detail how the integration of SOA has been achieved through a message-oriented language and the representation and administration of a shared storage medium where decisions with various degrees of complexity can be analyzed and made. ```

Lines 1 and 2 establish the exclusion condition to accept new requests. The condition establishes that the editor has exclusive access until the completion of his editing activities as indicated by the variable \"editing\". Line 4 establishes the selection dictated by the BPEL implementation to determine which message will be served next. If two requests are received simultaneously, one is selected non-deterministically while the other is discarded. In a relatively slow-changing IoT environment, losing some messages do not negatively affect the system performance. In line 5, the received message is declared and accepted in the <pick/> branch by <onMessage/>. The port type of the update service, the link to the business partner, and the variable where the request information will be stored are also indicated. Lines 6 and 38 delimit the scope of the local variables declared in lines 8 to 10. Lines 13 to 18 show the assignment of the logical expression value given in line 15 to the variable \"sampage\" that establishes the first condition to update the notebook. The second condition is established from lines 19 to 28. In lines 19 to 24, the requested data are received in \"valueinnote\" variable. The value registered in the notebook is assigned into the variable \"Valueinnotebook\", as indicated in lines 25 to 28. Both assignments display the Xpath expressions to obtain the indicated values. In lines 29 to 36, it is decided whether or not to carry out the update. The updating criterion is given by the conjunction of the two previous conditions. First, the values to be compared correspond to the same notebook, page, and topic, and second, the value received is different from the one previously recorded. When both conditions are met, the update is performed through an XSLT transformation to the notebook's contents. Since the notebook structure remains unchanged as long as the number and type of publisher clients remain unchanged, the corresponding \"update.xsl\" operation is straightforward. In line 33, the invocation of the transformation procedure appears together with its current parameters. In line 34, once the transformation of the notebook is completed, the updated structure is assigned to the same variable. Finally, between lines 40 and 43, the second branch of <pick> appears schematically to receive subscription requests. The invocation to doXslTransform is what transforms the edit notebook. Notice the update of the attribute \"time\" defined for all fields. This attribute establishes how recent the update is, so newly updated fields will include this attribute with the value of \"0\". The value of this attribute is decremented by one with each update (by invocation of doXslTransform). Accordingly, in the next update of the notebook, those fields that had the value of \"0\" will now have the value \"\(-\)1\", which makes it possible to distinguish them from the newly updated ones because the latter will have the value of \"0\" as said. At the end of the next update of the notebook, the fields whose attribute \"time\" had the value \"\(-\)1\" will now have the value \"\(-\)2\" and so on. Although this counting can be continued, it is enough to limit the count up to \"\(-\)2\". Fields that have reached their \"time\" count limit are considered not changed recently.