Hi all, As a component of my project (discussed in the mail thread "*Metadata model for supporting edge nodes in an IoT deployment*") it is required to create an API that would return the structure of a Device Organization connected to the IoT Server.
When being enrolled, the agents of each device informs the server who their parent is. Both the deviceID and the parentID of the device being enrolled are saved into a table at the time of enrollment. The structure of which is as follows; deviceID deviceName parentID lastContact state isGateway As shown the table structure is such that the parentID is saved against the deviceID. When generating the JSON hierarchy it was decided to take a layer-by-layer approach rather a depth-first approach. As such, the system will maintain 3 arrays; 1) An array that creates the hierarchy and returns it at program completion 2) An array to hold a list of an upper/parent device layer temporarily 3) An array to hold a list of a lower/child device layer temporarily. The algorithm for the hierarchy generation is as follows depicted in a flowchart; [image: Inline image 2] The compromise of this algorithm would be increased complexity due to having 3 arrays. Furthermore, another downside is that DB calls will be going out each time an iteration happens. Currently working on reducing the complexity and possibly DB calls as well. Suggestions and feedback are appreciated. -- *Nuwan Jayawardene* *Software Engineering Intern* *WSO2, Inc.:http://wso2.com <http://wso2.com/>* *lean.enterprise.middleware* *Mobile :- +94 71 1813299 <+94%2071%20181%203299>* - *Linkedin* *:- **https://www.linkedin.com/in/nuwa <https://www.linkedin.com/in/nuwanjaya/>**njaya/ <https://www.linkedin.com/in/nuwanjaya/>* - * <https://www.wso2.com/signature>*
_______________________________________________ Architecture mailing list Architecture@wso2.org https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture