List of usage examples for java.util Locale GERMANY
Locale GERMANY
To view the source code for java.util Locale GERMANY.
Click Source Link
From source file:de.randi2.testUtility.utility.Bootstrap.java
public void init() throws ServiceException { long time1 = System.nanoTime(); EntityTransaction transaction = entityManager.getTransaction(); transaction.begin();/*from w w w . j a va2 s . c o m*/ entityManager.persist(Role.ROLE_INVESTIGATOR); entityManager.persist(Role.ROLE_USER); entityManager.persist(Role.ROLE_STATISTICAN); entityManager.persist(Role.ROLE_MONITOR); entityManager.persist(Role.ROLE_P_INVESTIGATOR); entityManager.persist(Role.ROLE_ANONYMOUS); entityManager.persist(Role.ROLE_ADMIN); Role.ROLE_ADMIN.getRolesToAssign().add(Role.ROLE_ADMIN); entityManager.merge(Role.ROLE_ADMIN); transaction.commit(); transaction.begin(); Role roleAdmin = (Role) entityManager.find(Role.class, 1L); roleAdmin.getRolesToAssign().add(roleAdmin); entityManager.merge(roleAdmin); transaction.commit(); transaction.begin(); Person cp1 = new Person(); cp1.setFirstname("Contact"); cp1.setSurname("Person"); cp1.setEmail("randi2@action.ms"); cp1.setPhone("1234567"); cp1.setSex(Gender.MALE); Person cp2 = new Person(); cp2.setFirstname("Contact"); cp2.setSurname("Person"); cp2.setEmail("randi2@action.ms"); cp2.setPhone("1234567"); cp2.setSex(Gender.MALE); Person adminP = new Person(); adminP.setFirstname("Max"); adminP.setSurname("Administrator"); adminP.setEmail("randi2@action.ms"); adminP.setPhone("1234567"); adminP.setSex(Gender.MALE); Login adminL = new Login(); adminL.setUsername("admin@trialsite1.de"); adminL.setPassword(passwordEncoder.encodePassword("1$heidelberg", saltSourceUser.getSalt(adminL))); adminL.setPerson(adminP); adminL.setPrefLocale(Locale.GERMANY); adminL.addRole(Role.ROLE_ADMIN); adminL.setPrefLocale(Locale.GERMAN); entityManager.persist(adminL); TrialSite trialSite = new TrialSite(); trialSite.setCity("Heidelberg"); trialSite.setCountry("Germany"); trialSite.setName("Trial Site 1"); trialSite.setPostcode("69120"); trialSite.setStreet("INF"); trialSite.setPassword( passwordEncoder.encodePassword("1$heidelberg", saltSourceTrialSite.getSystemWideSalt())); trialSite.setContactPerson(cp1); trialSite.getMembers().add(adminP); entityManager.persist(trialSite); transaction.commit(); rolesAndRights.registerPerson(adminL); rolesAndRights.grantRights(adminL, trialSite); rolesAndRights.grantRights(trialSite, trialSite); entityManager.clear(); AnonymousAuthenticationToken authToken = new AnonymousAuthenticationToken("anonymousUser", adminL, new ArrayList<GrantedAuthority>(adminL.getAuthorities())); // Perform authentication SecurityContextHolder.getContext().setAuthentication(authToken); SecurityContextHolder.getContext().getAuthentication().setAuthenticated(true); Person userPInv = new Person(); userPInv.setFirstname("Maxi"); userPInv.setSurname("Investigator"); userPInv.setEmail("randi2@action.ms"); userPInv.setPhone("1234567"); // userPInv.setTrialSite(trialSite); Login userLInv = new Login(); userLInv.setUsername("investigator@trialsite1.de"); userLInv.setPassword("1$heidelberg"); userLInv.setPerson(userPInv); userLInv.setPrefLocale(Locale.GERMANY); userLInv.addRole(Role.ROLE_INVESTIGATOR); userLInv.setPrefLocale(Locale.GERMAN); userService.create(userLInv, trialSite); Person userPPInv = new Person(); userPPInv.setFirstname("Max"); userPPInv.setSurname("PInvestigator"); userPPInv.setEmail("randi2@action.ms"); userPPInv.setPhone("1234567"); userPPInv.setSex(Gender.MALE); // userPPInv.setTrialSite(trialSite); Login userLPInv = new Login(); userLPInv.setUsername("p_investigator@trialsite1.de"); userLPInv.setPassword("1$heidelberg"); userLPInv.setPerson(userPPInv); userLPInv.setPrefLocale(Locale.GERMANY); userLPInv.addRole(Role.ROLE_P_INVESTIGATOR); userLPInv.setPrefLocale(Locale.GERMAN); userService.create(userLPInv, trialSite); Person userP = new Person(); userP.setFirstname("Maxi"); userP.setSurname("Monitor"); userP.setEmail("randi2@action.ms"); userP.setPhone("1234567"); userP.setSex(Gender.FEMALE); // userP.setTrialSite(trialSite); Login userL = new Login(); userL.setUsername("monitor@trialsite1.de"); userL.setPassword("1$heidelberg"); userL.setPerson(userP); userL.setPrefLocale(Locale.GERMANY); userL.addRole(Role.ROLE_MONITOR); userL.setPrefLocale(Locale.GERMAN); userService.create(userL, trialSite); userP = new Person(); userP.setFirstname("Max"); userP.setSurname("Statistican"); userP.setEmail("randi2@action.ms"); userP.setPhone("1234567"); userP.setSex(Gender.MALE); // userP.setTrialSite(trialSite); userL = new Login(); userL.setUsername("statistican@trialsite1.de"); userL.setPassword("1$heidelberg"); userL.setPerson(userP); userL.setPrefLocale(Locale.GERMANY); userL.addRole(Role.ROLE_STATISTICAN); userL.setPrefLocale(Locale.GERMAN); userService.create(userL, trialSite); TrialSite trialSite1 = new TrialSite(); trialSite1.setCity("Heidelberg"); trialSite1.setCountry("Germany"); trialSite1.setName("Trial Site 2"); trialSite1.setPostcode("69120"); trialSite1.setStreet("INF"); trialSite1.setPassword("1$heidelberg"); trialSite1.setContactPerson(cp2); trialSiteService.create(trialSite1); // create test trial trialSite1 = trialSiteService.getObject(trialSite1.getId()); Person userPInv2 = new Person(); userPInv2.setFirstname("Max"); userPInv2.setSurname("Investigator"); userPInv2.setEmail("randi2@action.ms"); userPInv2.setPhone("1234567"); userPInv2.setSex(Gender.MALE); Login userLInv2 = new Login(); userLInv2.setUsername("investigator@trialsite2.de"); userLInv2.setPassword("1$heidelberg"); userLInv2.setPerson(userPInv2); userLInv2.setPrefLocale(Locale.GERMANY); userLInv2.addRole(Role.ROLE_INVESTIGATOR); userLInv2.setPrefLocale(Locale.GERMAN); userService.create(userLInv2, trialSite1); // create test trial System.out.println("create user: " + (System.nanoTime() - time1) / 1000000 + " ms"); time1 = System.nanoTime(); // create test trial authToken = new AnonymousAuthenticationToken("anonymousUser", userLPInv, new ArrayList<GrantedAuthority>(userLPInv.getAuthorities())); // Perform authentication SecurityContextHolder.getContext().setAuthentication(authToken); SecurityContextHolder.getContext().getAuthentication().setAuthenticated(true); trialSite1 = entityManager.find(TrialSite.class, trialSite1.getId()); Trial trial = new Trial(); trial.setAbbreviation("bs"); trial.setName("Block study"); trial.setDescription("Block study with two treatment arms and blocksize 8, stratified by trial site"); trial.setGenerateIds(true); trial.setStratifyTrialSite(true); trial.setSponsorInvestigator(userPPInv); trial.setLeadingSite(trialSite); trial.addParticipatingSite(trialSite); trial.addParticipatingSite(trialSite1); trial.setStartDate(new GregorianCalendar(2009, 0, 1)); trial.setEndDate(new GregorianCalendar(2010, 11, 1)); trial.setStatus(TrialStatus.ACTIVE); BlockRandomizationConfig randConf = new BlockRandomizationConfig(); randConf.setMaximum(8); randConf.setMinimum(8); randConf.setType(TYPE.ABSOLUTE); trial.setRandomizationConfiguration(randConf); TreatmentArm arm1 = new TreatmentArm(); arm1.setDescription("First Treatment"); arm1.setName("arm1"); arm1.setDescription("description"); arm1.setPlannedSubjects(200); TreatmentArm arm2 = new TreatmentArm(); arm2.setDescription("Second Treatment"); arm2.setName("arm2"); arm2.setDescription("description"); arm2.setPlannedSubjects(200); trial.setTreatmentArms(new HashSet<TreatmentArm>(Arrays.asList(arm1, arm2))); DichotomousCriterion cr = new DichotomousCriterion(); cr.setName("SEX"); cr.setOption1("M"); cr.setOption2("F"); DichotomousCriterion cr1 = new DichotomousCriterion(); cr1.setOption1("1"); cr1.setOption2("2"); cr1.setName("Tum.Status"); DichotomousCriterion cr2 = new DichotomousCriterion(); cr2.setOption1("1"); cr2.setOption2("2"); cr2.setName("Fit.Level"); try { cr.addStrata(new DichotomousConstraint(Arrays.asList(new String[] { "M" }))); cr.addStrata(new DichotomousConstraint(Arrays.asList(new String[] { "F" }))); cr1.addStrata(new DichotomousConstraint(Arrays.asList(new String[] { "1" }))); cr1.addStrata(new DichotomousConstraint(Arrays.asList(new String[] { "2" }))); cr2.addStrata(new DichotomousConstraint(Arrays.asList(new String[] { "1" }))); cr2.addStrata(new DichotomousConstraint(Arrays.asList(new String[] { "2" }))); trial.addCriterion(cr); trial.addCriterion(cr1); trial.addCriterion(cr2); } catch (ConstraintViolatedException e) { BoxedException.throwBoxed(e); } try { trialService.create(trial); } catch (ConstraintViolationException e) { // TODO: handle exception System.out.println(e.getMessage()); for (ConstraintViolation<?> v : e.getConstraintViolations()) { System.out.println(v.getPropertyPath() + " " + v.getMessage()); } } System.out.println("create trial: " + (System.nanoTime() - time1) / 1000000 + " ms"); time1 = System.nanoTime(); int countTS1 = 120; int countTS2 = 60; int countMo = (new GregorianCalendar()).get(GregorianCalendar.MONTH) + 1; int countAll = 0; // Objects for the while-loop Random rand = new Random(); GregorianCalendar date; int runs; boolean tr1; int count; // --- while (countTS1 != 0 || countTS2 != 0) { countAll++; date = new GregorianCalendar(2009, countAll % countMo, 1); runs = 0; tr1 = false; count = 0; if (rand.nextInt(2) == 0 && countTS1 != 0) { count = countTS1; tr1 = true; } else if (countTS2 != 0) { count = countTS2; } if (count >= 10) { runs = rand.nextInt(10) + 1; } else if (count != 0) { runs = rand.nextInt(count) + 1; } // Authorizing the investigator for upcoming randomization AnonymousAuthenticationToken at = tr1 ? new AnonymousAuthenticationToken("anonymousUser", userLInv, new ArrayList<GrantedAuthority>(userLInv.getAuthorities())) : new AnonymousAuthenticationToken("anonymousUser", userLInv2, new ArrayList<GrantedAuthority>(userLInv2.getAuthorities())); SecurityContextHolder.getContext().setAuthentication(at); SecurityContextHolder.getContext().getAuthentication().setAuthenticated(true); // --- for (int i = 0; i < runs; i++) { initRandBS(trial, date, rand); if (tr1) { countTS1--; } else { countTS2--; } } } System.out.println("added trial subjects: " + (System.nanoTime() - time1) / 1000000 + " ms"); }
From source file:org.jfree.data.time.MinuteTest.java
/** * Some checks for the getLastMillisecond(TimeZone) method. *///from ww w . j a v a 2 s. c o m @Test public void testGetLastMillisecondWithCalendar() { Minute m = new Minute(45, 21, 21, 4, 2001); GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY); calendar.setTimeZone(TimeZone.getTimeZone("Europe/Frankfurt")); assertEquals(987889559999L, m.getLastMillisecond(calendar)); // try null calendar boolean pass = false; try { m.getLastMillisecond((Calendar) null); } catch (NullPointerException e) { pass = true; } assertTrue(pass); }
From source file:org.projectforge.business.humanresources.HRPlanningDao.java
/** * <ul>//from w w w . j ava2 s.co m * <li>Checks week date on: monday, 0:00:00.000 and if check fails then the date will be set to.</li> * <li>Check deleted entries and re-adds them instead of inserting a new entry, if exist.</li> * <ul> * * @see org.projectforge.framework.persistence.api.BaseDao#onSaveOrModify(org.projectforge.core.ExtendedBaseDO) */ @Override protected void onSaveOrModify(final HRPlanningDO obj) { final DateHolder date = new DateHolder(obj.getWeek(), DateHelper.UTC, Locale.GERMANY); if (date.getDayOfWeek() != Calendar.MONDAY || date.getMilliSecond() != 0 || date.getMinute() != 0 || date.getHourOfDay() != 0) { log.error("Date is not begin of week, try to change date: " + DateHelper.formatAsUTC(date.getDate())); obj.setFirstDayOfWeek(date.getSQLDate()); } super.onSaveOrModify(obj); }
From source file:org.jfree.data.time.SecondTest.java
/** * Some checks for the getLastMillisecond(TimeZone) method. *//*from w w w . ja v a 2 s .com*/ @Test public void testGetLastMillisecondWithCalendar() { Second s = new Second(50, 45, 21, 21, 4, 2001); GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY); calendar.setTimeZone(TimeZone.getTimeZone("Europe/Frankfurt")); assertEquals(987889550999L, s.getLastMillisecond(calendar)); // try null calendar boolean pass = false; try { s.getLastMillisecond((Calendar) null); } catch (NullPointerException e) { pass = true; } assertTrue(pass); }
From source file:org.talend.dataquality.statistics.datetime.CustomDateTimePatternManagerTest.java
@Test public void testDateWithLocaleFR() { // simulate a JVM Locale.setDefault(Locale.FRANCE); final List<String> pattern = Collections.<String>singletonList("MMMM d ?? yyyy"); final String[] dates = new String[] { "January 9 ?? 1970", // EN "janvier 9 ?? 1970", // FR "Januar 9 ?? 1970", // DE " 9 ?? 1970", // CN };//from ww w .j a v a 2 s . c o m final boolean[] EXPECTED_IS_DATE_DEFAULT = new boolean[] { true, false, false, false }; final boolean[] EXPECTED_IS_DATE_US = new boolean[] { true, false, false, false }; final boolean[] EXPECTED_IS_DATE_FR = new boolean[] { true, true, false, false }; final boolean[] EXPECTED_IS_DATE_DE = new boolean[] { true, false, true, false }; final boolean[] EXPECTED_IS_DATE_CN = new boolean[] { true, false, false, true }; // final String[] EXPECTED_PATTERN_STRING = new String[] { "", }; StringBuilder sb = new StringBuilder("\n"); sb.append("-------------- JVM Locale: " + Locale.getDefault().toString() + " ------\n"); sb.append("Input \\ UserLocale\tN/A\tEN\tFR\tDE\tCN\n"); for (int i = 0; i < dates.length; i++) { sb.append(dates[i]).append(" \t"); sb.append(CustomDateTimePatternManager.isDate(dates[i], pattern)).append("\t"); sb.append(CustomDateTimePatternManager.isDate(dates[i], pattern, Locale.US)).append("\t"); sb.append(CustomDateTimePatternManager.isDate(dates[i], pattern, Locale.FRANCE)).append("\t"); sb.append(CustomDateTimePatternManager.isDate(dates[i], pattern, Locale.GERMANY)).append("\t"); sb.append(CustomDateTimePatternManager.isDate(dates[i], pattern, Locale.CHINA)).append("\t"); sb.append("\n"); assertEquals(EXPECTED_IS_DATE_DEFAULT[i], CustomDateTimePatternManager.isDate(dates[i], pattern)); assertEquals(EXPECTED_IS_DATE_US[i], CustomDateTimePatternManager.isDate(dates[i], pattern, Locale.US)); assertEquals(EXPECTED_IS_DATE_FR[i], CustomDateTimePatternManager.isDate(dates[i], pattern, Locale.FRANCE)); assertEquals(EXPECTED_IS_DATE_DE[i], CustomDateTimePatternManager.isDate(dates[i], pattern, Locale.GERMANY)); assertEquals(EXPECTED_IS_DATE_CN[i], CustomDateTimePatternManager.isDate(dates[i], pattern, Locale.CHINA)); } LOGGER.info(sb.toString()); }
From source file:de.damdi.fitness.activity.create_workout.ExerciseTypeListFragment.java
/** * Filters the list of exercises for the search query. The method * {@link #filterExercisesForMusclesAndEquipment()} will be called in this * method.//from w w w.j ava 2 s.c o m * */ private void filterExercisesForSearchQuery() { Log.d(TAG, "filterExercisesForSearchQuery() mSearchEquery=" + mSearchQuery); filterExercisesForMusclesAndEquipment(); if (mSearchQuery == null) mSearchQuery = ""; // quit if the user did not search for anything if (mSearchQuery.equals("") || mSearchQuery.replaceAll(" ", "").equals("")) return; for (ExerciseType ex : new ArrayList<ExerciseType>(mExericseList)) { boolean accepted = false; for (String name : ex.getAlternativeNames()) { name = name.toLowerCase(Locale.GERMANY); if (name.contains(mSearchQuery.toLowerCase(Locale.GERMANY))) { accepted = true; continue; } } if (!accepted) { mExericseList.remove(ex); } } setListAdapter(new ExerciseTypeListAdapter(getActivity(), android.R.layout.simple_list_item_single_choice, android.R.id.text1, mExericseList)); }
From source file:org.jfree.data.time.junit.MillisecondTest.java
/** * Some checks for the getFirstMillisecond(TimeZone) method. *//*from www . ja va 2s .c o m*/ public void testGetFirstMillisecondWithCalendar() { Millisecond m = new Millisecond(500, 55, 40, 2, 15, 4, 2000); GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY); calendar.setTimeZone(TimeZone.getTimeZone("Europe/Frankfurt")); assertEquals(955766455500L, m.getFirstMillisecond(calendar)); // try null calendar boolean pass = false; try { m.getFirstMillisecond((Calendar) null); } catch (NullPointerException e) { pass = true; } assertTrue(pass); }
From source file:org.jfree.data.time.MonthTest.java
/** * Some checks for the getFirstMillisecond(TimeZone) method. *//*from ww w . ja va 2s . c o m*/ @Test public void testGetFirstMillisecondWithCalendar() { Month m = new Month(1, 2001); GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY); calendar.setTimeZone(TimeZone.getTimeZone("Europe/Frankfurt")); assertEquals(978307200000L, m.getFirstMillisecond(calendar)); // try null calendar boolean pass = false; try { m.getFirstMillisecond((Calendar) null); } catch (NullPointerException e) { pass = true; } assertTrue(pass); }
From source file:de.randi2.jsf.controllerBeans.LoginHandler.java
public void setDEGerman(ActionEvent event) { this.loggedInUser.setPrefLocale(Locale.GERMANY); this.setChosenLocale(Locale.GERMANY); }
From source file:org.jfree.data.time.DayTest.java
/** * Some checks for the getFirstMillisecond(TimeZone) method. *//*w w w . j a v a2 s . c o m*/ @Test public void testGetFirstMillisecondWithCalendar() { Day d = new Day(1, 12, 2001); GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY); calendar.setTimeZone(TimeZone.getTimeZone("Europe/Frankfurt")); assertEquals(1007164800000L, d.getFirstMillisecond(calendar)); // try null calendar boolean pass = false; try { d.getFirstMillisecond((Calendar) null); } catch (NullPointerException e) { pass = true; } assertTrue(pass); }