package com.cgi.eoss.ftep.api.controllers;

import com.cgi.eoss.ftep.api.security.FtepSecurityService;
import com.cgi.eoss.ftep.model.JobConfig;
import com.cgi.eoss.ftep.model.QJobConfig;
import com.cgi.eoss.ftep.model.QUser;
import com.cgi.eoss.ftep.persistence.dao.JobConfigDao;
import com.querydsl.core.types.dsl.NumberPath;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@RequiredArgsConstructor(onConstructor = @__(@Autowired))
@Getter
@Component
public class JobConfigsApiImpl extends BaseRepositoryApiImpl<JobConfig> {

    private final FtepSecurityService securityService;
    private final JobConfigDao dao;

    @Override
    NumberPath<Long> getIdPath() {
        return QJobConfig.jobConfig.id;
    }

    @Override
    QUser getOwnerPath() {
        return QJobConfig.jobConfig.owner;
    }

    @Override
    Class<JobConfig> getEntityClass() {
        return JobConfig.class;
    }

}

@@ -739,16 +739,579 @@
 o dao;%0A%0A
+    @Override%0A    public %3CS extends JobConfig%3E S save(S entity) %7B%0A        if (entity.getOwner() == null) %7B%0A            getSecurityService().updateOwnerWithCurrentUser(entity);%0A        %7D%0A%0A        JobConfig existing = getDao().findOne(QJobConfig.jobConfig.owner.eq(entity.getOwner())%0A                .and(QJobConfig.jobConfig.service.eq(entity.getService()))%0A                .and(QJobConfig.jobConfig.inputs.eq(entity.getInputs())));%0A        if (existing != null) %7B%0A            entity.setId(existing.getId());%0A        %7D%0A        return getDao().save(entity);%0A    %7D%0A%0A
     @Ove

Fix job config uniqueness check in POST API endpoint