Hi All,
I was trying to programatically create a Project room template using SAP_Project_Template. I was able to do that. I was wondering whether we can create a task & assin that task to any user using any API ?
Below is the code for that :
package com.tcs.aditya.raj2;
import com.sapportals.portal.prt.component.AbstractPortalComponent;
import com.sapportals.portal.prt.component.IPortalComponentRequest;
import com.sapportals.portal.prt.component.IPortalComponentResponse;
//imports for User Management
import com.sap.security.api.IUser;
import com.sap.security.api.UMFactory;
//imports for Portal
import com.sapportals.portal.prt.runtime.PortalRuntime;
//imports for Collaboration Rooms
import com.sap.ip.collaboration.room.api.IRoomInfo;
import com.sap.ip.collaboration.room.api.IRooms;
//import com.sap.ip.collaboration.room.api.IRoom;
import com.sap.ip.collaboration.room.api.IRoomCategoryFactory;
import com.sap.ip.collaboration.room.api.IRoomCategory;
import com.sap.ip.collaboration.room.api.template.IRoomRole;
import com.sap.ip.collaboration.room.api.template.ITemplate;
import com.sap.ip.collaboration.room.api.types.RoomPrivacyType;
public class RoomCreationTesting extends AbstractPortalComponent
{
IRoomInfo roomInfo;
public void doContent(IPortalComponentRequest request, IPortalComponentResponse response) {
try {
String templateName = "SAP_Project_Template";
String roleName1 = "Admin";
String roleName2 = "Member";
IRooms roomsAPI = (IRooms) PortalRuntime.getRuntimeResources().getService(IRooms.PORTAL_SERVICE_ID);
IRoomCategoryFactory categoryName = roomsAPI.getRoomCategoryFactory();
IRoomCategory[] categoryInfo= categoryName.getRoomCategories();
//Get Template Related Infos
ITemplate template = roomsAPI.getRoomTemplate(templateName);
IRoomRole role1= template.getRoomRole(roleName1);
IRoomRole role2= template.getRoomRole(roleName2);
//Get an empty RoomInfo object
roomInfo = roomsAPI.getRoomCreationInfo();
//Fill RoomInfo object with values
roomInfo.setName("Programme ROOM_withDoc");
roomInfo.setDescription("New Room Description");
roomInfo.setTemplateName(templateName);
roomInfo.setCategories(categoryInfo);
roomInfo.addRoomParameter("Objectives","desc1","objective", false);
roomInfo.addRoomParameter("Start Date","desc2", "s date", false);
roomInfo.addRoomParameter("Target Date", "desc3","t date", false);
roomInfo.addRoomParameter("Initiatives", "desc4","initiatives", false);
roomInfo.addRoomParameter("Mission", "desc5", "mission", false);
roomInfo.addRoomParameter("Goal", "desc6","goal", false);
roomInfo.setPrivacy(RoomPrivacyType.DEFAULT);
//Set User Role Assignments
IUser owner = UMFactory.getUserFactory().getUserByLogonID("vishal");
IUser owner2 = UMFactory.getUserFactory().getUserByUniqueName("aditya");
roomInfo.setOwnerId(owner.getUniqueID());
roomInfo.addUserToRole(owner.getUniqueID(), role1);
roomInfo.addUserToRole(owner2.getUniqueID(), role2);
//Finally Create the Room
if(roomInfo.validate())
{
roomsAPI.createRoom(roomInfo, false);
response.write("/////room created sucessfully////");
//from here i want to create tasks
}
} catch ( Throwable e ) {
// Display exception
//response.write(roomInfo.g);
response.write("Application encountered an internal exception:" );
response.write(e.getMessage() );
e.printStackTrace( System.err );
response.write(e.toString());
//response.write(System.err);
} // catch
}
}
After creating the room, i want to create tasks...is it possbile to do that ? if yes how ?
Thanks,
Regards,
Aditya Metkul