Search in sources :

Example 1 with TrainingSession

use of com.axelor.apps.talent.db.TrainingSession in project axelor-open-suite by axelor.

the class TrainingSessionController method updateTraingRegisterTraining.

public void updateTraingRegisterTraining(ActionRequest request, ActionResponse response) {
    TrainingSession trainingSession = request.getContext().asType(TrainingSession.class);
    if (trainingSession.getTrainingRegisterList() != null) {
        trainingSession = Beans.get(TrainingSessionService.class).updateTraingRegisterTraining(trainingSession);
        response.setValue("trainingRegisterList", trainingSession.getTrainingRegisterList());
    }
}
Also used : TrainingSession(com.axelor.apps.talent.db.TrainingSession)

Example 2 with TrainingSession

use of com.axelor.apps.talent.db.TrainingSession in project axelor-open-suite by axelor.

the class TrainingSessionController method cancel.

public void cancel(ActionRequest request, ActionResponse response) {
    TrainingSession trainingSession = request.getContext().asType(TrainingSession.class);
    trainingSession = Beans.get(TrainingSessionRepository.class).find(trainingSession.getId());
    Beans.get(TrainingSessionService.class).cancel(trainingSession);
    response.setReload(true);
}
Also used : TrainingSessionService(com.axelor.apps.talent.service.TrainingSessionService) TrainingSession(com.axelor.apps.talent.db.TrainingSession)

Example 3 with TrainingSession

use of com.axelor.apps.talent.db.TrainingSession in project axelor-open-suite by axelor.

the class TrainingRegisterTalentRepository method remove.

@Override
public void remove(TrainingRegister trainingRegister) {
    Training training = trainingRegister.getTraining();
    TrainingSession session = trainingRegister.getTrainingSession();
    List<Event> eventList = trainingRegister.getEventList();
    for (Event event : eventList) {
        eventRepo.remove(event);
    }
    super.remove(trainingRegister);
    trainingRegisterService.updateTrainingRating(training, null);
    if (session != null) {
        trainingRegisterService.updateSessionRating(session, null);
    }
}
Also used : Training(com.axelor.apps.talent.db.Training) Event(com.axelor.apps.crm.db.Event) TrainingSession(com.axelor.apps.talent.db.TrainingSession)

Example 4 with TrainingSession

use of com.axelor.apps.talent.db.TrainingSession in project axelor-open-suite by axelor.

the class TrainingRegisterTalentRepository method save.

@Override
public TrainingRegister save(TrainingRegister trainingRegister) {
    if (trainingRegister.getFromDate().isAfter(trainingRegister.getToDate())) {
        throw new ValidationException(I18n.get(IExceptionMessage.INVALID_DATE_RANGE));
    }
    TrainingSession trainingSession = trainingRegister.getTrainingSession();
    if (trainingSession != null && (trainingSession.getFromDate().isAfter(trainingRegister.getFromDate()) || trainingSession.getToDate().isBefore(trainingRegister.getToDate()))) {
        throw new ValidationException(I18n.get(IExceptionMessage.INVALID_TR_DATE));
    }
    trainingRegister.setFullName(trainingRegisterService.computeFullName(trainingRegister));
    trainingRegister = super.save(trainingRegister);
    trainingRegisterService.updateTrainingRating(trainingRegister.getTraining(), null);
    if (trainingRegister.getTrainingSession() != null) {
        trainingRegisterService.updateSessionRating(trainingRegister.getTrainingSession(), null);
    }
    refresh(trainingRegister);
    return trainingRegister;
}
Also used : ValidationException(javax.validation.ValidationException) TrainingSession(com.axelor.apps.talent.db.TrainingSession)

Example 5 with TrainingSession

use of com.axelor.apps.talent.db.TrainingSession in project axelor-open-suite by axelor.

the class TrainingRegisterController method updateOldRating.

public void updateOldRating(ActionRequest request, ActionResponse response) {
    TrainingRegister trainingRegister = request.getContext().asType(TrainingRegister.class);
    TrainingRegisterService trainingRegisterService = Beans.get(TrainingRegisterService.class);
    Training trainingSaved = null;
    TrainingSession trainingSessionSaved = null;
    if (trainingRegister.getId() != null) {
        TrainingRegister trainingRegisterSaved = Beans.get(TrainingRegisterRepository.class).find(trainingRegister.getId());
        trainingSessionSaved = trainingRegisterSaved.getTrainingSession();
        trainingSaved = trainingRegisterSaved.getTraining();
    }
    if (trainingSaved != null && trainingSaved.getId().equals(trainingRegister.getTraining().getId())) {
        trainingRegisterService.updateTrainingRating(trainingSaved, trainingRegister.getId());
    }
    if (trainingSessionSaved != null) {
        if (trainingRegister.getTrainingSession() == null || trainingRegister.getTrainingSession().getId().equals(trainingSessionSaved.getId())) {
            trainingRegisterService.updateSessionRating(trainingSessionSaved, trainingRegister.getId());
        }
    }
}
Also used : Training(com.axelor.apps.talent.db.Training) TrainingRegister(com.axelor.apps.talent.db.TrainingRegister) TrainingRegisterRepository(com.axelor.apps.talent.db.repo.TrainingRegisterRepository) TrainingRegisterService(com.axelor.apps.talent.service.TrainingRegisterService) TrainingSession(com.axelor.apps.talent.db.TrainingSession)

Aggregations

TrainingSession (com.axelor.apps.talent.db.TrainingSession)8 TrainingSessionService (com.axelor.apps.talent.service.TrainingSessionService)3 Event (com.axelor.apps.crm.db.Event)2 Training (com.axelor.apps.talent.db.Training)2 TrainingRegisterService (com.axelor.apps.talent.service.TrainingRegisterService)2 TrainingRegister (com.axelor.apps.talent.db.TrainingRegister)1 TrainingRegisterRepository (com.axelor.apps.talent.db.repo.TrainingRegisterRepository)1 TrainingSessionRepository (com.axelor.apps.talent.db.repo.TrainingSessionRepository)1 Context (com.axelor.rpc.Context)1 ArrayList (java.util.ArrayList)1 LinkedHashMap (java.util.LinkedHashMap)1 ValidationException (javax.validation.ValidationException)1