jira-integration: Move code part from updateWorkReportLine to updateOrCreateWorkReportLineAndAddToWorkReport

The code was being generated in 2 parts, first for the query and then to be set.
As in other cases if the WorkReportLine is found by code, we don't need to set
it again. So the part related to manage the code has been moved close to the
query and only set for newly created objects.

FEA: ItEr77S16JiraAndTimConnectorContributionIntegration
This commit is contained in:
Manuel Rego Casasnovas 2013-01-30 17:25:11 +01:00
parent 15bbcde0c4
commit e16ec15add

View file

@ -185,13 +185,14 @@ public class JiraTimesheetSynchronizer implements IJiraTimesheetSynchronizer {
for (WorkLogItem workLogItem : workLogItems) {
WorkReportLine workReportLine;
String code = orderElement.getCode() + "-" + workLogItem.getId();
try {
workReportLine = workReport
.getWorkReportLineByCode(orderElement.getCode() + "-"
+ workLogItem.getId());
workReportLine = workReport.getWorkReportLineByCode(code);
} catch (InstanceNotFoundException e) {
workReportLine = WorkReportLine.create(workReport);
workReport.addWorkReportLine(workReportLine);
workReportLine.setCode(code);
}
Resource resource = getWorker(workLogItem.getAuthor().getName());
@ -219,10 +220,8 @@ public class JiraTimesheetSynchronizer implements IJiraTimesheetSynchronizer {
OrderElement orderElement, WorkLogItem workLogItem,
Resource resource) {
String code = orderElement.getCode() + "-" + workLogItem.getId();
int timeSpent = workLogItem.getTimeSpentSeconds().intValue();
workReportLine.setCode(code);
workReportLine.setDate(workLogItem.getStarted());
workReportLine.setResource(resource);
workReportLine.setOrderElement(orderElement);