Revision: 6575
http://squirrel-sql.svn.sourceforge.net/squirrel-sql/?rev=6575&view=rev
Author: manningr
Date: 2012-02-13 22:52:54 +0000 (Mon, 13 Feb 2012)
Log Message:
-----------
Initial version of utility that can scan independent source trees (not built in the same maven reactor) for circular dependencies between them.
Modified Paths:
--------------
trunk/maven-plugin-workspace/pom.xml
Added Paths:
-----------
trunk/maven-plugin-workspace/maven-utils/
trunk/maven-plugin-workspace/maven-utils/pom.xml
trunk/maven-plugin-workspace/maven-utils/src/
trunk/maven-plugin-workspace/maven-utils/src/main/
trunk/maven-plugin-workspace/maven-utils/src/main/java/
trunk/maven-plugin-workspace/maven-utils/src/main/java/net/
trunk/maven-plugin-workspace/maven-utils/src/main/java/net/sf/
trunk/maven-plugin-workspace/maven-utils/src/main/java/net/sf/squirrel_sql/
trunk/maven-plugin-workspace/maven-utils/src/main/java/net/sf/squirrel_sql/Main.java
trunk/maven-plugin-workspace/maven-utils/src/main/java/net/sf/squirrel_sql/MavenMultiTreeDependencyAnalyzer.java
trunk/maven-plugin-workspace/maven-utils/src/main/java/net/sf/squirrel_sql/MavenMultiTreeDependencyAnalyzerImpl.java
trunk/maven-plugin-workspace/maven-utils/src/main/java/net/sf/squirrel_sql/persistence/
trunk/maven-plugin-workspace/maven-utils/src/main/java/net/sf/squirrel_sql/persistence/PomDependency.java
trunk/maven-plugin-workspace/maven-utils/src/main/java/net/sf/squirrel_sql/persistence/PomDependencyDao.java
trunk/maven-plugin-workspace/maven-utils/src/main/java/net/sf/squirrel_sql/persistence/PomDependencyDaoImpl.java
trunk/maven-plugin-workspace/maven-utils/src/main/java/net/sf/squirrel_sql/persistence/PomDependencyFactory.java
trunk/maven-plugin-workspace/maven-utils/src/main/java/net/sf/squirrel_sql/persistence/PomDependencyFactoryImpl.java
trunk/maven-plugin-workspace/maven-utils/src/main/java/net/sf/squirrel_sql/persistence/PomDependencyImpl.java
trunk/maven-plugin-workspace/maven-utils/src/main/java/net/sf/squirrel_sql/persistence/PomFile.java
trunk/maven-plugin-workspace/maven-utils/src/main/java/net/sf/squirrel_sql/persistence/PomFileDao.java
trunk/maven-plugin-workspace/maven-utils/src/main/java/net/sf/squirrel_sql/persistence/PomFileDaoImpl.java
trunk/maven-plugin-workspace/maven-utils/src/main/java/net/sf/squirrel_sql/persistence/PomFileFactory.java
trunk/maven-plugin-workspace/maven-utils/src/main/java/net/sf/squirrel_sql/persistence/PomFileFactoryImpl.java
trunk/maven-plugin-workspace/maven-utils/src/main/java/net/sf/squirrel_sql/persistence/PomFileImpl.java
trunk/maven-plugin-workspace/maven-utils/src/main/java/net/sf/squirrel_sql/util/
trunk/maven-plugin-workspace/maven-utils/src/main/java/net/sf/squirrel_sql/util/PomFileUtils.java
trunk/maven-plugin-workspace/maven-utils/src/main/java/net/sf/squirrel_sql/util/PomFileUtilsFactory.java
trunk/maven-plugin-workspace/maven-utils/src/main/java/net/sf/squirrel_sql/util/PomFileUtilsFactoryImpl.java
trunk/maven-plugin-workspace/maven-utils/src/main/java/net/sf/squirrel_sql/util/PomFileUtilsImpl.java
trunk/maven-plugin-workspace/maven-utils/src/main/resources/
trunk/maven-plugin-workspace/maven-utils/src/main/resources/META-INF/
trunk/maven-plugin-workspace/maven-utils/src/main/resources/META-INF/persistence.xml
trunk/maven-plugin-workspace/maven-utils/src/main/resources/create.sql
trunk/maven-plugin-workspace/maven-utils/src/main/resources/dao.xml
trunk/maven-plugin-workspace/maven-utils/src/main/resources/drop.sql
trunk/maven-plugin-workspace/maven-utils/src/main/resources/logback.xml
trunk/maven-plugin-workspace/maven-utils/src/main/resources/select.sql
trunk/maven-plugin-workspace/maven-utils/src/main/resources/service.xml
Added: trunk/maven-plugin-workspace/maven-utils/pom.xml
===================================================================
--- trunk/maven-plugin-workspace/maven-utils/pom.xml (rev 0)
+++ trunk/maven-plugin-workspace/maven-utils/pom.xml 2012-02-13 22:52:54 UTC (rev 6575)
@@ -0,0 +1,149 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>net.sf.squirrel-sql</groupId>
+ <artifactId>maven-utils</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <packaging>jar</packaging>
+
+ <parent>
+ <groupId>org.sonatype.oss</groupId>
+ <artifactId>oss-parent</artifactId>
+ <version>7</version>
+ </parent>
+
+ <name>Maven Utilities</name>
+ <description>
+ This project provides a tool for scanning multiple independent source code trees for the purpose of
+ determining if there are circular dependencies between them. Since independent source trees will
+ not be in a single reactor, Maven cannot detect this condition.
+ </description>
+ <inceptionYear>2001</inceptionYear>
+ <developers>
+ <developer>
+ <name>Gerd Wagner</name>
+ <roles>
+ <role>Administrator</role>
+ <role>Developer</role>
+ </roles>
+ </developer>
+ <developer>
+ <name>Rob Manning</name>
+ <roles>
+ <role>Developer</role>
+ <role>Release Manager</role>
+ </roles>
+ </developer>
+ </developers>
+ <licenses>
+ <license>
+ <name>GNU Lesser General Public License</name>
+ <url>http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt</url>
+ <distribution>repo</distribution>
+ </license>
+ </licenses>
+ <url>http://www.squirrelsql.org/</url>
+ <scm>
+ <connection>scm:svn:https://squirrel-sql.svn.sourceforge.net/svnroot/squirrel-sql/trunk/maven-plugin-workspace/maven-utils</connection>
+ <developerConnection>scm:svn:https://squirrel-sql.svn.sourceforge.net/svnroot/squirrel-sql/trunk/maven-plugin-workspace/maven-utils</developerConnection>
+ <url>http://squirrel-sql.svn.sourceforge.net/viewvc/squirrel-sql/trunk/maven-plugin-workspace/maven-utils</url>
+ </scm>
+ <issueManagement>
+ <system>SourceForge Tracker</system>
+ <url>http://sourceforge.net/tracker/?group_id=28383%26atid=393414</url>
+ </issueManagement>
+ <ciManagement>
+ <system>Hudson</system>
+ <url>https://www.squirrel-sql.org/hudson/</url>
+ </ciManagement>
+ <dependencies>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>2.0.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-core</artifactId>
+ <version>4.0.1.Final</version>
+ </dependency>
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-entitymanager</artifactId>
+ <version>4.0.1.Final</version>
+ </dependency>
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-annotations</artifactId>
+ <version>3.5.6-Final</version>
+ </dependency>
+ <dependency>
+ <groupId>org.hibernate.java-persistence</groupId>
+ <artifactId>jpa-api</artifactId>
+ <version>2.0-cr-1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-beans</artifactId>
+ <version>3.0.5.RELEASE</version>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-context</artifactId>
+ <version>3.0.5.RELEASE</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-orm</artifactId>
+ <version>3.0.5.RELEASE</version>
+ </dependency>
+ <dependency>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
+ <version>1.3.153</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-model</artifactId>
+ <version>3.0.3</version>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-utils</artifactId>
+ <version>2.0.7</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-core</artifactId>
+ <version>3.0.3</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>jcl-over-slf4j</artifactId>
+ <version>1.6.4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>1.6.4</version>
+ </dependency>
+ <dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-classic</artifactId>
+ <version>1.0.0</version>
+ </dependency>
+ <dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-core</artifactId>
+ <version>1.0.0</version>
+ <type>pom</type>
+ </dependency>
+ </dependencies>
+
+</project>
Added: trunk/maven-plugin-workspace/maven-utils/src/main/java/net/sf/squirrel_sql/Main.java
===================================================================
--- trunk/maven-plugin-workspace/maven-utils/src/main/java/net/sf/squirrel_sql/Main.java (rev 0)
+++ trunk/maven-plugin-workspace/maven-utils/src/main/java/net/sf/squirrel_sql/Main.java 2012-02-13 22:52:54 UTC (rev 6575)
@@ -0,0 +1,46 @@
+package net.sf.squirrel_sql;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+public class Main
+{
+
+ /**
+ * @param args
+ */
+ public static void main(String[] args)
+ {
+ String[] appCtx = new String[] {
+ "classpath:dao.xml",
+ "classpath:service.xml",
+ };
+
+ ApplicationContext ctx = new ClassPathXmlApplicationContext(appCtx);
+ MavenMultiTreeDependencyAnalyzer analyzer = (MavenMultiTreeDependencyAnalyzer)
+ ctx.getBean("net.sf.squirrel_sql.MavenMultiTreeDependencyAnalyzer");
+
+ final List<String> pathList = new ArrayList<String>(args.length);
+ for (int i = 0; i < args.length; i++) {
+ pathList.add(args[i]);
+ }
+
+ analyzer.setSourceTreePaths(pathList);
+ try
+ {
+ analyzer.analyzePaths();
+ }
+ catch (IOException e)
+ {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ }
+
+}
Added: trunk/maven-plugin-workspace/maven-utils/src/main/java/net/sf/squirrel_sql/MavenMultiTreeDependencyAnalyzer.java
===================================================================
--- trunk/maven-plugin-workspace/maven-utils/src/main/java/net/sf/squirrel_sql/MavenMultiTreeDependencyAnalyzer.java (rev 0)
+++ trunk/maven-plugin-workspace/maven-utils/src/main/java/net/sf/squirrel_sql/MavenMultiTreeDependencyAnalyzer.java 2012-02-13 22:52:54 UTC (rev 6575)
@@ -0,0 +1,13 @@
+package net.sf.squirrel_sql;
+
+import java.io.IOException;
+import java.util.List;
+
+public interface MavenMultiTreeDependencyAnalyzer
+{
+
+ public abstract void analyzePaths() throws IOException;
+
+ public abstract void setSourceTreePaths(List<String> sourceTreePaths);
+
+}
\ No newline at end of file
Added: trunk/maven-plugin-workspace/maven-utils/src/main/java/net/sf/squirrel_sql/MavenMultiTreeDependencyAnalyzerImpl.java
===================================================================
--- trunk/maven-plugin-workspace/maven-utils/src/main/java/net/sf/squirrel_sql/MavenMultiTreeDependencyAnalyzerImpl.java (rev 0)
+++ trunk/maven-plugin-workspace/maven-utils/src/main/java/net/sf/squirrel_sql/MavenMultiTreeDependencyAnalyzerImpl.java 2012-02-13 22:52:54 UTC (rev 6575)
@@ -0,0 +1,158 @@
+package net.sf.squirrel_sql;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import net.sf.squirrel_sql.persistence.PomDependency;
+import net.sf.squirrel_sql.persistence.PomDependencyDao;
+import net.sf.squirrel_sql.persistence.PomDependencyFactory;
+import net.sf.squirrel_sql.persistence.PomFile;
+import net.sf.squirrel_sql.persistence.PomFileDao;
+import net.sf.squirrel_sql.persistence.PomFileFactory;
+import net.sf.squirrel_sql.util.PomFileUtils;
+import net.sf.squirrel_sql.util.PomFileUtilsFactory;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.filefilter.IOFileFilter;
+import org.apache.commons.io.filefilter.NameFileFilter;
+import org.apache.commons.io.filefilter.TrueFileFilter;
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.model.Dependency;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Required;
+import org.springframework.transaction.annotation.Transactional;
+
+public class MavenMultiTreeDependencyAnalyzerImpl implements MavenMultiTreeDependencyAnalyzer
+{
+ private static final Logger log = LoggerFactory.getLogger(MavenMultiTreeDependencyAnalyzerImpl.class);
+
+ private final IOFileFilter pomFileFilter = new NameFileFilter("pom.xml");
+
+ private List<String> sourceTreePaths;
+
+ private PomFileDao pomFileDao = null;
+
+ private PomDependencyDao pomDependencyDao = null;
+
+ private PomDependencyFactory pomDependencyFactory = null;
+
+ private PomFileFactory pomFileFactory = null;
+
+ private PomFileUtilsFactory pomFileUtilsFactory = null;
+
+ private List<PomFileUtils> pomFileUtilsList = null;
+
+ /**
+ * @throws IOException
+ * @see net.sf.squirrel_sql.MavenMultiTreeDependencyAnalyzer#analyzePaths()
+ */
+ @Transactional
+ public void analyzePaths() throws IOException
+ {
+ for (String sourceTreePath : sourceTreePaths)
+ {
+ File pathFile = new File(sourceTreePath);
+ analyzePath(pathFile);
+ }
+ }
+
+ private void analyzePath(File sourceTreePathFile) throws IOException
+ {
+ Iterator<File> pomFiles =
+ FileUtils.iterateFiles(sourceTreePathFile, pomFileFilter, TrueFileFilter.INSTANCE);
+ pomFileUtilsList = new ArrayList<PomFileUtils>();
+
+ // First pass will create a PomFileUtils object for each pom file and insert all pom file records, in
+ // preparation for the second pass.
+ while (pomFiles.hasNext())
+ {
+ File file = pomFiles.next();
+ if (file.getAbsolutePath().contains("/target/"))
+ {
+ continue;
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("Processing file: " + file);
+ }
+ PomFileUtils pomFileUtils = pomFileUtilsFactory.create(file);
+ pomFileUtilsList.add(pomFileUtils);
+
+ PomFile pomFile =
+ pomFileFactory.createPomFile(sourceTreePathFile.getAbsolutePath(), file.getAbsolutePath(),
+ pomFileUtils.getGroupId(), pomFileUtils.getArtifactId(), pomFileUtils.getProjectName());
+ pomFileDao.insertPom(pomFile);
+ }
+
+ // Second pass gets dependencies and if a dependency is on a pom from the first pass,
+ // it gets stored as a dependency.
+ for (PomFileUtils pomFileUtils : pomFileUtilsList)
+ {
+ PomFile pomFile =
+ pomFileDao.findByGroupIdAndArtifactId(pomFileUtils.getGroupId(), pomFileUtils.getArtifactId());
+ if (log.isDebugEnabled()) {
+ log.debug("Processing artifact: " + pomFileUtils.getArtifactId());
+ }
+
+ for (Dependency dependency: pomFileUtils.getDependencies()) {
+ if (log.isDebugEnabled()) {
+ log.debug("Processing artifact dependency: "+dependency);
+ }
+ PomFile dependsUponPomFile =
+ pomFileDao.findByGroupIdAndArtifactId(dependency.getGroupId(), dependency.getArtifactId());
+ if (dependsUponPomFile != null) {
+ PomDependency pomDependency =
+ pomDependencyFactory.createDependency(pomFile, dependsUponPomFile, dependency.getType());
+ pomDependencyDao.insertDependency(pomDependency);
+ }
+ }
+
+ }
+
+ }
+
+ @Override
+ public void setSourceTreePaths(List<String> sourceTreePaths)
+ {
+ this.sourceTreePaths = sourceTreePaths;
+ }
+
+ @Required
+ public void setPomFileDao(PomFileDao pomFileDao)
+ {
+ if (pomFileDao == null) { throw new IllegalArgumentException("pomFileDao cannot be null"); }
+ this.pomFileDao = pomFileDao;
+ }
+
+ @Required
+ public void setDependencyDao(PomDependencyDao pomDependencyDao)
+ {
+ if (pomDependencyDao == null) { throw new IllegalArgumentException("pomDependencyDao cannot be null"); }
+ this.pomDependencyDao = pomDependencyDao;
+ }
+
+ @Required
+ public void setDependencyFactory(PomDependencyFactory pomDependencyFactory)
+ {
+ if (pomDependencyFactory == null) { throw new IllegalArgumentException("pomDependencyFactory cannot be null"); }
+ this.pomDependencyFactory = pomDependencyFactory;
+ }
+
+ @Required
+ public void setPomFileFactory(PomFileFactory pomFileFactory)
+ {
+ if (pomFileFactory == null) { throw new IllegalArgumentException("pomFileFactory cannot be null"); }
+ this.pomFileFactory = pomFileFactory;
+ }
+
+ @Required
+ public void setPomFileUtilsFactory(PomFileUtilsFactory pomFileUtilsFactory)
+ {
+ if (pomFileUtilsFactory == null) { throw new IllegalArgumentException(
+ "pomFileUtilsFactory cannot be null"); }
+ this.pomFileUtilsFactory = pomFileUtilsFactory;
+ }
+}
Added: trunk/maven-plugin-workspace/maven-utils/src/main/java/net/sf/squirrel_sql/persistence/PomDependency.java
===================================================================
--- trunk/maven-plugin-workspace/maven-utils/src/main/java/net/sf/squirrel_sql/persistence/PomDependency.java (rev 0)
+++ trunk/maven-plugin-workspace/maven-utils/src/main/java/net/sf/squirrel_sql/persistence/PomDependency.java 2012-02-13 22:52:54 UTC (rev 6575)
@@ -0,0 +1,21 @@
+package net.sf.squirrel_sql.persistence;
+
+
+public interface PomDependency
+{
+
+ public abstract PomFile getPomFile();
+
+ public abstract void setPomFile(PomFile pomFile);
+
+ public abstract PomFile getDependsUponPomFile();
+
+ public abstract void setDependsUponPomFile(PomFile dependsUponPomFile);
+
+ public abstract Long getId();
+
+ public abstract Long getVersion();
+
+ public abstract String getType();
+
+}
\ No newline at end of file
Added: trunk/maven-plugin-workspace/maven-utils/src/main/java/net/sf/squirrel_sql/persistence/PomDependencyDao.java
===================================================================
--- trunk/maven-plugin-workspace/maven-utils/src/main/java/net/sf/squirrel_sql/persistence/PomDependencyDao.java (rev 0)
+++ trunk/maven-plugin-workspace/maven-utils/src/main/java/net/sf/squirrel_sql/persistence/PomDependencyDao.java 2012-02-13 22:52:54 UTC (rev 6575)
@@ -0,0 +1,8 @@
+package net.sf.squirrel_sql.persistence;
+
+public interface PomDependencyDao
+{
+
+ public abstract void insertDependency(PomDependency d);
+
+}
\ No newline at end of file
Added: trunk/maven-plugin-workspace/maven-utils/src/main/java/net/sf/squirrel_sql/persistence/PomDependencyDaoImpl.java
===================================================================
--- trunk/maven-plugin-workspace/maven-utils/src/main/java/net/sf/squirrel_sql/persistence/PomDependencyDaoImpl.java (rev 0)
+++ trunk/maven-plugin-workspace/maven-utils/src/main/java/net/sf/squirrel_sql/persistence/PomDependencyDaoImpl.java 2012-02-13 22:52:54 UTC (rev 6575)
@@ -0,0 +1,26 @@
+package net.sf.squirrel_sql.persistence;
+
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class PomDependencyDaoImpl implements PomDependencyDao
+{
+ private static final Logger log = LoggerFactory.getLogger(PomDependencyDaoImpl.class);
+
+ @PersistenceContext
+ private EntityManager em;
+
+ /**
+ * @see net.sf.squirrel_sql.persistence.PomDependencyDao#insertDependency(net.sf.squirrel_sql.DependencyImpl)
+ */
+ @Override
+ public void insertDependency(PomDependency d) {
+ if (log.isDebugEnabled()) {
+ log.debug("Persisting pom dependency: "+d);
+ }
+ em.persist(d);
+ }
+}
Added: trunk/maven-plugin-workspace/maven-utils/src/main/java/net/sf/squirrel_sql/persistence/PomDependencyFactory.java
===================================================================
--- trunk/maven-plugin-workspace/maven-utils/src/main/java/net/sf/squirrel_sql/persistence/PomDependencyFactory.java (rev 0)
+++ trunk/maven-plugin-workspace/maven-utils/src/main/java/net/sf/squirrel_sql/persistence/PomDependencyFactory.java 2012-02-13 22:52:54 UTC (rev 6575)
@@ -0,0 +1,9 @@
+package net.sf.squirrel_sql.persistence;
+
+
+public interface PomDependencyFactory
+{
+
+ public abstract PomDependency createDependency(PomFile pomFile, PomFile dependsUponPomFile, String type);
+
+}
\ No newline at end of file
Added: trunk/maven-plugin-workspace/maven-utils/src/main/java/net/sf/squirrel_sql/persistence/PomDependencyFactoryImpl.java
===================================================================
--- trunk/maven-plugin-workspace/maven-utils/src/main/java/net/sf/squirrel_sql/persistence/PomDependencyFactoryImpl.java (rev 0)
+++ trunk/maven-plugin-workspace/maven-utils/src/main/java/net/sf/squirrel_sql/persistence/PomDependencyFactoryImpl.java 2012-02-13 22:52:54 UTC (rev 6575)
@@ -0,0 +1,14 @@
+package net.sf.squirrel_sql.persistence;
+
+
+public class PomDependencyFactoryImpl implements PomDependencyFactory
+{
+ /**
+ * @see net.sf.squirrel_sql.persistence.PomFileFactory#createPomFile(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
+ */
+ @Override
+ public PomDependency createDependency(PomFile pomFile, PomFile dependsUponPomFile, String type)
+ {
+ return new PomDependencyImpl(pomFile, dependsUponPomFile, type);
+ }
+}
Added: trunk/maven-plugin-workspace/maven-utils/src/main/java/net/sf/squirrel_sql/persistence/PomDependencyImpl.java
===================================================================
--- trunk/maven-plugin-workspace/maven-utils/src/main/java/net/sf/squirrel_sql/persistence/PomDependencyImpl.java (rev 0)
+++ trunk/maven-plugin-workspace/maven-utils/src/main/java/net/sf/squirrel_sql/persistence/PomDependencyImpl.java 2012-02-13 22:52:54 UTC (rev 6575)
@@ -0,0 +1,126 @@
+/**
+ *
+ */
+package net.sf.squirrel_sql.persistence;
+
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.OneToOne;
+import javax.persistence.Table;
+import javax.persistence.UniqueConstraint;
+import javax.persistence.Version;
+
+
+/**
+ * @author manningr
+ *
+ */
+@Entity
+@Table(name="Dependency",
+uniqueConstraints = {@UniqueConstraint(columnNames={"pomFileId", "dependsUponPomFileId", "type"})}
+)
+public class PomDependencyImpl implements PomDependency
+{
+ @Id
+ @GeneratedValue(strategy=GenerationType.SEQUENCE)
+ private Long Id;
+
+ @Version
+ private Long version;
+
+ @OneToOne(cascade=CascadeType.ALL, targetEntity=PomFileImpl.class)
+ @JoinColumn(name = "pomFileId", nullable=false)
+ private PomFile pomFile;
+
+ @OneToOne(cascade=CascadeType.ALL, targetEntity=PomFileImpl.class)
+ @JoinColumn(name = "dependsUponPomFileId", nullable=false)
+ private PomFile dependsUponPomFile;
+
+ @Column(nullable=false)
+ private String type;
+
+ public PomDependencyImpl() {}
+
+ public PomDependencyImpl(PomFile pomFile, PomFile dependsUponPomFile, String type) {
+ this.pomFile = pomFile;
+ this.dependsUponPomFile = dependsUponPomFile;
+ this.type = type;
+ }
+
+ /**
+ * @see net.sf.squirrel_sql.persistence.PomDependency#getPomFile()
+ */
+ @Override
+ public PomFile getPomFile()
+ {
+ return pomFile;
+ }
+
+ /**
+ * @see net.sf.squirrel_sql.persistence.PomDependency#setPomFile(net.sf.squirrel_sql.persistence.PomFileImpl)
+ */
+ @Override
+ public void setPomFile(PomFile pomFile)
+ {
+ this.pomFile = pomFile;
+ }
+
+ /**
+ * @see net.sf.squirrel_sql.persistence.PomDependency#getDependsUponPomFile()
+ */
+ @Override
+ public PomFile getDependsUponPomFile()
+ {
+ return dependsUponPomFile;
+ }
+
+ /**
+ * @see net.sf.squirrel_sql.persistence.PomDependency#setDependsUponPomFile(net.sf.squirrel_sql.persistence.PomFileImpl)
+ */
+ @Override
+ public void setDependsUponPomFile(PomFile dependsUponPomFile)
+ {
+ this.dependsUponPomFile = dependsUponPomFile;
+ }
+
+ /**
+ * @see net.sf.squirrel_sql.persistence.PomDependency#getId()
+ */
+ @Override
+ public Long getId()
+ {
+ return Id;
+ }
+
+ /**
+ * @see net.sf.squirrel_sql.persistence.PomDependency#getVersion()
+ */
+ @Override
+ public Long getVersion()
+ {
+ return version;
+ }
+
+ /**
+ * @see net.sf.squirrel_sql.persistence.PomDependency#getType()
+ */
+ @Override
+ public String getType()
+ {
+ return type;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "PomDependencyImpl [Id=" + Id + ", version=" + version + ", pomFile=" + pomFile
+ + ", dependsUponPomFile=" + dependsUponPomFile + ", type=" + type + "]";
+ }
+
+
+}
Added: trunk/maven-plugin-workspace/maven-utils/src/main/java/net/sf/squirrel_sql/persistence/PomFile.java
===================================================================
--- trunk/maven-plugin-workspace/maven-utils/src/main/java/net/sf/squirrel_sql/persistence/PomFile.java (rev 0)
+++ trunk/maven-plugin-workspace/maven-utils/src/main/java/net/sf/squirrel_sql/persistence/PomFile.java 2012-02-13 22:52:54 UTC (rev 6575)
@@ -0,0 +1,20 @@
+package net.sf.squirrel_sql.persistence;
+
+public interface PomFile
+{
+
+ public abstract long getId();
+
+ public abstract String getPath();
+
+ public abstract String getProjectName();
+
+ public abstract String getTreeRootDir();
+
+ public abstract long getVersion();
+
+ public abstract String getProjectArtifactId();
+
+ public abstract String getProjectGroupId();
+
+}
\ No newline at end of file
Added: trunk/maven-plugin-workspace/maven-utils/src/main/java/net/sf/squirrel_sql/persistence/PomFileDao.java
===================================================================
--- trunk/maven-plugin-workspace/maven-utils/src/main/java/net/sf/squirrel_sql/persistence/PomFileDao.java (rev 0)
+++ trunk/maven-plugin-workspace/maven-utils/src/main/java/net/sf/squirrel_sql/persistence/PomFileDao.java 2012-02-13 22:52:54 UTC (rev 6575)
@@ -0,0 +1,10 @@
+package net.sf.squirrel_sql.persistence;
+
+public interface PomFileDao
+{
+
+ public abstract void insertPom(PomFile pomFile);
+
+ public abstract PomFile findByGroupIdAndArtifactId(String groupId, String artifactId);
+
+}
\ No newline at end of file
Added: trunk/maven-plugin-workspace/maven-utils/src/main/java/net/sf/squirrel_sql/persistence/PomFileDaoImpl.java
===================================================================
--- trunk/maven-plugin-workspace/maven-utils/src/main/java/net/sf/squirrel_sql/persistence/PomFileDaoImpl.java (rev 0)
+++ trunk/maven-plugin-workspace/maven-utils/src/main/java/net/sf/squirrel_sql/persistence/PomFileDaoImpl.java 2012-02-13 22:52:54 UTC (rev 6575)
@@ -0,0 +1,66 @@
+package net.sf.squirrel_sql.persistence;
+
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.Query;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Repository;
+import org.springframework.transaction.annotation.Transactional;
+
+@Repository
+public class PomFileDaoImpl implements PomFileDao
+{
+ private static final Logger log = LoggerFactory.getLogger(PomFileDaoImpl.class);
+
+ @PersistenceContext
+ EntityManager em;
+
+ private static String groupArtifactQuery =
+ "SELECT p FROM PomFileImpl p WHERE p.projectGroupId = :groupId AND p.projectArtifactId = :artifactId";
+
+ /**
+ * @see net.sf.squirrel_sql.persistence.PomFileDao#insertPom(net.sf.squirrel_sql.persistence.PomFileImpl)
+ */
+ @Transactional
+ public void insertPom(PomFile pomFile)
+ {
+ em.persist(pomFile);
+ }
+
+ /**
+ * @see net.sf.squirrel_sql.persistence.PomFileDao#findByGroupIdAndArtifactId(java.lang.String,
+ * java.lang.String)
+ */
+ @Override
+ @Transactional
+ public PomFile findByGroupIdAndArtifactId(String groupId, String artifactId)
+ {
+ if (log.isDebugEnabled())
+ {
+ log.debug("Searching for PomFile using groupId=" + groupId + " and artifactId=" + artifactId);
+ }
+ Query query = em.createQuery(groupArtifactQuery);
+ query.setParameter("groupId", groupId);
+ query.setParameter("artifactId", artifactId);
+ PomFile result = null;
+ try
+ {
+ result = (PomFile) query.getSingleResult();
+ }
+ catch (Exception e)
+ {
+ if (log.isTraceEnabled()) {
+ log.error("Couldn't locate PomFile using groupId=" + groupId + " and artifactId=" + artifactId
+ + ": " + e.getMessage(), e);
+ }
+ else if (log.isDebugEnabled())
+ {
+ log.error("Couldn't locate PomFile using groupId=" + groupId + " and artifactId=" + artifactId
+ + ": " + e.getMessage());
+ }
+ }
+ return result;
+ }
+}
Added: trunk/maven-plugin-workspace/maven-utils/src/main/java/net/sf/squirrel_sql/persistence/PomFileFactory.java
===================================================================
--- trunk/maven-plugin-workspace/maven-utils/src/main/java/net/sf/squirrel_sql/persistence/PomFileFactory.java (rev 0)
+++ trunk/maven-plugin-workspace/maven-utils/src/main/java/net/sf/squirrel_sql/persistence/PomFileFactory.java 2012-02-13 22:52:54 UTC (rev 6575)
@@ -0,0 +1,9 @@
+package net.sf.squirrel_sql.persistence;
+
+public interface PomFileFactory
+{
+
+ public abstract PomFile createPomFile(String treeRootDir, String path, String projectGroupId,
+ String projectArtifactId, String projectName);
+
+}
\ No newline at end of file
Added: trunk/maven-plugin-workspace/maven-utils/src/main/java/net/sf/squirrel_sql/persistence/PomFileFactoryImpl.java
===================================================================
--- trunk/maven-plugin-workspace/maven-utils/src/main/java/net/sf/squirrel_sql/persistence/PomFileFactoryImpl.java (rev 0)
+++ trunk/maven-plugin-workspace/maven-utils/src/main/java/net/sf/squirrel_sql/persistence/PomFileFactoryImpl.java 2012-02-13 22:52:54 UTC (rev 65...
[truncated message content] |