Package gwlpr.database.entities

Examples of gwlpr.database.entities.Usergroup


       
       
       
        // chat
        ChatOptions chat = new ChatOptions();
        Usergroup group = dBChar.getAccountID().getUserGroup();
        if (group != null)
        {
            chat.chatPefix = group.getPrefix();
            chat.prefixVisible = true;
           
            chat.chatColor = ChatColor.values()[group.getChatColor()];
            chat.enableColor = true;

            List<String> availCommands = new ArrayList<>();
            for (Command command : group.getCommandCollection())
            {
                availCommands.add(command.getName());
            }

            chat.availableCommands = availCommands;
View Full Code Here


            for (Command commandCollectionCommand : usergroup.getCommandCollection()) {
                commandCollectionCommand.getUsergroupCollection().add(usergroup);
                commandCollectionCommand = em.merge(commandCollectionCommand);
            }
            for (Account accountCollectionAccount : usergroup.getAccountCollection()) {
                Usergroup oldUserGroupOfAccountCollectionAccount = accountCollectionAccount.getUserGroup();
                accountCollectionAccount.setUserGroup(usergroup);
                accountCollectionAccount = em.merge(accountCollectionAccount);
                if (oldUserGroupOfAccountCollectionAccount != null) {
                    oldUserGroupOfAccountCollectionAccount.getAccountCollection().remove(accountCollectionAccount);
                    oldUserGroupOfAccountCollectionAccount = em.merge(oldUserGroupOfAccountCollectionAccount);
                }
            }
            em.getTransaction().commit();
        } finally {
View Full Code Here

    public void edit(Usergroup usergroup) throws NonexistentEntityException, Exception {
        EntityManager em = null;
        try {
            em = getEntityManager();
            em.getTransaction().begin();
            Usergroup persistentUsergroup = em.find(Usergroup.class, usergroup.getId());
            Collection<Command> commandCollectionOld = persistentUsergroup.getCommandCollection();
            Collection<Command> commandCollectionNew = usergroup.getCommandCollection();
            Collection<Account> accountCollectionOld = persistentUsergroup.getAccountCollection();
            Collection<Account> accountCollectionNew = usergroup.getAccountCollection();
            Collection<Command> attachedCommandCollectionNew = new ArrayList<Command>();
            for (Command commandCollectionNewCommandToAttach : commandCollectionNew) {
                commandCollectionNewCommandToAttach = em.getReference(commandCollectionNewCommandToAttach.getClass(), commandCollectionNewCommandToAttach.getName());
                attachedCommandCollectionNew.add(commandCollectionNewCommandToAttach);
            }
            commandCollectionNew = attachedCommandCollectionNew;
            usergroup.setCommandCollection(commandCollectionNew);
            Collection<Account> attachedAccountCollectionNew = new ArrayList<Account>();
            for (Account accountCollectionNewAccountToAttach : accountCollectionNew) {
                accountCollectionNewAccountToAttach = em.getReference(accountCollectionNewAccountToAttach.getClass(), accountCollectionNewAccountToAttach.getEMail());
                attachedAccountCollectionNew.add(accountCollectionNewAccountToAttach);
            }
            accountCollectionNew = attachedAccountCollectionNew;
            usergroup.setAccountCollection(accountCollectionNew);
            usergroup = em.merge(usergroup);
            for (Command commandCollectionOldCommand : commandCollectionOld) {
                if (!commandCollectionNew.contains(commandCollectionOldCommand)) {
                    commandCollectionOldCommand.getUsergroupCollection().remove(usergroup);
                    commandCollectionOldCommand = em.merge(commandCollectionOldCommand);
                }
            }
            for (Command commandCollectionNewCommand : commandCollectionNew) {
                if (!commandCollectionOld.contains(commandCollectionNewCommand)) {
                    commandCollectionNewCommand.getUsergroupCollection().add(usergroup);
                    commandCollectionNewCommand = em.merge(commandCollectionNewCommand);
                }
            }
            for (Account accountCollectionOldAccount : accountCollectionOld) {
                if (!accountCollectionNew.contains(accountCollectionOldAccount)) {
                    accountCollectionOldAccount.setUserGroup(null);
                    accountCollectionOldAccount = em.merge(accountCollectionOldAccount);
                }
            }
            for (Account accountCollectionNewAccount : accountCollectionNew) {
                if (!accountCollectionOld.contains(accountCollectionNewAccount)) {
                    Usergroup oldUserGroupOfAccountCollectionNewAccount = accountCollectionNewAccount.getUserGroup();
                    accountCollectionNewAccount.setUserGroup(usergroup);
                    accountCollectionNewAccount = em.merge(accountCollectionNewAccount);
                    if (oldUserGroupOfAccountCollectionNewAccount != null && !oldUserGroupOfAccountCollectionNewAccount.equals(usergroup)) {
                        oldUserGroupOfAccountCollectionNewAccount.getAccountCollection().remove(accountCollectionNewAccount);
                        oldUserGroupOfAccountCollectionNewAccount = em.merge(oldUserGroupOfAccountCollectionNewAccount);
                    }
                }
            }
            em.getTransaction().commit();
View Full Code Here

    public void destroy(Integer id) throws NonexistentEntityException {
        EntityManager em = null;
        try {
            em = getEntityManager();
            em.getTransaction().begin();
            Usergroup usergroup;
            try {
                usergroup = em.getReference(Usergroup.class, id);
                usergroup.getId();
            } catch (EntityNotFoundException enfe) {
                throw new NonexistentEntityException("The usergroup with id " + id + " no longer exists.", enfe);
            }
            Collection<Command> commandCollection = usergroup.getCommandCollection();
            for (Command commandCollectionCommand : commandCollection) {
                commandCollectionCommand.getUsergroupCollection().remove(usergroup);
                commandCollectionCommand = em.merge(commandCollectionCommand);
            }
            Collection<Account> accountCollection = usergroup.getAccountCollection();
            for (Account accountCollectionAccount : accountCollection) {
                accountCollectionAccount.setUserGroup(null);
                accountCollectionAccount = em.merge(accountCollectionAccount);
            }
            em.remove(usergroup);
View Full Code Here

        }
        EntityManager em = null;
        try {
            em = getEntityManager();
            em.getTransaction().begin();
            Usergroup userGroup = account.getUserGroup();
            if (userGroup != null) {
                userGroup = em.getReference(userGroup.getClass(), userGroup.getId());
                account.setUserGroup(userGroup);
            }
            Inventory materialStorage = account.getMaterialStorage();
            if (materialStorage != null) {
                materialStorage = em.getReference(materialStorage.getClass(), materialStorage.getId());
                account.setMaterialStorage(materialStorage);
            }
            Collection<Storagetab> attachedStoragetabCollection = new ArrayList<Storagetab>();
            for (Storagetab storagetabCollectionStoragetabToAttach : account.getStoragetabCollection()) {
                storagetabCollectionStoragetabToAttach = em.getReference(storagetabCollectionStoragetabToAttach.getClass(), storagetabCollectionStoragetabToAttach.getStoragetabPK());
                attachedStoragetabCollection.add(storagetabCollectionStoragetabToAttach);
            }
            account.setStoragetabCollection(attachedStoragetabCollection);
            Collection<Factionstat> attachedFactionstatCollection = new ArrayList<Factionstat>();
            for (Factionstat factionstatCollectionFactionstatToAttach : account.getFactionstatCollection()) {
                factionstatCollectionFactionstatToAttach = em.getReference(factionstatCollectionFactionstatToAttach.getClass(), factionstatCollectionFactionstatToAttach.getFactionstatPK());
                attachedFactionstatCollection.add(factionstatCollectionFactionstatToAttach);
            }
            account.setFactionstatCollection(attachedFactionstatCollection);
            Collection<Character> attachedCharacterCollection = new ArrayList<Character>();
            for (Character characterCollectionCharacterToAttach : account.getCharacterCollection()) {
                characterCollectionCharacterToAttach = em.getReference(characterCollectionCharacterToAttach.getClass(), characterCollectionCharacterToAttach.getId());
                attachedCharacterCollection.add(characterCollectionCharacterToAttach);
            }
            account.setCharacterCollection(attachedCharacterCollection);
            em.persist(account);
            if (userGroup != null) {
                userGroup.getAccountCollection().add(account);
                userGroup = em.merge(userGroup);
            }
            if (materialStorage != null) {
                materialStorage.getAccountCollection().add(account);
                materialStorage = em.merge(materialStorage);
View Full Code Here

        EntityManager em = null;
        try {
            em = getEntityManager();
            em.getTransaction().begin();
            Account persistentAccount = em.find(Account.class, account.getEMail());
            Usergroup userGroupOld = persistentAccount.getUserGroup();
            Usergroup userGroupNew = account.getUserGroup();
            Inventory materialStorageOld = persistentAccount.getMaterialStorage();
            Inventory materialStorageNew = account.getMaterialStorage();
            Collection<Storagetab> storagetabCollectionOld = persistentAccount.getStoragetabCollection();
            Collection<Storagetab> storagetabCollectionNew = account.getStoragetabCollection();
            Collection<Factionstat> factionstatCollectionOld = persistentAccount.getFactionstatCollection();
            Collection<Factionstat> factionstatCollectionNew = account.getFactionstatCollection();
            Collection<Character> characterCollectionOld = persistentAccount.getCharacterCollection();
            Collection<Character> characterCollectionNew = account.getCharacterCollection();
            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 account field is not nullable.");
                }
            }
            for (Factionstat factionstatCollectionOldFactionstat : factionstatCollectionOld) {
                if (!factionstatCollectionNew.contains(factionstatCollectionOldFactionstat)) {
                    if (illegalOrphanMessages == null) {
                        illegalOrphanMessages = new ArrayList<String>();
                    }
                    illegalOrphanMessages.add("You must retain Factionstat " + factionstatCollectionOldFactionstat + " since its account field is not nullable.");
                }
            }
            for (Character characterCollectionOldCharacter : characterCollectionOld) {
                if (!characterCollectionNew.contains(characterCollectionOldCharacter)) {
                    if (illegalOrphanMessages == null) {
                        illegalOrphanMessages = new ArrayList<String>();
                    }
                    illegalOrphanMessages.add("You must retain Character " + characterCollectionOldCharacter + " since its accountID field is not nullable.");
                }
            }
            if (illegalOrphanMessages != null) {
                throw new IllegalOrphanException(illegalOrphanMessages);
            }
            if (userGroupNew != null) {
                userGroupNew = em.getReference(userGroupNew.getClass(), userGroupNew.getId());
                account.setUserGroup(userGroupNew);
            }
            if (materialStorageNew != null) {
                materialStorageNew = em.getReference(materialStorageNew.getClass(), materialStorageNew.getId());
                account.setMaterialStorage(materialStorageNew);
            }
            Collection<Storagetab> attachedStoragetabCollectionNew = new ArrayList<Storagetab>();
            for (Storagetab storagetabCollectionNewStoragetabToAttach : storagetabCollectionNew) {
                storagetabCollectionNewStoragetabToAttach = em.getReference(storagetabCollectionNewStoragetabToAttach.getClass(), storagetabCollectionNewStoragetabToAttach.getStoragetabPK());
                attachedStoragetabCollectionNew.add(storagetabCollectionNewStoragetabToAttach);
            }
            storagetabCollectionNew = attachedStoragetabCollectionNew;
            account.setStoragetabCollection(storagetabCollectionNew);
            Collection<Factionstat> attachedFactionstatCollectionNew = new ArrayList<Factionstat>();
            for (Factionstat factionstatCollectionNewFactionstatToAttach : factionstatCollectionNew) {
                factionstatCollectionNewFactionstatToAttach = em.getReference(factionstatCollectionNewFactionstatToAttach.getClass(), factionstatCollectionNewFactionstatToAttach.getFactionstatPK());
                attachedFactionstatCollectionNew.add(factionstatCollectionNewFactionstatToAttach);
            }
            factionstatCollectionNew = attachedFactionstatCollectionNew;
            account.setFactionstatCollection(factionstatCollectionNew);
            Collection<Character> attachedCharacterCollectionNew = new ArrayList<Character>();
            for (Character characterCollectionNewCharacterToAttach : characterCollectionNew) {
                characterCollectionNewCharacterToAttach = em.getReference(characterCollectionNewCharacterToAttach.getClass(), characterCollectionNewCharacterToAttach.getId());
                attachedCharacterCollectionNew.add(characterCollectionNewCharacterToAttach);
            }
            characterCollectionNew = attachedCharacterCollectionNew;
            account.setCharacterCollection(characterCollectionNew);
            account = em.merge(account);
            if (userGroupOld != null && !userGroupOld.equals(userGroupNew)) {
                userGroupOld.getAccountCollection().remove(account);
                userGroupOld = em.merge(userGroupOld);
            }
            if (userGroupNew != null && !userGroupNew.equals(userGroupOld)) {
                userGroupNew.getAccountCollection().add(account);
                userGroupNew = em.merge(userGroupNew);
            }
            if (materialStorageOld != null && !materialStorageOld.equals(materialStorageNew)) {
                materialStorageOld.getAccountCollection().remove(account);
                materialStorageOld = em.merge(materialStorageOld);
View Full Code Here

                illegalOrphanMessages.add("This Account (" + account + ") cannot be destroyed since the Character " + characterCollectionOrphanCheckCharacter + " in its characterCollection field has a non-nullable accountID field.");
            }
            if (illegalOrphanMessages != null) {
                throw new IllegalOrphanException(illegalOrphanMessages);
            }
            Usergroup userGroup = account.getUserGroup();
            if (userGroup != null) {
                userGroup.getAccountCollection().remove(account);
                userGroup = em.merge(userGroup);
            }
            Inventory materialStorage = account.getMaterialStorage();
            if (materialStorage != null) {
                materialStorage.getAccountCollection().remove(account);
View Full Code Here

TOP

Related Classes of gwlpr.database.entities.Usergroup

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.