Package gwlpr.database.entities

Examples of gwlpr.database.entities.Inventory


                attachedCharacterCollection5.add(characterCollection5CharacterToAttach);
            }
            inventory.setCharacterCollection5(attachedCharacterCollection5);
            em.persist(inventory);
            for (Account accountCollectionAccount : inventory.getAccountCollection()) {
                Inventory oldMaterialStorageOfAccountCollectionAccount = accountCollectionAccount.getMaterialStorage();
                accountCollectionAccount.setMaterialStorage(inventory);
                accountCollectionAccount = em.merge(accountCollectionAccount);
                if (oldMaterialStorageOfAccountCollectionAccount != null) {
                    oldMaterialStorageOfAccountCollectionAccount.getAccountCollection().remove(accountCollectionAccount);
                    oldMaterialStorageOfAccountCollectionAccount = em.merge(oldMaterialStorageOfAccountCollectionAccount);
                }
            }
            for (Storagetab storagetabCollectionStoragetab : inventory.getStoragetabCollection()) {
                Inventory oldInventoryIDOfStoragetabCollectionStoragetab = storagetabCollectionStoragetab.getInventoryID();
                storagetabCollectionStoragetab.setInventoryID(inventory);
                storagetabCollectionStoragetab = em.merge(storagetabCollectionStoragetab);
                if (oldInventoryIDOfStoragetabCollectionStoragetab != null) {
                    oldInventoryIDOfStoragetabCollectionStoragetab.getStoragetabCollection().remove(storagetabCollectionStoragetab);
                    oldInventoryIDOfStoragetabCollectionStoragetab = em.merge(oldInventoryIDOfStoragetabCollectionStoragetab);
                }
            }
            for (Storeditem storeditemCollectionStoreditem : inventory.getStoreditemCollection()) {
                Inventory oldInventoryOfStoreditemCollectionStoreditem = storeditemCollectionStoreditem.getInventory();
                storeditemCollectionStoreditem.setInventory(inventory);
                storeditemCollectionStoreditem = em.merge(storeditemCollectionStoreditem);
                if (oldInventoryOfStoreditemCollectionStoreditem != null) {
                    oldInventoryOfStoreditemCollectionStoreditem.getStoreditemCollection().remove(storeditemCollectionStoreditem);
                    oldInventoryOfStoreditemCollectionStoreditem = em.merge(oldInventoryOfStoreditemCollectionStoreditem);
                }
            }
            for (Character characterCollectionCharacter : inventory.getCharacterCollection()) {
                Inventory oldEquipmentPackOfCharacterCollectionCharacter = characterCollectionCharacter.getEquipmentPack();
                characterCollectionCharacter.setEquipmentPack(inventory);
                characterCollectionCharacter = em.merge(characterCollectionCharacter);
                if (oldEquipmentPackOfCharacterCollectionCharacter != null) {
                    oldEquipmentPackOfCharacterCollectionCharacter.getCharacterCollection().remove(characterCollectionCharacter);
                    oldEquipmentPackOfCharacterCollectionCharacter = em.merge(oldEquipmentPackOfCharacterCollectionCharacter);
                }
            }
            for (Character characterCollection1Character : inventory.getCharacterCollection1()) {
                Inventory oldEquipmentOfCharacterCollection1Character = characterCollection1Character.getEquipment();
                characterCollection1Character.setEquipment(inventory);
                characterCollection1Character = em.merge(characterCollection1Character);
                if (oldEquipmentOfCharacterCollection1Character != null) {
                    oldEquipmentOfCharacterCollection1Character.getCharacterCollection1().remove(characterCollection1Character);
                    oldEquipmentOfCharacterCollection1Character = em.merge(oldEquipmentOfCharacterCollection1Character);
                }
            }
            for (Character characterCollection2Character : inventory.getCharacterCollection2()) {
                Inventory oldBeltpouchOfCharacterCollection2Character = characterCollection2Character.getBeltpouch();
                characterCollection2Character.setBeltpouch(inventory);
                characterCollection2Character = em.merge(characterCollection2Character);
                if (oldBeltpouchOfCharacterCollection2Character != null) {
                    oldBeltpouchOfCharacterCollection2Character.getCharacterCollection2().remove(characterCollection2Character);
                    oldBeltpouchOfCharacterCollection2Character = em.merge(oldBeltpouchOfCharacterCollection2Character);
                }
            }
            for (Character characterCollection3Character : inventory.getCharacterCollection3()) {
                Inventory oldBag2OfCharacterCollection3Character = characterCollection3Character.getBag2();
                characterCollection3Character.setBag2(inventory);
                characterCollection3Character = em.merge(characterCollection3Character);
                if (oldBag2OfCharacterCollection3Character != null) {
                    oldBag2OfCharacterCollection3Character.getCharacterCollection3().remove(characterCollection3Character);
                    oldBag2OfCharacterCollection3Character = em.merge(oldBag2OfCharacterCollection3Character);
                }
            }
            for (Character characterCollection4Character : inventory.getCharacterCollection4()) {
                Inventory oldBag1OfCharacterCollection4Character = characterCollection4Character.getBag1();
                characterCollection4Character.setBag1(inventory);
                characterCollection4Character = em.merge(characterCollection4Character);
                if (oldBag1OfCharacterCollection4Character != null) {
                    oldBag1OfCharacterCollection4Character.getCharacterCollection4().remove(characterCollection4Character);
                    oldBag1OfCharacterCollection4Character = em.merge(oldBag1OfCharacterCollection4Character);
                }
            }
            for (Character characterCollection5Character : inventory.getCharacterCollection5()) {
                Inventory oldBackpackOfCharacterCollection5Character = characterCollection5Character.getBackpack();
                characterCollection5Character.setBackpack(inventory);
                characterCollection5Character = em.merge(characterCollection5Character);
                if (oldBackpackOfCharacterCollection5Character != null) {
                    oldBackpackOfCharacterCollection5Character.getCharacterCollection5().remove(characterCollection5Character);
                    oldBackpackOfCharacterCollection5Character = em.merge(oldBackpackOfCharacterCollection5Character);
                }
            }
            em.getTransaction().commit();
        } finally {
View Full Code Here


    public void edit(Inventory inventory) throws IllegalOrphanException, NonexistentEntityException, Exception {
        EntityManager em = null;
        try {
            em = getEntityManager();
            em.getTransaction().begin();
            Inventory persistentInventory = em.find(Inventory.class, inventory.getId());
            Collection<Account> accountCollectionOld = persistentInventory.getAccountCollection();
            Collection<Account> accountCollectionNew = inventory.getAccountCollection();
            Collection<Storagetab> storagetabCollectionOld = persistentInventory.getStoragetabCollection();
            Collection<Storagetab> storagetabCollectionNew = inventory.getStoragetabCollection();
            Collection<Storeditem> storeditemCollectionOld = persistentInventory.getStoreditemCollection();
            Collection<Storeditem> storeditemCollectionNew = inventory.getStoreditemCollection();
            Collection<Character> characterCollectionOld = persistentInventory.getCharacterCollection();
            Collection<Character> characterCollectionNew = inventory.getCharacterCollection();
            Collection<Character> characterCollection1Old = persistentInventory.getCharacterCollection1();
            Collection<Character> characterCollection1New = inventory.getCharacterCollection1();
            Collection<Character> characterCollection2Old = persistentInventory.getCharacterCollection2();
            Collection<Character> characterCollection2New = inventory.getCharacterCollection2();
            Collection<Character> characterCollection3Old = persistentInventory.getCharacterCollection3();
            Collection<Character> characterCollection3New = inventory.getCharacterCollection3();
            Collection<Character> characterCollection4Old = persistentInventory.getCharacterCollection4();
            Collection<Character> characterCollection4New = inventory.getCharacterCollection4();
            Collection<Character> characterCollection5Old = persistentInventory.getCharacterCollection5();
            Collection<Character> characterCollection5New = inventory.getCharacterCollection5();
            List<String> illegalOrphanMessages = null;
            for (Storagetab storagetabCollectionOldStoragetab : storagetabCollectionOld) {
                if (!storagetabCollectionNew.contains(storagetabCollectionOldStoragetab)) {
                    if (illegalOrphanMessages == null) {
                        illegalOrphanMessages = new ArrayList<String>();
                    }
                    illegalOrphanMessages.add("You must retain Storagetab " + storagetabCollectionOldStoragetab + " since its inventoryID field is not nullable.");
                }
            }
            for (Storeditem storeditemCollectionOldStoreditem : storeditemCollectionOld) {
                if (!storeditemCollectionNew.contains(storeditemCollectionOldStoreditem)) {
                    if (illegalOrphanMessages == null) {
                        illegalOrphanMessages = new ArrayList<String>();
                    }
                    illegalOrphanMessages.add("You must retain Storeditem " + storeditemCollectionOldStoreditem + " since its inventory field is not nullable.");
                }
            }
            if (illegalOrphanMessages != null) {
                throw new IllegalOrphanException(illegalOrphanMessages);
            }
            Collection<Account> attachedAccountCollectionNew = new ArrayList<Account>();
            for (Account accountCollectionNewAccountToAttach : accountCollectionNew) {
                accountCollectionNewAccountToAttach = em.getReference(accountCollectionNewAccountToAttach.getClass(), accountCollectionNewAccountToAttach.getEMail());
                attachedAccountCollectionNew.add(accountCollectionNewAccountToAttach);
            }
            accountCollectionNew = attachedAccountCollectionNew;
            inventory.setAccountCollection(accountCollectionNew);
            Collection<Storagetab> attachedStoragetabCollectionNew = new ArrayList<Storagetab>();
            for (Storagetab storagetabCollectionNewStoragetabToAttach : storagetabCollectionNew) {
                storagetabCollectionNewStoragetabToAttach = em.getReference(storagetabCollectionNewStoragetabToAttach.getClass(), storagetabCollectionNewStoragetabToAttach.getStoragetabPK());
                attachedStoragetabCollectionNew.add(storagetabCollectionNewStoragetabToAttach);
            }
            storagetabCollectionNew = attachedStoragetabCollectionNew;
            inventory.setStoragetabCollection(storagetabCollectionNew);
            Collection<Storeditem> attachedStoreditemCollectionNew = new ArrayList<Storeditem>();
            for (Storeditem storeditemCollectionNewStoreditemToAttach : storeditemCollectionNew) {
                storeditemCollectionNewStoreditemToAttach = em.getReference(storeditemCollectionNewStoreditemToAttach.getClass(), storeditemCollectionNewStoreditemToAttach.getStoreditemPK());
                attachedStoreditemCollectionNew.add(storeditemCollectionNewStoreditemToAttach);
            }
            storeditemCollectionNew = attachedStoreditemCollectionNew;
            inventory.setStoreditemCollection(storeditemCollectionNew);
            Collection<Character> attachedCharacterCollectionNew = new ArrayList<Character>();
            for (Character characterCollectionNewCharacterToAttach : characterCollectionNew) {
                characterCollectionNewCharacterToAttach = em.getReference(characterCollectionNewCharacterToAttach.getClass(), characterCollectionNewCharacterToAttach.getId());
                attachedCharacterCollectionNew.add(characterCollectionNewCharacterToAttach);
            }
            characterCollectionNew = attachedCharacterCollectionNew;
            inventory.setCharacterCollection(characterCollectionNew);
            Collection<Character> attachedCharacterCollection1New = new ArrayList<Character>();
            for (Character characterCollection1NewCharacterToAttach : characterCollection1New) {
                characterCollection1NewCharacterToAttach = em.getReference(characterCollection1NewCharacterToAttach.getClass(), characterCollection1NewCharacterToAttach.getId());
                attachedCharacterCollection1New.add(characterCollection1NewCharacterToAttach);
            }
            characterCollection1New = attachedCharacterCollection1New;
            inventory.setCharacterCollection1(characterCollection1New);
            Collection<Character> attachedCharacterCollection2New = new ArrayList<Character>();
            for (Character characterCollection2NewCharacterToAttach : characterCollection2New) {
                characterCollection2NewCharacterToAttach = em.getReference(characterCollection2NewCharacterToAttach.getClass(), characterCollection2NewCharacterToAttach.getId());
                attachedCharacterCollection2New.add(characterCollection2NewCharacterToAttach);
            }
            characterCollection2New = attachedCharacterCollection2New;
            inventory.setCharacterCollection2(characterCollection2New);
            Collection<Character> attachedCharacterCollection3New = new ArrayList<Character>();
            for (Character characterCollection3NewCharacterToAttach : characterCollection3New) {
                characterCollection3NewCharacterToAttach = em.getReference(characterCollection3NewCharacterToAttach.getClass(), characterCollection3NewCharacterToAttach.getId());
                attachedCharacterCollection3New.add(characterCollection3NewCharacterToAttach);
            }
            characterCollection3New = attachedCharacterCollection3New;
            inventory.setCharacterCollection3(characterCollection3New);
            Collection<Character> attachedCharacterCollection4New = new ArrayList<Character>();
            for (Character characterCollection4NewCharacterToAttach : characterCollection4New) {
                characterCollection4NewCharacterToAttach = em.getReference(characterCollection4NewCharacterToAttach.getClass(), characterCollection4NewCharacterToAttach.getId());
                attachedCharacterCollection4New.add(characterCollection4NewCharacterToAttach);
            }
            characterCollection4New = attachedCharacterCollection4New;
            inventory.setCharacterCollection4(characterCollection4New);
            Collection<Character> attachedCharacterCollection5New = new ArrayList<Character>();
            for (Character characterCollection5NewCharacterToAttach : characterCollection5New) {
                characterCollection5NewCharacterToAttach = em.getReference(characterCollection5NewCharacterToAttach.getClass(), characterCollection5NewCharacterToAttach.getId());
                attachedCharacterCollection5New.add(characterCollection5NewCharacterToAttach);
            }
            characterCollection5New = attachedCharacterCollection5New;
            inventory.setCharacterCollection5(characterCollection5New);
            inventory = em.merge(inventory);
            for (Account accountCollectionOldAccount : accountCollectionOld) {
                if (!accountCollectionNew.contains(accountCollectionOldAccount)) {
                    accountCollectionOldAccount.setMaterialStorage(null);
                    accountCollectionOldAccount = em.merge(accountCollectionOldAccount);
                }
            }
            for (Account accountCollectionNewAccount : accountCollectionNew) {
                if (!accountCollectionOld.contains(accountCollectionNewAccount)) {
                    Inventory oldMaterialStorageOfAccountCollectionNewAccount = accountCollectionNewAccount.getMaterialStorage();
                    accountCollectionNewAccount.setMaterialStorage(inventory);
                    accountCollectionNewAccount = em.merge(accountCollectionNewAccount);
                    if (oldMaterialStorageOfAccountCollectionNewAccount != null && !oldMaterialStorageOfAccountCollectionNewAccount.equals(inventory)) {
                        oldMaterialStorageOfAccountCollectionNewAccount.getAccountCollection().remove(accountCollectionNewAccount);
                        oldMaterialStorageOfAccountCollectionNewAccount = em.merge(oldMaterialStorageOfAccountCollectionNewAccount);
                    }
                }
            }
            for (Storagetab storagetabCollectionNewStoragetab : storagetabCollectionNew) {
                if (!storagetabCollectionOld.contains(storagetabCollectionNewStoragetab)) {
                    Inventory oldInventoryIDOfStoragetabCollectionNewStoragetab = storagetabCollectionNewStoragetab.getInventoryID();
                    storagetabCollectionNewStoragetab.setInventoryID(inventory);
                    storagetabCollectionNewStoragetab = em.merge(storagetabCollectionNewStoragetab);
                    if (oldInventoryIDOfStoragetabCollectionNewStoragetab != null && !oldInventoryIDOfStoragetabCollectionNewStoragetab.equals(inventory)) {
                        oldInventoryIDOfStoragetabCollectionNewStoragetab.getStoragetabCollection().remove(storagetabCollectionNewStoragetab);
                        oldInventoryIDOfStoragetabCollectionNewStoragetab = em.merge(oldInventoryIDOfStoragetabCollectionNewStoragetab);
                    }
                }
            }
            for (Storeditem storeditemCollectionNewStoreditem : storeditemCollectionNew) {
                if (!storeditemCollectionOld.contains(storeditemCollectionNewStoreditem)) {
                    Inventory oldInventoryOfStoreditemCollectionNewStoreditem = storeditemCollectionNewStoreditem.getInventory();
                    storeditemCollectionNewStoreditem.setInventory(inventory);
                    storeditemCollectionNewStoreditem = em.merge(storeditemCollectionNewStoreditem);
                    if (oldInventoryOfStoreditemCollectionNewStoreditem != null && !oldInventoryOfStoreditemCollectionNewStoreditem.equals(inventory)) {
                        oldInventoryOfStoreditemCollectionNewStoreditem.getStoreditemCollection().remove(storeditemCollectionNewStoreditem);
                        oldInventoryOfStoreditemCollectionNewStoreditem = em.merge(oldInventoryOfStoreditemCollectionNewStoreditem);
                    }
                }
            }
            for (Character characterCollectionOldCharacter : characterCollectionOld) {
                if (!characterCollectionNew.contains(characterCollectionOldCharacter)) {
                    characterCollectionOldCharacter.setEquipmentPack(null);
                    characterCollectionOldCharacter = em.merge(characterCollectionOldCharacter);
                }
            }
            for (Character characterCollectionNewCharacter : characterCollectionNew) {
                if (!characterCollectionOld.contains(characterCollectionNewCharacter)) {
                    Inventory oldEquipmentPackOfCharacterCollectionNewCharacter = characterCollectionNewCharacter.getEquipmentPack();
                    characterCollectionNewCharacter.setEquipmentPack(inventory);
                    characterCollectionNewCharacter = em.merge(characterCollectionNewCharacter);
                    if (oldEquipmentPackOfCharacterCollectionNewCharacter != null && !oldEquipmentPackOfCharacterCollectionNewCharacter.equals(inventory)) {
                        oldEquipmentPackOfCharacterCollectionNewCharacter.getCharacterCollection().remove(characterCollectionNewCharacter);
                        oldEquipmentPackOfCharacterCollectionNewCharacter = em.merge(oldEquipmentPackOfCharacterCollectionNewCharacter);
                    }
                }
            }
            for (Character characterCollection1OldCharacter : characterCollection1Old) {
                if (!characterCollection1New.contains(characterCollection1OldCharacter)) {
                    characterCollection1OldCharacter.setEquipment(null);
                    characterCollection1OldCharacter = em.merge(characterCollection1OldCharacter);
                }
            }
            for (Character characterCollection1NewCharacter : characterCollection1New) {
                if (!characterCollection1Old.contains(characterCollection1NewCharacter)) {
                    Inventory oldEquipmentOfCharacterCollection1NewCharacter = characterCollection1NewCharacter.getEquipment();
                    characterCollection1NewCharacter.setEquipment(inventory);
                    characterCollection1NewCharacter = em.merge(characterCollection1NewCharacter);
                    if (oldEquipmentOfCharacterCollection1NewCharacter != null && !oldEquipmentOfCharacterCollection1NewCharacter.equals(inventory)) {
                        oldEquipmentOfCharacterCollection1NewCharacter.getCharacterCollection1().remove(characterCollection1NewCharacter);
                        oldEquipmentOfCharacterCollection1NewCharacter = em.merge(oldEquipmentOfCharacterCollection1NewCharacter);
                    }
                }
            }
            for (Character characterCollection2OldCharacter : characterCollection2Old) {
                if (!characterCollection2New.contains(characterCollection2OldCharacter)) {
                    characterCollection2OldCharacter.setBeltpouch(null);
                    characterCollection2OldCharacter = em.merge(characterCollection2OldCharacter);
                }
            }
            for (Character characterCollection2NewCharacter : characterCollection2New) {
                if (!characterCollection2Old.contains(characterCollection2NewCharacter)) {
                    Inventory oldBeltpouchOfCharacterCollection2NewCharacter = characterCollection2NewCharacter.getBeltpouch();
                    characterCollection2NewCharacter.setBeltpouch(inventory);
                    characterCollection2NewCharacter = em.merge(characterCollection2NewCharacter);
                    if (oldBeltpouchOfCharacterCollection2NewCharacter != null && !oldBeltpouchOfCharacterCollection2NewCharacter.equals(inventory)) {
                        oldBeltpouchOfCharacterCollection2NewCharacter.getCharacterCollection2().remove(characterCollection2NewCharacter);
                        oldBeltpouchOfCharacterCollection2NewCharacter = em.merge(oldBeltpouchOfCharacterCollection2NewCharacter);
                    }
                }
            }
            for (Character characterCollection3OldCharacter : characterCollection3Old) {
                if (!characterCollection3New.contains(characterCollection3OldCharacter)) {
                    characterCollection3OldCharacter.setBag2(null);
                    characterCollection3OldCharacter = em.merge(characterCollection3OldCharacter);
                }
            }
            for (Character characterCollection3NewCharacter : characterCollection3New) {
                if (!characterCollection3Old.contains(characterCollection3NewCharacter)) {
                    Inventory oldBag2OfCharacterCollection3NewCharacter = characterCollection3NewCharacter.getBag2();
                    characterCollection3NewCharacter.setBag2(inventory);
                    characterCollection3NewCharacter = em.merge(characterCollection3NewCharacter);
                    if (oldBag2OfCharacterCollection3NewCharacter != null && !oldBag2OfCharacterCollection3NewCharacter.equals(inventory)) {
                        oldBag2OfCharacterCollection3NewCharacter.getCharacterCollection3().remove(characterCollection3NewCharacter);
                        oldBag2OfCharacterCollection3NewCharacter = em.merge(oldBag2OfCharacterCollection3NewCharacter);
                    }
                }
            }
            for (Character characterCollection4OldCharacter : characterCollection4Old) {
                if (!characterCollection4New.contains(characterCollection4OldCharacter)) {
                    characterCollection4OldCharacter.setBag1(null);
                    characterCollection4OldCharacter = em.merge(characterCollection4OldCharacter);
                }
            }
            for (Character characterCollection4NewCharacter : characterCollection4New) {
                if (!characterCollection4Old.contains(characterCollection4NewCharacter)) {
                    Inventory oldBag1OfCharacterCollection4NewCharacter = characterCollection4NewCharacter.getBag1();
                    characterCollection4NewCharacter.setBag1(inventory);
                    characterCollection4NewCharacter = em.merge(characterCollection4NewCharacter);
                    if (oldBag1OfCharacterCollection4NewCharacter != null && !oldBag1OfCharacterCollection4NewCharacter.equals(inventory)) {
                        oldBag1OfCharacterCollection4NewCharacter.getCharacterCollection4().remove(characterCollection4NewCharacter);
                        oldBag1OfCharacterCollection4NewCharacter = em.merge(oldBag1OfCharacterCollection4NewCharacter);
                    }
                }
            }
            for (Character characterCollection5OldCharacter : characterCollection5Old) {
                if (!characterCollection5New.contains(characterCollection5OldCharacter)) {
                    characterCollection5OldCharacter.setBackpack(null);
                    characterCollection5OldCharacter = em.merge(characterCollection5OldCharacter);
                }
            }
            for (Character characterCollection5NewCharacter : characterCollection5New) {
                if (!characterCollection5Old.contains(characterCollection5NewCharacter)) {
                    Inventory oldBackpackOfCharacterCollection5NewCharacter = characterCollection5NewCharacter.getBackpack();
                    characterCollection5NewCharacter.setBackpack(inventory);
                    characterCollection5NewCharacter = em.merge(characterCollection5NewCharacter);
                    if (oldBackpackOfCharacterCollection5NewCharacter != null && !oldBackpackOfCharacterCollection5NewCharacter.equals(inventory)) {
                        oldBackpackOfCharacterCollection5NewCharacter.getCharacterCollection5().remove(characterCollection5NewCharacter);
                        oldBackpackOfCharacterCollection5NewCharacter = em.merge(oldBackpackOfCharacterCollection5NewCharacter);
                    }
                }
            }
            em.getTransaction().commit();
View Full Code Here

    public void destroy(Integer id) throws IllegalOrphanException, NonexistentEntityException {
        EntityManager em = null;
        try {
            em = getEntityManager();
            em.getTransaction().begin();
            Inventory inventory;
            try {
                inventory = em.getReference(Inventory.class, id);
                inventory.getId();
            } catch (EntityNotFoundException enfe) {
                throw new NonexistentEntityException("The inventory with id " + id + " no longer exists.", enfe);
            }
            List<String> illegalOrphanMessages = null;
            Collection<Storagetab> storagetabCollectionOrphanCheck = inventory.getStoragetabCollection();
            for (Storagetab storagetabCollectionOrphanCheckStoragetab : storagetabCollectionOrphanCheck) {
                if (illegalOrphanMessages == null) {
                    illegalOrphanMessages = new ArrayList<String>();
                }
                illegalOrphanMessages.add("This Inventory (" + inventory + ") cannot be destroyed since the Storagetab " + storagetabCollectionOrphanCheckStoragetab + " in its storagetabCollection field has a non-nullable inventoryID field.");
            }
            Collection<Storeditem> storeditemCollectionOrphanCheck = inventory.getStoreditemCollection();
            for (Storeditem storeditemCollectionOrphanCheckStoreditem : storeditemCollectionOrphanCheck) {
                if (illegalOrphanMessages == null) {
                    illegalOrphanMessages = new ArrayList<String>();
                }
                illegalOrphanMessages.add("This Inventory (" + inventory + ") cannot be destroyed since the Storeditem " + storeditemCollectionOrphanCheckStoreditem + " in its storeditemCollection field has a non-nullable inventory field.");
            }
            if (illegalOrphanMessages != null) {
                throw new IllegalOrphanException(illegalOrphanMessages);
            }
            Collection<Account> accountCollection = inventory.getAccountCollection();
            for (Account accountCollectionAccount : accountCollection) {
                accountCollectionAccount.setMaterialStorage(null);
                accountCollectionAccount = em.merge(accountCollectionAccount);
            }
            Collection<Character> characterCollection = inventory.getCharacterCollection();
            for (Character characterCollectionCharacter : characterCollection) {
                characterCollectionCharacter.setEquipmentPack(null);
                characterCollectionCharacter = em.merge(characterCollectionCharacter);
            }
            Collection<Character> characterCollection1 = inventory.getCharacterCollection1();
            for (Character characterCollection1Character : characterCollection1) {
                characterCollection1Character.setEquipment(null);
                characterCollection1Character = em.merge(characterCollection1Character);
            }
            Collection<Character> characterCollection2 = inventory.getCharacterCollection2();
            for (Character characterCollection2Character : characterCollection2) {
                characterCollection2Character.setBeltpouch(null);
                characterCollection2Character = em.merge(characterCollection2Character);
            }
            Collection<Character> characterCollection3 = inventory.getCharacterCollection3();
            for (Character characterCollection3Character : characterCollection3) {
                characterCollection3Character.setBag2(null);
                characterCollection3Character = em.merge(characterCollection3Character);
            }
            Collection<Character> characterCollection4 = inventory.getCharacterCollection4();
            for (Character characterCollection4Character : characterCollection4) {
                characterCollection4Character.setBag1(null);
                characterCollection4Character = em.merge(characterCollection4Character);
            }
            Collection<Character> characterCollection5 = inventory.getCharacterCollection5();
            for (Character characterCollection5Character : characterCollection5) {
                characterCollection5Character.setBackpack(null);
                characterCollection5Character = em.merge(characterCollection5Character);
            }
            em.remove(inventory);
View Full Code Here

        storagetab.getStoragetabPK().setAccountID(storagetab.getAccount().getId());
        EntityManager em = null;
        try {
            em = getEntityManager();
            em.getTransaction().begin();
            Inventory inventoryID = storagetab.getInventoryID();
            if (inventoryID != null) {
                inventoryID = em.getReference(inventoryID.getClass(), inventoryID.getId());
                storagetab.setInventoryID(inventoryID);
            }
            Account account = storagetab.getAccount();
            if (account != null) {
                account = em.getReference(account.getClass(), account.getEMail());
                storagetab.setAccount(account);
            }
            em.persist(storagetab);
            if (inventoryID != null) {
                inventoryID.getStoragetabCollection().add(storagetab);
                inventoryID = em.merge(inventoryID);
            }
            if (account != null) {
                account.getStoragetabCollection().add(storagetab);
                account = em.merge(account);
View Full Code Here

        EntityManager em = null;
        try {
            em = getEntityManager();
            em.getTransaction().begin();
            Storagetab persistentStoragetab = em.find(Storagetab.class, storagetab.getStoragetabPK());
            Inventory inventoryIDOld = persistentStoragetab.getInventoryID();
            Inventory inventoryIDNew = storagetab.getInventoryID();
            Account accountOld = persistentStoragetab.getAccount();
            Account accountNew = storagetab.getAccount();
            if (inventoryIDNew != null) {
                inventoryIDNew = em.getReference(inventoryIDNew.getClass(), inventoryIDNew.getId());
                storagetab.setInventoryID(inventoryIDNew);
            }
            if (accountNew != null) {
                accountNew = em.getReference(accountNew.getClass(), accountNew.getEMail());
                storagetab.setAccount(accountNew);
            }
            storagetab = em.merge(storagetab);
            if (inventoryIDOld != null && !inventoryIDOld.equals(inventoryIDNew)) {
                inventoryIDOld.getStoragetabCollection().remove(storagetab);
                inventoryIDOld = em.merge(inventoryIDOld);
            }
            if (inventoryIDNew != null && !inventoryIDNew.equals(inventoryIDOld)) {
                inventoryIDNew.getStoragetabCollection().add(storagetab);
                inventoryIDNew = em.merge(inventoryIDNew);
            }
            if (accountOld != null && !accountOld.equals(accountNew)) {
                accountOld.getStoragetabCollection().remove(storagetab);
                accountOld = em.merge(accountOld);
View Full Code Here

                storagetab = em.getReference(Storagetab.class, id);
                storagetab.getStoragetabPK();
            } catch (EntityNotFoundException enfe) {
                throw new NonexistentEntityException("The storagetab with id " + id + " no longer exists.", enfe);
            }
            Inventory inventoryID = storagetab.getInventoryID();
            if (inventoryID != null) {
                inventoryID.getStoragetabCollection().remove(storagetab);
                inventoryID = em.merge(inventoryID);
            }
            Account account = storagetab.getAccount();
            if (account != null) {
                account.getStoragetabCollection().remove(storagetab);
View Full Code Here

            Item itemID = storeditem.getItemID();
            if (itemID != null) {
                itemID = em.getReference(itemID.getClass(), itemID.getId());
                storeditem.setItemID(itemID);
            }
            Inventory inventory = storeditem.getInventory();
            if (inventory != null) {
                inventory = em.getReference(inventory.getClass(), inventory.getId());
                storeditem.setInventory(inventory);
            }
            em.persist(storeditem);
            if (itemID != null) {
                itemID.getStoreditemCollection().add(storeditem);
                itemID = em.merge(itemID);
            }
            if (inventory != null) {
                inventory.getStoreditemCollection().add(storeditem);
                inventory = em.merge(inventory);
            }
            em.getTransaction().commit();
        } catch (Exception ex) {
            if (findStoreditem(storeditem.getStoreditemPK()) != null) {
View Full Code Here

            em = getEntityManager();
            em.getTransaction().begin();
            Storeditem persistentStoreditem = em.find(Storeditem.class, storeditem.getStoreditemPK());
            Item itemIDOld = persistentStoreditem.getItemID();
            Item itemIDNew = storeditem.getItemID();
            Inventory inventoryOld = persistentStoreditem.getInventory();
            Inventory inventoryNew = storeditem.getInventory();
            if (itemIDNew != null) {
                itemIDNew = em.getReference(itemIDNew.getClass(), itemIDNew.getId());
                storeditem.setItemID(itemIDNew);
            }
            if (inventoryNew != null) {
                inventoryNew = em.getReference(inventoryNew.getClass(), inventoryNew.getId());
                storeditem.setInventory(inventoryNew);
            }
            storeditem = em.merge(storeditem);
            if (itemIDOld != null && !itemIDOld.equals(itemIDNew)) {
                itemIDOld.getStoreditemCollection().remove(storeditem);
                itemIDOld = em.merge(itemIDOld);
            }
            if (itemIDNew != null && !itemIDNew.equals(itemIDOld)) {
                itemIDNew.getStoreditemCollection().add(storeditem);
                itemIDNew = em.merge(itemIDNew);
            }
            if (inventoryOld != null && !inventoryOld.equals(inventoryNew)) {
                inventoryOld.getStoreditemCollection().remove(storeditem);
                inventoryOld = em.merge(inventoryOld);
            }
            if (inventoryNew != null && !inventoryNew.equals(inventoryOld)) {
                inventoryNew.getStoreditemCollection().add(storeditem);
                inventoryNew = em.merge(inventoryNew);
            }
            em.getTransaction().commit();
        } catch (Exception ex) {
            String msg = ex.getLocalizedMessage();
View Full Code Here

            Item itemID = storeditem.getItemID();
            if (itemID != null) {
                itemID.getStoreditemCollection().remove(storeditem);
                itemID = em.merge(itemID);
            }
            Inventory inventory = storeditem.getInventory();
            if (inventory != null) {
                inventory.getStoreditemCollection().remove(storeditem);
                inventory = em.merge(inventory);
            }
            em.remove(storeditem);
            em.getTransaction().commit();
        } finally {
View Full Code Here

            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);
            }
            if (lastOutpost != null) {
                lastOutpost.getCharacterCollection().add(character);
                lastOutpost = em.merge(lastOutpost);
            }
            if (equipmentPack != null) {
                equipmentPack.getCharacterCollection().add(character);
                equipmentPack = em.merge(equipmentPack);
            }
            if (equipment != null) {
                equipment.getCharacterCollection().add(character);
                equipment = em.merge(equipment);
            }
            if (beltpouch != null) {
                beltpouch.getCharacterCollection().add(character);
                beltpouch = em.merge(beltpouch);
            }
            if (bag2 != null) {
                bag2.getCharacterCollection().add(character);
                bag2 = em.merge(bag2);
            }
            if (bag1 != null) {
                bag1.getCharacterCollection().add(character);
                bag1 = em.merge(bag1);
            }
            if (backpack != null) {
                backpack.getCharacterCollection().add(character);
                backpack = em.merge(backpack);
            }
            if (accountID != null) {
                accountID.getCharacterCollection().add(character);
                accountID = em.merge(accountID);
View Full Code Here

TOP

Related Classes of gwlpr.database.entities.Inventory

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.