<commit_before>package com.sequenceiq.cloudbreak.converter.v2.cli;

import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import com.sequenceiq.cloudbreak.api.model.AmbariStackDetailsJson;
import com.sequenceiq.cloudbreak.cloud.model.component.StackRepoDetails;
import com.sequenceiq.cloudbreak.converter.AbstractConversionServiceAwareConverter;

@Component
public class StackRepoDetailsToStackRepoDetailsJsonConverter
        extends AbstractConversionServiceAwareConverter<StackRepoDetails, AmbariStackDetailsJson> {

    private static final Logger LOGGER = LoggerFactory.getLogger(StackRepoDetailsToStackRepoDetailsJsonConverter.class);

    private static final String REDHAT_6 = "redhat6";

    private static final String REDHAT_7 = "redhat7";

    @Override
    public AmbariStackDetailsJson convert(StackRepoDetails source) {
        AmbariStackDetailsJson ambariStackDetailsJson = new AmbariStackDetailsJson();

        Map<String, String> stack = source.getStack();
        ambariStackDetailsJson.setStackRepoId(stack.get(StackRepoDetails.REPO_ID_TAG));
        ambariStackDetailsJson.setRepositoryVersion(stack.get(StackRepoDetails.REPOSITORY_VERSION));
        ambariStackDetailsJson.setVersionDefinitionFileUrl(stack.get(StackRepoDetails.CUSTOM_VDF_REPO_KEY));
        ambariStackDetailsJson.setMpackUrl(stack.get(StackRepoDetails.MPACK_TAG));
        if (stack.containsKey(REDHAT_6)) {
            ambariStackDetailsJson.setOs(REDHAT_6);
            ambariStackDetailsJson.setStackBaseURL(stack.get(REDHAT_6));
        } else if (stack.containsKey(REDHAT_7)) {
            ambariStackDetailsJson.setOs(REDHAT_7);
            ambariStackDetailsJson.setStackBaseURL(stack.get(REDHAT_7));
        }

        Map<String, String> util = source.getUtil();
        ambariStackDetailsJson.setUtilsRepoId(util.get(StackRepoDetails.REPO_ID_TAG));
        if (util.containsKey(REDHAT_6)) {
            ambariStackDetailsJson.setUtilsBaseURL(util.get(REDHAT_6));
        } else if (util.containsKey(REDHAT_7)) {
            ambariStackDetailsJson.setUtilsBaseURL(util.get(REDHAT_7));
        }


        ambariStackDetailsJson.setVerify(source.isVerify());
        ambariStackDetailsJson.setVersion(source.getHdpVersion());
        return ambariStackDetailsJson;
    }
}<commit_msg>RMP-10350 add stack field to stackdetails<commit_after>package com.sequenceiq.cloudbreak.converter.v2.cli;

import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import com.sequenceiq.cloudbreak.api.model.AmbariStackDetailsJson;
import com.sequenceiq.cloudbreak.cloud.model.component.StackRepoDetails;
import com.sequenceiq.cloudbreak.converter.AbstractConversionServiceAwareConverter;

@Component
public class StackRepoDetailsToStackRepoDetailsJsonConverter
        extends AbstractConversionServiceAwareConverter<StackRepoDetails, AmbariStackDetailsJson> {

    private static final Logger LOGGER = LoggerFactory.getLogger(StackRepoDetailsToStackRepoDetailsJsonConverter.class);

    private static final String REDHAT_6 = "redhat6";

    private static final String REDHAT_7 = "redhat7";

    @Override
    public AmbariStackDetailsJson convert(StackRepoDetails source) {
        AmbariStackDetailsJson ambariStackDetailsJson = new AmbariStackDetailsJson();

        Map<String, String> stack = source.getStack();
        ambariStackDetailsJson.setStackRepoId(stack.get(StackRepoDetails.REPO_ID_TAG));
        ambariStackDetailsJson.setStack(stack.get(StackRepoDetails.REPO_ID_TAG));
        ambariStackDetailsJson.setRepositoryVersion(stack.get(StackRepoDetails.REPOSITORY_VERSION));
        ambariStackDetailsJson.setVersionDefinitionFileUrl(stack.get(StackRepoDetails.CUSTOM_VDF_REPO_KEY));
        ambariStackDetailsJson.setMpackUrl(stack.get(StackRepoDetails.MPACK_TAG));
        if (stack.containsKey(REDHAT_6)) {
            ambariStackDetailsJson.setOs(REDHAT_6);
            ambariStackDetailsJson.setStackBaseURL(stack.get(REDHAT_6));
        } else if (stack.containsKey(REDHAT_7)) {
            ambariStackDetailsJson.setOs(REDHAT_7);
            ambariStackDetailsJson.setStackBaseURL(stack.get(REDHAT_7));
        }

        Map<String, String> util = source.getUtil();
        ambariStackDetailsJson.setUtilsRepoId(util.get(StackRepoDetails.REPO_ID_TAG));
        if (util.containsKey(REDHAT_6)) {
            ambariStackDetailsJson.setUtilsBaseURL(util.get(REDHAT_6));
        } else if (util.containsKey(REDHAT_7)) {
            ambariStackDetailsJson.setUtilsBaseURL(util.get(REDHAT_7));
        }


        ambariStackDetailsJson.setVerify(source.isVerify());
        ambariStackDetailsJson.setVersion(source.getHdpVersion());
        return ambariStackDetailsJson;
    }
}
{'fraction_non_alphanumeric': 0.08629966887417219, 'fraction_numerical': 0.008071192052980132, 'mean_word_length': 4.652631578947369, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '3529554', 'n_tokens_mistral': 1477, 'n_tokens_neox': 1456, 'n_words': 172}