String resourceId = org.sipfoundry.sipxconfig.common.User.GROUP_RESOURCE_ID; Group g = m_settingDao.getGroupCreateIfNotFound(resourceId, adminPhone .getRemoveGroup()); DataCollectionUtil.removeByPrimaryKey(myPhones[i].getGroups(), g);
Group g = m_settingDao.getGroupByName(GROUP_RESOURCE_ID, adminPhone.getRemoveGroup()); if (g != null) { DataCollectionUtil.removeByPrimaryKey(myPhones[i].getGroups(), g.getPrimaryKey()); }
    public void adminPhone(AdminPhone adminPhone) throws RemoteException {        org.sipfoundry.sipxconfig.phone.Phone[] myPhones = phoneSearch(adminPhone.getSearch());        if (Boolean.TRUE.equals(adminPhone.getGenerateProfiles())) {            m_context.generateProfilesAndRestart(Arrays.asList(myPhones));        } else if (Boolean.TRUE.equals(adminPhone.getRestart())) {            m_context.restart(Arrays.asList(myPhones));        } else {            for (int i = 0; i < myPhones.length; i++) {                if (Boolean.TRUE.equals(adminPhone.getDeletePhone())) {                    m_context.deletePhone(myPhones[i]);                    continue; // all other edits wouldn't make sense                }                if (adminPhone.getEdit() != null) {                    Phone apiPhone = new Phone();                    Set properties = ApiBeanUtil.getSpecfiedProperties(adminPhone.getEdit());                    ApiBeanUtil.setProperties(apiPhone, adminPhone.getEdit());                    m_builder.toMyObject(myPhones[i], apiPhone, properties);                }                if (adminPhone.getRemoveLine() != null) {                    String username = adminPhone.getRemoveLine();                    org.sipfoundry.sipxconfig.phone.Line l = myPhones[i].findByUsername(username);                    if (l != null) {                        myPhones[i].removeLine(l);                    }                }                if (adminPhone.getAddLine() != null) {                    String userName = adminPhone.getAddLine().getUserName();                    org.sipfoundry.sipxconfig.common.User u = m_coreContext                            .loadUserByUserName(userName);                    org.sipfoundry.sipxconfig.phone.Line l = myPhones[i].createLine();                    l.setUser(u);                    myPhones[i].addLine(l);                }                if (adminPhone.getAddGroup() != null) {                    String resourceId = org.sipfoundry.sipxconfig.common.User.GROUP_RESOURCE_ID;                    Group g = m_settingDao.getGroupCreateIfNotFound(resourceId, adminPhone                            .getAddGroup());                    myPhones[i].addGroup(g);                }                if (adminPhone.getRemoveGroup() != null) {                    String resourceId = org.sipfoundry.sipxconfig.common.User.GROUP_RESOURCE_ID;                    Group g = m_settingDao.getGroupCreateIfNotFound(resourceId, adminPhone                            .getRemoveGroup());                    DataCollectionUtil.removeByPrimaryKey(myPhones[i].getGroups(), g);                }                m_context.storePhone(myPhones[i]);            }        }    }