Java API for AI Space

Java API for AI Space

Sample for Creating AI Space XML

import org.json.JSONObject; import com.kyvos.commons.entity.reportobjects.Space; public class Main { public static void main(String[] args) { //Creating AI Space Object and setting the required fields for IRO Object Space space = new Space(); space.setName("AISpaceName"); space.setId("AISpaceID"); space.setFolderId("IdofAISpaceFolder"); space.setFolderName("FolderNameOfAISpace"); // Create the main "spaceEntities" object JSONObject spaceEntities = new JSONObject(); // Semantic model details needed to be added in AI Space JSONObject entityDetailsJSON = new JSONObject(); entityDetailsJSON.put("id", "332C952D-FC70-0BF5-9C4A-C2B9571BC1A5"); //id of semantic model entityDetailsJSON.put("name", "Retail Superstore"); //name of semantic model entityDetailsJSON.put("type", "SEMANTIC_MODEL"); //entity type (Possible value: SEMANTIC_MODEL always) entityDetailsJSON.put("categoryId", "folder_4ACA84C3-57A0-7891-180F-53750255C90A"); //Folder id of semantic model entityDetailsJSON.put("categoryName", "Business Catalog"); //Folder name of semantic model // Second semantic model needed to be added in AI Space JSONObject enity2DetailsJSON = new JSONObject(); enity2DetailsJSON.put("id", "51EDC3B6-B7E8-1A3A-B340-E382A719318A"); enity2DetailsJSON.put("name", "AdventureWorksMF"); enity2DetailsJSON.put("type", "SEMANTIC_MODEL"); enity2DetailsJSON.put("categoryId", "folder_4ACA84C3-57A0-7891-180F-53750255C90A"); enity2DetailsJSON.put("categoryName", "Business Catalog"); // Add both entities to "spaceEntities" // id of semantic model and JSON containing details of semantic model spaceEntities.put("332C952D-FC70-0BF5-9C4A-C2B9571BC1A5", entityDetailsJSON); spaceEntities.put("51EDC3B6-B7E8-1A3A-B340-E382A719318A", enity2DetailsJSON); // Create the root object JSONObject spaceEntitiesJSONObj = new JSONObject(); spaceEntitiesJSONObj.put("spaceEntities", spaceEntities); space.setSpaceEntity(spaceEntitiesJSONObj.toString()); //To get IRO XML of space object System.out.println(space.getXML()); } }

Copyright Kyvos, Inc. 2025. All rights reserved.