@@ -0,0 +1,2296 @@
+package com.dteknoloji.repository.project;%0A%0A/*%0A **************************%0A * Copyright (c) 2014     *%0A *                        *%0A * This code belongs to:  *%0A *                        *%0A * Ahmet Emre %C3%9Cnal        *%0A * S001974                *%0A *                        *%0A * aemreunal@gmail.com    *%0A * emre.unal@ozu.edu.tr   *%0A *                        *%0A * aemreunal.com          *%0A **************************%0A */%0A%0Aimport java.util.ArrayList;%0Aimport javax.persistence.criteria.CriteriaBuilder;%0Aimport javax.persistence.criteria.CriteriaQuery;%0Aimport javax.persistence.criteria.Predicate;%0Aimport javax.persistence.criteria.Root;%0Aimport org.springframework.data.jpa.domain.Specification;%0Aimport com.dteknoloji.domain.Project;%0A%0Apublic class ProjectSpecifications %7B%0A%0A    /**%0A     * Creates the Project search specification from the given attributes%0A     *%0A     * @param projectName%0A     *     The Project Name attribute to search for%0A     * @param ownerName%0A     *     The Owner name attribute to search for%0A     * @param ownerID%0A     *     The Owner ID attribute to search for%0A     *%0A     * @return The specification of the project%0A     */%0A    public static Specification%3CProject%3E projectWithSpecification(final String projectName, final String ownerName, final Long ownerID) %7B%0A        return new Specification%3CProject%3E() %7B%0A            public Predicate toPredicate(Root%3CProject%3E root, CriteriaQuery%3C?%3E query, CriteriaBuilder builder) %7B%0A                ArrayList%3CPredicate%3E predicates = new ArrayList%3CPredicate%3E();%0A%0A                if (!projectName.equals(%22%22)) %7B%0A                    predicates.add(builder.like(builder.upper(root.get(%22name%22).as(String.class)), %22%25%22 + projectName.toUpperCase() + %22%25%22));%0A                %7D%0A%0A                if (!ownerName.equals(%22%22)) %7B%0A                    // TODO Check for errors%0A                    predicates.add(builder.like(builder.upper(root.get(%22owner%22).get(%22name%22).as(String.class)), %22%25%22 + ownerName.toUpperCase() + %22%25%22));%0A                %7D%0A%0A                if (ownerID != null) %7B%0A                    // TODO Check for errors%0A                    predicates.add(builder.equal(root.get(%22owner%22).get(%22userId%22), ownerID));%0A                %7D%0A%0A                return builder.and(predicates.toArray(new Predicate%5Bpredicates.size()%5D));%0A            %7D%0A        %7D;%0A    %7D%0A%7D%0A

Add Project specifications creator