You can use the Cognos SDK to load your Framework Manager model into memory and then parse or search the xml model schema. For example, say if you wanted to build a small utility to determine the data that a query subject item was last changed. Then you would load the model and search for the specific XML node and view its current value. If you continue to expand on this concept then you can come up with developing your own version control monitory utility.
Don’t forget to place your TRY-CATCH logic around your test app!
private void getModel(String packageSearchPath){
propEnum[] props = new propEnum[] { propEnum.searchPath, propEnum.model };
baseClass[] model = null;
searchPathMultipleObject spMulti = new searchPathMultipleObject();
spMulti.Value = packageSearchPath + "/model";
//you need to append the model with a valid XML header
string strXMLHeader = "<?xml version=" + "\"" + "1.0" + "\"" + " encoding=" + "\"" + "UTF-8" + "\"" + " ?>";
string strXMLModel = null;
//query the content store to retrieve the model
model = cmService.query(spMulti, props, new sort[]{}, new queryOptions());
//iterate through the model schema
for (int i = 0; i < model.Length; i++){
strXMLModel = strXMLHeader + ((model)model[i]).model1.value;
XmlDocument docXML = new XmlDocument();
docXML.LoadXml(strXMLModel);
//you could also call an existing model file to simplify the process
//docXML.Load("C:\\MODELS\\XML Datasource Sample\\model.xml");
XmlNode node;
node = docXML.DocumentElement;
foreach (XmlNode node1 in node.ChildNodes)
foreach (XmlNode node2 in node1.ChildNodes)
//for example purposes we’ll retrieve the project xml node. Open your model file in Notepad or any XML viewer to review the model XML schema structure.
if (node2.Name == "lastchanged")
{
string strProject = node2.InnerText;
string strNewProject = "lastUpdateWasAppliedAtThisTime";
//for example purposes were just going to update the existing value
node2.InnerText = strNewProject;
}
//save the updated xml file
docXML.Save("C:\\MyUpdatedModel.xml");
}