Examples of HPerson


Examples of org.zanata.model.HPerson

        localeMemberDAO.flush();
    }

    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) {
View Full Code Here

Examples of org.zanata.model.HPerson

        if (version == null || version.getStatus() == EntityStatus.OBSOLETE ||
                version.getProject().getStatus() == EntityStatus.OBSOLETE) {
            throw new NoSuchEntityException(projectSlug + "/" + versionSlug);
        }

        HPerson person = personDAO.findByUsername(username);
        if (person == null) {
            throw new NoSuchEntityException(username);
        }

        String[] dateRange = dateRangeParam.split("\\.\\.");
        if (dateRange.length != 2) {
            throw new InvalidDateParamException(dateRangeParam);
        }

        Date fromDate, toDate;

        try {
            fromDate = DateUtil.getDate(dateRange[0], DATE_FORMAT);
            toDate = DateUtil.getDate(dateRange[1], DATE_FORMAT);

            fromDate = DateUtil.getStartOfDay(fromDate);
            toDate = DateUtil.getEndOfTheDay(toDate);

            if (fromDate.after(toDate) || !DateUtil.isDatesInRange(fromDate,
                    toDate, MAX_STATS_DAYS)) {
                throw new InvalidDateParamException(dateRangeParam);
            }
        } catch (IllegalArgumentException e) {
            throw new InvalidDateParamException(dateRangeParam);
        }

        LocaleStatistics localeStatistics = new LocaleStatistics();

        List<Object[]> data =
                textFlowTargetHistoryDAO.getUserTranslationHistoryInVersion(
                        version.getId(), person.getId(), fromDate, toDate);

        for (Object[] entry : data) {
            int count = ((BigDecimal) entry[0]).intValue();
            ContentState state = ContentState.values()[(int) entry[1]];
            LocaleId localeId = new LocaleId(entry[2].toString());
View Full Code Here

Examples of org.zanata.model.HPerson

                identityStore.disableUser(username);
            }
        }.addRole("admin").run();

        HAccount account = accountDAO.getByUsername(username);
        HPerson person = new HPerson();
        person.setAccount(account);
        person.setEmail(email);
        person.setName(name);

        this.postProcessRegisteredAccount(account);
        personDAO.makePersistent(person);

        HAccountActivationKey key = new HAccountActivationKey();
View Full Code Here

Examples of org.zanata.model.HPerson

                identityStore.disableUser(username);
            }
        }.addRole("admin").run();

        HAccount account = accountDAO.getByUsername(username);
        HPerson person = new HPerson();
        person.setAccount(account);
        person.setEmail(email);
        person.setName(name);

        this.postProcessRegisteredAccount(account);
        personDAO.makePersistent(person);

        HAccountActivationKey key = new HAccountActivationKey();
View Full Code Here

Examples of org.zanata.model.HPerson

        }.addRole("admin").run();

        HAccount account = accountDAO.getByUsername(username);
        account.getCredentials().add(
                new HOpenIdCredentials(account, externalId, email));
        HPerson person = new HPerson();
        person.setAccount(account);
        person.setEmail(email);
        person.setName(name);

        this.postProcessRegisteredAccount(account);
        personDAO.makePersistent(person);

        HAccountActivationKey key = new HAccountActivationKey();
View Full Code Here

Examples of org.zanata.model.HPerson

        @Override
        public void execute() {
            obsolete = entityManager.merge(obsolete);
            active = entityManager.merge(active);

            HPerson activePerson = active.getPerson();
            HPerson obsoletePerson = obsolete.getPerson();

            // Disable obsolete account and change the email address
            obsolete.setEnabled(false);
            obsolete.getPerson().setEmail(
                    obsolete.getPerson().getEmail() + ".disabled");

            // Merge all Roles
            for (HAccountRole role : obsolete.getRoles()) {
                active.getRoles().add(role);
            }
            obsolete.getRoles().clear();

            // Add Credentials
            for (HCredentials credentials : obsolete.getCredentials()) {
                credentials.setAccount(active);
                active.getCredentials().add(credentials);
            }

            // Merge all Maintained Projects
            List<HProject> maintainedProjects =
                    new ArrayList<HProject>(
                            obsoletePerson.getMaintainerProjects());
            for (HProject proj : maintainedProjects) {
                proj.getMaintainers().add(activePerson);
                proj.getMaintainers().remove(obsoletePerson);
            }

            // Merge all maintained Version Groups
            List<HIterationGroup> maintainedGroups =
                    new ArrayList<HIterationGroup>(
                            obsoletePerson.getMaintainerVersionGroups());
            for (HIterationGroup group : maintainedGroups) {
                group.getMaintainers().add(activePerson);
                group.getMaintainers().remove(obsoletePerson);
            }
View Full Code Here

Examples of org.zanata.model.HPerson

    private static HTextFlowTarget addHTextFlowTarget(HLocale hLocale,
            HTextFlow hTextFlow, String username) {
        HTextFlowTarget hTextFlowTarget =
                new HTextFlowTarget(hTextFlow, hLocale);
        HPerson lastModifiedBy = new HPerson();
        HAccount account = new HAccount();
        account.setUsername(username);
        lastModifiedBy.setAccount(account);
        hTextFlowTarget.setLastModifiedBy(lastModifiedBy);
        hTextFlowTarget.setLastChanged(new Date());
        return hTextFlowTarget;
    }
View Full Code Here

Examples of org.zanata.model.HPerson

    }

    @Test
    public void testTargetUserComment() {
        PersonDAO personDAO = new PersonDAO(getSession());
        HPerson person = personDAO.findById(1L, false);
        HTextFlowTarget target = textFlowTargetDAO.findById(1L, false);

        List<HTextFlowTargetReviewComment> userComments =
                target.getReviewComments();

        assertThat(userComments, Matchers.empty());

        target.addReviewComment("bad translation", person);
        getEm().persist(target);

        List<HTextFlowTargetReviewComment> result =
                reviewCommentsDAO.getReviewComments(new TransUnitId(target
                        .getTextFlow().getId()), target.getLocaleId());

        assertThat(result, Matchers.hasSize(1));
        assertThat(result.get(0).getCommenterName(),
                Matchers.equalTo(person.getName()));
        assertThat(result.get(0).getCreationDate(),
                Matchers.lessThanOrEqualTo(new Date()));
    }
View Full Code Here

Examples of org.zanata.model.HPerson

    }

    @Test
    public void testTargetUserCommentMadeOnPreviousTranslation() {
        PersonDAO personDAO = new PersonDAO(getSession());
        HPerson person = personDAO.findById(1L, false);
        HTextFlowTarget target = textFlowTargetDAO.findById(2L, false);

        List<String> oldTranslation = target.getContents();
        int oldVersion = target.getVersionNum();
View Full Code Here

Examples of org.zanata.model.HPerson

        int wordCount = target.getTextFlow().getWordCount().intValue();

        String todayDate = formatter.format(today);

        String username = "demo";
        HPerson demoPerson = personDAO.findByUsername(username);

        ContributionStatistics initialStats =
                statisticsService.getContributionStatistics(
                        "sample-project", "1.0", username, todayDate + ".."
                                + todayDate);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.