Package org.zanata.model

Examples of org.zanata.model.HLocaleMember


    public boolean requestingTranslator() {
        return requestAsTranslator != null && requestAsTranslator && !isTranslator();
    }

    public boolean isTranslator() {
        HLocaleMember member = getLocaleMember();
        if (member != null) {
            return getLocaleMember().isTranslator();
        }
        return false;
    }
View Full Code Here


    public boolean requestingReviewer() {
        return requestAsReviewer != null && requestAsReviewer && !isReviewer();
    }

    public boolean isReviewer() {
        HLocaleMember member = getLocaleMember();
        if (member != null) {
            return getLocaleMember().isReviewer();
        }
        return false;
    }
View Full Code Here

    public boolean requestingCoordinator() {
        return requestAsCoordinator != null && requestAsCoordinator && !isCoordinator();
    }

    public boolean isCoordinator() {
        HLocaleMember member = getLocaleMember();
        if (member != null) {
            return getLocaleMember().isCoordinator();
        }
        return false;
    }
View Full Code Here

    public void searchForTeamMembers() {
        clearSearchResult();
        List<HPerson> results =
                this.personDAO.findAllContainingName(this.searchTerm);
        for (HPerson person : results) {
            HLocaleMember localeMember = getLocaleMember(person.getId());
            boolean isMember = localeMember == null ? false : true;
            boolean isReviewer = false;
            boolean isTranslator = false;
            boolean isCoordinator = false;

            if (isMember) {
                isTranslator = localeMember.isTranslator();
                isReviewer = localeMember.isReviewer();
                isCoordinator = localeMember.isCoordinator();
            }
            getSearchResults().add(
                    new SelectablePerson(person, isMember, isTranslator,
                            isReviewer, isCoordinator));
        }
View Full Code Here

            entityManager.persist(asLocaleMember(person, locale));
        }
    }

    private static HLocaleMember asLocaleMember(HPerson person, HLocale locale) {
        return new HLocaleMember(person, locale, true, false, false);
    }
View Full Code Here

        LocaleId localeId = new LocaleId(locale);
        HPerson currentPerson = personDAO.findById(personId, false);

        boolean alreadyJoined =
                localeMemberDAO.isLocaleMember(personId, localeId);
        HLocaleMember localeMember;
        if (!alreadyJoined) {
            if (currentPerson.getLanguageMemberships().size() >= MAX_NUMBER_MEMBERSHIP) {
                throw new ZanataServiceException(
                        "You can only be a member of up to "
                                + MAX_NUMBER_MEMBERSHIP
                                + " languages at one time.");
            }
            HLocale lang = localeDAO.findByLocaleId(localeId);
            localeMember =
                    new HLocaleMember(currentPerson, lang, isTranslator,
                            isReviewer, isCoordinator);
            lang.getMembers().add(localeMember);
        } else {
            localeMember =
                    localeMemberDAO.findByPersonAndLocale(personId, localeId);
            localeMember.setTranslator(isTranslator);
            localeMember.setReviewer(isReviewer);
            localeMember.setCoordinator(isCoordinator);
        }
        localeMemberDAO.makePersistent(localeMember);
        localeMemberDAO.flush();
    }
View Full Code Here

    }

    public boolean leaveLanguageTeam(String locale, Long personId) {
        HLocale lang = localeDAO.findByLocaleId(new LocaleId(locale));
        HPerson currentPerson = personDAO.findById(personId, false);
        final HLocaleMember membership =
                localeMemberDAO.findById(new HLocaleMemberPk(currentPerson,
                        lang), true);

        if (membership != null) {
            localeMemberDAO.makeTransient(membership);
View Full Code Here

                    personDAO.getAllLanguageTeamMemberships(obsoletePerson);
            List<HLocaleMember> activeMemberships =
                    personDAO.getAllLanguageTeamMemberships(activePerson);

            for (HLocaleMember obsoleteMembership : obsoleteMemberships) {
                HLocaleMember activeMembership = null;

                for (HLocaleMember m : activeMemberships) {
                    if (m.getPerson().getId()
                            .equals(obsoleteMembership.getPerson().getId())
                            && m.getSupportedLanguage()
                                    .getLocaleId()
                                    .equals(obsoleteMembership
                                            .getSupportedLanguage()
                                            .getLocaleId())) {
                        activeMembership = m;
                        break;
                    }
                }

                if (activeMembership == null) {
                    activeMembership =
                            new HLocaleMember(activePerson,
                                    obsoleteMembership.getSupportedLanguage(),
                                    obsoleteMembership.isTranslator(),
                                    obsoleteMembership.isReviewer(),
                                    obsoleteMembership.isCoordinator());
                }

                activeMembership.setCoordinator(activeMembership
                        .isCoordinator() || obsoleteMembership.isCoordinator());
                entityManager.remove(obsoleteMembership);
            }

            // Link all merged accounts
View Full Code Here

        HAccount account = entityManager.find(HAccount.class, new Long(1));

        assertThat(locale, notNullValue());
        assertThat(account, notNullValue());

        HLocaleMember newMember =
                new HLocaleMember(account.getPerson(), locale, true, true, true);
        // Should fail as there is no user logged in
        localeMemberDAO.makePersistent(newMember);
    }
View Full Code Here

        HAccount account = entityManager.find(HAccount.class, new Long(1));

        assertThat(locale, notNullValue());
        assertThat(account, notNullValue());

        HLocaleMember newMember =
                new HLocaleMember(account.getPerson(), locale, true, true, true);
        localeMemberDAO.makePersistent(newMember);
    }
View Full Code Here

TOP

Related Classes of org.zanata.model.HLocaleMember

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.