jira-integration: Modify bootstraps in order to set JiraConfiguration properly
* Renamed PersonalTimesheetsTypeOfWorkHoursBootstrap to ConfigurationTypeOfWorkHoursBootstrapa in order to set up TypeOfWorkHours for both personal timesheets and Jira connector. * Modified ConfigurationBootstrap to ensure that the JiraConfiguration is created properly. * Removed unneeded code in ConfigurationModel. FEA: ItEr77S16JiraAndTimConnectorContributionIntegration
This commit is contained in:
parent
44dca50bc9
commit
ae3b7610f1
5 changed files with 31 additions and 41 deletions
|
|
@ -67,27 +67,28 @@ public class ConfigurationBootstrap implements IConfigurationBootstrap {
|
|||
public void loadRequiredData() {
|
||||
loadRequiredDataSequences();
|
||||
|
||||
List<Configuration> list = configurationDAO.list(Configuration.class);
|
||||
if (list.isEmpty()) {
|
||||
Configuration configuration = Configuration.create();
|
||||
Configuration configuration = configurationDAO.getConfiguration();
|
||||
if (configuration == null) {
|
||||
configuration = Configuration.create();
|
||||
configuration.setDefaultCalendar(getDefaultCalendar());
|
||||
configuration.setCompanyCode(COMPANY_CODE);
|
||||
LDAPConfiguration ldapConfiguration = configuration
|
||||
.getLdapConfiguration();
|
||||
if (null == configuration.getLdapConfiguration()) {
|
||||
ldapConfiguration = LDAPConfiguration.create();
|
||||
}
|
||||
configuration.setLdapConfiguration(ldapConfiguration);
|
||||
|
||||
JiraConfiguration jiraConfiguration = configuration
|
||||
.getJiraConfiguration();
|
||||
if (null == configuration.getJiraConfiguration()) {
|
||||
jiraConfiguration = JiraConfiguration.create();
|
||||
}
|
||||
configuration.setJiraConfiguration(jiraConfiguration);
|
||||
|
||||
configurationDAO.save(configuration);
|
||||
}
|
||||
|
||||
LDAPConfiguration ldapConfiguration = configuration
|
||||
.getLdapConfiguration();
|
||||
if (ldapConfiguration == null) {
|
||||
ldapConfiguration = LDAPConfiguration.create();
|
||||
}
|
||||
configuration.setLdapConfiguration(ldapConfiguration);
|
||||
|
||||
JiraConfiguration jiraConfiguration = configuration
|
||||
.getJiraConfiguration();
|
||||
if (jiraConfiguration == null) {
|
||||
jiraConfiguration = JiraConfiguration.create();
|
||||
}
|
||||
configuration.setJiraConfiguration(jiraConfiguration);
|
||||
|
||||
configurationDAO.save(configuration);
|
||||
}
|
||||
|
||||
public void loadRequiredDataSequences() {
|
||||
|
|
|
|||
|
|
@ -32,8 +32,9 @@ import org.springframework.stereotype.Component;
|
|||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* Fills the attribute {@link Configuration#personalTimesheetsTypeOfWorkHours}
|
||||
* with a default value.<br />
|
||||
* Fills the attributes {@link Configuration#personalTimesheetsTypeOfWorkHours}
|
||||
* and {@link JiraConfiguration#jiraConnectorTypeOfWorkHours} with a default
|
||||
* values.<br />
|
||||
*
|
||||
* If possible it uses the "Default" {@link TypeOfWorkHours}, but if it doesn't
|
||||
* exist, it uses the first {@link TypeOfWorkHours} found.<br />
|
||||
|
|
@ -47,8 +48,8 @@ import org.springframework.transaction.annotation.Transactional;
|
|||
@Component
|
||||
@Scope("singleton")
|
||||
@BootstrapOrder(1)
|
||||
public class PersonalTimesheetsTypeOfWorkHoursBootstrap implements
|
||||
IPersonalTimesheetsTypeOfWorkHoursBootstrap {
|
||||
public class ConfigurationTypeOfWorkHoursBootstrap implements
|
||||
IConfigurationTypeOfWorkHoursBootstrap {
|
||||
|
||||
@Autowired
|
||||
private IConfigurationDAO configurationDAO;
|
||||
|
|
@ -74,6 +75,8 @@ public class PersonalTimesheetsTypeOfWorkHoursBootstrap implements
|
|||
}
|
||||
|
||||
configuration.setPersonalTimesheetsTypeOfWorkHours(typeOfWorkHours);
|
||||
configuration.getJiraConfiguration().setJiraConnectorTypeOfWorkHours(
|
||||
typeOfWorkHours);
|
||||
configurationDAO.save(configuration);
|
||||
}
|
||||
|
||||
|
|
@ -22,11 +22,11 @@ package org.libreplan.business.common.entities;
|
|||
import org.libreplan.business.IDataBootstrap;
|
||||
|
||||
/**
|
||||
* Contract for {@link PersonalTimesheetsTypeOfWorkHoursBootstrap}.
|
||||
* Contract for {@link ConfigurationTypeOfWorkHoursBootstrap}.
|
||||
*
|
||||
* @author Manuel Rego Casasnovas <mrego@igalia.com>
|
||||
*/
|
||||
public interface IPersonalTimesheetsTypeOfWorkHoursBootstrap extends
|
||||
public interface IConfigurationTypeOfWorkHoursBootstrap extends
|
||||
IDataBootstrap {
|
||||
|
||||
void loadRequiredData();
|
||||
|
|
@ -107,8 +107,6 @@ public class ConfigurationModel implements IConfigurationModel {
|
|||
public void init() {
|
||||
this.configuration = getCurrentConfiguration();
|
||||
initEntitySequences();
|
||||
initLdapConfiguration();
|
||||
initJiraConfiguration();
|
||||
}
|
||||
|
||||
private void initEntitySequences() {
|
||||
|
|
@ -122,18 +120,6 @@ public class ConfigurationModel implements IConfigurationModel {
|
|||
}
|
||||
}
|
||||
|
||||
private void initLdapConfiguration() {
|
||||
if (null == configuration.getLdapConfiguration()) {
|
||||
configuration.setLdapConfiguration(LDAPConfiguration.create());
|
||||
}
|
||||
}
|
||||
|
||||
private void initJiraConfiguration() {
|
||||
if (null == configuration.getJiraConfiguration()) {
|
||||
configuration.setJiraConfiguration(JiraConfiguration.create());
|
||||
}
|
||||
}
|
||||
|
||||
private Configuration getCurrentConfiguration() {
|
||||
Configuration configuration = configurationDAO.getConfiguration();
|
||||
if (configuration == null) {
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ import org.junit.runner.RunWith;
|
|||
import org.libreplan.business.common.IAdHocTransactionService;
|
||||
import org.libreplan.business.common.IOnTransaction;
|
||||
import org.libreplan.business.common.entities.IConfigurationBootstrap;
|
||||
import org.libreplan.business.common.entities.IPersonalTimesheetsTypeOfWorkHoursBootstrap;
|
||||
import org.libreplan.business.common.entities.IConfigurationTypeOfWorkHoursBootstrap;
|
||||
import org.libreplan.business.common.exceptions.InstanceNotFoundException;
|
||||
import org.libreplan.business.costcategories.daos.ITypeOfWorkHoursDAO;
|
||||
import org.libreplan.business.costcategories.entities.ITypeOfWorkHoursBootstrap;
|
||||
|
|
@ -86,7 +86,7 @@ public class TypeOfWorkHoursServiceTest {
|
|||
private ITypeOfWorkHoursBootstrap typeOfWorkHoursBootstrap;
|
||||
|
||||
@Autowired
|
||||
private IPersonalTimesheetsTypeOfWorkHoursBootstrap personalTimesheetsTypeOfWorkHoursBootstrap;
|
||||
private IConfigurationTypeOfWorkHoursBootstrap configurationTypeOfWorkHoursBootstrap;
|
||||
|
||||
@Before
|
||||
public void loadRequiredData() {
|
||||
|
|
@ -96,7 +96,7 @@ public class TypeOfWorkHoursServiceTest {
|
|||
public Void execute() {
|
||||
configurationBootstrap.loadRequiredData();
|
||||
typeOfWorkHoursBootstrap.loadRequiredData();
|
||||
personalTimesheetsTypeOfWorkHoursBootstrap.loadRequiredData();
|
||||
configurationTypeOfWorkHoursBootstrap.loadRequiredData();
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue