Package org.nxplanner.domain

Examples of org.nxplanner.domain.Person


    protected boolean isAuthenticated(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        // This could also be implemented in a special login module
        if (!isSubjectInRequest(request)) {
            try {
                Person person = getPerson(ThreadSession.get(), defaultUserId);
                Subject subject = new Subject();
                subject.getPrincipals().add(new PersonPrincipal(person));
                SecurityHelper.setSubject(request, subject);
            } catch (HibernateException e) {
                throw new ServletException(e);
View Full Code Here


    // todo - these methods should be moved to an object repository
    private Person getPerson(Session session, String userId) throws HibernateException {
        List people = session.find("from person in class " +
                Person.class.getName() + " where userid = ?",
                userId, Hibernate.STRING);
        Person person = null;
        Iterator peopleIterator = people.iterator();
        if (peopleIterator.hasNext()) {
            person = (Person)peopleIterator.next();
        }
        return person;
View Full Code Here

            throw new ExportException(he);
         }

         reportStream = PdfReportExporter.class.getClassLoader().getResourceAsStream("org/nxplanner/export/reports/JRStory.jasper");
         parameters.put("StoryName", story.getName());
         Person cust = story.getCustomer(); parameters.put("StoryCustomerName", (cust != null) ? cust.getName() : null);
         parameters.put("StoryEstimatedHours", new java.lang.Double(story.getEstimatedHours()));
         parameters.put("StoryDescription", story.getDescription());
      } else if (object instanceof Task) {
         Task task = (Task)object;

         try {
            ds = new TaskDataSource(task, session);
         } catch (HibernateException he) {
            throw new ExportException(he);
         }

         reportStream = PdfReportExporter.class.getClassLoader().getResourceAsStream("org/nxplanner/export/reports/JRTask.jasper");
         parameters.put("TaskName", task.getName());
         parameters.put("TaskDescription", task.getDescription());
         double actual = task.getActualHours();
         parameters.put("TaskPercentage", new java.lang.Integer((int)((actual * 100) / (actual + task.getRemainingHours()))));
         parameters.put("TaskDisposition", task.getDisposition());
         parameters.put("TaskType", task.getType());
         parameters.put("TaskAcceptor", getPersonName(session, new Integer(task.getAcceptorId())));
         parameters.put("TaskEstimate", new java.lang.Double(task.getEstimatedHours()));
         parameters.put("TaskCompleted", new java.lang.Boolean(task.isCompleted()));
      } else if (object instanceof Person) {
         Person person = (Person)object;

         try {
            ds = new PersonDataSource(person, session);
         } catch (HibernateException he) {
            throw new ExportException(he);
         }

         reportStream = PdfReportExporter.class.getClassLoader().getResourceAsStream("org/nxplanner/export/reports/JRPerson.jasper");
         parameters.put("PersonName", person.getName());
      }

      if (ds == null) {
         throw new ExportException("Could not instantiate data source");
      }
View Full Code Here

   {
      if (id == null || id.intValue() == 0) {
         return null;
      }

      Person person = null;
      try {
         person = (Person)session.load(Person.class, id);
      } catch (HibernateException he) {
         return null;
      }

      if (person == null) { return null; }

      return person.getName();
   }
View Full Code Here

        try {
            List people = session.find("from person in class " + Person.class.getName() +
                    " where person.userId = ?",
                    sysadminId, Hibernate.STRING);
            Iterator personItr = people.iterator();
            Person sysadmin;
            if (personItr.hasNext()) {
                sysadmin = (Person) personItr.next();
                log.info("using " + sysadminId + " user");
            } else {
                log.info("creating " + sysadminId + " user");
                sysadmin = new Person();
                sysadmin.setUserId(sysadminId);
                sysadmin.setName(sysadminId);
                sysadmin.setInitials("SYS");
                sysadmin.setPassword("1tGWp1Bdm02Sw4bD7/o0N2ao405Tf8kjxGBW/A=="); // password=admin
                sysadmin.setLastUpdateTime(new Date());
                session.save(sysadmin);
            }
            Role viewerRole = initializeRole(session, "viewer", 1, 8);
            Role editorRole = initializeRole(session, "editor", 2, 7);
            Role adminRole = initializeRole(session, "admin", 3, 6);
            Role sysadminRole = initializeRole(session, "sysadmin", 4, 5);
            addRoleAssociation(session, sysadminRole.getId(), sysadmin.getId(), 0);
            createPermission(session, sysadminRole, "%", "%");
            createPermission(session, adminRole, "%", "admin%");
            createPermission(session, editorRole, "%", "create%");
            createPermission(session, editorRole, "%", "edit%");
            createPermission(session, editorRole, "%", "integrate%");
View Full Code Here

        assertTrue("filter chain not called", mockFilterChain.doFilterCalled);
    }

    public void testDefaultAuthenticationAsSysadmin() throws Exception {
        String userId = "sysadmin";
        Person person = new Person(userId);
        support.hibernateSession.find2Return = Arrays.asList(new Object[]{person});
        person.setId(11);
        Subject subject = new Subject();
        subject.getPrincipals().add(new PersonPrincipal(person));
        setUpRequest("/x/*", "/do/something");

        securityFilter.doFilter(support.request, support.response, mockFilterChain);
View Full Code Here

        assertTrue("filter chain not called", mockFilterChain.doFilterCalled);
    }

    public void testDefaultAuthenticationAsSysadmin() throws Exception {
        String userId = "sysadmin";
        Person person = new Person(userId);
        support.hibernateSession.find2Return = Arrays.asList(new Object[]{person});
        person.setId(11);
        Subject subject = new Subject();
        subject.getPrincipals().add(new PersonPrincipal(person));
        setUpRequest("/x/*", "/do/something");

        securityFilter.doFilter(support.request, support.response, mockFilterChain);
View Full Code Here

    }

    public void testUpgrader() throws Exception {
        removeTestPeople();
        setUpOldRoleTable();
        Person testperson1 = createPerson("testperson1", null);
        createOldPersonRole(testperson1.getId(), "viewer");
        Person testperson2 = createPerson("testperson2", null);
        createOldPersonRole(testperson2.getId(), "admin");
        session.flush();
        session.connection().commit();
        closeSession();

        upgrader.run(new String[0]);
View Full Code Here

    public Subject setUpSubjectInRole(String role) {
        return setUpSubject(DEFAULT_PERSON_USER_ID, new String[]{role});
    }

    public Subject setUpSubject(String userId, String[] roles) {
        Person person = new Person(userId);
        person.setId(DEFAULT_PERSON_ID);
        return setUpSubject(person, roles);
    }
View Full Code Here

        UserStoryEditorForm form = new UserStoryEditorForm();
        form.setOid("111");
        form.setAction(EditStoryAction.UPDATE_ACTION);
        support.form = form;
        form.setCustomerId(1);
        Person person1 = new Person();
        person1.setId(1);
        Person person2 = new Person();
        person2.setId(2);
        UserStory story = new UserStory();
        story.setId(111);
        expectObjectRepositoryAccess(UserStory.class);
        mockObjectRepositoryControl.expectAndReturn(mockObjectRepository.load(111), story);
        mockObjectRepository.update(story);
View Full Code Here

TOP

Related Classes of org.nxplanner.domain.Person

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.