<commit_before>/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

package org.ow2.choreos.chors.bus;

import java.util.ArrayList;
import java.util.List;

import org.apache.log4j.Logger;
import org.ow2.choreos.chors.bus.selector.ESBNodeSelector;
import org.ow2.choreos.chors.bus.selector.ESBNodeSelectorFactory;
import org.ow2.choreos.chors.datamodel.Choreography;
import org.ow2.choreos.chors.datamodel.LegacyService;
import org.ow2.choreos.chors.datamodel.LegacyServiceInstance;
import org.ow2.choreos.nodes.datamodel.ResourceImpact;
import org.ow2.choreos.selectors.NotSelectedException;
import org.ow2.choreos.services.datamodel.DeployableService;
import org.ow2.choreos.services.datamodel.Proxification;
import org.ow2.choreos.services.datamodel.ServiceInstance;

/**
 * 
 * @author leonardo
 * 
 */
public class ESBNodesSelector {

    private static Logger logger = Logger.getLogger(ESBNodesSelector.class);

    private List<ProxificationTask> proxificationTasks = new ArrayList<ProxificationTask>();
    private ESBNodeSelector selector = ESBNodeSelectorFactory.getFactoryInstance().getNodeSelectorInstance();
    

    void setSelector(ESBNodeSelector selector) {
        this.selector = selector;
    }
    
    /**
     * Selects EasyESB nodes to each one of the service instances. EASY_ESB
     * services (CDs) will be not proxified.
     * 
     * @param choreography
     * @return a list of proxification tasks, where nativeUri and easyEsbNode
     *         are inputs, and the result of the task must be saved on the
     *         provided proxification object; if it was not possible to select
     *         an esb node to a specific instance, there will be not a key to
     *         this instance.
     */
    public List<ProxificationTask> selectESBNodes(Choreography choreography) {
        List<DeployableService> deployableServices = choreography.getDeployableServices();
        if (deployableServices != null && !deployableServices.isEmpty())
            createTasksForDeployableServices(choreography);
        List<LegacyService> legacyServices = choreography.getLegacyServices();
        if (legacyServices != null && !legacyServices.isEmpty())
            createTasksForLegacyServices(choreography);
        return proxificationTasks;
    }
    
    private void createTasksForDeployableServices(Choreography choreography) {<commit_msg>avoiding failure on tests when we have no properties<commit_after>/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

package org.ow2.choreos.chors.bus;

import java.util.ArrayList;
import java.util.List;

import org.apache.log4j.Logger;
import org.ow2.choreos.chors.bus.selector.ESBNodeSelector;
import org.ow2.choreos.chors.bus.selector.ESBNodeSelectorFactory;
import org.ow2.choreos.chors.datamodel.Choreography;
import org.ow2.choreos.chors.datamodel.LegacyService;
import org.ow2.choreos.chors.datamodel.LegacyServiceInstance;
import org.ow2.choreos.nodes.datamodel.ResourceImpact;
import org.ow2.choreos.selectors.NotSelectedException;
import org.ow2.choreos.services.datamodel.DeployableService;
import org.ow2.choreos.services.datamodel.Proxification;
import org.ow2.choreos.services.datamodel.ServiceInstance;

/**
 * 
 * @author leonardo
 * 
 */
public class ESBNodesSelector {

    private static Logger logger = Logger.getLogger(ESBNodesSelector.class);

    private List<ProxificationTask> proxificationTasks = new ArrayList<ProxificationTask>();
    private ESBNodeSelector selector;
    

    void setSelector(ESBNodeSelector selector) {
        this.selector = selector;
    }
    
    /**
     * Selects EasyESB nodes to each one of the service instances. EASY_ESB
     * services (CDs) will be not proxified.
     * 
     * @param choreography
     * @return a list of proxification tasks, where nativeUri and easyEsbNode
     *         are inputs, and the result of the task must be saved on the
     *         provided proxification object; if it was not possible to select
     *         an esb node to a specific instance, there will be not a key to
     *         this instance.
     */
    public List<ProxificationTask> selectESBNodes(Choreography choreography) {
	if (selector == null)
	    selector = ESBNodeSelectorFactory.getFactoryInstance().getNodeSelectorInstance();
        List<DeployableService> deployableServices = choreography.getDeployableServices();
        if (deployableServices != null && !deployableServices.isEmpty())
            createTasksForDeployableServices(choreography);
        List<LegacyService> legacyServices = choreography.getLegacyServices();
        if (legacyServices != null && !legacyServices.isEmpty())
            createTasksForLegacyServices(choreography);
        return proxificationTasks;
    }
    
    private void createTasksForDeployableServices(Choreography choreography) {
{'fraction_non_alphanumeric': 0.08409756097560976, 'fraction_numerical': 0.006243902439024391, 'mean_word_length': 3.7728119180633146, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '3960182', 'n_tokens_mistral': 1550, 'n_tokens_neox': 1491, 'n_words': 374}