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

Commit

Permalink
Merge branch 'integration/master' of github.com:zanata/zanata into in…
Browse files Browse the repository at this point in the history
…tegration/master
  • Loading branch information
Alex Eng committed Oct 2, 2012
2 parents f963a0a + 9da2e05 commit 24f21cb
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
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
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
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
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
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 24f21cb

Please sign in to comment.