<commit_before>package com.validation.manager.core.server.core;

import static com.validation.manager.core.DataBaseManager.getEntityManagerFactory;
import com.validation.manager.core.EntityServer;
import com.validation.manager.core.db.Test;
import com.validation.manager.core.db.TestPlan;
import com.validation.manager.core.db.TestPlanHasTest;
import com.validation.manager.core.db.TestPlanHasTestPK;
import com.validation.manager.core.db.TestProject;
import com.validation.manager.core.db.controller.TestPlanHasTestJpaController;
import com.validation.manager.core.db.controller.TestPlanJpaController;
import com.validation.manager.core.db.controller.exceptions.IllegalOrphanException;
import com.validation.manager.core.db.controller.exceptions.NonexistentEntityException;
import com.validation.manager.core.db.controller.exceptions.PreexistingEntityException;
import java.util.Date;
import java.util.logging.Level;
import static java.util.logging.Logger.getLogger;

/**
 *
 * @author <NAME> <<EMAIL>>
 */
public final class TestPlanServer extends TestPlan implements EntityServer<TestPlan> {

    public TestPlanServer(TestPlan plan) {
        TestPlanJpaController controller = new TestPlanJpaController(getEntityManagerFactory());
        TestPlan temp = controller.findTestPlan(plan.getTestPlanPK());
        update(TestPlanServer.this, temp);
    }

    public TestPlanServer(TestProject testProject, boolean active,
            boolean isOpen) {
        super(testProject, active, isOpen);
        setTestProject(testProject);
    }

    @Override
    public int write2DB() throws IllegalOrphanException,
            NonexistentEntityException, Exception {
        TestPlanJpaController controller
                = new TestPlanJpaController(getEntityManagerFactory());
        if (getTestPlanPK().getId() > 0) {
            TestPlan temp = controller.findTestPlan(getTestPlanPK());
            update(temp, this);
            controller.edit(temp);
        } else {
            TestPlan temp = new TestPlan(getTestProject(), getActive(),
                    getIsOpen());
            update(temp, this);
            controller.create(temp);
            setTestPlanPK(temp.getTestPlanPK());
        }
        return getTestPlanPK().getId();
    }

    public static boolean deleteTestPlan(TestPlan tp) {
        try {
            new TestPlanJpaController(getEntityManagerFactory())
                    .destroy(tp.getTestPlanPK());
        } catch (IllegalOrphanException | NonexistentEntityException ex) {
            getLogger(TestPlanServer.class.getName()).log(Level.SEVERE, null, ex);
            return false;
        }
        return true;
    }

    public boolean addTest(Test test) {
        try {
            TestPlanHasTest tpht = new TestPlanHasTest(
                    new TestPlanHasTestPK(getTestPlanPK().getId(),
                            getTestPlanPK().getTestProjectId(), test.getId()),
                    new Date(), 1);
            tpht.setTest(test);
            tpht.setTestPlan(new TestPlanJpaController(getEntityManagerFactory())
                    .findTestPlan(getTestPlanPK()));
            new TestPlanHasTestJpaController(getEntityManagerFactory())
                    .create(tpht);
            getTestPlanHasTestList().add(tpht);
            write2DB();
            return true;
        } catch (PreexistingEntityException ex) {
            getLogger(TestPlanServer.class.getName()).log(Level.SEVERE,
                    null, ex);
        } catch (Exception ex) {
            getLogger(TestPlanServer.class.getName()).log(Level.SEVERE,
                    null, ex);
        }
        return false;
    }

    @Override
    public TestPlan getEntity() {
        return new TestPlanJpaController(
                getEntityManagerFactory())
                .findTestPlan(getTestPlanPK());
    }

    @Override
    public void update(TestPlan target, TestPlan source) {
        target.setActive(source.getActive());
        target.setIsOpen(source.getIsOpen());
        target.setNotes(source.getNotes());
        target.setTestPlanHasTestList(source.getTestPlanHasTestList());
        target.setTestPlanList(source.getTestPlanList());
        target.setUserTestPlanRoleList(source.getUserTestPlanRoleList());
        target.setTestPlanPK(source.getTestPlanPK());
    }

    @Override
    public void update() {
        update(this, getEntity());
    }
}<commit_msg>1) Set missing lists. 2) Add missing field to be copied in update method.<commit_after>package com.validation.manager.core.server.core;

