ItEr40S22CUProcuraOrganizacionsTraballoItEr32S10: Added company code to configuration.
This commit is contained in:
parent
e4d9fa0e01
commit
1eff2e9dce
7 changed files with 86 additions and 6 deletions
|
|
@ -20,6 +20,9 @@
|
|||
|
||||
package org.navalplanner.business.common.entities;
|
||||
|
||||
import org.hibernate.validator.AssertTrue;
|
||||
import org.hibernate.validator.NotEmpty;
|
||||
import org.hibernate.validator.NotNull;
|
||||
import org.navalplanner.business.calendars.entities.BaseCalendar;
|
||||
import org.navalplanner.business.common.BaseEntity;
|
||||
|
||||
|
|
@ -36,12 +39,36 @@ public class Configuration extends BaseEntity {
|
|||
|
||||
private BaseCalendar defaultCalendar;
|
||||
|
||||
private String companyCode;
|
||||
|
||||
public void setDefaultCalendar(BaseCalendar defaultCalendar) {
|
||||
this.defaultCalendar = defaultCalendar;
|
||||
}
|
||||
|
||||
@NotNull(message = "default calendar not specified")
|
||||
public BaseCalendar getDefaultCalendar() {
|
||||
return defaultCalendar;
|
||||
}
|
||||
|
||||
}
|
||||
public void setCompanyCode(String companyCode) {
|
||||
if (companyCode != null) {
|
||||
companyCode = companyCode.trim();
|
||||
}
|
||||
this.companyCode = companyCode;
|
||||
}
|
||||
|
||||
@NotEmpty(message = "company code not specified")
|
||||
public String getCompanyCode() {
|
||||
return companyCode;
|
||||
}
|
||||
|
||||
@AssertTrue(message = "company code must not contain white spaces")
|
||||
public boolean checkConstraintCompanyCodeWithoutWhiteSpaces() {
|
||||
if ((companyCode == null) || (companyCode.isEmpty())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return !companyCode.contains(" ");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -40,6 +40,8 @@ import org.springframework.transaction.annotation.Transactional;
|
|||
@Scope("singleton")
|
||||
public class ConfigurationBootstrap implements IConfigurationBootstrap {
|
||||
|
||||
private final String COMPANY_CODE = "COMPANY_CODE";
|
||||
|
||||
@Autowired
|
||||
private IConfigurationDAO configurationDAO;
|
||||
|
||||
|
|
@ -53,6 +55,7 @@ public class ConfigurationBootstrap implements IConfigurationBootstrap {
|
|||
if (list.isEmpty()) {
|
||||
Configuration configuration = Configuration.create();
|
||||
configuration.setDefaultCalendar(getDefaultCalendar());
|
||||
configuration.setCompanyCode(COMPANY_CODE);
|
||||
configurationDAO.save(configuration);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,6 +15,8 @@
|
|||
<many-to-one name="defaultCalendar" cascade="none"
|
||||
column="CONFIGURATION_ID" />
|
||||
|
||||
<property name="companyCode" />
|
||||
|
||||
</class>
|
||||
|
||||
</hibernate-mapping>
|
||||
|
|
@ -26,6 +26,7 @@ import java.util.List;
|
|||
|
||||
import org.navalplanner.business.calendars.entities.BaseCalendar;
|
||||
import org.navalplanner.business.common.entities.Configuration;
|
||||
import org.navalplanner.business.common.exceptions.ValidationException;
|
||||
import org.navalplanner.web.common.components.bandboxsearch.BandboxSearch;
|
||||
import org.zkoss.zk.ui.Component;
|
||||
import org.zkoss.zk.ui.event.Event;
|
||||
|
|
@ -49,6 +50,10 @@ public class ConfigurationController extends GenericForwardComposer {
|
|||
|
||||
private IConfigurationModel configurationModel;
|
||||
|
||||
private IMessagesForUser messages;
|
||||
|
||||
private Component messagesContainer;
|
||||
|
||||
@Override
|
||||
public void doAfterCompose(Component comp) throws Exception {
|
||||
super.doAfterCompose(comp);
|
||||
|
|
@ -66,6 +71,8 @@ public class ConfigurationController extends GenericForwardComposer {
|
|||
.getValue());
|
||||
}
|
||||
});
|
||||
|
||||
messages = new MessagesForUser(messagesContainer);
|
||||
}
|
||||
|
||||
public List<BaseCalendar> getCalendars() {
|
||||
|
|
@ -81,9 +88,15 @@ public class ConfigurationController extends GenericForwardComposer {
|
|||
}
|
||||
|
||||
public void save() throws InterruptedException {
|
||||
configurationModel.confirm();
|
||||
Messagebox.show(_("Changes saved"), _("Information"), Messagebox.OK,
|
||||
Messagebox.INFORMATION);
|
||||
if (ConstraintChecker.isValid(configurationWindow)) {
|
||||
try {
|
||||
configurationModel.confirm();
|
||||
messages.showMessage(Level.INFO, _("Changes saved"));
|
||||
reloadWindow();
|
||||
} catch (ValidationException e) {
|
||||
messages.showInvalidValues(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void cancel() throws InterruptedException {
|
||||
|
|
@ -97,4 +110,12 @@ public class ConfigurationController extends GenericForwardComposer {
|
|||
Util.reloadBindings(configurationWindow);
|
||||
}
|
||||
|
||||
public String getCompanyCode() {
|
||||
return configurationModel.getCompanyCode();
|
||||
}
|
||||
|
||||
public void setCompanyCode(String companyCode) {
|
||||
configurationModel.setCompanyCode(companyCode);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -108,4 +108,19 @@ public class ConfigurationModel implements IConfigurationModel {
|
|||
configuration = getCurrentConfiguration();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCompanyCode() {
|
||||
if (configuration == null) {
|
||||
return null;
|
||||
}
|
||||
return configuration.getCompanyCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCompanyCode(String companyCode) {
|
||||
if (configuration != null) {
|
||||
configuration.setCompanyCode(companyCode);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -47,6 +47,9 @@ public interface IConfigurationModel {
|
|||
BaseCalendar getDefaultCalendar();
|
||||
void setDefaultCalendar(BaseCalendar calendar);
|
||||
|
||||
String getCompanyCode();
|
||||
void setCompanyCode(String companyCode);
|
||||
|
||||
/*
|
||||
* Final conversation steps
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -32,18 +32,27 @@
|
|||
<window id="configurationWindow" self="@{define(content)}"
|
||||
apply="org.navalplanner.web.common.ConfigurationController"
|
||||
title="${i18n:_('Configuration')}">
|
||||
|
||||
<vbox id="messagesContainer" />
|
||||
|
||||
<tabbox>
|
||||
<tabs>
|
||||
<tab label="${i18n:_('Main preferences')}" />
|
||||
</tabs>
|
||||
<tabpanels>
|
||||
<tabpanel>
|
||||
<grid fixedLayout="true">
|
||||
<grid fixedLayout="true" id="configurationVariables">
|
||||
<columns>
|
||||
<column width="200px" />
|
||||
<column />
|
||||
</columns>
|
||||
<rows>
|
||||
<row>
|
||||
<label value="${i18n:_('Company code')}" />
|
||||
<textbox id="companyCode"
|
||||
value="@{configurationController.companyCode}"
|
||||
constraint="no empty:${i18n:_('Cannot be empty or null')}" />
|
||||
</row>
|
||||
<row>
|
||||
<label value="${i18n:_('Default calendar')}" />
|
||||
<bandboxSearch
|
||||
|
|
@ -67,4 +76,4 @@
|
|||
|
||||
</window>
|
||||
|
||||
</zk>
|
||||
</zk>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue