Incremental work on XML implementation.

This commit is contained in:
Jonathan Bernard 2011-05-27 10:25:57 -05:00
parent 482330d02a
commit 6c36d78b7d
106 changed files with 287 additions and 9 deletions

0
.hgignore Normal file → Executable file
View File

0
build.xml Normal file → Executable file
View File

0
libpit/build.xml Normal file → Executable file
View File

0
libpit/project.properties Normal file → Executable file
View File

0
libpit/release/pit-2.3.1.jar Normal file → Executable file
View File

0
libpit/session.vim Normal file → Executable file
View File

0
libpit/src/com/jdbernard/pit/Category.groovy Normal file → Executable file
View File

0
libpit/src/com/jdbernard/pit/Filter.groovy Normal file → Executable file
View File

0
libpit/src/com/jdbernard/pit/FlatProjectView.groovy Normal file → Executable file
View File

5
libpit/src/com/jdbernard/pit/Issue.groovy Normal file → Executable file
View File

@ -63,7 +63,8 @@ public abstract class Issue {
public void setDeliveryDate(Date dd) { deliveryDate = dd }
@Override
public String toString() { return "${id}(${priority}-${status}): ${category} ${title}" }
public String toString() {
return "${id}(${priority}-${status}): ${category} ${title}"
}
public abstract boolean delete()
}

4
libpit/src/com/jdbernard/pit/Project.groovy Normal file → Executable file
View File

@ -33,5 +33,7 @@ public abstract class Project {
public abstract Project createNewProject(String name)
public abstract boolean delete()
public abstract boolean deleteIssue(Issue issue)
public abstract boolean deleteProject(Project project)
}

View File

@ -0,0 +1,8 @@
package com.jdbernard.pit
public abstract class Repository {
public abstract void persist()
public abstract Project[] getRootProjects()
public abstract Project createNewProject(String name)
}

0
libpit/src/com/jdbernard/pit/Status.groovy Normal file → Executable file
View File

2
libpit/src/com/jdbernard/pit/file/FileIssue.groovy Normal file → Executable file
View File

@ -84,7 +84,7 @@ public class FileIssue extends Issue {
super.setText(text)
}
public boolean delete() { return source.delete() }
boolean deleteFile() { return source.deleteDir() }
public static boolean isValidFilename(String name) {
return name ==~ fileExp

20
libpit/src/com/jdbernard/pit/file/FileProject.groovy Normal file → Executable file
View File

@ -74,7 +74,25 @@ class FileProject extends Project {
return new FileProject(newDir)
}
public boolean delete() { return source.deleteDir() }
public boolean deleteIssue(Issue issue) {
if (!issues[(issue.id)]) return false
issues.remove(issue.id)
if (issue instanceof FileIssue)
return issue.deleteFile()
else return true
}
public boolean deleteProject(Project project) {
if (!projects[(project.name)]) return false
projects.remove(project.name)
if (project instanceof FileProject)
return project.source.delete()
return true
}
@Override
public String toString() { return name }

View File

@ -0,0 +1,22 @@
package com.jdbernard.pit.file
import com.jdbernard.pit.*
public class FileRepository extends Repository {
@Delegate FileProject fileProject
public FileRepository(File dir) {
assert dir.isDirectory()
fileProject = new FileProject(dir)
}
public void persist() {} // nothing to do
public Project[] getRootProjects() {
return fileProject.proejcts.values() as Project[]
}
public FileProject createNewProject(String name) {
return fileProject.createNewProject()
}
}

0
libpit/src/com/jdbernard/pit/util/Convert1_2.groovy Normal file → Executable file
View File

View File

@ -0,0 +1,64 @@
package com.jdbernard.pit.xml
import com.jdbernard.pit.*
public class XmlIssue extends Issue {
def issueNode
XmlProject project
XmlRepository repository
XmlIssue(def issueNode, XmlRepository repository, XmlProject project) {
super(issueNode.@id, issueNode.@category ?: Category.TASK,
issueNode.@status ?: Status.NEW, issueNode.@priority ?: 9)
this.issueNode = issueNode
this.project = project
this.repository = repository
}
XmlIssue(String id, Category c = Category.TASK, Status s = Status.NEW,
int p = 9, String text, XmlRepository repository, XmlProject project) {
super(id, c, s, p)
this.project = project
this.repository = repository
// Node constructor adds the node to the parent node
issueNode = new Node(project.projectNode, "Issue",
[id: id, category: c, status: s, priority: p])
this.text = text
issueNode.value = text
repository.persist()
}
public void setCategory(Category c) {
super.setCategory(c)
issueNode.@category = c.name()
repository.persist()
}
public void setStatus(Status s) {
super.setStatus(s)
issueNode.@status = s.name()
repository.persist()
}
public void setPriority(int p) {
super(p)
issueNode.@priority = p
repository.persist()
public void setText(String t) {
super.setText(t)
issueNode.value = t
repository.persist()
}
}

75
libpit/src/com/jdbernard/pit/xml/XmlProject.groovy Normal file → Executable file
View File

@ -4,5 +4,80 @@ import com.jdbernard.pit.*
public class XmlProject extends Project {
def projectNode
XmlRepository repository
XmlProject(def projectNode, XmlRepository repository) {
super(projectName.@name)
this.projectNode = projectNode
this.repository = repository
}
XmlProject(String name, def parentProject, XmlRepository repository) {
super(name)
// Node constructor adds the node to the parent node
projectNode = new Node(parentProject.projectNode, "Project",
[name: name])
repository.persist()
}
public void setName(String name) {
super(name)
projectNode.@name = name
repository.persist()
}
public XmlIssue createNewIssue(Map options) {
if (!options) options = [:]
if (!options.category) options.category = Category.TASK
if (!options.status) options.status = Status.NEW
if (!options.priority) options.priority = 5
if (!options.text) options.text = "Default issue title.\n" +
"====================\n"
String id
if (issues.size() == 0) id = "0000"
else {
id = (issues.values().max { it.id.toInteger() }).id
id = (id.toInteger() + 1).toString().padLeft(id.length(), '0')
}
// XmlIssue constructor will persist XML data
issues[(id)] = new XmlIssue(id, options.category, options.status,
options.priority, options.text, repository, this)
return issues[(id)]
}
public XmlProject createNewProject(String name) {
// XmlProject constructor persists the XML data
projects[(name)] = new XmlProject(name, this, repository)
return projects[(name)]
}
public boolean deleteIssue(Issue issue) {
if (!issues[(issue.id)]) return false
issues.remove(issue.id)
if (issue instanceof XmlIssue)
projectNode.remove(issue.issueNode)
repository.persist()
return true
}
public boolean deleteProject(Project project) {
if (!projects[(project.name)]) return false
projects.remove(project.name)
if (project instanceof XmlProject)
projectNode.remove(project.projectNode)
repository.persist()
}
}

View File

@ -0,0 +1,47 @@
package com.jdbernard.pit.xml
import com.jdbernard.pit.*
import groovy.xml.XmlUtil
public class XmlRepository extends Repository {
def repository
def projects = []
File repoFile
public XmlRepository(File repoFile) {
this.repoFile = repoFile
repository = new XmlParser().parse(repoFile)
repository.Project.each { projectNode ->
projects << new XmlProject(projectNode)
}
}
public synchronized void persist() {
repoFile.withOutputStream { XmlUtil.serialize(repository, it) }
}
public XmlProject[] getRootProjects() {
return projects as XmlProject[]
}
public XmlProject createNewProject(String name) {
def newProject = new XmlProject(name, this, null)
repository << newProject.projectNode
persist()
return newProject
}
public boolean deleteProject(Project p) {
if (!projects.contains(p)) return false
projects.remove(p)
repository.remove(p.projectNode)
return true
}
}

0
libpit/test/com/jdbernard/pit/CategoryTest.groovy Normal file → Executable file
View File

0
libpit/test/com/jdbernard/pit/FilterTest.groovy Normal file → Executable file
View File

0
libpit/test/com/jdbernard/pit/MockIssue.groovy Normal file → Executable file
View File

6
libpit/test/com/jdbernard/pit/MockProject.groovy Normal file → Executable file
View File

@ -5,11 +5,13 @@ class MockProject extends Project {
public MockProject(String name) { super(name) }
public Issue createNewIssue(Map options) {
throw new UnsupportedOperationException()
return new MockIssue(options.id ?: 'n/a',
options.c ?: Category.TASK, options.s ?: Status.NEW,
options.p ?: 5)
}
public Project createNewProject(String name) {
throw new UnsupportedOperationException()
return new MockProject(name)
}
public boolean delete() { return true }

View File

@ -0,0 +1,12 @@
package com.jdbernard.pit
class MockRepository extends Repository {
public void persist() {}
public Project[] getRootProjects() { return [] as Project[] }
public Project createNewProject(String name) {
return new MockProject(name)
}
}

0
libpit/test/com/jdbernard/pit/StatusTest.groovy Normal file → Executable file
View File

View File

@ -1,5 +1,6 @@
package com.jdbernard.pit
package com.jdbernard.pit.file
import com.jdbernard.pit.*
import org.junit.*
import static org.junit.Assert.assertTrue
import static org.junit.Assert.assertFalse

View File

@ -1,5 +1,6 @@
package com.jdbernard.pit
package com.jdbernard.pit.file
import com.jdbernard.pit.*
import org.junit.After
import org.junit.Before
import org.junit.Test

View File

@ -0,0 +1,25 @@
package com.jdbernard.pit.xml
import com.jdbernard.pit.*
import groovy.util.Node
import org.junit.Test
import static org.junit.Assert.assertEquals
import static org.junit.Assert.assertFalse
import static org.junit.Assert.assertTrue
public class XmlIssueTest {
Node issueNode = new Node(null, 'Issue',
[id: '0000', category: 'BUG', status: 'RESOLVED', priority: 1],
'Test Issue')
@Test public void testNodeConstructor() {
XmlIssue issue = new XmlIssue(issueNode,
assertEquals issue.text, 'Test Issue'
assertEquals issue.id, '0000'
assertEquals issue.category, Category.BUG
assertEquals issue.status, Status.RESOLVED
assertEquals issue.priority, 1
}
}

0
pit-cli/build.xml Normal file → Executable file
View File

0
pit-cli/lib/commons-cli-1.2.jar Normal file → Executable file
View File

0
pit-cli/lib/pit-2.1.0.jar Normal file → Executable file
View File

0
pit-cli/project.properties Normal file → Executable file
View File

0
pit-cli/release/pit-cli-2.1.0.jar Normal file → Executable file
View File

View File

0
pit-swing/application.properties Normal file → Executable file
View File

0
pit-swing/griffon-app/conf/Application.groovy Normal file → Executable file
View File

0
pit-swing/griffon-app/conf/BuildConfig.groovy Normal file → Executable file
View File

0
pit-swing/griffon-app/conf/Builder.groovy Normal file → Executable file
View File

0
pit-swing/griffon-app/conf/Config.groovy Normal file → Executable file
View File

0
pit-swing/griffon-app/conf/Events.groovy Normal file → Executable file
View File

0
pit-swing/griffon-app/conf/webstart/applet.html Normal file → Executable file
View File

0
pit-swing/griffon-app/conf/webstart/applet.jnlp Normal file → Executable file
View File

0
pit-swing/griffon-app/conf/webstart/application.jnlp Normal file → Executable file
View File

View File

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

View File

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 31 KiB

View File

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

View File

Before

Width:  |  Height:  |  Size: 5.1 KiB

After

Width:  |  Height:  |  Size: 5.1 KiB

View File

Before

Width:  |  Height:  |  Size: 5.8 KiB

After

Width:  |  Height:  |  Size: 5.8 KiB

0
pit-swing/griffon-app/conf/webstart/griffon.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

0
pit-swing/griffon-app/i18n/messages.properties Normal file → Executable file
View File

0
pit-swing/griffon-app/lifecycle/Initialize.groovy Normal file → Executable file
View File

0
pit-swing/griffon-app/lifecycle/Ready.groovy Normal file → Executable file
View File

0
pit-swing/griffon-app/lifecycle/Shutdown.groovy Normal file → Executable file
View File

0
pit-swing/griffon-app/lifecycle/Startup.groovy Normal file → Executable file
View File

0
pit-swing/griffon-app/lifecycle/Stop.groovy Normal file → Executable file
View File

View File

0
pit-swing/griffon-app/resources/bug.gif Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

0
pit-swing/griffon-app/resources/default-issue.css Normal file → Executable file
View File

0
pit-swing/griffon-app/resources/icon16x16.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 306 B

After

Width:  |  Height:  |  Size: 306 B

0
pit-swing/griffon-app/resources/icon32x32.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 411 B

After

Width:  |  Height:  |  Size: 411 B

0
pit-swing/griffon-app/resources/icon64x64.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 822 B

After

Width:  |  Height:  |  Size: 822 B

0
pit-swing/griffon-app/resources/log4j.properties Normal file → Executable file
View File

0
pit-swing/griffon-app/resources/new.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 146 B

After

Width:  |  Height:  |  Size: 146 B

0
pit-swing/griffon-app/resources/rst2xhtml.xsl Normal file → Executable file
View File

0
pit-swing/griffon-app/resources/splash.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 40 KiB

After

Width:  |  Height:  |  Size: 40 KiB

0
pit-swing/griffon-app/resources/splash.xcf Normal file → Executable file
View File

View File

0
pit-swing/griffonw Normal file → Executable file
View File

0
pit-swing/griffonw.bat Normal file → Executable file
View File

0
pit-swing/lib/commons-lang-2.4.jar Normal file → Executable file
View File

0
pit-swing/lib/commons-logging-1.1.1.jar Normal file → Executable file
View File

0
pit-swing/lib/commons-primitives-1.0.jar Normal file → Executable file
View File

0
pit-swing/lib/dom4j-1.6.1.jar Normal file → Executable file
View File

0
pit-swing/lib/jaxen-1.1.1.jar Normal file → Executable file
View File

0
pit-swing/lib/jrst-1.1.1.jar Normal file → Executable file
View File

0
pit-swing/lib/log4j-1.2.15.jar Normal file → Executable file
View File

0
pit-swing/lib/miglayout-3.7.1-swing.jar Normal file → Executable file
View File

0
pit-swing/lib/nuiton-i18n-1.1.jar Normal file → Executable file
View File

0
pit-swing/lib/pit-2.3.1.jar Normal file → Executable file
View File

0
pit-swing/lib/slf4j-api-1.6.0.jar Normal file → Executable file
View File

0
pit-swing/lib/slf4j-log4j12-1.6.0.jar Normal file → Executable file
View File

0
pit-swing/lib/substance.jar Normal file → Executable file
View File

0
pit-swing/lib/trident.jar Normal file → Executable file
View File

View File

View File

View File

0
pit-swing/test/integration/pit/swing/PITests.groovy Normal file → Executable file
View File

View File

Some files were not shown because too many files have changed in this diff Show More