<commit_before>//
// Copyright (c) 2011 Linkeos.
//
// This file is part of Elveos.org.
// Elveos.org is free software: you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the
// Free Software Foundation, either version 3 of the License, or (at your
// option) any later version.
//
// Elveos.org is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
// more details.
// You should have received a copy of the GNU General Public License along
// with Elveos.org. If not, see http://www.gnu.org/licenses/.
//
package com.bloatit.model;

import com.bloatit.data.DaoFollowSoftware;
import com.bloatit.model.right.Action;
import com.bloatit.model.right.AuthToken;
import com.bloatit.model.right.UnauthorizedOperationException;
import com.bloatit.model.visitor.ModelClassVisitor;

public final class FollowSoftware extends Identifiable<DaoFollowSoftware> {

    // /////////////////////////////////////////////////////////////////////////////////////////
    // CONSTRUCTION
    // /////////////////////////////////////////////////////////////////////////////////////////

    private static final class MyCreator extends Creator<DaoFollowSoftware, FollowSoftware> {
        @SuppressWarnings("synthetic-access")
        @Override
        public FollowSoftware doCreate(final DaoFollowSoftware dao) {
            return new FollowSoftware(dao);
        }
    }

    @SuppressWarnings("synthetic-access")
    public static FollowSoftware create(final DaoFollowSoftware dao) {
        return new MyCreator().create(dao);
    }

    private FollowSoftware(final DaoFollowSoftware id) {
        super(id);
    }

    // /////////////////////////////////////////////////////////////////////////////////////////
    // Getters
    // /////////////////////////////////////////////////////////////////////////////////////////

    public final Member getFollower() {
        return Member.create(getDao().getFollower());
    }

    public final Software getFollowed() {
        return Software.create(getDao().getFollowed());
    }

    public final boolean isMail() {
        return getDao().isMail();
    }

    // /////////////////////////////////////////////////////////////////////////////////////////
    // Setters
    // /////////////////////////////////////////////////////////////////////////////////////////

    public final void setMail(final boolean mail) throws UnauthorizedOperationException {
        final Member follower = Member.create(getDao().getFollower());
        if (!(AuthToken.isAdmin() || (AuthToken.isAuthenticated() && AuthToken.getMember().equals(follower)))) {
            throw new UnauthorizedOperationException(Action.WRITE);
        }
        getDao().setMail(mail);
        for (final FollowFeature followFeature : getFollower().getFollowedFeatures()) {
            if (followFeature.getFollowed().getSoftware().equals(getFollowed())) {
                followFeature.setMail(mail);
            }
        }

    }

    // /////////////////////////////////////////////////////////////////////////////////////////
    // Visitor
    // /////////////////////////////////////////////////////////////////////////////////////////

    @Override
    public <ReturnType> ReturnType accept(final ModelClassVisitor<ReturnType> visitor) {
        return visitor.visit(this);<commit_msg>fix follow software with no software feature<commit_after>//
// Copyright (c) 2011 Linkeos.
//
// This file is part of Elveos.org.
// Elveos.org is free software: you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the
// Free Software Foundation, either version 3 of the License, or (at your
// option) any later version.
//
// Elveos.org is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
// more details.
// You should have received a copy of the GNU General Public License along
// with Elveos.org. If not, see http://www.gnu.org/licenses/.
//
package com.bloatit.model;

import com.bloatit.data.DaoFollowSoftware;
import com.bloatit.model.right.Action;
import com.bloatit.model.right.AuthToken;
import com.bloatit.model.right.UnauthorizedOperationException;
import com.bloatit.model.visitor.ModelClassVisitor;

public final class FollowSoftware extends Identifiable<DaoFollowSoftware> {

    // /////////////////////////////////////////////////////////////////////////////////////////
    // CONSTRUCTION
    // /////////////////////////////////////////////////////////////////////////////////////////

    private static final class MyCreator extends Creator<DaoFollowSoftware, FollowSoftware> {
        @SuppressWarnings("synthetic-access")
        @Override
        public FollowSoftware doCreate(final DaoFollowSoftware dao) {
            return new FollowSoftware(dao);
        }
    }

    @SuppressWarnings("synthetic-access")
    public static FollowSoftware create(final DaoFollowSoftware dao) {
        return new MyCreator().create(dao);
    }

    private FollowSoftware(final DaoFollowSoftware id) {
        super(id);
    }

    // /////////////////////////////////////////////////////////////////////////////////////////
    // Getters
    // /////////////////////////////////////////////////////////////////////////////////////////

    public final Member getFollower() {
        return Member.create(getDao().getFollower());
    }

    public final Software getFollowed() {
        return Software.create(getDao().getFollowed());
    }

    public final boolean isMail() {
        return getDao().isMail();
    }

    // /////////////////////////////////////////////////////////////////////////////////////////
    // Setters
    // /////////////////////////////////////////////////////////////////////////////////////////

    public final void setMail(final boolean mail) throws UnauthorizedOperationException {
        final Member follower = Member.create(getDao().getFollower());
        if (!(AuthToken.isAdmin() || (AuthToken.isAuthenticated() && AuthToken.getMember().equals(follower)))) {
            throw new UnauthorizedOperationException(Action.WRITE);
        }
        getDao().setMail(mail);
        for (final FollowFeature followFeature : getFollower().getFollowedFeatures()) {
            if (followFeature.getFollowed().getSoftware() != null && followFeature.getFollowed().getSoftware().equals(getFollowed())) {
                followFeature.setMail(mail);
            }
        }

    }

    // /////////////////////////////////////////////////////////////////////////////////////////
    // Visitor
    // /////////////////////////////////////////////////////////////////////////////////////////

    @Override
    public <ReturnType> ReturnType accept(final ModelClassVisitor<ReturnType> visitor) {
        return visitor.visit(this);
{'fraction_non_alphanumeric': 0.28197919595164467, 'fraction_numerical': 0.0014056789429294349, 'mean_word_length': 1.4747826086956521, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '6984006', 'n_tokens_mistral': 1593, 'n_tokens_neox': 1535, 'n_words': 441}