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;
|
package org.libreplan.business.workreports.entities;
|
||||||
|
|
||||||
|
import org.libreplan.business.workreports.valueobjects.DescriptionField;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines the default {@link WorkReportType WorkReportTypes}.
|
* Defines the default {@link WorkReportType WorkReportTypes}.
|
||||||
*
|
*
|
||||||
|
|
@ -27,7 +29,9 @@ package org.libreplan.business.workreports.entities;
|
||||||
*/
|
*/
|
||||||
public enum PredefinedWorkReportTypes {
|
public enum PredefinedWorkReportTypes {
|
||||||
DEFAULT("Default", false, false, false),
|
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;
|
private WorkReportType workReportType;
|
||||||
|
|
||||||
|
|
@ -41,6 +45,15 @@ public enum PredefinedWorkReportTypes {
|
||||||
.setOrderElementIsSharedInLines(orderElementIsSharedInLines);
|
.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() {
|
public WorkReportType getWorkReportType() {
|
||||||
return workReportType;
|
return workReportType;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -532,4 +532,11 @@ public class WorkReportType extends IntegrationEntity implements IHumanIdentifia
|
||||||
.getName());
|
.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 {
|
} else {
|
||||||
createPersonalTimesheetsWorkReportTypeIfNeeded();
|
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}
|
* @return A {@link List} of {@link WorkReportType}
|
||||||
*/
|
*/
|
||||||
List<WorkReportType> getWorkReportTypesExceptPersonalTimeSheets();
|
List<WorkReportType> getWorkReportTypesExceptPersonalAndJiraTimesheets();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stores the current {@link WorkReportType}.
|
* Stores the current {@link WorkReportType}.
|
||||||
|
|
|
||||||
|
|
@ -116,7 +116,7 @@ public class WorkReportTypeCRUDController extends BaseCRUDController<WorkReportT
|
||||||
private OrderedFieldsAndLabelsRowRenderer orderedFieldsAndLabesRowRenderer = new OrderedFieldsAndLabelsRowRenderer();
|
private OrderedFieldsAndLabelsRowRenderer orderedFieldsAndLabesRowRenderer = new OrderedFieldsAndLabelsRowRenderer();
|
||||||
|
|
||||||
public List<WorkReportType> getWorkReportTypes() {
|
public List<WorkReportType> getWorkReportTypes() {
|
||||||
return workReportTypeModel.getWorkReportTypesExceptPersonalTimeSheets();
|
return workReportTypeModel.getWorkReportTypesExceptPersonalAndJiraTimesheets();
|
||||||
}
|
}
|
||||||
|
|
||||||
public WorkReportType getWorkReportType() {
|
public WorkReportType getWorkReportType() {
|
||||||
|
|
|
||||||
|
|
@ -118,12 +118,15 @@ public class WorkReportTypeModel extends IntegrationEntityModel implements
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
public List<WorkReportType> getWorkReportTypesExceptPersonalTimeSheets() {
|
public List<WorkReportType> getWorkReportTypesExceptPersonalAndJiraTimesheets() {
|
||||||
List<WorkReportType> list = workReportTypeDAO.list(WorkReportType.class);
|
List<WorkReportType> list = workReportTypeDAO.list(WorkReportType.class);
|
||||||
try {
|
try {
|
||||||
list.remove(workReportTypeDAO
|
list.remove(workReportTypeDAO
|
||||||
.findUniqueByName(PredefinedWorkReportTypes.PERSONAL_TIMESHEETS
|
.findUniqueByName(PredefinedWorkReportTypes.PERSONAL_TIMESHEETS
|
||||||
.getName()));
|
.getName()));
|
||||||
|
list.remove(workReportTypeDAO
|
||||||
|
.findUniqueByName(PredefinedWorkReportTypes.JIRA_TIMESHEETS
|
||||||
|
.getName()));
|
||||||
} catch (NonUniqueResultException e) {
|
} catch (NonUniqueResultException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
} catch (InstanceNotFoundException e) {
|
} catch (InstanceNotFoundException e) {
|
||||||
|
|
@ -155,6 +158,10 @@ public class WorkReportTypeModel extends IntegrationEntityModel implements
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
"Personal timesheets timesheet template cannot be edited");
|
"Personal timesheets timesheet template cannot be edited");
|
||||||
}
|
}
|
||||||
|
if (workReportType.isJiraTimesheetsType()) {
|
||||||
|
throw new IllegalArgumentException(
|
||||||
|
"Personal timesheets timesheet template cannot be edited");
|
||||||
|
}
|
||||||
|
|
||||||
setListing(false);
|
setListing(false);
|
||||||
editing = true;
|
editing = true;
|
||||||
|
|
@ -224,6 +231,10 @@ public class WorkReportTypeModel extends IntegrationEntityModel implements
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
"Personal timesheets timesheet template cannot be removed");
|
"Personal timesheets timesheet template cannot be removed");
|
||||||
}
|
}
|
||||||
|
if (workReportType.isJiraTimesheetsType()) {
|
||||||
|
throw new IllegalArgumentException(
|
||||||
|
"Personal timesheets timesheet template cannot be removed");
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
workReportTypeDAO.remove(workReportType.getId());
|
workReportTypeDAO.remove(workReportType.getId());
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue