Search in sources :

Example 1 with SynergyTask

use of org.apache.maven.scm.provider.synergy.util.SynergyTask in project maven-scm by apache.

the class SynergyGetCompletedTasksConsumerTest method testSynergyGetCompletedTasksConsumer.

public void testSynergyGetCompletedTasksConsumer() throws IOException {
    InputStream inputStream = getResourceAsStream("/synergy/consumer/getCompletedTasks.txt");
    BufferedReader in = new BufferedReader(new InputStreamReader(inputStream));
    String s = in.readLine();
    SynergyGetCompletedTasksConsumer consumer = new SynergyGetCompletedTasksConsumer(new DefaultLog());
    while (s != null) {
        consumer.consumeLine(s);
        s = in.readLine();
    }
    Collection<SynergyTask> entries = consumer.getTasks();
    assertEquals("Wrong number of tasks returned", 1, entries.size());
    SynergyTask task = (SynergyTask) entries.iterator().next();
    assertEquals(35, task.getNumber());
    assertEquals("AHD456", task.getUsername());
    assertEquals("gefdeag", task.getComment());
    Calendar cal = Calendar.getInstance();
    cal.clear();
    cal.set(2006, Calendar.OCTOBER, 4, 15, 42, 47);
    assertEquals(cal.getTime(), task.getModifiedTime());
}
Also used : InputStreamReader(java.io.InputStreamReader) InputStream(java.io.InputStream) DefaultLog(org.apache.maven.scm.log.DefaultLog) Calendar(java.util.Calendar) BufferedReader(java.io.BufferedReader) SynergyTask(org.apache.maven.scm.provider.synergy.util.SynergyTask)

Example 2 with SynergyTask

use of org.apache.maven.scm.provider.synergy.util.SynergyTask in project maven-scm by apache.

the class SynergyChangeLogCommand method executeChangeLogCommand.

/**
 * {@inheritDoc}
 */
protected ChangeLogScmResult executeChangeLogCommand(ScmProviderRepository repository, ScmFileSet fileSet, Date startDate, Date endDate, ScmBranch branch, String datePattern) throws ScmException {
    if (getLogger().isDebugEnabled()) {
        getLogger().debug("executing changelog command...");
    }
    SynergyScmProviderRepository repo = (SynergyScmProviderRepository) repository;
    if (getLogger().isDebugEnabled()) {
        getLogger().debug("basedir: " + fileSet.getBasedir());
    }
    String ccmAddr = SynergyUtil.start(getLogger(), repo.getUser(), repo.getPassword(), null);
    List<ChangeSet> csList = new ArrayList<ChangeSet>();
    try {
        String projectSpec = SynergyUtil.getWorkingProject(getLogger(), repo.getProjectSpec(), repo.getUser(), ccmAddr);
        if (projectSpec == null) {
            throw new ScmException("You should checkout a working project first");
        }
        List<SynergyTask> tasks = SynergyUtil.getCompletedTasks(getLogger(), projectSpec, startDate, endDate, ccmAddr);
        for (SynergyTask t : tasks) {
            ChangeSet cs = new ChangeSet();
            cs.setAuthor(t.getUsername());
            cs.setComment("Task " + t.getNumber() + ": " + t.getComment());
            cs.setDate(t.getModifiedTime());
            cs.setFiles(SynergyUtil.getModifiedObjects(getLogger(), t.getNumber(), ccmAddr));
            csList.add(cs);
        }
    } finally {
        SynergyUtil.stop(getLogger(), ccmAddr);
    }
    return new ChangeLogScmResult("ccm query ...", new ChangeLogSet(csList, startDate, endDate));
}
Also used : ScmException(org.apache.maven.scm.ScmException) ChangeLogSet(org.apache.maven.scm.command.changelog.ChangeLogSet) SynergyScmProviderRepository(org.apache.maven.scm.provider.synergy.repository.SynergyScmProviderRepository) ArrayList(java.util.ArrayList) SynergyTask(org.apache.maven.scm.provider.synergy.util.SynergyTask) ChangeLogScmResult(org.apache.maven.scm.command.changelog.ChangeLogScmResult) ChangeSet(org.apache.maven.scm.ChangeSet)

Example 3 with SynergyTask

use of org.apache.maven.scm.provider.synergy.util.SynergyTask in project maven-scm by apache.

the class SynergyGetCompletedTasksConsumer method consumeLine.

/**
 * {@inheritDoc}
 */
public void consumeLine(String line) {
    if (getLogger().isDebugEnabled()) {
        getLogger().debug("Consume: " + line);
    }
    StringTokenizer tokenizer = new StringTokenizer(line.trim(), SynergyUtil.SEPARATOR);
    if (tokenizer.countTokens() == 4) {
        SynergyTask task = new SynergyTask();
        task.setNumber(Integer.parseInt(tokenizer.nextToken()));
        task.setUsername(tokenizer.nextToken());
        try {
            task.setModifiedTime(new SimpleDateFormat(ccmDateFormat, new Locale(language, country)).parse(tokenizer.nextToken()));
        } catch (ParseException e) {
            if (getLogger().isErrorEnabled()) {
                getLogger().error("Wrong date format", e);
            }
        }
        task.setComment(tokenizer.nextToken());
        // Add the task to the list
        entries.add(task);
    } else {
        if (getLogger().isErrorEnabled()) {
            getLogger().error("Invalid token count in SynergyGetCompletedTasksConsumer [" + tokenizer.countTokens() + "]");
        }
        if (getLogger().isDebugEnabled()) {
            while (tokenizer.hasMoreElements()) {
                getLogger().debug(tokenizer.nextToken());
            }
        }
    }
}
Also used : Locale(java.util.Locale) StringTokenizer(java.util.StringTokenizer) SynergyTask(org.apache.maven.scm.provider.synergy.util.SynergyTask) ParseException(java.text.ParseException) SimpleDateFormat(java.text.SimpleDateFormat)

Example 4 with SynergyTask

use of org.apache.maven.scm.provider.synergy.util.SynergyTask in project maven-scm by apache.

the class SynergyGetCompletedTasksConsumerTest method testSynergyGetCompletedTasksConsumerWithFrenchDate.

public void testSynergyGetCompletedTasksConsumerWithFrenchDate() throws IOException {
    InputStream inputStream = getResourceAsStream("/synergy/consumer/getCompletedTasksFrenchDate.txt");
    BufferedReader in = new BufferedReader(new InputStreamReader(inputStream));
    String s = in.readLine();
    System.setProperty(SynergyGetCompletedTasksConsumer.CCMDATEFORMAT_PROPERTY, "EEEE dd MMMM yyyy HH:mm:ss");
    System.setProperty(SynergyGetCompletedTasksConsumer.LANGUAGE_PROPERTY, "fr");
    System.setProperty(SynergyGetCompletedTasksConsumer.COUNTRY_PROPERTY, "FR");
    SynergyGetCompletedTasksConsumer consumer = new SynergyGetCompletedTasksConsumer(new DefaultLog());
    while (s != null) {
        consumer.consumeLine(s);
        s = in.readLine();
    }
    Collection<SynergyTask> entries = consumer.getTasks();
    assertEquals("Wrong number of tasks returned", 2, entries.size());
    Iterator<SynergyTask> i = entries.iterator();
    SynergyTask task = (SynergyTask) i.next();
    assertEquals(52, task.getNumber());
    assertEquals("ccm_root", task.getUsername());
    assertEquals("Modification du pom (url scm)", task.getComment());
    Calendar cal = Calendar.getInstance();
    cal.clear();
    cal.set(2006, Calendar.OCTOBER, 6, 10, 3, 59);
    assertEquals(cal.getTime(), task.getModifiedTime());
    task = (SynergyTask) i.next();
    assertEquals(53, task.getNumber());
    assertEquals("ccm_root", task.getUsername());
    assertEquals("Inverser l'odre purpose/release", task.getComment());
    cal.clear();
    cal.set(2006, Calendar.OCTOBER, 6, 10, 47, 13);
    assertEquals(cal.getTime(), task.getModifiedTime());
}
Also used : InputStreamReader(java.io.InputStreamReader) InputStream(java.io.InputStream) DefaultLog(org.apache.maven.scm.log.DefaultLog) Calendar(java.util.Calendar) BufferedReader(java.io.BufferedReader) SynergyTask(org.apache.maven.scm.provider.synergy.util.SynergyTask)

Aggregations

SynergyTask (org.apache.maven.scm.provider.synergy.util.SynergyTask)4 BufferedReader (java.io.BufferedReader)2 InputStream (java.io.InputStream)2 InputStreamReader (java.io.InputStreamReader)2 Calendar (java.util.Calendar)2 DefaultLog (org.apache.maven.scm.log.DefaultLog)2 ParseException (java.text.ParseException)1 SimpleDateFormat (java.text.SimpleDateFormat)1 ArrayList (java.util.ArrayList)1 Locale (java.util.Locale)1 StringTokenizer (java.util.StringTokenizer)1 ChangeSet (org.apache.maven.scm.ChangeSet)1 ScmException (org.apache.maven.scm.ScmException)1 ChangeLogScmResult (org.apache.maven.scm.command.changelog.ChangeLogScmResult)1 ChangeLogSet (org.apache.maven.scm.command.changelog.ChangeLogSet)1 SynergyScmProviderRepository (org.apache.maven.scm.provider.synergy.repository.SynergyScmProviderRepository)1