<commit_before>package Application;

import Domain.Models.Permission;
import Persistence.Entities.AccountEntity;
import Persistence.Entities.MusicianPartEntity;
import Persistence.Entities.PartEntity;
import Persistence.PersistanceFacade;
import Utils.Enum.AccountRole;
import Utils.Enum.SectionType;

import java.util.Collection;

/**
 * Created by timorzipa on 04/05/2017.
 */
public class AccountAdministrationManager {

    private static AccountAdministrationManager instance = null;
    private static PersistanceFacade<AccountEntity> persistanceFacade = new PersistanceFacade<>(AccountEntity.class);

    private AccountRole accountRole = null;
    private AccountEntity userAccount = null;
    private Permission permission = null;
    private SectionType sectionType;

    private AccountAdministrationManager() {}

    public static AccountAdministrationManager getInstance() {
        if(instance == null) {
            instance = new AccountAdministrationManager();
        }
        return instance;
    }

    public void setAccount(String username, String password) {
        AccountEntity accountEntity = persistanceFacade.get(p -> p.getUsername().equals(username) && p.getPassword().equals(password));
        if(accountEntity != null) {
            setLoggedInUser(accountEntity);
            if(accountEntity.getPersonAccountId().getMusicianPartsByPersonId() != null) {
                Collection<MusicianPartEntity> parts = accountEntity.getPersonAccountId().getMusicianPartsByPersonId();
                for(MusicianPartEntity musicianPartEntity : parts) {
                    sectionType = SectionType.valueOf(musicianPartEntity.getPartByPart().getSectionType());
                    return;
                }
            }
        }
    }

    private void setLoggedInUser(AccountEntity account) {
        userAccount = account;
        accountRole = AccountRole.valueOf(userAccount.getAccountRole());

        // set permissions
        permission = new Permission(accountRole);
    }

    public void resetUser() {
        accountRole = null;
        userAccount = null;
        permission = null;
    }

    public SectionType getSectionType() { return sectionType; }

    public AccountEntity getLoggedInAccount(){
        return userAccount;<commit_msg>Some changed to AccountAdministrationManager<commit_after>package Application;

import Domain.Models.Permission;
import Persistence.Entities.AccountEntity;
import Persistence.Entities.MusicianPartEntity;
import Persistence.Entities.PartEntity;
import Persistence.PersistanceFacade;
import Utils.Enum.AccountRole;
import Utils.Enum.SectionType;

import java.util.Collection;

/**
 * Created by timorzipa on 04/05/2017.
 */
public class AccountAdministrationManager {

    private static AccountAdministrationManager instance = null;
    private static PersistanceFacade<AccountEntity> persistanceFacade = new PersistanceFacade<>(AccountEntity.class);

    private AccountRole accountRole = null;
    private AccountEntity userAccount = null;
    private Permission permission = null;
    private SectionType sectionType;

    private AccountAdministrationManager() {}

    public static AccountAdministrationManager getInstance() {
        if(instance == null) {
            instance = new AccountAdministrationManager();
        }
        return instance;
    }

    public void setAccount(String username, String password) {
        AccountEntity accountEntity = persistanceFacade.get(p -> p.getUsername().equals(username) && p.getPassword().equals(password));
        if(accountEntity != null) {
            setLoggedInUser(accountEntity);
        }
    }

    private void setLoggedInUser(AccountEntity account) {
        resetUser();

        userAccount = account;
        accountRole = AccountRole.valueOf(userAccount.getAccountRole());

        // get section type
        if(account.getPersonAccountId().getMusicianPartsByPersonId() != null) {
            Collection<MusicianPartEntity> parts = account.getPersonAccountId().getMusicianPartsByPersonId();
            for(MusicianPartEntity musicianPartEntity : parts) {
                sectionType = SectionType.valueOf(musicianPartEntity.getPartByPart().getSectionType());
                return;
            }
        }

        // set permissions
        permission = new Permission(accountRole);
    }

    public void resetUser() {
        accountRole = null;
        userAccount = null;
        permission = null;
        sectionType = null;
    }

    public SectionType getSectionType() { return sectionType; }

    public AccountEntity getLoggedInAccount(){
        return userAccount;
{'fraction_non_alphanumeric': 0.0822538860103627, 'fraction_numerical': 0.0034542314335060447, 'mean_word_length': 3.2818853974121995, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, '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': '2645021', 'n_tokens_mistral': 1165, 'n_tokens_neox': 1113, 'n_words': 252}