jira-integration: Move code prefix for JIRA entities to a constant
As the same prefix is used in several files it has been defined as a constant in JiraConfiguration. FEA: ItEr77S16JiraAndTimConnectorContributionIntegration
This commit is contained in:
parent
d2fe100ca3
commit
89e9a58b6b
5 changed files with 23 additions and 13 deletions
|
|
@ -23,6 +23,11 @@ import org.libreplan.business.common.BaseEntity;
|
|||
|
||||
public class JiraConfiguration extends BaseEntity {
|
||||
|
||||
/**
|
||||
* Code prefix for different entities integrated with JIRA.
|
||||
*/
|
||||
public static final String CODE_PREFIX = "JIRA-";
|
||||
|
||||
public static JiraConfiguration create() {
|
||||
return create(new JiraConfiguration());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ import org.libreplan.business.advance.entities.DirectAdvanceAssignment;
|
|||
import org.libreplan.business.advance.exceptions.DuplicateAdvanceAssignmentForOrderElementException;
|
||||
import org.libreplan.business.advance.exceptions.DuplicateValueTrueReportGlobalAdvanceException;
|
||||
import org.libreplan.business.common.daos.IConfigurationDAO;
|
||||
import org.libreplan.business.common.entities.JiraConfiguration;
|
||||
import org.libreplan.business.orders.entities.HoursGroup;
|
||||
import org.libreplan.business.orders.entities.Order;
|
||||
import org.libreplan.business.orders.entities.OrderElement;
|
||||
|
|
@ -52,8 +53,6 @@ import org.springframework.transaction.annotation.Transactional;
|
|||
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
|
||||
public class JiraOrderElementSynchronizer implements IJiraOrderElementSynchronizer {
|
||||
|
||||
private static final String CODE_PREFIX = "JIRA-";
|
||||
|
||||
@Autowired
|
||||
private IConfigurationDAO configurationDAO;
|
||||
|
||||
|
|
@ -102,7 +101,8 @@ public class JiraOrderElementSynchronizer implements IJiraOrderElementSynchroniz
|
|||
jiraSyncInfo = new JiraSyncInfo();
|
||||
|
||||
for (Issue issue : issues) {
|
||||
String code = CODE_PREFIX + order.getCode() + "-" + issue.getKey();
|
||||
String code = JiraConfiguration.CODE_PREFIX + order.getCode() + "-"
|
||||
+ issue.getKey();
|
||||
String name = issue.getFields().getSummary();
|
||||
|
||||
syncOrderLine(order, code, name);
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import java.util.Set;
|
|||
|
||||
import org.hibernate.NonUniqueResultException;
|
||||
import org.libreplan.business.common.IAdHocTransactionService;
|
||||
import org.libreplan.business.common.entities.JiraConfiguration;
|
||||
import org.libreplan.business.common.exceptions.InstanceNotFoundException;
|
||||
import org.libreplan.business.costcategories.daos.ITypeOfWorkHoursDAO;
|
||||
import org.libreplan.business.costcategories.entities.TypeOfWorkHours;
|
||||
|
|
@ -56,8 +57,6 @@ import org.springframework.transaction.annotation.Transactional;
|
|||
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
|
||||
public class JiraTimesheetSynchronizer implements IJiraTimesheetSynchronizer {
|
||||
|
||||
private static String CODE_PREFIX = "JIRA-";
|
||||
|
||||
private JiraSyncInfo jiraSyncInfo;
|
||||
|
||||
private List<Worker> workers;
|
||||
|
|
@ -139,8 +138,8 @@ public class JiraTimesheetSynchronizer implements IJiraTimesheetSynchronizer {
|
|||
+ issue.getKey() + "' issue");
|
||||
} else {
|
||||
|
||||
String codeOrderElement = CODE_PREFIX + order.getCode() + "-"
|
||||
+ issue.getKey();
|
||||
String codeOrderElement = JiraConfiguration.CODE_PREFIX
|
||||
+ order.getCode() + "-" + issue.getKey();
|
||||
|
||||
OrderElement orderElement = order.getOrderElement(codeOrderElement);
|
||||
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ import org.libreplan.business.advance.exceptions.DuplicateValueTrueReportGlobalA
|
|||
import org.libreplan.business.common.IAdHocTransactionService;
|
||||
import org.libreplan.business.common.IOnTransaction;
|
||||
import org.libreplan.business.common.daos.IConfigurationDAO;
|
||||
import org.libreplan.business.common.entities.JiraConfiguration;
|
||||
import org.libreplan.business.common.exceptions.InstanceNotFoundException;
|
||||
import org.libreplan.business.orders.daos.IOrderDAO;
|
||||
import org.libreplan.business.orders.entities.HoursGroup;
|
||||
|
|
@ -207,7 +208,8 @@ public class JiraOrderElementSynchronizerTest {
|
|||
OrderVersion version = setupVersionUsing(scenarioManager, order);
|
||||
order.useSchedulingDataFor(version);
|
||||
for (Issue issue : issues) {
|
||||
String code = "JIRA-" + order.getCode() + "-" + issue.getKey();
|
||||
String code = JiraConfiguration.CODE_PREFIX + order.getCode() + "-"
|
||||
+ issue.getKey();
|
||||
String name = issue.getFields().getSummary();
|
||||
|
||||
syncOrderLine(order, code, name);
|
||||
|
|
@ -374,7 +376,8 @@ public class JiraOrderElementSynchronizerTest {
|
|||
public void testSyncOrderElementsOfAnExistingOrderWithNoOrderLines() {
|
||||
Order order = givenOrder();
|
||||
for (Issue issue : issues) {
|
||||
String code = "JIRA-" + order.getCode() + "-" + issue.getKey();
|
||||
String code = JiraConfiguration.CODE_PREFIX + order.getCode() + "-"
|
||||
+ issue.getKey();
|
||||
String name = issue.getFields().getSummary();
|
||||
|
||||
syncOrderLine(order, code, name);
|
||||
|
|
@ -396,7 +399,8 @@ public class JiraOrderElementSynchronizerTest {
|
|||
Order order = givenOrderWithValidOrderLines();
|
||||
Integer workingHours = order.getWorkHours();
|
||||
for (Issue issue : issues) {
|
||||
String code = "JIRA-" + order.getCode() + "-" + issue.getKey();
|
||||
String code = JiraConfiguration.CODE_PREFIX + order.getCode() + "-"
|
||||
+ issue.getKey();
|
||||
String name = issue.getFields().getSummary();
|
||||
|
||||
syncOrderLine(order, code, name);
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ import org.libreplan.business.IDataBootstrap;
|
|||
import org.libreplan.business.common.IAdHocTransactionService;
|
||||
import org.libreplan.business.common.IOnTransaction;
|
||||
import org.libreplan.business.common.daos.IConfigurationDAO;
|
||||
import org.libreplan.business.common.entities.JiraConfiguration;
|
||||
import org.libreplan.business.common.exceptions.InstanceNotFoundException;
|
||||
import org.libreplan.business.costcategories.entities.TypeOfWorkHours;
|
||||
import org.libreplan.business.orders.daos.IOrderDAO;
|
||||
|
|
@ -185,7 +186,8 @@ public class JiraTimesheetSynchronizerTest {
|
|||
OrderVersion version = setupVersionUsing(scenarioManager, order);
|
||||
order.useSchedulingDataFor(version);
|
||||
for (Issue issue : issues) {
|
||||
String code = "JIRA-" + order.getCode() + "-" + issue.getKey();
|
||||
String code = JiraConfiguration.CODE_PREFIX + order.getCode() + "-"
|
||||
+ issue.getKey();
|
||||
String name = issue.getFields().getSummary();
|
||||
|
||||
OrderLine orderLine = OrderLine
|
||||
|
|
@ -336,8 +338,8 @@ public class JiraTimesheetSynchronizerTest {
|
|||
List<WorkLogItem> workLogItems = worklog.getWorklogs();
|
||||
if (workLogItems != null && !workLogItems.isEmpty()) {
|
||||
|
||||
String code1 = "JIRA-" + order.getCode() + "-"
|
||||
+ issue.getKey();
|
||||
String code1 = JiraConfiguration.CODE_PREFIX
|
||||
+ order.getCode() + "-" + issue.getKey();
|
||||
|
||||
OrderElement orderElement = order.getOrderElement(code1);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue