Search in sources :

Example 1 with AppProject

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);
}
Also used : AxelorException(com.axelor.exception.AxelorException) Company(com.axelor.apps.base.db.Company) PersistenceException(javax.persistence.PersistenceException) SequenceService(com.axelor.apps.base.service.administration.SequenceService) Team(com.axelor.team.db.Team) AppProject(com.axelor.apps.base.db.AppProject) AppProjectService(com.axelor.apps.project.service.app.AppProjectService)

Example 2 with AppProject

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());
    }
}
Also used : AppProject(com.axelor.apps.base.db.AppProject) Project(com.axelor.apps.project.db.Project) AxelorException(com.axelor.exception.AxelorException) AppProject(com.axelor.apps.base.db.AppProject) AppProjectService(com.axelor.apps.project.service.app.AppProjectService) Wizard(com.axelor.apps.base.db.Wizard) ProjectTemplate(com.axelor.apps.project.db.ProjectTemplate)

Aggregations

AppProject (com.axelor.apps.base.db.AppProject)2 AppProjectService (com.axelor.apps.project.service.app.AppProjectService)2 AxelorException (com.axelor.exception.AxelorException)2 Company (com.axelor.apps.base.db.Company)1 Wizard (com.axelor.apps.base.db.Wizard)1 SequenceService (com.axelor.apps.base.service.administration.SequenceService)1 Project (com.axelor.apps.project.db.Project)1 ProjectTemplate (com.axelor.apps.project.db.ProjectTemplate)1 Team (com.axelor.team.db.Team)1 PersistenceException (javax.persistence.PersistenceException)1