<commit_before>package org.zalando.stups.fullstop.violation.repository.impl;

import com.mysema.query.jpa.JPQLQuery;
import org.springframework.data.jpa.repository.support.QueryDslRepositorySupport;
import org.zalando.stups.fullstop.violation.entity.LifecycleEntity;
import org.zalando.stups.fullstop.violation.entity.QApplicationEntity;
import org.zalando.stups.fullstop.violation.entity.QLifecycleEntity;
import org.zalando.stups.fullstop.violation.entity.QVersionEntity;
import org.zalando.stups.fullstop.violation.repository.LifecycleRepositoryCustom;

import java.util.List;

public class LifecycleRepositoryImpl extends QueryDslRepositorySupport implements LifecycleRepositoryCustom {


    public LifecycleRepositoryImpl() {
        super(LifecycleEntity.class);
    }


    @Override
    public List<LifecycleEntity> findByApplicationNameAndVersion(String name, String version) {

        final QLifecycleEntity qLifecycleEntity = new QLifecycleEntity("lifecycle");
        final QApplicationEntity qApplicationEntity = new QApplicationEntity("application");
        final QVersionEntity qVersionEntity = new QVersionEntity("version");


        JPQLQuery queryResult = from(qLifecycleEntity).join(qLifecycleEntity.applicationEntity, qApplicationEntity);

        if (version != null) {
            queryResult.join(qLifecycleEntity.versionEntity, qVersionEntity);
            queryResult.where(qVersionEntity.name.eq(version));
        }

        queryResult.where(qApplicationEntity.name.eq(name))
                .groupBy(qLifecycleEntity.versionEntity,
                        qLifecycleEntity.instanceId,
                        qLifecycleEntity.created,
                        qLifecycleEntity.id,
                        qApplicationEntity.id);

        if (version != null) {
            queryResult.groupBy(qVersionEntity.id);
        }

        List<LifecycleEntity> lifecycleEntities = queryResult.orderBy(qLifecycleEntity.created.asc())
                .list(new QLifecycleEntity(qLifecycleEntity));
<commit_msg>#391 check for emtpy strings<commit_after>package org.zalando.stups.fullstop.violation.repository.impl;

import com.mysema.query.jpa.JPQLQuery;
import org.springframework.data.jpa.repository.support.QueryDslRepositorySupport;
import org.zalando.stups.fullstop.violation.entity.LifecycleEntity;
import org.zalando.stups.fullstop.violation.entity.QApplicationEntity;
import org.zalando.stups.fullstop.violation.entity.QLifecycleEntity;
import org.zalando.stups.fullstop.violation.entity.QVersionEntity;
import org.zalando.stups.fullstop.violation.repository.LifecycleRepositoryCustom;

import java.util.List;

import static org.apache.logging.log4j.util.Strings.isNotEmpty;

public class LifecycleRepositoryImpl extends QueryDslRepositorySupport implements LifecycleRepositoryCustom {


    public LifecycleRepositoryImpl() {
        super(LifecycleEntity.class);
    }


    @Override
    public List<LifecycleEntity> findByApplicationNameAndVersion(String name, String version) {

        final QLifecycleEntity qLifecycleEntity = new QLifecycleEntity("lifecycle");
        final QApplicationEntity qApplicationEntity = new QApplicationEntity("application");
        final QVersionEntity qVersionEntity = new QVersionEntity("version");


        JPQLQuery queryResult = from(qLifecycleEntity).join(qLifecycleEntity.applicationEntity, qApplicationEntity);

        if (version != null && isNotEmpty(version)) {
            queryResult.join(qLifecycleEntity.versionEntity, qVersionEntity);
            queryResult.where(qVersionEntity.name.eq(version));
        }

        queryResult.where(qApplicationEntity.name.eq(name))
                .groupBy(qLifecycleEntity.versionEntity,
                        qLifecycleEntity.instanceId,
                        qLifecycleEntity.created,
                        qLifecycleEntity.id,
                        qApplicationEntity.id);

        if (version != null && isNotEmpty(version)) {
            queryResult.groupBy(qVersionEntity.id);
        }

        List<LifecycleEntity> lifecycleEntities = queryResult.orderBy(qLifecycleEntity.created.asc())
                .list(new QLifecycleEntity(qLifecycleEntity));

{'fraction_non_alphanumeric': 0.08492366412213741, 'fraction_numerical': 0.0009541984732824427, 'mean_word_length': 3.633149171270718, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '989748', 'n_tokens_mistral': 1150, 'n_tokens_neox': 1105, 'n_words': 159}