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

Commit

Permalink
invoke raw pull from normal pull mojo
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmason committed Oct 18, 2012
1 parent 1aa7e11 commit fda535b
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 194 deletions.

This file was deleted.

Expand Up @@ -68,46 +68,55 @@ private PullStrategy getStrategy(String strategyType)

private void logOptions()
{
log.info("Server: {}", getOpts().getUrl());
log.info("Project: {}", getOpts().getProj());
log.info("Version: {}", getOpts().getProjectVersion());
log.info("Username: {}", getOpts().getUsername());
log.info("Project type: {}", getOpts().getProjectType());
log.info("Enable modules: {}", getOpts().getEnableModules());
if (getOpts().getEnableModules())
logOptions(log, getOpts());
log.info("Create skeletons for untranslated messages/files: {}", getOpts().getCreateSkeletons());

if (getOpts().isDryRun())
{
log.info("Current Module: {}", getOpts().getCurrentModule());
if (getOpts().isRootModule())
log.info("DRY RUN: no permanent changes will be made");
}
}

/**
* @param logger
* @param opts
*/
public static void logOptions(Logger logger, PullOptions opts)
{
logger.info("Server: {}", opts.getUrl());
logger.info("Project: {}", opts.getProj());
logger.info("Version: {}", opts.getProjectVersion());
logger.info("Username: {}", opts.getUsername());
logger.info("Project type: {}", opts.getProjectType());
logger.info("Enable modules: {}", opts.getEnableModules());
if (opts.getEnableModules())
{
logger.info("Current Module: {}", opts.getCurrentModule());
if (opts.isRootModule())
{
log.info("Root module: YES");
if (log.isDebugEnabled())
logger.info("Root module: YES");
if (logger.isDebugEnabled())
{
log.debug("Modules: {}", StringUtils.join(getOpts().getAllModules(), ", "));
logger.debug("Modules: {}", StringUtils.join(opts.getAllModules(), ", "));
}
}
}
log.info("Locales to pull: {}", getOpts().getLocaleMapList());
if (getOpts().getPullType() == PushPullType.Source)
logger.info("Locales to pull: {}", opts.getLocaleMapList());
if (opts.getPullType() == PushPullType.Source)
{
log.info("Pulling source documents only");
log.info("Source-language directory (originals): {}", getOpts().getSrcDir());
logger.info("Pulling source documents only");
logger.info("Source-language directory (originals): {}", opts.getSrcDir());
}
else if( getOpts().getPullType() == PushPullType.Trans )
else if( opts.getPullType() == PushPullType.Trans )
{
log.info("Pulling target documents (translations) only");
log.info("Target-language base directory (translations): {}", getOpts().getTransDir());
logger.info("Pulling target documents (translations) only");
logger.info("Target-language base directory (translations): {}", opts.getTransDir());
}
else
{
log.info("Pulling source and target (translation) documents");
log.info("Source-language directory (originals): {}", getOpts().getSrcDir());
log.info("Target-language base directory (translations): {}", getOpts().getTransDir());
}
log.info("Create skeletons for untranslated messages/files: {}", getOpts().getCreateSkeletons());

if (getOpts().isDryRun())
{
log.info("DRY RUN: no permanent changes will be made");
logger.info("Pulling source and target (translation) documents");
logger.info("Source-language directory (originals): {}", opts.getSrcDir());
logger.info("Target-language base directory (translations): {}", opts.getTransDir());
}
}

Expand Down
Expand Up @@ -21,11 +21,15 @@

package org.zanata.client.commands.pull;

import org.zanata.client.commands.PushPullOptions;
import org.zanata.client.commands.push.PushPullType;

/**
* @author Sean Flanigan <a href="mailto:sflaniga@redhat.com">sflaniga@redhat.com</a>
*
*/
public interface PullOptions extends CommonPullOptions
public interface PullOptions extends PushPullOptions
{
PushPullType getPullType();
boolean getCreateSkeletons();
}
Expand Up @@ -30,6 +30,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.zanata.client.commands.PushPullCommand;
import org.zanata.client.commands.push.PushCommand;
import org.zanata.client.commands.push.PushPullType;
import org.zanata.client.config.LocaleList;
import org.zanata.client.config.LocaleMapping;
Expand All @@ -44,13 +45,13 @@
* @author David Mason, <a href="mailto:damason@redhat.com">damason@redhat.com</a>
*
*/
public class RawPullCommand extends PushPullCommand<CommonPullOptions>
public class RawPullCommand extends PushPullCommand<PullOptions>
{
private static final Logger log = LoggerFactory.getLogger(RawPullCommand.class);

private IFileResource fileResource;

public RawPullCommand(CommonPullOptions opts)
public RawPullCommand(PullOptions opts)
{
super(opts);
this.fileResource = getRequestFactory().getFileResource();
Expand All @@ -59,6 +60,14 @@ public RawPullCommand(CommonPullOptions opts)
@Override
public void run() throws Exception
{
PullCommand.logOptions(log, getOpts());
if (getOpts().isDryRun())
{
log.info("DRY RUN: no permanent changes will be made");
}

log.warn("Using EXPERIMENTAL project type 'raw'.");

LocaleList locales = getOpts().getLocaleMapList();
if (locales == null)
throw new ConfigException("no locales specified");
Expand Down
Expand Up @@ -41,9 +41,9 @@ public class RawPullStrategy

private static final Logger log = LoggerFactory.getLogger(RawPullStrategy.class);

private CommonPullOptions opts;
private PullOptions opts;

public void setPullOptions(CommonPullOptions opts)
public void setPullOptions(PullOptions opts)
{
this.opts = opts;
}
Expand Down
Expand Up @@ -79,7 +79,7 @@ public RawPushCommand(PushOptions opts, ZanataProxyFactory factory, ISourceDocRe
public void run() throws Exception
{
PushCommand.logOptions(log, getOpts());
log.warn("Using experimental project type 'raw'.");
log.warn("Using EXPERIMENTAL project type 'raw'.");

// only supporting single module for now

Expand Down
13 changes: 11 additions & 2 deletions zanata-maven-plugin/src/main/java/org/zanata/maven/PullMojo.java
Expand Up @@ -20,8 +20,10 @@
*/
package org.zanata.maven;

import org.zanata.client.commands.PushPullCommand;
import org.zanata.client.commands.pull.PullCommand;
import org.zanata.client.commands.pull.PullOptions;
import org.zanata.client.commands.pull.RawPullCommand;
import org.zanata.client.commands.push.PushPullType;
import org.zanata.client.config.LocaleList;
import org.zanata.client.config.LocaleMapping;
Expand Down Expand Up @@ -79,9 +81,16 @@ public PullMojo() throws Exception
super();
}

public PullCommand initCommand()
public PushPullCommand<PullOptions> initCommand()
{
return new PullCommand(this);
if ("raw".equals(getProjectType()))
{
return new RawPullCommand(this);
}
else
{
return new PullCommand(this);
}
}

@Override
Expand Down
129 changes: 0 additions & 129 deletions zanata-maven-plugin/src/main/java/org/zanata/maven/RawPullMojo.java

This file was deleted.

0 comments on commit fda535b

Please sign in to comment.