<commit_before>package org.op.controller;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import org.op.model.Activity;
import org.op.model.Contact;
import org.op.model.Project;

import org.op.repositories.SubscribersRepository;
import org.op.util.FMessage;
import org.op.util.MailFactory;

@ManagedBean
@ViewScoped
public class NewController implements Serializable
{

    private final SubscribersRepository subscribersRepository = new SubscribersRepository("OpenProvaPU");

    private List<Project> projects = subscribersRepository.getResultList(Project.class);

    private final MailFactory mailFactory = new MailFactory();

    private final FMessage msg = new FMessage();

    private Project selectedProject = new Project();

    private List<Activity> projectActivities;

    private Contact newContact = new Contact();

    private boolean allDatesSelected;

    private String additionalMessage;

    //<editor-fold defaultstate="collapsed" desc="Getters & Setters">
    public String getAdditionalMessage()
    {
        return additionalMessage;
    }

    public void setAdditionalMessage(String additionalMessage)
    {
        this.additionalMessage = additionalMessage;
    }

    public boolean isAllDatesSelected()
    {
        return allDatesSelected;
    }

    public void setAllDatesSelected(boolean allDatesSelected)
    {
        this.allDatesSelected = allDatesSelected;
    }

    public Contact getNewContact()
    {
        return newContact;
    }

    public void setNewContact(Contact newContact)
    {
        this.newContact = newContact;
    }

    public List<Project> getProjects()
    {
        return projects;
    }

    public void setProjects(List<Project> projects)
    {
        this.projects = projects;
    }

    public Project getSelectedProject()
    {
        return selectedProject;
    }

    public void setSelectedProject(Project selectedProject)
    {
        this.selectedProject = selectedProject;
    }

    public List<Activity> getProjectActivities()
    {
        return projectActivities;
    }

    public void setProjectActivities(List<Activity> projectActivities)
    {
        this.projectActivities = projectActivities;
    }

    //</editor-fold>
    //Loading project data and cloning dates
    public void selectProject()
    {
        projectActivities = new ArrayList();
        projects.forEach((p) ->
        {
            if (p.getId() != null)
            {
                selectedProject = p;
            } else
            {
                selectedProject = new Project();
            }
        });
        List<Activity> masterActivities = subscribersRepository
                .getProjectActivities(selectedProject.getId(), true);
        masterActivities.forEach((ma) ->
        {
            Activity a = new Activity();
            a.setCommentsByContact(ma.getCommentsByContact());
            a.setDate(ma.getDate());
            a.setDescription(ma.getDescription());
            a.setEndTime(ma.getEndTime());
            a.setIsMasterActivity(false);
            a.setLocation(ma.getLocation());
            a.setPresent(ma.isPresent());
            a.setProjectId(ma.getProjectId());
            a.setStartTime(ma.getStartTime());
            projectActivities.add(a);
        });
    }

    public void selectAllDates()
    {
        projectActivities.parallelStream().forEach((activity) ->
        {
            if (allDatesSelected)
            {
                activity.setPresent(true);
            } else
            {
                activity.setPresent(false);
            }
        });
    }

    public void saveNewSubscription()
    {
        //Saving the new Contact
        if (mailFactory.addressValid(newContact.getEmail())
                && !subscribersRepository.isExistingContact(newContact)
                && subscribersRepository.persisted(newContact))<commit_msg>tampered with array cloning. no success.<commit_after>package org.op.controller;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import org.op.model.Activity;
import org.op.model.Contact;
import org.op.model.Project;

import org.op.repositories.SubscribersRepository;
import org.op.util.FMessage;
import org.op.util.MailFactory;

@ManagedBean
@ViewScoped
public class NewController implements Serializable
{

    private final SubscribersRepository subscribersRepository = new SubscribersRepository("OpenProvaPU");

    private List<Project> projects = subscribersRepository.getResultList(Project.class);

    private final MailFactory mailFactory = new MailFactory();

    private final FMessage msg = new FMessage();

    private Project selectedProject = new Project();

    private List<Activity> projectActivities;

    private Contact newContact = new Contact();

    private boolean allDatesSelected;

    private String additionalMessage;

    //<editor-fold defaultstate="collapsed" desc="Getters & Setters">
    public String getAdditionalMessage()
    {
        return additionalMessage;
    }

    public void setAdditionalMessage(String additionalMessage)
    {
        this.additionalMessage = additionalMessage;
    }

    public boolean isAllDatesSelected()
    {
        return allDatesSelected;
    }

    public void setAllDatesSelected(boolean allDatesSelected)
    {
        this.allDatesSelected = allDatesSelected;
    }

    public Contact getNewContact()
    {
        return newContact;
    }

    public void setNewContact(Contact newContact)
    {
        this.newContact = newContact;
    }

    public List<Project> getProjects()
    {
        return projects;
    }

    public void setProjects(List<Project> projects)
    {
        this.projects = projects;
    }

    public Project getSelectedProject()
    {
        return selectedProject;
    }

    public void setSelectedProject(Project selectedProject)
    {
        this.selectedProject = selectedProject;
    }

    public List<Activity> getProjectActivities()
    {
        return projectActivities;
    }

    public void setProjectActivities(List<Activity> projectActivities)
    {
        this.projectActivities = projectActivities;
    }

    //</editor-fold>
    //Loading project data and cloning dates
    public void selectProject()
    {
        projects.forEach((p) ->
        {
            if (p.getId() != null)
            {
                selectedProject = p;
            } else
            {
                selectedProject = new Project();
            }
        });

        List<Activity> masterActivities = subscribersRepository
                .getProjectActivities(selectedProject.getId(), true);

        projectActivities = new ArrayList();

        //not using the Collections clong constructor option because this
        //is not a master activity
        masterActivities.forEach((ma) ->
        {
            Activity a = new Activity();
            a.setCommentsByContact(ma.getCommentsByContact());
            a.setDate(ma.getDate());
            a.setDescription(ma.getDescription());
            a.setEndTime(ma.getEndTime());
            a.setIsMasterActivity(false);
            a.setLocation(ma.getLocation());
            a.setPresent(ma.isPresent());
            a.setProjectId(ma.getProjectId());
            a.setStartTime(ma.getStartTime());
            a.setIsMasterActivity(false);
            projectActivities.add(a);
        });
    }

    public void selectAllDates()
    {
        projectActivities.parallelStream().forEach((activity) ->
        {
            if (allDatesSelected)
            {
                activity.setPresent(true);
            } else
            {
                activity.setPresent(false);
            }
        });
    }

    public void saveNewSubscription()
    {
        //Saving the new Contact
        if (mailFactory.addressValid(newContact.getEmail())
                && !subscribersRepository.isExistingContact(newContact)
                && subscribersRepository.persisted(newContact))
{'fraction_non_alphanumeric': 0.09051882742548754, 'fraction_numerical': 0.0, 'mean_word_length': 2.393258426966292, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 27, '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': '4220683', 'n_tokens_mistral': 2160, 'n_tokens_neox': 2068, 'n_words': 429}