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;
}
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);
}
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>"));
}
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"));
}
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;
}
Aggregations