use of com.axelor.apps.base.db.AppProject in project axelor-open-suite by axelor.
the class ProjectManagementRepository method save.
@Override
public Project save(Project project) {
ProjectManagementRepository.setAllProjectMembersUserSet(project);
if (project.getSynchronize()) {
Team team = project.getTeam();
if (team != null) {
team.clearMembers();
project.getMembersUserSet().forEach(team::addMember);
}
}
try {
AppProject appProject = Beans.get(AppProjectService.class).getAppProject();
if (Strings.isNullOrEmpty(project.getCode()) && appProject.getGenerateProjectSequence()) {
Company company = project.getCompany();
String seq = Beans.get(SequenceService.class).getSequenceNumber(SequenceRepository.PROJECT_SEQUENCE, company);
if (seq == null) {
throw new AxelorException(company, TraceBackRepository.CATEGORY_CONFIGURATION_ERROR, I18n.get(IExceptionMessage.PROJECT_SEQUENCE_ERROR), company.getName());
}
project.setCode(seq);
}
} catch (AxelorException e) {
TraceBackService.traceExceptionFromSaveMethod(e);
throw new PersistenceException(e.getMessage(), e);
}
setAllProjectFullName(project);
project.setEstimatedTimeHrs(project.getEstimatedTimeDays().multiply(Beans.get(AppBaseService.class).getAppBase().getDailyWorkHours()));
return super.save(project);
}
use of com.axelor.apps.base.db.AppProject in project axelor-open-suite by axelor.
the class ProjectTemplateController method createProjectFromTemplate.
public void createProjectFromTemplate(ActionRequest request, ActionResponse response) {
ProjectTemplate projectTemplate = request.getContext().asType(ProjectTemplate.class);
AppProject appProject = Beans.get(AppProjectService.class).getAppProject();
if (appProject.getGenerateProjectSequence() && !projectTemplate.getIsBusinessProject()) {
Project project;
try {
project = Beans.get(ProjectService.class).createProjectFromTemplate(projectTemplate, null, null);
response.setView(ActionView.define(I18n.get("Project")).model(Project.class.getName()).add("form", "project-form").add("grid", "project-grid").param("search-filters", "project-filters").context("_showRecord", project.getId()).map());
} catch (AxelorException e) {
TraceBackService.trace(response, e);
}
} else {
response.setView(ActionView.define(I18n.get("Create project from this template")).model(Wizard.class.getName()).add("form", "project-template-wizard-form").param("popup", "reload").param("show-toolbar", "false").param("show-confirm", "false").param("width", "large").param("popup-save", "false").context("_projectTemplate", projectTemplate).context("_businessProject", projectTemplate.getIsBusinessProject()).map());
}
}
Aggregations