using System; using TestFramework.ApplicationAPI; using TestFramework.AuthenticateAPI; using TestFramework; namespace Tests.resource { /// <summary> /// Summary description for ResourceIndusExp. /// /// this sample creates an industry experience /// and assigns it to an existing resource. /// </summary> public class ResourceIndusExp { public ResourceIndusExp() { } //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 industry experience ResourceScope rScope = new ResourceScope(); // adjust resource scope to keep relation rScope.industryExperiences = true; // create an industry experience IndustryExperience iExp = new IndustryExperience(); // 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 industry experience with default values // assign a classification from RPM repository iExp.classification = (Classification)APISetup. application.loadFromXpath(sessionid, "/Classification", null ).rpmObjectList[0]; // assign an industry type iExp.industry = (IndustryType)APISetup.application. loadFromXpath(sessionid, "/Industrytype", null ). rpmObjectList[0]; // assign the resource to the industry // experience as the parent iExp.parent = res; // assign a proficiency level iExp.proficiency = (ProficiencyLevel)APISetup. application.loadFromXpath(sessionid, "/Proficiencylevel", null ).rpmObjectList[0]; // assign the industry experience to the ressource res.industryExperiences = new IndustryExperience[] {iExp}; // save the resource in the RPM repository // use the sessionid acquired in the setUp // use a resource scope to relate with // industry experiences SaveResult save = APISetup.application.save(sessionid, res, rScope, ReloadType.SavedResult ); APISetup.checkForErrors( save ); // end the communication with the api. APISetup.CleanUp(sessionid); } } }