We need a java servlet that will export all workitems for a project and type (project.id: AND created:[20220301 TO $today-2d$])in an excel in polarion. i need to do a compare of the existing workitems and new items that will be created using a new excel to find duplicate record before importing o new excel and creating new workitems.
Tried to get project but not the list of workitems in excel.
import java.util.List;
import javax.servlet.http.HttpServlet;
import org.apache.commons.collections4.CollectionUtils;
import com.polarion.alm.projects.IProjectService;
import com.polarion.alm.projects.model.IProject;
import com.polarion.alm.tracker.ITrackerService;
import com.polarion.alm.tracker.model.IWorkItem;
import com.polarion.platform.ITransactionService;
import com.polarion.platform.core.PlatformContext;
import com.polarion.platform.persistence.IDataService;
import com.polarion.platform.persistence.spi.PObject;
public class TestServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
private ITransactionService transactionService;
private IDataService dataService;
@Override
public void init() {
// load properties from disk, do be used by subsequent calls
transactionService = PlatformContext.getPlatform().lookupService(ITransactionService.class);
dataService = PlatformContext.getPlatform().lookupService(IDataService.class);
}
public void getProjectWorkItem() {
IProjectService projectService = (IProjectService) PlatformContext.getPlatform()
.lookupService(IProjectService.class);
ITrackerService trackerService = (ITrackerService) PlatformContext.getPlatform()
.lookupService(ITrackerService.class);
List<IProject> projects = projectService.searchProjects("mytest");
if (CollectionUtils.isNotEmpty(projects)) {
// IProject projectSingle = projects.get(0).getId();
IWorkItem workItem = trackerService.findWorkItem("mytest", "task");
System.out.println("workItem");
}
System.out.println("workItem");
}
}