diff --git a/tools/cldr-apps/src/main/java/org/unicode/cldr/util/CLDRConfigImpl.java b/tools/cldr-apps/src/main/java/org/unicode/cldr/util/CLDRConfigImpl.java index 3f4bd0949fb..35138d194f5 100644 --- a/tools/cldr-apps/src/main/java/org/unicode/cldr/util/CLDRConfigImpl.java +++ b/tools/cldr-apps/src/main/java/org/unicode/cldr/util/CLDRConfigImpl.java @@ -457,12 +457,12 @@ public JSONObject toJSONObject() throws JSONException { @Override public CheckCLDR.Phase getPhase() { - return SurveyMain.phase().getCPhase(); + return SurveyMain.getOverallSurveyPhase().toCheckCLDRPhase(); } @Override public CheckCLDR.Phase getDDLPhase() { - return SurveyMain.getDDLPhase().getCPhase(); + return SurveyMain.getOverallDDLPhase().toCheckCLDRPhase(); } @Override diff --git a/tools/cldr-apps/src/main/java/org/unicode/cldr/web/DBUtils.java b/tools/cldr-apps/src/main/java/org/unicode/cldr/web/DBUtils.java index 841fcb0b4ba..a62b47a2ba3 100644 --- a/tools/cldr-apps/src/main/java/org/unicode/cldr/web/DBUtils.java +++ b/tools/cldr-apps/src/main/java/org/unicode/cldr/web/DBUtils.java @@ -53,7 +53,6 @@ import org.unicode.cldr.util.CldrUtility; import org.unicode.cldr.util.PathHeader; import org.unicode.cldr.util.StackTracker; -import org.unicode.cldr.web.SurveyMain.Phase; /** Singleton utility class for simple(r) DB access. */ public class DBUtils { @@ -963,8 +962,7 @@ public static StringBuilder appendVersionString( /** Append a versioned string */ public static StringBuilder appendVersionString(StringBuilder sb) { - return appendVersionString( - sb, SurveyMain.getNewVersion(), SurveyMain.phase() == SurveyMain.Phase.BETA); + return appendVersionString(sb, SurveyMain.getNewVersion(), SurveyMain.isPhaseBeta()); } private static String[] arrayOfResult(ResultSet rs) throws SQLException { @@ -1380,8 +1378,7 @@ public synchronized String toString() { "Error: don't use Table.toString before CLDRConfig is setup."); } defaultString = - forVersion(SurveyMain.getNewVersion(), SurveyMain.phase() == Phase.BETA) - .toString(); + forVersion(SurveyMain.getNewVersion(), SurveyMain.isPhaseBeta()).toString(); } return defaultString; } diff --git a/tools/cldr-apps/src/main/java/org/unicode/cldr/web/DataPage.java b/tools/cldr-apps/src/main/java/org/unicode/cldr/web/DataPage.java index 232d76d2c51..607c126658f 100644 --- a/tools/cldr-apps/src/main/java/org/unicode/cldr/web/DataPage.java +++ b/tools/cldr-apps/src/main/java/org/unicode/cldr/web/DataPage.java @@ -988,7 +988,7 @@ public Map getNonDistinguishingAttributes() { */ public StatusAction getStatusAction(InputMethod inputMethod) { // null because this is for display. - return SurveyMain.getCPhase(locale) + return SurveyMain.checkCLDRPhase(locale) .getShowRowAction(this, inputMethod, getPathHeader(), userForVotelist); } diff --git a/tools/cldr-apps/src/main/java/org/unicode/cldr/web/SurveyAjax.java b/tools/cldr-apps/src/main/java/org/unicode/cldr/web/SurveyAjax.java index 720a3e85bef..5d92275b499 100644 --- a/tools/cldr-apps/src/main/java/org/unicode/cldr/web/SurveyAjax.java +++ b/tools/cldr-apps/src/main/java/org/unicode/cldr/web/SurveyAjax.java @@ -1092,7 +1092,6 @@ private static JSONObject createJSONLocMap(SurveyMain sm) throws JSONException { // locales will have info about each locale, including name JSONObject locales = new JSONObject(); SupplementalDataInfo sdi = sm.getSupplementalDataInfo(); - final StandardCodes sc = StandardCodes.make(); Factory disk = sm.getDiskFactory(); @@ -2658,7 +2657,7 @@ public static void handleBulkSubmit( final List checkResult = new ArrayList<>(); TestCache.TestResultBundle cc = stf.getTestResult(loc, DataPage.getOptions(cs, loc)); UserRegistry.User u = theirU; - CheckCLDR.Phase cPhase = SurveyMain.getCPhase(loc); + CheckCLDR.Phase cPhase = SurveyMain.checkCLDRPhase(loc); Set allValidPaths = stf.getPathsForFile(loc); CLDRProgressTask progress = sm.openProgress("Bulk:" + loc, all.size()); CLDRFile cldrUnresolved = cf.getUnresolved(); diff --git a/tools/cldr-apps/src/main/java/org/unicode/cldr/web/SurveyMain.java b/tools/cldr-apps/src/main/java/org/unicode/cldr/web/SurveyMain.java index b633a42f6b5..95076d37a27 100644 --- a/tools/cldr-apps/src/main/java/org/unicode/cldr/web/SurveyMain.java +++ b/tools/cldr-apps/src/main/java/org/unicode/cldr/web/SurveyMain.java @@ -177,7 +177,7 @@ public String toString() { * @see org.unicode.cldr.test.CheckCLDR.Phase * @return the CheckCLDR.Phase */ - public CheckCLDR.Phase getCPhase() { + public CheckCLDR.Phase toCheckCLDRPhase() { return cphase; } } @@ -2079,8 +2079,8 @@ public String getLocaleLink(WebContext ctx, CLDRLocale locale, String n) { if (canModify) { rv = rv + (modifyThing(ctx)); int odisp; - if ((SurveyMain.phase(locale) == Phase.VETTING - || SurveyMain.phase(locale) == Phase.SUBMIT + if ((SurveyMain.surveyPhase(locale) == Phase.VETTING + || SurveyMain.surveyPhase(locale) == Phase.SUBMIT || isPhaseVettingClosed(locale)) && ((odisp = DisputePageManager.getOrgDisputeCount(ctx)) > 0)) { rv = rv + ctx.iconHtml("disp", "(" + odisp + " org disputes)"); @@ -2446,7 +2446,7 @@ private synchronized String getDirectionalityFor(CLDRLocale id) { * @see org.unicode.cldr.test.CheckCoverage#check(String, String, String, Map, List) */ public static org.unicode.cldr.test.CheckCLDR.Phase getTestPhase() { - return phase().getCPhase(); + return getOverallSurveyPhase().toCheckCLDRPhase(); } /** @@ -2844,7 +2844,11 @@ private void doStartup() { } currentDdlPhase = ddlPhase; } - logger.info("Phase: " + phase() + ", cPhase: " + phase().getCPhase()); + logger.info( + "Phase: " + + getOverallSurveyPhase() + + ", CheckCLDR Phase: " + + getOverallSurveyPhase().toCheckCLDRPhase()); progress.update("Setup props.."); newVersion = survprops.getProperty(CLDR_NEWVERSION, CLDR_NEWVERSION); oldVersion = survprops.getProperty(CLDR_OLDVERSION, CLDR_OLDVERSION); @@ -3575,33 +3579,43 @@ public static String localhost() { // ============= Following have to do with phases public static boolean isPhaseVettingClosed(CLDRLocale locale) { - return phase(locale) == Phase.VETTING_CLOSED; + return surveyPhase(locale) == Phase.VETTING_CLOSED; } public static boolean isPhaseReadonly() { - return phase() == Phase.READONLY; + return getOverallSurveyPhase() == Phase.READONLY; } public static boolean isPhaseBeta() { - return phase() == Phase.BETA; + return getOverallSurveyPhase() == Phase.BETA; } - public static Phase phase() { + /** Internal- returns the overall phase. Not locale specific. */ + public static Phase getOverallSurveyPhase() { return currentPhase; } - public static Phase phase(CLDRLocale locale) { - return (SubmissionLocales.isTcLocale(locale) ? phase() : getDDLPhase()); + /** + * @returns the SurveyTool Phase for the locale + */ + public static Phase surveyPhase(CLDRLocale locale) { + return (SubmissionLocales.isTcLocale(locale) + ? getOverallSurveyPhase() + : getOverallDDLPhase()); } /** - * @returns the current phase for the locale. This is the preferred API. + * @returns the current CheckCLDR phase for the locale. This is the preferred API. */ - public static CheckCLDR.Phase getCPhase(CLDRLocale loc) { - return phase(loc).getCPhase(); + public static CheckCLDR.Phase checkCLDRPhase(CLDRLocale loc) { + return surveyPhase(loc).toCheckCLDRPhase(); } - public static Phase getDDLPhase() { + /** + * the DDL (non-TC) overall phase. It is preferred to use one of the phase functions which takes + * a locale. + */ + public static Phase getOverallDDLPhase() { return currentDdlPhase; } @@ -3676,8 +3690,8 @@ private class StatusForFrontEnd implements JSONString { private String organizationName = null; private final int pages = SurveyMain.pages; private Object permissions = null; - private final Phase phase = phase(); - private final Phase ddlPhase = getDDLPhase(); + private final Phase phase = getOverallSurveyPhase(); + private final Phase ddlPhase = getOverallDDLPhase(); private String sessionId = null; private final String specialHeader = getSpecialHeaderText(); private final long surveyRunningStamp = SurveyMain.surveyRunningStamp.current(); diff --git a/tools/cldr-apps/src/main/java/org/unicode/cldr/web/UserRegistry.java b/tools/cldr-apps/src/main/java/org/unicode/cldr/web/UserRegistry.java index f4f56b5e9a4..36f0575f96b 100644 --- a/tools/cldr-apps/src/main/java/org/unicode/cldr/web/UserRegistry.java +++ b/tools/cldr-apps/src/main/java/org/unicode/cldr/web/UserRegistry.java @@ -1821,7 +1821,7 @@ public static boolean userCanCreateUsers(User u) { } static boolean userCanSubmit(User u, SurveyMain.Phase phase) { - return (u != null) && u.getLevel().canSubmit(phase.getCPhase()); + return (u != null) && u.getLevel().canSubmit(phase.toCheckCLDRPhase()); } /** diff --git a/tools/cldr-apps/src/main/java/org/unicode/cldr/web/WebContext.java b/tools/cldr-apps/src/main/java/org/unicode/cldr/web/WebContext.java index 2500d12590f..423c178d78e 100644 --- a/tools/cldr-apps/src/main/java/org/unicode/cldr/web/WebContext.java +++ b/tools/cldr-apps/src/main/java/org/unicode/cldr/web/WebContext.java @@ -1089,7 +1089,7 @@ public static HTMLDirection fromCldr(String dir) { * @return true if the user can modify this locale */ public Boolean canModify() { - if (STFactory.isReadOnlyLocale(locale) || SurveyMain.phase() == Phase.READONLY) + if (STFactory.isReadOnlyLocale(locale) || SurveyMain.surveyPhase(locale) == Phase.READONLY) return (canModify = false); if (canModify == null) { if (session != null && session.user != null) { diff --git a/tools/cldr-apps/src/main/java/org/unicode/cldr/web/api/Summary.java b/tools/cldr-apps/src/main/java/org/unicode/cldr/web/api/Summary.java index 22ca409ae1b..468e8d13e32 100644 --- a/tools/cldr-apps/src/main/java/org/unicode/cldr/web/api/Summary.java +++ b/tools/cldr-apps/src/main/java/org/unicode/cldr/web/api/Summary.java @@ -336,7 +336,7 @@ public void run() { private void makeAutoPriorityItemsSnapshot() throws IOException, JSONException { boolean summarizeAllLocales = false; if (ENABLE_ALL_LOCALE_SUMMARY) { - final SurveyMain.Phase phase = SurveyMain.phase(); + final SurveyMain.Phase phase = SurveyMain.getOverallSurveyPhase(); summarizeAllLocales = (phase == SurveyMain.Phase.VETTING || phase == SurveyMain.Phase.VETTING_CLOSED); } diff --git a/tools/cldr-apps/src/test/java/org/unicode/cldr/web/TestUserLevel.java b/tools/cldr-apps/src/test/java/org/unicode/cldr/web/TestUserLevel.java index 12f9417538a..cc26378d3cb 100644 --- a/tools/cldr-apps/src/test/java/org/unicode/cldr/web/TestUserLevel.java +++ b/tools/cldr-apps/src/test/java/org/unicode/cldr/web/TestUserLevel.java @@ -302,7 +302,8 @@ void TestVoteResolverLevel( assertEquals(expected, l.canUseVettingSummary(), onFail); break; case "userCanSubmit_SUBMIT": - assertEquals(expected, l.canSubmit(SurveyMain.Phase.SUBMIT.getCPhase()), onFail); + assertEquals( + expected, l.canSubmit(SurveyMain.Phase.SUBMIT.toCheckCLDRPhase()), onFail); break; case "userCanCreateSummarySnapshot": assertEquals(expected, l.canCreateSummarySnapshot(), onFail);