/**
 * JBoss, Home of Professional Open Source.
 * Copyright 2014 Red Hat, Inc., and individual contributors
 * as indicated by the @author tags.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.jboss.pnc.datastore.repositories;

import org.jboss.pnc.datastore.repositories.internal.AbstractRepository;
import org.jboss.pnc.datastore.repositories.internal.BuildRecordPushResultSpringRepository;
import org.jboss.pnc.model.BuildRecordPushResult;
import org.jboss.pnc.spi.datastore.predicates.BuildRecordPushResultPredicates;
import org.jboss.pnc.spi.datastore.repositories.BuildRecordPushResultRepository;

import javax.ejb.Stateless;
import javax.inject.Inject;

/**
 * @author <a href="mailto:matejonnet@gmail.com">Matej Lazar</a>
 */
@Stateless
public class BuildRecordPushResultRepositoryImpl
        extends AbstractRepository<BuildRecordPushResult, Integer>
        implements BuildRecordPushResultRepository {

    @Inject
    public BuildRecordPushResultRepositoryImpl(BuildRecordPushResultSpringRepository springRepository) {
        super(springRepository, springRepository);
    }

    @Override
    public BuildRecordPushResult getLatestForBuildRecord(Integer buildRecordId) {
        return queryByPredicates(BuildRecordPushResultPredicates.forBuildRecordOrderByIdDesc(buildRecordId));
    }
}

@@ -1175,16 +1175,39 @@
 .Inject;
+%0Aimport java.util.List;
 %0A%0A/**%0A *
@@ -1737,22 +1737,70 @@
     
-return
+List%3CBuildRecordPushResult%3E buildRecordPushResults =
  query
-By
+With
 Pred
@@ -1870,24 +1870,227 @@
 esc(
-buildRecordId));
+%0A                buildRecordId));%0A        if (buildRecordPushResults == null %7C%7C buildRecordPushResults.size() == 0) %7B%0A            return null;%0A        %7D else %7B%0A            return buildRecordPushResults.get(0);%0A        %7D
 %0A   

Fix get latest BR Push result.