Package gwlpr.database.entities

Examples of gwlpr.database.entities.Skill


            for (Character characterCollectionCharacter : skill.getCharacterCollection()) {
                characterCollectionCharacter.getSkillCollection().add(skill);
                characterCollectionCharacter = em.merge(characterCollectionCharacter);
            }
            for (EquippedSkill equippedSkillCollectionEquippedSkill : skill.getEquippedSkillCollection()) {
                Skill oldSkillOfEquippedSkillCollectionEquippedSkill = equippedSkillCollectionEquippedSkill.getSkill();
                equippedSkillCollectionEquippedSkill.setSkill(skill);
                equippedSkillCollectionEquippedSkill = em.merge(equippedSkillCollectionEquippedSkill);
                if (oldSkillOfEquippedSkillCollectionEquippedSkill != null) {
                    oldSkillOfEquippedSkillCollectionEquippedSkill.getEquippedSkillCollection().remove(equippedSkillCollectionEquippedSkill);
                    oldSkillOfEquippedSkillCollectionEquippedSkill = em.merge(oldSkillOfEquippedSkillCollectionEquippedSkill);
                }
            }
            em.getTransaction().commit();
        } finally {
View Full Code Here


    public void edit(Skill skill) throws IllegalOrphanException, NonexistentEntityException, Exception {
        EntityManager em = null;
        try {
            em = getEntityManager();
            em.getTransaction().begin();
            Skill persistentSkill = em.find(Skill.class, skill.getId());
            Attribute attributeOld = persistentSkill.getAttribute();
            Attribute attributeNew = skill.getAttribute();
            Collection<Character> characterCollectionOld = persistentSkill.getCharacterCollection();
            Collection<Character> characterCollectionNew = skill.getCharacterCollection();
            Collection<EquippedSkill> equippedSkillCollectionOld = persistentSkill.getEquippedSkillCollection();
            Collection<EquippedSkill> equippedSkillCollectionNew = skill.getEquippedSkillCollection();
            List<String> illegalOrphanMessages = null;
            for (EquippedSkill equippedSkillCollectionOldEquippedSkill : equippedSkillCollectionOld) {
                if (!equippedSkillCollectionNew.contains(equippedSkillCollectionOldEquippedSkill)) {
                    if (illegalOrphanMessages == null) {
                        illegalOrphanMessages = new ArrayList<String>();
                    }
                    illegalOrphanMessages.add("You must retain EquippedSkill " + equippedSkillCollectionOldEquippedSkill + " since its skill field is not nullable.");
                }
            }
            if (illegalOrphanMessages != null) {
                throw new IllegalOrphanException(illegalOrphanMessages);
            }
            if (attributeNew != null) {
                attributeNew = em.getReference(attributeNew.getClass(), attributeNew.getId());
                skill.setAttribute(attributeNew);
            }
            Collection<Character> attachedCharacterCollectionNew = new ArrayList<Character>();
            for (Character characterCollectionNewCharacterToAttach : characterCollectionNew) {
                characterCollectionNewCharacterToAttach = em.getReference(characterCollectionNewCharacterToAttach.getClass(), characterCollectionNewCharacterToAttach.getId());
                attachedCharacterCollectionNew.add(characterCollectionNewCharacterToAttach);
            }
            characterCollectionNew = attachedCharacterCollectionNew;
            skill.setCharacterCollection(characterCollectionNew);
            Collection<EquippedSkill> attachedEquippedSkillCollectionNew = new ArrayList<EquippedSkill>();
            for (EquippedSkill equippedSkillCollectionNewEquippedSkillToAttach : equippedSkillCollectionNew) {
                equippedSkillCollectionNewEquippedSkillToAttach = em.getReference(equippedSkillCollectionNewEquippedSkillToAttach.getClass(), equippedSkillCollectionNewEquippedSkillToAttach.getEquippedSkillPK());
                attachedEquippedSkillCollectionNew.add(equippedSkillCollectionNewEquippedSkillToAttach);
            }
            equippedSkillCollectionNew = attachedEquippedSkillCollectionNew;
            skill.setEquippedSkillCollection(equippedSkillCollectionNew);
            skill = em.merge(skill);
            if (attributeOld != null && !attributeOld.equals(attributeNew)) {
                attributeOld.getSkillCollection().remove(skill);
                attributeOld = em.merge(attributeOld);
            }
            if (attributeNew != null && !attributeNew.equals(attributeOld)) {
                attributeNew.getSkillCollection().add(skill);
                attributeNew = em.merge(attributeNew);
            }
            for (Character characterCollectionOldCharacter : characterCollectionOld) {
                if (!characterCollectionNew.contains(characterCollectionOldCharacter)) {
                    characterCollectionOldCharacter.getSkillCollection().remove(skill);
                    characterCollectionOldCharacter = em.merge(characterCollectionOldCharacter);
                }
            }
            for (Character characterCollectionNewCharacter : characterCollectionNew) {
                if (!characterCollectionOld.contains(characterCollectionNewCharacter)) {
                    characterCollectionNewCharacter.getSkillCollection().add(skill);
                    characterCollectionNewCharacter = em.merge(characterCollectionNewCharacter);
                }
            }
            for (EquippedSkill equippedSkillCollectionNewEquippedSkill : equippedSkillCollectionNew) {
                if (!equippedSkillCollectionOld.contains(equippedSkillCollectionNewEquippedSkill)) {
                    Skill oldSkillOfEquippedSkillCollectionNewEquippedSkill = equippedSkillCollectionNewEquippedSkill.getSkill();
                    equippedSkillCollectionNewEquippedSkill.setSkill(skill);
                    equippedSkillCollectionNewEquippedSkill = em.merge(equippedSkillCollectionNewEquippedSkill);
                    if (oldSkillOfEquippedSkillCollectionNewEquippedSkill != null && !oldSkillOfEquippedSkillCollectionNewEquippedSkill.equals(skill)) {
                        oldSkillOfEquippedSkillCollectionNewEquippedSkill.getEquippedSkillCollection().remove(equippedSkillCollectionNewEquippedSkill);
                        oldSkillOfEquippedSkillCollectionNewEquippedSkill = em.merge(oldSkillOfEquippedSkillCollectionNewEquippedSkill);
                    }
                }
            }
            em.getTransaction().commit();
View Full Code Here

    public void destroy(Integer id) throws IllegalOrphanException, NonexistentEntityException {
        EntityManager em = null;
        try {
            em = getEntityManager();
            em.getTransaction().begin();
            Skill skill;
            try {
                skill = em.getReference(Skill.class, id);
                skill.getId();
            } catch (EntityNotFoundException enfe) {
                throw new NonexistentEntityException("The skill with id " + id + " no longer exists.", enfe);
            }
            List<String> illegalOrphanMessages = null;
            Collection<EquippedSkill> equippedSkillCollectionOrphanCheck = skill.getEquippedSkillCollection();
            for (EquippedSkill equippedSkillCollectionOrphanCheckEquippedSkill : equippedSkillCollectionOrphanCheck) {
                if (illegalOrphanMessages == null) {
                    illegalOrphanMessages = new ArrayList<String>();
                }
                illegalOrphanMessages.add("This Skill (" + skill + ") cannot be destroyed since the EquippedSkill " + equippedSkillCollectionOrphanCheckEquippedSkill + " in its equippedSkillCollection field has a non-nullable skill field.");
            }
            if (illegalOrphanMessages != null) {
                throw new IllegalOrphanException(illegalOrphanMessages);
            }
            Attribute attribute = skill.getAttribute();
            if (attribute != null) {
                attribute.getSkillCollection().remove(skill);
                attribute = em.merge(attribute);
            }
            Collection<Character> characterCollection = skill.getCharacterCollection();
            for (Character characterCollectionCharacter : characterCollection) {
                characterCollectionCharacter.getSkillCollection().remove(skill);
                characterCollectionCharacter = em.merge(characterCollectionCharacter);
            }
            em.remove(skill);
View Full Code Here

        equippedSkill.getEquippedSkillPK().setCharacterID(equippedSkill.getCharacter().getId());
        EntityManager em = null;
        try {
            em = getEntityManager();
            em.getTransaction().begin();
            Skill skill = equippedSkill.getSkill();
            if (skill != null) {
                skill = em.getReference(skill.getClass(), skill.getId());
                equippedSkill.setSkill(skill);
            }
            Character character = equippedSkill.getCharacter();
            if (character != null) {
                character = em.getReference(character.getClass(), character.getId());
                equippedSkill.setCharacter(character);
            }
            em.persist(equippedSkill);
            if (skill != null) {
                skill.getEquippedSkillCollection().add(equippedSkill);
                skill = em.merge(skill);
            }
            if (character != null) {
                character.getEquippedSkillCollection().add(equippedSkill);
                character = em.merge(character);
View Full Code Here

        EntityManager em = null;
        try {
            em = getEntityManager();
            em.getTransaction().begin();
            EquippedSkill persistentEquippedSkill = em.find(EquippedSkill.class, equippedSkill.getEquippedSkillPK());
            Skill skillOld = persistentEquippedSkill.getSkill();
            Skill skillNew = equippedSkill.getSkill();
            Character characterOld = persistentEquippedSkill.getCharacter();
            Character characterNew = equippedSkill.getCharacter();
            if (skillNew != null) {
                skillNew = em.getReference(skillNew.getClass(), skillNew.getId());
                equippedSkill.setSkill(skillNew);
            }
            if (characterNew != null) {
                characterNew = em.getReference(characterNew.getClass(), characterNew.getId());
                equippedSkill.setCharacter(characterNew);
            }
            equippedSkill = em.merge(equippedSkill);
            if (skillOld != null && !skillOld.equals(skillNew)) {
                skillOld.getEquippedSkillCollection().remove(equippedSkill);
                skillOld = em.merge(skillOld);
            }
            if (skillNew != null && !skillNew.equals(skillOld)) {
                skillNew.getEquippedSkillCollection().add(equippedSkill);
                skillNew = em.merge(skillNew);
            }
            if (characterOld != null && !characterOld.equals(characterNew)) {
                characterOld.getEquippedSkillCollection().remove(equippedSkill);
                characterOld = em.merge(characterOld);
View Full Code Here

                equippedSkill = em.getReference(EquippedSkill.class, id);
                equippedSkill.getEquippedSkillPK();
            } catch (EntityNotFoundException enfe) {
                throw new NonexistentEntityException("The equippedSkill with id " + id + " no longer exists.", enfe);
            }
            Skill skill = equippedSkill.getSkill();
            if (skill != null) {
                skill.getEquippedSkillCollection().remove(equippedSkill);
                skill = em.merge(skill);
            }
            Character character = equippedSkill.getCharacter();
            if (character != null) {
                character.getEquippedSkillCollection().remove(equippedSkill);
View Full Code Here

TOP

Related Classes of gwlpr.database.entities.Skill

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.