jira-integration: Add predefined WorkReportType for JIRA connector
* The predefined type will have a line description value to store comments in each line. * As for the case of personal timesheets the new type will be hidden for the users in the list of timesheets templates. FEA: ItEr77S16JiraAndTimConnectorContributionIntegration
This commit is contained in:
parent
f3bec8193f
commit
52a0e89071
6 changed files with 48 additions and 4 deletions
|
|
@ -19,6 +19,8 @@
|
|||
*/
|
||||
package org.libreplan.business.workreports.entities;
|
||||
|
||||
import org.libreplan.business.workreports.valueobjects.DescriptionField;
|
||||
|
||||
/**
|
||||
* Defines the default {@link WorkReportType WorkReportTypes}.
|
||||
*
|
||||
|
|
@ -27,7 +29,9 @@ package org.libreplan.business.workreports.entities;
|
|||
*/
|
||||
public enum PredefinedWorkReportTypes {
|
||||
DEFAULT("Default", false, false, false),
|
||||
PERSONAL_TIMESHEETS("Personal timesheets", false, true, false);
|
||||
PERSONAL_TIMESHEETS("Personal timesheets", false, true, false),
|
||||
JIRA_TIMESHEETS("JIRA timesheets", false, false, false,
|
||||
DescriptionField.create("Comment", 255));
|
||||
|
||||
private WorkReportType workReportType;
|
||||
|
||||
|
|
@ -41,6 +45,15 @@ public enum PredefinedWorkReportTypes {
|
|||
.setOrderElementIsSharedInLines(orderElementIsSharedInLines);
|
||||
}
|
||||
|
||||
private PredefinedWorkReportTypes(String name, boolean dateIsSharedByLines,
|
||||
boolean resourceIsSharedInLines,
|
||||
boolean orderElementIsSharedInLines,
|
||||
DescriptionField lineDescriptionField) {
|
||||
this(name, dateIsSharedByLines, resourceIsSharedInLines,
|
||||
orderElementIsSharedInLines);
|
||||
workReportType.addDescriptionFieldToEndLine(lineDescriptionField);
|
||||
}
|
||||
|
||||
public WorkReportType getWorkReportType() {
|
||||
return workReportType;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -532,4 +532,11 @@ public class WorkReportType extends IntegrationEntity implements IHumanIdentifia
|
|||
.getName());
|
||||
}
|
||||
|
||||
public boolean isJiraTimesheetsType() {
|
||||
if (StringUtils.isBlank(name)) {
|
||||
return false;
|
||||
}
|
||||
return name.equals(PredefinedWorkReportTypes.JIRA_TIMESHEETS.getName());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,6 +60,7 @@ public class WorkReportTypeBootstrap implements IWorkReportTypeBootstrap {
|
|||
}
|
||||
} else {
|
||||
createPersonalTimesheetsWorkReportTypeIfNeeded();
|
||||
createJiraTimesheetsWorkReportTypeIfNeeded();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -86,4 +87,16 @@ public class WorkReportTypeBootstrap implements IWorkReportTypeBootstrap {
|
|||
}
|
||||
}
|
||||
|
||||
private void createJiraTimesheetsWorkReportTypeIfNeeded() {
|
||||
try {
|
||||
workReportTypeDAO
|
||||
.findUniqueByName(PredefinedWorkReportTypes.JIRA_TIMESHEETS
|
||||
.getName());
|
||||
} catch (NonUniqueResultException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (InstanceNotFoundException e) {
|
||||
createAndSaveWorkReportType(PredefinedWorkReportTypes.JIRA_TIMESHEETS);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ public interface IWorkReportTypeModel extends IIntegrationEntityModel {
|
|||
*
|
||||
* @return A {@link List} of {@link WorkReportType}
|
||||
*/
|
||||
List<WorkReportType> getWorkReportTypesExceptPersonalTimeSheets();
|
||||
List<WorkReportType> getWorkReportTypesExceptPersonalAndJiraTimesheets();
|
||||
|
||||
/**
|
||||
* Stores the current {@link WorkReportType}.
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ public class WorkReportTypeCRUDController extends BaseCRUDController<WorkReportT
|
|||
private OrderedFieldsAndLabelsRowRenderer orderedFieldsAndLabesRowRenderer = new OrderedFieldsAndLabelsRowRenderer();
|
||||
|
||||
public List<WorkReportType> getWorkReportTypes() {
|
||||
return workReportTypeModel.getWorkReportTypesExceptPersonalTimeSheets();
|
||||
return workReportTypeModel.getWorkReportTypesExceptPersonalAndJiraTimesheets();
|
||||
}
|
||||
|
||||
public WorkReportType getWorkReportType() {
|
||||
|
|
|
|||
|
|
@ -118,12 +118,15 @@ public class WorkReportTypeModel extends IntegrationEntityModel implements
|
|||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public List<WorkReportType> getWorkReportTypesExceptPersonalTimeSheets() {
|
||||
public List<WorkReportType> getWorkReportTypesExceptPersonalAndJiraTimesheets() {
|
||||
List<WorkReportType> list = workReportTypeDAO.list(WorkReportType.class);
|
||||
try {
|
||||
list.remove(workReportTypeDAO
|
||||
.findUniqueByName(PredefinedWorkReportTypes.PERSONAL_TIMESHEETS
|
||||
.getName()));
|
||||
list.remove(workReportTypeDAO
|
||||
.findUniqueByName(PredefinedWorkReportTypes.JIRA_TIMESHEETS
|
||||
.getName()));
|
||||
} catch (NonUniqueResultException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (InstanceNotFoundException e) {
|
||||
|
|
@ -155,6 +158,10 @@ public class WorkReportTypeModel extends IntegrationEntityModel implements
|
|||
throw new IllegalArgumentException(
|
||||
"Personal timesheets timesheet template cannot be edited");
|
||||
}
|
||||
if (workReportType.isJiraTimesheetsType()) {
|
||||
throw new IllegalArgumentException(
|
||||
"Personal timesheets timesheet template cannot be edited");
|
||||
}
|
||||
|
||||
setListing(false);
|
||||
editing = true;
|
||||
|
|
@ -224,6 +231,10 @@ public class WorkReportTypeModel extends IntegrationEntityModel implements
|
|||
throw new IllegalArgumentException(
|
||||
"Personal timesheets timesheet template cannot be removed");
|
||||
}
|
||||
if (workReportType.isJiraTimesheetsType()) {
|
||||
throw new IllegalArgumentException(
|
||||
"Personal timesheets timesheet template cannot be removed");
|
||||
}
|
||||
|
||||
try {
|
||||
workReportTypeDAO.remove(workReportType.getId());
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue