using System; using TestFramework.ApplicationAPI; using TestFramework.AuthenticateAPI; using TestFramework; namespace Tests.resource { /// <summary> /// Summary description for ResourceLang. /// /// this samples creates a Language proficiency /// and assigns it to a resource in RPM repository /// </summary> public class ResourceLang { public ResourceLang() { } //All these variables are used in this sample public static String resourceName = "IBM_testABCDEF"; //Session ID is use for all transaction and is get from the //Authenticate.login function. The session ID will replace // the User password while transacting public static String sessionid = ""; public void sampleTest() { // start the communication with the api sessionid = APISetup.SetUp(); // Declare the resource wich we are going to use Resource res = null; // create a resourceScope to keep track of the relation // between the resource and the language proficiency ResourceScope rScope = new ResourceScope(); // adjust resource scope to keep relation rScope.languageProficiencies = true; // create a language proficiency LanguageProficiency lProf = new LanguageProficiency(); // Find the resource in RPM using XPath. // take resource in RPM repository by its fullname // or externalid res = (Resource)APISetup.application. loadFromXpath(sessionid, "/Resource[fullname='" + resourceName + "']", rScope ).rpmObjectList[0]; // initialise the Language proficiency with default // values assign a language from RPM repository lProf.language = (Language)APISetup.application. loadFromXpath(sessionid, "/Language", null ). rpmObjectList[0]; // assign levels of qualification lProf.readLevel = 1; lProf.speakLevel = 1; lProf.writeLevel = 1; // assign the resource to the language proficiency // as the parent lProf.parent = res; // assign the language proficiency to the ressource res.languageProficiencies = new LanguageProficiency[] {lProf}; // save the resource in the RPM repository // use the sessionid acquired in the setUp // use a resource scope to relate with // language proficiency SaveResult save = APISetup.application.save(sessionid, res, rScope, ReloadType.SavedResult ); APISetup.checkForErrors( save ); // end the communication with the api. APISetup.CleanUp(sessionid); } } }