To execute the example, in the HEAD tag of the HTML page add links to the following JS and CSS files:
PP.js.
PP.Metabase.js.
PP.Import.js;
resources file (such as resources.en)
PP.css.
Add the DIV element with the div1 identifier in the BODY tag.
Add the following script in the SCRIPT tag:
function onLoad()
{
var importDataWizard; // data import wizard
var monitorDiv = document.getElementById('div1');
PP.resourceManager.setRootResourcesFolder("resources/"); // path to the folder with text resources
PP.setCurrentCulture(PP.Cultures.ru); // current locale - Russian
PP.ImagePath = "build/img/"; // path to the folder with text resources
PP.ScriptPath = "build/"; // path to the folder with scripts for loading (PP.TabSheet.js)
PP.CSSPath = "build/"; // path to the folder with css
function _onMetabaseOpened(sender, args)
{
//corresponding message is displayed on the page
monitorDiv.innerHTML += "<br/>Repository is opened.";
//service for working with import object
var dataImportService = new PP.Mb.DataImportService({ Metabase: mb });
//event generated on import completion
dataImportService.ImportCompleted.add(_onImportCompleted, dataImportService);
//create a data import wizard
importDataWizard = new PP.Mb.Ui.ImportDataWizard({
ParentNode: document.body,
CubeImport: dataImportService.openCubeImport(),
FileUploadUrl: mb.getImportUrl(),
DefaultImportFolderDesc: { k: 206035, i: null, n: null, c: 0 } // Place import result in the folder with the 206035 key
});
importDataWizard.show();
importDataWizard.updateSize();
}
//when import is finished successfully and when import is finished with error, the page displays corresponding messages
function _onImportCompleted(sender, args)
{
monitorDiv.innerHTML += "<br/>Import is finished";
if (args.CubeInfo)
monitorDiv.innerHTML += "<br/>successfully. Object identifier: " + args.CubeInfo.i + "<br/>File name: " + importDataWizard.getCubeImport().getFileName() + ".";
else
monitorDiv.innerHTML += "<br/> with error. Error identifier: \"" + args.ErrorInfo.id + "\". Error text: \"" + args.ErrorInfo.message + "\"";
}
//repository connection
var mb = new PP.Mb.Metabase(
{
PPServiceUrl: "http://localhost/FPBI_App_v10.x/axis2/services/PP.SOM.Som",
Id: "Repository",
UserCreds: {
UserName: "user",
Password: "password"
}
});
document.getElementById("div1").innerHTML += "Opening repository…";
mb.open(_onMetabaseOpened);
}
After executing the example the data import wizard opens on the page. After the user follows all steps of the wizard and clicks Done on the last stage, the HTML page shows a message that informs if the import is successful or not.
See also: