Tim-connector: extended with connectors functionaliteit.
Functionaliteit added to save and get connector properties
This commit is contained in:
parent
65b7d138f0
commit
e0788a30e4
1 changed files with 57 additions and 0 deletions
|
|
@ -37,8 +37,10 @@ import java.util.TreeMap;
|
|||
import org.apache.commons.lang.StringUtils;
|
||||
import org.libreplan.business.calendars.daos.IBaseCalendarDAO;
|
||||
import org.libreplan.business.calendars.entities.BaseCalendar;
|
||||
import org.libreplan.business.common.daos.IAppPropertiesDAO;
|
||||
import org.libreplan.business.common.daos.IConfigurationDAO;
|
||||
import org.libreplan.business.common.daos.IEntitySequenceDAO;
|
||||
import org.libreplan.business.common.entities.AppProperties;
|
||||
import org.libreplan.business.common.entities.Configuration;
|
||||
import org.libreplan.business.common.entities.EntityNameEnum;
|
||||
import org.libreplan.business.common.entities.EntitySequence;
|
||||
|
|
@ -88,6 +90,13 @@ public class ConfigurationModel implements IConfigurationModel {
|
|||
@Autowired
|
||||
private IWorkReportDAO workReportDAO;
|
||||
|
||||
@Autowired
|
||||
IAppPropertiesDAO appPropertiesDAO;
|
||||
|
||||
private Map<String, List<AppProperties>> appPropertiesMap = new HashMap<String, List<AppProperties>>();
|
||||
|
||||
private String connectorId = "Tim";
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public List<BaseCalendar> getCalendars() {
|
||||
|
|
@ -107,6 +116,8 @@ public class ConfigurationModel implements IConfigurationModel {
|
|||
public void init() {
|
||||
this.configuration = getCurrentConfiguration();
|
||||
initEntitySequences();
|
||||
initLdapConfiguration();
|
||||
initConnectorConfiguration();
|
||||
}
|
||||
|
||||
private void initEntitySequences() {
|
||||
|
|
@ -120,6 +131,23 @@ public class ConfigurationModel implements IConfigurationModel {
|
|||
}
|
||||
}
|
||||
|
||||
private void initLdapConfiguration() {
|
||||
if (null == configuration.getLdapConfiguration()) {
|
||||
configuration.setLdapConfiguration(LDAPConfiguration.create());
|
||||
}
|
||||
}
|
||||
|
||||
private void initConnectorConfiguration() {
|
||||
this.appPropertiesMap.clear();
|
||||
for (AppProperties appProperties : appPropertiesDAO.getAll()) {
|
||||
if (!this.appPropertiesMap.containsKey(appProperties.getMajorId())) {
|
||||
appPropertiesMap.put(appProperties.getMajorId(),
|
||||
new ArrayList<AppProperties>());
|
||||
}
|
||||
appPropertiesMap.get(appProperties.getMajorId()).add(appProperties);
|
||||
}
|
||||
}
|
||||
|
||||
private Configuration getCurrentConfiguration() {
|
||||
Configuration configuration = configurationDAO.getConfiguration();
|
||||
if (configuration == null) {
|
||||
|
|
@ -160,6 +188,7 @@ public class ConfigurationModel implements IConfigurationModel {
|
|||
public void confirm() {
|
||||
checkEntitySequences();
|
||||
configurationDAO.save(configuration);
|
||||
storeAppProperties();
|
||||
try {
|
||||
storeAndRemoveEntitySequences();
|
||||
} catch (IllegalStateException e) {
|
||||
|
|
@ -695,4 +724,32 @@ public class ConfigurationModel implements IConfigurationModel {
|
|||
}
|
||||
}
|
||||
|
||||
public void storeAppProperties() {
|
||||
List<AppProperties> appProperties = appPropertiesMap
|
||||
.get(getAppConnectorId());
|
||||
for (AppProperties appProperty : appProperties) {
|
||||
appPropertiesDAO.save(appProperty);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, List<AppProperties>> getAppProperties() {
|
||||
return appPropertiesMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateProperties(String key, List<AppProperties> value) {
|
||||
this.appPropertiesMap.put(key, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAppConnectorId(String connectorId) {
|
||||
this.connectorId = connectorId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAppConnectorId() {
|
||||
return connectorId;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue