org.jlot.client.executor.PushCommandExecutor Maven / Gradle / Ivy
package org.jlot.client.executor;
import java.util.List;
import java.util.Properties;
import javax.inject.Inject;
import org.jlot.client.configuration.Console;
import org.jlot.client.configuration.ProjectConfiguration;
import org.jlot.client.executor.spi.AbstractCommandExecutor;
import org.jlot.client.remote.PushRestCommand;
import org.jlot.client.remote.rest.RestException;
import org.jlot.core.dto.PushResultDTO;
import org.jlot.core.form.PushForm;
import org.jlot.core.utils.VersionResolver;
import org.springframework.stereotype.Component;
@Component
public class PushCommandExecutor extends AbstractCommandExecutor
{
@Inject
private Console console;
@Inject
private PushRestCommand pushRestCommand;
@Inject
private ProjectConfiguration projectConfiguration;
@Inject
private VersionResolver versionResolver;
@Override
public boolean executeInternal ( Properties properties ) throws RestException
{
PushForm pushForm = getPushCommandForm();
List resultList = pushRestCommand.execute(pushForm);
console.prompt("List of pushed files:");
for (PushResultDTO pushResultDTO : resultList)
{
console.prompt(pushResultDTO.getResourceName());
}
console.prompt("Pushing files done.");
return true;
}
protected PushForm getPushCommandForm ( )
{
PushForm pushForm = new PushForm();
pushForm.setBaseDir(projectConfiguration.getBasedir());
pushForm.setProjectName(projectConfiguration.getProjectName());
pushForm.setVersionName(projectConfiguration.getVersionName());
pushForm.setResourceNameSet(projectConfiguration.getResources());
pushForm.setJlotClientVersion(versionResolver.getJlotVersionName());
return pushForm;
}
}