Skip to content

Commit

Permalink
CLDR-16835 ddl phase - update per locale comments
Browse files Browse the repository at this point in the history
- replaced phase() and getCPhase() with getSurveyPhase() and toCheckCLDRPhase() for more clarity
- renamed the non-locale calls to getOverallSurveyPhase(), and reviewed.

See also CLDR-8196 for merging SurveyTool.Phase and CheckCLDR.Phase
  • Loading branch information
srl295 committed Jun 11, 2024
1 parent 44e0b01 commit 701415f
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -988,7 +988,7 @@ public Map<String, String> 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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -2658,7 +2657,7 @@ public static void handleBulkSubmit(
final List<CheckCLDR.CheckStatus> 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<String> allValidPaths = stf.getPathsForFile(loc);
CLDRProgressTask progress = sm.openProgress("Bulk:" + loc, all.size());
CLDRFile cldrUnresolved = cf.getUnresolved();
Expand Down
48 changes: 31 additions & 17 deletions tools/cldr-apps/src/main/java/org/unicode/cldr/web/SurveyMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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)");
Expand Down Expand Up @@ -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();
}

/**
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 701415f

Please sign in to comment.