import static com.validation.manager.core.DataBaseManager.getEntityManagerFactory;
import com.validation.manager.core.EntityServer;
import com.validation.manager.core.db.Test;
import com.validation.manager.core.db.TestPlan;
import com.validation.manager.core.db.TestPlanHasTest;
import com.validation.manager.core.db.TestPlanHasTestPK;
import com.validation.manager.core.db.TestProject;
import com.validation.manager.core.db.controller.TestPlanHasTestJpaController;
import com.validation.manager.core.db.controller.TestPlanJpaController;
import com.validation.manager.core.db.controller.exceptions.IllegalOrphanException;
import com.validation.manager.core.db.controller.exceptions.NonexistentEntityException;
import com.validation.manager.core.db.controller.exceptions.PreexistingEntityException;
import java.util.ArrayList;
import java.util.Date;
import java.util.logging.Level;
import static java.util.logging.Logger.getLogger;

/**
 *
 * @author <NAME> <<EMAIL>>
 */
public final class TestPlanServer extends TestPlan implements EntityServer<TestPlan> {

    public TestPlanServer(TestPlan plan) {
        TestPlanJpaController controller
                = new TestPlanJpaController(getEntityManagerFactory());
        TestPlan temp = controller.findTestPlan(plan.getTestPlanPK());
        update(TestPlanServer.this, temp);
    }

    public TestPlanServer(TestProject testProject, boolean active,
            boolean isOpen) {
        super(testProject, active, isOpen);
        setTestProject(testProject);
        setTestPlanHasTestList(new ArrayList<>());
        setTestPlanList(new ArrayList<>());
        setUserTestPlanRoleList(new ArrayList<>());
    }

    @Override
    public int write2DB() throws IllegalOrphanException,
            NonexistentEntityException, Exception {
        TestPlanJpaController controller
                = new TestPlanJpaController(getEntityManagerFactory());
        if (getTestPlanPK().getId() > 0) {
            TestPlan temp = controller.findTestPlan(getTestPlanPK());
            update(temp, this);
            controller.edit(temp);
        } else {
            TestPlan temp = new TestPlan(getTestProject(), getActive(),
                    getIsOpen());
            update(temp, this);
            controller.create(temp);
            setTestPlanPK(temp.getTestPlanPK());
        }
        return getTestPlanPK().getId();
    }

    public static boolean deleteTestPlan(TestPlan tp) {
        try {
            new TestPlanJpaController(getEntityManagerFactory())
                    .destroy(tp.getTestPlanPK());
        } catch (IllegalOrphanException | NonexistentEntityException ex) {
            getLogger(TestPlanServer.class.getName()).log(Level.SEVERE, null, ex);
            return false;
        }
        return true;
    }

    public boolean addTest(Test test) {
        try {
            TestPlanHasTest tpht = new TestPlanHasTest(
                    new TestPlanHasTestPK(getTestPlanPK().getId(),
                            getTestPlanPK().getTestProjectId(), test.getId()),
                    new Date(), getTestPlanHasTestList().size() + 1);
            tpht.setTest(test);
            tpht.setTestPlan(new TestPlanJpaController(getEntityManagerFactory())
                    .findTestPlan(getTestPlanPK()));
            new TestPlanHasTestJpaController(getEntityManagerFactory())
                    .create(tpht);
            getTestPlanHasTestList().add(tpht);
            write2DB();
            return true;
        } catch (PreexistingEntityException ex) {
            getLogger(TestPlanServer.class.getName()).log(Level.SEVERE,
                    null, ex);
        } catch (Exception ex) {
            getLogger(TestPlanServer.class.getName()).log(Level.SEVERE,
                    null, ex);
        }
        return false;
    }

    @Override
    public TestPlan getEntity() {
        return new TestPlanJpaController(
                getEntityManagerFactory())
                .findTestPlan(getTestPlanPK());
    }

    @Override
    public void update(TestPlan target, TestPlan source) {
        target.setActive(source.getActive());
        target.setIsOpen(source.getIsOpen());
        target.setNotes(source.getNotes());
        target.setTestPlanHasTestList(source.getTestPlanHasTestList());
        target.setTestPlanList(source.getTestPlanList());
        target.setUserTestPlanRoleList(source.getUserTestPlanRoleList());
        target.setTestPlanPK(source.getTestPlanPK());
        target.setTestPlan(source.getTestPlan());
    }

    @Override
    public void update() {
        update(this, getEntity());
    }
}
{'fraction_non_alphanumeric': 0.1018892650431364, 'fraction_numerical': 0.0010920607185759528, 'mean_word_length': 2.7874276261373034, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 16, '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': '6081413', 'n_tokens_mistral': 2448, 'n_tokens_neox': 2410, 'n_words': 407}