Search in sources :

Example 1 with DefaultSortInfo

use of org.jboss.pnc.spi.datastore.repositories.api.impl.DefaultSortInfo in project pnc by project-ncl.

the class BuildRecordRepositoryImpl method getAnyLatestSuccessfulBuildRecordWithBuildConfig.

@Override
public BuildRecord getAnyLatestSuccessfulBuildRecordWithBuildConfig(Integer configurationId, boolean temporaryBuild) {
    PageInfo pageInfo = new DefaultPageInfo(0, 1);
    SortInfo sortInfo = new DefaultSortInfo(SortInfo.SortingDirection.DESC, BuildRecord_.submitTime.getName());
    List<BuildRecord> buildRecords = queryWithPredicates(pageInfo, sortInfo, withBuildConfigurationId(configurationId), withSuccess(), includeTemporary(temporaryBuild));
    if (buildRecords.size() == 0) {
        return null;
    } else {
        return buildRecords.get(0);
    }
}
Also used : PageInfo(org.jboss.pnc.spi.datastore.repositories.api.PageInfo) DefaultPageInfo(org.jboss.pnc.spi.datastore.repositories.api.impl.DefaultPageInfo) DefaultPageInfo(org.jboss.pnc.spi.datastore.repositories.api.impl.DefaultPageInfo) DefaultSortInfo(org.jboss.pnc.spi.datastore.repositories.api.impl.DefaultSortInfo) BuildRecord(org.jboss.pnc.model.BuildRecord) SortInfo(org.jboss.pnc.spi.datastore.repositories.api.SortInfo) DefaultSortInfo(org.jboss.pnc.spi.datastore.repositories.api.impl.DefaultSortInfo)

Example 2 with DefaultSortInfo

use of org.jboss.pnc.spi.datastore.repositories.api.impl.DefaultSortInfo in project pnc by project-ncl.

the class BuildRecordRepositoryImpl method getPreferredLatestSuccessfulBuildRecordWithRevision.

@Override
public BuildRecord getPreferredLatestSuccessfulBuildRecordWithRevision(IdRev idRev, boolean temporaryBuild, AlignmentPreference alignmentPreference) {
    PageInfo pageInfo = new DefaultPageInfo(0, 1);
    SortInfo sortInfo = new DefaultSortInfo(SortInfo.SortingDirection.DESC, BuildRecord_.submitTime.getName());
    List<BuildRecord> buildRecords = queryWithPredicates(pageInfo, sortInfo, withBuildConfigurationIdRev(idRev), withSuccess(), includeTemporary(idRev, temporaryBuild, alignmentPreference));
    if (buildRecords.size() == 0) {
        return null;
    } else {
        return buildRecords.get(0);
    }
}
Also used : PageInfo(org.jboss.pnc.spi.datastore.repositories.api.PageInfo) DefaultPageInfo(org.jboss.pnc.spi.datastore.repositories.api.impl.DefaultPageInfo) DefaultPageInfo(org.jboss.pnc.spi.datastore.repositories.api.impl.DefaultPageInfo) DefaultSortInfo(org.jboss.pnc.spi.datastore.repositories.api.impl.DefaultSortInfo) BuildRecord(org.jboss.pnc.model.BuildRecord) SortInfo(org.jboss.pnc.spi.datastore.repositories.api.SortInfo) DefaultSortInfo(org.jboss.pnc.spi.datastore.repositories.api.impl.DefaultSortInfo)

Example 3 with DefaultSortInfo

use of org.jboss.pnc.spi.datastore.repositories.api.impl.DefaultSortInfo in project pnc by project-ncl.

the class BuildRecordRepositoryImpl method getPreferredLatestSuccessfulBuildRecordWithBuildConfig.

@Override
public BuildRecord getPreferredLatestSuccessfulBuildRecordWithBuildConfig(Integer configurationId, boolean temporaryBuild, AlignmentPreference alignmentPreference) {
    PageInfo pageInfo = new DefaultPageInfo(0, 1);
    SortInfo sortInfo = new DefaultSortInfo(SortInfo.SortingDirection.DESC, BuildRecord_.submitTime.getName());
    List<BuildRecord> buildRecords = queryWithPredicates(pageInfo, sortInfo, withBuildConfigurationId(configurationId), withSuccess(), includeTemporary(configurationId, temporaryBuild, alignmentPreference));
    if (buildRecords.size() == 0) {
        return null;
    } else {
        return buildRecords.get(0);
    }
}
Also used : PageInfo(org.jboss.pnc.spi.datastore.repositories.api.PageInfo) DefaultPageInfo(org.jboss.pnc.spi.datastore.repositories.api.impl.DefaultPageInfo) DefaultPageInfo(org.jboss.pnc.spi.datastore.repositories.api.impl.DefaultPageInfo) DefaultSortInfo(org.jboss.pnc.spi.datastore.repositories.api.impl.DefaultSortInfo) BuildRecord(org.jboss.pnc.model.BuildRecord) SortInfo(org.jboss.pnc.spi.datastore.repositories.api.SortInfo) DefaultSortInfo(org.jboss.pnc.spi.datastore.repositories.api.impl.DefaultSortInfo)

