Search in sources :

Example 31 with User

use of com.autentia.tnt.businessobject.User in project TNTConcept by autentia.

the class GlobalHoursReportCSVServlet method getCSVFooter.

private StringBuilder getCSVFooter(List<User> users, List<GlobalHourReport> globalHourReports) {
    StringBuilder sbFooter = new StringBuilder();
    DecimalFormatSymbols symbols = new DecimalFormatSymbols();
    symbols.setDecimalSeparator(',');
    DecimalFormat formatter = new DecimalFormat("#0.00", symbols);
    sbFooter.append("\"\"").append(CSV_SEPARATOR).append("\"TOTAL\"");
    double totalHours = 0;
    double totalCost = 0;
    for (User user : users) {
        double userTotalHours = 0;
        for (GlobalHourReport report : globalHourReports) {
            userTotalHours += report.getUserHours(user);
        }
        sbFooter.append(CSV_SEPARATOR).append("\"").append(formatter.format(userTotalHours)).append("\"").append(CSV_SEPARATOR).append("\"").append(formatter.format(userTotalHours * user.getSalaryPerHour())).append("\"");
        totalHours += userTotalHours;
        totalCost += userTotalHours * user.getSalaryPerHour();
    }
    sbFooter.append(CSV_SEPARATOR).append("\"").append(formatter.format(totalHours)).append("\"").append(CSV_SEPARATOR).append("\"").append(formatter.format(totalCost)).append("\"").append("\r\n");
    return sbFooter;
}
Also used : User(com.autentia.tnt.businessobject.User) GlobalHourReport(com.autentia.tnt.businessobject.GlobalHourReport) DecimalFormatSymbols(java.text.DecimalFormatSymbols) DecimalFormat(java.text.DecimalFormat)

Example 32 with User

use of com.autentia.tnt.businessobject.User in project TNTConcept by autentia.

the class GlobalHoursReportCSVServlet method getCSVHeader.

private StringBuilder getCSVHeader(List<User> users) {
    StringBuilder sbHeader = new StringBuilder();
    StringBuilder sbSubHeader = new StringBuilder();
    sbHeader.append("\"OrganizaciĆ³n\"").append(CSV_SEPARATOR).append("\"Proyecto\"");
    sbSubHeader.append("").append(CSV_SEPARATOR).append("");
    for (User user : users) {
        sbHeader.append(CSV_SEPARATOR).append("\"" + user.getName() + "\"").append(CSV_SEPARATOR).append("");
        sbSubHeader.append(CSV_SEPARATOR).append("\"Horas\"").append(CSV_SEPARATOR).append("\"Coste\"");
    }
    sbHeader.append(CSV_SEPARATOR).append("\"Total\"").append(CSV_SEPARATOR).append("").append("\r\n");
    sbSubHeader.append(CSV_SEPARATOR).append("\"Horas\"").append(CSV_SEPARATOR).append("\"Coste\"").append("\r\n");
    return sbHeader.append(sbSubHeader);
}
Also used : User(com.autentia.tnt.businessobject.User)

Example 33 with User

use of com.autentia.tnt.businessobject.User in project TNTConcept by autentia.

the class LinkBeanTest method shouldFailWhenCheckingWithInactiveUser.

@Test
public void shouldFailWhenCheckingWithInactiveUser() {
    User testUser = new User();
    testUser.setLogin("testUser");
    testUser.setActive(false);
    Link testLink = new Link();
    testLink.setLink("linkTest");
    testLink.setUser("testUser");
    testLink.setInsertDate(new Date());
    doReturn(Arrays.asList(testLink)).when(sutMock).getLinksWithLink("linkTest");
    doReturn(testUser).when(sutMock).getUserByName(testLink.getUser());
    String result = sutMock.checkLinkAndResetPassword(testLink.getLink());
    assertThat(result, equalTo("<p>El enlace no existe o ha caducado</p>"));
}
Also used : User(com.autentia.tnt.businessobject.User) Link(com.autentia.tnt.businessobject.Link) Date(java.util.Date) Test(org.junit.Test)

Example 34 with User

use of com.autentia.tnt.businessobject.User in project TNTConcept by autentia.

the class LinkBeanTest method shouldResetPasswordWithDB.

@Test
public void shouldResetPasswordWithDB() {
    User testUser = new User();
    testUser.setPassword("test");
    String[] x = new String[] { "x" };
    String[] y = new String[] { "y" };
    String[] z = new String[] { "z" };
    String[] v = new String[] { "v" };
    String[] w = new String[] { "w" };
    doReturn(x).when(sutMock).callFacesUtilsFormatMessage("AuthenticationManager.randomWords0");
    doReturn(y).when(sutMock).callFacesUtilsFormatMessage("AuthenticationManager.randomWords1");
    doReturn(z).when(sutMock).callFacesUtilsFormatMessage("AuthenticationManager.randomWords2");
    doReturn(v).when(sutMock).callFacesUtilsFormatMessage("AuthenticationManager.randomWords3");
    doReturn(w).when(sutMock).callFacesUtilsFormatMessage("AuthenticationManager.randomWords4");
    doReturn("changed").when(authManager).resetPasswordExternal(testUser, x, y, z, v, w);
    doReturn(true).when(configurationUtil).isLdapProviderEnabled();
    String changedPassword = sutMock.resetPassword(testUser);
    verify(userManager, times(0)).updateEntity(testUser, true);
    assertThat(changedPassword, equalTo("changed"));
}
Also used : User(com.autentia.tnt.businessobject.User) Test(org.junit.Test)

Example 35 with User

use of com.autentia.tnt.businessobject.User in project TNTConcept by autentia.

the class CollaboratorBean method getUsers.

// Getters to list possible values of related entities
/**
 * Get the list of all users
 * @return the list of all users
 */
public List<SelectItem> getUsers() {
    List<User> refs = UserManager.getDefault().getAllEntities(null, new SortCriteria("name"));
    ArrayList<SelectItem> ret = new ArrayList<SelectItem>();
    ret.add(new SelectItem(null, ""));
    for (User ref : refs) {
        ret.add(new SelectItem(ref, ref.getName()));
    }
    return ret;
}
Also used : SortCriteria(com.autentia.tnt.dao.SortCriteria) User(com.autentia.tnt.businessobject.User) SelectItem(javax.faces.model.SelectItem) ArrayList(java.util.ArrayList)

Aggregations

User (com.autentia.tnt.businessobject.User)70 Test (org.junit.Test)24 ArrayList (java.util.ArrayList)17 SortCriteria (com.autentia.tnt.dao.SortCriteria)15 SelectItem (javax.faces.model.SelectItem)11 UserDAO (com.autentia.tnt.dao.hibernate.UserDAO)10 Date (java.util.Date)9 Link (com.autentia.tnt.businessobject.Link)6 UserSearch (com.autentia.tnt.dao.search.UserSearch)5 Attributes (javax.naming.directory.Attributes)5 BasicAttributes (javax.naming.directory.BasicAttributes)5 Activity (com.autentia.tnt.businessobject.Activity)4 Attribute (javax.naming.directory.Attribute)4 BasicAttribute (javax.naming.directory.BasicAttribute)4 GlobalHourReport (com.autentia.tnt.businessobject.GlobalHourReport)3 GlobalHoursReportBean (com.autentia.tnt.bean.activity.GlobalHoursReportBean)2 Commissioning (com.autentia.tnt.businessobject.Commissioning)2 Objective (com.autentia.tnt.businessobject.Objective)2 Occupation (com.autentia.tnt.businessobject.Occupation)2 DataIntegrityException (com.autentia.tnt.dao.DataIntegrityException)2