From 7c8244947832c7ad0b689866e5df7982b27ad60e Mon Sep 17 00:00:00 2001 From: Tom Bishop Date: Tue, 13 Feb 2024 17:15:45 -0500 Subject: [PATCH] CLDR-16946 Fix triple up arrow producing error in VXML (#3501) -Replace makeVettedFile with return make(loc.getBaseName(), false) -Remove dead code including VoteLoadingContext.VXML_GENERATION, makeVettedSource, makeVettedFile -Baseline has long been used instead of last-release; obsolete comments indicated VXML required VoteResolver for last-release -Comments --- .../unicode/cldr/web/BallotBoxXMLSource.java | 4 - .../unicode/cldr/web/OutputFileManager.java | 2 +- .../java/org/unicode/cldr/web/STFactory.java | 88 +++---------------- 3 files changed, 11 insertions(+), 83 deletions(-) diff --git a/tools/cldr-apps/src/main/java/org/unicode/cldr/web/BallotBoxXMLSource.java b/tools/cldr-apps/src/main/java/org/unicode/cldr/web/BallotBoxXMLSource.java index f6d7e1f5777..35c437f057a 100644 --- a/tools/cldr-apps/src/main/java/org/unicode/cldr/web/BallotBoxXMLSource.java +++ b/tools/cldr-apps/src/main/java/org/unicode/cldr/web/BallotBoxXMLSource.java @@ -54,9 +54,6 @@ VoteResolver setValueFromResolver( * * Do not skip vote resolution if VoteLoadingContext.SINGLE_VOTE, even for empty xpd. Otherwise an Abstain can * result in "no votes", "skip vote resolution", failure to get the right winning value, possibly inherited. - * - * Do not skip vote resolution if VoteLoadingContext.VXML_GENERATION, even for empty xpd. We may need to call - * getWinningValue for vote resolution for a larger set of paths to get baseline, etc. */ /** @@ -98,7 +95,6 @@ private String getFullPathWithResolver(String path, VoteResolver resolve /* * Catch Status.missing, or it will trigger an exception in draftStatusFromWinningStatus * since there is no "missing" in DraftStatus. - * This may happen especially for VoteLoadingContext.VXML_GENERATION. * * Status.missing can also occur for VoteLoadingContext.SINGLE_VOTE, when a user abstains * after submitting a new value. Then, delegate.removeValueAtDPath and/or delegate.putValueAtPath diff --git a/tools/cldr-apps/src/main/java/org/unicode/cldr/web/OutputFileManager.java b/tools/cldr-apps/src/main/java/org/unicode/cldr/web/OutputFileManager.java index 038ad4ad1c1..f970964c7e4 100644 --- a/tools/cldr-apps/src/main/java/org/unicode/cldr/web/OutputFileManager.java +++ b/tools/cldr-apps/src/main/java/org/unicode/cldr/web/OutputFileManager.java @@ -337,7 +337,7 @@ private File writeManualOutputFile(File vetDataDir, CLDRLocale loc, Kind kind) { long st = System.currentTimeMillis(); CLDRFile cldrFile; if (kind == Kind.vxml) { - cldrFile = sm.getSTFactory().makeVettedFile(loc); + cldrFile = sm.getSTFactory().make(loc.getBaseName(), false); } else if (kind == Kind.pxml) { cldrFile = sm.getSTFactory().makeProposedFile(loc); } else { diff --git a/tools/cldr-apps/src/main/java/org/unicode/cldr/web/STFactory.java b/tools/cldr-apps/src/main/java/org/unicode/cldr/web/STFactory.java index 1f1ebe1c747..71d32a87685 100644 --- a/tools/cldr-apps/src/main/java/org/unicode/cldr/web/STFactory.java +++ b/tools/cldr-apps/src/main/java/org/unicode/cldr/web/STFactory.java @@ -69,11 +69,6 @@ enum VoteLoadingContext { */ ORDINARY_LOAD_VOTES, - /** - * The special context when loadVoteValues is called by makeVettedSource for generating VXML - */ - VXML_GENERATION, - /** * The context when a voting (or abstaining) event occurs and setValueFromResolver is called * by voteForValue (not used for loadVoteValues) @@ -359,7 +354,7 @@ public Date getLastModDate() { new BallotBoxXMLSource( diskDataEntry.diskData.cloneAsThawed(), this); registerXmlSource(dataBackedSource); - loadVoteValues(dataBackedSource, VoteLoadingContext.ORDINARY_LOAD_VOTES); + loadVoteValues(); nextStamp(); XMLSource resolvedXmlsource = makeResolvingSource(); rFile = @@ -428,18 +423,10 @@ private boolean isValidSurveyToolVote(UserRegistry.User user, String xpath) { } /** - * Load internal data (votes, etc.) for this PerLocaleData, and push it into the given - * DataBackedSource. - * - * @param targetXmlSource the DataBackedSource which might or might not equal - * this.xmlsource; for makeVettedSource, it is a different (uncached) DataBackedSource. - * @param voteLoadingContext VoteLoadingContext.ORDINARY_LOAD_VOTES or - * VoteLoadingContext.VXML_GENERATION (not VoteLoadingContext.SINGLE_VOTE) - *

Called by PerLocaleData.makeSource (with VoteLoadingContext.ORDINARY_LOAD_VOTES) - * and by PerLocaleData.makeVettedSource (with VoteLoadingContext.VXML_GENERATION). + * Load internal data (votes, etc.) for this PerLocaleData, and push it into + * dataBackedSource */ - private void loadVoteValues( - BallotBoxXMLSource targetXmlSource, VoteLoadingContext voteLoadingContext) { + private void loadVoteValues() { VoteResolver resolver = null; // save recalculating this. ElapsedTimer et = (SurveyLog.DEBUG) ? new ElapsedTimer("Loading PLD for " + locale) : null; @@ -554,35 +541,17 @@ private void loadVoteValues( : null; /* * Now that we've loaded all the votes, resolve the votes for each path. - * - * For VoteLoadingContext.VXML_GENERATION we use all paths in diskData (trunk) in - * addition to allPXDPaths(); otherwise, vxml produced by OutputFileManager is missing some paths. - * allPXDPaths() may return an empty array if there are no votes in current votes table. - * (However, we assume that last-release value soon won't be used anymore for vote resolution. - * If we did need paths from last-release, or any paths missing from trunk and current votes table, - * we could loop through sm.getSTFactory().getPathsForFile(locale); however, that would generally - * include more paths than are wanted for vxml.) - * Reference: https://unicode-org.atlassian.net/browse/CLDR-11909 - * - * TODO: revisit whether this difference for VoteLoadingContext.VXML_GENERATION is still necessary; when added - * cases where last-release value made a difference to vote resolution; now that "baseline" = trunk not - * last-release it's possible that vote resolution isn't needed for items without current votes. */ - Set xpathSet; - if (voteLoadingContext == VoteLoadingContext.VXML_GENERATION) { - xpathSet = new HashSet<>(allPXDPaths()); - for (String xp : diskDataEntry.diskData) { - xpathSet.add(xp); - } - } else { // voteLoadingContext == VoteLoadingContext.ORDINARY_LOAD_VOTES - xpathSet = allPXDPaths(); - } + Set xpathSet = allPXDPaths(); int j = 0; for (String xp : xpathSet) { try { resolver = - targetXmlSource.setValueFromResolver( - xp, resolver, voteLoadingContext, peekXpathData(xp)); + dataBackedSource.setValueFromResolver( + xp, + resolver, + VoteLoadingContext.ORDINARY_LOAD_VOTES, + peekXpathData(xp)); } catch (Exception e) { e.printStackTrace(); SurveyLog.logException(logger, e, "In setValueFromResolver, xp = " + xp); @@ -779,23 +748,6 @@ public String getVoteValue(User user, String distinguishingXpath) { } } - /** - * Make a vetted source for this PerLocaleData, suitable for producing vxml with - * vote-resolution done on more paths. - * - *

This function is similar to makeSource, but with VoteLoadingContext.VXML_GENERATION. - * - * @return the DataBackedSource (NOT the same as PerLocaleData.xmlsource) - */ - private synchronized XMLSource makeVettedSource() { - BallotBoxXMLSource vxmlSource = - new BallotBoxXMLSource(diskDataEntry.diskData.cloneAsThawed(), this); - if (!readonly) { - loadVoteValues(vxmlSource, VoteLoadingContext.VXML_GENERATION); - } - return vxmlSource; - } - @Override public void unvoteFor(User user, String distinguishingXpath) throws BallotBox.InvalidXPathException, VoteNotAcceptedException { @@ -1456,26 +1408,6 @@ public CLDRFile make(CLDRLocale loc, boolean resolved) { return make(loc.getBaseName(), resolved); } - /** - * Make a "vetted" CLDRFile with more paths resolved, for generating VXML (vetted XML). - * - *

See loadVoteValues for what exactly "more paths" means. - * - *

This kind of CLDRFile should not be confused with ordinary (not-fully-vetted) files, or - * re-used for anything other than vxml. Avoid mixing data for the two kinds of CLDRFile in - * caches (such as rLocales). - * - * @param loc the CLDRLocale - * @return the vetted CLDRFile with more paths resolved - */ - public CLDRFile makeVettedFile(CLDRLocale loc) { - PerLocaleData pld = get(loc.getBaseName()); - XMLSource xmlSource = pld.makeVettedSource(); - CLDRFile cldrFile = new CLDRFile(xmlSource); - cldrFile.setSupplementalDirectory(getSupplementalDirectory()); - return cldrFile; - } - /** * Prepare statement. Args: locale Result: xpath,submitter,value *