Package gwlpr.database.entities

Examples of gwlpr.database.entities.Profession


            for (Character characterCollectionCharacter : profession.getCharacterCollection()) {
                characterCollectionCharacter.getProfessionCollection().add(profession);
                characterCollectionCharacter = em.merge(characterCollectionCharacter);
            }
            for (Attribute attributeCollectionAttribute : profession.getAttributeCollection()) {
                Profession oldProfessionOfAttributeCollectionAttribute = attributeCollectionAttribute.getProfession();
                attributeCollectionAttribute.setProfession(profession);
                attributeCollectionAttribute = em.merge(attributeCollectionAttribute);
                if (oldProfessionOfAttributeCollectionAttribute != null) {
                    oldProfessionOfAttributeCollectionAttribute.getAttributeCollection().remove(attributeCollectionAttribute);
                    oldProfessionOfAttributeCollectionAttribute = em.merge(oldProfessionOfAttributeCollectionAttribute);
                }
            }
            for (Character characterCollection1Character : profession.getCharacterCollection1()) {
                Profession oldSecondaryProfessionOfCharacterCollection1Character = characterCollection1Character.getSecondaryProfession();
                characterCollection1Character.setSecondaryProfession(profession);
                characterCollection1Character = em.merge(characterCollection1Character);
                if (oldSecondaryProfessionOfCharacterCollection1Character != null) {
                    oldSecondaryProfessionOfCharacterCollection1Character.getCharacterCollection1().remove(characterCollection1Character);
                    oldSecondaryProfessionOfCharacterCollection1Character = em.merge(oldSecondaryProfessionOfCharacterCollection1Character);
                }
            }
            for (Character characterCollection2Character : profession.getCharacterCollection2()) {
                Profession oldPrimaryProfessionOfCharacterCollection2Character = characterCollection2Character.getPrimaryProfession();
                characterCollection2Character.setPrimaryProfession(profession);
                characterCollection2Character = em.merge(characterCollection2Character);
                if (oldPrimaryProfessionOfCharacterCollection2Character != null) {
                    oldPrimaryProfessionOfCharacterCollection2Character.getCharacterCollection2().remove(characterCollection2Character);
                    oldPrimaryProfessionOfCharacterCollection2Character = em.merge(oldPrimaryProfessionOfCharacterCollection2Character);
                }
            }
            em.getTransaction().commit();
        } finally {
View Full Code Here


    public void edit(Profession profession) throws IllegalOrphanException, NonexistentEntityException, Exception {
        EntityManager em = null;
        try {
            em = getEntityManager();
            em.getTransaction().begin();
            Profession persistentProfession = em.find(Profession.class, profession.getId());
            Collection<Character> characterCollectionOld = persistentProfession.getCharacterCollection();
            Collection<Character> characterCollectionNew = profession.getCharacterCollection();
            Collection<Attribute> attributeCollectionOld = persistentProfession.getAttributeCollection();
            Collection<Attribute> attributeCollectionNew = profession.getAttributeCollection();
            Collection<Character> characterCollection1Old = persistentProfession.getCharacterCollection1();
            Collection<Character> characterCollection1New = profession.getCharacterCollection1();
            Collection<Character> characterCollection2Old = persistentProfession.getCharacterCollection2();
            Collection<Character> characterCollection2New = profession.getCharacterCollection2();
            List<String> illegalOrphanMessages = null;
            for (Attribute attributeCollectionOldAttribute : attributeCollectionOld) {
                if (!attributeCollectionNew.contains(attributeCollectionOldAttribute)) {
                    if (illegalOrphanMessages == null) {
                        illegalOrphanMessages = new ArrayList<String>();
                    }
                    illegalOrphanMessages.add("You must retain Attribute " + attributeCollectionOldAttribute + " since its profession field is not nullable.");
                }
            }
            if (illegalOrphanMessages != null) {
                throw new IllegalOrphanException(illegalOrphanMessages);
            }
            Collection<Character> attachedCharacterCollectionNew = new ArrayList<Character>();
            for (Character characterCollectionNewCharacterToAttach : characterCollectionNew) {
                characterCollectionNewCharacterToAttach = em.getReference(characterCollectionNewCharacterToAttach.getClass(), characterCollectionNewCharacterToAttach.getId());
                attachedCharacterCollectionNew.add(characterCollectionNewCharacterToAttach);
            }
            characterCollectionNew = attachedCharacterCollectionNew;
            profession.setCharacterCollection(characterCollectionNew);
            Collection<Attribute> attachedAttributeCollectionNew = new ArrayList<Attribute>();
            for (Attribute attributeCollectionNewAttributeToAttach : attributeCollectionNew) {
                attributeCollectionNewAttributeToAttach = em.getReference(attributeCollectionNewAttributeToAttach.getClass(), attributeCollectionNewAttributeToAttach.getId());
                attachedAttributeCollectionNew.add(attributeCollectionNewAttributeToAttach);
            }
            attributeCollectionNew = attachedAttributeCollectionNew;
            profession.setAttributeCollection(attributeCollectionNew);
            Collection<Character> attachedCharacterCollection1New = new ArrayList<Character>();
            for (Character characterCollection1NewCharacterToAttach : characterCollection1New) {
                characterCollection1NewCharacterToAttach = em.getReference(characterCollection1NewCharacterToAttach.getClass(), characterCollection1NewCharacterToAttach.getId());
                attachedCharacterCollection1New.add(characterCollection1NewCharacterToAttach);
            }
            characterCollection1New = attachedCharacterCollection1New;
            profession.setCharacterCollection1(characterCollection1New);
            Collection<Character> attachedCharacterCollection2New = new ArrayList<Character>();
            for (Character characterCollection2NewCharacterToAttach : characterCollection2New) {
                characterCollection2NewCharacterToAttach = em.getReference(characterCollection2NewCharacterToAttach.getClass(), characterCollection2NewCharacterToAttach.getId());
                attachedCharacterCollection2New.add(characterCollection2NewCharacterToAttach);
            }
            characterCollection2New = attachedCharacterCollection2New;
            profession.setCharacterCollection2(characterCollection2New);
            profession = em.merge(profession);
            for (Character characterCollectionOldCharacter : characterCollectionOld) {
                if (!characterCollectionNew.contains(characterCollectionOldCharacter)) {
                    characterCollectionOldCharacter.getProfessionCollection().remove(profession);
                    characterCollectionOldCharacter = em.merge(characterCollectionOldCharacter);
                }
            }
            for (Character characterCollectionNewCharacter : characterCollectionNew) {
                if (!characterCollectionOld.contains(characterCollectionNewCharacter)) {
                    characterCollectionNewCharacter.getProfessionCollection().add(profession);
                    characterCollectionNewCharacter = em.merge(characterCollectionNewCharacter);
                }
            }
            for (Attribute attributeCollectionNewAttribute : attributeCollectionNew) {
                if (!attributeCollectionOld.contains(attributeCollectionNewAttribute)) {
                    Profession oldProfessionOfAttributeCollectionNewAttribute = attributeCollectionNewAttribute.getProfession();
                    attributeCollectionNewAttribute.setProfession(profession);
                    attributeCollectionNewAttribute = em.merge(attributeCollectionNewAttribute);
                    if (oldProfessionOfAttributeCollectionNewAttribute != null && !oldProfessionOfAttributeCollectionNewAttribute.equals(profession)) {
                        oldProfessionOfAttributeCollectionNewAttribute.getAttributeCollection().remove(attributeCollectionNewAttribute);
                        oldProfessionOfAttributeCollectionNewAttribute = em.merge(oldProfessionOfAttributeCollectionNewAttribute);
                    }
                }
            }
            for (Character characterCollection1OldCharacter : characterCollection1Old) {
                if (!characterCollection1New.contains(characterCollection1OldCharacter)) {
                    characterCollection1OldCharacter.setSecondaryProfession(null);
                    characterCollection1OldCharacter = em.merge(characterCollection1OldCharacter);
                }
            }
            for (Character characterCollection1NewCharacter : characterCollection1New) {
                if (!characterCollection1Old.contains(characterCollection1NewCharacter)) {
                    Profession oldSecondaryProfessionOfCharacterCollection1NewCharacter = characterCollection1NewCharacter.getSecondaryProfession();
                    characterCollection1NewCharacter.setSecondaryProfession(profession);
                    characterCollection1NewCharacter = em.merge(characterCollection1NewCharacter);
                    if (oldSecondaryProfessionOfCharacterCollection1NewCharacter != null && !oldSecondaryProfessionOfCharacterCollection1NewCharacter.equals(profession)) {
                        oldSecondaryProfessionOfCharacterCollection1NewCharacter.getCharacterCollection1().remove(characterCollection1NewCharacter);
                        oldSecondaryProfessionOfCharacterCollection1NewCharacter = em.merge(oldSecondaryProfessionOfCharacterCollection1NewCharacter);
                    }
                }
            }
            for (Character characterCollection2OldCharacter : characterCollection2Old) {
                if (!characterCollection2New.contains(characterCollection2OldCharacter)) {
                    characterCollection2OldCharacter.setPrimaryProfession(null);
                    characterCollection2OldCharacter = em.merge(characterCollection2OldCharacter);
                }
            }
            for (Character characterCollection2NewCharacter : characterCollection2New) {
                if (!characterCollection2Old.contains(characterCollection2NewCharacter)) {
                    Profession oldPrimaryProfessionOfCharacterCollection2NewCharacter = characterCollection2NewCharacter.getPrimaryProfession();
                    characterCollection2NewCharacter.setPrimaryProfession(profession);
                    characterCollection2NewCharacter = em.merge(characterCollection2NewCharacter);
                    if (oldPrimaryProfessionOfCharacterCollection2NewCharacter != null && !oldPrimaryProfessionOfCharacterCollection2NewCharacter.equals(profession)) {
                        oldPrimaryProfessionOfCharacterCollection2NewCharacter.getCharacterCollection2().remove(characterCollection2NewCharacter);
                        oldPrimaryProfessionOfCharacterCollection2NewCharacter = em.merge(oldPrimaryProfessionOfCharacterCollection2NewCharacter);
                    }
                }
            }
            em.getTransaction().commit();
View Full Code Here

    public void destroy(Integer id) throws IllegalOrphanException, NonexistentEntityException {
        EntityManager em = null;
        try {
            em = getEntityManager();
            em.getTransaction().begin();
            Profession profession;
            try {
                profession = em.getReference(Profession.class, id);
                profession.getId();
            } catch (EntityNotFoundException enfe) {
                throw new NonexistentEntityException("The profession with id " + id + " no longer exists.", enfe);
            }
            List<String> illegalOrphanMessages = null;
            Collection<Attribute> attributeCollectionOrphanCheck = profession.getAttributeCollection();
            for (Attribute attributeCollectionOrphanCheckAttribute : attributeCollectionOrphanCheck) {
                if (illegalOrphanMessages == null) {
                    illegalOrphanMessages = new ArrayList<String>();
                }
                illegalOrphanMessages.add("This Profession (" + profession + ") cannot be destroyed since the Attribute " + attributeCollectionOrphanCheckAttribute + " in its attributeCollection field has a non-nullable profession field.");
            }
            if (illegalOrphanMessages != null) {
                throw new IllegalOrphanException(illegalOrphanMessages);
            }
            Collection<Character> characterCollection = profession.getCharacterCollection();
            for (Character characterCollectionCharacter : characterCollection) {
                characterCollectionCharacter.getProfessionCollection().remove(profession);
                characterCollectionCharacter = em.merge(characterCollectionCharacter);
            }
            Collection<Character> characterCollection1 = profession.getCharacterCollection1();
            for (Character characterCollection1Character : characterCollection1) {
                characterCollection1Character.setSecondaryProfession(null);
                characterCollection1Character = em.merge(characterCollection1Character);
            }
            Collection<Character> characterCollection2 = profession.getCharacterCollection2();
            for (Character characterCollection2Character : characterCollection2) {
                characterCollection2Character.setPrimaryProfession(null);
                characterCollection2Character = em.merge(characterCollection2Character);
            }
            em.remove(profession);
View Full Code Here

        }
        EntityManager em = null;
        try {
            em = getEntityManager();
            em.getTransaction().begin();
            Profession secondaryProfession = character.getSecondaryProfession();
            if (secondaryProfession != null) {
                secondaryProfession = em.getReference(secondaryProfession.getClass(), secondaryProfession.getId());
                character.setSecondaryProfession(secondaryProfession);
            }
            Profession primaryProfession = character.getPrimaryProfession();
            if (primaryProfession != null) {
                primaryProfession = em.getReference(primaryProfession.getClass(), primaryProfession.getId());
                character.setPrimaryProfession(primaryProfession);
            }
            Level level = character.getLevel();
            if (level != null) {
                level = em.getReference(level.getClass(), level.getLevel());
                character.setLevel(level);
            }
            Map lastOutpost = character.getLastOutpost();
            if (lastOutpost != null) {
                lastOutpost = em.getReference(lastOutpost.getClass(), lastOutpost.getId());
                character.setLastOutpost(lastOutpost);
            }
            Inventory equipmentPack = character.getEquipmentPack();
            if (equipmentPack != null) {
                equipmentPack = em.getReference(equipmentPack.getClass(), equipmentPack.getId());
                character.setEquipmentPack(equipmentPack);
            }
            Inventory equipment = character.getEquipment();
            if (equipment != null) {
                equipment = em.getReference(equipment.getClass(), equipment.getId());
                character.setEquipment(equipment);
            }
            Inventory beltpouch = character.getBeltpouch();
            if (beltpouch != null) {
                beltpouch = em.getReference(beltpouch.getClass(), beltpouch.getId());
                character.setBeltpouch(beltpouch);
            }
            Inventory bag2 = character.getBag2();
            if (bag2 != null) {
                bag2 = em.getReference(bag2.getClass(), bag2.getId());
                character.setBag2(bag2);
            }
            Inventory bag1 = character.getBag1();
            if (bag1 != null) {
                bag1 = em.getReference(bag1.getClass(), bag1.getId());
                character.setBag1(bag1);
            }
            Inventory backpack = character.getBackpack();
            if (backpack != null) {
                backpack = em.getReference(backpack.getClass(), backpack.getId());
                character.setBackpack(backpack);
            }
            Account accountID = character.getAccountID();
            if (accountID != null) {
                accountID = em.getReference(accountID.getClass(), accountID.getEMail());
                character.setAccountID(accountID);
            }
            Collection<Skill> attachedSkillCollection = new ArrayList<Skill>();
            for (Skill skillCollectionSkillToAttach : character.getSkillCollection()) {
                skillCollectionSkillToAttach = em.getReference(skillCollectionSkillToAttach.getClass(), skillCollectionSkillToAttach.getId());
                attachedSkillCollection.add(skillCollectionSkillToAttach);
            }
            character.setSkillCollection(attachedSkillCollection);
            Collection<Profession> attachedProfessionCollection = new ArrayList<Profession>();
            for (Profession professionCollectionProfessionToAttach : character.getProfessionCollection()) {
                professionCollectionProfessionToAttach = em.getReference(professionCollectionProfessionToAttach.getClass(), professionCollectionProfessionToAttach.getId());
                attachedProfessionCollection.add(professionCollectionProfessionToAttach);
            }
            character.setProfessionCollection(attachedProfessionCollection);
            Collection<EquippedSkill> attachedEquippedSkillCollection = new ArrayList<EquippedSkill>();
            for (EquippedSkill equippedSkillCollectionEquippedSkillToAttach : character.getEquippedSkillCollection()) {
                equippedSkillCollectionEquippedSkillToAttach = em.getReference(equippedSkillCollectionEquippedSkillToAttach.getClass(), equippedSkillCollectionEquippedSkillToAttach.getEquippedSkillPK());
                attachedEquippedSkillCollection.add(equippedSkillCollectionEquippedSkillToAttach);
            }
            character.setEquippedSkillCollection(attachedEquippedSkillCollection);
            Collection<Weaponset> attachedWeaponsetCollection = new ArrayList<Weaponset>();
            for (Weaponset weaponsetCollectionWeaponsetToAttach : character.getWeaponsetCollection()) {
                weaponsetCollectionWeaponsetToAttach = em.getReference(weaponsetCollectionWeaponsetToAttach.getClass(), weaponsetCollectionWeaponsetToAttach.getWeaponsetPK());
                attachedWeaponsetCollection.add(weaponsetCollectionWeaponsetToAttach);
            }
            character.setWeaponsetCollection(attachedWeaponsetCollection);
            Collection<Item> attachedItemCollection = new ArrayList<Item>();
            for (Item itemCollectionItemToAttach : character.getItemCollection()) {
                itemCollectionItemToAttach = em.getReference(itemCollectionItemToAttach.getClass(), itemCollectionItemToAttach.getId());
                attachedItemCollection.add(itemCollectionItemToAttach);
            }
            character.setItemCollection(attachedItemCollection);
            Collection<Attributepoint> attachedAttributepointCollection = new ArrayList<Attributepoint>();
            for (Attributepoint attributepointCollectionAttributepointToAttach : character.getAttributepointCollection()) {
                attributepointCollectionAttributepointToAttach = em.getReference(attributepointCollectionAttributepointToAttach.getClass(), attributepointCollectionAttributepointToAttach.getAttributepointPK());
                attachedAttributepointCollection.add(attributepointCollectionAttributepointToAttach);
            }
            character.setAttributepointCollection(attachedAttributepointCollection);
            em.persist(character);
            if (secondaryProfession != null) {
                secondaryProfession.getCharacterCollection().add(character);
                secondaryProfession = em.merge(secondaryProfession);
            }
            if (primaryProfession != null) {
                primaryProfession.getCharacterCollection().add(character);
                primaryProfession = em.merge(primaryProfession);
            }
            if (level != null) {
                level.getCharacterCollection().add(character);
                level = em.merge(level);
View Full Code Here

        EntityManager em = null;
        try {
            em = getEntityManager();
            em.getTransaction().begin();
            Character persistentCharacter = em.find(Character.class, character.getId());
            Profession secondaryProfessionOld = persistentCharacter.getSecondaryProfession();
            Profession secondaryProfessionNew = character.getSecondaryProfession();
            Profession primaryProfessionOld = persistentCharacter.getPrimaryProfession();
            Profession primaryProfessionNew = character.getPrimaryProfession();
            Level levelOld = persistentCharacter.getLevel();
            Level levelNew = character.getLevel();
            Map lastOutpostOld = persistentCharacter.getLastOutpost();
            Map lastOutpostNew = character.getLastOutpost();
            Inventory equipmentPackOld = persistentCharacter.getEquipmentPack();
            Inventory equipmentPackNew = character.getEquipmentPack();
            Inventory equipmentOld = persistentCharacter.getEquipment();
            Inventory equipmentNew = character.getEquipment();
            Inventory beltpouchOld = persistentCharacter.getBeltpouch();
            Inventory beltpouchNew = character.getBeltpouch();
            Inventory bag2Old = persistentCharacter.getBag2();
            Inventory bag2New = character.getBag2();
            Inventory bag1Old = persistentCharacter.getBag1();
            Inventory bag1New = character.getBag1();
            Inventory backpackOld = persistentCharacter.getBackpack();
            Inventory backpackNew = character.getBackpack();
            Account accountIDOld = persistentCharacter.getAccountID();
            Account accountIDNew = character.getAccountID();
            Collection<Skill> skillCollectionOld = persistentCharacter.getSkillCollection();
            Collection<Skill> skillCollectionNew = character.getSkillCollection();
            Collection<Profession> professionCollectionOld = persistentCharacter.getProfessionCollection();
            Collection<Profession> professionCollectionNew = character.getProfessionCollection();
            Collection<EquippedSkill> equippedSkillCollectionOld = persistentCharacter.getEquippedSkillCollection();
            Collection<EquippedSkill> equippedSkillCollectionNew = character.getEquippedSkillCollection();
            Collection<Weaponset> weaponsetCollectionOld = persistentCharacter.getWeaponsetCollection();
            Collection<Weaponset> weaponsetCollectionNew = character.getWeaponsetCollection();
            Collection<Item> itemCollectionOld = persistentCharacter.getItemCollection();
            Collection<Item> itemCollectionNew = character.getItemCollection();
            Collection<Attributepoint> attributepointCollectionOld = persistentCharacter.getAttributepointCollection();
            Collection<Attributepoint> attributepointCollectionNew = character.getAttributepointCollection();
            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 character field is not nullable.");
                }
            }
            for (Weaponset weaponsetCollectionOldWeaponset : weaponsetCollectionOld) {
                if (!weaponsetCollectionNew.contains(weaponsetCollectionOldWeaponset)) {
                    if (illegalOrphanMessages == null) {
                        illegalOrphanMessages = new ArrayList<String>();
                    }
                    illegalOrphanMessages.add("You must retain Weaponset " + weaponsetCollectionOldWeaponset + " since its character field is not nullable.");
                }
            }
            for (Attributepoint attributepointCollectionOldAttributepoint : attributepointCollectionOld) {
                if (!attributepointCollectionNew.contains(attributepointCollectionOldAttributepoint)) {
                    if (illegalOrphanMessages == null) {
                        illegalOrphanMessages = new ArrayList<String>();
                    }
                    illegalOrphanMessages.add("You must retain Attributepoint " + attributepointCollectionOldAttributepoint + " since its character field is not nullable.");
                }
            }
            if (illegalOrphanMessages != null) {
                throw new IllegalOrphanException(illegalOrphanMessages);
            }
            if (secondaryProfessionNew != null) {
                secondaryProfessionNew = em.getReference(secondaryProfessionNew.getClass(), secondaryProfessionNew.getId());
                character.setSecondaryProfession(secondaryProfessionNew);
            }
            if (primaryProfessionNew != null) {
                primaryProfessionNew = em.getReference(primaryProfessionNew.getClass(), primaryProfessionNew.getId());
                character.setPrimaryProfession(primaryProfessionNew);
            }
            if (levelNew != null) {
                levelNew = em.getReference(levelNew.getClass(), levelNew.getLevel());
                character.setLevel(levelNew);
            }
            if (lastOutpostNew != null) {
                lastOutpostNew = em.getReference(lastOutpostNew.getClass(), lastOutpostNew.getId());
                character.setLastOutpost(lastOutpostNew);
            }
            if (equipmentPackNew != null) {
                equipmentPackNew = em.getReference(equipmentPackNew.getClass(), equipmentPackNew.getId());
                character.setEquipmentPack(equipmentPackNew);
            }
            if (equipmentNew != null) {
                equipmentNew = em.getReference(equipmentNew.getClass(), equipmentNew.getId());
                character.setEquipment(equipmentNew);
            }
            if (beltpouchNew != null) {
                beltpouchNew = em.getReference(beltpouchNew.getClass(), beltpouchNew.getId());
                character.setBeltpouch(beltpouchNew);
            }
            if (bag2New != null) {
                bag2New = em.getReference(bag2New.getClass(), bag2New.getId());
                character.setBag2(bag2New);
            }
            if (bag1New != null) {
                bag1New = em.getReference(bag1New.getClass(), bag1New.getId());
                character.setBag1(bag1New);
            }
            if (backpackNew != null) {
                backpackNew = em.getReference(backpackNew.getClass(), backpackNew.getId());
                character.setBackpack(backpackNew);
            }
            if (accountIDNew != null) {
                accountIDNew = em.getReference(accountIDNew.getClass(), accountIDNew.getEMail());
                character.setAccountID(accountIDNew);
            }
            Collection<Skill> attachedSkillCollectionNew = new ArrayList<Skill>();
            for (Skill skillCollectionNewSkillToAttach : skillCollectionNew) {
                skillCollectionNewSkillToAttach = em.getReference(skillCollectionNewSkillToAttach.getClass(), skillCollectionNewSkillToAttach.getId());
                attachedSkillCollectionNew.add(skillCollectionNewSkillToAttach);
            }
            skillCollectionNew = attachedSkillCollectionNew;
            character.setSkillCollection(skillCollectionNew);
            Collection<Profession> attachedProfessionCollectionNew = new ArrayList<Profession>();
            for (Profession professionCollectionNewProfessionToAttach : professionCollectionNew) {
                professionCollectionNewProfessionToAttach = em.getReference(professionCollectionNewProfessionToAttach.getClass(), professionCollectionNewProfessionToAttach.getId());
                attachedProfessionCollectionNew.add(professionCollectionNewProfessionToAttach);
            }
            professionCollectionNew = attachedProfessionCollectionNew;
            character.setProfessionCollection(professionCollectionNew);
            Collection<EquippedSkill> attachedEquippedSkillCollectionNew = new ArrayList<EquippedSkill>();
            for (EquippedSkill equippedSkillCollectionNewEquippedSkillToAttach : equippedSkillCollectionNew) {
                equippedSkillCollectionNewEquippedSkillToAttach = em.getReference(equippedSkillCollectionNewEquippedSkillToAttach.getClass(), equippedSkillCollectionNewEquippedSkillToAttach.getEquippedSkillPK());
                attachedEquippedSkillCollectionNew.add(equippedSkillCollectionNewEquippedSkillToAttach);
            }
            equippedSkillCollectionNew = attachedEquippedSkillCollectionNew;
            character.setEquippedSkillCollection(equippedSkillCollectionNew);
            Collection<Weaponset> attachedWeaponsetCollectionNew = new ArrayList<Weaponset>();
            for (Weaponset weaponsetCollectionNewWeaponsetToAttach : weaponsetCollectionNew) {
                weaponsetCollectionNewWeaponsetToAttach = em.getReference(weaponsetCollectionNewWeaponsetToAttach.getClass(), weaponsetCollectionNewWeaponsetToAttach.getWeaponsetPK());
                attachedWeaponsetCollectionNew.add(weaponsetCollectionNewWeaponsetToAttach);
            }
            weaponsetCollectionNew = attachedWeaponsetCollectionNew;
            character.setWeaponsetCollection(weaponsetCollectionNew);
            Collection<Item> attachedItemCollectionNew = new ArrayList<Item>();
            for (Item itemCollectionNewItemToAttach : itemCollectionNew) {
                itemCollectionNewItemToAttach = em.getReference(itemCollectionNewItemToAttach.getClass(), itemCollectionNewItemToAttach.getId());
                attachedItemCollectionNew.add(itemCollectionNewItemToAttach);
            }
            itemCollectionNew = attachedItemCollectionNew;
            character.setItemCollection(itemCollectionNew);
            Collection<Attributepoint> attachedAttributepointCollectionNew = new ArrayList<Attributepoint>();
            for (Attributepoint attributepointCollectionNewAttributepointToAttach : attributepointCollectionNew) {
                attributepointCollectionNewAttributepointToAttach = em.getReference(attributepointCollectionNewAttributepointToAttach.getClass(), attributepointCollectionNewAttributepointToAttach.getAttributepointPK());
                attachedAttributepointCollectionNew.add(attributepointCollectionNewAttributepointToAttach);
            }
            attributepointCollectionNew = attachedAttributepointCollectionNew;
            character.setAttributepointCollection(attributepointCollectionNew);
            character = em.merge(character);
            if (secondaryProfessionOld != null && !secondaryProfessionOld.equals(secondaryProfessionNew)) {
                secondaryProfessionOld.getCharacterCollection().remove(character);
                secondaryProfessionOld = em.merge(secondaryProfessionOld);
            }
            if (secondaryProfessionNew != null && !secondaryProfessionNew.equals(secondaryProfessionOld)) {
                secondaryProfessionNew.getCharacterCollection().add(character);
                secondaryProfessionNew = em.merge(secondaryProfessionNew);
            }
            if (primaryProfessionOld != null && !primaryProfessionOld.equals(primaryProfessionNew)) {
                primaryProfessionOld.getCharacterCollection().remove(character);
                primaryProfessionOld = em.merge(primaryProfessionOld);
            }
            if (primaryProfessionNew != null && !primaryProfessionNew.equals(primaryProfessionOld)) {
                primaryProfessionNew.getCharacterCollection().add(character);
                primaryProfessionNew = em.merge(primaryProfessionNew);
            }
            if (levelOld != null && !levelOld.equals(levelNew)) {
                levelOld.getCharacterCollection().remove(character);
                levelOld = em.merge(levelOld);
View Full Code Here

                illegalOrphanMessages.add("This Character (" + character + ") cannot be destroyed since the Attributepoint " + attributepointCollectionOrphanCheckAttributepoint + " in its attributepointCollection field has a non-nullable character field.");
            }
            if (illegalOrphanMessages != null) {
                throw new IllegalOrphanException(illegalOrphanMessages);
            }
            Profession secondaryProfession = character.getSecondaryProfession();
            if (secondaryProfession != null) {
                secondaryProfession.getCharacterCollection().remove(character);
                secondaryProfession = em.merge(secondaryProfession);
            }
            Profession primaryProfession = character.getPrimaryProfession();
            if (primaryProfession != null) {
                primaryProfession.getCharacterCollection().remove(character);
                primaryProfession = em.merge(primaryProfession);
            }
            Level level = character.getLevel();
            if (level != null) {
                level.getCharacterCollection().remove(character);
View Full Code Here

        }
        EntityManager em = null;
        try {
            em = getEntityManager();
            em.getTransaction().begin();
            Profession profession = attribute.getProfession();
            if (profession != null) {
                profession = em.getReference(profession.getClass(), profession.getId());
                attribute.setProfession(profession);
            }
            Collection<Skill> attachedSkillCollection = new ArrayList<Skill>();
            for (Skill skillCollectionSkillToAttach : attribute.getSkillCollection()) {
                skillCollectionSkillToAttach = em.getReference(skillCollectionSkillToAttach.getClass(), skillCollectionSkillToAttach.getId());
                attachedSkillCollection.add(skillCollectionSkillToAttach);
            }
            attribute.setSkillCollection(attachedSkillCollection);
            Collection<Attributepoint> attachedAttributepointCollection = new ArrayList<Attributepoint>();
            for (Attributepoint attributepointCollectionAttributepointToAttach : attribute.getAttributepointCollection()) {
                attributepointCollectionAttributepointToAttach = em.getReference(attributepointCollectionAttributepointToAttach.getClass(), attributepointCollectionAttributepointToAttach.getAttributepointPK());
                attachedAttributepointCollection.add(attributepointCollectionAttributepointToAttach);
            }
            attribute.setAttributepointCollection(attachedAttributepointCollection);
            em.persist(attribute);
            if (profession != null) {
                profession.getAttributeCollection().add(attribute);
                profession = em.merge(profession);
            }
            for (Skill skillCollectionSkill : attribute.getSkillCollection()) {
                Attribute oldAttributeOfSkillCollectionSkill = skillCollectionSkill.getAttribute();
                skillCollectionSkill.setAttribute(attribute);
View Full Code Here

        EntityManager em = null;
        try {
            em = getEntityManager();
            em.getTransaction().begin();
            Attribute persistentAttribute = em.find(Attribute.class, attribute.getId());
            Profession professionOld = persistentAttribute.getProfession();
            Profession professionNew = attribute.getProfession();
            Collection<Skill> skillCollectionOld = persistentAttribute.getSkillCollection();
            Collection<Skill> skillCollectionNew = attribute.getSkillCollection();
            Collection<Attributepoint> attributepointCollectionOld = persistentAttribute.getAttributepointCollection();
            Collection<Attributepoint> attributepointCollectionNew = attribute.getAttributepointCollection();
            List<String> illegalOrphanMessages = null;
            for (Skill skillCollectionOldSkill : skillCollectionOld) {
                if (!skillCollectionNew.contains(skillCollectionOldSkill)) {
                    if (illegalOrphanMessages == null) {
                        illegalOrphanMessages = new ArrayList<String>();
                    }
                    illegalOrphanMessages.add("You must retain Skill " + skillCollectionOldSkill + " since its attribute field is not nullable.");
                }
            }
            for (Attributepoint attributepointCollectionOldAttributepoint : attributepointCollectionOld) {
                if (!attributepointCollectionNew.contains(attributepointCollectionOldAttributepoint)) {
                    if (illegalOrphanMessages == null) {
                        illegalOrphanMessages = new ArrayList<String>();
                    }
                    illegalOrphanMessages.add("You must retain Attributepoint " + attributepointCollectionOldAttributepoint + " since its attribute field is not nullable.");
                }
            }
            if (illegalOrphanMessages != null) {
                throw new IllegalOrphanException(illegalOrphanMessages);
            }
            if (professionNew != null) {
                professionNew = em.getReference(professionNew.getClass(), professionNew.getId());
                attribute.setProfession(professionNew);
            }
            Collection<Skill> attachedSkillCollectionNew = new ArrayList<Skill>();
            for (Skill skillCollectionNewSkillToAttach : skillCollectionNew) {
                skillCollectionNewSkillToAttach = em.getReference(skillCollectionNewSkillToAttach.getClass(), skillCollectionNewSkillToAttach.getId());
                attachedSkillCollectionNew.add(skillCollectionNewSkillToAttach);
            }
            skillCollectionNew = attachedSkillCollectionNew;
            attribute.setSkillCollection(skillCollectionNew);
            Collection<Attributepoint> attachedAttributepointCollectionNew = new ArrayList<Attributepoint>();
            for (Attributepoint attributepointCollectionNewAttributepointToAttach : attributepointCollectionNew) {
                attributepointCollectionNewAttributepointToAttach = em.getReference(attributepointCollectionNewAttributepointToAttach.getClass(), attributepointCollectionNewAttributepointToAttach.getAttributepointPK());
                attachedAttributepointCollectionNew.add(attributepointCollectionNewAttributepointToAttach);
            }
            attributepointCollectionNew = attachedAttributepointCollectionNew;
            attribute.setAttributepointCollection(attributepointCollectionNew);
            attribute = em.merge(attribute);
            if (professionOld != null && !professionOld.equals(professionNew)) {
                professionOld.getAttributeCollection().remove(attribute);
                professionOld = em.merge(professionOld);
            }
            if (professionNew != null && !professionNew.equals(professionOld)) {
                professionNew.getAttributeCollection().add(attribute);
                professionNew = em.merge(professionNew);
            }
            for (Skill skillCollectionNewSkill : skillCollectionNew) {
                if (!skillCollectionOld.contains(skillCollectionNewSkill)) {
                    Attribute oldAttributeOfSkillCollectionNewSkill = skillCollectionNewSkill.getAttribute();
View Full Code Here

                illegalOrphanMessages.add("This Attribute (" + attribute + ") cannot be destroyed since the Attributepoint " + attributepointCollectionOrphanCheckAttributepoint + " in its attributepointCollection field has a non-nullable attribute field.");
            }
            if (illegalOrphanMessages != null) {
                throw new IllegalOrphanException(illegalOrphanMessages);
            }
            Profession profession = attribute.getProfession();
            if (profession != null) {
                profession.getAttributeCollection().remove(attribute);
                profession = em.merge(profession);
            }
            em.remove(attribute);
            em.getTransaction().commit();
        } finally {
View Full Code Here

TOP

Related Classes of gwlpr.database.entities.Profession

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.