Java API for Designing Semantic model
Applies to: Kyvos Enterprise Kyvos Cloud (SaaS on AWS) Kyvos AWS Marketplace
Kyvos Azure Marketplace Kyvos GCP Marketplace Kyvos Single Node Installation (Kyvos SNI)
Overview
Create a Semantic model object by passing a DRD name in the API.
Kyvos fetches the DRD Object, validates it, and sets it in the Semantic model objectAdd a dimension to this Semantic model.
To add more dimensions, call this API, which in turn will add the dimension to the internal listAdd a hierarchy to this dimension.
Add a level to this hierarchy.
To add more levels, call this API, which in turn will add the levels to the internal listAdd an attribute to the Semantic model.
To add more attributes, call this API, which in turn will add the attribute to the internal listCreate a UserInfo object, to be used for authorizing the requester.
Create measure groups and measures.
Call the API to save the Semantic model object in the repository.
Retrieve existing Semantic model objects from the repository by name.
Get measure, dimension, hierarchy, level, and attribute by name.
Update an existing Semantic object.
Use smart recommendations for designing semantic model.
Example
Create the Semantic model Object.
/* * method to create new semantic model object in Repository Manager. * @param drdName: Name of the DRD. * @param requestorUserInfo: Object of type UserInfo. * @return cubeObject: Object of type CubeObject. */ public CubeObject createCubeObject(String drdName, UserInfo requestorUserInfo); /** * method to create new semantic model object from DRD inside a folder in Repository Manager. * @param drdName: Name of the DRD. * @param drdFolderdName: Name of the folder that contains DRD. * @param requestorUserInfo: Object of type UserInfo containing information about logged in user. * @return cubeObject: Object of type CubeObject. */ public CubeObject createCubeObject(String drdName, String drdFolderdName, UserInfo requestorUserInfo);APIs to create dimension, hierarchy, and level objects.
/** * method to add dimension. * @param dimensionName: Name of the dimension. * @return Dimension: Object of type Dimension. */ public Dimension addDimension(String dimensionName); /* * method to add hierarchy in the dimension. * @param hierarchyName: Name of the hierarchy. * @return Hierarchy: Object of type Hierarchy. */ public Hierarchy addHierarchy(String hierarchyName); /* * method to add new level in hierarchy with field. * @param datasetName: Name of the dataset to associated. * @param fieldName: Data field to be associated. * @return Level: Object of type Level. */ public Level addLevel(String datasetName, String fieldName); /** * method to add new level in hierarchy with field and display field. * @param datasetName Name of the dataset to associated with field. * @param fieldName name of the field. * @param dispalyFieldDatasetName Name of the dataset to associated with display field. * @param displayFieldName name of the display field. * @return level: Object of type Level. */ public Level addLevelWithDisplayField(String datasetName, String fieldName, String dispalyFieldDatasetName, String displayFieldName);Create the Attribute object.
/* * @param datasetName: Name of the dataset to associated. * @param fieldName: Data field to be associated. * @return dimAttribute: Object of type DimAttribute. */ public DimAttribute addDimAttribute(String datasetName, String fieldName);Refer to step 4 under the Steps for using Java APIs section to create UserInfo object.
Create Measure Groups and Measures.
/* * @return MeasureGroups: Object of type MeasureGroups. */ public MeasureGroups addMeasureGroups(); /** * @param datasetName: Name of the dataset to associated. * @param fieldName: Data field to be associated. * @return Measure: Object of Measure type. */ public Measure addMeasure(String datasetName, String fieldName); /** * method to add measure in specified measure group. * @param datasetName: Name of the dataset to associated. * @param fieldName: Data field to be associated. * @param measureGroupName: name of the measure group in which measure has to be added will create new measure group with measureGroupName if does not exist. * @return Measure: Object of Measure type. */ public Measure addMeasureInMeasureGroup(String datasetName, String fieldName, String measureGroupName); /** * method to add measure in specified measure group. * @param datasetName: Name of the dataset to associated. * @param fieldName: Data field to be associated. * @param measureGroupName: name of the measure group in which measure has to be added will create new measure group with measureGroupName if does not exist. * @return Measure: Object of Measure type. */ public Measure addMeasureInMeasureGroup(String datasetName, String fieldName, String measureGroupName);Add the Semantic model object to the repository.
/** * method to add semantic model object in Repository Manager. * @param cubeObj: Object of type CubeObject. * userInfo: Object of type UserInfo containing information about logged in user. * @return ResponseStatus. */ public ResponseStatus addCubeObject(CubeObject cubeObj, UserInfo userInfo); ** * method to add Cube object inside folder in Repository Manager. * @param cubeObj: Object of type CubeObject. * @param folderName: Name of the folder in which CubeObject has to be added. * userInfo: Object of type UserInfo containing information about logged in user. * @return ResponseStatus. */ public ResponseStatus addCubeObject(CubeObject cubeObj, String folderName, UserInfo userInfo);API to retrieve existing Semantic model object from repository by name.
/** * method to get semantic model object by its name in the Repository Manager. * @param sModelName: Name of the semantic model. * @param userInfo: Object of type UserInfo containing information about logged in user. * @return cubeObj Object of type CubeObject. */ public CubeObject getCubeByName(String sModelName, UserInfo userInfo); /** * method to get Cube object by cube name and folder name in Repository Manager. * @param sModelName: Name of the semantic model. * @param folderName: Name of the folder that contains cube object. * @param userInfo: Object of type UserInfo containing information about logged in user. * @return cubeObj Object of type CubeObject. */ public CubeObject getCubeByName(String sModelName,String folderName,UserInfo userInfo);Get measure, dimension, hierarchy, level, and attribute by names.
API to get Measure by name
/** * Gets the measure by name. * @param measureName: Name of the measure. * @return the measure by name. */ public Measure getMeasureByName(String measureName);API to get Dimension by name
/** * Gets the dimension by name. * @param dimName: Name of the dimension. * @return the dimension by name. */ public Dimension getDimensionByName(String dimName);API to get Hierarchy from Dimension
/** * method to get Hierarchy Object in Dimension. * @return hierarchy Object of type Hierarchy. */ public Hierarchy getHierarchy();API to get Level by level name from semantic model object
/** * Gets the level by name. * @param dimension: object of type Dimension from which level has to be fetched. * @param levelName: Name of the level. * @return the level by name. */ public Level getLevelByLevelName(Dimension dimension, String levelName);API to get Attribute by attribute name from semantic model object
/** * Gets the DimAttribute by name. * @param dimension object of type Dimension from which level has to be fetched. * @param attributeName: Name of the dimension. * @return the dimension by name. */ public DimAttribute getDimAttributeByName(Dimension dimension, String attributeName);
API to update existing semantic model object.
/** * method to update existing semantic model object in Repository Manager. * @param cubeObj: Object of type CubeObject. */ public void updateCubeObject(CubeObject cubeObj, UserInfo userInfo);API to use smart recommendations for designing semantic model.
/** * method to get smart recommendation of semantic model in EntityObjectManager . * @param sModelName: Name of the semantic model. * @param folderName: Name of the folder containing cube, use “” for root folder. * @param queryDays: Get recommendation based on queries run on past X number of days. * @param orientation: Scale of optimizing orientation , semantic model size vs query response time.Possible values (-2 to 2). Plus value incline towards optimizing build size and vice versa. * @param userInfo: Object of type UserInfo containing information about logged in user. */ public RecommendationData getAllCubeRecommendations(String sModelName, String folderName, int queryDays, int orientation, UserInfo userInfo); public RecommendationData getPhysicalViewRecommendations(String sModelName, String folderName, int queryDays, int orientation, UserInfo userInfo); public RecommendationData getPropertiesRecommendations(String sModelName, String folderName, int queryDays, int orientation, UserInfo userInfo); public RecommendationData getPartitionRecommendations(String sModelName, String folderName, int queryDays, int orientation, UserInfo userInfo;Method to add Attribute through display field (under design semantic model)
/* * method to add Attribute through display field * @param datasetName: Name of the dataset to associated. * @param fieldName: Data field to be associated. * @param displayFieldDatasetName : Name of the dataset to associated with display field. * @param displayFieldName name of the display field. @return dimAttribute: Object of type DimAttribute. */ public addDimAttributeWithDisplayField(String datasetName, String fieldName, String displayFieldDatasetName, String displayFieldName)API to use smart recommendations for designing semantic model (update).
/* @param lastBuildType: Type of the build, FULL or INCREMENTAL. @param lastBuildHistoryId: History ID of the last full/incremental semantic model job. @param sModelName: Name of the semantic model. @param folderName: Name of the folder containing semantic model, use “” for root folder. @param queryDays: Get recommendation based on queries run on past X number of days. @param orientation: Scale of optimizing orientation, cube size vs query response time.Possible values (-2 to 2). Plus value incline towards optimizing build size and vice versa. @param userInfo: Object of type UserInfo containing information about logged in user. */ public RecommendationData getAllCubeRecommendations(String sModelName, String folderName, int queryDays, int orientation,String lastBuildType, String lastBuildHistoryId, UserInfo userInfo); public RecommendationData getPhysicalViewRecommendations(String sModelName, String folderName, int queryDays, int orientation,String lastBuildType, String lastBuildHistoryId, UserInfo userInfo); public RecommendationData getPropertiesRecommendations(String sModelName, String folderName, int queryDays, int orientation,String lastBuildType, String lastBuildHistoryId,UserInfo userInfo); public RecommendationData getPartitionRecommendations(String sModelNamecubeName, String folderName, int queryDays, int orientation,String lastBuildType, String lastBuildHistoryId,UserInfo userInfo;API to save smart recommendation of semantic model in EntityObjectManager.
/* @param requestXML: Response XML Received from get Recommendation methods. @param userInfo: Object of type UserInfo containing information about logged in user. */ public ResponseStatus saveRecommendations(String requestXML,UserInfo userInfo);API to use smart recommendations for designing semantic model (Update)
Introduced one more Parameter (Aggregation type) in getAllRecommnedation JAVA API/* @param lastBuildType: Type of the job, FULL or INCREMENTAL. @param lastBuildHistoryId: History ID of the last full/incremental semantic model job. @param sModelName: Name of the semantic model. @param folderName: Name of the folder containing semantic model, use “” for the root folder. @param queryDays: Get recommendation based on queries run on the past X number of days. @param Aggregation Type: Get recommendation on type of aggregation (ALL,ONLY_AGGREGATION,ONLY_NEW_AGGREGATION) @param orientation: Scale of optimizing orientation, semantic model size vs query response time.Possible values (-2 to 2). Plus value incline towards optimizing build size and vice versa. @param userInfo: Object of type UserInfo containing information about logged in user. @return Recommendation: Recommendation class object */ public RecommendationData getAllCubeRecommendations(String sModelName, String folderName, int queryDays, int orientation,String lastBuildType, String lastBuildHistoryId, String aggregationType,UserInfo userInfo);API to get only Aggregation type smart recommendation on designing semantic model.
/* @param lastBuildType: Type of the build, FULL or INCREMENTAL. @param lastBuildHistoryId: history id of last full/incremental cube build. @param sModelName: Name of the semantic model. @param folderName: Name of the folder containing semantic model, use “” for root folder. @param queryDays: Get recommendation based on queries run on the past X number of days. @param Aggregation Type: Get recommendation on type of aggregation (ALL,ONLY_AGGREGATION,ONLY_NEW_AGGREGATION) @param orientation: Scale of optimizing orientation, cube size vs query response time.Possible values (-2 to 2). Plus value incline towards optimizing build size and vice versa. @param userInfo: Object of type UserInfo containing information about logged in user. @return Recommendation: Recommendation class object */ public RecommendationData getAggregatesRecommendations (String sModelName, String folderName, int queryDays, int orientation,String lastBuildType, String lastBuildHistoryId, String aggregationType,UserInfo userInfo);API to add a dimension.
/** * Method to add a Dimension. * @param Dimension dim */ public void addDimension(Dimension dim)Dimension to add time type hierarchy.
/** * Method to add Time Hierarchy * @param hierarchyName: Name of the hierarchy * @param timeHierarchyType: Type of the time hierarchy * @param datasetName: Name of the dataset to associated * @param fieldName: Data field to be associated * @return Hierarchy: Object of newly added Hierarchy */ public Hierarchy addTimeHierarchy(String hierarchyName, String timeHierarchyType, String dataSetName, String fieldName)Dimension to add hierarchy in a dimension.
/** * Method to add a Hierarchy. * @param Hierarchy hierarchy */ public void addHierarchy(Hierarchy hierarchy)Hierarchy to add a level object in the hierarchy.
/** * Method to add a Level. * @param Level level */ public void addLevel(Level level)
Sample code
/*Method to design semantic model and Add it to Kyvos*/
public static void designCube(RepositoryManager repManager, UserInfo userInfo) {
CubeObject cubeObject;
try {
cubeObject = repManager.createCubeObject("DRDName", "DRDFolderName", userInfo);
Dimension add = cubeObject.addDimension("DimensionName");
Hierarchy hierarchy = add.addHierarchy("HierarchyName");
hierarchy.addLevel("NodeName", "FieldName");
add.addDimAttribute("NodeName", "Field");
cubeObject.addMeasureGroups("MeasureGroupName");
com.kyvos.commons.entity.olap.Measure measure = cubeObject.addMeasureInMeasureGroup("DRDName", "FieldName", "MeasureGroupName");
measure.setIsDefault(true);
cubeObject.setName("sModelName");
cubeObject.setFolderName("sModelFolderName");
cubeObject.setFolderID("sModelNameFolderID");
repManager.addCubeObject(cubeObject, "sModelNameName", userInfo);
} catch (ReportObjectException e) {
e.printStackTrace();
}
}