Search in sources :

Example 1 with ProdProcessRepository

use of com.axelor.apps.production.db.repo.ProdProcessRepository in project axelor-open-suite by axelor.

the class ProdProcessController method checkOriginalProductionProcess.

public void checkOriginalProductionProcess(ActionRequest request, ActionResponse response) {
    ProdProcessRepository prodProcessRepository = Beans.get(ProdProcessRepository.class);
    ProdProcess prodProcess = prodProcessRepository.find(request.getContext().asType(ProdProcess.class).getId());
    List<ProdProcess> prodProcessSet = Lists.newArrayList();
    prodProcessSet = prodProcessRepository.all().filter("self.originalProdProcess = :origin").bind("origin", prodProcess).fetch();
    String message;
    if (!prodProcessSet.isEmpty()) {
        String existingVersions = "";
        for (ProdProcess prodProcessVersion : prodProcessSet) {
            existingVersions += "<li>" + prodProcessVersion.getFullName() + "</li>";
        }
        message = String.format(I18n.get("This production process already has the following versions : <br/><ul> %s </ul>And these versions may also have ones. Do you still wish to create a new one ?"), existingVersions);
    } else {
        message = I18n.get("Do you really wish to create a new version of this production process ?");
    }
    response.setAlert(message);
}
Also used : ProdProcessRepository(com.axelor.apps.production.db.repo.ProdProcessRepository) ProdProcess(com.axelor.apps.production.db.ProdProcess)

Aggregations

ProdProcess (com.axelor.apps.production.db.ProdProcess)1 ProdProcessRepository (com.axelor.apps.production.db.repo.ProdProcessRepository)1