Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
rhbz837979 - Change default enabled locales for projects and versions.
Browse files Browse the repository at this point in the history
The default selected locales when overriding only include the "enabled by default" ones. The others will not be selected but available for selection.
  • Loading branch information
Carlos Munoz committed Oct 2, 2012
1 parent ca75637 commit 9da2e05
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 48 deletions.
12 changes: 5 additions & 7 deletions zanata-war/src/main/java/org/zanata/action/LocaleListAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,16 +121,14 @@ public Map<String, String> loadItems()
customizedItems = localeServiceImpl.getCustomizedLocalesItems(slug);
if (customizedItems.isEmpty())
{
customizedItems = globalItems;
customizedItems = localeServiceImpl.getDefaultCustomizedLocalesItems();
}
else

for (String op : globalItems.keySet())
{
for (String op : globalItems.keySet())
if (!customizedItems.containsKey(op))
{
if (!customizedItems.containsKey(op))
{
availableItems.put(op, op);
}
availableItems.put(op, op);
}
}
return availableItems;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,8 @@ public class ProjectIterationLocaleAction implements Serializable
@In
ProjectIterationDAO projectIterationDAO;

private String projectSlug;

private String iterationSlug;
@In
private ProjectIterationHome projectIterationHome;

@In
LocaleService localeServiceImpl;
Expand Down Expand Up @@ -119,46 +118,25 @@ public Map<String, String> getIterationCustomizedItems()
public Map<String, String> loadItems()
{
log.debug("load iterationCustomizedItems");
HProjectIteration iteration = projectIterationHome.getInstance();
availableItems = new TreeMap<String, String>();
iterationCustomizedItems = localeServiceImpl.getIterationCustomizedLocalesItems(projectSlug, iterationSlug);
globalItems = localeServiceImpl.getIterationGlobalLocaleItems(projectSlug);
iterationCustomizedItems = localeServiceImpl.getIterationCustomizedLocalesItems(iteration.getProject().getSlug(), iteration.getSlug());
globalItems = localeServiceImpl.getIterationGlobalLocaleItems(iteration.getProject().getSlug());
if (iterationCustomizedItems.isEmpty())
{
iterationCustomizedItems = globalItems;
iterationCustomizedItems = localeServiceImpl.getDefaultCustomizedLocalesItems();
}
else

for (String op : globalItems.keySet())
{
for (String op : globalItems.keySet())
if (!iterationCustomizedItems.containsKey(op))
{
if (!iterationCustomizedItems.containsKey(op))
{
availableItems.put(op, op);
}
availableItems.put(op, op);
}
}
return availableItems;
}

public String getProjectSlug()
{
return projectSlug;
}

public void setProjectSlug(String projectSlug)
{
this.projectSlug = projectSlug;
}

public String getIterationSlug()
{
return iterationSlug;
}

public void setIterationSlug(String iterationSlug)
{
this.iterationSlug = iterationSlug;
}

public void setSetting(boolean var)
{
setting = var;
Expand All @@ -169,14 +147,13 @@ public boolean getSetting()
{
if (iterationOverrideLocales == null)
{
if (projectSlug == null || iterationSlug == null)
if (projectIterationHome.getInstance() == null)
{
setting = false;
}
else
{
HProjectIteration project = projectIterationDAO.getBySlug(projectSlug, iterationSlug);
setting = project.getOverrideLocales();
setting = projectIterationHome.getInstance().getOverrideLocales();
}
iterationOverrideLocales = new Boolean(setting);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,12 @@ public interface LocaleService
Map<String, String> getGlobalLocaleItems();

Map<String, String> getCustomizedLocalesItems(String project);


/**
* @return The default selected locale items.
*/
Map<String, String> getDefaultCustomizedLocalesItems();

Set<HLocale> convertCustomizedLocale(Map<String, String> var);

Map<String, String> getIterationCustomizedLocalesItems(String projectSlug, String iterationSlug);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ protected Void work() throws Exception
int copyCount = 0;

// Determine the state of the copies for each pass
ContentState copyState = Approved;
boolean checkContext = true,
checkProject = true,
checkDocument = true;
Expand Down Expand Up @@ -189,10 +188,6 @@ protected Void work() throws Exception
{
// Relax context restriction
checkContext = false;
if( options.getContextMismatchAction() == DOWNGRADE_TO_FUZZY )
{
copyState = NeedReview;
}
// Assuming above phases:
// Context does not match
// either doc Id didn't match, or the user explicitly rejected non-matching documents
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,23 @@ public Map<String, String> getCustomizedLocalesItems(String projectSlug)
return customizedItems;
}

@Override
public Map<String, String> getDefaultCustomizedLocalesItems()
{
Map<String, String> defaultItems = new TreeMap<String, String>();
List<HLocale> allLocales = getSupportedLocales();

for( HLocale locale : allLocales )
{
if( locale.isEnabledByDefault() )
{
String desc = getDescript(locale);
defaultItems.put(desc, desc);
}
}
return defaultItems;
}

@Override
public Map<String, String> getIterationCustomizedLocalesItems(String projectSlug, String iterationSlug)
{
Expand Down

0 comments on commit 9da2e05

Please sign in to comment.