Example 4 with DefaultSortInfo

use of org.jboss.pnc.spi.datastore.repositories.api.impl.DefaultSortInfo in project pnc by project-ncl.

the class SortRSQLNodeTraveller method visit.

@Override
public SortInfo visit(ComparisonNode node) {
    SortingDirection sortingDirection;
    List<String> sortingFields = new ArrayList<>();
    if (node.getOperator().equals(ASC)) {
        sortingDirection = SortInfo.SortingDirection.ASC;
    } else if (node.getOperator().equals(DESC)) {
        sortingDirection = SortInfo.SortingDirection.DESC;
    } else {
        throw new UnsupportedOperationException("Unsupported sorting: " + node.getOperator());
    }
    logger.trace("Sorting direction - {}, arguments {}", sortingDirection, node.getArguments());
    for (String argument : node.getArguments()) {
        if ("id".equals(argument)) {
            // Disable sorting by id
            throw new RSQLException("Sorting by id is not supported.");
        }
        sortingFields.add(toPath.apply(RSQLSelectorPath.get(argument)));
    }
    return new DefaultSortInfo(sortingDirection, sortingFields);
}
Also used : ArrayList(java.util.ArrayList) SortingDirection(org.jboss.pnc.spi.datastore.repositories.api.SortInfo.SortingDirection) DefaultSortInfo(org.jboss.pnc.spi.datastore.repositories.api.impl.DefaultSortInfo)

Example 5 with DefaultSortInfo

use of org.jboss.pnc.spi.datastore.repositories.api.impl.DefaultSortInfo in project pnc by project-ncl.

the class BuildRecordRepositoryImpl method getAnyLatestSuccessfulBuildRecordWithRevision.

@Override
public BuildRecord getAnyLatestSuccessfulBuildRecordWithRevision(IdRev idRev, boolean temporaryBuild) {
    PageInfo pageInfo = new DefaultPageInfo(0, 1);
    SortInfo sortInfo = new DefaultSortInfo(SortInfo.SortingDirection.DESC, BuildRecord_.submitTime.getName());
    List<BuildRecord> buildRecords = queryWithPredicates(pageInfo, sortInfo, withBuildConfigurationIdRev(idRev), withSuccess(), includeTemporary(temporaryBuild));
    if (buildRecords.size() == 0) {
        return null;
    } else {
        return buildRecords.get(0);
    }
}
Also used : PageInfo(org.jboss.pnc.spi.datastore.repositories.api.PageInfo) DefaultPageInfo(org.jboss.pnc.spi.datastore.repositories.api.impl.DefaultPageInfo) DefaultPageInfo(org.jboss.pnc.spi.datastore.repositories.api.impl.DefaultPageInfo) DefaultSortInfo(org.jboss.pnc.spi.datastore.repositories.api.impl.DefaultSortInfo) BuildRecord(org.jboss.pnc.model.BuildRecord) SortInfo(org.jboss.pnc.spi.datastore.repositories.api.SortInfo) DefaultSortInfo(org.jboss.pnc.spi.datastore.repositories.api.impl.DefaultSortInfo)

Aggregations

DefaultSortInfo (org.jboss.pnc.spi.datastore.repositories.api.impl.DefaultSortInfo)6 BuildRecord (org.jboss.pnc.model.BuildRecord)5 PageInfo (org.jboss.pnc.spi.datastore.repositories.api.PageInfo)5 SortInfo (org.jboss.pnc.spi.datastore.repositories.api.SortInfo)5 DefaultPageInfo (org.jboss.pnc.spi.datastore.repositories.api.impl.DefaultPageInfo)5 ArrayList (java.util.ArrayList)1 SortingDirection (org.jboss.pnc.spi.datastore.repositories.api.SortInfo.SortingDirection)1